Browse Source

Merge pull request #4778 in DESIGN/design from release/11.0 to feature/x

* commit '4b54257940625b7c74fcd100de47c6d344504c92':
  CHART-19508 图表切换支持调整顺序和复制
  REPORT-54354  去掉程序数据集的编辑功能
research/11.0
superman 3 years ago
parent
commit
90823065fd
  1. 35
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ClassTableDataPane.java
  2. 221
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java

35
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ClassTableDataPane.java

@ -4,7 +4,6 @@ import com.fr.base.Parameter;
import com.fr.data.impl.ClassTableData; import com.fr.data.impl.ClassTableData;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.JavaEditorPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itableeditorpane.ParameterTableModel; import com.fr.design.gui.itableeditorpane.ParameterTableModel;
@ -15,14 +14,18 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import javax.swing.*; import javax.swing.BorderFactory;
import java.awt.*; import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -65,30 +68,6 @@ public class ClassTableDataPane extends AbstractTableDataPane<ClassTableData> {
dlg.setVisible(true); dlg.setVisible(true);
} }
}); });
UIButton editButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Edit"));
editButton.setPreferredSize(new Dimension(
editButton.getPreferredSize().width,
classNameTextField.getPreferredSize().height));
reportletNamePane.add(editButton);
editButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final JavaEditorPane javaEditorPane = new JavaEditorPane(classNameTextField.getText(), JavaEditorPane.DEFAULT_TABLEDATA_STRING);
final BasicDialog dlg = javaEditorPane.showMediumWindow(SwingUtilities.getWindowAncestor(ClassTableDataPane.this),
new DialogActionAdapter() {
public void doOk() {
classNameTextField.setText(javaEditorPane.getClassText());
}
});
javaEditorPane.addSaveActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dlg.doOK();
}
});
dlg.setVisible(true);
}
});
Component[][] components = { Component[][] components = {
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Class_Name") + ":"), reportletNamePane}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Class_Name") + ":"), reportletNamePane},

221
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java

@ -6,7 +6,6 @@ import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.chartx.attr.ChartProvider; import com.fr.chartx.attr.ChartProvider;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.design.dialog.DialogActionListener; import com.fr.design.dialog.DialogActionListener;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserver;
@ -16,7 +15,9 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.imenutable.UIMenuNameableCreator; import com.fr.design.gui.imenutable.UIMenuNameableCreator;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.gui.ChartTypePane.ComboBoxPane; import com.fr.design.mainframe.chart.gui.ChartTypePane.ComboBoxPane;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.vanchart.VanChart; import com.fr.plugin.chart.vanchart.VanChart;
@ -48,6 +49,7 @@ import java.awt.image.BufferedImage;
/** /**
* 图表 类型 增删 控制按钮界面. * 图表 类型 增删 控制按钮界面.
*
* @author kunsnat E-mail:kunsnat@gmail.com * @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2013-9-26 上午09:27:49 * @version 创建时间2013-9-26 上午09:27:49
*/ */
@ -55,7 +57,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
private static final long serialVersionUID = -8130803225718028933L; private static final long serialVersionUID = -8130803225718028933L;
private static final int B_W = 52; private static final int B_W = 52;
private static final int B_H = 20; private static final int B_H = 20;
private static final int COL_COUNT = 3; private static final int COL_COUNT = 4;
private static final int P_W = 300; private static final int P_W = 300;
private static final int P_H = 400; private static final int P_H = 400;
@ -67,7 +69,11 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
private UIButton addButton; private UIButton addButton;
private UIButton configButton; private UIButton configButton;
private ArrayList<ChartChangeButton> indexList = new ArrayList<ChartChangeButton>(); private UIButton copyButton;
private UIButton moveForwardButton;
private UIButton moveBackButton;
private ArrayList<ChartChangeButton> indexList = new ArrayList<>();
private JPanel buttonPane; private JPanel buttonPane;
private ChartCollection editingCollection; private ChartCollection editingCollection;
@ -92,75 +98,139 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
public ChartTypeButtonPane() { public ChartTypeButtonPane() {
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png"));
configButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/config.png"));
initButton();
buttonPane = new JPanel(); buttonPane = new JPanel();
this.add(buttonPane, BorderLayout.CENTER); this.add(buttonPane, BorderLayout.CENTER);
JPanel eastPane = new JPanel(); JPanel northPane = new JPanel();
this.add(eastPane, BorderLayout.EAST); this.add(northPane, BorderLayout.NORTH);
northPane.setLayout(new BorderLayout());
northPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
eastPane.setLayout(new BorderLayout()); JPanel addPanel = new JPanel();
addPanel.setLayout(new BorderLayout());
addPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3));
addPanel.add(addButton, BorderLayout.CENTER);
eastPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 5));
JPanel button = new JPanel(); JPanel button = new JPanel();
button.setPreferredSize(new Dimension(45, 20)); button.setPreferredSize(new Dimension(95, 20));
button.setLayout(new GridLayout(1, 2, 5, 0)); button.setLayout(new GridLayout(1, 4, 0, 0));
button.add(addButton); button.add(addPanel);
button.add(configButton); button.add(copyButton);
eastPane.add(button, BorderLayout.NORTH); button.add(moveForwardButton);
button.add(moveBackButton);
northPane.add(button, BorderLayout.WEST);
northPane.add(configButton, BorderLayout.EAST);
initAddButton();
initConfigButton();
initConfigCreator(); initConfigCreator();
// Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); // Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK);
} }
private void initButton() {
addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png"));
configButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/config.png"));
copyButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png"));
copyButton.setBorderPainted(false);
copyButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Action_Copy"));
moveForwardButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/left.png"));
moveForwardButton.setToolTipText(Toolkit.i18nText("Fine-Design_Report_HF_Move_Left"));
moveForwardButton.setBorderPainted(false);
moveBackButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/right.png"));
moveBackButton.setToolTipText(Toolkit.i18nText("Fine-Design_Report_HF_Move_Right"));
moveBackButton.setBorderPainted(false);
initAddButton();
initConfigButton();
initMoveButton();
initCopyButton();
}
public static void registerSupportChangeConfigChartClass(Class<? extends ChartProvider> cls) { public static void registerSupportChangeConfigChartClass(Class<? extends ChartProvider> cls) {
supportChangeConfigChartClassSet.add(cls); supportChangeConfigChartClassSet.add(cls);
} }
private void initConfigCreator() { private void initConfigCreator() {
configCreator = new UIMenuNameableCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Change_Config_Attributes"), new AttrChangeConfig(), ChangeConfigPane.class); configCreator = new UIMenuNameableCreator(Toolkit.i18nText("Fine-Design_Chart_Change_Config_Attributes"), new AttrChangeConfig(), ChangeConfigPane.class);
} }
private void initAddButton() { private void initAddButton() {
addButton.setPreferredSize(new Dimension(20, 20)); addButton.setPreferredSize(new Dimension(20, 20));
addButton.addActionListener(addListener); addButton.addActionListener((e) -> {
String name = getNewChartName();
ChartProvider chart = getChangeStateNewChart();
addNewChart(chart, name, editingCollection.getChartCount());
});
} }
private void initConfigButton() { private void initConfigButton() {
configButton.setPreferredSize(new Dimension(20, 20)); configButton.setPreferredSize(new Dimension(20, 20));
configButton.addActionListener(configListener); configButton.addActionListener((e) -> showConfigDialog());
} }
ActionListener addListener = new ActionListener() { private void initCopyButton() {
@Override copyButton.setPreferredSize(new Dimension(20, 20));
public void actionPerformed(ActionEvent e) { copyButton.addActionListener((e) -> {
String name = getNewChartName(); String name = getCopyChartName();
ChartChangeButton button = new ChartChangeButton(name);// some set selected ChartProvider chart = getCopyChart();
addNewChart(chart, name, editingCollection.getSelectedIndex() + 1);
});
}
button.registerChangeListener(uiobListener); private void initMoveButton() {
moveForwardButton.setPreferredSize(new Dimension(20, 20));
moveBackButton.setPreferredSize(new Dimension(20, 20));
moveForwardButton.addActionListener((e) -> moveForwardChart());
moveBackButton.addActionListener((e) -> moveBackChart());
}
indexList.add(button); private void moveBackChart() {
editingCollection.moveBackChart();
populateBean(editingCollection);
}
if (editingCollection != null) { private void moveForwardChart() {
//点击添加按钮,则会触发切换状态 editingCollection.moveForwardChart();
ChartProvider chart = getChangeStateNewChart(); populateBean(editingCollection);
try {
ChartProvider newChart = (ChartProvider) chart.clone();
editingCollection.addNamedChart(name, newChart);
ChartInfoCollector.getInstance().collection(newChart, null);
} catch (CloneNotSupportedException e1) {
FineLoggerFactory.getLogger().error("Error in Clone");
} }
checkoutChange();
private void checkMoveButton() {
moveBackButton.setEnabled(editingCollection.getSelectedIndex() != editingCollection.getChartCount() - 1);
moveForwardButton.setEnabled(editingCollection.getSelectedIndex() != 0);
}
private void addNewChart(ChartProvider chart, String name, int index) {
if (chart == null) {
return;
} }
ChartChangeButton button = new ChartChangeButton(name);// some set selected
button.registerChangeListener(uiobListener);
indexList.add(index, button);
editingCollection.addNamedChart(index, name, chart);
ChartInfoCollector.getInstance().collection(chart, null);
checkoutChange();
layoutPane(buttonPane); layoutPane(buttonPane);
} }
};
private void showConfigDialog() {
UIMenuNameableCreator ui = configCreator.clone();
final BasicBeanPane pane = ui.getPane();
pane.populateBean(editingCollection);
UIDialog dialog = pane.showUnsizedWindow(SwingUtilities.getWindowAncestor(new JPanel()), new DialogActionListener() {
@Override
public void doOk() {
pane.updateBean(editingCollection);
}
@Override
public void doCancel() {
}
});
dialog.setSize(P_W, P_H);
dialog.setVisible(true);
}
//获取图表收集器的状态 //获取图表收集器的状态
private void checkoutChange() { private void checkoutChange() {
@ -170,6 +240,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
} }
//检查是否可以配置切换 //检查是否可以配置切换
configButton.setEnabled(changeEnable()); configButton.setEnabled(changeEnable());
checkMoveButton();
} }
/** /**
@ -181,7 +252,23 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
ChartProvider chart = editingCollection.getSelectedChartProvider(ChartProvider.class); ChartProvider chart = editingCollection.getSelectedChartProvider(ChartProvider.class);
String chartID = chart.getID(); String chartID = chart.getID();
String priority = ChartTypeManager.getInstanceWithCheck().getPriority(chartID); String priority = ChartTypeManager.getInstanceWithCheck().getPriority(chartID);
return ChartTypeManager.getInstanceWithCheck().getFirstChart(priority); ChartProvider firstChart = ChartTypeManager.getInstanceWithCheck().getFirstChart(priority);
try {
return (ChartProvider) firstChart.clone();
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
return null;
}
public ChartProvider getCopyChart() {
ChartProvider chart = editingCollection.getSelectedChartProvider(ChartProvider.class);
try {
return (ChartProvider) chart.clone();
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
return getChangeStateNewChart();
}
} }
//图表收集器模式状态改变 //图表收集器模式状态改变
@ -204,46 +291,40 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
return supportChangeConfigChartClassSet.contains(editingCollection.getSelectedChartProvider(ChartProvider.class).getClass()); return supportChangeConfigChartClassSet.contains(editingCollection.getSelectedChartProvider(ChartProvider.class).getClass());
} }
ActionListener configListener = new ActionListener() { private String getNewChartName() {
@Override int count = indexList.size() + 1;
public void actionPerformed(ActionEvent e) { while (true) {
UIMenuNameableCreator ui = configCreator.clone(); String nameTest = Toolkit.i18nText("Fine-Design_Chart_Module_Name") + count;
final BasicBeanPane pane = ui.getPane(); if (!nameRepeated(nameTest)) {
pane.populateBean(editingCollection); return nameTest;
UIDialog dialog = pane.showUnsizedWindow(SwingUtilities.getWindowAncestor(parent), new DialogActionListener() {
@Override
public void doOk() {
pane.updateBean(editingCollection);
} }
count++;
@Override
public void doCancel() {
} }
});
dialog.setSize(P_W, P_H);
dialog.setVisible(true);
} }
};
private String getNewChartName() { private String getCopyChartName() {
int count = indexList.size() + 1; String chartName = "CopyOf" + editingCollection.getChartName(editingCollection.getSelectedIndex());
if (!nameRepeated(chartName)) {
return chartName;
}
int count = 1;
while (true) { while (true) {
String name_test = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Module_Name") + count; String nameTest = chartName + count;
boolean repeated = false; if (!nameRepeated(nameTest)) {
for (int i = 0, len = indexList.size(); i < len; i++) { return nameTest;
ChartChangeButton nameable = indexList.get(i); }
if (ComparatorUtils.equals(nameable.getButtonName(), name_test)) { count++;
repeated = true;
break;
} }
} }
if (!repeated) { private boolean nameRepeated(String name) {
return name_test; for (int i = 0, len = indexList.size(); i < len; i++) {
ChartChangeButton nameable = indexList.get(i);
if (ComparatorUtils.equals(nameable.getButtonName(), name)) {
return true;
} }
count++;
} }
return false;
} }
private void layoutPane(JPanel northPane) { private void layoutPane(JPanel northPane) {
@ -291,6 +372,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
/** /**
* 注册监听器 * 注册监听器
*
* @param listener 观察者监听事件 * @param listener 观察者监听事件
*/ */
public void registerChangeListener(UIObserverListener listener) { public void registerChangeListener(UIObserverListener listener) {
@ -299,6 +381,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
/** /**
* 是否应该响应事件监听器 * 是否应该响应事件监听器
*
* @return 是则返回true * @return 是则返回true
*/ */
public boolean shouldResponseChangeListener() { public boolean shouldResponseChangeListener() {
@ -383,7 +466,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
int selectedIndex = editingCollection.getSelectedIndex(); int selectedIndex = editingCollection.getSelectedIndex();
ChartChangeButton button = indexList.get(selectedIndex); ChartChangeButton button = indexList.get(selectedIndex);
button.isMoveOn = false; button.isMoveOn = false;
if (!ComparatorUtils.equals(editingCollection.getChartName(selectedIndex), newName)) { if (!nameRepeated(newName)) {
editingCollection.setChartName(selectedIndex, newName); editingCollection.setChartName(selectedIndex, newName);
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().fireTargetModified(); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().fireTargetModified();
button.changeChartName(newName); button.changeChartName(newName);

Loading…
Cancel
Save