Qinghui.Liu
5 years ago
9 changed files with 534 additions and 141 deletions
@ -0,0 +1,123 @@
|
||||
package com.fr.van.chart.box.data; |
||||
|
||||
import com.fr.chart.base.ChartConstants; |
||||
import com.fr.chart.chartattr.ChartCollection; |
||||
import com.fr.chart.chartdata.NormalTableDataDefinition; |
||||
import com.fr.chart.chartdata.TableDataDefinition; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.chart.gui.data.ChartDataFilterPane; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.plugin.chart.box.data.VanBoxTableDefinitionHelper; |
||||
import com.fr.plugin.chart.box.data.VanBoxTableResultDefinition; |
||||
import com.fr.stable.ArrayUtils; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.ComboBoxModel; |
||||
|
||||
public class BoxPlotDataContentPaneHelp { |
||||
|
||||
public static void populateDataScreeningPane(ChartDataFilterPane dataScreeningPane, ChartCollection collection) { |
||||
NormalTableDataDefinition detailedDefinition = VanBoxTableDefinitionHelper.getBoxTableDetailedDefinition(collection); |
||||
VanBoxTableResultDefinition resultDefinition = VanBoxTableDefinitionHelper.getBoxTableResultDefinition(collection); |
||||
|
||||
if (detailedDefinition != null) { |
||||
dataScreeningPane.populateDefinition(detailedDefinition, false); |
||||
} else if (resultDefinition != null) { |
||||
dataScreeningPane.populateDefinition(resultDefinition, false); |
||||
} |
||||
} |
||||
|
||||
public static void updateDataScreeningPane(ChartDataFilterPane dataScreeningPane, ChartCollection collection) { |
||||
NormalTableDataDefinition detailedDefinition = VanBoxTableDefinitionHelper.getBoxTableDetailedDefinition(collection); |
||||
VanBoxTableResultDefinition resultDefinition = VanBoxTableDefinitionHelper.getBoxTableResultDefinition(collection); |
||||
|
||||
if (detailedDefinition != null) { |
||||
dataScreeningPane.updateDefinition(detailedDefinition); |
||||
} |
||||
|
||||
if (resultDefinition != null) { |
||||
dataScreeningPane.updateDefinition(resultDefinition); |
||||
} |
||||
} |
||||
|
||||
public static void updateCategoryPane(UIComboBox categoryCombox, ChartCollection collection, boolean isDetailed) { |
||||
Object categoryName = categoryCombox.getSelectedItem(); |
||||
|
||||
TableDataDefinition dataDefinition; |
||||
|
||||
if (isDetailed) { |
||||
dataDefinition = VanBoxTableDefinitionHelper.getBoxTableDetailedDefinition(collection); |
||||
|
||||
if (dataDefinition == null) { |
||||
return; |
||||
} |
||||
|
||||
if (ArrayUtils.contains(ChartConstants.getNoneKeys(), categoryName)) { |
||||
((NormalTableDataDefinition) dataDefinition).setCategoryName(StringUtils.EMPTY); |
||||
} else { |
||||
((NormalTableDataDefinition) dataDefinition).setCategoryName(categoryName == null ? null : categoryName.toString()); |
||||
} |
||||
} else { |
||||
dataDefinition = VanBoxTableDefinitionHelper.getBoxTableResultDefinition(collection); |
||||
|
||||
if (dataDefinition == null) { |
||||
return; |
||||
} |
||||
|
||||
if (ArrayUtils.contains(ChartConstants.getNoneKeys(), categoryName)) { |
||||
((VanBoxTableResultDefinition) dataDefinition).setCategoryName(StringUtils.EMPTY); |
||||
} else { |
||||
((VanBoxTableResultDefinition) dataDefinition).setCategoryName(categoryName == null ? null : categoryName.toString()); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static void populateCategoryPane(UIComboBox categoryCombox, ChartCollection collection, boolean isDetailed) { |
||||
TableDataDefinition data; |
||||
|
||||
if (isDetailed) { |
||||
data = VanBoxTableDefinitionHelper.getBoxTableDetailedDefinition(collection); |
||||
|
||||
if (data == null) { |
||||
categoryCombox.setSelectedItem(Toolkit.i18nText("Fine-Design_Chart_Use_None")); |
||||
} else { |
||||
populateCategoryItem(categoryCombox, ((NormalTableDataDefinition) data).getCategoryName()); |
||||
} |
||||
} else { |
||||
data = VanBoxTableDefinitionHelper.getBoxTableResultDefinition(collection); |
||||
|
||||
if (data == null) { |
||||
categoryCombox.setSelectedItem(Toolkit.i18nText("Fine-Design_Chart_Use_None")); |
||||
} else { |
||||
populateCategoryItem(categoryCombox, ((VanBoxTableResultDefinition) data).getCategoryName()); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static void populateCategoryItem(UIComboBox categoryCombox, Object item) { |
||||
if (ComparatorUtils.equals(item, StringUtils.EMPTY)) { |
||||
categoryCombox.setSelectedItem(Toolkit.i18nText("Fine-Design_Chart_Use_None")); |
||||
} else if (!boxItemsContainsObject(categoryCombox, item)) { |
||||
categoryCombox.setSelectedItem(null); |
||||
} else { |
||||
categoryCombox.setSelectedItem(item); |
||||
} |
||||
} |
||||
|
||||
public static boolean boxItemsContainsObject(UIComboBox box, Object item) { |
||||
if (box == null) { |
||||
return false; |
||||
} |
||||
|
||||
ComboBoxModel dataModel = box.getModel(); |
||||
|
||||
for (int i = 0; i < dataModel.getSize(); i++) { |
||||
if (ComparatorUtils.equals(dataModel.getElementAt(i), item)) { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
} |
@ -1,20 +0,0 @@
|
||||
package com.fr.van.chart.box.data; |
||||
|
||||
import com.fr.design.mainframe.chart.gui.ChartDataPane; |
||||
import com.fr.design.mainframe.chart.gui.data.table.CategoryPlotTableDataContentPane; |
||||
|
||||
import java.util.List; |
||||
|
||||
public class BoxPlotTableDetailedDataSeriesPane extends CategoryPlotTableDataContentPane { |
||||
|
||||
public BoxPlotTableDetailedDataSeriesPane(ChartDataPane parent) { |
||||
super(parent); |
||||
} |
||||
|
||||
public void refreshBoxListWithSelectTableData(List list) { |
||||
refreshBoxItems(categoryCombox, list); |
||||
categoryCombox.addItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")); |
||||
|
||||
seriesTypeComboxPane.refreshBoxListWithSelectTableData(list); |
||||
} |
||||
} |
@ -0,0 +1,143 @@
|
||||
package com.fr.van.chart.box.data; |
||||
|
||||
import com.fr.chart.chartattr.ChartCollection; |
||||
import com.fr.chart.chartdata.MoreNameCDDefinition; |
||||
import com.fr.chart.chartdata.NormalTableDataDefinition; |
||||
import com.fr.chart.chartdata.OneValueCDDefinition; |
||||
import com.fr.design.beans.FurtherBasicBeanPane; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.gui.frpane.UIComboBoxPane; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.chart.gui.ChartDataPane; |
||||
import com.fr.design.mainframe.chart.gui.data.table.SeriesNameUseFieldNamePane; |
||||
import com.fr.design.mainframe.chart.gui.data.table.SeriesNameUseFieldValuePane; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.design.utils.gui.UIComponentUtils; |
||||
import com.fr.plugin.chart.box.data.VanBoxTableDefinition; |
||||
import com.fr.plugin.chart.box.data.VanBoxTableDefinitionHelper; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class BoxPlotTableSeriesTypeUsePane extends UIComboBoxPane<ChartCollection> { |
||||
|
||||
private static boolean NEED_SUMMERY = false; |
||||
|
||||
private SeriesNameUseFieldValuePane nameFieldValuePane; |
||||
private SeriesNameUseFieldNamePane nameFieldNamePane; |
||||
|
||||
public BoxPlotTableSeriesTypeUsePane() { |
||||
cards = initPaneList(); |
||||
initComponents(); |
||||
} |
||||
|
||||
protected void initLayout() { |
||||
this.setLayout(new BorderLayout(4, LayoutConstants.VGAP_MEDIUM)); |
||||
|
||||
cardPane.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 15)); |
||||
|
||||
this.add(createNorthPane(), BorderLayout.NORTH); |
||||
this.add(cardPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
protected UIComboBox createComboBox() { |
||||
UIComboBox uiComboBox = new UIComboBox(); |
||||
UIComponentUtils.setPreferedWidth(uiComboBox, 100); |
||||
return uiComboBox; |
||||
} |
||||
|
||||
private JPanel createNorthPane() { |
||||
JPanel north = new JPanel(new BorderLayout(4, 0)); |
||||
|
||||
UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Series_Name_From")); |
||||
label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); |
||||
north.add(GUICoreUtils.createBorderLayoutPane(new Component[]{jcb, null, null, label, null})); |
||||
north.setBorder(BorderFactory.createEmptyBorder(10, 24, 0, 15)); |
||||
|
||||
return north; |
||||
} |
||||
|
||||
public void checkBoxUse(boolean hasUse) { |
||||
jcb.setEnabled(hasUse); |
||||
nameFieldValuePane.checkUse(hasUse); |
||||
} |
||||
|
||||
public void refreshBoxListWithSelectTableData(List list) { |
||||
nameFieldValuePane.refreshBoxListWithSelectTableData(list); |
||||
nameFieldNamePane.refreshBoxListWithSelectTableData(list); |
||||
} |
||||
|
||||
public void clearAllBoxList() { |
||||
nameFieldValuePane.clearAllBoxList(); |
||||
nameFieldNamePane.clearAllBoxList(); |
||||
} |
||||
|
||||
protected String title4PopupWindow() { |
||||
return Toolkit.i18nText("Fine-Design_Chart_Series_Name_From"); |
||||
} |
||||
|
||||
protected List<FurtherBasicBeanPane<? extends ChartCollection>> initPaneList() { |
||||
nameFieldValuePane = new SeriesNameUseFieldValuePane(); |
||||
nameFieldNamePane = new SeriesNameUseFieldNamePane(); |
||||
|
||||
nameFieldValuePane.relayoutPane(NEED_SUMMERY); |
||||
nameFieldNamePane.relayoutPane(NEED_SUMMERY); |
||||
|
||||
List<FurtherBasicBeanPane<? extends ChartCollection>> paneList = new ArrayList<FurtherBasicBeanPane<? extends ChartCollection>>(); |
||||
|
||||
paneList.add(nameFieldValuePane); |
||||
paneList.add(nameFieldNamePane); |
||||
|
||||
return paneList; |
||||
} |
||||
|
||||
public void relayoutPane() { |
||||
if (jcb.getSelectedIndex() == 0) { |
||||
nameFieldValuePane.relayoutPane(NEED_SUMMERY); |
||||
} else { |
||||
nameFieldNamePane.relayoutPane(NEED_SUMMERY); |
||||
} |
||||
} |
||||
|
||||
protected void comboBoxItemStateChanged() { |
||||
if (jcb.getSelectedIndex() == 0) { |
||||
nameFieldValuePane.relayoutPane(NEED_SUMMERY); |
||||
} else { |
||||
nameFieldNamePane.relayoutPane(NEED_SUMMERY); |
||||
} |
||||
} |
||||
|
||||
public void populateBean(ChartCollection collection) { |
||||
NormalTableDataDefinition definition = VanBoxTableDefinitionHelper.getBoxTableDetailedDefinition(collection); |
||||
|
||||
if (definition instanceof OneValueCDDefinition) { |
||||
this.setSelectedIndex(0); |
||||
nameFieldValuePane.populateDefinition(definition, NEED_SUMMERY); |
||||
} else if (definition instanceof MoreNameCDDefinition) { |
||||
this.setSelectedIndex(1); |
||||
nameFieldNamePane.populateDefinition(definition, NEED_SUMMERY); |
||||
} |
||||
} |
||||
|
||||
public void updateBean(ChartCollection ob) { |
||||
VanBoxTableDefinition table = VanBoxTableDefinitionHelper.getBoxTableDefinition(ob); |
||||
|
||||
NormalTableDataDefinition definition; |
||||
|
||||
if (this.getSelectedIndex() == 0) { |
||||
definition = nameFieldValuePane.updateDefinition(); |
||||
} else { |
||||
definition = nameFieldNamePane.updateDefinition(table.getDetailedDefinition()); |
||||
} |
||||
|
||||
table.setDetailedDefinition(definition); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue