|
|
@ -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; |
|
|
@ -85,37 +91,60 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen |
|
|
|
//所以:stopEditing--选中其他button则响应click之后relayout;普通失焦则直接relayout.
|
|
|
|
//所以:stopEditing--选中其他button则响应click之后relayout;普通失焦则直接relayout.
|
|
|
|
private boolean pressOtherButtonWhenEditing = false; |
|
|
|
private boolean pressOtherButtonWhenEditing = false; |
|
|
|
|
|
|
|
|
|
|
|
public ChartTypeButtonPane(ChartTypePane chartTypePane){ |
|
|
|
public ChartTypeButtonPane(ChartTypePane chartTypePane) { |
|
|
|
this(); |
|
|
|
this(); |
|
|
|
parent = chartTypePane; |
|
|
|
parent = chartTypePane; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
eastPane.setLayout(new BorderLayout()); |
|
|
|
northPane.setLayout(new BorderLayout()); |
|
|
|
|
|
|
|
northPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) { |
|
|
@ -123,53 +152,95 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
private void checkMoveButton() { |
|
|
|
ChartInfoCollector.getInstance().collection(newChart, null); |
|
|
|
moveBackButton.setEnabled(editingCollection.getSelectedIndex() != editingCollection.getChartCount() - 1); |
|
|
|
} catch (CloneNotSupportedException e1) { |
|
|
|
moveForwardButton.setEnabled(editingCollection.getSelectedIndex() != 0); |
|
|
|
FineLoggerFactory.getLogger().error("Error in Clone"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
checkoutChange(); |
|
|
|
private void addNewChart(ChartProvider chart, String name, int index) { |
|
|
|
} |
|
|
|
if (chart == null) { |
|
|
|
layoutPane(buttonPane); |
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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() { |
|
|
|
calculateMultiChartMode(); |
|
|
|
calculateMultiChartMode(); |
|
|
|
if (parent != null){ |
|
|
|
if (parent != null) { |
|
|
|
parent.relayoutChartTypePane(editingCollection); |
|
|
|
parent.relayoutChartTypePane(editingCollection); |
|
|
|
} |
|
|
|
} |
|
|
|
//检查是否可以配置切换
|
|
|
|
//检查是否可以配置切换
|
|
|
|
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,48 +291,42 @@ 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() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
|
|
UIMenuNameableCreator ui = configCreator.clone(); |
|
|
|
|
|
|
|
final BasicBeanPane pane = ui.getPane(); |
|
|
|
|
|
|
|
pane.populateBean(editingCollection); |
|
|
|
|
|
|
|
UIDialog dialog = pane.showUnsizedWindow(SwingUtilities.getWindowAncestor(parent), new DialogActionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void doOk() { |
|
|
|
|
|
|
|
pane.updateBean(editingCollection); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void doCancel() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
dialog.setSize(P_W, P_H); |
|
|
|
|
|
|
|
dialog.setVisible(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getNewChartName() { |
|
|
|
private String getNewChartName() { |
|
|
|
int count = indexList.size() + 1; |
|
|
|
int count = indexList.size() + 1; |
|
|
|
while (true) { |
|
|
|
while (true) { |
|
|
|
String name_test = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Module_Name") + count; |
|
|
|
String nameTest = Toolkit.i18nText("Fine-Design_Chart_Module_Name") + 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)) { |
|
|
|
|
|
|
|
repeated = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
count++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!repeated) { |
|
|
|
private String getCopyChartName() { |
|
|
|
return name_test; |
|
|
|
String chartName = "CopyOf" + editingCollection.getChartName(editingCollection.getSelectedIndex()); |
|
|
|
|
|
|
|
if (!nameRepeated(chartName)) { |
|
|
|
|
|
|
|
return chartName; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
int count = 1; |
|
|
|
|
|
|
|
while (true) { |
|
|
|
|
|
|
|
String nameTest = chartName + count; |
|
|
|
|
|
|
|
if (!nameRepeated(nameTest)) { |
|
|
|
|
|
|
|
return nameTest; |
|
|
|
} |
|
|
|
} |
|
|
|
count++; |
|
|
|
count++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean nameRepeated(String name) { |
|
|
|
|
|
|
|
for (int i = 0, len = indexList.size(); i < len; i++) { |
|
|
|
|
|
|
|
ChartChangeButton nameable = indexList.get(i); |
|
|
|
|
|
|
|
if (ComparatorUtils.equals(nameable.getButtonName(), name)) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void layoutPane(JPanel northPane) { |
|
|
|
private void layoutPane(JPanel northPane) { |
|
|
|
if (northPane == null) { |
|
|
|
if (northPane == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -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); |
|
|
@ -391,7 +474,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen |
|
|
|
buttonPane.remove(currentEditingEditor); |
|
|
|
buttonPane.remove(currentEditingEditor); |
|
|
|
currentEditingEditor = null; |
|
|
|
currentEditingEditor = null; |
|
|
|
|
|
|
|
|
|
|
|
if(!pressOtherButtonWhenEditing) { |
|
|
|
if (!pressOtherButtonWhenEditing) { |
|
|
|
layoutPane(buttonPane); |
|
|
|
layoutPane(buttonPane); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -427,7 +510,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void focusLost(FocusEvent e) {//编辑状态lost才走这边
|
|
|
|
public void focusLost(FocusEvent e) {//编辑状态lost才走这边
|
|
|
|
if (currentEditingEditor != null ) { |
|
|
|
if (currentEditingEditor != null) { |
|
|
|
stopEditing(); |
|
|
|
stopEditing(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -519,7 +602,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen |
|
|
|
relayoutPane(); |
|
|
|
relayoutPane(); |
|
|
|
|
|
|
|
|
|
|
|
//重构面板
|
|
|
|
//重构面板
|
|
|
|
if (parent != null ){ |
|
|
|
if (parent != null) { |
|
|
|
parent.reLayoutEditPane(lastPlotID, editingCollection); |
|
|
|
parent.reLayoutEditPane(lastPlotID, editingCollection); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -534,7 +617,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
mouseClick(e); |
|
|
|
mouseClick(e); |
|
|
|
if(pressOtherButtonWhenEditing){ |
|
|
|
if (pressOtherButtonWhenEditing) { |
|
|
|
relayoutPane(); |
|
|
|
relayoutPane(); |
|
|
|
pressOtherButtonWhenEditing = false; |
|
|
|
pressOtherButtonWhenEditing = false; |
|
|
|
} |
|
|
|
} |
|
|
@ -581,7 +664,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen |
|
|
|
|
|
|
|
|
|
|
|
//需要先更新,最后重构面板
|
|
|
|
//需要先更新,最后重构面板
|
|
|
|
//重构面板
|
|
|
|
//重构面板
|
|
|
|
if (parent != null ){ |
|
|
|
if (parent != null) { |
|
|
|
parent.reLayoutEditPane(lastPlotID, editingCollection); |
|
|
|
parent.reLayoutEditPane(lastPlotID, editingCollection); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|