Fangjie Hu 8 years ago
parent
commit
3ed8e3eefd
  1. 33
      designer/src/com/fr/design/module/DesignerModule.java
  2. 2
      designer/src/com/fr/poly/creator/ChartBlockCreator.java
  3. 18
      designer/src/com/fr/quickeditor/ChartQuickEditor.java
  4. 23
      designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java
  5. 36
      designer_base/src/com/fr/design/actions/core/ActionFactory.java
  6. 6
      designer_base/src/com/fr/design/actions/file/SwitchExistEnv.java
  7. 34
      designer_base/src/com/fr/design/data/DesignTableDataManager.java
  8. 1
      designer_base/src/com/fr/design/data/datapane/TableDataComboBox.java
  9. 37
      designer_base/src/com/fr/design/event/TemplateTreeDragSource.java
  10. 8
      designer_base/src/com/fr/design/file/HistoryTemplateListPane.java
  11. 2
      designer_base/src/com/fr/design/file/MutilTempalteTabPane.java
  12. 4
      designer_base/src/com/fr/design/fun/ElementUIProvider.java
  13. 4
      designer_base/src/com/fr/design/gui/chart/BaseChartPropertyPane.java
  14. 13
      designer_base/src/com/fr/design/gui/chart/ChartEditPaneProvider.java
  15. 3
      designer_base/src/com/fr/design/gui/frpane/UIComboBoxPane.java
  16. 3
      designer_base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java
  17. 1
      designer_base/src/com/fr/design/mainframe/HelpDialogManager.java
  18. 2
      designer_base/src/com/fr/design/module/DesignModuleFactory.java
  19. 8
      designer_base/src/com/fr/design/selection/QuickEditor.java
  20. 2
      designer_base/src/com/fr/start/BaseDesigner.java
  21. 4
      designer_chart/src/com/fr/design/chart/gui/active/DataSeriesActiveGlyph.java
  22. 4
      designer_chart/src/com/fr/design/chart/gui/active/action/SetAnalysisLineStyleAction.java
  23. 4
      designer_chart/src/com/fr/design/chart/gui/active/action/SetAxisStyleAction.java
  24. 4
      designer_chart/src/com/fr/design/chart/gui/active/action/SetChartStyleAciton.java
  25. 4
      designer_chart/src/com/fr/design/chart/gui/active/action/SetDataLabelStyleAction.java
  26. 4
      designer_chart/src/com/fr/design/chart/gui/active/action/SetDataSeriesAttrAction.java
  27. 4
      designer_chart/src/com/fr/design/chart/gui/active/action/SetDataSheetAction.java
  28. 4
      designer_chart/src/com/fr/design/chart/gui/active/action/SetLegendStyleAction.java
  29. 4
      designer_chart/src/com/fr/design/chart/gui/active/action/SetPlotStyleAction.java
  30. 4
      designer_chart/src/com/fr/design/chart/gui/active/action/SetTitleStyleAction.java
  31. 4
      designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java
  32. 143
      designer_chart/src/com/fr/design/mainframe/ChartAndWidgetPropertyPane.java
  33. 34
      designer_chart/src/com/fr/design/mainframe/ChartDesigner.java
  34. 134
      designer_chart/src/com/fr/design/mainframe/ChartDesignerPropertyPane.java
  35. 7
      designer_chart/src/com/fr/design/mainframe/ChartPropertyPane.java
  36. 47
      designer_chart/src/com/fr/design/mainframe/ChartUndoState.java
  37. 376
      designer_chart/src/com/fr/design/mainframe/JChart.java
  38. 16
      designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java
  39. 132
      designer_chart/src/com/fr/design/mainframe/actions/AbstractExportAction4JChart.java
  40. 68
      designer_chart/src/com/fr/design/mainframe/actions/ExcelExportAction4Chart.java
  41. 21
      designer_chart/src/com/fr/design/mainframe/actions/JChartAction.java
  42. 61
      designer_chart/src/com/fr/design/mainframe/actions/NewChartAction.java
  43. 65
      designer_chart/src/com/fr/design/mainframe/actions/PDFExportAction4Chart.java
  44. 66
      designer_chart/src/com/fr/design/mainframe/actions/PNGExportAction4Chart.java
  45. 1
      designer_chart/src/com/fr/design/mainframe/chart/AbstractChartAttrPane.java
  46. 16
      designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java
  47. 1
      designer_chart/src/com/fr/design/mainframe/chart/gui/ChartDataPane.java
  48. 32
      designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java
  49. 1
      designer_chart/src/com/fr/design/mainframe/chart/gui/data/DatabaseTableDataPane.java
  50. 1
      designer_chart/src/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java
  51. 6
      designer_chart/src/com/fr/design/mainframe/chart/gui/data/ReportDataPane.java
  52. 4
      designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartSwitchPane.java
  53. 94
      designer_chart/src/com/fr/design/mainframe/exporter/ExcelExporter4Chart.java
  54. 25
      designer_chart/src/com/fr/design/mainframe/exporter/Exporter4Chart.java
  55. 89
      designer_chart/src/com/fr/design/mainframe/exporter/ImageExporter4Chart.java
  56. 382
      designer_chart/src/com/fr/design/mainframe/exporter/PdfExporter4Chart.java
  57. 2
      designer_chart/src/com/fr/design/module/ChartDesignerModule.java
  58. 95
      designer_chart/src/com/fr/design/module/ChartStartModule.java
  59. 18
      designer_chart/src/com/fr/start/ChartSplashPane.java
  60. 406
      designer_chart/src/com/fr/start/Designer4Chart.java
  61. 22
      designer_form/src/com/fr/design/mainframe/CoverReportPane.java
  62. 6
      designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java

33
designer/src/com/fr/design/module/DesignerModule.java

@ -111,17 +111,17 @@ public class DesignerModule extends DesignModule {
*/ */
private void registerCellEditor() { private void registerCellEditor() {
ActionFactory.registerCellEditor(String.class, CellStringQuickEditor.getInstance()); ActionFactory.registerCellEditor(String.class, CellStringQuickEditor.class);
ActionFactory.registerCellEditor(Number.class, CellStringQuickEditor.getInstance()); ActionFactory.registerCellEditor(Number.class, CellStringQuickEditor.class);
ActionFactory.registerCellEditor(Formula.class, CellStringQuickEditor.getInstance()); ActionFactory.registerCellEditor(Formula.class, CellStringQuickEditor.class);
ActionFactory.registerCellEditor(SubReport.class, CellSubReportEditor.getInstance()); ActionFactory.registerCellEditor(SubReport.class, CellSubReportEditor.class);
ActionFactory.registerCellEditor(RichText.class, CellRichTextEditor.getInstance()); ActionFactory.registerCellEditor(RichText.class, CellRichTextEditor.class);
ActionFactory.registerCellEditor(DSColumn.class, CellDScolumnEditor.getInstance()); ActionFactory.registerCellEditor(DSColumn.class, CellDSColumnEditor.class);
ActionFactory.registerCellEditor(Image.class, CellImageQuickEditor.getInstance()); ActionFactory.registerCellEditor(Image.class, CellImageQuickEditor.class);
ActionFactory.registerCellEditor(BiasTextPainter.class, new CellBiasTextPainterEditor()); ActionFactory.registerCellEditor(BiasTextPainter.class, CellBiasTextPainterEditor.class);
ActionFactory.registerCellEditor(BufferedImage.class, CellImageQuickEditor.getInstance()); ActionFactory.registerCellEditor(BufferedImage.class, CellImageQuickEditor.class);
ActionFactory.registerChartCellEditorInEditor(ChartQuickEditor.getInstance()); ActionFactory.registerChartCellEditorInEditor(ChartQuickEditor.class);
Set<ElementUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING); Set<ElementUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING);
for (ElementUIProvider provider : providers) { for (ElementUIProvider provider : providers) {
@ -139,14 +139,13 @@ public class DesignerModule extends DesignModule {
* kunnat: 注册悬浮选中Editor * kunnat: 注册悬浮选中Editor
*/ */
private void registerFloatEditor() { private void registerFloatEditor() {
FloatStringQuickEditor floatStringQuickEditor = new FloatStringQuickEditor(); ActionFactory.registerFloatEditor(String.class, FloatStringQuickEditor.class);
ActionFactory.registerFloatEditor(String.class, floatStringQuickEditor); ActionFactory.registerFloatEditor(Formula.class, FloatStringQuickEditor.class);
ActionFactory.registerFloatEditor(Formula.class, floatStringQuickEditor);
FloatImageQuickEditor floatImageQuickEditor = new FloatImageQuickEditor(); FloatImageQuickEditor floatImageQuickEditor = new FloatImageQuickEditor();
ActionFactory.registerFloatEditor(Image.class, floatImageQuickEditor); ActionFactory.registerFloatEditor(Image.class, FloatImageQuickEditor.class);
ActionFactory.registerFloatEditor(BufferedImage.class, floatImageQuickEditor); ActionFactory.registerFloatEditor(BufferedImage.class, FloatImageQuickEditor.class);
ActionFactory.registerChartFloatEditorInEditor(ChartQuickEditor.getInstance()); ActionFactory.registerChartFloatEditorInEditor(ChartQuickEditor.class);
} }
/** /**

2
designer/src/com/fr/poly/creator/ChartBlockCreator.java

@ -142,7 +142,7 @@ public class ChartBlockCreator extends BlockCreator<PolyChartBlock> {
@Override @Override
public QuickEditor getQuickEditor(TargetComponent tc) { public QuickEditor getQuickEditor(TargetComponent tc) {
ChartQuickEditor quitEditor = ChartQuickEditor.getInstance(); ChartQuickEditor quitEditor = new ChartQuickEditor();
quitEditor.populate(tc); quitEditor.populate(tc);
return quitEditor; return quitEditor;
} }

18
designer/src/com/fr/quickeditor/ChartQuickEditor.java

@ -16,29 +16,17 @@ import com.fr.design.selection.QuickEditor;
import java.awt.*; import java.awt.*;
public class ChartQuickEditor extends QuickEditor<TargetComponent>{ public class ChartQuickEditor extends QuickEditor<TargetComponent>{
private static ChartQuickEditor THIS;
// kunsnat: editingPropertyPane初始化 避开设计器启动, 在用到的时候再初始化. // kunsnat: editingPropertyPane初始化 避开设计器启动, 在用到的时候再初始化.
private BaseChartPropertyPane editingPropertyPane = null; //private BaseChartPropertyPane editingPropertyPane = null;
public static final ChartQuickEditor getInstance() {
if(THIS == null) {
THIS = new ChartQuickEditor();
}
return THIS;
}
private ChartQuickEditor() { public ChartQuickEditor() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
setBorder(null); setBorder(null);
} }
@Override @Override
protected void refresh() { protected void refresh() {
if(editingPropertyPane != null) { BaseChartPropertyPane editingPropertyPane = null;
remove(editingPropertyPane);
}
BaseChartCollection collection = null; BaseChartCollection collection = null;
if(tc instanceof PolyDesigner) { if(tc instanceof PolyDesigner) {
ChartBlockEditor chartBlockEditor = (ChartBlockEditor)((PolyDesigner)tc).getSelection().getEditor(); ChartBlockEditor chartBlockEditor = (ChartBlockEditor)((PolyDesigner)tc).getSelection().getEditor();

23
designer/src/com/fr/quickeditor/cellquick/CellDScolumnEditor.java → designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

@ -16,7 +16,7 @@ import java.awt.*;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
public class CellDScolumnEditor extends CellQuickEditor { public class CellDSColumnEditor extends CellQuickEditor {
private JPanel dsColumnRegion; private JPanel dsColumnRegion;
private JPanel centerPane; private JPanel centerPane;
private SelectedDataColumnPane dataPane; private SelectedDataColumnPane dataPane;
@ -55,16 +55,7 @@ public class CellDScolumnEditor extends CellQuickEditor {
} }
}; };
private static CellDScolumnEditor THIS; private CellDSColumnEditor() {
public static final CellDScolumnEditor getInstance() {
if (THIS == null) {
THIS = new CellDScolumnEditor();
}
return THIS;
}
private CellDScolumnEditor() {
super(); super();
} }
@ -107,4 +98,14 @@ public class CellDScolumnEditor extends CellQuickEditor {
this.validate(); this.validate();
} }
/**
* for 关闭时候释放
*/
public void release () {
super.release();
dsColumnRegion = null;
centerPane = null;
}
} }

36
designer_base/src/com/fr/design/actions/core/ActionFactory.java

@ -10,6 +10,7 @@ import com.fr.design.selection.QuickEditor;
import javax.swing.*; import javax.swing.*;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.*; import java.util.*;
/** /**
@ -22,11 +23,11 @@ public class ActionFactory {
private ActionFactory() { private ActionFactory() {
} }
private static Map<Class, QuickEditor> floatEditor = new HashMap<Class, QuickEditor>(); private static Map<Class, Class<? extends QuickEditor>> floatEditor = new HashMap<Class, Class<? extends QuickEditor>>();
private static Class chartCollectionClass = null; private static Class chartCollectionClass = null;
private static Map<Class, QuickEditor> cellEditor = new HashMap<Class, QuickEditor>(); private static Map<Class, Class<? extends QuickEditor>> cellEditor = new HashMap<Class, Class<? extends QuickEditor>>();
private static UpdateAction chartPreStyleAction = null; private static UpdateAction chartPreStyleAction = null;
@ -36,17 +37,18 @@ public class ActionFactory {
* @param clazz 待说明 * @param clazz 待说明
* @param editor 待说明 * @param editor 待说明
*/ */
public static void registerCellEditor(Class clazz, QuickEditor editor) { public static void registerCellEditor(Class clazz, Class<? extends QuickEditor> editor) {
cellEditor.put(clazz, editor); cellEditor.put(clazz, editor);
} }
/** /**
* 待说明 * 待说明
* *
* @param clazz 待说明 * @param clazz 待说明
* @param editor 待说明 * @param editor 待说明
*/ */
public static void registerFloatEditor(Class clazz, QuickEditor editor) { public static void registerFloatEditor(Class clazz, Class<? extends QuickEditor> editor) {
floatEditor.put(clazz, editor); floatEditor.put(clazz, editor);
} }
@ -84,7 +86,7 @@ public class ActionFactory {
* *
* @param editor 待说明 * @param editor 待说明
*/ */
public static void registerChartFloatEditorInEditor(QuickEditor editor) { public static void registerChartFloatEditorInEditor(Class<? extends QuickEditor> editor) {
if (chartCollectionClass != null) { if (chartCollectionClass != null) {
floatEditor.put(chartCollectionClass, editor); floatEditor.put(chartCollectionClass, editor);
} }
@ -95,7 +97,7 @@ public class ActionFactory {
* *
* @param editor 待说明 * @param editor 待说明
*/ */
public static void registerChartCellEditorInEditor(QuickEditor editor) { public static void registerChartCellEditorInEditor(Class<? extends QuickEditor> editor) {
if (chartCollectionClass != null) { if (chartCollectionClass != null) {
cellEditor.put(chartCollectionClass, editor); cellEditor.put(chartCollectionClass, editor);
} }
@ -105,11 +107,29 @@ public class ActionFactory {
* 返回 悬浮元素选中的Editor * 返回 悬浮元素选中的Editor
*/ */
public static QuickEditor getFloatEditor(Class clazz) { public static QuickEditor getFloatEditor(Class clazz) {
return floatEditor.get(clazz); return createEditor(clazz, floatEditor);
}
private static QuickEditor createEditor(Class clazz, Map<Class, Class<? extends QuickEditor>> editorMap) {
Class<? extends QuickEditor> c = editorMap.get(clazz);
try {
Constructor<? extends QuickEditor> constructor = c.getDeclaredConstructor();
constructor.setAccessible(true);
return constructor.newInstance();
} catch (NoSuchMethodException e) {
FRContext.getLogger().error(e.getMessage(), e);
} catch (IllegalAccessException e) {
FRContext.getLogger().error(e.getMessage(), e);
} catch (InstantiationException e) {
FRContext.getLogger().error(e.getMessage(), e);
} catch (InvocationTargetException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
return null;
} }
public static QuickEditor getCellEditor(Class clazz) { public static QuickEditor getCellEditor(Class clazz) {
return cellEditor.get(clazz); return createEditor(clazz, cellEditor);
} }
/** /**

6
designer_base/src/com/fr/design/actions/file/SwitchExistEnv.java

@ -10,6 +10,7 @@ import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.TemplatePane; import com.fr.design.mainframe.TemplatePane;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
@ -41,13 +42,16 @@ public class SwitchExistEnv extends MenuDef {
this.setName(getMenuKeySet().getMenuName()); this.setName(getMenuKeySet().getMenuName());
this.setHasScrollSubMenu(true); this.setHasScrollSubMenu(true);
initMenuDef(); initMenuDef();
GeneralContext.addEnvWillChangedListener(new EnvChangedListener() { JTemplate<?, ?> t = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if(t != null) {
GeneralContext.addEnvWillChangedListener(t.getFullPathName(), new EnvChangedListener() {
public void envChanged() { public void envChanged() {
SwitchExistEnv.this.clearShortCuts(); SwitchExistEnv.this.clearShortCuts();
initMenuDef(); initMenuDef();
} }
}); });
} }
}
private void initMenuDef() { private void initMenuDef() {
//ButtonGroup group = new ButtonGroup(); //ButtonGroup group = new ButtonGroup();

34
designer_base/src/com/fr/design/data/DesignTableDataManager.java

@ -13,8 +13,10 @@ import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.data.impl.storeproc.StoreProcedureConstants; import com.fr.data.impl.storeproc.StoreProcedureConstants;
import com.fr.design.data.tabledata.wrapper.*; import com.fr.design.data.tabledata.wrapper.*;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.iprogressbar.AutoProgressBar; import com.fr.design.gui.iprogressbar.AutoProgressBar;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.parameter.ParameterInputPane; import com.fr.design.parameter.ParameterInputPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.file.DatasourceManager; import com.fr.file.DatasourceManager;
@ -34,6 +36,7 @@ import java.io.ByteArrayOutputStream;
import java.text.Collator; import java.text.Collator;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* 设计器管理操作数据集的类: * 设计器管理操作数据集的类:
@ -54,7 +57,10 @@ public abstract class DesignTableDataManager {
*/ */
private static java.util.Map<String, TableDataWrapper> globalDsCache = new java.util.HashMap<String, TableDataWrapper>(); private static java.util.Map<String, TableDataWrapper> globalDsCache = new java.util.HashMap<String, TableDataWrapper>();
private static java.util.Map<String, String> dsNameChangedMap = new HashMap<String, String>(); private static java.util.Map<String, String> dsNameChangedMap = new HashMap<String, String>();
private static List<ChangeListener> dsListeners = new ArrayList<ChangeListener>(); // private static List<ChangeListener> dsListeners = new ArrayList<ChangeListener>();
private static Map<String, List<ChangeListener>> dsListenersMap = new HashMap<String, List<ChangeListener>>();
public static String NO_PARAMETER = "no_paramater_pane"; public static String NO_PARAMETER = "no_paramater_pane";
@ -73,6 +79,8 @@ public abstract class DesignTableDataManager {
* 响应数据集改变. * 响应数据集改变.
*/ */
private static void fireDsChanged() { private static void fireDsChanged() {
for(Entry<String, List<ChangeListener>> listenerEntry : dsListenersMap.entrySet()) {
List<ChangeListener> dsListeners = listenerEntry.getValue();
for (int i = 0; i < dsListeners.size(); i++) { for (int i = 0; i < dsListeners.size(); i++) {
//增强for循环用的iterator实现的, 如果中间哪个listener修改或删除了(如ChartEditPane.dsChangeListener), //增强for循环用的iterator实现的, 如果中间哪个listener修改或删除了(如ChartEditPane.dsChangeListener),
// 由于dsListeners是arraylist, 此时会ConcurrentModifyException // 由于dsListeners是arraylist, 此时会ConcurrentModifyException
@ -81,6 +89,20 @@ public abstract class DesignTableDataManager {
dsListeners.get(i).stateChanged(e); dsListeners.get(i).stateChanged(e);
} }
} }
}
public static void closeTemplate(JTemplate<?,?> template) {
if(template != null) {
dsListenersMap.remove(template.getFullPathName());
}
}
public static void envChange() {
dsListenersMap.clear();
dsNameChangedMap.clear();
clearGlobalDs();
}
/** /**
* 响应数据集改变 * 响应数据集改变
@ -127,6 +149,16 @@ public abstract class DesignTableDataManager {
* @param l ChangeListener监听器 * @param l ChangeListener监听器
*/ */
public static void addDsChangeListener(ChangeListener l) { public static void addDsChangeListener(ChangeListener l) {
JTemplate<?, ?> template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
String key = StringUtils.EMPTY;
if(template != null) {
key = template.getFullPathName();
}
List<ChangeListener> dsListeners = dsListenersMap.get(key);
if (dsListeners == null) {
dsListeners = new ArrayList<ChangeListener>();
dsListenersMap.put(key, dsListeners);
}
dsListeners.add(l); dsListeners.add(l);
} }

1
designer_base/src/com/fr/design/data/datapane/TableDataComboBox.java

@ -146,4 +146,5 @@ public class TableDataComboBox extends UIComboBox implements Prepare4DataSourceC
} }
}); });
} }
} }

37
designer_base/src/com/fr/design/event/TemplateTreeDragSource.java

@ -1,37 +0,0 @@
package com.fr.design.event;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.mainframe.dnd.ArrayTransferable;
import com.fr.design.mainframe.dnd.SerializableTransferable;
import com.fr.general.web.ParameterConsts;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.dnd.DragGestureEvent;
import java.awt.dnd.DragGestureListener;
import java.awt.dnd.DragSource;
import java.awt.dnd.DragSourceAdapter;
/**
* Created with IntelliJ IDEA.
* User: richie
* Date: 13-11-4
* Time: 下午2:17
*/
public class TemplateTreeDragSource extends DragSourceAdapter implements DragGestureListener {
private DragSource source;
public TemplateTreeDragSource(JTree tree, int actions) {
source = new DragSource();
source.createDefaultDragGestureRecognizer(tree, actions, this);
}
public void dragGestureRecognized(DragGestureEvent dge) {
Component comp = dge.getComponent();
if (comp instanceof TemplateFileTree) {
String selectedPath = ((TemplateFileTree)comp).getSelectedTemplatePath();
source.startDrag(dge, DragSource.DefaultLinkDrop, new SerializableTransferable(selectedPath), this);
}
}
}

8
designer_base/src/com/fr/design/file/HistoryTemplateListPane.java

@ -9,8 +9,11 @@ import java.util.logging.Level;
import javax.swing.*; import javax.swing.*;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
@ -24,9 +27,11 @@ import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilist.UIList; import com.fr.design.gui.ilist.UIList;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.module.DesignModuleFactory;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.GeneralContext;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
@ -102,6 +107,9 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations {
* @param selected 选择的 * @param selected 选择的
*/ */
public void closeSelectedReport(JTemplate<?, ?> selected) { public void closeSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected);
GeneralContext.removeEnvWillChangedListener(selected.getFullPathName());
if (contains(selected) == -1) { if (contains(selected) == -1) {
return; return;
} }

2
designer_base/src/com/fr/design/file/MutilTempalteTabPane.java

File diff suppressed because one or more lines are too long

4
designer_base/src/com/fr/design/fun/ElementUIProvider.java

@ -13,7 +13,7 @@ public interface ElementUIProvider extends Mutable {
String MARK_STRING = "ElementUIProvider"; String MARK_STRING = "ElementUIProvider";
int CURRENT_LEVEL = 1; int CURRENT_LEVEL = 2;
/** /**
* 单元格元素编辑器 * 单元格元素编辑器
@ -31,7 +31,7 @@ public interface ElementUIProvider extends Mutable {
* 右侧的快速编辑器 * 右侧的快速编辑器
* @return 编辑器 * @return 编辑器
*/ */
QuickEditor<?> quickEditor(); Class<? extends QuickEditor> quickEditor();
/** /**
* 插件单元格元素 * 插件单元格元素

4
designer_base/src/com/fr/design/gui/chart/BaseChartPropertyPane.java

@ -21,5 +21,7 @@ public abstract class BaseChartPropertyPane extends DockingView {
public abstract void populateChartPropertyPane(BaseChartCollection collection, TargetComponent<?> ePane); public abstract void populateChartPropertyPane(BaseChartCollection collection, TargetComponent<?> ePane);
public abstract void setWidgetPropertyPane(BaseWidgetPropertyPane pane); public abstract ChartEditPaneProvider getChartEditPane();
//public abstract void clear();
} }

13
designer_base/src/com/fr/design/gui/chart/ChartEditPaneProvider.java

@ -0,0 +1,13 @@
package com.fr.design.gui.chart;
/**
* Created by daniel on 2016/11/2.
*/
public interface ChartEditPaneProvider {
void gotoPane(String... id);
void fire();
}

3
designer_base/src/com/fr/design/gui/frpane/UIComboBoxPane.java

@ -153,4 +153,7 @@ public abstract class UIComboBoxPane<T> extends BasicBeanPane<T> {
return this.cards; return this.cards;
} }
public void clear() {
reset();
}
} }

3
designer_base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java

@ -2,13 +2,11 @@ package com.fr.design.gui.itree.filetree;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.dnd.DnDConstants;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.event.TemplateTreeDragSource;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import javax.swing.JTree; import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeCellRenderer;
@ -74,7 +72,6 @@ public class EnvFileTree extends RefreshableJTree {
this.setRootVisible(false); this.setRootVisible(false);
this.setShowsRootHandles(true); this.setShowsRootHandles(true);
this.setEditable(false); this.setEditable(false);
new TemplateTreeDragSource(this, DnDConstants.ACTION_COPY);
} }
// CellRenderer // CellRenderer

1
designer_base/src/com/fr/design/mainframe/HelpDialogManager.java

@ -40,5 +40,6 @@ public class HelpDialogManager {
if (handler != null) { if (handler != null) {
handler.destroyHelpDialog(); handler.destroyHelpDialog();
} }
handler = null;
} }
} }

2
designer_base/src/com/fr/design/module/DesignModuleFactory.java

File diff suppressed because one or more lines are too long

8
designer_base/src/com/fr/design/selection/QuickEditor.java

@ -41,6 +41,14 @@ public abstract class QuickEditor<T extends TargetComponent> extends JComponent
protected abstract void refresh(); protected abstract void refresh();
/**
* for 关闭时候释放
*/
public void release () {
tc = null;
}
public static QuickEditor DEFAULT_EDITOR = new QuickEditor() { public static QuickEditor DEFAULT_EDITOR = new QuickEditor() {
@Override @Override

2
designer_base/src/com/fr/start/BaseDesigner.java

@ -248,7 +248,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
}); });
df.setVisible(true); df.setVisible(true);
} catch (Exception e) { } catch (Exception e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage(), e);
if (!isException) { if (!isException) {
showDesignerFrame(args, df, true); showDesignerFrame(args, df, true);
} else { } else {

4
designer_chart/src/com/fr/design/chart/gui/active/DataSeriesActiveGlyph.java

@ -6,8 +6,8 @@ import com.fr.base.chart.Glyph;
import com.fr.chart.chartglyph.DataSeries; import com.fr.chart.chartglyph.DataSeries;
import com.fr.chart.chartglyph.PlotGlyph; import com.fr.chart.chartglyph.PlotGlyph;
import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
/** /**
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
@ -36,7 +36,7 @@ public class DataSeriesActiveGlyph extends ActiveGlyph {
return; return;
} }
ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_SERIES_TITLE); DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_SERIES_TITLE);
} }
@Override @Override

4
designer_chart/src/com/fr/design/chart/gui/active/action/SetAnalysisLineStyleAction.java

@ -3,8 +3,8 @@ package com.fr.design.chart.gui.active.action;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
import com.fr.general.Inter; import com.fr.general.Inter;
public class SetAnalysisLineStyleAction extends ChartComponentAction{ public class SetAnalysisLineStyleAction extends ChartComponentAction{
@ -20,7 +20,7 @@ public class SetAnalysisLineStyleAction extends ChartComponentAction{
} }
public void showAnalysisLineStylePane(){ public void showAnalysisLineStylePane(){
ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_LINE_TITLE); DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_LINE_TITLE);
} }

4
designer_chart/src/com/fr/design/chart/gui/active/action/SetAxisStyleAction.java

@ -3,8 +3,8 @@ package com.fr.design.chart.gui.active.action;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -28,6 +28,6 @@ public class SetAxisStyleAction extends ChartComponentAction {
public void showAxisStylePane() { public void showAxisStylePane() {
String axisType = getActiveAxisGlyph() == null ? StringUtils.EMPTY : getActiveAxisGlyph().getAxisType(); String axisType = getActiveAxisGlyph() == null ? StringUtils.EMPTY : getActiveAxisGlyph().getAxisType();
ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_AXIS_TITLE, axisType); DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_AXIS_TITLE, axisType);
} }
} }

4
designer_chart/src/com/fr/design/chart/gui/active/action/SetChartStyleAciton.java

@ -3,8 +3,8 @@ package com.fr.design.chart.gui.active.action;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
import com.fr.general.Inter; import com.fr.general.Inter;
/** /**
@ -26,6 +26,6 @@ public class SetChartStyleAciton extends ChartComponentAction {
} }
public void showChartStylePane() { public void showChartStylePane() {
ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_AREA_TITLE, PaneTitleConstants.CHART_STYLE_AREA_AREA_TITLE); DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_AREA_TITLE, PaneTitleConstants.CHART_STYLE_AREA_AREA_TITLE);
} }
} }

4
designer_chart/src/com/fr/design/chart/gui/active/action/SetDataLabelStyleAction.java

@ -3,8 +3,8 @@ package com.fr.design.chart.gui.active.action;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
import com.fr.general.Inter; import com.fr.general.Inter;
public class SetDataLabelStyleAction extends ChartComponentAction{ public class SetDataLabelStyleAction extends ChartComponentAction{
@ -20,7 +20,7 @@ public class SetDataLabelStyleAction extends ChartComponentAction{
} }
public void showDataLabelStylePane() { public void showDataLabelStylePane() {
ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_LABEL_TITLE); DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_LABEL_TITLE);
} }
} }

4
designer_chart/src/com/fr/design/chart/gui/active/action/SetDataSeriesAttrAction.java

@ -3,8 +3,8 @@ package com.fr.design.chart.gui.active.action;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
import com.fr.general.Inter; import com.fr.general.Inter;
/** /**
@ -21,6 +21,6 @@ public class SetDataSeriesAttrAction extends ChartComponentAction {
} }
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_SERIES_TITLE); DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_SERIES_TITLE);
} }
} }

4
designer_chart/src/com/fr/design/chart/gui/active/action/SetDataSheetAction.java

@ -3,8 +3,8 @@ package com.fr.design.chart.gui.active.action;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
import com.fr.general.Inter; import com.fr.general.Inter;
/** /**
@ -28,6 +28,6 @@ public class SetDataSheetAction extends ChartComponentAction {
} }
public void showDataSheetStylePane() { public void showDataSheetStylePane() {
ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_DATA_TITLE); DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_DATA_TITLE);
} }
} }

4
designer_chart/src/com/fr/design/chart/gui/active/action/SetLegendStyleAction.java

@ -3,8 +3,8 @@ package com.fr.design.chart.gui.active.action;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
import com.fr.general.Inter; import com.fr.general.Inter;
/** /**
@ -27,6 +27,6 @@ public class SetLegendStyleAction extends ChartComponentAction {
} }
public void showLegendStylePane() { public void showLegendStylePane() {
ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_LEGNED_TITLE); DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_LEGNED_TITLE);
} }
} }

4
designer_chart/src/com/fr/design/chart/gui/active/action/SetPlotStyleAction.java

@ -3,8 +3,8 @@ package com.fr.design.chart.gui.active.action;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
import com.fr.general.Inter; import com.fr.general.Inter;
/** /**
@ -27,6 +27,6 @@ public class SetPlotStyleAction extends ChartComponentAction {
} }
public void showPlotPane() { public void showPlotPane() {
ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_AREA_TITLE, PaneTitleConstants.CHART_STYLE_AREA_PLOT_TITLE); DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_AREA_TITLE, PaneTitleConstants.CHART_STYLE_AREA_PLOT_TITLE);
} }
} }

4
designer_chart/src/com/fr/design/chart/gui/active/action/SetTitleStyleAction.java

@ -3,8 +3,8 @@ package com.fr.design.chart.gui.active.action;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.module.DesignModuleFactory;
import com.fr.general.Inter; import com.fr.general.Inter;
/** /**
@ -27,6 +27,6 @@ public class SetTitleStyleAction extends ChartComponentAction {
} }
public void showTitlePane() { public void showTitlePane() {
ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_TITLE_TITLE); DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_TITLE_TITLE);
} }
} }

4
designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java

@ -13,8 +13,8 @@ import com.fr.design.editor.ValueEditorPaneFactory;
import com.fr.design.gui.itableeditorpane.ParameterTableModel; import com.fr.design.gui.itableeditorpane.ParameterTableModel;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.ChartHyperEditPane; import com.fr.design.mainframe.chart.ChartHyperEditPane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.Inter; import com.fr.general.Inter;
@ -130,7 +130,7 @@ public class ChartHyperPoplinkPane extends BasicBeanPane<ChartHyperPoplink> {
hyperEditPane.updateHyperLink(chartHyperlink); hyperEditPane.updateHyperLink(chartHyperlink);
chartHyperlink.setChartCollection(chartComponent.update()); chartHyperlink.setChartCollection(chartComponent.update());
ChartEditPane.getInstance().fire();// 响应整个图表保存事件等. DesignModuleFactory.getChartPropertyPane().getChartEditPane().fire();// 响应整个图表保存事件等.
if(itemNameTextField != null){ if(itemNameTextField != null){
chartHyperlink.setItemName(this.itemNameTextField.getText()); chartHyperlink.setItemName(this.itemNameTextField.getText());
} }

143
designer_chart/src/com/fr/design/mainframe/ChartAndWidgetPropertyPane.java

@ -1,143 +0,0 @@
/*
* Copyright(c) 2001-2011, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe;
import java.awt.BorderLayout;
import java.awt.Component;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.TargetComponent;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itabpane.TitleChangeListener;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.module.DesignModuleFactory;
import com.fr.general.Inter;
public class ChartAndWidgetPropertyPane extends MiddleChartPropertyPane {
public synchronized static ChartAndWidgetPropertyPane getInstance(BaseFormDesigner formEditor) {
if(singleton == null) {
singleton = new ChartAndWidgetPropertyPane(formEditor);
}
singleton.setWidgetPropertyPane(DesignModuleFactory.getWidgetPropertyPane(formEditor));
singleton.setSureProperty();
return singleton;
}
public static ChartAndWidgetPropertyPane getInstance() {
if(singleton == null) {
singleton = new ChartAndWidgetPropertyPane();
}
return singleton;
}
private static ChartAndWidgetPropertyPane singleton;
private BaseWidgetPropertyPane widgetpane = null;
private UIToggleButton hisButton;
public ChartAndWidgetPropertyPane() {
}
public ChartAndWidgetPropertyPane(BaseFormDesigner formEditor) {
super();
this.widgetpane = DesignModuleFactory.getWidgetPropertyPane(formEditor);
}
public void setWidgetPropertyPane(BaseWidgetPropertyPane pane) {
this.widgetpane = pane;
}
@Override
protected void createMainPane() {
this.add(chartEditPane, BorderLayout.CENTER);
}
@Override
protected void createNameLabel() {
nameLabel = new UILabel();
nameLabel.setHorizontalAlignment(SwingConstants.LEFT);
nameLabel.setBorder(BorderFactory.createEmptyBorder(-2, 6, 2, 0));
}
@Override
protected JComponent createNorthComponent() {
JPanel toolPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel hisPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
hisPane.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
hisButton = new UIToggleButton(Inter.getLocText(new String[]{"Widget", "Attribute"}), UIConstants.HISTORY_ICON);
hisButton.setNormalPainted(false);
hisButton.setBorderPaintedOnlyWhenPressed(true);
hisPane.add(hisButton, BorderLayout.CENTER);
hisButton.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
cardChange();
}
});
toolPane.add(nameLabel, BorderLayout.CENTER);
toolPane.add(hisPane, BorderLayout.EAST);
titleListener = new TitleChangeListener() {
@Override
public void fireTitleChange(String addName) {
if(hisButton.isSelected()) {
nameLabel.setText(Inter.getLocText(new String[]{"Widget", "Form-Widget_Property_Table"}));
}else {
nameLabel.setText(Inter.getLocText("Chart-Property_Table") + '-' + addName);
}
}
};
return toolPane;
}
/**
* 感觉ChartCollection加载图表属性界面.
* @param collection 收集图表
* @param ePane 面板
*/
public void populateChartPropertyPane(ChartCollection collection, TargetComponent<?> ePane) {
super.populateChartPropertyPane(collection, ePane);
//表单中的图表切换界面上得更新
resetChartEditPane();
}
protected void resetChartEditPane() {
cardChange();
}
private void cardChange() {
remove(chartEditPane);
remove((Component)widgetpane);
if(hisButton.isSelected()) {
nameLabel.setText(Inter.getLocText(new String[]{"Widget", "Form-Widget_Property_Table"}));
add((Component)widgetpane, BorderLayout.CENTER);
} else {
String tabname = chartEditPane.getSelectedTabName();
nameLabel.setText(Inter.getLocText(new String[]{"Utils-The-Chart", "Form-Widget_Property_Table"}) + (tabname != null ? ('-' + chartEditPane.getSelectedTabName()) : ""));
add(chartEditPane, BorderLayout.CENTER);
}
validate();
repaint();
revalidate();
}
}

34
designer_chart/src/com/fr/design/mainframe/ChartDesigner.java

@ -29,40 +29,13 @@ public class ChartDesigner extends TargetComponent<ChartBook> implements MouseL
private ChartArea chartArea;//上层区域 private ChartArea chartArea;//上层区域
private boolean hasCalGap = false; private boolean hasCalGap = false;
private ChartDesignerUI designerUI;
private ArrayList<ChangeListener> changeListeners = new ArrayList<ChangeListener>(); private ArrayList<ChangeListener> changeListeners = new ArrayList<ChangeListener>();
private ChartToolBarPane chartToolBarPane;
public ChartDesigner(ChartBook chartBook) { public ChartDesigner(ChartBook chartBook) {
super(chartBook); super(chartBook);
this.addMouseListener(this); this.addMouseListener(this);
designerUI = new ChartDesignerUI();
chartToolBarPane = new ChartToolBarPane(this){
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
return new Dimension(size.width, ChartToolBarPane.TOTAL_HEIGHT);
}
};
this.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
if(designerUI!=null){
designerUI.mouseMoved(e);
ChartDesigner.this.repaint();
}
}
});
updateUI();// 初始化界面设计工具的UI实例 updateUI();// 初始化界面设计工具的UI实例
} }
/**
* 设置其UI类为DesignerUI负责渲染
*/
@Override
public void updateUI() {
setUI(designerUI);
}
/** /**
* 设置上层区域 * 设置上层区域
* @param chartArea 图表区域 * @param chartArea 图表区域
@ -203,8 +176,6 @@ public class ChartDesigner extends TargetComponent<ChartBook> implements MouseL
* @param e 事件 * @param e 事件
*/ */
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
designerUI.mouseClicked(e);
this.chartToolBarPane.populate();
} }
/** /**
@ -247,18 +218,13 @@ public class ChartDesigner extends TargetComponent<ChartBook> implements MouseL
this.changeListeners.add(changeListener); this.changeListeners.add(changeListener);
} }
public ChartToolBarPane getChartToolBarPane(){
return this.chartToolBarPane;
}
public void populate(){ public void populate(){
this.chartToolBarPane.populate();
} }
/** /**
* 清除工具栏上面全局风格按钮的选中 * 清除工具栏上面全局风格按钮的选中
*/ */
public void clearToolBarStyleChoose(){ public void clearToolBarStyleChoose(){
chartToolBarPane.clearStyleChoose();
} }
} }

134
designer_chart/src/com/fr/design/mainframe/ChartDesignerPropertyPane.java

@ -1,134 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe;
import com.fr.base.chart.BaseChartCollection;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.designer.TargetComponent;
import com.fr.design.gui.chart.BaseChartPropertyPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itabpane.TitleChangeListener;
import com.fr.design.mainframe.chart.ChartDesignEditPane;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-15
* Time: 下午12:43
*/
public class ChartDesignerPropertyPane extends BaseChartPropertyPane {
private static ChartDesignerPropertyPane instance;
private TargetComponentContainer container = new TargetComponentContainer();
private ChartEditPane chartEditPane;
private UILabel nameLabel;
private TitleChangeListener titleListener = new TitleChangeListener() {
@Override
public void fireTitleChange(String addName) {
nameLabel.setText(Inter.getLocText("Chart-Property_Table") + '-' + addName);
}
};
public synchronized static ChartDesignerPropertyPane getInstance() {
if (instance == null) {
instance = new ChartDesignerPropertyPane();
}
instance.setSureProperty();
return instance;
}
public ChartDesignerPropertyPane() {
this.setLayout(new BorderLayout());
this.setBorder(null);
createNameLabel();
this.add(nameLabel, BorderLayout.NORTH);
chartEditPane = ChartDesignEditPane.getInstance();
this.add(chartEditPane, BorderLayout.CENTER);
}
private void createNameLabel() {
nameLabel = new UILabel() {
@Override
public Dimension getPreferredSize() {
return new Dimension(super.getPreferredSize().width, 18);
}
};
nameLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 1, 0));
nameLabel.setHorizontalAlignment(SwingConstants.CENTER);
}
@Override
public void setSureProperty() {
chartEditPane.setContainer(container);
chartEditPane.addTitleChangeListener(titleListener);
String tabname = chartEditPane.getSelectedTabName();
nameLabel.setText(Inter.getLocText("Chart-Property_Table") + (tabname != null ? ('-' + chartEditPane.getSelectedTabName()) : ""));
resetChartEditPane();
}
protected void resetChartEditPane() {
remove(chartEditPane);
add(chartEditPane, BorderLayout.CENTER);
validate();
repaint();
revalidate();
}
@Override
public void setSupportCellData(boolean supportCellData){
}
/**
* 感觉ChartCollection加载图表属性界面.
* @param collection 收集图表
* @param chartDesigner 图表设计
*/
public void populateChartPropertyPane(BaseChartCollection collection, TargetComponent<?> chartDesigner) {
if (collection instanceof ChartCollection) {
this.container.setEPane(chartDesigner);
chartEditPane.populate((ChartCollection) collection);
}
}
@Override
public void setWidgetPropertyPane(BaseWidgetPropertyPane pane) {
}
/**
* 刷新
*/
public void refreshDockingView() {
}
@Override
public String getViewTitle() {
return null;
}
@Override
public Icon getViewIcon() {
return null;
}
/**
* 位置
* @return 位置
*/
public Location preferredLocation() {
return null;
}
}

7
designer_chart/src/com/fr/design/mainframe/ChartPropertyPane.java

@ -17,7 +17,7 @@ public class ChartPropertyPane extends MiddleChartPropertyPane{
/** /**
* 创建图表属性表实例. * 创建图表属性表实例.
*/ */
public synchronized static ChartPropertyPane getInstance() { private synchronized static ChartPropertyPane getInstance() {
if(singleton == null) { if(singleton == null) {
singleton = new ChartPropertyPane(); singleton = new ChartPropertyPane();
} }
@ -50,8 +50,7 @@ public class ChartPropertyPane extends MiddleChartPropertyPane{
return nameLabel; return nameLabel;
} }
@Override public synchronized static void clear() {
public void setWidgetPropertyPane(BaseWidgetPropertyPane pane) { singleton = null;
} }
} }

47
designer_chart/src/com/fr/design/mainframe/ChartUndoState.java

@ -1,47 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe;
import com.fr.form.ui.ChartBook;
import java.awt.*;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-13
* Time: 下午2:32
*/
public class ChartUndoState extends BaseUndoState<JChart> {
private ChartBook chartBook;
private Dimension designerSize;
private double widthValue;
private double heightValue;
public ChartUndoState(JChart t,ChartArea area) {
super(t);
try {
this.chartBook = (ChartBook) t.getTarget().clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
this.widthValue =area.getCustomWidth();
this.heightValue = area.getCustomHeight();
}
public ChartBook getChartBook(){
return this.chartBook;
}
/**
* 应用状态
*/
public void applyState() {
this.getApplyTarget().applyUndoState(this);
}
}

376
designer_chart/src/com/fr/design/mainframe/JChart.java

@ -1,376 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
* 图表类型文件
*/
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.file.FILEChooserPane;
import com.fr.file.FILEChooserPane4Chart;
import com.fr.form.ui.ChartBook;
import com.fr.design.DesignModelAdapter;
import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.actions.ExcelExportAction4Chart;
import com.fr.design.mainframe.actions.PDFExportAction4Chart;
import com.fr.design.mainframe.actions.PNGExportAction4Chart;
import com.fr.design.mainframe.form.FormECCompositeProvider;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.file.FILE;
import com.fr.general.Inter;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.datatransfer.StringSelection;
/**
* 图表crt文件
* <p/>
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-13
* Time: 下午2:28
*/
public class JChart extends JTemplate<ChartBook, ChartUndoState> {
public static final String XML_TAG = "JChart";
private static final String CHART_CARD = "FORM";
private static final String ELEMENTCASE_CARD = "ELEMENTCASE";
private static final String[] CARDNAME = new String[]{CHART_CARD, ELEMENTCASE_CARD};
private static final int TOOLBARPANEDIMHEIGHT_FORM = 60;
//图表设计器
ChartDesigner chartDesigner;
//中间编辑区域, carllayout布局
private JPanel tabCenterPane;
private CardLayout cardLayout;
//当前编辑的组件对象
private JComponent editingComponent;
private FormECCompositeProvider reportComposite;
public JChart() {
super(new ChartBook(), "Chart");
}
public JChart(ChartBook chartFile, FILE file) {
super(chartFile, file);
}
@Override
protected JPanel createCenterPane() {
tabCenterPane = FRGUIPaneFactory.createCardLayout_S_Pane();
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
centerPane.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, new Color(85, 85, 85)));
chartDesigner = new ChartDesigner(this.getTarget());
ChartArea area = new ChartArea(chartDesigner);
centerPane.add(area, BorderLayout.CENTER);
tabCenterPane.add(centerPane, CHART_CARD, 0);
chartDesigner.addTargetModifiedListener(new TargetModifiedListener() {
public void targetModified(TargetModifiedEvent e) {
JChart.this.fireTargetModified();// 调用保存*, 调用刷新界面, 刷新工具栏按钮
}
});
this.add(tabCenterPane, BorderLayout.CENTER);
return tabCenterPane;
}
/**
* 移除选择
*/
public void removeTemplateSelection() {
}
/**
* 刷新容器
*/
public void refreshContainer() {
}
/**
* 移除参数面板选择
*/
public void removeParameterPaneSelection() {
}
/**
* 创建设计模式
*
* @return 返回模式
*/
protected DesignModelAdapter<ChartBook, ?> createDesignModel() {
return null;
}
/**
* 创建预览得菜单
*
* @return 菜单
*/
public UIMenuItem[] createMenuItem4Preview() {
return new UIMenuItem[0];
}
/**
* 创建撤销状态
*
* @return 状态
*/
protected ChartUndoState createUndoState() {
return new ChartUndoState(this,chartDesigner.getArea());
}
/**
* 应用撤销状态
*
* @param chartUndoState 撤销状态
*/
protected void applyUndoState(ChartUndoState chartUndoState) {
try {
this.setTarget((ChartBook)chartUndoState.getChartBook().clone());
chartDesigner.setTarget(this.getTarget());
chartDesigner.populate();
}catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
}
/**
* 后缀
*
* @return 后缀
*/
public String suffix() {
return ".crt";
}
/**
* 复制
*/
public void copy() {
}
/**
* 黏贴
*
* @return 是否鸟贴成功
*/
public boolean paste() {
return false;
}
/**
* 是否剪切
*
* @return 剪切成功
*/
public boolean cut() {
return false;
}
/**
* 创建权限编辑面板
*
* @return 面板
*/
public AuthorityEditPane createAuthorityEditPane() {
return null;
}
/**
* 工具栏
*
* @return 工具栏
*/
public ToolBarMenuDockPlus getToolBarMenuDockPlus() {
return null;
}
/**
* 东上面板
*
* @return 面板
*/
public JPanel getEastUpPane() {
return null;
}
/**
* 东下面板
*
* @return 面板
*/
public JPanel getEastDownPane() {
return null;
}
/**
* 工具栏菜单
*
* @return 菜单
*/
public ToolBarDef[] toolbars4Target() {
return new ToolBarDef[0];
}
/**
* 表单面板
*
* @return 面板
*/
public JPanel[] toolbarPanes4Form() {
return new JPanel[0];
}
/**
* 模版菜单
*
* @return 模版菜单
*/
public ShortCut[] shortcut4TemplateMenu() {
return new ShortCut[0];
}
/**
* 权限编辑菜单
*
* @return 菜单
*/
public ShortCut[] shortCuts4Authority() {
return new ShortCut[0];
}
/**
* 工具条表单
*
* @return 表单
*/
public JComponent[] toolBarButton4Form() {
return new JComponent[0];
}
/**
* 权限编辑工具栏,但是图表设计器里面用于正常工具栏不是全县编辑
*
* @return 工具条
*/
public JComponent toolBar4Authority() {
return chartDesigner.getChartToolBarPane();
}
/**
* 工具条高度
*
* @return 工具条高度
*/
public int getToolBarHeight() {
return 0;
}
/**
* 是否是报表
*
* @return 不是
*/
public boolean isJWorkBook() {
return false;
}
/**
* 是否是图表
*
* @return 是则返回true
*/
public boolean isChartBook() {
return true;
}
/**
* 设置权限编辑模式
*
* @param isUpMode 没有权限编辑
*/
public void setAuthorityMode(boolean isUpMode) {
}
/**
* 刷新工具区域
*/
public void refreshToolArea() {
DesignerContext.getDesignerFrame().resetToolkitByPlus(JChart.this);
chartDesigner.populate();
ChartDesignerPropertyPane.getInstance().populateChartPropertyPane(getTarget().getChartCollection(), chartDesigner);
EastRegionContainerPane.getInstance().replaceUpPane(ChartDesignerPropertyPane.getInstance());
}
/**
* 导出菜单的子菜单 目前用于图表设计器
*
* @return 子菜单
*/
public ShortCut[] shortcut4ExportMenu() {
return new ShortCut[]{new PNGExportAction4Chart(this), new ExcelExportAction4Chart(this), new PDFExportAction4Chart(this)};
}
public Icon getIcon() {
return BaseUtils.readIcon("/com/fr/design/images/chart.png");
}
public ChartDesigner getChartDesigner(){
return chartDesigner;
}
/**
* 复制JS代码
*/
public void copyJS(){
JSONObject jsonObject =this.getTarget().createExportConfig();
String jsonString = StringUtils.EMPTY;
if(jsonObject != null){
try{
if(jsonObject.has("charts")){
JSONArray charts = jsonObject.getJSONArray("charts");
jsonString = charts.toString(2);
}else{
jsonString = jsonObject.toString(2);
}
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Chart-CopyJS_Message"), Inter.getLocText("FR-Chart-Action_Copy")+"JS", JOptionPane.INFORMATION_MESSAGE);
}catch (JSONException ex){
FRContext.getLogger().error(ex.getMessage());
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Chart-CopyJS_Failed")+"!", Inter.getLocText("Error"), JOptionPane.ERROR_MESSAGE);
}
}else{
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Chart-CopyJS_Failed")+"!", Inter.getLocText("Error"), JOptionPane.ERROR_MESSAGE);
}
StringSelection stringSelection = new StringSelection(jsonString);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null);
};
/**
* 系列风格改动
*/
public void styleChange(){
chartDesigner.clearToolBarStyleChoose();
}
protected FILEChooserPane getFILEChooserPane(boolean isShowLoc){
return new FILEChooserPane4Chart(true, isShowLoc);
}
}

16
designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java

@ -13,11 +13,13 @@ import com.fr.base.chart.BaseChartCollection;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.design.gui.chart.BaseChartPropertyPane; import com.fr.design.gui.chart.BaseChartPropertyPane;
import com.fr.design.gui.chart.ChartEditPaneProvider;
import com.fr.design.gui.frpane.UITitlePanel; import com.fr.design.gui.frpane.UITitlePanel;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itabpane.TitleChangeListener; import com.fr.design.gui.itabpane.TitleChangeListener;
import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.StableUtils;
public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{
@ -37,7 +39,7 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{
createNameLabel(); createNameLabel();
this.add(createNorthComponent(), BorderLayout.NORTH); this.add(createNorthComponent(), BorderLayout.NORTH);
chartEditPane = ChartEditPane.getInstance(); chartEditPane = StableUtils.construct(ChartEditPane.class);
chartEditPane.setSupportCellData(true); chartEditPane.setSupportCellData(true);
this.createMainPane(); this.createMainPane();
} }
@ -48,6 +50,12 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{
protected abstract void createMainPane(); protected abstract void createMainPane();
@Override
public ChartEditPaneProvider getChartEditPane() {
return chartEditPane;
}
public void setSureProperty() { public void setSureProperty() {
chartEditPane.setContainer(container); chartEditPane.setContainer(container);
chartEditPane.addTitleChangeListener(titleListener); chartEditPane.addTitleChangeListener(titleListener);
@ -93,6 +101,12 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{
} }
} }
// public void clear() {
// this.container.setEPane(null);
// chartEditPane.clear();
// getParent().remove(this);
// }
/** /**
* 返回View的标题. * 返回View的标题.
*/ */

132
designer_chart/src/com/fr/design/mainframe/actions/AbstractExportAction4JChart.java

@ -1,132 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe.actions;
import com.fr.base.FRContext;
import com.fr.design.gui.iprogressbar.FRProgressBar;
import com.fr.form.ui.ChartBook;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.JChart;
import com.fr.design.mainframe.exporter.Exporter4Chart;
import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.io.FileOutputStream;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-15
* Time: 上午9:48
*/
public abstract class AbstractExportAction4JChart extends JChartAction {
protected AbstractExportAction4JChart(JChart chart){
super(chart);
}
private FRProgressBar progressbar;
protected ChartBook getChartBook(){
return this.getEditingComponent().getTarget();
}
/**
* 执行方法
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
JChart chart = this.getEditingComponent();
FILE editingFILE = chart.getEditingFILE();
DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
// 弹出参数
final java.util.Map parameterMap = new java.util.HashMap();
final ChartBook chartBook = getChartBook();
// Choose a file name....
FILEChooserPane fileChooserPane = FILEChooserPane.getInstance(false, true);
fileChooserPane.setFILEFilter(this.getChooseFileFilter());
// 打开文件后输出文件名修改,eg:w.cpt.doc / w.svg.doc,去掉中间的后缀名~~ w.doc
String filenName = editingFILE.getName();
if (filenName.indexOf('.') != -1) {
filenName = filenName.substring(0, editingFILE.getName().lastIndexOf('.'));
}
fileChooserPane.setFileNameTextField(filenName, "." + this.getDefaultExtension());
int saveValue = fileChooserPane.showSaveDialog(designerFrame, "." + this.getDefaultExtension());
if (saveValue == FILEChooserPane.CANCEL_OPTION || saveValue == FILEChooserPane.JOPTIONPANE_CANCEL_OPTION) {
fileChooserPane = null;
return;
} else if (saveValue == FILEChooserPane.JOPTIONPANE_OK_OPTION || saveValue == FILEChooserPane.OK_OPTION) {
FILE file = fileChooserPane.getSelectedFILE();
try {
file.mkfile();
} catch (Exception e1) {
FRLogger.getLogger().error("Error In Make New File");
}
fileChooserPane = null;
FRContext.getLogger().info("\"" + file.getName() + "\"" + Inter.getLocText("Prepare_Export") + "!");
(progressbar = new FRProgressBar(createExportWork(file, chartBook), designerFrame,
Inter.getLocText("Exporting"), "", 0, 100)).start();
}
}
private SwingWorker createExportWork(FILE file, final ChartBook chartBook) {
final String filePath = file.getPath();
final String fileGetName = file.getName();
SwingWorker exportWorker = new SwingWorker<Void, Void>() {
protected Void doInBackground() throws Exception {
Thread.sleep(100); //bug 10516
try {
final FileOutputStream fileOutputStream = new FileOutputStream(filePath);
this.setProgress(10);
dealExporter(fileOutputStream,chartBook);
this.setProgress(80);
fileOutputStream.close();
this.setProgress(100);
FRContext.getLogger().info("\"" + fileGetName + "\"" + Inter.getLocText("Finish_Export") + "!");
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Inter.getLocText("Exported_successfully") + "\n" + filePath);
} catch (Exception exp) {
this.setProgress(100);
FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Export_failed") + "\n" + filePath);
}
return null;
}
public void done() {
progressbar.close();
}
};
return exportWorker;
}
private void dealExporter(FileOutputStream fileOutputStream, final ChartBook chartBook) throws Exception {
final Exporter4Chart exporter = AbstractExportAction4JChart.this.getExporter();
exporter.export(fileOutputStream,this.getEditingComponent());
}
protected abstract ChooseFileFilter getChooseFileFilter();
protected abstract String getDefaultExtension();
protected abstract Exporter4Chart getExporter();
}

68
designer_chart/src/com/fr/design/mainframe/actions/ExcelExportAction4Chart.java

@ -1,68 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe.actions;
import com.fr.base.BaseUtils;
import com.fr.base.ExcelUtils;
import com.fr.design.mainframe.JChart;
import com.fr.design.mainframe.exporter.ExcelExporter4Chart;
import com.fr.design.mainframe.exporter.Exporter4Chart;
import com.fr.design.menu.MenuKeySet;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.event.KeyEvent;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-15
* Time: 上午9:52
*/
public class ExcelExportAction4Chart extends AbstractExportAction4JChart {
private MenuKeySet excel= new MenuKeySet() {
@Override
public char getMnemonic() {
return 'E';
}
@Override
public String getMenuName() {
return Inter.getLocText("FR-Chart-Format_Excel");
}
@Override
public KeyStroke getKeyStroke() {
return KeyStroke.getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_MASK);
}
};
public ExcelExportAction4Chart(JChart chart) {
super(chart);
this.setMenuKeySet(excel);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/excel.png"));
}
@Override
protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(new String[]{"xls", "xlsx"}, Inter.getLocText("Export-Excel"));
}
@Override
protected String getDefaultExtension() {
return ExcelUtils.checkThirdJarSupportPOI() ? "xlsx" : "xls";
}
@Override
protected Exporter4Chart getExporter() {
return new ExcelExporter4Chart();
}
}

21
designer_chart/src/com/fr/design/mainframe/actions/JChartAction.java

@ -1,21 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe.actions;
import com.fr.design.actions.JTemplateAction;
import com.fr.design.mainframe.JChart;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-15
* Time: 上午9:47
*/
public abstract class JChartAction extends JTemplateAction<JChart> {
public JChartAction(JChart jChart) {
super(jChart);
}
}

61
designer_chart/src/com/fr/design/mainframe/actions/NewChartAction.java

@ -1,61 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe.actions;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JChart;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-13
* Time: 下午3:22
*/
public class NewChartAction extends UpdateAction{
public NewChartAction(){
this.setMenuKeySet(NEW_CHART);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/newchart_normal.png"));
this.setAccelerator(getMenuKeySet().getKeyStroke());
}
/**
* 执行事件
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
DesignerContext.getDesignerFrame().addAndActivateJTemplate(new JChart());
}
public static final MenuKeySet NEW_CHART = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'F';
}
@Override
public String getMenuName() {
return Inter.getLocText("M-New_ChartBook");
}
@Override
public KeyStroke getKeyStroke() {
return KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_MASK);
}
};
}

65
designer_chart/src/com/fr/design/mainframe/actions/PDFExportAction4Chart.java

@ -1,65 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe.actions;
import com.fr.base.BaseUtils;
import com.fr.design.mainframe.JChart;
import com.fr.design.mainframe.exporter.Exporter4Chart;
import com.fr.design.mainframe.exporter.PdfExporter4Chart;
import com.fr.design.menu.MenuKeySet;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.general.Inter;
import javax.swing.*;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-15
* Time: 上午10:16
*/
public class PDFExportAction4Chart extends AbstractExportAction4JChart {
private MenuKeySet pdf = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'P';
}
@Override
public String getMenuName() {
return Inter.getLocText("FR-Chart-Format_PDF");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
public PDFExportAction4Chart(JChart chart) {
super(chart);
this.setMenuKeySet(pdf);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/pdf.png"));
}
@Override
protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(new String[]{"pdf"}, Inter.getLocText("Export-PDF"));
}
@Override
protected String getDefaultExtension() {
return "pdf";
}
@Override
protected Exporter4Chart getExporter() {
return new PdfExporter4Chart();
}
}

66
designer_chart/src/com/fr/design/mainframe/actions/PNGExportAction4Chart.java

@ -1,66 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe.actions;
import com.fr.base.BaseUtils;
import com.fr.design.mainframe.JChart;
import com.fr.design.mainframe.exporter.Exporter4Chart;
import com.fr.design.mainframe.exporter.ImageExporter4Chart;
import com.fr.design.menu.MenuKeySet;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.event.KeyEvent;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-15
* Time: 上午10:18
*/
public class PNGExportAction4Chart extends AbstractExportAction4JChart {
private MenuKeySet menuSet = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'M';
}
@Override
public String getMenuName() {
return Inter.getLocText("FR-Chart-Format_Image");
}
@Override
public KeyStroke getKeyStroke() {
return KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_MASK);
}
};
public PNGExportAction4Chart(JChart chart) {
super(chart);
this.setMenuKeySet(menuSet);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/exportimg.png"));
}
@Override
protected ChooseFileFilter getChooseFileFilter() {
return new ChooseFileFilter(new String[]{"png"}, Inter.getLocText("Image"));
}
@Override
protected String getDefaultExtension() {
return "png";
}
@Override
protected Exporter4Chart getExporter() {
return new ImageExporter4Chart();
}
}

1
designer_chart/src/com/fr/design/mainframe/chart/AbstractChartAttrPane.java

@ -32,4 +32,5 @@ public abstract class AbstractChartAttrPane extends AbstractAttrNoScrollPane {
public void refreshChartDataPane(ChartCollection collection){ public void refreshChartDataPane(ChartCollection collection){
} }
} }

16
designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java

@ -9,6 +9,7 @@ import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.data.tabledata.Prepare4DataSourceChange;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.chart.ChartEditPaneProvider;
import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.gui.itabpane.TitleChangeListener; import com.fr.design.gui.itabpane.TitleChangeListener;
@ -30,20 +31,13 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4DataSourceChange { public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4DataSourceChange, ChartEditPaneProvider {
public synchronized static ChartEditPane getInstance() {
if (singleton == null) {
singleton = new ChartEditPane();
}
return singleton;
}
private final static int CHANGE_MIN_TIME = 80; private final static int CHANGE_MIN_TIME = 80;
protected ChartCollection collection; protected ChartCollection collection;
protected boolean isDefaultPane = true;//是否是默认的界面 protected boolean isDefaultPane = true;//是否是默认的界面
private static ChartEditPane singleton;
protected List<AbstractChartAttrPane> paneList; protected List<AbstractChartAttrPane> paneList;
protected ChartTypePane typePane; protected ChartTypePane typePane;
@ -79,10 +73,6 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4
registerDSChangeListener(); registerDSChangeListener();
} }
public static ChartEditPane getSingleton() {
return singleton;
}
//构建主面板 //构建主面板
protected void createTabsPane() { protected void createTabsPane() {
Icon[] iconArray = new Icon[paneList.size()]; Icon[] iconArray = new Icon[paneList.size()];
@ -295,7 +285,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4
* *
* @param id 界面的标志.id * @param id 界面的标志.id
*/ */
public void GoToPane(String... id) { public void gotoPane(String... id) {
this.setSelectedIndex(id); this.setSelectedIndex(id);
EastRegionContainerPane.getInstance().setWindow2PreferWidth(); EastRegionContainerPane.getInstance().setWindow2PreferWidth();
} }

1
designer_chart/src/com/fr/design/mainframe/chart/gui/ChartDataPane.java

@ -105,4 +105,5 @@ public class ChartDataPane extends AbstractChartAttrPane {
public void refreshChartDataPane(ChartCollection collection){ public void refreshChartDataPane(ChartCollection collection){
this.populate(collection); this.populate(collection);
} }
} }

32
designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java

@ -68,20 +68,20 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
return this.mouseOnChartTypeButtonPane; return this.mouseOnChartTypeButtonPane;
} }
private AWTEventListener awt = new AWTEventListener() { // private AWTEventListener awt = new AWTEventListener() {
public void eventDispatched(AWTEvent event) { // public void eventDispatched(AWTEvent event) {
//没有进行鼠标点击,则返回 // //没有进行鼠标点击,则返回
if (event instanceof MouseEvent && ((MouseEvent) event).getClickCount() > 0) { // if (event instanceof MouseEvent && ((MouseEvent) event).getClickCount() > 0) {
if (currentEditingEditor != null && !ComparatorUtils.equals(event.getSource(), currentEditingEditor)) { // if (currentEditingEditor != null && !ComparatorUtils.equals(event.getSource(), currentEditingEditor)) {
stopEditing(); // stopEditing();
if (event.getSource() instanceof ChartChangeButton) { // if (event.getSource() instanceof ChartChangeButton) {
((ChartChangeButton) event.getSource()).mouseClick((MouseEvent) event); // ((ChartChangeButton) event.getSource()).mouseClick((MouseEvent) event);
} // }
populateBean(editingCollection); // populateBean(editingCollection);
} // }
} // }
} // }
}; // };
public ChartTypeButtonPane(ChartTypePane chartTypePane){ public ChartTypeButtonPane(ChartTypePane chartTypePane){
this(); this();
@ -113,7 +113,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
initConfigButton(); initConfigButton();
initConfigCreator(); initConfigCreator();
Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); // Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK);
} }
private void initConfigCreator() { private void initConfigCreator() {
@ -336,7 +336,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
private void checkConfigButtonVisible() { private void checkConfigButtonVisible() {
addButton.setVisible(true); addButton.setVisible(true);
//新建一个collection //新建一个collection
if(editingCollection.getState() == SwitchState.DEFAULT){ if(editingCollection.getState() == SwitchState.DEFAULT && editingCollection.getSelectedChart() != null){
//Chart 不支持图表切换 //Chart 不支持图表切换
configButton.setVisible(editingCollection.getSelectedChart().supportChange()); configButton.setVisible(editingCollection.getSelectedChart().supportChange());
} }

1
designer_chart/src/com/fr/design/mainframe/chart/gui/data/DatabaseTableDataPane.java

@ -102,4 +102,5 @@ public class DatabaseTableDataPane extends BasicPane{
} }
}); });
} }
} }

1
designer_chart/src/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java

@ -133,4 +133,5 @@ public class NormalChartDataPane extends DataContentsPane {
public void setSupportCellData(boolean supportCellData) { public void setSupportCellData(boolean supportCellData) {
dataPane.justSupportOneSelect(supportCellData); dataPane.justSupportOneSelect(supportCellData);
} }
} }

6
designer_chart/src/com/fr/design/mainframe/chart/gui/data/ReportDataPane.java

@ -52,7 +52,7 @@ public class ReportDataPane extends FurtherBasicBeanPane<ChartCollection>{
* 界面重置 * 界面重置
*/ */
public void reset() { public void reset() {
clear();
} }
/** /**
@ -98,4 +98,8 @@ public class ReportDataPane extends FurtherBasicBeanPane<ChartCollection>{
public ChartCollection updateBean() { public ChartCollection updateBean() {
return null; return null;
} }
public void clear() {
this.removeAll();
}
} }

4
designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartSwitchPane.java

@ -49,8 +49,8 @@ public class ChartSwitchPane extends AbstractAttrNoScrollPane{
if(currentChartEditPane != null) { if(currentChartEditPane != null) {
currentChartEditPane.populate(editingChartCollection);// 选中新Plot之后 刷新对应界面, 比如超级链接等, 然后才能update. currentChartEditPane.populate(editingChartCollection);// 选中新Plot之后 刷新对应界面, 比如超级链接等, 然后才能update.
currentChartEditPane.GoToPane(PaneTitleConstants.CHART_TYPE_TITLE); currentChartEditPane.gotoPane(PaneTitleConstants.CHART_TYPE_TITLE);
currentChartEditPane.GoToPane(PaneTitleConstants.CHART_OTHER_TITLE, PaneTitleConstants.CHART_OTHER_TITLE_CHANGE); currentChartEditPane.gotoPane(PaneTitleConstants.CHART_OTHER_TITLE, PaneTitleConstants.CHART_OTHER_TITLE_CHANGE);
currentChartEditPane.fire(); currentChartEditPane.fire();
} }
} }

94
designer_chart/src/com/fr/design/mainframe/exporter/ExcelExporter4Chart.java

@ -1,94 +0,0 @@
package com.fr.design.mainframe.exporter;
import com.fr.base.ExcelUtils;
import com.fr.design.mainframe.ChartDesigner;
import com.fr.design.mainframe.JChart;
import com.fr.general.FRLogger;
import com.fr.general.IOUtils;
import com.fr.stable.CoreGraphHelper;
import com.fr.third.v2.org.apache.poi.hssf.usermodel.HSSFClientAnchor;
import com.fr.third.v2.org.apache.poi.hssf.usermodel.HSSFWorkbook;
import com.fr.third.v2.org.apache.poi.ss.usermodel.ClientAnchor;
import com.fr.third.v2.org.apache.poi.ss.usermodel.Drawing;
import com.fr.third.v2.org.apache.poi.ss.usermodel.Sheet;
import com.fr.third.v2.org.apache.poi.ss.usermodel.Workbook;
import com.fr.third.v2.org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import com.fr.third.v2.org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-22
* Time: 上午10:47
*/
public class ExcelExporter4Chart extends ImageExporter4Chart {
private static final int PICTURE_TYPE_PNG = 6 ;
private static final int DEFAULT_COLUMN_SPAN = 12;
private static final int DEFAULT_ROW_SPAN = 26;
private Workbook workbook;
private ClientAnchor anchor;
/**
* 导出
*
* @param out 输出流
* @param chart 图表文件
* @throws Exception 异常
*/
public void export(OutputStream out, JChart chart) throws Exception {
try {
ChartDesigner designer = chart.getChartDesigner();
int imageWidth = designer.getArea().getCustomWidth();
int imageHeight = designer.getArea().getCustomHeight();
BufferedImage image = CoreGraphHelper.createBufferedImage(imageWidth, (int) imageHeight, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = image.createGraphics();
paintGlyph(g2d,imageWidth,imageHeight,designer);
g2d.dispose();
if (checkExcelExportVersion()) {
workbook = new XSSFWorkbook();
}else{
workbook = new HSSFWorkbook();
}
Sheet sheet = workbook.createSheet();
if(checkExcelExportVersion()){
anchor = new XSSFClientAnchor(0,0,0,0,1,1,DEFAULT_COLUMN_SPAN,DEFAULT_ROW_SPAN);
}else{
anchor = new HSSFClientAnchor(0,0,0,0,(short)1,1,(short)DEFAULT_COLUMN_SPAN,DEFAULT_ROW_SPAN);
}
Drawing patriarch = sheet.createDrawingPatriarch();
patriarch.createPicture(anchor,loadPicture(image));
workbook.write(out);
out.flush();
}catch (Exception e){
FRLogger.getLogger().error(e.getMessage());
}
}
private boolean checkExcelExportVersion() {
return ExcelUtils.checkThirdJarSupportPOI();
}
// 加载图片.
private int loadPicture(BufferedImage bufferedImage)throws IOException {
ByteArrayOutputStream bos = null;
try {
bos = new ByteArrayOutputStream();
IOUtils.writeImage(bufferedImage, "png", bos);
//引用这个参数是jdk1.5的版本 XSSFWorkbook.PICTURE_TYPE_PNG, 在1.4下无法编译, 所有手动去掉这个参数.
return workbook.addPicture(bos.toByteArray(), PICTURE_TYPE_PNG);
} finally {
if (bos != null) {
bos.flush();
bos.close();
}
bufferedImage.flush();
}
}
}

25
designer_chart/src/com/fr/design/mainframe/exporter/Exporter4Chart.java

@ -1,25 +0,0 @@
package com.fr.design.mainframe.exporter;
import com.fr.design.mainframe.JChart;
import java.io.OutputStream;
/**
* 图表设计器crt文件的导出成其他类型文件的接口
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-21
* Time: 下午7:14
*/
public interface Exporter4Chart {
/**
* 将结果crt导出成目标文件
*
* @param out 输出流
* @param chart chart文件
* @throws Exception 导出失败则抛出此异常
*/
public void export(OutputStream out, JChart chart) throws Exception;
}

89
designer_chart/src/com/fr/design/mainframe/exporter/ImageExporter4Chart.java

@ -1,89 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe.exporter;
import com.fr.base.chart.BaseChartGlyph;
import com.fr.base.chart.chartdata.BaseTableDefinition;
import com.fr.base.chart.chartdata.ChartData;
import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartglyph.ChartGlyph;
import com.fr.data.TableDataSource;
import com.fr.design.mainframe.ChartDesigner;
import com.fr.design.mainframe.JChart;
import com.fr.script.Calculator;
import com.fr.stable.Constants;
import com.fr.stable.CoreGraphHelper;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.OutputStream;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-15
* Time: 上午10:04
*/
public class ImageExporter4Chart implements Exporter4Chart{
private int resolution = Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION;
protected Calculator calculator;
public ImageExporter4Chart() {
}
/**
* 导出
*
* @param out 输出流
* @param chart 图表文件
* @throws Exception 异常
*/
public void export(OutputStream out, JChart chart) throws Exception {
ChartDesigner designer = chart.getChartDesigner();
int imageWidth = designer.getArea().getCustomWidth();
int imageHeight = designer.getArea().getCustomHeight();
BufferedImage image = CoreGraphHelper.createBufferedImage(imageWidth, (int) imageHeight, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = image.createGraphics();
paintGlyph(g2d,imageWidth,imageHeight,designer);
ImageIO.write(image, "png", out);
}
protected void paintGlyph(Graphics2D g2d,int imageWidth,int imageHeight,ChartDesigner designer){
if (imageWidth == 0 || imageHeight == 0) {
return;
}
this.calculator = Calculator.createCalculator();
this.calculator.setAttribute(TableDataSource.class, null);
g2d.setColor(Color.white);
g2d.fillRect(0, 0, imageWidth,imageHeight);
ChartCollection chartCollection = (ChartCollection) designer.getTarget().getChartCollection();
Chart editingChart = chartCollection.getSelectedChart();
TopDefinitionProvider topDefinition = editingChart.getFilterDefinition();
ChartData chartData4Glyph = null;
if (topDefinition instanceof BaseTableDefinition) {
chartData4Glyph = ((BaseTableDefinition) topDefinition).calcu4ChartData(calculator, editingChart.getDataProcessor());
}
if (chartData4Glyph == null) {
chartData4Glyph = editingChart.defaultChartData();
}
BaseChartGlyph chartGlyph = null;
if (editingChart != null && editingChart.getPlot() != null) {
chartGlyph = editingChart.createGlyph(chartData4Glyph);
}
if (chartGlyph instanceof ChartGlyph) {
Image glyphImage = ((ChartGlyph) chartGlyph).toImage(imageWidth, imageHeight, resolution);
g2d.drawImage(glyphImage, 0, 0, null);
}
}
}

382
designer_chart/src/com/fr/design/mainframe/exporter/PdfExporter4Chart.java

@ -1,382 +0,0 @@
package com.fr.design.mainframe.exporter;
import com.fr.base.FRContext;
import com.fr.design.mainframe.ChartDesigner;
import com.fr.design.mainframe.JChart;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.stable.OperatingSystem;
import com.fr.stable.StableUtils;
import com.fr.third.com.lowagie.text.Document;
import com.fr.third.com.lowagie.text.ExceptionConverter;
import com.fr.third.com.lowagie.text.Rectangle;
import com.fr.third.com.lowagie.text.pdf.*;
import java.awt.*;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Locale;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-22
* Time: 上午10:20
*/
public class PdfExporter4Chart extends ImageExporter4Chart {
protected static MyFontMapper fontMapper = null;
/**
* 将结果crt导出成目标文件
*
* @param out 输出流
* @param chart chart文件
* @throws Exception 导出失败则抛出此异常
*/
public void export(OutputStream out, JChart chart) throws Exception {
ChartDesigner designer = chart.getChartDesigner();
int imageWidth = designer.getArea().getCustomWidth();
int imageHeight = designer.getArea().getCustomHeight();
Document document = null;
PdfWriter writer = null;
ByteArrayOutputStream bo = new ByteArrayOutputStream();
if (document == null) {
document = new Document(new Rectangle(imageWidth, imageHeight));
writer = PdfWriter.getInstance(document, bo);
document.open();
}
//将chart画到PDF上去
PdfContentByte cb = writer.getDirectContent();
Graphics2D g2d = cb.createGraphics(imageWidth, imageHeight, prepareFontMapper());
paintGlyph(g2d, imageWidth, imageHeight, designer);
g2d.dispose();
if (document != null) {
document.close();
}
try {
out.write(bo.toByteArray());
out.flush();
out.close();
} catch (IOException e) {
FRLogger.getLogger().error(e.getMessage());
}
}
private static void insertDirectory4Linux() {
/*
* alex:在222这台Redhat的机器上测试,发现把从windows拷来的simsun.ttc只有放在usr/share/fonts/default/Type1里面才可以用起来
* 如果是放在usr/share/fonts目录或是${env}/resources/fonts目录下面,虽然可以读到,但是awtToPdf之后返回出去却依旧无法起作用
* 中文字依然挤在一起
*
* 觉得实在很诡异,可能必须放在系统字体的文件夹下面才行吧
*
* PS:这是在用Graphics drawString的时候遇到的问题
*/
//Linux
InsertDirectory(fontMapper, new File("/usr/X11R6/lib/X11/fonts"));
InsertDirectory(fontMapper, new File("/usr/share/fonts"));
String path = StableUtils.pathJoin(new String[]{FRContext.getCurrentEnv().getPath(), "fonts"});
//再去web-inf/fonts里面找一下, 省去客户四处找jdk安装路径的麻烦
InsertDirectory(fontMapper, new File(path));
//Solaris
InsertDirectory(fontMapper, new File("/usr/X/lib/X11/fonts/TrueType"));
InsertDirectory(fontMapper, new File("/usr/openwin/lib/X11/fonts/TrueType"));
}
private static void insertDirectory4Windows() {
String libraryPath = System.getProperty("java.library.path");
String[] libraryPathArray = StableUtils.splitString(libraryPath, ";");
for (int i = 0; i < libraryPathArray.length; i++) {
File libraryFile = new File(libraryPathArray[i]);
InsertDirectory(fontMapper, new File(libraryFile, "Fonts"));
}
InsertDirectory(fontMapper, new File("C:\\WINNT\\Fonts"));
InsertDirectory(fontMapper, new File("C:\\WINDOWS\\Fonts"));
}
//peter:循环所有的目录,遍历所有的FontMapper.
protected static void InsertDirectory(MyFontMapper fontMapper, File dir) {
if (dir == null || !dir.exists() || !dir.isDirectory()) {
return;
}
fontMapper.insertDirectory(dir.getAbsolutePath());
File[] listFiles = dir.listFiles();
for (int i = 0; i < listFiles.length; i++) {
InsertDirectory(fontMapper, listFiles[i]);
}
}
/**
* Prepares FontMapper.
*/
protected static MyFontMapper prepareFontMapper() {
if (fontMapper != null) {
return fontMapper;
}
fontMapper = new MyFontMapper();
try {
//然后加载系统Font字体.
if (OperatingSystem.isWindows()) {
insertDirectory4Windows();
} else {
insertDirectory4Linux();
}
String javaHomeProp = System.getProperty("java.home");
if (javaHomeProp != null) {
File javaFontFile = new File(StableUtils.pathJoin(new String[]{
javaHomeProp, "lib", "fonts"
}));
if (javaFontFile.exists() && javaFontFile.isDirectory()) {
InsertDirectory(fontMapper, javaFontFile);
}
}
if (FRContext.getLocale() == Locale.CHINA || FRContext.getLocale() == Locale.CHINESE) {
MyFontMapper.defaultFont = BaseFont.createFont(MyFontMapper.CHINESE_SIMPLIFIED_FONT, MyFontMapper.CHINESE_SIMPLIFIED_ENCODING_H, BaseFont.NOT_EMBEDDED);
} else if (FRContext.getLocale() == Locale.TAIWAN || FRContext.getLocale() == Locale.TRADITIONAL_CHINESE) {
MyFontMapper.defaultFont = BaseFont.createFont(MyFontMapper.CHINESE_TRADITIONAL_FONT_M_SUNG, MyFontMapper.CHINESE_TRADITIONAL_ENCODING_H, BaseFont.NOT_EMBEDDED);
} else if (FRContext.getLocale() == Locale.JAPAN || FRContext.getLocale() == Locale.JAPANESE) {
MyFontMapper.defaultFont = BaseFont.createFont(MyFontMapper.JAPANESE_FONT_GO, MyFontMapper.JAPANESE_ENCODING_H, BaseFont.NOT_EMBEDDED);
} else if (FRContext.getLocale() == Locale.KOREA || FRContext.getLocale() == Locale.KOREAN) {
MyFontMapper.defaultFont = BaseFont.createFont(MyFontMapper.KOREAN_FONT_GO_THIC, MyFontMapper.KOREAN_ENCODING_H, BaseFont.NOT_EMBEDDED);
} else {
//默认也设置一个吧45422 , 不设置默认字体, linux英文环境导不出来
MyFontMapper.defaultFont = BaseFont.createFont(MyFontMapper.CHINESE_SIMPLIFIED_FONT, MyFontMapper.CHINESE_SIMPLIFIED_ENCODING_H, BaseFont.NOT_EMBEDDED);
}
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
return fontMapper;
}
public static class MyFontMapper implements FontMapper {
public static final String CHINESE_SIMPLIFIED_FONT = "STSong-Light";
public static final String CHINESE_SIMPLIFIED_ENCODING_H = "UniGB-UCS2-H";
public static final String CHINESE_SIMPLIFIED_ENCODING_V = "UniGB-UCS2-V";
public static final String CHINESE_TRADITIONAL_FONT_M_HEI = "MHei-Medium";
public static final String CHINESE_TRADITIONAL_FONT_M_SUNG = "MSung-Light";
public static final String CHINESE_TRADITIONAL_ENCODING_H = "UniCNS-UCS2-H";
public static final String CHINESE_TRADITIONAL_ENCODING_V = "UniCNS-UCS2-V";
public static final String JAPANESE_FONT_GO = "HeiseiKakuGo-W5";
public static final String JAPANESE_FONT_MIN = "HeiseiMin-W3";
public static final String JAPANESE_ENCODING_H = "UniJIS-UCS2-H";
public static final String JAPANESE_ENCODING_V = "UniJIS-UCS2-V";
public static final String JAPANESE_ENCODING_HW_H = "UniJIS-UCS2-HW-H";
public static final String JAPANESE_ENCODING_HW_V = "UniJIS-UCS2-HW-V";
public static final String KOREAN_FONT_GO_THIC = "HYGoThic-Medium";
public static final String KOREAN_FONT_S_MYEONG_JO = "HYSMyeongJo-Medium";
public static final String KOREAN_ENCODING_H = "UniKS-UCS2-H";
public static final String KOREAN_ENCODING_V = "UniKS-UCS2-V";
public static BaseFont defaultFont;
private HashMap mapper;
public static class BaseFontParameters {
public String fontName;
public String encoding;
public boolean embedded;
public boolean cached;
public byte ttfAfm[];
public byte pfb[];
public BaseFontParameters(String fontName) {
this.fontName = fontName;
encoding = BaseFont.IDENTITY_H;
embedded = true;
cached = true;
}
/**
* toString方法
*
* @return 对象说明
*/
public String toString() {
return "{fontName:" + fontName + ",encoding:" + encoding + ",embedded:" + embedded + ",cached:" + cached;
}
}
public MyFontMapper() {
mapper = new HashMap();
}
/**
* 转化字体
*
* @param font awt字体
* @return pdf字体
*/
public BaseFont awtToPdf(Font font) {
try {
BaseFontParameters p = getBaseFontParameters(font.getFontName());
/*
* alex:不明真相
* 经测试,Arial粗体在getFontName返回的是Arial Bold,可以在上面的方法中得到对应的p
* 所以getFontName是有用的
* 但是在linux上测试,宋体在getFontName返回的却是Dialog这种逻辑字体,只有getName才返回SimSun
* 所以还需要getBaseFontParameters一下
*/
if (p == null) {
p = getBaseFontParameters(font.getName());
}
if (p != null) {
return BaseFont.createFont(p.fontName, p.encoding, p.embedded, p.cached, p.ttfAfm, p.pfb);
} else {
// FRContext.getLogger().info(Inter.getLocText("Utils-Font_Not_Found") + ":" + font.getFontName());
// alex:未找到合适的字体,如果有默认字体,用之,没有的话,根据Bold & Italic设置字体
if (defaultFont != null) {
return defaultFont;
} else {
String fontKey = BaseFont.COURIER;
if (font.isBold() && font.isItalic()) {
fontKey = BaseFont.COURIER_BOLDOBLIQUE;
} else if (font.isBold()) {
fontKey = BaseFont.COURIER_BOLD;
} else if (font.isItalic()) {
fontKey = BaseFont.COURIER_OBLIQUE;
}
return BaseFont.createFont(fontKey, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
}
}
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
throw new ExceptionConverter(e);
}
}
/**
* 转化字体
*
* @param font pdf字体
* @param size 大小
* @return 转化后awt字体
*/
public Font pdfToAwt(BaseFont font, int size) {
String[][] names = font.getFullFontName();
if (names.length == 1) {
return new Font(names[0][3], 0, size);
}
String name10 = null;
String name3x = null;
for (int k = 0; k < names.length; ++k) {
String[] name = names[k];
if (ComparatorUtils.equals(name[0], "1") && ComparatorUtils.equals(name[1], "0")) {
name10 = name[3];
} else if (ComparatorUtils.equals(name[2], "1033")) {
name3x = name[3];
break;
}
}
String finalName = name3x;
if (finalName == null) {
finalName = name10;
}
if (finalName == null) {
finalName = names[0][3];
}
return new Font(finalName, 0, size);
}
private BaseFontParameters getBaseFontParameters(String name) {
return (BaseFontParameters) mapper.get(name);
}
protected void insertNames(String names[][], String path) {
String main = null;
int k = 0;
do {
if (k >= names.length) {
break;
}
String[] name = names[k];
if (ComparatorUtils.equals(name[2], "1033")) {
main = name[3];
break;
}
k++;
} while (true);
if (main == null) {
main = names[0][3];
}
BaseFontParameters p = new BaseFontParameters(path);
// alex:不一样的名字可能对应同样的BaseFontParameters,比如simsun和宋体都对应同样的p
mapper.put(main, p);
for (k = 0; k < names.length; k++) {
mapper.put(names[k][3], p);
}
}
/**
* 插入目录里的字体
*
* @param dir 目录
* @return 插入数量
*/
public int insertDirectory(String dir) {
File file = new File(dir);
if (!file.exists() || !file.isDirectory()) {
return 0;
}
File[] files = file.listFiles();
int count = 0;
for (int k = 0; k < files.length; k++) {
file = files[k];
String name = file.getPath().toLowerCase();
try {
if (matchPostfix(name)) {
String[][] names = BaseFont.getFullFontName(file.getPath(), BaseFont.CP1252, null);
insertNames(names, file.getPath());
count++;
} else if (name.endsWith(".ttc")) {
String[] ttcs = BaseFont.enumerateTTCNames(file.getPath());
for (int j = 0; j < ttcs.length; j++) {
String nt = String.valueOf(new StringBuffer(file.getPath()).append(',').append(j));
String[][] names = BaseFont.getFullFontName(nt, BaseFont.CP1252, null);
insertNames(names, nt);
}
count++;
}
} catch (Exception exception) {
FRContext.getLogger().error(exception.getMessage(), exception);
}
}
return count;
}
private boolean matchPostfix(String name) {
return name.endsWith(".ttf") || name.endsWith(".otf") || name.endsWith(".afm");
}
}
}

2
designer_chart/src/com/fr/design/module/ChartDesignerModule.java

@ -1 +1 @@
package com.fr.design.module; import com.fr.chart.base.ChartInternationalNameContentBean; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.actions.core.ActionFactory; import com.fr.design.chart.ChartDialog; import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartWidgetOption; import com.fr.design.gui.core.WidgetOption; import com.fr.design.mainframe.App; import com.fr.design.mainframe.ChartAndWidgetPropertyPane; import com.fr.design.mainframe.ChartPropertyPane; import com.fr.form.ui.ChartEditor; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.stable.bridge.StableFactory; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import javax.swing.*; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 13-7-8 * Time: 上午9:13 */ public class ChartDesignerModule extends DesignModule { public void start() { super.start(); dealBeforeRegister(); register(); registerFloatEditor(); } protected void dealBeforeRegister(){ StableFactory.registerMarkedClass(ExtraChartDesignClassManagerProvider.XML_TAG, ChartTypeInterfaceManager.class); StableFactory.getStaticMarkedInstanceObjectFromClass(ExtraChartDesignClassManagerProvider.XML_TAG, ExtraChartDesignClassManagerProvider.class); } private void register(){ DesignModuleFactory.registerHyperlinkGroupType(new ChartHyperlinkGroup()); DesignModuleFactory.registerChartEditorClass(ChartEditor.class); DesignModuleFactory.registerChartComponentClass(ChartComponent.class); DesignModuleFactory.registerChartDialogClass(ChartDialog.class); DesignModuleFactory.registerChartAndWidgetPropertyPane(ChartAndWidgetPropertyPane.class); DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class); ActionFactory.registerChartPreStyleAction(new ChartPreStyleAction()); } protected void registerFloatEditor() { ActionFactory.registerChartCollection(ChartCollection.class); } /** * 返回设计器能打开的模板类型的一个数组列表 * * @return 可以打开的模板类型的数组 */ public App<?>[] apps4TemplateOpener() { return new App[0]; } protected WidgetOption[] options4Show() { ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames(); ChartWidgetOption[] child = new ChartWidgetOption[typeName.length]; for (int i = 0; i < typeName.length; i++) { String plotID = typeName[i].getPlotID(); Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); if(rowChart == null) { continue; } String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(plotID); Icon icon = IOUtils.readIcon(iconPath); child[i] = new ChartWidgetOption(Inter.getLocText(typeName[i].getName()), icon, ChartEditor.class, rowChart[0]); } return child; } public String getInterNationalName() { return Inter.getLocText("FR-Chart-Design_ChartModule"); } } package com.fr.design.module; import com.fr.chart.base.ChartInternationalNameContentBean; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.actions.core.ActionFactory; import com.fr.design.chart.ChartDialog; import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartWidgetOption; import com.fr.design.gui.core.WidgetOption; import com.fr.design.mainframe.App; import com.fr.design.mainframe.ChartPropertyPane; import com.fr.form.ui.ChartEditor; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.stable.bridge.StableFactory; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import javax.swing.*; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 13-7-8 * Time: 上午9:13 */ public class ChartDesignerModule extends DesignModule { public void start() { super.start(); dealBeforeRegister(); register(); registerFloatEditor(); } protected void dealBeforeRegister(){ StableFactory.registerMarkedClass(ExtraChartDesignClassManagerProvider.XML_TAG, ChartTypeInterfaceManager.class); StableFactory.getStaticMarkedInstanceObjectFromClass(ExtraChartDesignClassManagerProvider.XML_TAG, ExtraChartDesignClassManagerProvider.class); } private void register(){ DesignModuleFactory.registerHyperlinkGroupType(new ChartHyperlinkGroup()); DesignModuleFactory.registerChartEditorClass(ChartEditor.class); DesignModuleFactory.registerChartComponentClass(ChartComponent.class); DesignModuleFactory.registerChartDialogClass(ChartDialog.class); DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class); ActionFactory.registerChartPreStyleAction(new ChartPreStyleAction()); } protected void registerFloatEditor() { ActionFactory.registerChartCollection(ChartCollection.class); } /** * 返回设计器能打开的模板类型的一个数组列表 * * @return 可以打开的模板类型的数组 */ public App<?>[] apps4TemplateOpener() { return new App[0]; } protected WidgetOption[] options4Show() { ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames(); ChartWidgetOption[] child = new ChartWidgetOption[typeName.length]; for (int i = 0; i < typeName.length; i++) { String plotID = typeName[i].getPlotID(); Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); if(rowChart == null) { continue; } String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(plotID); Icon icon = IOUtils.readIcon(iconPath); child[i] = new ChartWidgetOption(Inter.getLocText(typeName[i].getName()), icon, ChartEditor.class, rowChart[0]); } return child; } public String getInterNationalName() { return Inter.getLocText("FR-Chart-Design_ChartModule"); } }

95
designer_chart/src/com/fr/design/module/ChartStartModule.java

@ -1,95 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.design.module;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.io.XMLEncryptUtils;
import com.fr.chart.base.ChartInternationalNameContentBean;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.chart.module.ChartModule;
import com.fr.design.DesignerEnvManager;
import com.fr.design.chart.gui.ChartWidgetOption;
import com.fr.design.gui.core.WidgetOption;
import com.fr.design.mainframe.*;
import com.fr.file.FILE;
import com.fr.form.ui.ChartBook;
import com.fr.form.ui.ChartEditor;
import com.fr.general.Inter;
import com.fr.general.ModuleContext;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-13
* Time: 下午2:56
*/
public class ChartStartModule extends ChartDesignerModule {
protected void dealBeforeRegister(){
ModuleContext.startModule(ChartModule.class.getName());
}
protected void registerFloatEditor() {
}
protected WidgetOption[] options4Show() {
ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames();
ChartWidgetOption[] child = new ChartWidgetOption[typeName.length];
for (int i = 0; i < typeName.length; i++) {
Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(typeName[i].getPlotID());
child[i] = new ChartWidgetOption(Inter.getLocText(typeName[i].getName()), BaseUtils
.readIcon("com/fr/design/images/form/toolbar/" + typeName[i].getName() + ".png"),
ChartEditor.class, rowChart[0]);
}
return child;
}
/**
* 应用打开器
* @return 应用
*/
public App<?>[] apps4TemplateOpener() {
return new App[]{new AbstractAppProvider<ChartBook>() {
@Override
public String[] defaultExtentions() {
return new String[]{"crt"};
}
@Override
public JTemplate<ChartBook, ?> openTemplate(FILE tplFile) {
return new JChart(asIOFile(tplFile), tplFile);
}
@Override
public ChartBook asIOFile(FILE file) {
if (XMLEncryptUtils.isCptEncoded() &&
!XMLEncryptUtils.checkVaild(DesignerEnvManager.getEnvManager().getEncryptionKey())) {
if (!new DecodeDialog(file).isPwdRight()) {
FRContext.getLogger().error(Inter.getLocText("FR-Chart-Password_Error"));
return new ChartBook();
}
}
ChartBook tpl = new ChartBook();
//打开通知
FRContext.getLogger().info(Inter.getLocText(new String[]{"LOG-Is_Being_Openned", "LOG-Please_Wait"},
new String[]{"\"" + file.getName() + "\"" + ",", "..."}));
try {
tpl.readStream(file.asInputStream());
} catch (Exception exp) {
FRContext.getLogger().error("Failed to generate frm from " + file, exp);
return null;
}
return tpl;
}
}};
}
}

18
designer_chart/src/com/fr/start/ChartSplashPane.java

@ -1,18 +0,0 @@
package com.fr.start;
import java.awt.Image;
import com.fr.base.BaseUtils;
public class ChartSplashPane extends SplashPane{
/**
* 创建启动画面的背景图片
*
* @return 背景图片
*
*/
public Image createSplashBackground() {
return BaseUtils.readImage("/com/fr/design/images/splash4Chart.png");
}
}

406
designer_chart/src/com/fr/start/Designer4Chart.java

@ -1,406 +0,0 @@
/*
* Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved.
*/
package com.fr.start;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.file.WebPreviewUtils;
import com.fr.design.actions.help.AboutAction;
import com.fr.design.constants.UIConstants;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.NewTemplatePane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.itoolbar.UILargeToolbar;
import com.fr.design.mainframe.*;
import com.fr.design.mainframe.actions.*;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.*;
import com.fr.design.module.ChartStartModule;
import com.fr.general.FRFont;
import com.fr.general.Inter;
import com.fr.general.web.ParameterConsts;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.border.MatteBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
/**
* Created by IntelliJ IDEA.
* Author : daisy
* Version: 6.5.6
* Date: 14-10-13
* Time: 上午11:02
*/
public class Designer4Chart extends BaseDesigner {
private static final int TOOLBAR_HEIGHT = 53;
private static final int TOOLBAR_WIDTH =60+34+7+1+7 ;
private static final int GAP = 7;
private static final int EAST_WIDTH = 292;
private static final int MESSAGEPORT = 51460;
private UIButton saveButton;
private UIButton undo;
private UIButton redo;
private UIButton run;
private UIButton copy;
/**
* 主函数
*
* @param args 入口参数
*/
public static void main(String[] args) {
new Designer4Chart(args);
}
public Designer4Chart(String[] args) {
super(args);
}
@Override
protected String module2Start() {
EastRegionContainerPane.getInstance().setDownPaneVisible(false);
EastRegionContainerPane.getInstance().setContainerWidth(EAST_WIDTH);
return ChartStartModule.class.getName();
}
protected void initLanguage() {
//这两句的位置不能随便调换,因为会影响语言切换的问题
FRContext.setLanguage(Constants.LANGUAGE_ENGLISH);
}
protected void initDefaultFont(){
FRContext.getDefaultValues().setFRFont(FRFont.getInstance("Meiryo", Font.PLAIN, 9));
}
/**
* build得路径
* @return build得路径
*/
public String buildPropertiesPath() {
return "/com/fr/chart/base/build.properties";
}
/**
* 创建文件菜单项
* @return 菜单项
*/
public ShortCut[] createNewFileShortCuts() {
ArrayList<ShortCut> shortCuts = new ArrayList<ShortCut>();
shortCuts.add(new NewChartAction());
return shortCuts.toArray(new ShortCut[shortCuts.size()]);
}
/**
* 创建新模版
* @return 模版
*/
public JTemplate<?, ?> createNewTemplate() {
return new JChart();
}
protected void resetToolTips(){
copy.setToolTipText(Inter.getLocText("FR-Chart-Action_Copy")+"JS");
run.setToolTipText(PREVIEW.getMenuKeySetName());
}
/**
* 创建设计器上几个比较大的图标新建cpt保存前进后退运行
*
* @return 返回大图标对应的工具栏
*/
public UILargeToolbar createLargeToolbar() {
UILargeToolbar largeToolbar = new UILargeToolbar(FlowLayout.LEFT){
public Dimension getPreferredSize() {
return new Dimension(TOOLBAR_WIDTH ,TOOLBAR_HEIGHT);
}
};
largeToolbar.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 4));
largeToolbar.add(new JPanel() {
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
dim.width = 1;
return dim;
}
});
createRunButton();
largeToolbar.add(run);
largeToolbar.add(new JPanel() {
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
dim.width = GAP;
return dim;
}
});
largeToolbar.addSeparator(new Dimension(2, 42));
largeToolbar.add(new JPanel() {
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
dim.width = GAP;
return dim;
}
});
createCopyButton();
largeToolbar.add(copy);
largeToolbar.add(new JPanel() {
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
dim.width = GAP;
return dim;
}
});
largeToolbar.addSeparator(new Dimension(2, 42));
largeToolbar.setBorder(new MatteBorder(new Insets(0, 0, 1, 0), UIConstants.LINE_COLOR));
return largeToolbar;
}
protected int getStartPort(){
return MESSAGEPORT;
}
protected DesignerFrame createDesignerFrame(){
return new DesignerFrame4Chart(this);
}
/**
* 创建上面一排的工具栏按钮
*
* @return 按钮
*/
public UIButton[] createUp() {
return new UIButton[]{createSaveButton(), createUndoButton(), createRedoButton()};
}
private UIButton createRunButton() {
run = new UIButton(BaseUtils.readIcon("com/fr/design/images/buttonicon/pageb24.png")) {
public Dimension getPreferredSize() {
return new Dimension(34, 43);
}
};
run.setToolTipText(PREVIEW.getMenuKeySetName());
run.set4ChartLargeToolButton();
run.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jt == null) {
return;
}
onChartPreview(jt);
}
});
return run;
}
public static void onChartPreview(JTemplate<?, ?> jt) {
WebPreviewUtils.actionPerformed(jt, null, ParameterConsts.CHARTLET);
}
public static final MenuKeySet PREVIEW = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'P';
}
@Override
public String getMenuName() {
return Inter.getLocText("FR-Chart-Template_Preview");
}
@Override
public KeyStroke getKeyStroke() {
return KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_MASK);
}
};
private UIButton createCopyButton(){
copy = new UIButton(BaseUtils.readIcon("com/fr/design/images/copyjs.png")) {
public Dimension getPreferredSize() {
return new Dimension(34, 43);
}
};
copy.setToolTipText(Inter.getLocText("FR-Chart-Action_Copy")+"JS");
copy.set4ChartLargeToolButton();
copy.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jt == null) {
return;
}
DesignerContext.getDesignerFrame().refreshToolbar();
jt.stopEditing();
if (!jt.isSaved() && !jt.saveTemplate2Env()) {
return;
}
//复制代码
jt.copyJS();
}
});
return copy;
}
private UIButton createSaveButton() {
saveButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/save.png"));
saveButton.setToolTipText(KeySetUtils.SAVE_TEMPLATE.getMenuKeySetName());
saveButton.set4ToolbarButton();
saveButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
jt.stopEditing();
jt.saveTemplate();
jt.requestFocus();
}
});
return saveButton;
}
private UIButton createUndoButton() {
undo = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/undo.png"));
undo.setToolTipText(KeySetUtils.UNDO.getMenuKeySetName());
undo.set4ToolbarButton();
undo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jt != null) {
jt.undo();
}
}
});
return undo;
}
private UIButton createRedoButton() {
redo = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/redo.png"));
redo.setToolTipText(KeySetUtils.REDO.getMenuKeySetName());
redo.set4ToolbarButton();
redo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jt != null) {
jt.redo();
}
}
});
return redo;
}
/**
* 重置工具条
* @param toolbarComponent 工具栏
* @param plus 对象
* @return 工具条对象
*/
public JComponent resetToolBar(JComponent toolbarComponent, ToolBarMenuDockPlus plus) {
return plus.toolBar4Authority();
}
public NewTemplatePane getNewTemplatePane(){
return new NewTemplatePane() {
@Override
public Icon getNew() {
return BaseUtils.readIcon("/com/fr/design/images/newchart_normal.png");
}
@Override
public Icon getMouseOverNew() {
return BaseUtils.readIcon("/com/fr/design/images/newchart_over.png");
}
@Override
public Icon getMousePressNew() {
return BaseUtils.readIcon("/com/fr/design/images/newchart_press.png");
}
};
};
@Override
protected void refreshLargeToolbarState() {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jt == null) {
return;
}
saveButton.setEnabled(!jt.isSaved());
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(HistoryTemplateListPane.getInstance().getHistoryList());
MutilTempalteTabPane.getInstance().repaint();
if (DesignerEnvManager.getEnvManager().isSupportUndo()) {
undo.setEnabled(jt.canUndo());
redo.setEnabled(jt.canRedo());
} else {
undo.setEnabled(false);
redo.setEnabled(false);
}
}
protected SplashPane createSplashPane() {
return new ChartSplashPane();
}
/**
*更新工具栏
*/
public void updateToolBarDef() {
refreshLargeToolbarState();
}
protected void addCloseCurrentTemplateAction(MenuDef menuDef) {
}
protected void addPreferenceAction(MenuDef menuDef) {
}
protected void addSwitchExistEnvAction(MenuDef menuDef) {
}
@Override
public MenuDef[] createTemplateShortCuts(ToolBarMenuDockPlus plus) {
MenuDef menuDef = new MenuDef(KeySetUtils.EXPORT_CHART.getMenuKeySetName(), KeySetUtils.EXPORT_CHART.getMnemonic());
menuDef.addShortCut(plus.shortcut4ExportMenu());
return new MenuDef[] {menuDef};
}
/**
* 创建帮助菜单得菜单项
* @return 菜单项
*/
public ShortCut[] createHelpShortCuts() {
resetToolTips();
return new ShortCut[]{
new ChartWebAction(),
SeparatorDef.DEFAULT,
new ChartFeedBackAciton(),
SeparatorDef.DEFAULT,
new UpdateOnlineAction(),
new AboutAction()
};
}
protected ShortCut openTemplateAction(){
return new OpenChartAction();
}
protected String[] startFileSuffix(){
return new String[]{".crt"};
}
}

22
designer_form/src/com/fr/design/mainframe/CoverReportPane.java

@ -44,17 +44,17 @@ public class CoverReportPane extends CoverPane implements HelpDialogHandler{
super(); super();
this.helpMsg = helpMsg; this.helpMsg = helpMsg;
add(controlButton); add(controlButton);
if (WidgetPropertyPane.getInstance().getEditingFormDesigner() != null) { // if (WidgetPropertyPane.getInstance().getEditingFormDesigner() != null) {
WidgetPropertyPane.getInstance().getEditingFormDesigner().addDesignerEditListener(new DesignerEditListener() { // WidgetPropertyPane.getInstance().getEditingFormDesigner().addDesignerEditListener(new DesignerEditListener() {
@Override // @Override
public void fireCreatorModified(DesignerEvent evt) { // public void fireCreatorModified(DesignerEvent evt) {
if (evt.getCreatorEventID() == (DesignerEvent.CREATOR_DELETED) // if (evt.getCreatorEventID() == (DesignerEvent.CREATOR_DELETED)
|| evt.getCreatorEventID() == (DesignerEvent.CREATOR_RESIZED)) { // || evt.getCreatorEventID() == (DesignerEvent.CREATOR_RESIZED)) {
destroyHelpDialog(); // destroyHelpDialog();
} // }
} // }
}); // });
} // }
} }
public String getHelpMsg() { public String getHelpMsg() {

6
designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java

@ -89,6 +89,12 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree
public void refreshDockingView() { public void refreshDockingView() {
FormDesigner formDesigner = this.getEditingFormDesigner(); FormDesigner formDesigner = this.getEditingFormDesigner();
removeAll(); removeAll();
if(this.componentTree != null) {
this.componentTree.removeAll();
}
if(this.treeComboBox != null) {
this.treeComboBox.removeAll();
}
if (formDesigner == null) { if (formDesigner == null) {
clearDockingView(); clearDockingView();
return; return;

Loading…
Cancel
Save