diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java index 443fea07a7..4012366a30 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java @@ -22,11 +22,11 @@ import com.fr.stable.StringUtils; import javax.swing.JPanel; import javax.swing.SwingConstants; +import java.util.ArrayList; +import java.util.List; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; -import java.util.ArrayList; -import java.util.List; /** * Created by shine on 2018/9/12. @@ -171,7 +171,6 @@ public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane< public void checkBoxUse(boolean hasUse) { series.setEnabled(hasUse); value.setEnabled(hasUse); - function.setEnabled(hasUse); } public void clearAllBoxList() { diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java index f82e4b253c..5d1a8c2f74 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java @@ -34,6 +34,7 @@ public abstract class AbstractMultiComponentPane extends J private List categoryComponentList = new ArrayList(); + private boolean categoryAxis = true; protected abstract T createFirstFieldComponent(); @@ -43,6 +44,16 @@ public abstract class AbstractMultiComponentPane extends J protected abstract void updateField(T component, ColumnField field); + public void setCategoryAxis(boolean categoryAxis) { + this.categoryAxis = categoryAxis; + if(!categoryAxis){ + addButton.setEnabled(false); + for (JComponent component : categoryComponentList) { + component.setEnabled(false); + } + } + } + public AbstractMultiComponentPane() { UILabel label = new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Category")); @@ -126,7 +137,7 @@ public abstract class AbstractMultiComponentPane extends J } private boolean canAdd() { - return categoryComponentList.size() < 2; + return categoryComponentList.size() < 2 && categoryAxis; } public List componentList() { @@ -169,7 +180,15 @@ public abstract class AbstractMultiComponentPane extends J } } - public void checkEnable(boolean hasUse){ - addButton.setEnabled(hasUse); + public void checkEnable(boolean hasUse) { + //增加按钮是否灰化要根据是否选择了数据源,是否分类轴,分类数量是否超标三个判断 + boolean buttonUse = hasUse && categoryAxis && categoryComponentList.size() < 2; + //额外的分类是否灰化根据是否选择了数据源,是否分类轴判断 + boolean categoryUse = hasUse && categoryAxis; + + addButton.setEnabled(buttonUse); + for (JComponent component : categoryComponentList) { + component.setEnabled(categoryUse); + } } } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java index 187dd25475..73a6351647 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java @@ -20,7 +20,6 @@ import javax.swing.event.ChangeListener; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; -import java.awt.Label; /** * Created by shine on 2019/07/18. @@ -110,7 +109,7 @@ public abstract class AbstractSingleFilterPane extends AbstractChartTabPane { } refreshBoxList(); - checkBoxUse(); tableDataPane.populateBean(ob.getNameTableData()); dataSetFieldsPane.populateBean(ob.getColumnFieldCollection()); + + checkBoxUse(); } @Override diff --git a/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java b/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java index 77347e0fd8..6df855cd70 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java @@ -14,6 +14,11 @@ public class UIComboBoxWithNone extends UIComboBox { return Toolkit.i18nText("Fine-Design_Chart_Use_None"); } + public UIComboBoxWithNone() { + super(); + addDefaultItem(); + } + @Override public void refreshBoxItems(List list) { super.refreshBoxItems(list); diff --git a/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractMultiCategoryVanChartUI.java b/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractMultiCategoryVanChartUI.java index 6cd2743fef..3aec1f671d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractMultiCategoryVanChartUI.java +++ b/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractMultiCategoryVanChartUI.java @@ -1,6 +1,7 @@ package com.fr.van.chart.vanchart; import com.fr.chart.chartattr.Chart; +import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; import com.fr.design.chartx.AbstractVanSingleDataPane; @@ -14,7 +15,13 @@ import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPa import com.fr.design.mainframe.chart.gui.data.report.CategoryPlotReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.CategoryPlotTableDataContentPane; +import com.fr.general.ComparatorUtils; +import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.plot.VanChartPlot; +import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; +import com.fr.plugin.chart.column.VanChartColumnPlot; +import com.fr.plugin.chart.type.AxisType; +import com.fr.plugin.chart.vanchart.VanChart; import com.fr.van.chart.designer.data.VanChartMoreCateReportDataContentPane; import com.fr.van.chart.designer.data.VanChartMoreCateTableDataContentPane; import com.fr.van.chart.designer.other.VanChartInteractivePane; @@ -68,9 +75,33 @@ public abstract class AbstractMultiCategoryVanChartUI extends AbstractIndependen @Override public ChartDataPane getChartDataPane(AttributeChangeListener listener) { return new AbstractVanSingleDataPane(listener) { + MultiCategoryDataSetFieldsPane multiCategoryDataSetFieldsPane; + MultiCategoryCellDataFieldsPane multiCategoryCellDataFieldsPane; + @Override protected SingleDataPane createSingleDataPane() { - return new SingleDataPane(new MultiCategoryDataSetFieldsPane(), new MultiCategoryCellDataFieldsPane()); + multiCategoryDataSetFieldsPane = new MultiCategoryDataSetFieldsPane(); + multiCategoryCellDataFieldsPane = new MultiCategoryCellDataFieldsPane(); + return new SingleDataPane(multiCategoryDataSetFieldsPane, multiCategoryCellDataFieldsPane); + } + + @Override + public void populate(ChartCollection collection) { + super.populate(collection); + VanChart vanChart = this.getVanChart(); + if (vanChart == null) { + return; + } + + VanChartRectanglePlot plot = vanChart.getPlot(); + VanChartAxis axis = plot.getDefaultXAxis(); + if (plot instanceof VanChartColumnPlot + && ((VanChartColumnPlot) plot).isBar()) { + axis = plot.getDefaultYAxis(); + } + + multiCategoryDataSetFieldsPane.setCategoryAxis(ComparatorUtils.equals(axis.getAxisType(), AxisType.AXIS_CATEGORY)); + multiCategoryCellDataFieldsPane.setCategoryAxis(ComparatorUtils.equals(axis.getAxisType(), AxisType.AXIS_CATEGORY)); } }; }