From 6a8905f46746bfe3b0999516dedba23876468c7d Mon Sep 17 00:00:00 2001 From: zack Date: Wed, 15 Jul 2020 00:10:28 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-34994=20=E7=A7=BB=E5=8A=A8=E7=AB=AF?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E6=8A=98=E5=8F=A0=E6=A0=91=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?(=E5=8D=95=E5=85=83=E6=A0=BC=E5=B1=9E=E6=80=A7=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=8E=A5=E5=8F=A3)-=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cell/AbstractCellElementPropertyPane.java | 23 +++++++++++++ .../cell/CellElementPropertyComponent.java | 34 +++++++++++++++++++ .../fr/design/fun/CellAttributeProvider.java | 2 ++ .../design/fun/CellPropertyPaneProvider.java | 18 ++++++++++ .../AbstractCellPropertyPaneProvider.java | 15 ++++++++ .../mainframe/EastRegionContainerPane.java | 6 ++-- .../mainframe/ElementCasePaneDelegate.java | 32 ++++++++++++++++- 7 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/cell/AbstractCellElementPropertyPane.java create mode 100644 designer-base/src/main/java/com/fr/design/cell/CellElementPropertyComponent.java create mode 100644 designer-base/src/main/java/com/fr/design/fun/CellPropertyPaneProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellPropertyPaneProvider.java diff --git a/designer-base/src/main/java/com/fr/design/cell/AbstractCellElementPropertyPane.java b/designer-base/src/main/java/com/fr/design/cell/AbstractCellElementPropertyPane.java new file mode 100644 index 000000000..3e4e001a8 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/cell/AbstractCellElementPropertyPane.java @@ -0,0 +1,23 @@ +package com.fr.design.cell; + +import com.fr.design.designer.TargetComponent; +import com.fr.design.dialog.BasicPane; + +import javax.swing.JPanel; + +/** + * @author zack + * @version 10.0 + * Created by zack on 2020/7/14 + */ +public abstract class AbstractCellElementPropertyPane extends BasicPane implements CellElementPropertyComponent { + @Override + public JPanel toPanel() { + return this; + } + + @Override + public boolean accept(TargetComponent tc) { + return true; + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/cell/CellElementPropertyComponent.java b/designer-base/src/main/java/com/fr/design/cell/CellElementPropertyComponent.java new file mode 100644 index 000000000..b3e6f4167 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/cell/CellElementPropertyComponent.java @@ -0,0 +1,34 @@ +package com.fr.design.cell; + +import com.fr.design.designer.TargetComponent; + +import javax.swing.JPanel; + +/** + * 单元格属性配置面板接口 + * @author zack + * @version 10.0 + * Created by zack on 2020/7/14 + */ +public interface CellElementPropertyComponent { + + /** + * 判断当前编辑的对象是否显示当前实现 + * @param tc + * @return + */ + boolean accept(TargetComponent tc); + + /** + * 加载数据 + * @param tc + */ + void populate(TargetComponent tc); + + /** + * 返回当前属性面板,默认返回this + * @return + */ + JPanel toPanel(); + +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/fun/CellAttributeProvider.java b/designer-base/src/main/java/com/fr/design/fun/CellAttributeProvider.java index 227333cd0..82f7a8144 100644 --- a/designer-base/src/main/java/com/fr/design/fun/CellAttributeProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/CellAttributeProvider.java @@ -4,8 +4,10 @@ import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.stable.fun.mark.Immutable; /** + * 单元格属性面板扩展接口,接口基本逻辑不通且不符合接口设计规范,单元格属性扩展可以使用CellPropertyPaneProvider * Created by zhouping on 2015/11/11. */ +@Deprecated public interface CellAttributeProvider extends Immutable{ String MARK_STRING = "CellAttributeProvider"; diff --git a/designer-base/src/main/java/com/fr/design/fun/CellPropertyPaneProvider.java b/designer-base/src/main/java/com/fr/design/fun/CellPropertyPaneProvider.java new file mode 100644 index 000000000..0100f4b2c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/CellPropertyPaneProvider.java @@ -0,0 +1,18 @@ +package com.fr.design.fun; + +import com.fr.design.cell.CellElementPropertyComponent; + +/** + * 单元格设置(属性)扩展接口 + * @author zack + * @version 10.0 + * Created by zack on 2020/7/14 + */ +public interface CellPropertyPaneProvider extends PropertyItemPaneProvider { + + /** + * 构造单元格属性面板,面板实现需要使用单例模式实现 + * @return 面板类 + */ + CellElementPropertyComponent getSingletonCelPropertyPane(); +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellPropertyPaneProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellPropertyPaneProvider.java new file mode 100644 index 000000000..ba1c71d5f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellPropertyPaneProvider.java @@ -0,0 +1,15 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.CellPropertyPaneProvider; +import com.fr.stable.fun.mark.API; + +/** + * Created by zhouping on 2015/11/11. + */ +@API(level = CellPropertyPaneProvider.CURRENT_LEVEL) +public abstract class AbstractCellPropertyPaneProvider extends AbstractPropertyItemPaneProvider implements CellPropertyPaneProvider { + + public int currentAPILevel() { + return CellPropertyPaneProvider.CURRENT_LEVEL; + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java index 394dfca1e..b2328f295 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java @@ -219,8 +219,10 @@ public class EastRegionContainerPane extends UIEastResizableContainer { itemBean.getEnableModes()); UIButton button = propertyItem.getButton(); List buttonListeners = itemBean.getButtonListeners(); - for (ActionListener buttonListener : buttonListeners) { - button.addActionListener(buttonListener); + if (buttonListeners != null) { + for (ActionListener buttonListener : buttonListeners) { + button.addActionListener(buttonListener); + } } propertyItemMap.put(key, propertyItem); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java index 22ab32344..3f46dded8 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignState; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.cell.CellAttributeAction; import com.fr.design.actions.cell.CellExpandAttrAction; @@ -18,7 +19,10 @@ import com.fr.design.actions.utils.DeprecatedActionManager; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.cell.CellElementPropertyComponent; +import com.fr.design.fun.CellPropertyPaneProvider; import com.fr.design.fun.MenuHandler; +import com.fr.design.fun.PropertyItemPaneProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.mainframe.cell.QuickEditorRegion; import com.fr.design.menu.KeySetUtils; @@ -28,15 +32,17 @@ import com.fr.design.present.ConditionAttributesGroupPane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.selection.SelectionEvent; import com.fr.design.selection.SelectionListener; - +import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.Selection; import com.fr.page.ReportSettingsProvider; +import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.worksheet.WorkSheet; import com.fr.stable.ArrayUtils; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.util.Set; /** @@ -82,6 +88,9 @@ public class ElementCasePaneDelegate extends ElementCasePane { } CellWidgetPropertyPane.getInstance().populate(ElementCasePaneDelegate.this); CellElementPropertyPane.getInstance().populate(ElementCasePaneDelegate.this); + //加载插件中的单元格属性 + populateExtraCellProperties(); + QuickEditorRegion.getInstance().populate(getCurrentEditor()); JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); // 模板初始化完成后,才能初始化超级链接面板 @@ -218,4 +227,25 @@ public class ElementCasePaneDelegate extends ElementCasePane { return this.getTarget().getReportSettings(); } + private void populateExtraCellProperties() { + Selection selection = getSelection(); + if (selection instanceof CellSelection) { + //单元格属性,限定下是选中单个单元格 + TemplateElementCase elementCase = getEditingElementCase(); + if (elementCase != null) { + Set itemPaneProviders = ExtraDesignClassManager.getInstance().getArray(PropertyItemPaneProvider.XML_TAG); + if (itemPaneProviders != null) { + for (PropertyItemPaneProvider itemPaneProvider : itemPaneProviders) { + if(itemPaneProvider instanceof CellPropertyPaneProvider){ + CellPropertyPaneProvider cellPropertyPaneProvider = (CellPropertyPaneProvider) itemPaneProvider; + CellElementPropertyComponent cellElementPropertyPane = cellPropertyPaneProvider.getSingletonCelPropertyPane(); + if (cellElementPropertyPane != null && cellElementPropertyPane.accept(ElementCasePaneDelegate.this)) { + cellElementPropertyPane.populate(ElementCasePaneDelegate.this); + } + } + } + } + } + } + } } From 1910d60fc951dd0b1a69c84d04f4f084812c0b44 Mon Sep 17 00:00:00 2001 From: zack Date: Wed, 15 Jul 2020 13:54:27 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-34994=20=E7=A7=BB=E5=8A=A8=E7=AB=AF?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E6=8A=98=E5=8F=A0=E6=A0=91=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?(=E5=8D=95=E5=85=83=E6=A0=BC=E5=B1=9E=E6=80=A7=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=8E=A5=E5=8F=A3)-=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E9=83=A8=E5=88=86=20=20,=E8=A1=A8=E5=8D=95=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?=E5=9D=97=E4=B9=9F=E9=9C=80=E8=A6=81=E8=BF=99=E4=B8=AA=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/CellElementPropertyPane.java | 30 +++++++++++++++++++ .../mainframe/ElementCasePaneDelegate.java | 30 ------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/CellElementPropertyPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/CellElementPropertyPane.java index 7324300eb..1716fb476 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/CellElementPropertyPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/CellElementPropertyPane.java @@ -4,9 +4,13 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.cell.CellElementPropertyComponent; import com.fr.design.fun.BackgroundQuickUIProvider; import com.fr.design.fun.CellAttributeProvider; +import com.fr.design.fun.CellPropertyPaneProvider; import com.fr.design.fun.PresentKindProvider; +import com.fr.design.fun.PropertyItemPaneProvider; import com.fr.design.gui.frpane.UITitlePanel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itabpane.TitleChangeListener; @@ -31,6 +35,7 @@ import javax.swing.JPanel; import javax.swing.SwingConstants; import java.awt.BorderLayout; import java.awt.Dimension; +import java.util.Set; /** @@ -156,6 +161,7 @@ public class CellElementPropertyPane extends DockingView { return; } ePane.getSelection().populatePropertyPane(ePane); + populateExtraCellProperties(ePane); } @Override @@ -188,5 +194,29 @@ public class CellElementPropertyPane extends DockingView { EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_CELL_ATTR); EastRegionContainerPane.getInstance().setWindow2PreferWidth(); } + private void populateExtraCellProperties(ElementCasePane ePane) { + if (ePane == null) { + return; + } + Selection selection = ePane.getSelection(); + if (selection instanceof CellSelection) { + //单元格属性,限定下是选中单个单元格 + TemplateElementCase elementCase = ePane.getEditingElementCase(); + if (elementCase != null) { + Set itemPaneProviders = ExtraDesignClassManager.getInstance().getArray(PropertyItemPaneProvider.XML_TAG); + if (itemPaneProviders != null) { + for (PropertyItemPaneProvider itemPaneProvider : itemPaneProviders) { + if(itemPaneProvider instanceof CellPropertyPaneProvider){ + CellPropertyPaneProvider cellPropertyPaneProvider = (CellPropertyPaneProvider) itemPaneProvider; + CellElementPropertyComponent cellElementPropertyPane = cellPropertyPaneProvider.getSingletonCelPropertyPane(); + if (cellElementPropertyPane != null && cellElementPropertyPane.accept(ePane)) { + cellElementPropertyPane.populate(ePane); + } + } + } + } + } + } + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java index 3f46dded8..83a1c0850 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java @@ -2,7 +2,6 @@ package com.fr.design.mainframe; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignState; -import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.cell.CellAttributeAction; import com.fr.design.actions.cell.CellExpandAttrAction; @@ -19,10 +18,7 @@ import com.fr.design.actions.utils.DeprecatedActionManager; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.cell.CellElementPropertyComponent; -import com.fr.design.fun.CellPropertyPaneProvider; import com.fr.design.fun.MenuHandler; -import com.fr.design.fun.PropertyItemPaneProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.mainframe.cell.QuickEditorRegion; import com.fr.design.menu.KeySetUtils; @@ -32,17 +28,14 @@ import com.fr.design.present.ConditionAttributesGroupPane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.selection.SelectionEvent; import com.fr.design.selection.SelectionListener; -import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.Selection; import com.fr.page.ReportSettingsProvider; -import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.worksheet.WorkSheet; import com.fr.stable.ArrayUtils; import javax.swing.JPanel; import java.awt.BorderLayout; -import java.util.Set; /** @@ -88,8 +81,6 @@ public class ElementCasePaneDelegate extends ElementCasePane { } CellWidgetPropertyPane.getInstance().populate(ElementCasePaneDelegate.this); CellElementPropertyPane.getInstance().populate(ElementCasePaneDelegate.this); - //加载插件中的单元格属性 - populateExtraCellProperties(); QuickEditorRegion.getInstance().populate(getCurrentEditor()); JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); @@ -227,25 +218,4 @@ public class ElementCasePaneDelegate extends ElementCasePane { return this.getTarget().getReportSettings(); } - private void populateExtraCellProperties() { - Selection selection = getSelection(); - if (selection instanceof CellSelection) { - //单元格属性,限定下是选中单个单元格 - TemplateElementCase elementCase = getEditingElementCase(); - if (elementCase != null) { - Set itemPaneProviders = ExtraDesignClassManager.getInstance().getArray(PropertyItemPaneProvider.XML_TAG); - if (itemPaneProviders != null) { - for (PropertyItemPaneProvider itemPaneProvider : itemPaneProviders) { - if(itemPaneProvider instanceof CellPropertyPaneProvider){ - CellPropertyPaneProvider cellPropertyPaneProvider = (CellPropertyPaneProvider) itemPaneProvider; - CellElementPropertyComponent cellElementPropertyPane = cellPropertyPaneProvider.getSingletonCelPropertyPane(); - if (cellElementPropertyPane != null && cellElementPropertyPane.accept(ElementCasePaneDelegate.this)) { - cellElementPropertyPane.populate(ElementCasePaneDelegate.this); - } - } - } - } - } - } - } } From 2dc9d95653a042033a30329409dbdb6e314543fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Thu, 16 Jul 2020 17:12:05 +0800 Subject: [PATCH 3/4] =?UTF-8?q?CHART-12123=20=E5=9B=BE=E8=A1=A8=E9=A2=84?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E9=85=8D=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../combobox/ColorSchemeComboBox.java | 13 +- .../design/module/ChartPreStyleListPane.java | 142 ++++++++++++++++ .../module/ChartPreStyleManagerPane.java | 153 +++++++++++------- .../fr/design/module/ChartPreStylePane.java | 2 +- 4 files changed, 249 insertions(+), 61 deletions(-) create mode 100644 designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java b/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java index e7a7ab929..e09362cb6 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java @@ -52,7 +52,7 @@ public class ColorSchemeComboBox extends UIComboBox { this.setRenderer(new ColorSchemeCellRenderer()); } - private Map getColorSchemesFromConfig() { + protected Map getColorSchemesFromConfig() { Map colorSchemes = new LinkedHashMap<>(); ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); @@ -92,7 +92,14 @@ public class ColorSchemeComboBox extends UIComboBox { } public void refresh() { - this.colorSchemes = getColorSchemesFromConfig(); + refresh(null); + } + + public void refresh(Map colorSchemes) { + if (colorSchemes == null) { + colorSchemes = getColorSchemesFromConfig(); + } + this.colorSchemes = colorSchemes; this.setModel(new DefaultComboBoxModel(colorSchemes.keySet().toArray())); } @@ -149,7 +156,7 @@ public class ColorSchemeComboBox extends UIComboBox { return colorSchemes.keySet(); } - public class ColorInfo { + public static class ColorInfo { private List colors; diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java new file mode 100644 index 000000000..f2f5c3cf6 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java @@ -0,0 +1,142 @@ +package com.fr.design.module; + +import com.fr.base.ChartColorMatching; +import com.fr.base.ChartPreStyleConfig; +import com.fr.base.Utils; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.controlpane.JListControlPane; +import com.fr.design.gui.controlpane.NameObjectCreator; +import com.fr.design.gui.controlpane.NameableCreator; +import com.fr.design.gui.controlpane.ShortCut4JControlPane; +import com.fr.design.gui.ilist.ModNameActionListener; +import com.fr.design.menu.ShortCut; +import com.fr.general.NameObject; +import com.fr.stable.Nameable; + +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import java.util.ArrayList; +import java.util.Iterator; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-07-08 + */ +public class ChartPreStyleListPane extends JListControlPane { + + ChartPreStyleManagerPane chartPreStyleManagerPane; + + public ChartPreStyleListPane(ChartPreStyleManagerPane chartPreStyleManagerPane) { + super(); + this.chartPreStyleManagerPane = chartPreStyleManagerPane; + initListener(); + } + + /** + * 创建有名字的creator + * + * @return 有名字的creator数组 + */ + @Override + public NameableCreator[] createNameableCreators() { + return new NameableCreator[]{ + new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_PreStyle_Duplicate"), + ChartColorMatching.class, ChartPreStylePane.class) + }; + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_PreStyle"); + } + + @Override + public BasicBeanPane createPaneByCreators(NameableCreator creator) { + return new ChartPreStylePane() { + @Override + protected void refreshWhenStyleChange(ChartColorMatching preStyle) { + super.refreshWhenStyleChange(preStyle); + chartPreStyleManagerPane.refreshDefaultColorBox(); + } + }; + } + + + protected ShortCut4JControlPane[] createShortcuts() { + return new ShortCut4JControlPane[]{ + shortCutFactory.addItemShortCut(), + createRemoveItemShortCut(), + shortCutFactory.copyItemShortCut(), + shortCutFactory.moveUpItemShortCut(), + shortCutFactory.moveDownItemShortCut(), + shortCutFactory.sortItemShortCut() + }; + } + + private ShortCut4JControlPane createRemoveItemShortCut() { + ShortCut4JControlPane shortCut4JControlPane = shortCutFactory.removeItemShortCut(); + //替换删除按钮的check事件。 + ShortCut shortCut = shortCut4JControlPane.getShortCut(); + shortCut4JControlPane = new MoreThanOneShortCut(shortCut); + return shortCut4JControlPane; + } + + public void initListener() { + nameableList.addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent e) { + chartPreStyleManagerPane.refreshDefaultColorBox(); + } + }); + nameableList.addModNameActionListener(new ModNameActionListener() { + @Override + public void nameModed(int index, String oldName, String newName) { + chartPreStyleManagerPane.refreshDefaultColorBox(oldName, newName); + } + }); + } + + public void populateBean() { + ChartPreStyleConfig config = ChartPreStyleConfig.getInstance().mirror(); + ArrayList list = new ArrayList(); + + Iterator keys = config.names(); + while (keys.hasNext()) { + Object key = keys.next(); + ChartColorMatching value = (ChartColorMatching) config.getPreStyle(key); + + list.add(new NameObject(Utils.objectToString(key), value)); + } + + Nameable[] values = (Nameable[]) list.toArray(new Nameable[list.size()]); + populate(values); + + if (config.containsName(config.getCurrentStyle())) { + this.setSelectedName(config.getCurrentStyle()); + } + } + + public void updateBean() { + ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); + + Nameable[] values = update(); + config.clearAllPreStyle(); + + for (Nameable value : values) { + config.putPreStyle(value.getName(), ((NameObject) value).getObject()); + } + } + + private class MoreThanOneShortCut extends ShortCut4JControlPane { + public MoreThanOneShortCut(ShortCut shortCut) { + this.shortCut = shortCut; + } + + + @Override + public void checkEnable() { + this.shortCut.setEnabled(nameableList.getModel().getSize() > 1); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleManagerPane.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleManagerPane.java index abae5118b..a0615817b 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleManagerPane.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleManagerPane.java @@ -2,72 +2,111 @@ package com.fr.design.module; import com.fr.base.ChartColorMatching; import com.fr.base.ChartPreStyleConfig; -import com.fr.base.Utils; -import com.fr.design.gui.controlpane.JListControlPane; -import com.fr.design.gui.controlpane.NameObjectCreator; -import com.fr.design.gui.controlpane.NameableCreator; +import com.fr.design.chartx.component.combobox.ColorSchemeComboBox; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralUtils; import com.fr.general.NameObject; import com.fr.stable.Nameable; -import java.util.ArrayList; +import javax.swing.JPanel; import java.util.Iterator; - +import java.util.LinkedHashMap; +import java.util.Map; +import java.awt.BorderLayout; /** * 图表预定义管理 界面, 在工具栏-服务器管理中. + * * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2013-8-21 下午02:33:48 */ -public class ChartPreStyleManagerPane extends JListControlPane { - - @Override - /** - * 创建有名字的creator - * @return 有名字的creator数组 - */ - public NameableCreator[] createNameableCreators() { - return new NameableCreator[]{ - new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_PreStyle_Duplicate"), - ChartColorMatching.class, ChartPreStylePane.class) - }; - } - - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_PreStyle"); - } - - public void populateBean() { - ChartPreStyleConfig config = ChartPreStyleConfig.getInstance().mirror(); - ArrayList list = new ArrayList(); - - Iterator keys = config.names(); - while(keys.hasNext()) { - Object key = keys.next(); - ChartColorMatching value = (ChartColorMatching) config.getPreStyle(key); - - list.add(new NameObject(Utils.objectToString(key), value)); - } - - Nameable[] values = (Nameable[])list.toArray(new Nameable[list.size()]); - populate(values); - - if(config.containsName(config.getCurrentStyle())) { - this.setSelectedName(config.getCurrentStyle()); - } - } - - public void updateBean() { - ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); - - config.setCurrentStyle(getSelectedName()); - - Nameable[] values = update(); - config.clearAllPreStyle(); - - for (Nameable value : values) { - config.putPreStyle(value.getName(), ((NameObject) value).getObject()); - } - } +public class ChartPreStyleManagerPane extends BasicPane { + + private ColorSchemeComboBox defaultColorBox; + + private ChartPreStyleListPane chartPreStyleListPane; + + public ChartPreStyleManagerPane() { + initComponent(); + } + + private void initComponent() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel colorBoxPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + + chartPreStyleListPane = new ChartPreStyleListPane(this); + + initDefaultColorBox(); + colorBoxPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Match_Default_Color_Scheme") + ":")); + colorBoxPane.add(defaultColorBox); + + this.add(colorBoxPane, BorderLayout.NORTH); + this.add(chartPreStyleListPane, BorderLayout.CENTER); + } + + private void initDefaultColorBox() { + Map colorSchemes = new LinkedHashMap<>(); + ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); + Iterator names = config.names(); + while (names.hasNext()) { + Object key = names.next(); + ColorSchemeComboBox.ColorInfo colorInfo = new ColorSchemeComboBox.ColorInfo(); + ChartColorMatching colorMatching = (ChartColorMatching) config.getPreStyle(key); + colorInfo.setGradient(colorMatching.getGradient()); + colorInfo.setColors(colorMatching.getColorList()); + colorSchemes.put(colorMatching.getId(), colorInfo); + } + defaultColorBox = new ColorSchemeComboBox(colorSchemes); + } + + private void refreshColorSchemes() { + Nameable[] nameables = chartPreStyleListPane.update(); + Map colorSchemes = new LinkedHashMap<>(); + for (Nameable value : nameables) { + String name = value.getName(); + ChartColorMatching colorMatching = (ChartColorMatching) ((NameObject) value).getObject(); + ColorSchemeComboBox.ColorInfo colorInfo = new ColorSchemeComboBox.ColorInfo(); + colorInfo.setGradient(colorMatching.getGradient()); + colorInfo.setColors(colorMatching.getColorList()); + colorSchemes.put(name, colorInfo); + } + defaultColorBox.refresh(colorSchemes); + } + + public void refreshDefaultColorBox() { + Object selectedItem = defaultColorBox.getSelectedItem(); + refreshColorSchemes(); + defaultColorBox.setSelectedItem(selectedItem); + } + + public void refreshDefaultColorBox(String oldName, String newName) { + Object selectedItem = defaultColorBox.getSelectedItem(); + if (ComparatorUtils.equals(selectedItem, oldName)) { + selectedItem = newName; + } + refreshColorSchemes(); + defaultColorBox.setSelectedItem(selectedItem); + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Report_ServerM_Predefined_Styles"); + } + + public void populateBean() { + ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); + String currentStyle = config.getCurrentStyle(); + defaultColorBox.setSelectedItem(currentStyle); + chartPreStyleListPane.populateBean(); + } + public void updateBean() { + ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); + config.setCurrentStyle(GeneralUtils.objectToString(defaultColorBox.getSelectedItem())); + chartPreStyleListPane.updateBean(); + } } diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java index 5bd4c3897..9cce2be7c 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java @@ -80,7 +80,7 @@ public class ChartPreStylePane extends BasicBeanPane { } } - private void refreshWhenStyleChange(ChartColorMatching preStyle) { + protected void refreshWhenStyleChange(ChartColorMatching preStyle) { if(chartComponent != null) { demoPlot.setPlotFillStyle(ChartUtils.chartColorMatching2AttrFillStyle(preStyle)); chartComponent.reset(); From 3a6efa8b3b901f0c489f9fa561f6942a51c11352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Fri, 17 Jul 2020 13:48:46 +0800 Subject: [PATCH 4/4] =?UTF-8?q?CHART-14664=20=E5=AE=BD=E5=BA=A6=E5=AE=9A?= =?UTF-8?q?=E9=95=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/module/ChartPreStyleManagerPane.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleManagerPane.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleManagerPane.java index a0615817b..44b504ef3 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleManagerPane.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleManagerPane.java @@ -11,12 +11,14 @@ import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import com.fr.general.NameObject; import com.fr.stable.Nameable; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; import javax.swing.JPanel; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.awt.BorderLayout; +import java.awt.Dimension; /** * 图表预定义管理 界面, 在工具栏-服务器管理中. @@ -61,6 +63,7 @@ public class ChartPreStyleManagerPane extends BasicPane { colorSchemes.put(colorMatching.getId(), colorInfo); } defaultColorBox = new ColorSchemeComboBox(colorSchemes); + defaultColorBox.setPreferredSize(new Dimension(TableLayout4VanChartHelper.EDIT_AREA_WIDTH, 20)); } private void refreshColorSchemes() {