Browse Source

CHART-13666 图表类型自动匹配设计器面板

feature/big-screen
白岳 5 years ago
parent
commit
e6df73ae30
  1. 13
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java
  2. 8
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java
  3. 28
      designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java
  4. BIN
      designer-base/src/main/resources/com/fr/design/images/m_insert/auto_chart.png
  5. 17
      designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java
  6. 69
      designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java
  7. 108
      designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java
  8. 230
      designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java
  9. 1
      designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java
  10. 78
      designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java
  11. 3
      designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java
  12. 41
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java
  13. BIN
      designer-chart/src/main/resources/com/fr/design/images/form/toolbar/auto_chart.png
  14. 113
      designer-form/src/main/java/com/fr/design/designer/creator/XAutoChartCreator.java
  15. 625
      designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java
  16. 2
      designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java
  17. 57
      designer-realize/src/main/java/com/fr/design/actions/insert/cell/AutoChartCellAction.java
  18. 53
      designer-realize/src/main/java/com/fr/design/actions/insert/flot/AutoChartFloatAction.java
  19. 11
      designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java
  20. 24
      designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartCellEditor.java
  21. 18
      designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartFloatEditor.java
  22. 18
      designer-realize/src/main/java/com/fr/design/cell/editor/ChartCellEditor.java
  23. 16
      designer-realize/src/main/java/com/fr/design/cell/editor/ChartFloatEditor.java
  24. 10
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java
  25. 49
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

13
designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java

@ -11,6 +11,10 @@ import com.fr.general.IOUtils;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
@ -22,10 +26,6 @@ import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public class UICheckListPopup extends UIPopupMenu { public class UICheckListPopup extends UIPopupMenu {
private List<ActionListener> listeners = new ArrayList<ActionListener>(); private List<ActionListener> listeners = new ArrayList<ActionListener>();
@ -68,6 +68,11 @@ public class UICheckListPopup extends UIPopupMenu {
addCheckboxValues(values); addCheckboxValues(values);
} }
public void refreshCheckboxValues(Object[] value){
this.values = value;
addCheckboxValues(values);
}
public void addCheckboxValues(Object[] value) { public void addCheckboxValues(Object[] value) {
checkboxPane.removeAll(); checkboxPane.removeAll();
checkBoxList.clear(); checkBoxList.clear();

8
designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java

@ -17,6 +17,9 @@ import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener; import javax.swing.event.PopupMenuListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
@ -29,9 +32,6 @@ import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/** /**
* 设计器下拉复选框组件 * 设计器下拉复选框组件
@ -198,7 +198,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
*/ */
public void refreshCombo(Object[] value) { public void refreshCombo(Object[] value) {
this.values = value; this.values = value;
this.popup.addCheckboxValues(value); this.popup.refreshCheckboxValues(value);
} }
/** /**

28
designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java

@ -19,11 +19,10 @@ import com.fr.plugin.solution.sandbox.collection.PluginSandboxCollections;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Constructor;
import java.awt.Dialog; import java.awt.Dialog;
import java.awt.Frame; import java.awt.Frame;
import java.awt.Window; import java.awt.Window;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
/** /**
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
@ -45,6 +44,7 @@ public class DesignModuleFactory {
private Class<Widget> chartEditorClass; private Class<Widget> chartEditorClass;
private Class<MiddleChartComponent> chartComponentClass; private Class<MiddleChartComponent> chartComponentClass;
private Class<MiddleChartDialog> chartDialogClass; private Class<MiddleChartDialog> chartDialogClass;
private Class<MiddleChartDialog> autoChartDialogClass;
private Class<? extends BaseChartPropertyPane> chartPropertyPaneClass; private Class<? extends BaseChartPropertyPane> chartPropertyPaneClass;
private Class newFormAction; private Class newFormAction;
private Class formParaDesigner; private Class formParaDesigner;
@ -100,6 +100,10 @@ public class DesignModuleFactory {
instance.chartDialogClass = cd; instance.chartDialogClass = cd;
} }
public static void registerAutoChartDialogClass(Class autoChartDialogClass) {
instance.autoChartDialogClass = autoChartDialogClass;
}
public static void registerChartPropertyPaneClass(Class<? extends BaseChartPropertyPane> p) { public static void registerChartPropertyPaneClass(Class<? extends BaseChartPropertyPane> p) {
instance.chartPropertyPaneClass = p; instance.chartPropertyPaneClass = p;
} }
@ -205,6 +209,26 @@ public class DesignModuleFactory {
return null; return null;
} }
/**
* kunsnat: 初始化图表向导对话框, 调用静态方法showWindow, 参数window.
*
* @return 返回调出的图表自动推荐ChartDialog
*/
public static MiddleChartDialog getAutoChartDialog(Window window) {
try {
Constructor<MiddleChartDialog> c;
if (window instanceof Frame) {
c = instance.autoChartDialogClass.getConstructor(Frame.class);
} else {
c = instance.autoChartDialogClass.getConstructor(Dialog.class);
}
return c.newInstance(window);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return null;
}
/** /**
* kunsnat: 获取图表属性界面 * kunsnat: 获取图表属性界面
* *

BIN
designer-base/src/main/resources/com/fr/design/images/m_insert/auto_chart.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

17
designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java

@ -12,8 +12,10 @@ import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.chart.fun.ChartTypeUIProvider; import com.fr.design.chart.fun.ChartTypeUIProvider;
import com.fr.design.chart.gui.ChartWidgetOption; import com.fr.design.chart.gui.ChartWidgetOption;
import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.condition.ConditionAttributesPane;
import com.fr.design.gui.core.CustomWidgetOption;
import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOption;
import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.ChartsConfigPane; import com.fr.design.mainframe.chart.ChartsConfigPane;
@ -41,6 +43,7 @@ import com.fr.design.type.ui.RangeChartTypeUI;
import com.fr.design.type.ui.StockChartTypeUI; import com.fr.design.type.ui.StockChartTypeUI;
import com.fr.design.type.ui.XYScatterChartTypeUI; import com.fr.design.type.ui.XYScatterChartTypeUI;
import com.fr.extended.chart.AbstractChart; import com.fr.extended.chart.AbstractChart;
import com.fr.form.ui.ChartAutoEditor;
import com.fr.form.ui.ChartEditor; import com.fr.form.ui.ChartEditor;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
@ -162,8 +165,13 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
public static WidgetOption[] initWidgetOption() { public static WidgetOption[] initWidgetOption() {
String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDs(); String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDs();
ChartWidgetOption[] child = new ChartWidgetOption[chartIDs.length]; List<WidgetOption> child = new ArrayList<>();
int index = 0; if (ChartTypeManager.AUTO_CHART) {
//TODO @Bjorn 视觉样式优化icon
child.add(new CustomWidgetOption(Toolkit.i18nText("Fine-Design_Chart_M_Popup_Auto_Chart_Type"),
IOUtils.readIcon("com/fr/design/images/form/toolbar/auto_chart.png"), ChartAutoEditor.class));
}
for (String chartID : chartIDs) { for (String chartID : chartIDs) {
ChartProvider[] rowChart = ChartTypeManager.getInstance().getCharts(chartID); ChartProvider[] rowChart = ChartTypeManager.getInstance().getCharts(chartID);
if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(chartID)) { if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(chartID)) {
@ -172,11 +180,10 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
String name = ChartTypeInterfaceManager.getInstance().getName(chartID); String name = ChartTypeInterfaceManager.getInstance().getName(chartID);
String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(chartID); String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(chartID);
Icon icon = IOUtils.readIcon(iconPath); Icon icon = IOUtils.readIcon(iconPath);
child[index] = new ChartWidgetOption(name, icon, ChartEditor.class, chartID); child.add(new ChartWidgetOption(name, icon, ChartEditor.class, chartID));
index++;
} }
return child; return child.toArray(new WidgetOption[child.size()]);
} }
private static void readVanChart() { private static void readVanChart() {

69
designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java

@ -0,0 +1,69 @@
package com.fr.design.chart;
import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.plugin.chart.vanchart.VanChart;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-28
*/
public class AutoChartDialog extends ChartDialog {
private AutoChartTypePane autoChartTypePane;
public AutoChartDialog(Frame owner) {
super(owner);
}
public AutoChartDialog(Dialog owner) {
super(owner);
}
protected Component initCenterPane() {
autoChartTypePane = new AutoChartTypePane();
return autoChartTypePane;
}
protected void addOkAction() {
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ChartCollection chartCollection = (ChartCollection) getChartCollection();
autoChartTypePane.update(chartCollection);
if (chartCollection.getChartCount() > 0) {
doOK();
} else {
doCancel();
}
}
});
}
/**
* 更新新建的图表 ChartCollection
*/
public void populate(BaseChartCollection cc) {
super.populate(cc);
ChartCollection chartCollection = (ChartCollection) getChartCollection();
VanChart vanChart = chartCollection.getSelectedChartProvider(VanChart.class);
if (vanChart == null) {
return;
}
TopDefinitionProvider filterDefinition = vanChart.getFilterDefinition();
if (filterDefinition == null) {
return;
}
String tableName = vanChart.getFilterDefinition().getTableName();
String[] dataFields = vanChart.getFilterDefinition().getDataFields();
autoChartTypePane.populate(tableName, dataFields);
}
}

108
designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java

@ -0,0 +1,108 @@
package com.fr.design.chart;
import com.fr.base.ScreenResolution;
import com.fr.base.chart.BaseChartPainter;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.base.chart.result.WebChartIDInfo;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.script.Calculator;
import javax.swing.Icon;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-29
*/
public class AutoChartIcon implements Icon {
private static final int WIDTH = 500;
private static final int HEIGHT = 281;
private ChartCollection chartCollection;
private CallbackEvent callbackEvent;
private String chartName;
public AutoChartIcon(ChartCollection chartCollection) {
this.chartCollection = chartCollection;
initChartName();
}
public ChartCollection getChartCollection() {
return chartCollection;
}
public String getChartName() {
return chartName;
}
private void initChartName() {
Chart chart = chartCollection.getSelectedChart(Chart.class);
String[] subName = ChartTypeInterfaceManager.getInstance().getSubName(chart.getPlot().getPlotID());
chartName = subName[0];
}
public void registerCallBackEvent(CallbackEvent callbackEvent) {
this.callbackEvent = callbackEvent;
}
/**
* 画出缩略图Icon
*
* @param g 图形的上下文
* @param c 所在的Component
* @param x 缩略图的起始坐标x
* @param y 缩略图的起始坐标y
*/
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(),
WebChartIDInfo.createEmptyDesignerInfo(), getIconWidth(), getIconHeight());
int resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getJTemplateResolution();
if (resolution == 0) {
resolution = ScreenResolution.getScreenResolution();
}
Graphics2D g2d = (Graphics2D) g;
Paint oldPaint = g2d.getPaint();
g.translate(x, y);
g2d.setPaint(Color.white);
g2d.fillRect(0, 0, getIconWidth(), getIconHeight());
painter.paint(g2d, getIconWidth(), getIconHeight(), resolution, null, callbackEvent);
g.translate(-x, -y);
g2d.setPaint(oldPaint);
}
/**
* 返回缩略图的宽度
*
* @return int 缩略图宽度
*/
@Override
public int getIconWidth() {
return WIDTH;
}
/**
* 返回缩略图的高度
*
* @return int 缩略图高度
*/
@Override
public int getIconHeight() {
return HEIGHT;
}
}

230
designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java

@ -0,0 +1,230 @@
package com.fr.design.chart;
import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.BaseChartGetter;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataComboBox;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombocheckbox.UIComboCheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.plugin.chart.area.VanChartAreaPlot;
import com.fr.plugin.chart.column.VanChartColumnPlot;
import com.fr.plugin.chart.line.VanChartLinePlot;
import com.fr.plugin.chart.vanchart.VanChart;
import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.ListCellRenderer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-29
*/
public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent {
private JList chartViewList;
private DefaultListModel chartResultModel;
private UIButton refreshButton;
private TableDataComboBox tableNameComboBox;
private UIComboCheckBox dataFieldBox;
public AutoChartTypePane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
initButtonGroup();
initRefreshLabel();
initDataFiledBox();
JPanel contentPane = createContentPane();
chartViewList = new JList();
chartResultModel = new DefaultListModel();
chartViewList.setModel(chartResultModel);
chartViewList.setVisibleRowCount(0);
chartViewList.setLayoutOrientation(JList.HORIZONTAL_WRAP);
chartViewList.setCellRenderer(iconCellRenderer);
JScrollPane subListPane = new JScrollPane(chartViewList);
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, contentPane, subListPane);
splitPane.setDividerLocation(60);
splitPane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Chart_M_Popup_Auto_Chart_Type")));
this.add(splitPane);
}
ListCellRenderer iconCellRenderer = new DefaultListCellRenderer() {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
this.setText("");
AutoChartIcon chartIcon = (AutoChartIcon) value;
this.setIcon(chartIcon);
setHorizontalAlignment(UILabel.CENTER);
if (isSelected) {
// 深蓝色.
this.setBackground(new Color(57, 107, 181));
this.setBorder(GUICoreUtils.createTitledBorder(chartIcon.getChartName(), Color.WHITE));
} else {
this.setBorder(GUICoreUtils.createTitledBorder(chartIcon.getChartName()));
}
return this;
}
};
private JPanel createContentPane() {
JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
JPanel tableDataPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
panel.add(tableDataPane);
tableDataPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":"));
tableNameComboBox.setPreferredSize(new Dimension(96, 20));
tableDataPane.add(tableNameComboBox);
JPanel areaNamePane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
panel.add(areaNamePane);
areaNamePane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Field") + ":"));
areaNamePane.add(dataFieldBox);
panel.add(refreshButton);
return panel;
}
private void initButtonGroup() {
dataFieldBox = new UIComboCheckBox(new Object[0]);
dataFieldBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkButtonState();
}
});
}
private void initDataFiledBox() {
tableNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource());
tableNameComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
refreshBox();
checkButtonState();
}
}
});
}
private void checkButtonState() {
if (tableNameComboBox.getSelectedItem() != null && dataFieldBox.getSelectedValues().length > 0) {
refreshButton.setEnabled(true);
} else {
refreshButton.setEnabled(false);
}
}
private void refreshBox() {
TableDataWrapper dataWrap = tableNameComboBox.getSelectedItem();
if (dataWrap == null) {
return;
}
dataFieldBox.clearText();
List<String> columnNameList = dataWrap.calculateColumnNameList();
dataFieldBox.refreshCombo(columnNameList.toArray());
}
private void initRefreshLabel() {
refreshButton = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Recommend"));
refreshButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
calculateAutoChart();
}
});
refreshButton.setEnabled(false);
}
private void calculateAutoChart() {
chartResultModel.clear();
//TODO 使用以下模拟数据,计算规则待补充
BaseChartCollection chartCollection = BaseChartGetter.createChartCollection(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID);
VanChart selectedChart = ((ChartCollection) chartCollection).getSelectedChart(VanChart.class);
selectedChart.getTitle().setTextObject("自动图表标题");
BaseChartCollection chartCollection1 = BaseChartGetter.createChartCollection(VanChartLinePlot.VAN_CHART_LINE_PLOT);
VanChart selectedChart1 = ((ChartCollection) chartCollection1).getSelectedChart(VanChart.class);
selectedChart1.getTitle().setTextObject("自动图表标题");
BaseChartCollection chartCollection2 = BaseChartGetter.createChartCollection(VanChartAreaPlot.VAN_CHART_AREA_PLOT_ID);
VanChart selectedChart2 = ((ChartCollection) chartCollection2).getSelectedChart(VanChart.class);
selectedChart2.getTitle().setTextObject("自动图表标题");
AutoChartIcon autoChartIcon = new AutoChartIcon((ChartCollection) chartCollection);
autoChartIcon.registerCallBackEvent(this);
AutoChartIcon autoChartIcon1 = new AutoChartIcon((ChartCollection) chartCollection1);
autoChartIcon1.registerCallBackEvent(this);
AutoChartIcon autoChartIcon2 = new AutoChartIcon((ChartCollection) chartCollection2);
autoChartIcon2.registerCallBackEvent(this);
chartResultModel.addElement(autoChartIcon);
chartResultModel.addElement(autoChartIcon1);
chartResultModel.addElement(autoChartIcon2);
chartViewList.setSelectedIndex(0);
}
@Override
public void populate(ChartCollection cc) {
}
@Override
public void update(ChartCollection cc) {
if (chartViewList.getSelectedIndex() < 0) {
return;
}
AutoChartIcon chartIcon = (AutoChartIcon) chartViewList.getSelectedValue();
ChartProvider chartProvider = chartIcon.getChartCollection().getSelectedChartProvider(ChartProvider.class);
if (cc.getChartCount() > 0) {
cc.setSelectChart(chartProvider);
} else {
cc.addChart(chartProvider);
}
}
public void populate(String tableName, String[] dataFields) {
tableNameComboBox.setSelectedTableDataByName(tableName);
Map<Object, Boolean> map = new HashMap();
for (String dataField : dataFields) {
map.put(dataField, true);
}
dataFieldBox.setSelectedValues(map);
}
@Override
public void callback() {
this.repaint();
}
}

1
designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java

@ -39,6 +39,7 @@ public class ChartDesignerActivator extends Activator implements Prepare {
DesignModuleFactory.registerChartComponentClass(ChartComponent.class); DesignModuleFactory.registerChartComponentClass(ChartComponent.class);
DesignModuleFactory.registerChartDialogClass(ChartDialog.class); DesignModuleFactory.registerChartDialogClass(ChartDialog.class);
DesignModuleFactory.registerAutoChartDialogClass(AutoChartDialog.class);
DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class); DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class);

78
designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java

@ -10,6 +10,7 @@ import com.fr.third.joda.time.DateTime;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dialog; import java.awt.Dialog;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.Frame; import java.awt.Frame;
@ -18,15 +19,17 @@ import java.awt.event.ActionListener;
/** /**
* 封装一层 图表新建的对话框, 配合属性表确定: 先单独只要一种图表类型的对话框. * 封装一层 图表新建的对话框, 配合属性表确定: 先单独只要一种图表类型的对话框.
*
* @author kunsnat E-mail:kunsnat@gmail.com * @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2013-1-7 下午07:29:15 * @version 创建时间2013-1-7 下午07:29:15
*/ */
public class ChartDialog extends MiddleChartDialog { public class ChartDialog extends MiddleChartDialog {
private BaseChartCollection cc; private BaseChartCollection cc;
private UIButton ok; protected UIButton ok;
private UIButton cancel; protected UIButton cancel;
private ChartTypePane chartTypePane;
public ChartDialog(Frame owner) { public ChartDialog(Frame owner) {
super(owner); super(owner);
@ -39,55 +42,60 @@ public class ChartDialog extends MiddleChartDialog {
} }
private void initComponent() { private void initComponent() {
final String createTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); this.setModal(true);
this.setLayout(new BorderLayout());
this.setModal(true); setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_M_Popup_Chart_Type"));
this.setLayout(new BorderLayout());
final ChartTypePane chartTypePane = new ChartTypePane();
setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_M_Popup_Chart_Type"));
this.applyClosingAction(); this.applyClosingAction();
this.applyEscapeAction(); this.applyEscapeAction();
this.setBasicDialogSize(BasicDialog.DEFAULT); this.setBasicDialogSize(BasicDialog.DEFAULT);
this.add(chartTypePane, BorderLayout.CENTER); this.add(initCenterPane(), BorderLayout.CENTER);
JPanel buttonPane = new JPanel(); JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
this.add(buttonPane, BorderLayout.SOUTH);
this.add(buttonPane, BorderLayout.SOUTH); ok = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK"));
cancel = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel"));
ok = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK")); addOkAction();
cancel = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel")); cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
doCancel();
}
});
buttonPane.add(ok); buttonPane.add(ok);
buttonPane.add(cancel); buttonPane.add(cancel);
ok.addActionListener(new ActionListener() { GUICoreUtils.setWindowCenter(getOwner(), this);
public void actionPerformed(ActionEvent e) { }
chartTypePane.update((ChartCollection)cc, createTime);
doOK();
}
});
cancel.addActionListener(new ActionListener() { protected Component initCenterPane() {
public void actionPerformed(ActionEvent e) { chartTypePane = new ChartTypePane();
doCancel(); return chartTypePane;
} }
});
GUICoreUtils.setWindowCenter(getOwner(), this); protected void addOkAction() {
final String createTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
chartTypePane.update((ChartCollection) cc, createTime);
doOK();
}
});
} }
/** /**
* 不处理 * 不处理
*/ */
public void checkValid() throws Exception { public void checkValid() throws Exception {
} }
/** /**
* 更新新建的图表 ChartCollection * 更新新建的图表 ChartCollection
*/ */
public void populate(BaseChartCollection cc) { public void populate(BaseChartCollection cc) {
if (cc == null) { if (cc == null) {
return; return;

3
designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java

@ -140,6 +140,9 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
public void paintComponent(Graphics g) { // public void paintComponent(Graphics g) { //
super.paintComponent(g); super.paintComponent(g);
if(chartCollection4Design.getChartCount() == 0) {
return;
}
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;

41
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java

@ -6,28 +6,36 @@ import com.fr.chartx.attr.ChartProvider;
import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.dialog.BasicScrollPane; import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.gui.frpane.UIComboBoxPane; import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.ChartEditPane; 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.mainframe.chart.gui.item.FlexibleComboBox; import com.fr.design.mainframe.chart.gui.item.FlexibleComboBox;
import com.fr.design.mainframe.chart.gui.item.ItemEventType; import com.fr.design.mainframe.chart.gui.item.ItemEventType;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/** /**
* 图表 属性表, 类型选择 界面. * 图表 属性表, 类型选择 界面.
@ -39,6 +47,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
private ChartTypeButtonPane buttonPane; private ChartTypeButtonPane buttonPane;
private ChartEditPane editPane; private ChartEditPane editPane;
private ChartCollection editingCollection; private ChartCollection editingCollection;
private UIButton autoButton;
@Override @Override
protected JPanel createContentPane() { protected JPanel createContentPane() {
@ -79,6 +88,11 @@ public class ChartTypePane extends AbstractChartAttrPane{
buttonPane.setEditingChartPane(chartTypeComBox); buttonPane.setEditingChartPane(chartTypeComBox);
if(ChartTypeManager.AUTO_CHART) {
initAutoButton();
content.add(autoButton, BorderLayout.SOUTH);
}
return content; return content;
} }
@ -97,6 +111,25 @@ public class ChartTypePane extends AbstractChartAttrPane{
return PaneTitleConstants.CHART_TYPE_TITLE; return PaneTitleConstants.CHART_TYPE_TITLE;
} }
private void initAutoButton(){
//TODO @Bjorn 视觉样式优化
autoButton = new UIButton(Toolkit.i18nText("Fine-Design_Chart_M_Popup_Auto_Chart_Type"));
autoButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final MiddleChartDialog autoChartDialog = DesignModuleFactory.getAutoChartDialog(DesignerContext.getDesignerFrame());
autoChartDialog.populate(editingCollection);
autoChartDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
populate(editingCollection);
}
});
autoChartDialog.setVisible(true);
}
});
}
class ComboBoxPane extends UIComboBoxPane<ChartProvider> { class ComboBoxPane extends UIComboBoxPane<ChartProvider> {
private Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane; private Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane;

BIN
designer-chart/src/main/resources/com/fr/design/images/form/toolbar/auto_chart.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

113
designer-form/src/main/java/com/fr/design/designer/creator/XAutoChartCreator.java

@ -0,0 +1,113 @@
package com.fr.design.designer.creator;
import com.fr.base.GraphHelper;
import com.fr.base.chart.BaseChartCollection;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.module.DesignModuleFactory;
import com.fr.form.ui.ChartAutoEditor;
import com.fr.stable.bridge.StableFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-26
*/
public class XAutoChartCreator extends XChartEditor {
private MiddleChartDialog autoChartDialog;
private EditingMouseListener editingMouseListener;
public XAutoChartCreator(ChartAutoEditor editor, Dimension size) {
super(editor, size);
}
/**
* 返回组件默认名
*
* @return 组件类名(小写)
*/
public String createDefaultName() {
return "auto_chart";
}
@Override
public ChartAutoEditor toData() {
return (ChartAutoEditor) data;
}
/**
* 点击选中的时候, 刷新界面
* 右键 reset之后, 触发事件 populate此方法
*
* @param jform 表单
* @param formDesigner 表单设计器
* @return 控件.
*/
public JComponent createToolPane(final BaseJForm jform, final FormDesigner formDesigner) {
if (toData().isChartSelect()) {
return super.createToolPane(jform, formDesigner);
}
if (isEditing) {
if (autoChartDialog != null && autoChartDialog.isVisible()) {
return new JPanel();
}
final BaseChartCollection chartCollection = (BaseChartCollection) StableFactory.createXmlObject(BaseChartCollection.XML_TAG);
autoChartDialog = DesignModuleFactory.getAutoChartDialog(DesignerContext.getDesignerFrame());
autoChartDialog.populate(chartCollection);
autoChartDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
initChart(autoChartDialog.getChartCollection());
formDesigner.fireTargetModified();
}
@Override
public void doCancel() {
editingMouseListener.stopEditing();
}
});
autoChartDialog.setVisible(true);
}
return toData().isChartSelect() ? super.createToolPane(jform, formDesigner) : new JPanel();
}
/**
* 响应点击事件
*
* @param editingMouseListener 鼠标点击位置处理器
* @param e 鼠标点击事件
*/
public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e) {
this.editingMouseListener = editingMouseListener;
super.respondClick(editingMouseListener, e);
}
public void paint(Graphics g) {
//TODO @Bjorn 视觉样式优化
g.setColor(Color.RED);
GraphHelper.fill(g, new Rectangle(0, 0, getWidth(), getHeight()));
super.paint(g);
}
private void initChart(BaseChartCollection chartCollection) {
((MiddleChartComponent) getDesignerEditor().getEditorTarget()).populate(chartCollection);
this.toData().resetChangeChartCollection(chartCollection);
this.toData().setChartSelect(true);
}
}

625
designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java

@ -28,328 +28,333 @@ import javax.swing.BorderFactory;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import java.beans.IntrospectionException;
import java.awt.Color; import java.awt.Color;
import java.awt.Cursor; import java.awt.Cursor;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.beans.IntrospectionException;
/** /**
* form中的图表按钮弹出的控件, 创建初始化图表内容. * form中的图表按钮弹出的控件, 创建初始化图表内容.
* *
* @author kunsnat E-mail:kunsnat@gmail.com * @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2013-7-5 上午10:28:30 * @version 创建时间2013-7-5 上午10:28:30
* 类说明 * 类说明
*/ */
public class XChartEditor extends XBorderStyleWidgetCreator { public class XChartEditor extends XBorderStyleWidgetCreator {
private static final long serialVersionUID = -7009439442104836657L; private static final long serialVersionUID = -7009439442104836657L;
private static final int BORDER_WIDTH = 2; private static final int BORDER_WIDTH = 2;
//具体来说是DesignerEditor<SimpleChartComponent> //具体来说是DesignerEditor<SimpleChartComponent>
private DesignerEditor<JComponent> designerEditor; private DesignerEditor<JComponent> designerEditor;
// private DesignerEditor<SimpleChartComponent> designerEditor; // private DesignerEditor<SimpleChartComponent> designerEditor;
//marro:无奈的属性,暂时想不出好办法 //marro:无奈的属性,暂时想不出好办法
private boolean isRefreshing = false; private boolean isRefreshing = false;
private boolean isEditing = false; protected boolean isEditing = false;
private boolean isHovering = false; private boolean isHovering = false;
private static final Color OUTER_BORDER_COLOR = new Color(65, 155, 249, 30); private static final Color OUTER_BORDER_COLOR = new Color(65, 155, 249, 30);
private static final Color INNER_BORDER_COLOR = new Color(65, 155, 249); private static final Color INNER_BORDER_COLOR = new Color(65, 155, 249);
public XChartEditor(BaseChartEditor editor) { public XChartEditor(BaseChartEditor editor) {
this(editor, new Dimension(250, 150)); this(editor, new Dimension(250, 150));
} }
public XChartEditor(BaseChartEditor editor, Dimension size) { public XChartEditor(BaseChartEditor editor, Dimension size) {
super((Widget)editor, size); super((Widget) editor, size);
} }
@Override @Override
public String getIconPath() { public String getIconPath() {
return super.getIconPath(); return super.getIconPath();
} }
@Override @Override
protected String getIconName() { protected String getIconName() {
return "Chart.png"; return "Chart.png";
} }
/** /**
* 返回组件默认名 * 返回组件默认名
* @return 组件类名(小写) *
*/ * @return 组件类名(小写)
public String createDefaultName() { */
return "chart"; public String createDefaultName() {
} return "chart";
}
/**
* 是否支持设置标题 /**
* @return 是返回true * 是否支持设置标题
*/ *
public boolean hasTitleStyle() { * @return 是返回true
return true; */
} public boolean hasTitleStyle() {
return true;
@Override }
public void stopEditing() {
isEditing = false; @Override
} public void stopEditing() {
isEditing = false;
/** }
* 得到属性名
* @return 属性名
* @throws java.beans.IntrospectionException /**
*/ * 得到属性名
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { *
return new CRPropertyDescriptor[] { * @return 属性名
new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Toolkit.i18nText("Fine-Design_Form_Form_Widget_Name")), * @throws java.beans.IntrospectionException
new CRPropertyDescriptor("visible", this.data.getClass()).setI18NName( */
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Visible")).setPropertyChangeListener(new PropertyChangeAdapter() { public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
return new CRPropertyDescriptor[]{
@Override new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Toolkit.i18nText("Fine-Design_Form_Form_Widget_Name")),
public void propertyChange() { new CRPropertyDescriptor("visible", this.data.getClass()).setI18NName(
makeVisible(toData().isVisible());} com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Visible")).setPropertyChangeListener(new PropertyChangeAdapter() {
}),
new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass( @Override
WLayoutBorderStyleEditor.class).setI18NName( public void propertyChange() {
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Style")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced") makeVisible(toData().isVisible());
.setPropertyChangeListener(new PropertyChangeAdapter() { }
}),
@Override new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass(
public void propertyChange() { WLayoutBorderStyleEditor.class).setI18NName(
initStyle(); com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Style")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced")
} .setPropertyChangeListener(new PropertyChangeAdapter() {
}),
}; @Override
} public void propertyChange() {
initStyle();
/** }
* 该组件是否可以拖入参数面板 }),
* @return 是则返回true };
*/ }
public boolean canEnterIntoParaPane(){
return false; /**
} * 该组件是否可以拖入参数面板
*
* @return 是则返回true
/** */
* 编辑状态的时候需要重新绘制下边框 public boolean canEnterIntoParaPane() {
* return false;
*/ }
@Override
public void paintBorder(Graphics g, Rectangle bounds){
if(isEditing){ /**
g.setColor(OUTER_BORDER_COLOR); * 编辑状态的时候需要重新绘制下边框
GraphHelper.draw(g, new Rectangle(bounds.x - BORDER_WIDTH, bounds.y - BORDER_WIDTH, bounds.width + BORDER_WIDTH + 1, bounds.height + BORDER_WIDTH + 1), Constants.LINE_LARGE); */
}else if(!isHovering){ @Override
super.paintBorder(g, bounds); public void paintBorder(Graphics g, Rectangle bounds) {
} if (isEditing) {
} g.setColor(OUTER_BORDER_COLOR);
GraphHelper.draw(g, new Rectangle(bounds.x - BORDER_WIDTH, bounds.y - BORDER_WIDTH, bounds.width + BORDER_WIDTH + 1, bounds.height + BORDER_WIDTH + 1), Constants.LINE_LARGE);
} else if (!isHovering) {
/** super.paintBorder(g, bounds);
* 返回设计器的Editor }
*/ }
public DesignerEditor<JComponent> getDesignerEditor() {
return designerEditor;
} /**
* 返回设计器的Editor
@Override */
protected void initXCreatorProperties() { public DesignerEditor<JComponent> getDesignerEditor() {
super.initXCreatorProperties(); return designerEditor;
initBorderStyle(); }
BaseChartCollection collection = ((BaseChartEditor) data).getChartCollection();
isRefreshing = true; @Override
((MiddleChartComponent) designerEditor.getEditorTarget()).populate(collection); protected void initXCreatorProperties() {
isRefreshing = false; super.initXCreatorProperties();
} initBorderStyle();
BaseChartCollection collection = ((BaseChartEditor) data).getChartCollection();
/** isRefreshing = true;
* 点击选中的时候, 刷新界面 ((MiddleChartComponent) designerEditor.getEditorTarget()).populate(collection);
* 右键 reset之后, 触发事件 populate此方法 isRefreshing = false;
* }
* @param jform 表单
* @param formDesigner 表单设计器 /**
* @return 控件. * 点击选中的时候, 刷新界面
*/ * 右键 reset之后, 触发事件 populate此方法
public JComponent createToolPane(final BaseJForm jform, final FormDesigner formDesigner) { *
MiddleChartComponent middleChartComponent = getDesignerEditorTarget(); * @param jform 表单
if (null != middleChartComponent) { * @param formDesigner 表单设计器
middleChartComponent.addStopEditingListener(new PropertyChangeAdapter() { * @return 控件.
public void propertyChange() { */
JComponent pane = jform.getEditingPane(); public JComponent createToolPane(final BaseJForm jform, final FormDesigner formDesigner) {
if (pane instanceof BaseChartPropertyPane) { MiddleChartComponent middleChartComponent = getDesignerEditorTarget();
((BaseChartPropertyPane) pane).setSupportCellData(true); if (null != middleChartComponent) {
MiddleChartComponent middleChartComponent = getDesignerEditorTarget(); middleChartComponent.addStopEditingListener(new PropertyChangeAdapter() {
if (null != middleChartComponent) { public void propertyChange() {
((BaseChartPropertyPane) pane).populateChartPropertyPane(middleChartComponent.update(), formDesigner); JComponent pane = jform.getEditingPane();
} if (pane instanceof BaseChartPropertyPane) {
} ((BaseChartPropertyPane) pane).setSupportCellData(true);
} MiddleChartComponent middleChartComponent = getDesignerEditorTarget();
}); if (null != middleChartComponent) {
} ((BaseChartPropertyPane) pane).populateChartPropertyPane(middleChartComponent.update(), formDesigner);
if (isEditing){ }
final BaseChartPropertyPane propertyPane = DesignModuleFactory.getChartPropertyPane(); }
SwingUtilities.invokeLater(new Runnable() { }
@Override });
public void run() { }
if (getDesignerEditor().getEditorTarget() != null) { if (isEditing) {
propertyPane.setSupportCellData(true); final BaseChartPropertyPane propertyPane = DesignModuleFactory.getChartPropertyPane();
MiddleChartComponent middleChartComponent = getDesignerEditorTarget(); SwingUtilities.invokeLater(new Runnable() {
if (null != middleChartComponent) { @Override
propertyPane.populateChartPropertyPane(middleChartComponent.update(), formDesigner); public void run() {
} if (getDesignerEditor().getEditorTarget() != null) {
} propertyPane.setSupportCellData(true);
} MiddleChartComponent middleChartComponent = getDesignerEditorTarget();
}); if (null != middleChartComponent) {
return (JComponent)propertyPane; propertyPane.populateChartPropertyPane(middleChartComponent.update(), formDesigner);
} }
else{ }
return (JComponent)DesignModuleFactory.getWidgetPropertyPane(formDesigner); }
} });
} return (JComponent) propertyPane;
} else {
private MiddleChartComponent getDesignerEditorTarget() { return (JComponent) DesignModuleFactory.getWidgetPropertyPane(formDesigner);
MiddleChartComponent bcc = null; }
if (getDesignerEditor().getEditorTarget() instanceof MiddleChartComponent) { }
bcc = (MiddleChartComponent) getDesignerEditor().getEditorTarget();
} private MiddleChartComponent getDesignerEditorTarget() {
return bcc; MiddleChartComponent bcc = null;
} if (getDesignerEditor().getEditorTarget() instanceof MiddleChartComponent) {
bcc = (MiddleChartComponent) getDesignerEditor().getEditorTarget();
/** }
* 渲染Painter return bcc;
*/ }
public void paint(Graphics g) {
designerEditor.paintEditor(g, this.getSize()); /**
super.paint(g); * 渲染Painter
if(isEditing){ */
g.setColor(INNER_BORDER_COLOR); public void paint(Graphics g) {
GraphHelper.draw(g, new Rectangle(0, 0, getWidth(), getHeight()), Constants.LINE_MEDIUM); designerEditor.paintEditor(g, this.getSize());
} super.paint(g);
} if (isEditing) {
g.setColor(INNER_BORDER_COLOR);
/** GraphHelper.draw(g, new Rectangle(0, 0, getWidth(), getHeight()), Constants.LINE_MEDIUM);
* 初始化Editor大小. }
* }
* @return 返回大小.
*/ /**
public Dimension initEditorSize() { * 初始化Editor大小.
return BORDER_PREFERRED_SIZE; *
} * @return 返回大小.
*/
/** public Dimension initEditorSize() {
* 响应点击事件 return BORDER_PREFERRED_SIZE;
* }
* @param editingMouseListener 鼠标点击位置处理器
* @param e 鼠标点击事件 /**
*/ * 响应点击事件
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){ *
FormDesigner designer = editingMouseListener.getDesigner(); * @param editingMouseListener 鼠标点击位置处理器
SelectionModel selectionModel = editingMouseListener.getSelectionModel(); * @param e 鼠标点击事件
isEditing = e.getButton() == MouseEvent.BUTTON1 && */
(e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR); public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e) {
displayCoverPane(!isEditing); FormDesigner designer = editingMouseListener.getDesigner();
selectionModel.selectACreatorAtMouseEvent(e); SelectionModel selectionModel = editingMouseListener.getSelectionModel();
isEditing = e.getButton() == MouseEvent.BUTTON1 &&
if (editingMouseListener.stopEditing()) { (e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR);
if (this != (XCreator)designer.getRootComponent()) { displayCoverPane(!isEditing);
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this); selectionModel.selectACreatorAtMouseEvent(e);
editingMouseListener.startEditing(this, isEditing ? adapter.getDesignerEditor() : null, adapter);
} if (editingMouseListener.stopEditing()) {
} if (this != (XCreator) designer.getRootComponent()) {
HelpDialogManager.getInstance().setPane(coverPanel); ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this);
if (this.isHelpBtnOnFocus()) { editingMouseListener.startEditing(this, isEditing ? adapter.getDesignerEditor() : null, adapter);
coverPanel.setMsgDisplay(e); }
} }
} HelpDialogManager.getInstance().setPane(coverPanel);
if (this.isHelpBtnOnFocus()) {
@Override coverPanel.setMsgDisplay(e);
protected JComponent initEditor() { }
if (designerEditor == null) { }
final MiddleChartComponent chartComponent = DesignModuleFactory.getChartComponent(((BaseChartEditor) data).getChartCollection());
if (chartComponent != null) { @Override
JComponent jChart = chartComponent; protected JComponent initEditor() {
jChart.setBorder(BorderFactory.createLineBorder(Color.lightGray)); if (designerEditor == null) {
designerEditor = new DesignerEditor<JComponent>(jChart); final MiddleChartComponent chartComponent = DesignModuleFactory.getChartComponent(((BaseChartEditor) data).getChartCollection());
chartComponent.addStopEditingListener(designerEditor); if (chartComponent != null) {
designerEditor.addPropertyChangeListener(new PropertyChangeAdapter() { JComponent jChart = chartComponent;
public void propertyChange() { jChart.setBorder(BorderFactory.createLineBorder(Color.lightGray));
if (!isRefreshing) { designerEditor = new DesignerEditor<JComponent>(jChart);
((BaseChartEditor) data).resetChangeChartCollection(chartComponent.update()); chartComponent.addStopEditingListener(designerEditor);
} designerEditor.addPropertyChangeListener(new PropertyChangeAdapter() {
} public void propertyChange() {
}); if (!isRefreshing) {
} ((BaseChartEditor) data).resetChangeChartCollection(chartComponent.update());
} }
}
if (editor == null) { });
setBorder(DEFALUTBORDER); }
editor = new JPanel(); }
editor.setBackground(null);
editor.setLayout(null); if (editor == null) {
editor.setOpaque(false); setBorder(DEFALUTBORDER);
editor = new JPanel();
coverPanel = new CoverReportPane(); editor.setBackground(null);
coverPanel.setPreferredSize(this.getPreferredSize()); editor.setLayout(null);
coverPanel.setBounds(this.getBounds()); editor.setOpaque(false);
editor.add(coverPanel); coverPanel = new CoverReportPane();
coverPanel.setVisible(false); coverPanel.setPreferredSize(this.getPreferredSize());
} coverPanel.setBounds(this.getBounds());
return editor;
} editor.add(coverPanel);
coverPanel.setVisible(false);
/** }
* 是否展现覆盖的pane return editor;
* @param display 是否 }
*/
public void displayCoverPane(boolean display){ /**
isHovering = display; * 是否展现覆盖的pane
coverPanel.setVisible(display); *
coverPanel.setPreferredSize(editor.getPreferredSize()); * @param display 是否
coverPanel.setBounds(editor.getBounds()); */
editor.repaint(); public void displayCoverPane(boolean display) {
} isHovering = display;
coverPanel.setVisible(display);
public JComponent getCoverPane(){ coverPanel.setPreferredSize(editor.getPreferredSize());
return coverPanel; coverPanel.setBounds(editor.getBounds());
} editor.repaint();
}
/**
* 是否支持设置可用 public JComponent getCoverPane() {
* return boolean return coverPanel;
*/ }
public boolean supportSetEnable(){
return false; /**
} * 是否支持设置可用
* return boolean
/** */
* data属性改变触发其他操作 public boolean supportSetEnable() {
* return false;
*/ }
public void firePropertyChange(){
initStyle(); /**
} * data属性改变触发其他操作
*/
@Override public void firePropertyChange() {
public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { initStyle();
return new WidgetPropertyUIProvider[]{ new ChartEditorPropertyUI(this)}; }
}
@Override
/** public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
* 是否支持共享-现只支持报表块图表tab块绝对布局 return new WidgetPropertyUIProvider[]{new ChartEditorPropertyUI(this)};
* @return }
*/
public boolean isSupportShared() { /**
return true; * 是否支持共享-现只支持报表块图表tab块绝对布局
} *
* @return
@Override */
public boolean supportMobileStyle() { public boolean isSupportShared() {
return false; return true;
} }
@Override
public boolean supportMobileStyle() {
return false;
}
} }

2
designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java

@ -19,6 +19,7 @@ import com.fr.form.parameter.FormSubmitButton;
import com.fr.form.ui.Button; import com.fr.form.ui.Button;
import com.fr.form.ui.CardAddButton; import com.fr.form.ui.CardAddButton;
import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.ChartAutoEditor;
import com.fr.form.ui.CheckBox; import com.fr.form.ui.CheckBox;
import com.fr.form.ui.CheckBoxGroup; import com.fr.form.ui.CheckBoxGroup;
import com.fr.form.ui.ComboBox; import com.fr.form.ui.ComboBox;
@ -174,6 +175,7 @@ public class XCreatorUtils {
private static void putExtraEditor() { private static void putExtraEditor() {
if (DesignModuleFactory.getChartEditorClass() != null) { if (DesignModuleFactory.getChartEditorClass() != null) {
objectMap.put(DesignModuleFactory.getChartEditorClass(), XChartEditor.class); objectMap.put(DesignModuleFactory.getChartEditorClass(), XChartEditor.class);
objectMap.put(ChartAutoEditor.class, XAutoChartCreator.class);
} }
} }

57
designer-realize/src/main/java/com/fr/design/actions/insert/cell/AutoChartCellAction.java

@ -0,0 +1,57 @@
package com.fr.design.actions.insert.cell;
import com.fr.base.BaseUtils;
import com.fr.chart.chartattr.AutoChartCollection;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.menu.MenuKeySet;
import javax.swing.KeyStroke;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-28
*/
public class AutoChartCellAction extends AbstractCellAction implements WorkBookSupportable {
public AutoChartCellAction() {
initAction();
}
public AutoChartCellAction(ElementCasePane t) {
super(t);
initAction();
}
private void initAction() {
this.setMenuKeySet(INSERT_AUTO_CHART);
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
//TODO @Bjorn 视觉样式优化icon
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/auto_chart.png"));
}
public static final MenuKeySet INSERT_AUTO_CHART = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'M';
}
@Override
public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_Insert_Auto_Chart");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
@Override
public Class getCellValueClass() {
return AutoChartCollection.class;
}
}

53
designer-realize/src/main/java/com/fr/design/actions/insert/flot/AutoChartFloatAction.java

@ -0,0 +1,53 @@
package com.fr.design.actions.insert.flot;
import com.fr.base.BaseUtils;
import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.module.DesignModuleFactory;
import javax.swing.KeyStroke;
import java.awt.Window;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-28
*/
public class AutoChartFloatAction extends ChartFloatAction {
/**
* 构造函数 图表插入悬浮元素
*/
public AutoChartFloatAction(ElementCasePane t) {
super(t);
}
protected void init() {
this.setMenuKeySet(FLOAT_INSERT_AUTO_CHART);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/auto_chart.png"));
}
public static final MenuKeySet FLOAT_INSERT_AUTO_CHART = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'M';
}
@Override
public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_Insert_Auto_Chart");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getAutoChartDialog(window);
}
}

11
designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java

@ -27,6 +27,7 @@ import com.fr.stable.unit.OLDPIX;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import java.awt.Color; import java.awt.Color;
import java.awt.Window;
/** /**
* 图表插入悬浮元素的操作. * 图表插入悬浮元素的操作.
@ -40,6 +41,10 @@ public class ChartFloatAction extends ElementCaseAction {
*/ */
public ChartFloatAction(ElementCasePane t) { public ChartFloatAction(ElementCasePane t) {
super(t); super(t);
init();
}
protected void init() {
this.setMenuKeySet(FLOAT_INSERT_CHART); this.setMenuKeySet(FLOAT_INSERT_CHART);
this.setName(getMenuKeySet().getMenuKeySetName()); this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
@ -78,7 +83,7 @@ public class ChartFloatAction extends ElementCaseAction {
reportPane.stopEditing(); reportPane.stopEditing();
final BaseChartCollection cc = (BaseChartCollection) StableFactory.createXmlObject(BaseChartCollection.XML_TAG); final BaseChartCollection cc = (BaseChartCollection) StableFactory.createXmlObject(BaseChartCollection.XML_TAG);
final MiddleChartDialog chartDialog = DesignModuleFactory.getChartDialog(DesignerContext.getDesignerFrame()); final MiddleChartDialog chartDialog = getMiddleChartDialog(DesignerContext.getDesignerFrame());
chartDialog.populate(cc); chartDialog.populate(cc);
chartDialog.addDialogActionListener(new DialogActionAdapter() { chartDialog.addDialogActionListener(new DialogActionAdapter() {
@Override @Override
@ -124,4 +129,8 @@ public class ChartFloatAction extends ElementCaseAction {
chartDialog.setVisible(true); chartDialog.setVisible(true);
return isRecordNeeded; return isRecordNeeded;
} }
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getChartDialog(window);
}
} }

24
designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartCellEditor.java

@ -0,0 +1,24 @@
package com.fr.design.cell.editor;
import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.report.elementcase.TemplateElementCase;
import java.awt.Window;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-28
*/
public class AutoChartCellEditor extends ChartCellEditor {
public AutoChartCellEditor(ElementCasePane<? extends TemplateElementCase> ePane) {
super(ePane);
}
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getAutoChartDialog(window);
}
}

18
designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartFloatEditor.java

@ -0,0 +1,18 @@
package com.fr.design.cell.editor;
import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.module.DesignModuleFactory;
import java.awt.Window;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-28
*/
public class AutoChartFloatEditor extends ChartFloatEditor {
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getAutoChartDialog(window);
}
}

18
designer-realize/src/main/java/com/fr/design/cell/editor/ChartCellEditor.java

@ -1,21 +1,21 @@
package com.fr.design.cell.editor; package com.fr.design.cell.editor;
import java.awt.Component;
import javax.swing.SwingUtilities;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.design.dialog.DialogActionListener;
import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.design.gui.chart.MiddleChartDialog; import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.dialog.DialogActionListener;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.grid.Grid; import com.fr.grid.Grid;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.SwingUtilities;
import java.awt.Component;
import java.awt.Window;
/** /**
* CellEditor used to edit Chart object. * CellEditor used to edit Chart object.
*/ */
@ -67,7 +67,7 @@ public class ChartCellEditor extends AbstractCellEditor implements DialogActionL
this.chartCellEditorDialog = null; this.chartCellEditorDialog = null;
return glyphComponent; return glyphComponent;
} }
this.chartCellEditorDialog = DesignModuleFactory.getChartDialog(SwingUtilities.getWindowAncestor(grid)); this.chartCellEditorDialog = getMiddleChartDialog(SwingUtilities.getWindowAncestor(grid));
this.chartCellEditorDialog.addDialogActionListener(this); this.chartCellEditorDialog.addDialogActionListener(this);
BaseChartCollection cc = (BaseChartCollection)StableFactory.createXmlObject(BaseChartCollection.XML_TAG); BaseChartCollection cc = (BaseChartCollection)StableFactory.createXmlObject(BaseChartCollection.XML_TAG);
this.chartCellEditorDialog.populate(cc); this.chartCellEditorDialog.populate(cc);
@ -84,4 +84,8 @@ public class ChartCellEditor extends AbstractCellEditor implements DialogActionL
public void doCancel() { public void doCancel() {
cancelCellEditing(); cancelCellEditing();
} }
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getChartDialog(window);
}
} }

16
designer-realize/src/main/java/com/fr/design/cell/editor/ChartFloatEditor.java

@ -1,20 +1,20 @@
package com.fr.design.cell.editor; package com.fr.design.cell.editor;
import java.awt.Component;
import javax.swing.SwingUtilities;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.design.dialog.DialogActionListener;
import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.design.gui.chart.MiddleChartDialog; import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
import com.fr.design.dialog.DialogActionListener;
import com.fr.grid.Grid; import com.fr.grid.Grid;
import com.fr.report.cell.FloatElement; import com.fr.report.cell.FloatElement;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.SwingUtilities;
import java.awt.Component;
import java.awt.Window;
public class ChartFloatEditor extends AbstractFloatEditor implements DialogActionListener { public class ChartFloatEditor extends AbstractFloatEditor implements DialogActionListener {
private MiddleChartDialog chartFloatEditorDialog = null; private MiddleChartDialog chartFloatEditorDialog = null;
@ -65,7 +65,7 @@ public class ChartFloatEditor extends AbstractFloatEditor implements DialogActio
} }
return glyphComponent; return glyphComponent;
} }
this.chartFloatEditorDialog = DesignModuleFactory.getChartDialog(SwingUtilities.getWindowAncestor(grid)); this.chartFloatEditorDialog = getMiddleChartDialog(SwingUtilities.getWindowAncestor(grid));
this.chartFloatEditorDialog.addDialogActionListener(this); this.chartFloatEditorDialog.addDialogActionListener(this);
BaseChartCollection cc = (BaseChartCollection)StableFactory.createXmlObject(BaseChartCollection.XML_TAG); BaseChartCollection cc = (BaseChartCollection)StableFactory.createXmlObject(BaseChartCollection.XML_TAG);
this.chartFloatEditorDialog.populate(cc); this.chartFloatEditorDialog.populate(cc);
@ -82,4 +82,8 @@ public class ChartFloatEditor extends AbstractFloatEditor implements DialogActio
public void doCancel() { public void doCancel() {
cancelFloatEditing(); cancelFloatEditing();
} }
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getChartDialog(window);
}
} }

10
designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java

@ -9,6 +9,7 @@ import com.fr.base.Formula;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.chart.chartattr.AutoChartCollection;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
@ -52,6 +53,8 @@ import com.fr.design.cell.bar.DynamicScrollBar;
import com.fr.design.cell.clipboard.CellElementsClip; import com.fr.design.cell.clipboard.CellElementsClip;
import com.fr.design.cell.clipboard.ElementsTransferable; import com.fr.design.cell.clipboard.ElementsTransferable;
import com.fr.design.cell.clipboard.FloatElementsClip; import com.fr.design.cell.clipboard.FloatElementsClip;
import com.fr.design.cell.editor.AutoChartCellEditor;
import com.fr.design.cell.editor.AutoChartFloatEditor;
import com.fr.design.cell.editor.BiasTextPainterCellEditor; import com.fr.design.cell.editor.BiasTextPainterCellEditor;
import com.fr.design.cell.editor.CellEditor; import com.fr.design.cell.editor.CellEditor;
import com.fr.design.cell.editor.ChartCellEditor; import com.fr.design.cell.editor.ChartCellEditor;
@ -118,6 +121,8 @@ import javax.swing.JPanel;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
import javax.swing.JScrollBar; import javax.swing.JScrollBar;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import java.lang.reflect.Constructor;
import java.util.Set;
import java.awt.AWTEvent; import java.awt.AWTEvent;
import java.awt.Adjustable; import java.awt.Adjustable;
import java.awt.Dimension; import java.awt.Dimension;
@ -131,8 +136,6 @@ import java.awt.event.ActionListener;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.lang.reflect.Constructor;
import java.util.Set;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
@ -399,6 +402,9 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
grid.setDefaultFloatEditor(chartClass, new ChartFloatEditor()); grid.setDefaultFloatEditor(chartClass, new ChartFloatEditor());
} }
grid.setDefaultCellEditor(AutoChartCollection.class, new AutoChartCellEditor(this));
grid.setDefaultFloatEditor(AutoChartCollection.class, new AutoChartFloatEditor());
addExtraCellEditor(grid); addExtraCellEditor(grid);
grid.setDefaultFloatEditor(Formula.class, new FormulaFloatEditor()); grid.setDefaultFloatEditor(Formula.class, new FormulaFloatEditor());

49
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -7,12 +7,14 @@ import com.fr.base.passport.FinePassportListenerAdapter;
import com.fr.base.passport.FinePassportManager; import com.fr.base.passport.FinePassportManager;
import com.fr.base.process.ProcessOperator; import com.fr.base.process.ProcessOperator;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.decision.update.backup.RecoverManager; import com.fr.decision.update.backup.RecoverManager;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.NewFormAction; import com.fr.design.actions.NewFormAction;
import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.insert.cell.AutoChartCellAction;
import com.fr.design.actions.insert.cell.BiasCellAction; import com.fr.design.actions.insert.cell.BiasCellAction;
import com.fr.design.actions.insert.cell.ChartCellAction; import com.fr.design.actions.insert.cell.ChartCellAction;
import com.fr.design.actions.insert.cell.DSColumnCellAction; import com.fr.design.actions.insert.cell.DSColumnCellAction;
@ -21,6 +23,7 @@ import com.fr.design.actions.insert.cell.GeneralCellAction;
import com.fr.design.actions.insert.cell.ImageCellAction; import com.fr.design.actions.insert.cell.ImageCellAction;
import com.fr.design.actions.insert.cell.RichTextCellAction; import com.fr.design.actions.insert.cell.RichTextCellAction;
import com.fr.design.actions.insert.cell.SubReportCellAction; import com.fr.design.actions.insert.cell.SubReportCellAction;
import com.fr.design.actions.insert.flot.AutoChartFloatAction;
import com.fr.design.actions.insert.flot.ChartFloatAction; import com.fr.design.actions.insert.flot.ChartFloatAction;
import com.fr.design.actions.insert.flot.FormulaFloatAction; import com.fr.design.actions.insert.flot.FormulaFloatAction;
import com.fr.design.actions.insert.flot.ImageFloatAction; import com.fr.design.actions.insert.flot.ImageFloatAction;
@ -112,11 +115,11 @@ import com.fr.start.BBSGuestPaneProvider;
import com.fr.task.Once; import com.fr.task.Once;
import com.fr.xml.ReportXMLUtils; import com.fr.xml.ReportXMLUtils;
import java.awt.*;
import java.awt.image.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.awt.Image;
import java.awt.image.BufferedImage;
/** /**
* Created by juhaoyu on 2018/1/31. * Created by juhaoyu on 2018/1/31.
@ -222,16 +225,21 @@ public class DesignerActivator extends Activator {
classes.add(provider.actionForInsertCellElement()); classes.add(provider.actionForInsertCellElement());
} }
return ArrayUtils.addAll(new Class<?>[]{ List<Class<?>> baseClasses = new ArrayList<>();
DSColumnCellAction.class, baseClasses.add(DSColumnCellAction.class);
GeneralCellAction.class, baseClasses.add(GeneralCellAction.class);
RichTextCellAction.class, baseClasses.add(RichTextCellAction.class);
FormulaCellAction.class, baseClasses.add(FormulaCellAction.class);
ChartCellAction.class, baseClasses.add(ChartCellAction.class);
ImageCellAction.class, if(ChartTypeManager.AUTO_CHART) {
BiasCellAction.class, baseClasses.add(AutoChartCellAction.class);
SubReportCellAction.class }
}, classes.toArray(new Class<?>[classes.size()])); baseClasses.add(ImageCellAction.class);
baseClasses.add(BiasCellAction.class);
baseClasses.add(SubReportCellAction.class);
return ArrayUtils.addAll(baseClasses.toArray(new Class<?>[baseClasses.size()]),
classes.toArray(new Class<?>[classes.size()]));
} }
private static Class<?>[] actionsForInsertFloatElement() { private static Class<?>[] actionsForInsertFloatElement() {
@ -240,12 +248,17 @@ public class DesignerActivator extends Activator {
for (ElementUIProvider provider : providers) { for (ElementUIProvider provider : providers) {
classes.add(provider.actionForInsertFloatElement()); classes.add(provider.actionForInsertFloatElement());
} }
return ArrayUtils.addAll(new Class<?>[]{
TextBoxFloatAction.class, List<Class<?>> baseClasses = new ArrayList<>();
FormulaFloatAction.class, baseClasses.add(TextBoxFloatAction.class);
ChartFloatAction.class, baseClasses.add(FormulaFloatAction.class);
ImageFloatAction.class baseClasses.add(ChartFloatAction.class);
}, classes.toArray(new Class<?>[classes.size()])); if(ChartTypeManager.AUTO_CHART) {
baseClasses.add(AutoChartFloatAction.class);
}
baseClasses.add(ImageFloatAction.class);
return ArrayUtils.addAll(baseClasses.toArray(new Class<?>[baseClasses.size()]),
classes.toArray(new Class<?>[classes.size()]));
} }
private static NameableCreator[] hyperlinkTypes() { private static NameableCreator[] hyperlinkTypes() {

Loading…
Cancel
Save