Fangjie Hu 8 years ago
parent
commit
cd7e2f1b5d
  1. 8
      designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java
  2. 19
      designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java
  3. 66
      designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java

8
designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java

@ -55,12 +55,17 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
private static ChartTypeInterfaceManager classManager = null; private static ChartTypeInterfaceManager classManager = null;
//所有图表存储器
private static LinkedHashMap<String, IndependentChartUIProvider> chartTypeInterfaces = new LinkedHashMap<String, IndependentChartUIProvider>(); private static LinkedHashMap<String, IndependentChartUIProvider> chartTypeInterfaces = new LinkedHashMap<String, IndependentChartUIProvider>();
//插件图表存储器
private static LinkedHashMap<String, IndependentChartUIProvider> vanChartTypeInterfaces = new LinkedHashMap<String, IndependentChartUIProvider>();
public synchronized static ChartTypeInterfaceManager getInstance() { public synchronized static ChartTypeInterfaceManager getInstance() {
if (classManager == null) { if (classManager == null) {
classManager = new ChartTypeInterfaceManager(); classManager = new ChartTypeInterfaceManager();
chartTypeInterfaces.clear(); chartTypeInterfaces.clear();
vanChartTypeInterfaces.clear();
} }
return classManager; return classManager;
} }
@ -149,6 +154,9 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
if (chartTypeInterfaces != null && !chartTypeInterfaces.containsKey(plotID)) { if (chartTypeInterfaces != null && !chartTypeInterfaces.containsKey(plotID)) {
chartTypeInterfaces.put(plotID, provider); chartTypeInterfaces.put(plotID, provider);
} }
if (vanChartTypeInterfaces != null && !vanChartTypeInterfaces.containsKey(plotID)) {
vanChartTypeInterfaces.put(plotID, provider);
}
} }
/** /**

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

@ -3,6 +3,7 @@ package com.fr.design.mainframe.chart.gui;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.SwitchState;
import com.fr.chart.charttypes.ColumnIndependentChart; import com.fr.chart.charttypes.ColumnIndependentChart;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserver;
@ -11,6 +12,7 @@ import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.ibutton.UIButton; 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.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.gui.ChartTypePane.ComboBoxPane; import com.fr.design.mainframe.chart.gui.ChartTypePane.ComboBoxPane;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
@ -34,6 +36,7 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
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 = 3;
private AbstractChartAttrPane parent;
private UIButton addButton; private UIButton addButton;
private ArrayList<ChartChangeButton> indexList = new ArrayList<ChartChangeButton>(); private ArrayList<ChartChangeButton> indexList = new ArrayList<ChartChangeButton>();
@ -89,6 +92,11 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK);
} }
public ChartTypeButtonPane(AbstractChartAttrPane parent){
this();
this.parent = parent;
}
ActionListener addListener = new ActionListener() { ActionListener addListener = new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -101,6 +109,13 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
indexList.add(button); indexList.add(button);
if (editingCollection != null) { if (editingCollection != null) {
//判断当前编辑的图表类型
if(!ComparatorUtils.equals(editingCollection.getSelectedChart().getClass(), Chart.class)){
editingCollection.setState(SwitchState.NEW);
}else {
editingCollection.setState(SwitchState.DEFAULT);
}
Chart[] barChart = ColumnIndependentChart.columnChartTypes; Chart[] barChart = ColumnIndependentChart.columnChartTypes;
try { try {
Chart newChart = (Chart) barChart[0].clone(); Chart newChart = (Chart) barChart[0].clone();
@ -112,6 +127,10 @@ public class ChartTypeButtonPane extends BasicBeanPane<ChartCollection> implemen
} }
layoutPane(buttonPane); layoutPane(buttonPane);
if (parent != null){
parent.populate(editingCollection);
}
} }
}; };

66
designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java

@ -4,15 +4,19 @@ import com.fr.base.FRContext;
import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Plot; import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartattr.SwitchState;
import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chart.charttypes.ChartTypeManager;
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.gui.frpane.UIComboBoxPane; import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.icombobox.UIComboBox;
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.type.AbstractChartTypePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -34,7 +38,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
protected JPanel createContentPane() { protected JPanel createContentPane() {
JPanel content = new JPanel(new BorderLayout()); JPanel content = new JPanel(new BorderLayout());
buttonPane = new ChartTypeButtonPane(); buttonPane = new ChartTypeButtonPane(this);
content.add(buttonPane, BorderLayout.NORTH); content.add(buttonPane, BorderLayout.NORTH);
chartTypePane = new ComboBoxPane(); chartTypePane = new ComboBoxPane();
@ -130,14 +134,72 @@ public class ChartTypePane extends AbstractChartAttrPane{
} }
} }
} }
public void populateBean(ChartCollection collection) {
Chart chart = collection.getSelectedChart();
switch (collection.getState()){
case NEW:{
reactorComboBoxItem(chart, true);
break;
}
case DEFAULT:{
reactorComboBoxItem(chart, false);
break;
}
case NONE:{
populateBean(chart);
break;
}
default:{
populateBean(chart);
}
}
}
private void reactorComboBoxItem(Chart chart, boolean isVanChart){
//重构下拉选项
if (jcb != null) {
jcb.removeAllItems();
}
//重构下拉框选项
for (int i = 0; i < this.cards.size(); i++) {
String name = cards.get(i).title4PopupWindow();
if (name.contains(Inter.getLocText("Plugin-ChartF_NewChart")) && isVanChart){
jcb.addItem(cards.get(i).title4PopupWindow());
}else if (!name.contains(Inter.getLocText("Plugin-ChartF_NewChart")) && !isVanChart) {
jcb.addItem(cards.get(i).title4PopupWindow());
}
} }
for (int i = 0; i < this.cards.size(); i++) {
FurtherBasicBeanPane pane = cards.get(i);
if (pane.accept(chart)) {
pane.populateBean(chart);
int index = getJcbIndex(pane, jcb);
jcb.setSelectedIndex(index);
return;
}
}
}
private int getJcbIndex(FurtherBasicBeanPane pane, UIComboBox jcb) {
String name = pane.title4PopupWindow();
for (int i = 0; i < jcb.getItemCount(); i++){
if (ComparatorUtils.equals(name, jcb.getItemAt(i))){
return i;
}
}
return 0;
}
}
/** /**
* 更新界面属性 用于展示 * 更新界面属性 用于展示
*/ */
public void populate(ChartCollection collection) { public void populate(ChartCollection collection) {
Chart chart = collection.getSelectedChart(); Chart chart = collection.getSelectedChart();
chartTypePane.populateBean(chart); chartTypePane.populateBean(collection);
buttonPane.populateBean(collection); buttonPane.populateBean(collection);
} }

Loading…
Cancel
Save