diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index ce32e2323c..ce495cdb97 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -236,7 +236,7 @@ public class EnvChangeEntrance { //说明版本一致,仅做日志记录 FineLoggerFactory.getLogger().info("Remote Designer version consistency"); } else { - localBranch = formatBranch(localBranch); + localBranch = GeneralUtils.getVersion(); remoteBranch = formatBranch(remoteBranch); Set noExistServiceSet = getNoExistServiceSet(connectionInfo); StringBuilder textBuilder = new StringBuilder(); diff --git a/designer-base/src/main/java/com/fr/design/actions/TableDataSourceAction.java b/designer-base/src/main/java/com/fr/design/actions/TableDataSourceAction.java index 600f9721ed..a0ca4d9558 100644 --- a/designer-base/src/main/java/com/fr/design/actions/TableDataSourceAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/TableDataSourceAction.java @@ -15,6 +15,7 @@ import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; /* @@ -51,6 +52,10 @@ public class TableDataSourceAction extends TemplateComponentAction iterator = tds.getTableDataNameIterator(); + while (iterator.hasNext()) { + DesignTableDataManager.removeSelectedColumnNames(iterator.next()); + } DesignModelAdapter.getCurrentModelAdapter().renameTableData(tableDataPane.getDsNameChangedMap()); tableDataPane.update(tds); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); diff --git a/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java b/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java index b0803635c9..4fd7e6c42b 100644 --- a/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java @@ -17,6 +17,7 @@ import com.fr.design.mainframe.toolbar.UpdateActionManager; import com.fr.design.menu.ShortCut; import com.fr.design.selection.SelectionListener; import com.fr.general.ComparatorUtils; +import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import com.fr.stable.pinyin.PinyinFormat; import com.fr.stable.pinyin.PinyinHelper; @@ -562,7 +563,12 @@ public abstract class UpdateAction extends ShortCut implements Action { for (int i = 0; i < component.getTabCount(); i++) { String title = component.getTitleAt(i); handleSearchText(separator, text, pinyin, shortPinyin, title); - Component tabComponent = component.getComponentAt(i); + Component tabComponent = null; + try { + tabComponent = component.getComponentAt(i); + } catch (Exception ignore) { + FineLoggerFactory.getLogger().info("AlphaFine index tabPane end"); + } if (tabComponent instanceof JPanel) { getComponentTexts((JPanel) tabComponent, separator, text, pinyin, shortPinyin); } else if (tabComponent instanceof JTabbedPane) { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/BugNeedAction.java b/designer-base/src/main/java/com/fr/design/actions/community/BugNeedAction.java new file mode 100644 index 0000000000..17ee23b530 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/actions/community/BugNeedAction.java @@ -0,0 +1,48 @@ +package com.fr.design.actions.community; + +import com.fr.base.BaseUtils; +import com.fr.design.actions.UpdateAction; +import com.fr.design.locale.impl.BugNeedMark; +import com.fr.design.menu.MenuKeySet; +import com.fr.design.utils.BrowseUtils; +import com.fr.general.locale.LocaleCenter; +import com.fr.general.locale.LocaleMark; + +import javax.swing.*; +import java.awt.event.ActionEvent; + +/** + * @Author: Yuan.Wang + * @Date: 2020/7/28 + */ +public class BugNeedAction extends UpdateAction { + public BugNeedAction() { + this.setMenuKeySet(BugAndNeed); + this.setName(getMenuKeySet().getMenuName()); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/need.png")); + } + + @Override + public void actionPerformed(ActionEvent e) { + LocaleMark localeMark = LocaleCenter.getMark(BugNeedMark.class); + BrowseUtils.browser(localeMark.getValue()); + } + + public static final MenuKeySet BugAndNeed = new MenuKeySet() { + @Override + public char getMnemonic() { + return 0; + } + + @Override + public String getMenuName() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_BugAndNeed"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; +} diff --git a/designer-base/src/main/java/com/fr/design/actions/community/TechSupportAction.java b/designer-base/src/main/java/com/fr/design/actions/community/TechSupportAction.java new file mode 100644 index 0000000000..9c8067138e --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/actions/community/TechSupportAction.java @@ -0,0 +1,49 @@ +package com.fr.design.actions.community; + +import com.fr.base.BaseUtils; +import com.fr.design.actions.UpdateAction; +import com.fr.design.locale.impl.TechSupportMark; +import com.fr.design.menu.MenuKeySet; +import com.fr.design.utils.BrowseUtils; +import com.fr.general.locale.LocaleCenter; +import com.fr.general.locale.LocaleMark; + +import javax.swing.*; +import java.awt.event.ActionEvent; + +/** + * @Author: Yuan.Wang + * @Date: 2020/7/28 + */ +public class TechSupportAction extends UpdateAction { + public TechSupportAction() { + this.setMenuKeySet(TechSupport); + this.setName(getMenuKeySet().getMenuName()); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/support.png")); + } + + @Override + public void actionPerformed(ActionEvent e) { + LocaleMark localeMark = LocaleCenter.getMark(TechSupportMark.class); + String str=localeMark.getValue(); + BrowseUtils.browser(localeMark.getValue()); + } + + public static final MenuKeySet TechSupport = new MenuKeySet() { + @Override + public char getMnemonic() { + return 0; + } + + @Override + public String getMenuName() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_TechSupport"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; +} diff --git a/designer-base/src/main/java/com/fr/design/actions/file/OpenRecentReportMenuDef.java b/designer-base/src/main/java/com/fr/design/actions/file/OpenRecentReportMenuDef.java index 2bb026159f..7533cb133a 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/OpenRecentReportMenuDef.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/OpenRecentReportMenuDef.java @@ -1,6 +1,7 @@ package com.fr.design.actions.file; import java.awt.event.ActionEvent; +import java.io.File; import java.util.List; import com.fr.base.BaseUtils; @@ -11,6 +12,7 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.MenuDef; import com.fr.file.FILEFactory; +import com.fr.file.FileFILE; /** * Open Resent MenuDef. @@ -68,7 +70,12 @@ public class OpenRecentReportMenuDef extends MenuDef { * @param e 事件 */ public void actionPerformed(ActionEvent e) { - DesignerContext.getDesignerFrame().openTemplate(FILEFactory.createFILE(this.getPath())); + File file = new File(this.getPath()); + if (file.exists()) { + DesignerContext.getDesignerFrame().openTemplate(new FileFILE(file)); + } else { + DesignerContext.getDesignerFrame().openTemplate(FILEFactory.createFILE(this.getPath())); + } } public String getPath() { diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index 57d9bbcb9a..0ccb5d3e7b 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -256,7 +256,7 @@ public class PreferencePane extends BasicPane { } private void createVcsSettingPane(JPanel generalPane) { - JPanel vcsPane = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Title")); + JPanel vcsPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Title")); generalPane.add(vcsPane); remindVcsLabel = new UILabel(i18nText("Fine-Design_Vcs_Remind")); remindVcsLabel.setVisible(!VcsHelper.getInstance().needInit()); @@ -449,10 +449,6 @@ public class PreferencePane extends BasicPane { JPanel colorSettingPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Setting_Colors")); generalPane.add(colorSettingPane); - new UILabel(i18nText("Fine-Design_Basic_Preference_Grid_Line_Color")); - - new UILabel(i18nText("Fine-Design_Basic_Preference_Pagination_Line_Color")); - gridLineColorTBButton = new UIColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); gridLineColorTBButton.setEnabled(this.isEnabled()); diff --git a/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java b/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java index a7aac03913..6158540888 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java @@ -11,8 +11,10 @@ import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.general.CloudCenter; +import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.GeneralUtils; +import com.fr.locale.InterProviderFactory; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.bridge.StableFactory; @@ -36,14 +38,16 @@ public class AboutPane extends JPanel { private static final String BUILD_PREFIX = " "; private static final String COMPANY_TELEPHONE = CloudCenter.getInstance().acquireUrlByKind("help.compNo"); private static final String PRESIDENT_PHONE = CloudCenter.getInstance().acquireUrlByKind("help.PNo"); + private static final String LEFT_BRACKET = "("; + private static final String RIGHT_BRACKET = ")"; private int maxWidth; public AboutPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.maxWidth = GraphHelper.getWidth(getBuildTitle() + GeneralUtils.readFullBuildNO() + - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy_Build_NO") + - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy_Build_NO_OK")); + this.maxWidth = GraphHelper.getWidth(getBuildTitle() + getVersionBuildNO() + + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy_Build_NO") + + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy_Build_NO_OK")); //center panel JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); this.add(centerPane, BorderLayout.CENTER); @@ -51,9 +55,10 @@ public class AboutPane extends JPanel { JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); centerPane.add(contentPane, BorderLayout.NORTH); + contentPane.add(new BoxCenterAligmentPane(getBuildTitle())); BoxCenterAlignmentCopyablePane buildCopyPane = new BoxCenterAlignmentCopyablePane( - getBuildTitle(), - GeneralUtils.readFullBuildNO(), + StringUtils.EMPTY, + getVersionBuildNO(), new String[]{ com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy_Build_NO"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy_Build_NO_OK") @@ -95,6 +100,15 @@ public class AboutPane extends JPanel { } } + public String getVersionBuildNO() { + String version = GeneralUtils.getVersion(); + String build = GeneralUtils.readFullBuildNO(); + String notInstalledVersion = InterProviderFactory.getProvider().getLocText("Fine-Core_Basic_About_No_Build"); + if (ComparatorUtils.equals(notInstalledVersion, build)) + return notInstalledVersion; + return version + LEFT_BRACKET + build + RIGHT_BRACKET; + } + @Override public Dimension getPreferredSize() { return new Dimension(this.maxWidth, super.getPreferredSize().height); @@ -191,7 +205,7 @@ public class AboutPane extends JPanel { private String getBuildTitle() { return append(ProductConstants.APP_NAME, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_About_Version"), - StringUtils.BLANK, ProductConstants.RELEASE_VERSION, BUILD_PREFIX); + StringUtils.BLANK, ProductConstants.VERSION, BUILD_PREFIX); } private JPanel getEmailActionPane(final String desc, final String mailTo) { @@ -289,12 +303,13 @@ public class AboutPane extends JPanel { public BoxCenterAlignmentCopyablePane(String title, String copyText, final String[] descriptions) { setLayout(FRGUIPaneFactory.createBorderLayout()); JPanel centerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - this.label = new UILabel(title); + if (StringUtils.isNotEmpty(title)) { + this.label = new UILabel(title); + centerPane.add(label); + } this.textField = new UILabel(copyText); textField.setBackground(null); textField.setBorder(null); - - centerPane.add(label); centerPane.add(textField); textField.addMouseListener(new MouseAdapter() { @Override diff --git a/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java b/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java index 0e9db97c7a..627a862fb6 100644 --- a/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java @@ -5,7 +5,6 @@ package com.fr.design.actions.server; import com.fr.base.BaseUtils; import com.fr.base.TableData; -import com.fr.config.Configuration; import com.fr.design.DesignModelAdapter; import com.fr.design.actions.UpdateAction; import com.fr.design.data.DesignTableDataManager; @@ -18,12 +17,10 @@ import com.fr.design.gui.NameInspector; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.design.menu.MenuKeySet; -import com.fr.file.ProcedureConfig; import com.fr.file.TableDataConfig; import com.fr.transaction.CallBackAdaptor; import com.fr.transaction.Configurations; -import com.fr.transaction.Worker; import com.fr.transaction.WorkerFacade; import javax.swing.KeyStroke; @@ -95,6 +92,10 @@ public class GlobalTableDataAction extends UpdateAction implements ResponseDataS } DesignTableDataManager.clearGlobalDs(); + // 保存时 移除服务器数据集列名缓存 + for (String name : tableDataConfig.getTableDatas().keySet()) { + DesignTableDataManager.removeSelectedColumnNames(name); + } Configurations.modify(new WorkerFacade(TableDataConfig.class) { @Override 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 0000000000..3e4e001a8f --- /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 0000000000..b3e6f41674 --- /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/condition/ConditionAttributesPane.java b/designer-base/src/main/java/com/fr/design/condition/ConditionAttributesPane.java index 781c57b052..6ca4ed6808 100644 --- a/designer-base/src/main/java/com/fr/design/condition/ConditionAttributesPane.java +++ b/designer-base/src/main/java/com/fr/design/condition/ConditionAttributesPane.java @@ -15,8 +15,9 @@ import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JScrollPane; import java.awt.Dimension; -import java.util.HashMap; import java.util.Iterator; +import java.util.Map; +import java.util.LinkedHashMap; @Open public abstract class ConditionAttributesPane extends BasicBeanPane { @@ -27,7 +28,7 @@ public abstract class ConditionAttributesPane extends BasicBeanPane { protected LiteConditionPane liteConditionPane; - protected java.util.Map classPaneMap = new HashMap(); + protected Map classPaneMap = new LinkedHashMap<>(); //可用的Actions. protected java.util.List useAbleActionList = new java.util.ArrayList(); @@ -70,7 +71,7 @@ public abstract class ConditionAttributesPane extends BasicBeanPane { selectedItemScrollPane.setMinimumSize(new Dimension((int) selectedItemScrollPane.getPreferredSize().getWidth(), MIN_HEIGHT)); propertyChangePane.add(selectedItemScrollPane); } - + public void updateBean(T ob) { updateMenuDef(); } diff --git a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java index f9c9ddab6b..f2b1e8e5b3 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java +++ b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java @@ -439,9 +439,14 @@ public abstract class DesignTableDataManager { * @throws Exception 异常 */ public static EmbeddedTableData previewTableDataNeedInputParameters(TableDataSource tableDataSource, TableData tabledata, int rowCount, boolean needLoadingBar) throws Exception { - return previewTableData(tableDataSource, tabledata, rowCount, true, needLoadingBar); + return previewTableDataNeedInputParameters(tableDataSource, tabledata, rowCount, needLoadingBar, null); } + public static EmbeddedTableData previewTableDataNeedInputParameters(TableDataSource tableDataSource, TableData tabledata, int rowCount, boolean needLoadingBar, AutoProgressBar progressBar) throws Exception { + return previewTableData(tableDataSource, tabledata, rowCount, true, needLoadingBar, progressBar); + } + + /** * 预览不需要参数的数据集 * @@ -478,7 +483,16 @@ public abstract class DesignTableDataManager { * @return */ private static EmbeddedTableData previewTableData(TableDataSource tableDataSource, TableData tabledata, int rowCount, boolean isMustInputParameters, boolean needLoadingBar) throws Exception { - final AutoProgressBar loadingBar = PreviewTablePane.getInstance().getProgressBar(); + return previewTableData(tableDataSource, tabledata, rowCount, isMustInputParameters, needLoadingBar, null); + } + + private static EmbeddedTableData previewTableData(TableDataSource tableDataSource, TableData tabledata, int rowCount, boolean isMustInputParameters, boolean needLoadingBar, AutoProgressBar progressBar) throws Exception { + final AutoProgressBar loadingBar; + if (progressBar == null) { + loadingBar = PreviewTablePane.getInstance().getProgressBar(); + } else { + loadingBar = progressBar; + } ParameterProvider[] parameters = DataOperator.getInstance().getTableDataParameters(tabledata); if (ArrayUtils.isEmpty(parameters)) { parameters = tabledata.getParameters(Calculator.createCalculator()); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java index dcb38c14ee..bebcd14e25 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java @@ -71,28 +71,42 @@ public class TableDataCreatorProducer { } public TableDataNameObjectCreator[] createServerTableDataCreator() { - TableDataNameObjectCreator dataBase = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Database_Query"), "/com/fr/design/images/data/dock/serverdatabase.png", DBTableData.class, + TableDataNameObjectCreator dataBase = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Database_Query"), + "ds", + "/com/fr/design/images/data/dock/serverdatabase.png", DBTableData.class, DBTableDataPane.class); - TableDataNameObjectCreator ds_Class = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Class"), "/com/fr/design/images/data/dock/serverclasstabledata.png", ClassTableData.class, + TableDataNameObjectCreator ds_Class = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Class"), + "Class", + "/com/fr/design/images/data/dock/serverclasstabledata.png", ClassTableData.class, ClassTableDataPane.class); - TableDataNameObjectCreator table = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Embedded"), "/com/fr/design/images/data/dock/serverdatatable.png", EmbeddedTableData.class, + TableDataNameObjectCreator table = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Embedded"), + "Embedded", + "/com/fr/design/images/data/dock/serverdatatable.png", EmbeddedTableData.class, EmbeddedTableDataPane.class); - TableDataNameObjectCreator fileTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_File"), "/com/fr/design/images/data/file.png", FileTableData.class, + TableDataNameObjectCreator fileTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_File"), + "File", + "/com/fr/design/images/data/file.png", FileTableData.class, FileTableDataSmallPane.class); - TableDataNameObjectCreator treeTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Tree"), "/com/fr/design/images/data/tree.png", + TableDataNameObjectCreator treeTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Tree"), + "Tree", + "/com/fr/design/images/data/tree.png", RecursionTableData.class, GlobalTreeTableDataPane.class) { public boolean isNeedParameterWhenPopulateJControlPane() { return true; } }; - TableDataNameObjectCreator multiTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Relation"), "/com/fr/design/images/data/multi.png", + TableDataNameObjectCreator multiTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Relation"), + "Multi", + "/com/fr/design/images/data/multi.png", ConditionTableData.class, GlobalMultiTDTableDataPane.class) { public boolean isNeedParameterWhenPopulateJControlPane() { return true; } }; - TableDataNameObjectCreator storeProcedure = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Stored_Procedure"), "/com/fr/design/images/data/store_procedure.png", + TableDataNameObjectCreator storeProcedure = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Stored_Procedure"), + "Proc", + "/com/fr/design/images/data/store_procedure.png", StoreProcedure.class, ProcedureDataPane.class) { @Override public boolean shouldInsertSeparator() { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java index 575ba43f5b..46706cf591 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java @@ -17,6 +17,10 @@ import javax.swing.table.AbstractTableModel; * 这个TableModel主要是预览数据的. 字段TableData必须转化为内置的 */ public class PreviewTableModel extends AbstractTableModel { + + private static final int LEN_LIMIT = 1000; + private static final String THREE_DOT = "..."; + private DataModel dataModel; private String erroMessage = null; @@ -127,11 +131,21 @@ public class PreviewTableModel extends AbstractTableModel { public Object getValueAt(int row, int column) { try { - return dataModel.getValueAt(row, column); + Object value = dataModel.getValueAt(row, column); + if (value != null) { + String strValue = value.toString(); + // 字符长度过长 swing会卡住一会 + // 同时设计器内预览展示也不需要展示太长的字符 + if (strValue.length() > LEN_LIMIT) { + strValue = strValue.substring(0, LEN_LIMIT) + THREE_DOT; + return strValue; + } + } + return value; } catch (TableDataException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); DesignUtils.errorMessage(e.getMessage()); - return ""; + return StringUtils.EMPTY; } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java index 2cd16b4940..8d8e3a48c6 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java @@ -372,7 +372,7 @@ public class PreviewTablePane extends BasicPane { connectionBar.close(); } TableDataSource dataSource = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getTarget(); - previewTableData = DesignTableDataManager.previewTableDataNeedInputParameters(dataSource, tableData, (int) maxPreviewNumberField.getValue(), true); + previewTableData = DesignTableDataManager.previewTableDataNeedInputParameters(dataSource, tableData, (int) maxPreviewNumberField.getValue(), true, progressBar); // parameterInputDialog // update之后的parameters,转成一个parameterMap,用于预览TableData PreviewTableModel previewModel = new PreviewTableModel(previewTableData.createDataModel(null), (int) maxPreviewNumberField.getValue()); diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java index 6ad281e268..23e6f46136 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java @@ -29,10 +29,10 @@ import com.fr.design.gui.itableeditorpane.UITableEditorPane; import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants; import com.fr.design.gui.syntax.ui.rtextarea.RTextScrollPane; -import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.ToolBarDef; +import com.fr.design.utils.ParameterUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.general.sql.SqlUtils; @@ -219,8 +219,7 @@ public class DBTableDataPane extends AbstractTableDataPane { paramTexts[1] = SqlUtils.tryPureSqlText(pageQuery); List existParameterList = editorPane.update(); Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]); - - editorPane.populate(ParameterHelper.analyzeAndUnionSameParameters(paramTexts, ps)); + editorPane.populate(ParameterUtils.analyzeAndUnionParameters(paramTexts, ps)); } private JToolBar createToolBar() { @@ -316,7 +315,8 @@ public class DBTableDataPane extends AbstractTableDataPane { // com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + "."); } } - + // 保存前 刷新下参数列表 保证获取到最新的参数 + refresh(); List parameterList = editorPane.update(); Parameter[] parameters = parameterList.toArray(new Parameter[parameterList.size()]); diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MaxMemRowCountPanel.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MaxMemRowCountPanel.java index 00bbcc995b..d43e6bdee4 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MaxMemRowCountPanel.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MaxMemRowCountPanel.java @@ -1,5 +1,6 @@ package com.fr.design.data.tabledata.tabledatapane; + import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -11,6 +12,8 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.i18n.Toolkit; +import com.fr.stable.StringUtils; public class MaxMemRowCountPanel extends UIToolbar { @@ -19,7 +22,7 @@ public class MaxMemRowCountPanel extends UIToolbar { private static final String[] CACHE_LIST = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save_All_Records_In_Memory"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Max_Mem_Row_Count") }; private static final int MAX_WIDTH = getMaxComBoBoxWidth() > 200 ? 350 : 250; - + private static final int MAX_COMPONENT_COUNT_OF_MAX_MEMORY = 4; private static int getMaxComBoBoxWidth() { int maxWidth = GraphHelper.getWidth(CACHE_LIST[0]); for (int i = 1; i < CACHE_LIST.length; i++) { @@ -86,9 +89,13 @@ public class MaxMemRowCountPanel extends UIToolbar { this.removeAll(); this.add(switchCache); switchCache.setSelectedIndex(MAX_IN_MEMORY); - this.add(new UILabel(" ")); + if (this.getComponentCount() == MAX_COMPONENT_COUNT_OF_MAX_MEMORY) { + //此处因为switchCache的setSelectedIndex可能会造成双层调用,然后因为重复添加组件产生bug,故而定义这个工具栏的正常最大组件数,做个判断 + return; + } + this.add(new UILabel(StringUtils.BLANK)); this.add(numberSpinner); - this.add(new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Row"))); + this.add(new UILabel(StringUtils.BLANK + Toolkit.i18nText("Fine-Design_Basic_Row"))); this.validate(); this.repaint(); } diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java index 2cf170c55e..571e13d447 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java @@ -19,6 +19,7 @@ import com.fr.design.gui.itableeditorpane.UITableEditorPane; import com.fr.design.gui.itextfield.UITextField; import com.fr.general.ComparatorUtils; +import com.fr.log.FineLoggerFactory; import com.fr.script.Calculator; import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; @@ -95,9 +96,8 @@ public class MultiTDTableDataPane extends AbstractTableDataPane> entryIt = resMap.entrySet().iterator(); - while (entryIt.hasNext()) { - TableDataWrapper tableDataWrappe = entryIt.next().getValue(); + for (Entry stringTableDataWrapperEntry : resMap.entrySet()) { + TableDataWrapper tableDataWrappe = stringTableDataWrapperEntry.getValue(); String tmp = tableDataWrappe.getTableDataName(); if (!ComparatorUtils.equals(tableDataWrappe.getTableDataName(), multiName)) { centerPanel.add(new BarPanel(tmp, tableDataWrappe.getIcon())); @@ -111,13 +111,10 @@ public class MultiTDTableDataPane extends AbstractTableDataPane { + MultiTDTableData td = MultiTDTableDataPane.this.updateBean(); + td.setTableDataSource(DesignTableDataManager.getEditingTableDataSource()); + new TemplateTableDataWrapper(td).previewData(); }; } @@ -126,12 +123,12 @@ public class MultiTDTableDataPane extends AbstractTableDataPane(new ParameterTableModel() { + editorPane = new UITableEditorPane<>(new ParameterTableModel() { @Override public UITableEditAction[] createAction() { return new UITableEditAction[]{new RefreshAction()}; } - }, " " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Default_Parameter")); + }, StringUtils.BLANK + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Default_Parameter")); jpanel.add(editorPane, BorderLayout.CENTER); @@ -162,29 +159,32 @@ public class MultiTDTableDataPane extends AbstractTableDataPane existParameterList = new ArrayList(); - Iterator> dataItera = choosenTableData.entrySet().iterator(); - List parameterName = new ArrayList(); - while (dataItera.hasNext()) { - Entry entry = dataItera.next(); - TableData td = resMap.get(entry.getKey()).getTableData(); - ParameterProvider[] currentparameters = td.getParameters(Calculator.createCalculator()); - for (int i=0; i existParameterList = new ArrayList<>(); + List parameterName = new ArrayList<>(); + for (Entry entry : choosenTableData.entrySet()) { + TableData td = resMap.get(entry.getKey()).getTableData(); + ParameterProvider[] currentParameters = td.getParameters(Calculator.createCalculator()); + for (ParameterProvider currentParameter : currentParameters) { + if (parameterName.contains(currentParameter.getName())) { + continue; + } + parameterName.add(currentParameter.getName()); + try { + //采用给新的界面刷新参数时,clone一个值过去,不然会出现联动修改 + existParameterList.add((ParameterProvider) currentParameter.clone()); + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } } ParameterProvider[] texts = ParameterHelper.analyze4Parameters(paramTexts, true); - for (int i=0; i> it = choosenTableData.entrySet().iterator(); - while (it.hasNext()) { - Entry entry = it.next(); + for (Entry entry : choosenTableData.entrySet()) { td.addTableData(entry.getKey(), entry.getValue()); } List paramList = editorPane.update(); if (paramList != null) { - td.setDefineParameters(paramList.toArray(new Parameter[paramList.size()])); + td.setDefineParameters(paramList.toArray(new Parameter[0])); } return td; @@ -348,9 +346,7 @@ public class MultiTDTableDataPane extends AbstractTableDataPane { + final UIFormula formulaPane = FormulaFactory.createFormulaPane(); + formulaPane.populate(BaseFormula.createFormulaBuilder().build(formulaContentTextField.getText())); + formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(MultiTDTableDataPane.this), new DialogActionAdapter() { + public void doOk() { + BaseFormula formula = formulaPane.update(); + if (formula == null) { + formulaContentTextField.setText(StringUtils.EMPTY); + } else { + formulaContentTextField.setText(formula.getContent().substring(1)); } - }).setVisible(true); - } + MultiTDTableDataPane.this.refresh(); + } + }).setVisible(true); }; } } diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java index 3d96ea1efc..6d1685e74f 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java @@ -1,6 +1,6 @@ package com.fr.design.env; -import com.fr.cluster.engine.remote.ClusterOperator; +import com.fr.cluster.engine.rpc.remote.ClusterOperator; import com.fr.design.i18n.Toolkit; import com.fr.base.operator.common.CommonOperator; import com.fr.rpc.ExceptionHandler; @@ -24,11 +24,11 @@ public class RemoteWorkspace implements Workspace { private final WorkspaceClient client; private final String address; - + private final WorkspaceConnectionInfo connection; - + private volatile Boolean isRoot = null; - + RemoteWorkspace(WorkspaceClient client, WorkspaceConnectionInfo connection) { this.client = client; @@ -41,13 +41,13 @@ public class RemoteWorkspace implements Workspace { return address; } - + @Override public String getDescription() { - + return Toolkit.i18nText("Fine-Design_Basic_Remote_Env"); } - + @Override public boolean isWarDeploy() { return WorkContext.getCurrent().get(CommonOperator.class, new ExceptionHandler() { @@ -66,7 +66,7 @@ public class RemoteWorkspace implements Workspace { @Override public boolean isRoot() { - + if (isRoot == null) { synchronized (this) { if (isRoot == null) { @@ -89,10 +89,10 @@ public class RemoteWorkspace implements Workspace { @Override public WorkspaceConnection getConnection() { - + return client.getConnection(); } - + @Override public T get(Class type) { @@ -111,22 +111,22 @@ public class RemoteWorkspace implements Workspace { } return client.getPool().get(type); } - + @Override public void close() { - + client.close(); } - + @Override public int hashCode() { - + return connection.hashCode(); } - + @Override public boolean equals(Object obj) { - + return obj instanceof RemoteWorkspace && AssistUtils.equals(((RemoteWorkspace) obj).connection, this.connection); } diff --git a/designer-base/src/main/java/com/fr/design/event/StateChangeListener.java b/designer-base/src/main/java/com/fr/design/event/StateChangeListener.java new file mode 100644 index 0000000000..9e4e655f31 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/event/StateChangeListener.java @@ -0,0 +1,9 @@ +package com.fr.design.event; + +/** + * @Author: Yuan.Wang + * @Date: 2020/7/29 + */ +public interface StateChangeListener { + public void stateChange(); +} diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java index 466e919b72..ba1cce5563 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java @@ -370,6 +370,7 @@ public class HistoryTemplateListCache implements CallbackEvent { */ public void load() { FineLoggerFactory.getLogger().info("Env Change Template Loading..."); + JTemplate currentTemplate = null; if (stashFILEMap != null && stashFILEMap.size() != 0) { int size = historyList.size(); for (int i = 0; i < size; i++) { @@ -385,20 +386,24 @@ public class HistoryTemplateListCache implements CallbackEvent { historyList.set(i, template); // 替换当前正在编辑的模板,使用添加并激活的方式,以便使用统一的入口来处理监听事件 if (isCurrentEditingFile(template.getPath())) { - loadCurrentTemplate(template); + currentTemplate = template; } } else { // 当模板为空时 说明是一个新建的未保存模板 但是内存中保存了该模板 可以从中获取 JTemplate jt = historyList.get(i); // 另外如果该模板是正在编辑的模板,需要要激活 if (jt != null && isCurrentEditingFile(jt.getPath())) { - loadCurrentTemplate(jt); + currentTemplate = jt; } } } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } + // 最后加载当前正在编辑的模板 以保证数据集刷新正常 + if (currentTemplate != null) { + loadCurrentTemplate(currentTemplate); + } stashFILEMap.clear(); MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList); MutilTempalteTabPane.getInstance().repaint(); diff --git a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java index f271f23c0e..e331d296ef 100644 --- a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java @@ -1 +1,244 @@ -package com.fr.design.file; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilist.UIList; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.ProductConstants; import javax.swing.*; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; /** * Author : daisy * Date: 13-8-9 * Time: 下午3:41 */ public class SaveSomeTemplatePane extends BasicPane { private UICheckBox[] templateCheckBoxes = null; private BasicDialog dialog; private JPanel templatesChoosePane; private UIScrollPane scrollPane; private java.util.List> unSavedTemplate = new ArrayList>(); private boolean isAllSaved = false; //该变量用来判断是在关闭其他模板或是关闭设计器的时候,是否需要判断当前模板有没有保存 private boolean isJudgeCurrentEditingTemplate = true; public SaveSomeTemplatePane(boolean isNeedTojudgeCurrent) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); if (this.dialog == null) { this.dialog = this.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override public void doOk() { for (int i = 0; i < templateCheckBoxes.length; i++) { if (templateCheckBoxes[i].isSelected()) { saveSelectedTemplate(unSavedTemplate.get(i)); } } isAllSaved = true; } public void doCancel() { isAllSaved = false; } }); } UILabel tip = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_The_Source_To_Save")); this.add(tip, BorderLayout.NORTH); templatesChoosePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); UIScrollPane scrollPane = new UIScrollPane(templatesChoosePane); this.add(scrollPane, BorderLayout.CENTER); this.isJudgeCurrentEditingTemplate = isNeedTojudgeCurrent; } private void initTemplatesChoosePane() { templatesChoosePane.setBorder(BorderFactory.createTitledBorder("")); for (int i = 0; i < unSavedTemplate.size(); i++) { templateCheckBoxes[i] = new UICheckBox(unSavedTemplate.get(i).getEditingFILE().getName()); templateCheckBoxes[i].setSelected(true); } final UIList templatesList = new UIList(templateCheckBoxes); templatesList.setModel(new UnSeletedTemplateListDataMode()); templatesList.setCellRenderer(new UnSelectedListCellRender()); templatesList.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { super.mousePressed(e); int index = templatesList.getSelectedIndex(); if (index < 0) { return; } UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(index); checkBox.setSelected(!checkBox.isSelected()); templatesList.repaint(); } }); final UICheckBox filenameCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_All")); filenameCheckBox.setSelected(true); filenameCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean isSelected = filenameCheckBox.isSelected(); for (int i = 0; i < templatesList.getModel().getSize(); i++) { UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(i); checkBox.setSelected(isSelected); } templatesList.repaint(); } }); templatesChoosePane.add(filenameCheckBox, BorderLayout.NORTH); templatesChoosePane.add(templatesList, BorderLayout.CENTER); } public boolean showSavePane() { populate(); //如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目 if (!unSavedTemplate.isEmpty()) { dialog.setVisible(true); } else { isAllSaved = true; } return isAllSaved; } public void populate() { java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); for (int i = 0; i < opendedTemplate.size(); i++) { if (isneedToAdd(opendedTemplate.get(i), currentTemplate)) { unSavedTemplate.add(opendedTemplate.get(i)); } } templateCheckBoxes = new UICheckBox[unSavedTemplate.size()]; initTemplatesChoosePane(); } private boolean isneedToAdd(JTemplate template, JTemplate currentTemplate) { //所有模板都判断是不是保存 if (isJudgeCurrentEditingTemplate) { return !template.isALLSaved(); } //当前编辑的模板不判断是否已经保存 if (ComparatorUtils.equals(template, currentTemplate)) { return false; } else { return !template.isALLSaved(); } } private void saveSelectedTemplate(JTemplate specifiedTemplate) { if (!specifiedTemplate.isSaved()) { specifiedTemplate.stopEditing(); specifiedTemplate.saveTemplate(); } FineLoggerFactory.getLogger().info( com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); } public int saveLastOneTemplate() { JTemplate specifiedTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (!specifiedTemplate.isALLSaved()) { specifiedTemplate.stopEditing(); int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (returnVal == JOptionPane.YES_OPTION && specifiedTemplate.saveTemplate()) { specifiedTemplate.saveTemplate(); FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); } return returnVal; } return JOptionPane.YES_OPTION; } protected String title4PopupWindow() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save"); } private class UnSelectedListCellRender extends DefaultListCellRenderer { @Override public Component getListCellRendererComponent(JList list, Object value, int index, final boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); templateCheckBoxes[index] = (UICheckBox) value; templateCheckBoxes[index].setBackground(list.getBackground()); return templateCheckBoxes[index]; } } private class UnSeletedTemplateListDataMode extends AbstractListModel { @Override public int getSize() { return templateCheckBoxes.length; } @Override public UICheckBox getElementAt(int index) { if (index > getSize() - 1 || index < 0) { return null; } return templateCheckBoxes[index]; } } } \ No newline at end of file +package com.fr.design.file; + +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.event.StateChangeListener; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ilist.UIList; +import com.fr.design.gui.itree.checkboxtree.NullTristateCheckBox; +import com.fr.design.gui.itree.checkboxtree.TristateCheckBox; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JTemplate; +import com.fr.general.ComparatorUtils; + +import com.fr.log.FineLoggerFactory; +import com.fr.stable.ProductConstants; + +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import java.awt.*; +import java.awt.event.*; +import java.util.ArrayList; + +/** + * Author : daisy + * Date: 13-8-9 + * Time: 下午3:41 + */ +public class SaveSomeTemplatePane extends BasicPane { + + private UICheckBox[] templateCheckBoxes = null; + private BasicDialog dialog; + private JPanel templatesChoosePane; + private UIScrollPane scrollPane; + private java.util.List> unSavedTemplate = new ArrayList>(); + private boolean isAllSaved = false; + + //该变量用来判断是在关闭其他模板或是关闭设计器的时候,是否需要判断当前模板有没有保存 + private boolean isJudgeCurrentEditingTemplate = true; + + public SaveSomeTemplatePane(boolean isNeedTojudgeCurrent) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + if (this.dialog == null) { + this.dialog = this.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + for (int i = 0; i < templateCheckBoxes.length; i++) { + if (templateCheckBoxes[i].isSelected()) { + saveSelectedTemplate(unSavedTemplate.get(i)); + } + } + isAllSaved = true; + } + + public void doCancel() { + isAllSaved = false; + } + + }); + } + UILabel tip = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_The_Source_To_Save")); + this.add(tip, BorderLayout.NORTH); + templatesChoosePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + UIScrollPane scrollPane = new UIScrollPane(templatesChoosePane); + this.add(scrollPane, BorderLayout.CENTER); + this.isJudgeCurrentEditingTemplate = isNeedTojudgeCurrent; + } + + private void initTemplatesChoosePane() { + templatesChoosePane.setBorder(BorderFactory.createTitledBorder("")); + for (int i = 0; i < unSavedTemplate.size(); i++) { + templateCheckBoxes[i] = new UICheckBox(unSavedTemplate.get(i).getEditingFILE().getName()); + templateCheckBoxes[i].setSelected(true); + } + + final UIList templatesList = new UIList(templateCheckBoxes); + templatesList.setModel(new UnSeletedTemplateListDataMode()); + templatesList.setCellRenderer(new UnSelectedListCellRender()); + + final TristateCheckBox chooseAllCheckBox = new NullTristateCheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_All")); + chooseAllCheckBox.setState(TristateCheckBox.SELECTED); + //取消chooseAllCheckBox的焦点事件监听,因为默认的焦点事件监听中失焦时会改变chooseAllCheckBox的状态 + chooseAllCheckBox.setFocusable(false); + chooseAllCheckBox.addStateChangeListener(new StateChangeListener() { + @Override + public void stateChange() { + if (chooseAllCheckBox.getState() == TristateCheckBox.DO_NOT_CARE) { + return; + } + boolean isSelected = chooseAllCheckBox.isSelected(); + for (int i = 0; i < templatesList.getModel().getSize(); i++) { + UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(i); + checkBox.setSelected(isSelected); + } + templatesList.repaint(); + } + }); + + templatesList.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + super.mousePressed(e); + int index = templatesList.getSelectedIndex(); + if (index < 0) { + return; + } + UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(index); + checkBox.setSelected(!checkBox.isSelected()); + + //根据templateCheckBoxes中的选择情况来更新全选框的状态 + int selectedCount = calculateSelectedNum(); + if (selectedCount == 0) { + chooseAllCheckBox.setState(TristateCheckBox.NOT_SELECTED); + } else if (selectedCount == templateCheckBoxes.length) { + chooseAllCheckBox.setState(TristateCheckBox.SELECTED); + } else { + chooseAllCheckBox.setState(TristateCheckBox.DO_NOT_CARE); + } + templatesList.repaint(); + } + }); + + templatesChoosePane.add(chooseAllCheckBox, BorderLayout.NORTH); + templatesChoosePane.add(templatesList, BorderLayout.CENTER); + + } + + /** + * 获取templateCheckBoxes中状态为选中状态的CheckBox数量 + * */ + private int calculateSelectedNum() { + int count = 0; + for (UICheckBox checkBox : templateCheckBoxes) { + if (checkBox.isSelected()) { + count++; + } + } + return count; + } + + + public boolean showSavePane() { + populate(); + //如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目 + if (!unSavedTemplate.isEmpty()) { + dialog.setVisible(true); + } else { + isAllSaved = true; + } + return isAllSaved; + } + + public void populate() { + java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); + JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + for (int i = 0; i < opendedTemplate.size(); i++) { + if (isneedToAdd(opendedTemplate.get(i), currentTemplate)) { + unSavedTemplate.add(opendedTemplate.get(i)); + } + } + templateCheckBoxes = new UICheckBox[unSavedTemplate.size()]; + initTemplatesChoosePane(); + } + + private boolean isneedToAdd(JTemplate template, JTemplate currentTemplate) { + //所有模板都判断是不是保存 + if (isJudgeCurrentEditingTemplate) { + return !template.isALLSaved(); + } + + //当前编辑的模板不判断是否已经保存 + if (ComparatorUtils.equals(template, currentTemplate)) { + return false; + } else { + return !template.isALLSaved(); + } + } + + + private void saveSelectedTemplate(JTemplate specifiedTemplate) { + if (!specifiedTemplate.isSaved()) { + specifiedTemplate.stopEditing(); + specifiedTemplate.saveTemplate(); + } + FineLoggerFactory.getLogger().info( com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); + } + + + public int saveLastOneTemplate() { + JTemplate specifiedTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + if (!specifiedTemplate.isALLSaved()) { + specifiedTemplate.stopEditing(); + int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); + if (returnVal == JOptionPane.YES_OPTION && specifiedTemplate.saveTemplate()) { + specifiedTemplate.saveTemplate(); + FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); + } + return returnVal; + } + return JOptionPane.YES_OPTION; + } + + + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save"); + } + + + private class UnSelectedListCellRender extends DefaultListCellRenderer { + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, final boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + templateCheckBoxes[index] = (UICheckBox) value; + templateCheckBoxes[index].setBackground(list.getBackground()); + return templateCheckBoxes[index]; + } + + } + + + private class UnSeletedTemplateListDataMode extends AbstractListModel { + + @Override + public int getSize() { + return templateCheckBoxes.length; + } + + @Override + public UICheckBox getElementAt(int index) { + if (index > getSize() - 1 || index < 0) { + return null; + } + return templateCheckBoxes[index]; + } + + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java index 93001bde44..5041cc34a3 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java @@ -226,6 +226,8 @@ public class TemplateTreePane extends JPanel implements FileOperations { */ @Override public void refresh() { + // 刷新远程文件夹权限 + NodeAuthProcessor.getInstance().refresh(); reportletsTree.refresh(); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_File_Tree_Refresh_Successfully") + "!"); } diff --git a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java index 96a82d228f..8b68dcdbe4 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java +++ b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java @@ -1008,15 +1008,23 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { this.searchKey = searchKey.toLowerCase(); } + /** + * 把以关键词开头的和不以关键词开头的分别按照字母表顺序排序 + * @param o1 待比较对象1 + * @param o2 待比较对象2 + * @return 比较结果,1表示 o1 > o2, -1表示 o1 < o2, 0表示 o1 = o2 + */ @Override public int compare(String o1, String o2) { - if (o1.toLowerCase().startsWith(searchKey)) { - return -1; - } - if (o2.toLowerCase().startsWith(searchKey)) { - return 1; + int result; + boolean o1StartWith = o1.toLowerCase().startsWith(searchKey); + boolean o2StartWith = o2.toLowerCase().startsWith(searchKey); + if (o1StartWith) { + result = o2StartWith ? o1.compareTo(o2) : -1; + } else { + result = o2StartWith ? 1 : o1.compareTo(o2); } - return o2.compareTo(o1); + return result; } } 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 227333cd08..82f7a81445 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 0000000000..0100f4b2cf --- /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 0000000000..ba1c71d5f3 --- /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/gui/controlpane/UIControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java index 747dbe32f0..04427b3378 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java @@ -9,12 +9,14 @@ import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.menu.ShortCut; +import com.fr.design.os.impl.PopupDialogSaveAction; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.invoke.Reflect; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; import com.fr.stable.os.OperatingSystem; +import com.fr.stable.os.support.OSSupportCenter; import javax.swing.BorderFactory; import javax.swing.JComponent; @@ -273,6 +275,8 @@ abstract class UIControlPane extends JControlPane { } saveSettings(); setVisible(false); + PopupDialogSaveAction saveAction = OSSupportCenter.getAction(PopupDialogSaveAction.class); + saveAction.unregister(); } private void initListener() { diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java index 0dec124219..100daf511b 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java @@ -7,9 +7,11 @@ import com.fr.design.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.UINameEdList; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.os.impl.PopupDialogSaveAction; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.ArrayUtils; import com.fr.stable.Nameable; +import com.fr.stable.os.support.OSSupportCenter; import javax.swing.DefaultListModel; import javax.swing.JList; @@ -216,6 +218,8 @@ public abstract class UIListControlPane extends UIControlPane implements ListCon ((PopupEditDialog)popupEditDialog).setTitle(getSelectedName()); } popupEditDialog.setVisible(true); + PopupDialogSaveAction osBasedAction = OSSupportCenter.getAction(PopupDialogSaveAction.class); + osBasedAction.register(this, popupEditDialog); } } diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/UIBubbleFloatPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/UIBubbleFloatPane.java index 0297353ee0..03927ca468 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/UIBubbleFloatPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/UIBubbleFloatPane.java @@ -9,14 +9,17 @@ import com.fr.stable.Constants; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.SwingUtilities; +import javax.swing.border.Border; import java.awt.AWTEvent; import java.awt.BasicStroke; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Component; import java.awt.Dialog; import java.awt.Frame; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.Insets; import java.awt.Point; import java.awt.Polygon; import java.awt.Rectangle; @@ -29,303 +32,312 @@ import java.awt.event.MouseEvent; /** * @author Jerry - * 非模态悬浮对话框,气泡形状 + * 非模态悬浮对话框,气泡形状 */ public abstract class UIBubbleFloatPane extends BasicBeanPane { - private static final long serialVersionUID = -6386018511442190959L; - private static int OFF_LEFT = 10; + private static final long serialVersionUID = -6386018511442190959L; + private static int OFF_LEFT = 10; private static final int ARROR_PARALLEL = 30; private static final int ARROR_VERTICAL = 20; private static final int TITLE_HEIGHT = 60; private static final double TIME_DEFAULT = 0.5; private static final double TIME_GAP = 0.1; - private BasicBeanPane contentPane; - private Rectangle bounds; - private int arrowPosition; - private double time = 0.5; - - private UIDialog showDialog; - - /** - * @param arrowPosition 箭头的位置,上下左右,暂时只处理了左边,后面用到了再说 TODO - * @param arrowPoint 箭头的坐标点 - * @param contentPane 对话框中的Panel - */ - public UIBubbleFloatPane(int arrowPosition, Point arrowPoint, BasicBeanPane contentPane) { - this(arrowPosition, arrowPoint, contentPane, contentPane.getPreferredSize().width, contentPane.getPreferredSize().height); - } - - /** - * 这个方法主要用于那些宽度和高度有变化的面板,因为显然外面的气泡要固定大小,不然忽大忽小,体验太差了 - * - * @param arrowPosition 箭头的位置,上下左右,暂时只处理了左边,后面用到了再说 TODO - * @param arrowPoint 箭头的坐标点 - * @param contentPane 对话框中的Panel - * @param width 对话框中的Panel的宽度,写死了 - * @param height 对话框中的Panel的高度,写死了 - */ - public UIBubbleFloatPane(int arrowPosition, Point arrowPoint, BasicBeanPane contentPane, int width, int height) { - this.contentPane = contentPane; - this.arrowPosition = arrowPosition; - this.time = initBoundsTime(arrowPosition, arrowPoint, width, height); - if (arrowPosition == Constants.LEFT) { - this.bounds = new Rectangle(arrowPoint.x - width, (int) (arrowPoint.y - height * time), width, height); - } else if (arrowPosition == Constants.TOP) { - this.bounds = new Rectangle((int) (arrowPoint.x - width * time), arrowPoint.y , width, height); - } else if (arrowPosition == Constants.RIGHT) { - this.bounds = new Rectangle(arrowPoint.x - OFF_LEFT * 2 - width, (int) (arrowPoint.y - height * time), width, height); - } - - initComponents(); - } + private BasicBeanPane contentPane; + private Rectangle bounds; + private int arrowPosition; + private double time = 0.5; + + private UIDialog showDialog; + + /** + * @param arrowPosition 箭头的位置,上下左右,暂时只处理了左边,后面用到了再说 TODO + * @param arrowPoint 箭头的坐标点 + * @param contentPane 对话框中的Panel + */ + public UIBubbleFloatPane(int arrowPosition, Point arrowPoint, BasicBeanPane contentPane) { + this(arrowPosition, arrowPoint, contentPane, contentPane.getPreferredSize().width, contentPane.getPreferredSize().height); + } + + /** + * 这个方法主要用于那些宽度和高度有变化的面板,因为显然外面的气泡要固定大小,不然忽大忽小,体验太差了 + * + * @param arrowPosition 箭头的位置,上下左右,暂时只处理了左边,后面用到了再说 TODO + * @param arrowPoint 箭头的坐标点 + * @param contentPane 对话框中的Panel + * @param width 对话框中的Panel的宽度,写死了 + * @param height 对话框中的Panel的高度,写死了 + */ + public UIBubbleFloatPane(int arrowPosition, Point arrowPoint, BasicBeanPane contentPane, int width, int height) { + this.contentPane = contentPane; + this.arrowPosition = arrowPosition; + this.time = initBoundsTime(arrowPosition, arrowPoint, width, height); + if (arrowPosition == Constants.LEFT) { + this.bounds = new Rectangle(arrowPoint.x - width, (int) (arrowPoint.y - height * time), width, height); + } else if (arrowPosition == Constants.TOP) { + this.bounds = new Rectangle((int) (arrowPoint.x - width * time), arrowPoint.y, width, height); + } else if (arrowPosition == Constants.RIGHT) { + this.bounds = new Rectangle(arrowPoint.x - OFF_LEFT * 2 - width, (int) (arrowPoint.y - height * time), width, height); + } + + initComponents(); + } /** * show对话框 + * * @param fatherPane 上一层界面 parentPane - * @param ob 传入的内容,在show之前populate + * @param ob 传入的内容,在show之前populate */ - public void show(JComponent fatherPane, T ob) { - populateBean(ob); - UIDialog dialog = showUnsizedWindow(SwingUtilities.getWindowAncestor(fatherPane)); - showDialog = dialog; - Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); - dialog.setVisible(true); - } - - /** - * 数据展现 - */ - public void populateBean(T ob) { - contentPane.populateBean(ob); - } - - /** - * 停止编辑, 更新至最新的面板到属性保存 - */ - public T updateBean() { - updateContentPane(); - return contentPane.updateBean(); - } - - /** - * 需要实现更新内容,将updateBean传值给对象即可,在窗口消失的时候会被调用 - */ - protected abstract void updateContentPane(); - - /** - * 以对话框的形式弹出 - * - * @param window 窗口 - * @return 对话框 - */ - public UIDialog showUnsizedWindow(Window window) { - CustomShapedDialog dg = null; - if (window instanceof Frame) { - dg = new CustomShapedDialog((Frame) window); - } else { - dg = new CustomShapedDialog((Dialog) window); - } - if (arrowPosition == Constants.LEFT || arrowPosition == Constants.RIGHT) { - dg.setSize(bounds.width + ARROR_PARALLEL, bounds.height + ARROR_VERTICAL); - } else { - dg.setSize(bounds.width + ARROR_VERTICAL, bounds.height + ARROR_PARALLEL); - } - - dg.setLocation(bounds.x, bounds.y); - dg.setBackground(Color.blue); - dg.setResizable(false); - return dg; - } - - @Override - protected String title4PopupWindow() { - return null; - } - - private double initBoundsTime(int arrowPosition, Point arrowPoint, int width, int height) { - int x = arrowPoint.x; - int y = arrowPoint.y; - int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width; - int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height - TITLE_HEIGHT; - double time = TIME_DEFAULT; - - if (arrowPosition == Constants.LEFT || arrowPosition == Constants.RIGHT) { - while (y + time * height > screenHeight && time > 0) { - time -= TIME_GAP; - } - - while (y - (1 - time) * height < 0 && time < 1) { - time += TIME_GAP; - } - } else if (arrowPosition == Constants.TOP) { - while (x + time * width > screenWidth && time > 0) { - time -= TIME_GAP; - } - - while (x - (1 - time) * width < 0 && time < 1) { - time += TIME_GAP; - } - } - return 1 - time; - } - - private AWTEventListener awt = new AWTEventListener() { - public void eventDispatched(AWTEvent event) { - doSomeInAll(event); - } - }; - - private void doSomeInAll(AWTEvent event) { - if (event instanceof MouseEvent) { - MouseEvent mv = (MouseEvent) event; - if (mv.getClickCount() > 0) { - Point point = new Point((int) (mv.getLocationOnScreen().getX()) - 2 * OFF_LEFT, (int) mv.getLocationOnScreen().getY()); - // 判断鼠标点击是否在边界内 - if (!containsPoint(point) && showDialog != null) { - updateContentPane(); - showDialog.setVisible(false); - Toolkit.getDefaultToolkit().removeAWTEventListener(awt); - } - } - } - } + public void show(JComponent fatherPane, T ob) { + populateBean(ob); + if (showDialog == null) { + showDialog = showUnsizedWindow(SwingUtilities.getWindowAncestor(fatherPane)); + } + Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); + showDialog.setVisible(true); + } + + /** + * 数据展现 + */ + public void populateBean(T ob) { + contentPane.populateBean(ob); + } + + /** + * 停止编辑, 更新至最新的面板到属性保存 + */ + public T updateBean() { + updateContentPane(); + return contentPane.updateBean(); + } + + /** + * 需要实现更新内容,将updateBean传值给对象即可,在窗口消失的时候会被调用 + */ + protected abstract void updateContentPane(); + + /** + * 以对话框的形式弹出 + * + * @param window 窗口 + * @return 对话框 + */ + public UIDialog showUnsizedWindow(Window window) { + CustomShapedDialog dg = null; + if (window instanceof Frame) { + dg = new CustomShapedDialog((Frame) window); + } else { + dg = new CustomShapedDialog((Dialog) window); + } + if (arrowPosition == Constants.LEFT || arrowPosition == Constants.RIGHT) { + dg.setSize(bounds.width + ARROR_PARALLEL, bounds.height + ARROR_VERTICAL); + } else { + dg.setSize(bounds.width + ARROR_VERTICAL, bounds.height + ARROR_PARALLEL); + } + + dg.setLocation(bounds.x, bounds.y); + dg.setBackground(Color.blue); + dg.setResizable(false); + return dg; + } + + @Override + protected String title4PopupWindow() { + return null; + } + + private double initBoundsTime(int arrowPosition, Point arrowPoint, int width, int height) { + int x = arrowPoint.x; + int y = arrowPoint.y; + int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width; + int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height - TITLE_HEIGHT; + double time = TIME_DEFAULT; + + if (arrowPosition == Constants.LEFT || arrowPosition == Constants.RIGHT) { + while (y + time * height > screenHeight && time > 0) { + time -= TIME_GAP; + } + + while (y - (1 - time) * height < 0 && time < 1) { + time += TIME_GAP; + } + } else if (arrowPosition == Constants.TOP) { + while (x + time * width > screenWidth && time > 0) { + time -= TIME_GAP; + } + + while (x - (1 - time) * width < 0 && time < 1) { + time += TIME_GAP; + } + } + return 1 - time; + } + + private AWTEventListener awt = new AWTEventListener() { + public void eventDispatched(AWTEvent event) { + doSomeInAll(event); + } + }; + + private void doSomeInAll(AWTEvent event) { + if (event instanceof MouseEvent) { + MouseEvent mv = (MouseEvent) event; + if (mv.getClickCount() > 0) { + Point point = new Point((int) (mv.getLocationOnScreen().getX()) - 2 * OFF_LEFT, (int) mv.getLocationOnScreen().getY()); + // 判断鼠标点击是否在边界内 + if (!containsPoint(point) && showDialog != null) { + updateContentPane(); + showDialog.setVisible(false); + Toolkit.getDefaultToolkit().removeAWTEventListener(awt); + } + } + } + } private boolean containsPoint(Point point) { - if(arrowPosition == Constants.TOP){ + if (arrowPosition == Constants.TOP) { //箭头和按钮也算在pane内 Rectangle judgedBounds = new Rectangle(bounds.x, bounds.y - OFF_LEFT * 2, bounds.width, bounds.height + OFF_LEFT * 2 + OFF_LEFT); - return judgedBounds.contains(point); + return judgedBounds.contains(point); } return bounds.contains(point); } - private void initComponents() { - if(arrowPosition == Constants.LEFT || arrowPosition == Constants.RIGHT) { - this.setBounds(20, 10, bounds.width, bounds.height); - } else { - this.setBounds(10, 10, bounds.width, bounds.height); - } - - this.setLayout(new BorderLayout()); - this.add(contentPane, BorderLayout.CENTER); - } + private void initComponents() { + if (arrowPosition == Constants.LEFT || arrowPosition == Constants.RIGHT) { + this.setBounds(20, 10, bounds.width, bounds.height); + } else { + this.setBounds(10, 10, bounds.width, bounds.height); + } + + this.setLayout(new BorderLayout()); + this.add(contentPane, BorderLayout.CENTER); + } - private class CustomShapedDialog extends UIDialog { + private class CustomShapedDialog extends UIDialog { private static final int GAP_SMALL = 10; private static final int GAP = 20; private static final int GAP_BIG = 30; - public CustomShapedDialog(Frame parent) { - super(parent); - this.initComponents(); - } - - public CustomShapedDialog(Dialog parent) { - super(parent); - this.initComponents(); - } - - - private Shape getCustomShap() { - Polygon polygon = new Polygon(); - if (arrowPosition == Constants.LEFT) { - polygon.addPoint(GAP_SMALL, 0); - polygon.addPoint(bounds.width + GAP_BIG, 0); - polygon.addPoint(bounds.width + GAP_BIG, bounds.height + GAP); - polygon.addPoint(GAP_SMALL, bounds.height + GAP); - polygon.addPoint(GAP_SMALL, (int) ((bounds.height + GAP) * time) - GAP_SMALL); - polygon.addPoint(0, (int) ((bounds.height + GAP) * time - GAP)); - polygon.addPoint(GAP_SMALL, (int) ((bounds.height + GAP) * time - GAP_BIG)); - polygon.addPoint(GAP_SMALL, 0); - } else if (arrowPosition == Constants.TOP) { - polygon.addPoint(0, GAP_SMALL); - polygon.addPoint((int) (bounds.width * time + GAP_SMALL), GAP_SMALL); - polygon.addPoint((int) (bounds.width * time + GAP), 0); - polygon.addPoint((int) (bounds.getWidth() * time + GAP_BIG), GAP_SMALL); - polygon.addPoint(bounds.width + GAP, GAP_SMALL); - polygon.addPoint(bounds.width + GAP, bounds.height + GAP_BIG); - polygon.addPoint(0, bounds.height + GAP_BIG); - polygon.addPoint(0, GAP_SMALL); - } else if (arrowPosition == Constants.RIGHT) { - polygon.addPoint(0, 0); - polygon.addPoint(bounds.width + GAP, 0); - polygon.addPoint(bounds.width + GAP, (int) ((bounds.height + GAP) * time) - GAP_BIG); - polygon.addPoint(bounds.width + GAP_BIG, (int) ((bounds.height + GAP) * time) - GAP); - polygon.addPoint(bounds.width + GAP, (int) ((bounds.height + GAP) * time) - GAP_SMALL); - polygon.addPoint(bounds.width + GAP, bounds.height + GAP); - polygon.addPoint(0, bounds.height + GAP); - polygon.addPoint(0, 0); - } - - return polygon; - } - - private Shape getShape4Board() { - Polygon polygon = new Polygon(); - if (arrowPosition == Constants.LEFT) { - polygon.addPoint(GAP_SMALL, 1); - polygon.addPoint(bounds.width + GAP_BIG - 1, 1); - polygon.addPoint(bounds.width + GAP_BIG - 1, bounds.height + GAP - 1); - polygon.addPoint(GAP_SMALL + 1, bounds.height + GAP - 1); - polygon.addPoint(GAP_SMALL + 1, (int) ((bounds.height + GAP) * time) - GAP_SMALL); - polygon.addPoint(1, (int) ((bounds.height + GAP) * time - GAP)); - polygon.addPoint(GAP_SMALL + 1, (int) ((bounds.height + GAP) * time - GAP_BIG)); - polygon.addPoint(GAP_SMALL + 1, 1); - } else if (arrowPosition == Constants.TOP) { - polygon.addPoint(1, GAP_SMALL + 1); - polygon.addPoint((int) (bounds.width * time + GAP_SMALL), GAP_SMALL + 1); - polygon.addPoint((int) (bounds.width * time + GAP), 1); - polygon.addPoint((int) (bounds.getWidth() * time + GAP_BIG), GAP_SMALL + 1); - polygon.addPoint(bounds.width + GAP - 1, GAP_SMALL + 1); - polygon.addPoint(bounds.width + GAP - 1, bounds.height + GAP_BIG - 1); - polygon.addPoint(1, bounds.height + GAP_BIG - 1); - polygon.addPoint(1, GAP_SMALL + 1); - } else if(arrowPosition == Constants.RIGHT) { - polygon.addPoint(1, 1); - polygon.addPoint(bounds.width + GAP - 1, 1); - polygon.addPoint(bounds.width + GAP - 1, (int) ((bounds.height + GAP) * time) - GAP_BIG); - polygon.addPoint(bounds.width + GAP_BIG - 1, (int) ((bounds.height + GAP) * time) - GAP); - polygon.addPoint(bounds.width + GAP - 1, (int) ((bounds.height + GAP) * time) - GAP_SMALL); - polygon.addPoint(bounds.width + GAP - 1, bounds.height + GAP - 1); - polygon.addPoint(1, bounds.height + GAP - 1); - polygon.addPoint(1, 0); - } - return polygon; - } - - /** - * 画出界面的样式, 边框等. - */ - public void paint(Graphics g) { - super.paint(g); - Graphics2D g2d = (Graphics2D) g; - Stroke oldStroke = g2d.getStroke(); - g2d.setStroke(new BasicStroke(2, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND)); - g2d.setColor(new Color(51, 51, 51)); - g2d.drawPolygon((Polygon) getShape4Board()); - g2d.setStroke(oldStroke); - } - - protected void initComponents() { - setUndecorated(true); - try { - AWTUtilities.setWindowShape(CustomShapedDialog.this, this.getCustomShap()); - } catch (UnsupportedOperationException e) { + public CustomShapedDialog(Frame parent) { + super(parent); + this.initComponents(); + } + + public CustomShapedDialog(Dialog parent) { + super(parent); + this.initComponents(); + } + + + private Shape getCustomShap() { + Polygon polygon = new Polygon(); + if (arrowPosition == Constants.LEFT) { + polygon.addPoint(GAP_SMALL, 0); + polygon.addPoint(bounds.width + GAP_BIG, 0); + polygon.addPoint(bounds.width + GAP_BIG, bounds.height + GAP); + polygon.addPoint(GAP_SMALL, bounds.height + GAP); + polygon.addPoint(GAP_SMALL, (int) ((bounds.height + GAP) * time) - GAP_SMALL); + polygon.addPoint(0, (int) ((bounds.height + GAP) * time - GAP)); + polygon.addPoint(GAP_SMALL, (int) ((bounds.height + GAP) * time - GAP_BIG)); + polygon.addPoint(GAP_SMALL, 0); + } else if (arrowPosition == Constants.TOP) { + polygon.addPoint(0, GAP_SMALL - 2); + polygon.addPoint((int) (bounds.width * time + GAP_SMALL), GAP_SMALL - 2); + polygon.addPoint((int) (bounds.width * time + GAP), 0); + polygon.addPoint((int) (bounds.getWidth() * time + GAP_BIG), GAP_SMALL - 2); + polygon.addPoint(bounds.width + GAP, GAP_SMALL - 2); + polygon.addPoint(bounds.width + GAP, bounds.height + GAP_BIG); + polygon.addPoint(0, bounds.height + GAP_BIG); + polygon.addPoint(0, GAP_SMALL - 2); + } else if (arrowPosition == Constants.RIGHT) { + polygon.addPoint(0, 0); + polygon.addPoint(bounds.width + GAP, 0); + polygon.addPoint(bounds.width + GAP, (int) ((bounds.height + GAP) * time) - GAP_BIG); + polygon.addPoint(bounds.width + GAP_BIG, (int) ((bounds.height + GAP) * time) - GAP); + polygon.addPoint(bounds.width + GAP, (int) ((bounds.height + GAP) * time) - GAP_SMALL); + polygon.addPoint(bounds.width + GAP, bounds.height + GAP); + polygon.addPoint(0, bounds.height + GAP); + polygon.addPoint(0, 0); + } + + return polygon; + } + + private Shape getShape4Board() { + Polygon polygon = new Polygon(); + if (arrowPosition == Constants.LEFT) { + polygon.addPoint(GAP_SMALL, 1); + polygon.addPoint(bounds.width + GAP_BIG - 1, 1); + polygon.addPoint(bounds.width + GAP_BIG - 1, bounds.height + GAP - 1); + polygon.addPoint(GAP_SMALL + 1, bounds.height + GAP - 1); + polygon.addPoint(GAP_SMALL + 1, (int) ((bounds.height + GAP) * time) - GAP_SMALL); + polygon.addPoint(1, (int) ((bounds.height + GAP) * time - GAP)); + polygon.addPoint(GAP_SMALL + 1, (int) ((bounds.height + GAP) * time - GAP_BIG)); + polygon.addPoint(GAP_SMALL + 1, 1); + } else if (arrowPosition == Constants.TOP) { + polygon.addPoint(1, GAP_SMALL - 1); + polygon.addPoint((int) (bounds.width * time + GAP_SMALL), GAP_SMALL - 1); + polygon.addPoint((int) (bounds.width * time + GAP), 1); + polygon.addPoint((int) (bounds.getWidth() * time + GAP_BIG), GAP_SMALL - 1); + polygon.addPoint(bounds.width + GAP - 1, GAP_SMALL - 1); + polygon.addPoint(bounds.width + GAP - 1, bounds.height + GAP_BIG - 1); + polygon.addPoint(1, bounds.height + GAP_BIG - 1); + polygon.addPoint(1, GAP_SMALL - 1); + } else if (arrowPosition == Constants.RIGHT) { + polygon.addPoint(1, 1); + polygon.addPoint(bounds.width + GAP - 1, 1); + polygon.addPoint(bounds.width + GAP - 1, (int) ((bounds.height + GAP) * time) - GAP_BIG); + polygon.addPoint(bounds.width + GAP_BIG - 1, (int) ((bounds.height + GAP) * time) - GAP); + polygon.addPoint(bounds.width + GAP - 1, (int) ((bounds.height + GAP) * time) - GAP_SMALL); + polygon.addPoint(bounds.width + GAP - 1, bounds.height + GAP - 1); + polygon.addPoint(1, bounds.height + GAP - 1); + polygon.addPoint(1, 0); + } + return polygon; + } + + protected void initComponents() { + setUndecorated(true); + try { + AWTUtilities.setWindowShape(CustomShapedDialog.this, this.getCustomShap()); + } catch (UnsupportedOperationException e) { FineLoggerFactory.getLogger().info("Not support"); - } - final JPanel contentPane = (JPanel) this.getContentPane(); - this.setLayout(null); - contentPane.add(UIBubbleFloatPane.this); - setVisible(true); - } - - /** - * 检查 - */ - public void checkValid() throws Exception { - - } - } + } + final JPanel contentPane = (JPanel) this.getContentPane(); + this.setLayout(null); + contentPane.add(UIBubbleFloatPane.this); + contentPane.setBorder(new Border() { + @Override + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + Graphics2D g2d = (Graphics2D) g; + Stroke oldStroke = g2d.getStroke(); + g2d.setStroke(new BasicStroke(2, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND)); + g2d.setColor(new Color(51, 51, 51)); + g2d.drawPolygon((Polygon) getShape4Board()); + g2d.setStroke(oldStroke); + } + + @Override + public Insets getBorderInsets(Component c) { + return null; + } + + @Override + public boolean isBorderOpaque() { + return false; + } + }); + } + + /** + * 检查 + */ + public void checkValid() throws Exception { + + } + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java b/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java index 0aad7ee918..5e595643c0 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java +++ b/designer-base/src/main/java/com/fr/design/gui/ipasswordfield/UIPassWordField.java @@ -1,11 +1,12 @@ package com.fr.design.gui.ipasswordfield; +import com.fr.common.inputevent.InputEventBaseOnOS; import com.fr.design.constants.UIConstants; -import javax.swing.*; +import javax.swing.JPasswordField; import javax.swing.text.Document; -import java.awt.*; +import java.awt.Graphics; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -21,26 +22,34 @@ public class UIPassWordField extends JPasswordField { public UIPassWordField() { super(); - addRollOverListener(); + init(); } public UIPassWordField(String text) { super(text); - addRollOverListener(); + init(); } public UIPassWordField(int columns) { super(columns); - addRollOverListener(); + init(); } public UIPassWordField(String text, int columns) { super(text, columns); - addRollOverListener(); + init(); } public UIPassWordField(Document doc, String txt, int columns) { super(doc, txt, columns); + init(); + } + + /** + * 每个构造方法里都需要做的一些操作 + */ + public void init() { + InputEventBaseOnOS.addBasicEditInputMap(this); addRollOverListener(); } @@ -69,4 +78,4 @@ public class UIPassWordField extends JPasswordField { super.paintBorder(g); } } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java index e416083f73..29214984c3 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java +++ b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java @@ -96,4 +96,11 @@ public class ProgressDialog extends UIDialog { public void updateLoadingText(String text) { this.text.setText(text); } + + public void updateLoadingText(String text, FRFont font) { + if (font != null) { + this.text.setFont(font); + } + this.text.setText(text); + } } diff --git a/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java b/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java index 7d04113078..4506bb9a6c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java +++ b/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java @@ -23,7 +23,7 @@ import java.util.List; * @editor zhou * @since 2012-3-28下午3:07:44 */ -public abstract class UITableModelAdapter extends AbstractTableModel implements UITableEditorLoader { +public abstract class UITableModelAdapter extends AbstractTableModel implements UITableEditorLoader { /** * @@ -37,7 +37,6 @@ public abstract class UITableModelAdapter extends AbstractTabl // list里放的是一行数据 private List list = new ArrayList(); - @SuppressWarnings({ "unchecked", "rawtypes" }) protected UITableModelAdapter(String[] columnNames) { this.columnNames = columnNames; table = new JTable(this); @@ -101,8 +100,8 @@ public abstract class UITableModelAdapter extends AbstractTabl } } - public void setRowAt(T value, int rowIndwx) { - this.list.set(rowIndwx, value); + public void setRowAt(T value, int rowIndex) { + this.list.set(rowIndex, value); } /** diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java index 98823bee9b..10edf9fe00 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java @@ -9,11 +9,20 @@ import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.Constants; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.Document; -import java.awt.*; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Insets; +import java.awt.LayoutManager; +import java.awt.RenderingHints; + /** * @author Jerry @@ -33,31 +42,33 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs public UITextField() { super(); - InputEventBaseOnOS.addBasicEditInputMap(this); - initListener(); + init(); } public UITextField(int columns) { super(columns); - InputEventBaseOnOS.addBasicEditInputMap(this); - initListener(); + init(); } public UITextField(String text, int columns) { super(text, columns); - InputEventBaseOnOS.addBasicEditInputMap(this); - initListener(); + init(); } public UITextField(String text) { super(text); - InputEventBaseOnOS.addBasicEditInputMap(this); - - initListener(); + init(); } public UITextField(Document doc, String text, int columns) { super(doc, text, columns); + init(); + } + + /** + * 每个构造方法里都需要做的一些操作 + */ + public void init() { InputEventBaseOnOS.addBasicEditInputMap(this); initListener(); } @@ -251,4 +262,4 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs this.isBorderPainted = isBorderPainted; } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/checkboxtree/TristateCheckBox.java b/designer-base/src/main/java/com/fr/design/gui/itree/checkboxtree/TristateCheckBox.java index a4a59ade24..b821b0731a 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/checkboxtree/TristateCheckBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/checkboxtree/TristateCheckBox.java @@ -1,6 +1,7 @@ package com.fr.design.gui.itree.checkboxtree; import com.fr.design.constants.UIConstants; +import com.fr.design.event.StateChangeListener; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.stable.Constants; @@ -75,6 +76,8 @@ public class TristateCheckBox extends UICheckBox { private final TristateDecorator model; + public StateChangeListener stateChangeListener; + public TristateCheckBox(String text, Icon icon, State initial) { super(text, icon); setUI(new TristateCheckBoxUI()); @@ -83,7 +86,7 @@ public class TristateCheckBox extends UICheckBox { @Override public void mousePressed(MouseEvent e) { grabFocus(); - model.setState(getNextState(model.getState())); + setState(getNextState(model.getState())); } }); // Reset the keyboard action map @@ -92,7 +95,7 @@ public class TristateCheckBox extends UICheckBox { @Override public void actionPerformed(ActionEvent e) { grabFocus(); - model.setState(getNextState(model.getState())); + setState(getNextState(model.getState())); } }); map.put("released", null); @@ -125,12 +128,20 @@ public class TristateCheckBox extends UICheckBox { public void addMouseListener(MouseListener l) { } + public void addStateChangeListener(StateChangeListener stateChangeListener) { + this.stateChangeListener=stateChangeListener; + } + /** * Set the new state to either SELECTED, NOT_SELECTED or * DO_NOT_CARE. If state == null, it is treated as DO_NOT_CARE. */ public void setState(State state) { + State old = getState(); model.setState(state); + if (old != state) { + fireBoxStateChanged(); + } } /** @@ -141,6 +152,11 @@ public class TristateCheckBox extends UICheckBox { return model.getState(); } + public void fireBoxStateChanged() { + if (stateChangeListener != null) { + stateChangeListener.stateChange(); + } + } /** * Exactly which Design Pattern is this? Is it an Adapter, diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaBase.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaBase.java index 01c9238c66..985a9527fa 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaBase.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaBase.java @@ -25,6 +25,7 @@ import javax.swing.JTextArea; import javax.swing.event.CaretEvent; import javax.swing.plaf.ColorUIResource; import javax.swing.plaf.TextUI; +import javax.swing.plaf.basic.BasicBorders; import javax.swing.text.AbstractDocument; import javax.swing.text.BadLocationException; import javax.swing.text.Caret; @@ -645,6 +646,7 @@ int currentCaretY; // Used to know when to rehighlight current line. setTabsEmulated(false); // Stuff needed by the caret listener below. + setBorder(new BasicBorders.MarginBorder()); previousCaretY = currentCaretY = getInsets().top; // Stuff to highlight the current line. diff --git a/designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperNorthPane.java b/designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperNorthPane.java index 43710cd0f2..8355d4f97f 100644 --- a/designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperNorthPane.java +++ b/designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperNorthPane.java @@ -395,7 +395,7 @@ public class ReportletHyperNorthPane extends AbstractHyperNorthPane 0) { dim.height += vgap; @@ -370,6 +373,7 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { * @see java.awt.Container * @see java.awt.Container#doLayout */ + @Override public void layoutContainer(Container target) { synchronized (target.getTreeLock()) { Insets insets = target.getInsets(); @@ -410,7 +414,9 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { protected int[] dealWithDim4LayoutContainer(Container target, Insets insets, Dimension d, int x, int y, int roww, int start, int maxlen, int i, boolean ltr) { if ((y == 0) || ((y + d.height) <= maxlen)) { - if (y > 0) y += vgap; + if (y > 0) { + y += vgap; + } y += d.height; roww = Math.max(roww, d.width); } else { @@ -449,6 +455,7 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { * * @return a string representation of this layout */ + @Override public String toString() { String str = ""; switch (this.newAlign) { @@ -465,4 +472,4 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { return getClass().getName() + "[hgap=" + hgap + ",vgap=" + vgap + str + "]"; } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/BugNeedMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/BugNeedMark.java new file mode 100644 index 0000000000..41822d19cb --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/locale/impl/BugNeedMark.java @@ -0,0 +1,29 @@ +package com.fr.design.locale.impl; + +import com.fr.general.CloudCenter; +import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleMark; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * @Author: Yuan.Wang + * @Date: 2020/7/29 + */ +public class BugNeedMark implements LocaleMark { + private Map map = new HashMap<>(); + private static final String TW_BUG_AND_NEEDS = CloudCenter.getInstance().acquireUrlByKind("bbs.bug.needs.zh_TW"); + + public BugNeedMark() { + map.put(Locale.TAIWAN, TW_BUG_AND_NEEDS); + } + + @Override + public String getValue() { + String result = map.get(GeneralContext.getLocale()); + return result == null ? TW_BUG_AND_NEEDS : result; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java b/designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java index 61de25937c..904a6c18b1 100644 --- a/designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java +++ b/designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java @@ -10,6 +10,7 @@ import java.util.Set; * 某些国际化环境支持的操作 * 需要增加/删除支持的语言 统一在这里修改 无须改动业务代码 * 后续有新的不同语言下的差异操作 添加新的枚举 + * * @author Hades * @date 2019/6/24 */ @@ -38,6 +39,123 @@ public enum SupportLocaleImpl implements SupportLocale { set.add(Locale.TAIWAN); return set; } + }, + + /** + * 支持韩文 + */ + SUPPORT_KOREA { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.KOREA); + return set; + } + }, + + /** + * BUG反馈 + */ + BUG { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.CHINA); + set.add(Locale.US); + set.add(Locale.JAPAN); + set.add(Locale.KOREA); + return set; + } + }, + + /** + * 需求反馈 + */ + NEED { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.CHINA); + set.add(Locale.US); + set.add(Locale.JAPAN); + set.add(Locale.KOREA); + return set; + } + }, + + /** + * BUG需求反馈 + */ + BUG_AND_NEED { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.TAIWAN); + return set; + } + }, + + /** + * 视频 + */ + VIDEO { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.US); + return set; + } + }, + + /** + * 技术支持-帮助菜单下 + */ + TECH_SUPPORT_HELP { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.US); + return set; + } + }, + + /** + * 技术支持-社区菜单下 + */ + TECH_SUPPORT_COMMUNITY { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.TAIWAN); + return set; + } + }, + + /** + * 帮助文档-帮助菜单下 + */ + TUTORIAL_HELP { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.US); + set.add(Locale.KOREA); + set.add(Locale.JAPAN); + return set; + } + }, + + /** + * 帮助文档-社区菜单下 + */ + TUTORIAL_COMMUNITY { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.CHINA); + set.add(Locale.TAIWAN); + return set; + } } diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/TechSupportMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/TechSupportMark.java new file mode 100644 index 0000000000..6d15764b5f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/locale/impl/TechSupportMark.java @@ -0,0 +1,30 @@ +package com.fr.design.locale.impl; + +import com.fr.general.CloudCenter; +import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleMark; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * @Author: Yuan.Wang + * @Date: 2020/7/29 + */ +public class TechSupportMark implements LocaleMark { + private Map map = new HashMap<>(); + private static final String EN_TECH_SUPPORT = CloudCenter.getInstance().acquireUrlByKind("bbs.tech.support.en_US"); + private static final String TW_TECH_SUPPORT = CloudCenter.getInstance().acquireUrlByKind("bbs.tech.support.zh_TW"); + + public TechSupportMark() { + map.put(Locale.US, EN_TECH_SUPPORT); + map.put(Locale.TAIWAN, TW_TECH_SUPPORT); + } + + @Override + public String getValue() { + String result = map.get(GeneralContext.getLocale()); + return result == null ? EN_TECH_SUPPORT : result; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index a31b77650e..42365dcc57 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -328,6 +328,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta if (DesignModeContext.isAuthorityEditing()) { doResize(); } + //刷新FixedPopupPane的位置 + EastRegionContainerPane.getInstance().freshCurrentPopupPane(); } }); this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); @@ -972,6 +974,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta * @param jt 添加的模板. */ public void addAndActivateJTemplate(JTemplate jt) { + //切换文件后清空FixedPopupPane面板 + EastRegionContainerPane.getInstance().clearCurrentPopupPane(); //释放模板对象 ActionFactory.editorRelease(); if (jt == null || jt.getEditingFILE() == null) { @@ -991,6 +995,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta * @param jt 模板 */ public void activateJTemplate(JTemplate jt) { + //切换文件后清空FixedPopupPane面板 + EastRegionContainerPane.getInstance().clearCurrentPopupPane(); //释放模板对象 ActionFactory.editorRelease(); if (jt == null || jt.getEditingFILE() == null) { @@ -1101,7 +1107,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta * @date 2014-10-14-下午6:31:05 */ private void openFile(FILE tplFile) { - + //切换文件后清空FixedPopupPane面板 + EastRegionContainerPane.getInstance().clearCurrentPopupPane(); if (tplFile != null) { int index = HistoryTemplateListCache.getInstance().contains(tplFile); if (index != -1) { 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 b2ea7be11f..a273828d84 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 @@ -67,6 +67,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { private JPanel leftPane; private JPanel rightPane; private FixedPopupPane currentPopupPane; + private UIButton currentButton; private static final int CONTAINER_WIDTH = containerWidth(); private static final int TAB_WIDTH = 38; private static final int TAB_BUTTON_WIDTH = 32; @@ -227,8 +228,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); @@ -493,17 +496,17 @@ public class EastRegionContainerPane extends UIEastResizableContainer { public void replaceAuthorityEditionPane(JComponent pane) { propertyItemMap.get(KEY_AUTHORITY_EDITION).replaceContentPane(pane); } - + public JComponent getAuthorityEditionPane() { return propertyItemMap.get(KEY_AUTHORITY_EDITION).getContentPane(); } - + public void replaceConfiguredRolesPane(JComponent pane) { propertyItemMap.get(KEY_CONFIGURED_ROLES).replaceContentPane(pane); } - + public void replaceKeyPane(final String key, final JComponent pane) { - + //需要放到 ui 线程中处理 UIUtil.invokeLaterIfNeeded(new Runnable() { @Override @@ -512,11 +515,11 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } }); } - + public JComponent getConfiguredRolesPane() { return propertyItemMap.get(KEY_CONFIGURED_ROLES).getContentPane(); } - + public void addParameterPane(JComponent paraPane) { propertyItemMap.get(KEY_WIDGET_SETTINGS).replaceHeaderPane(paraPane); } @@ -927,6 +930,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } else { hideCurrentPopupPane(); currentPopupPane = popupPane; + currentButton = button; GUICoreUtils.showPopupMenu(popupPane, button, -popupPane.getPreferredSize().width, 0); } } @@ -1007,6 +1011,35 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } } + /** + * @Description:刷新currentPopupPane面板位置,当设计器缩放时会调用这个函数 + * @param + * @return: + * @Author: Henry.Wang + * @date: 2020/7/30 11:39 + */ + public void freshCurrentPopupPane() { + if (currentPopupPane != null && currentPopupPane.isVisible()) { + hideCurrentPopupPane(); + if (currentButton != null && !isRightPaneVisible()) { + GUICoreUtils.showPopupMenu(currentPopupPane, currentButton, -currentPopupPane.getPreferredSize().width, 0); + } + } + } + + /** + * @Description:清空currentPopupPane数据,当切换模板时会调用这个函数 + * @param + * @return: + * @Author: Henry.Wang + * @date: 2020/7/30 11:42 + */ + public void clearCurrentPopupPane() { + hideCurrentPopupPane(); + currentPopupPane = null; + currentButton = null; + } + // 弹出属性面板的工具条 private class PopupToolPane extends JPanel { private String title; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java b/designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java index 1552d1b658..adea8d7e4d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java @@ -1,45 +1,34 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; -import com.fr.design.constants.LayoutConstants; import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ibutton.UIRadioButton; -import com.fr.design.gui.ibutton.UISliderButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.islider.UISlider; -import com.fr.design.gui.ispinner.UIBasicSpinner; -import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.utils.gui.GUICoreUtils; - import javax.swing.BorderFactory; -import javax.swing.ButtonGroup; -import javax.swing.JFormattedTextField; import javax.swing.JFrame; import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JRadioButton; -import javax.swing.JSeparator; -import javax.swing.JSpinner; -import javax.swing.SpinnerNumberModel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import javax.swing.text.DefaultFormatterFactory; -import javax.swing.text.NumberFormatter; +import javax.swing.plaf.basic.BasicSliderUI; import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Component; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.FlowLayout; -import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; import java.awt.Point; +import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; import java.awt.event.MouseEvent; import java.math.BigDecimal; @@ -47,76 +36,44 @@ import java.math.BigDecimal; * Created by MoMeak on 2017/7/13. */ public class JFormSliderPane extends JPanel { + public static final Image APPFIT_V0 = BaseUtils.readImage("com/fr/design/images/control/icon_thumb_normal.png"); private static final double ONEPOINTEIGHT = 1.8; private static final int SIX = 6; private static final int TEN = 10; - private static final int ONE_EIGHT = 18; - private static final int FONT_SIZE = 12; - private static final int SPINNER_WIDTH = 45; - private static final int SPINNER_HEIGHT = 20; private static final int HALF_HUNDRED = 50; private static final int HUNDRED = 100; private static final int TWO_HUNDRED = 200; - private static final int THREE_HUNDRED = 300; private static final int FOUR_HUNDRED = 400; - private static final int DIALOG_WIDTH = 157; - private static final int DIALOG_HEIGHT = 172; - private static final int SLIDER_WIDTH = 220; - private static final int SLIDER_HEIGHT = 20; - private static final int SHOWVALBUTTON_WIDTH = 40; + private static final int SHOWVALBUTTON_WIDTH = 35; private static final int SHOWVALBUTTON_HEIGHTH = 20; - private static final int SLIDER_GAP = 5; + private static final String SUFFIX = "%"; private static final int TOOLTIP_Y = 30; private static final Color BACK_COLOR = new Color(245, 245, 247); public int showValue = 100; - public double resolutionTimes = 1.0; - private UITextField showVal; - private JSpinner showValSpinner; + private UINumberField showValField; private UISlider slider; private int times; private int sliderValue; private UIButton downButton; private UIButton upButton; - private UISliderButton showValButton; - private UIRadioButton twoHundredButton; - private UIRadioButton oneHundredButton; - private UIRadioButton sevenFiveButton; - private UIRadioButton fiveTenButton; - private UIRadioButton twoFiveButton; - private UIRadioButton selfAdaptButton; - private UIRadioButton customButton; //拖动条处理和button、直接输入不一样 private boolean isButtonOrIsTxt = true; - //是否选中指定的几个缩放等级,避免触发不必要的事件 - private boolean selectSpecified = false; - private FormPopupPane dialog; - private int upButtonX; - private JPanel dialogContentPanel; public JFormSliderPane() { this.setLayout(new BorderLayout()); initSlider(); - initShowValSpinner(); - //MoMeak:控制只能输入10-400 - JSpinner.NumberEditor editor = new JSpinner.NumberEditor(showValSpinner, "0"); - showValSpinner.setEditor(editor); - JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); - textField.setEditable(true); - DefaultFormatterFactory factory = (DefaultFormatterFactory) textField.getFormatterFactory(); - NumberFormatter formatter = (NumberFormatter) factory.getDefaultFormatter(); - formatter.setAllowsInvalid(false); - initDownUpButton(); - initShowValButton(); - initUIRadioButton(); - initPane(); + initShowValField(); JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); panel.add(downButton); panel.add(slider); panel.add(upButton); - panel.add(showValButton); + panel.add(showValField); + UILabel uiLabel = new UILabel(SUFFIX); + uiLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4)); + panel.add(uiLabel); panel.setBackground(BACK_COLOR); this.add(panel, BorderLayout.NORTH); } @@ -131,6 +88,7 @@ public class JFormSliderPane extends JPanel { return new Point(event.getX(), event.getY() - TOOLTIP_Y); } }; + slider.setValue(HALF_HUNDRED); slider.setUI(new JSliderPaneUI(slider)); slider.addChangeListener(listener); slider.setPreferredSize(new Dimension(220, 20)); @@ -139,16 +97,6 @@ public class JFormSliderPane extends JPanel { slider.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Slider")); } - private void initShowValSpinner() { - showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, 0, FOUR_HUNDRED, 1)) { - public Point getToolTipLocation(MouseEvent event) { - return new Point(event.getX(), event.getY() - TOOLTIP_Y); - } - }; - showValSpinner.setEnabled(true); - showValSpinner.addChangeListener(showValSpinnerChangeListener); - showValSpinner.setPreferredSize(new Dimension(SPINNER_WIDTH, SPINNER_HEIGHT)); - } private void initDownUpButton() { downButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/normalDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png")) { @@ -173,142 +121,78 @@ public class JFormSliderPane extends JPanel { upButton.addActionListener(buttonActionListener); } - private void initShowValButton() { - showValButton = new UISliderButton(showValSpinner.getValue() + "%"); - showValButton.setBackground(BACK_COLOR); - showValButton.setBorderPainted(false); - showValButton.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH)); - showValButton.addActionListener(showValButtonActionListener); - showValButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Grade")); - } + private void initShowValField() { + showValField = new UINumberField(); + showValField.setValue(showValue); + showValField.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH)); + showValField.addKeyListener(new KeyListener() { + @Override + public void keyTyped(KeyEvent e) { + + } - private void initUIRadioButton() { - twoHundredButton = new UIRadioButton("200%"); - oneHundredButton = new UIRadioButton("100%"); - sevenFiveButton = new UIRadioButton("75%"); - fiveTenButton = new UIRadioButton("50%"); - twoFiveButton = new UIRadioButton("25%"); - selfAdaptButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Self_Adapt_Button")); - selfAdaptButton.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); - customButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Custom_Button")); - customButton.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); - twoHundredButton.addItemListener(radioButtonItemListener); - oneHundredButton.addItemListener(radioButtonItemListener); - sevenFiveButton.addItemListener(radioButtonItemListener); - fiveTenButton.addItemListener(radioButtonItemListener); - twoFiveButton.addItemListener(radioButtonItemListener); - customButton.addItemListener(new ItemListener() { @Override - public void itemStateChanged(ItemEvent e) { - JRadioButton temp = (JRadioButton) e.getSource(); - if (temp.isSelected()) { - JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); - textField.requestFocus(); - textField.selectAll(); + public void keyPressed(KeyEvent e) { + + } + + @Override + public void keyReleased(KeyEvent evt) { + int code = evt.getKeyCode(); + + if (code == KeyEvent.VK_ENTER) { + showValFieldChange((int) showValField.getValue()); } } }); + showValField.addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent e) { - ButtonGroup bg = new ButtonGroup();// 初始化按钮组 - bg.add(twoHundredButton);// 加入按钮组 - bg.add(oneHundredButton); - bg.add(sevenFiveButton); - bg.add(fiveTenButton); - bg.add(twoFiveButton); - bg.add(selfAdaptButton); - bg.add(customButton); - customButton.setSelected(true); - } + } - private void initPane() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {p, f}; - double[] rowSize = {p, p, p, p, p, p, p, p}; - UILabel upLabel = new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_EnlargeOrReduce")); - upLabel.setOpaque(false); - JPanel septPane = new JPanel(new BorderLayout()); - JSeparator sept = new JSeparator(); - sept.setBackground(new Color(232, 232, 233)); - septPane.add(sept, BorderLayout.NORTH); - septPane.setBorder(BorderFactory.createEmptyBorder(2, 5, 1, 10)); - septPane.setBackground(BACK_COLOR); - twoHundredButton.setBackground(BACK_COLOR); - oneHundredButton.setBackground(BACK_COLOR); - sevenFiveButton.setBackground(BACK_COLOR); - fiveTenButton.setBackground(BACK_COLOR); - twoFiveButton.setBackground(BACK_COLOR); -// selfAdaptButton.setBackground(BACK_COLOR); - customButton.setBackground(BACK_COLOR); - Component[][] components = new Component[][]{ - new Component[]{upLabel, null}, - new Component[]{septPane, null}, - new Component[]{twoHundredButton, null}, - new Component[]{oneHundredButton, null}, - new Component[]{sevenFiveButton, null}, - new Component[]{fiveTenButton, null}, - new Component[]{twoFiveButton, null}, - new Component[]{customButton, createSpinnerPanel()} - }; - dialogContentPanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, LayoutConstants.VGAP_MEDIUM, 0); - dialogContentPanel.setBackground(BACK_COLOR); - dialogContentPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + @Override + public void focusLost(FocusEvent e) { + showValFieldChange((int) showValField.getValue()); + } + }); } - private JPanel createSpinnerPanel() { - JPanel spinnerPanel = new JPanel(new FlowLayout()); - spinnerPanel.add(showValSpinner); - UILabel percent = new UILabel("%"); - percent.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); - spinnerPanel.add(percent); - spinnerPanel.setBackground(BACK_COLOR); - return spinnerPanel; + + + private void showValFieldChange(int value) { + isButtonOrIsTxt = true; + showValue = getPreferredValue(value); + refreshShowValueFieldText(); + refreshSlider(); } - private ActionListener showValButtonActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - popupDialog(); + private int getPreferredValue(int value){ + if (value > FOUR_HUNDRED) { + value = FOUR_HUNDRED; } - }; - - private ChangeListener showValSpinnerChangeListener = new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - int val = (int) ((UIBasicSpinner) e.getSource()).getValue(); - isButtonOrIsTxt = true; - resolutionTimes = divide(showValue, 100, 2); - if (val > FOUR_HUNDRED) { - showValSpinner.setValue(FOUR_HUNDRED); - val = FOUR_HUNDRED; - } - if (val < TEN) { - showValSpinner.setValue(TEN); - val = TEN; - } - refreshSlider(val); - refreshBottun(val); - JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); - textField.setCaretPosition(showValSpinner.getValue().toString().length()); - if (!selectSpecified) { - customButton.setSelected(true); - } + if (value < TEN) { + value = TEN; } - }; + return value; + } + private void refreshShowValueFieldText(){ + showValField.setValue(showValue); + setAdjustButtonStatus(); + } //定义一个监听器,用于监听所有滑动条 private ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent event) { //取出滑动条的值,并在文本中显示出来 if (!isButtonOrIsTxt) { - customButton.setSelected(true); EventQueue.invokeLater(new Runnable() { public void run() { sliderValue = slider.getValue(); getTimes(sliderValue); showValue = times; - showValSpinner.setValue(times); + refreshShowValueFieldText(); } }); } else { @@ -317,41 +201,28 @@ public class JFormSliderPane extends JPanel { } }; - private ItemListener radioButtonItemListener = new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - JRadioButton temp = (JRadioButton) e.getSource(); - if (temp.isSelected()) { - selectSpecified = true; - showValSpinner.setValue(Integer.valueOf(temp.getText().substring(0, temp.getText().indexOf("%")))); - selectSpecified = false; - } - } - }; - private void refreshSlider(int val) { - showValue = val; - if (showValue > HUNDRED) { - slider.setValue((int) (showValue + TWO_HUNDRED) / SIX); - } else if (showValue < HUNDRED) { - slider.setValue((int) ((showValue - TEN) / ONEPOINTEIGHT)); - } else { - slider.setValue(HALF_HUNDRED); - } + private void refreshSlider() { + slider.setValue(calSliderValue(showValue)); } - - private void refreshBottun(int val) { - showValButton.setText(val + "%"); + private void setAdjustButtonStatus(){ + this.downButton.setEnabled(this.showValue > TEN); + this.upButton.setEnabled(this.showValue < FOUR_HUNDRED); } - public double getResolutionTimes() { - return this.resolutionTimes; + private int calSliderValue(int value) { + int result; + if (value > HUNDRED) { + result = (value + TWO_HUNDRED) / SIX; + } else if (value < HUNDRED) { + result = (int) ((value - TEN) / ONEPOINTEIGHT); + } else { + result = HALF_HUNDRED; + } + return result; } - public int getshowValue() { - return this.showValue; - } public static double divide(double v1, double v2, int scale) { BigDecimal b1 = new BigDecimal(Double.toString(v1)); @@ -362,30 +233,28 @@ public class JFormSliderPane extends JPanel { private ActionListener buttonActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - showValue = (int) showValSpinner.getValue(); isButtonOrIsTxt = true; if ("less".equals(e.getActionCommand())) { int newDownVal = showValue - TEN; if (newDownVal >= TEN) { showValue = newDownVal; - showValSpinner.setValue(newDownVal); } else { - showValue = newDownVal; - showValSpinner.setValue(TEN); + showValue = TEN; } + refreshShowValueFieldText(); + refreshSlider(); } if ("more".equals(e.getActionCommand())) { int newUpVal = showValue + TEN; if (newUpVal <= FOUR_HUNDRED) { showValue = newUpVal; - showValSpinner.setValue(newUpVal); } else { - showValue = newUpVal; - showValSpinner.setValue(FOUR_HUNDRED); + showValue = FOUR_HUNDRED; } + refreshShowValueFieldText(); + refreshSlider(); } isButtonOrIsTxt = true; - customButton.setSelected(true); } }; @@ -396,35 +265,72 @@ public class JFormSliderPane extends JPanel { } else if (value < HALF_HUNDRED) { times = (int) Math.round(ONEPOINTEIGHT * value + TEN); } else { - times = (int) (SIX * value - TWO_HUNDRED); + times = SIX * value - TWO_HUNDRED; } } - public JSpinner getShowVal() { - return this.showValSpinner; + public int getShowValue() { + return this.showValue; } - public UIRadioButton getSelfAdaptButton() { - return this.selfAdaptButton; + public void setShowValue(int value) { + showValFieldChange(value); } - private void popupDialog() { - Point btnCoords = upButton.getLocationOnScreen(); - if (dialog == null) { - dialog = new FormPopupPane(upButton, dialogContentPanel); - if (upButtonX == 0) { - upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); - } - } else { - if (upButtonX == 0) { - upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); + + public void addValueChangeListener(ChangeListener changeListener){ + this.slider.addChangeListener(changeListener); + } + + class JSliderPaneUI extends BasicSliderUI { + + private static final int THUMB_XOFFSET = 8; + private static final int THUMB_YOFFSET = 3; + private static final int FOUR = 4; + private static final int FIVE = 5; + private static final int SIX = 6; + private static final int MID_X_SHIFT = 2; // 中点标记的水平位置偏移 + + public JSliderPaneUI(UISlider b) { + super(b); + } + + /** + * 绘制指示物 + */ + public void paintThumb(Graphics g) { + Rectangle knobBounds = thumbRect; + Graphics2D g2d = (Graphics2D) g; + g2d.drawImage(APPFIT_V0, knobBounds.x - THUMB_XOFFSET, knobBounds.y + THUMB_YOFFSET, null); + g2d.dispose(); + } + + /** + * 绘制刻度轨迹 + */ + public void paintTrack(Graphics g) { + int cy, cw; + Rectangle trackBounds = trackRect; + if (slider.getOrientation() == UISlider.HORIZONTAL) { + Graphics2D g2 = (Graphics2D) g; + cy = (trackBounds.height / 2); + cw = trackBounds.width; + g2.setPaint(BACK_COLOR); + g2.fillRect(0, -cy, cw + 10, cy * 4); + g.setColor(new Color(216, 216, 216)); + g.drawLine(0, cy, cw + 3, cy); + g.drawLine(MID_X_SHIFT + cw / 2, cy - FOUR, MID_X_SHIFT + cw / 2, cy + FOUR); } else { - GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); + super.paintTrack(g); } } + + public void setThumbLocation(int x, int y) { + super.setThumbLocation(x, y); + slider.repaint(); + } + } public static void main(String[] args) { @@ -440,16 +346,3 @@ public class JFormSliderPane extends JPanel { } } - -class FormPopupPane extends JPopupMenu { - private static final int DIALOG_WIDTH = 157; - private static final int DIALOG_HEIGHT = 172; - - FormPopupPane(UIButton b, JPanel dialogContentPanel) { - this.add(dialogContentPanel, BorderLayout.CENTER); - this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); - this.setBackground(new Color(245, 245, 247)); - } - - -} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JSliderPane.java b/designer-base/src/main/java/com/fr/design/mainframe/JSliderPane.java index 4c8f307d69..487d18a565 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JSliderPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JSliderPane.java @@ -1,516 +1,516 @@ -package com.fr.design.mainframe; - -import com.fr.base.BaseUtils; -import com.fr.design.constants.LayoutConstants; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ibutton.UIRadioButton; -import com.fr.design.gui.ibutton.UISliderButton; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.imenu.UIPopupMenu; -import com.fr.design.gui.islider.UISlider; -import com.fr.design.gui.ispinner.UIBasicSpinner; -import com.fr.design.gui.ispinner.UISpinnerUI; -import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.utils.gui.GUICoreUtils; - - -import javax.swing.BorderFactory; -import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JFormattedTextField; -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.JRadioButton; -import javax.swing.JSeparator; -import javax.swing.JSpinner; -import javax.swing.SpinnerNumberModel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.plaf.basic.BasicSliderUI; -import javax.swing.text.DefaultFormatterFactory; -import javax.swing.text.NumberFormatter; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.EventQueue; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.Insets; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.MouseEvent; -import java.math.BigDecimal; - -/** - * Created by MoMeak on 2017/7/13. - */ -public class JSliderPane extends JPanel { - - public static final Image APPFIT_V0 = BaseUtils.readImage("com/fr/design/images/control/icon_thumb_normal.png"); - private static final double ONEPOINTEIGHT = 1.8; - private static final int SIX = 6; - private static final int TEN = 10; - private static final int FONT_SIZE = 12; - private static final int SPINNER_WIDTH = 45; - private static final int SPINNER_HEIGHT = 20; - private static final int HALF_HUNDRED = 50; - private static final int HUNDRED = 100; - private static final int TWO_HUNDRED = 200; - private static final int FOUR_HUNDRED = 400; - private static final int SHOWVALBUTTON_WIDTH = 40; - private static final int SHOWVALBUTTON_HEIGHTH = 20; - private static final int TOOLTIP_Y = 30; - - private static final Color BACK_COLOR = new Color(245, 245, 247); - public int showValue = 100; - public double resolutionTimes = 1.0; - private UITextField showVal; - private JSpinner showValSpinner; - private UISlider slider; - private int times; - private int sliderValue; - private UIButton downButton; - private UIButton upButton; - private UISliderButton showValButton; - private UIRadioButton twoHundredButton; - private UIRadioButton oneHundredButton; - private UIRadioButton sevenFiveButton; - private UIRadioButton fiveTenButton; - private UIRadioButton twoFiveButton; - private UIRadioButton selfAdaptButton; - private UIRadioButton customButton; - /** - * 拖动条处理和button、直接输入不一样 - */ - private boolean isButtonOrIsTxt = true; - private PopupPane dialog; - private int upButtonX; - private JPanel dialogContentPanel; - - - public JSliderPane() { - this.setLayout(new BorderLayout()); - initSlider(); - initShowValSpinner(); - //MoMeak:控制只能输入10-400 - JSpinner.NumberEditor editor = new JSpinner.NumberEditor(showValSpinner, "0"); - showValSpinner.setEditor(editor); - JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); - textField.setEditable(true); - DefaultFormatterFactory factory = (DefaultFormatterFactory) textField.getFormatterFactory(); - NumberFormatter formatter = (NumberFormatter) factory.getDefaultFormatter(); - formatter.setAllowsInvalid(false); - - initDownUpButton(); - initShowValButton(); - initUIRadioButton(); - initPane(); - JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); - panel.add(downButton); - panel.add(slider); - panel.add(upButton); - panel.add(showValButton); - panel.setBackground(BACK_COLOR); - this.add(panel, BorderLayout.NORTH); - } - - - public static JSliderPane getInstance() { - return new JSliderPane(); - } - - private void initSlider() { - slider = new UISlider(0, HUNDRED, HALF_HUNDRED) { - public Point getToolTipLocation(MouseEvent event) { - return new Point(event.getX(), event.getY() - TOOLTIP_Y); - } - }; - slider.setUI(new JSliderPaneUI(slider)); - slider.addChangeListener(listener); - slider.setPreferredSize(new Dimension(220, 20)); - //去掉虚线框 - slider.setFocusable(false); - slider.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Slider")); - } - - private void initShowValSpinner() { - showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, 0, FOUR_HUNDRED, 1)) { - public Point getToolTipLocation(MouseEvent event) { - return new Point(event.getX(), event.getY() - TOOLTIP_Y); - } - }; - showValSpinner.setUI(new UISpinnerUI()); - showValSpinner.setEnabled(true); - showValSpinner.addChangeListener(showValSpinnerChangeListener); - showValSpinner.setPreferredSize(new Dimension(SPINNER_WIDTH, SPINNER_HEIGHT)); - } - - private void initDownUpButton() { - downButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/normalDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png")) { - public Point getToolTipLocation(MouseEvent event) { - return new Point(event.getX(), event.getY() - TOOLTIP_Y); - } - }; - downButton.setOpaque(false); - downButton.setBorderPainted(false); - downButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Down")); - upButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/normalUp20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverUp20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverUp20.png")) { - public Point getToolTipLocation(MouseEvent event) { - return new Point(event.getX(), event.getY() - TOOLTIP_Y); - } - }; - upButton.setOpaque(false); - upButton.setBorderPainted(false); - upButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Up")); - downButton.setActionCommand("less"); - upButton.setActionCommand("more"); - downButton.addActionListener(buttonActionListener); - upButton.addActionListener(buttonActionListener); - } - - private void initShowValButton() { - showValButton = new UISliderButton(showValSpinner.getValue() + "%"); - showValButton.setBackground(BACK_COLOR); - showValButton.setBorderPainted(false); - showValButton.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH)); - showValButton.addActionListener(showValButtonActionListener); - showValButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Grade")); - } - - private void initUIRadioButton() { - twoHundredButton = new UIRadioButton("200%"); - oneHundredButton = new UIRadioButton("100%"); - sevenFiveButton = new UIRadioButton("75%"); - fiveTenButton = new UIRadioButton("50%"); - twoFiveButton = new UIRadioButton("25%"); - selfAdaptButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Self_Adapt_Button")); - selfAdaptButton.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); - customButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Custom_Button")); - customButton.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); - twoHundredButton.addItemListener(radioButtonItemListener); - oneHundredButton.addItemListener(radioButtonItemListener); - sevenFiveButton.addItemListener(radioButtonItemListener); - fiveTenButton.addItemListener(radioButtonItemListener); - twoFiveButton.addItemListener(radioButtonItemListener); - customButton.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - JRadioButton temp = (JRadioButton) e.getSource(); - if (temp.isSelected()) { - JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); - textField.requestFocus(); - textField.selectAll(); - } - } - }); - - ButtonGroup bg = new ButtonGroup();// 初始化按钮组 - bg.add(twoHundredButton);// 加入按钮组 - bg.add(oneHundredButton); - bg.add(sevenFiveButton); - bg.add(fiveTenButton); - bg.add(twoFiveButton); - bg.add(selfAdaptButton); - bg.add(customButton); - customButton.setSelected(true); - } - - private void initPane() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {p, f}; - double[] rowSize = {p, p, p, p, p, p, p, p, p}; - UILabel upLabel = new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_EnlargeOrReduce")); - upLabel.setOpaque(false); - JPanel septPane = new JPanel(new BorderLayout()); - JSeparator sept = new JSeparator(); - sept.setBackground(new Color(232, 232, 233)); - septPane.add(sept, BorderLayout.NORTH); - septPane.setBorder(BorderFactory.createEmptyBorder(2, 5, 1, 10)); - septPane.setBackground(BACK_COLOR); - twoHundredButton.setBackground(BACK_COLOR); - oneHundredButton.setBackground(BACK_COLOR); - sevenFiveButton.setBackground(BACK_COLOR); - fiveTenButton.setBackground(BACK_COLOR); - twoFiveButton.setBackground(BACK_COLOR); - selfAdaptButton.setBackground(BACK_COLOR); - customButton.setBackground(BACK_COLOR); - Component[][] components = new Component[][]{ - new Component[]{upLabel, null}, - new Component[]{septPane, null}, - new Component[]{twoHundredButton, null}, - new Component[]{oneHundredButton, null}, - new Component[]{sevenFiveButton, null}, - new Component[]{fiveTenButton, null}, - new Component[]{twoFiveButton, null}, - new Component[]{selfAdaptButton, null}, - new Component[]{customButton, createSpinnerPanel()} - }; - dialogContentPanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, LayoutConstants.VGAP_MEDIUM, 0); - dialogContentPanel.setBackground(BACK_COLOR); - dialogContentPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); - } - - private JPanel createSpinnerPanel() { - JPanel spinnerPanel = new JPanel(new FlowLayout()); - spinnerPanel.add(showValSpinner); - UILabel percent = new UILabel("%"); - percent.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); - spinnerPanel.add(percent); - spinnerPanel.setBackground(BACK_COLOR); - return spinnerPanel; - } - - private ActionListener showValButtonActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - popupDialog(); - } - }; - - private ChangeListener showValSpinnerChangeListener = new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - int val = (int) ((UIBasicSpinner) e.getSource()).getValue(); - isButtonOrIsTxt = true; - resolutionTimes = divide(showValue, 100, 2); - if (val > FOUR_HUNDRED) { - showValSpinner.setValue(FOUR_HUNDRED); - val = FOUR_HUNDRED; - } - if (val < TEN) { - showValSpinner.setValue(TEN); - val = TEN; - } - refreshSlider(val); - refreshBottun(val); - JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); - textField.setCaretPosition(showValSpinner.getValue().toString().length()); - } - }; - - - //定义一个监听器,用于监听所有滑动条 - private ChangeListener listener = new ChangeListener() { - public void stateChanged(ChangeEvent event) { - //取出滑动条的值,并在文本中显示出来 - if (!isButtonOrIsTxt) { - customButton.setSelected(true); - EventQueue.invokeLater(new Runnable() { - public void run() { - sliderValue = slider.getValue(); - getTimes(sliderValue); - showValue = times; - showValSpinner.setValue(times); - customButton.setSelected(true); - } - }); - } else { - isButtonOrIsTxt = false; - } - } - }; - - private ItemListener radioButtonItemListener = new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - JRadioButton temp = (JRadioButton) e.getSource(); - if (temp.isSelected()) { - showValSpinner.setValue(Integer.valueOf(temp.getText().substring(0, temp.getText().indexOf("%")))); - } - } - }; - - private void refreshSlider(int val) { - showValue = val; - if (showValue > HUNDRED) { - slider.setValue((int) (showValue + TWO_HUNDRED) / SIX); - } else if (showValue < HUNDRED) { - slider.setValue((int) ((showValue - TEN) / ONEPOINTEIGHT)); - } else { - slider.setValue(HALF_HUNDRED); - } - } - - - private void refreshBottun(int val) { - showValButton.setText(val + "%"); - } - - public double getResolutionTimes() { - return this.resolutionTimes; - } - - public int getshowValue() { - return this.showValue; - } - - public void reset() { - this.showValSpinner.setValue(HUNDRED); - } - - public static double divide(double v1, double v2, int scale) { - BigDecimal b1 = new BigDecimal(Double.toString(v1)); - BigDecimal b2 = new BigDecimal(Double.toString(v2)); - return b1.divide(b2, scale).doubleValue(); - } - - private ActionListener buttonActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - showValue = (int) showValSpinner.getValue(); - isButtonOrIsTxt = true; - if ("less".equals(e.getActionCommand())) { - int newDownVal = showValue - TEN; - if (newDownVal >= TEN) { - showValue = newDownVal; - showValSpinner.setValue(newDownVal); - } else { - showValue = newDownVal; - showValSpinner.setValue(TEN); - } - } - if ("more".equals(e.getActionCommand())) { - int newUpVal = showValue + TEN; - if (newUpVal <= FOUR_HUNDRED) { - showValue = newUpVal; - showValSpinner.setValue(newUpVal); - } else { - showValue = newUpVal; - showValSpinner.setValue(FOUR_HUNDRED); - } - } - isButtonOrIsTxt = true; - customButton.setSelected(true); - } - }; - - - private void getTimes(int value) { - if (value == HALF_HUNDRED) { - times = HUNDRED; - } else if (value < HALF_HUNDRED) { - times = (int) Math.round(ONEPOINTEIGHT * value + TEN); - } else { - times = SIX * value - TWO_HUNDRED; - } - } - - - public JSpinner getShowVal() { - return this.showValSpinner; - } - - public UIRadioButton getSelfAdaptButton() { - return this.selfAdaptButton; - } - - private void popupDialog() { - Point btnCoords = upButton.getLocationOnScreen(); - if (dialog == null) { - dialog = new PopupPane(upButton, dialogContentPanel); - if (upButtonX == 0) { - upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height); - } - } else { - if (upButtonX == 0) { - upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height); - } else { - GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height); - } - } - } - - public static void main(String[] args) { - JFrame jf = new JFrame("test"); - jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - JPanel content = (JPanel) jf.getContentPane(); - content.setLayout(new BorderLayout()); - content.add(JSliderPane.getInstance(), BorderLayout.CENTER); - GUICoreUtils.centerWindow(jf); - jf.setSize(400, 80); - jf.setVisible(true); - - } -} - -class JSliderPaneUI extends BasicSliderUI { - - private static final Color BACK_COLOR = new Color(245, 245, 247); - private static final int THUMB_XOFFSET = 8; - private static final int THUMB_YOFFSET = 3; - private static final int FOUR = 4; - private static final int FIVE = 5; - private static final int SIX = 6; - private static final int MID_X_SHIFT = 2; // 中点标记的水平位置偏移 - - public JSliderPaneUI(UISlider b) { - super(b); - } - - /** - * 绘制指示物 - */ - public void paintThumb(Graphics g) { - Rectangle knobBounds = thumbRect; - Graphics2D g2d = (Graphics2D) g; - g2d.drawImage(JSliderPane.APPFIT_V0, knobBounds.x - THUMB_XOFFSET, knobBounds.y + THUMB_YOFFSET, null); - g2d.dispose(); - } - - /** - * 绘制刻度轨迹 - */ - public void paintTrack(Graphics g) { - int cy, cw; - Rectangle trackBounds = trackRect; - if (slider.getOrientation() == UISlider.HORIZONTAL) { - Graphics2D g2 = (Graphics2D) g; - cy = (trackBounds.height / 2); - cw = trackBounds.width; - g2.setPaint(BACK_COLOR); - g2.fillRect(0, -cy, cw + 10, cy * 4); - g.setColor(new Color(216, 216, 216)); - g.drawLine(0, cy, cw + 3, cy); - g.drawLine(MID_X_SHIFT + cw / 2, cy - FOUR, MID_X_SHIFT + cw / 2, cy + FOUR); - } else { - super.paintTrack(g); - } - } - - public void setThumbLocation(int x, int y) { - super.setThumbLocation(x, y); - slider.repaint(); - } - -} - -class PopupPane extends UIPopupMenu { - private static final float REC = 8f; - private static final int INSERT_TOPBOTTOM = 10; - private static final int INSERT_LEFTRIGHT = 2; - private static final int DIALOG_WIDTH = 157; - private static final int DIALOG_HEIGHT = 205; - - PopupPane(JButton b, JPanel dialogContentPanel) { - this.add(dialogContentPanel, BorderLayout.CENTER); - this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); - this.setBackground(new Color(245, 245, 247)); - } - - public Insets getInsets() { - return new Insets(INSERT_TOPBOTTOM, INSERT_LEFTRIGHT, INSERT_TOPBOTTOM, INSERT_LEFTRIGHT); - } -} +package com.fr.design.mainframe; + +import com.fr.base.BaseUtils; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ibutton.UISliderButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.imenu.UIPopupMenu; +import com.fr.design.gui.islider.UISlider; +import com.fr.design.gui.ispinner.UIBasicSpinner; +import com.fr.design.gui.ispinner.UISpinnerUI; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.utils.gui.GUICoreUtils; + + +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JFormattedTextField; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JSeparator; +import javax.swing.JSpinner; +import javax.swing.SpinnerNumberModel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.plaf.basic.BasicSliderUI; +import javax.swing.text.DefaultFormatterFactory; +import javax.swing.text.NumberFormatter; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseEvent; +import java.math.BigDecimal; + +/** + * Created by MoMeak on 2017/7/13. + */ +public class JSliderPane extends JPanel { + + public static final Image APPFIT_V0 = BaseUtils.readImage("com/fr/design/images/control/icon_thumb_normal.png"); + private static final double ONEPOINTEIGHT = 1.8; + private static final int SIX = 6; + private static final int TEN = 10; + private static final int FONT_SIZE = 12; + private static final int SPINNER_WIDTH = 45; + private static final int SPINNER_HEIGHT = 20; + private static final int HALF_HUNDRED = 50; + private static final int HUNDRED = 100; + private static final int TWO_HUNDRED = 200; + private static final int FOUR_HUNDRED = 400; + private static final int SHOWVALBUTTON_WIDTH = 40; + private static final int SHOWVALBUTTON_HEIGHTH = 20; + private static final int TOOLTIP_Y = 30; + + private static final Color BACK_COLOR = new Color(245, 245, 247); + public int showValue = 100; + public double resolutionTimes = 1.0; + private UITextField showVal; + private JSpinner showValSpinner; + private UISlider slider; + private int times; + private int sliderValue; + private UIButton downButton; + private UIButton upButton; + private UISliderButton showValButton; + private UIRadioButton twoHundredButton; + private UIRadioButton oneHundredButton; + private UIRadioButton sevenFiveButton; + private UIRadioButton fiveTenButton; + private UIRadioButton twoFiveButton; + private UIRadioButton selfAdaptButton; + private UIRadioButton customButton; + /** + * 拖动条处理和button、直接输入不一样 + */ + private boolean isButtonOrIsTxt = true; + private PopupPane dialog; + private int upButtonX; + private JPanel dialogContentPanel; + + + public JSliderPane() { + this.setLayout(new BorderLayout()); + initSlider(); + initShowValSpinner(); + //MoMeak:控制只能输入10-400 + JSpinner.NumberEditor editor = new JSpinner.NumberEditor(showValSpinner, "0"); + showValSpinner.setEditor(editor); + JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); + textField.setEditable(true); + DefaultFormatterFactory factory = (DefaultFormatterFactory) textField.getFormatterFactory(); + NumberFormatter formatter = (NumberFormatter) factory.getDefaultFormatter(); + formatter.setAllowsInvalid(false); + + initDownUpButton(); + initShowValButton(); + initUIRadioButton(); + initPane(); + JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); + panel.add(downButton); + panel.add(slider); + panel.add(upButton); + panel.add(showValButton); + panel.setBackground(BACK_COLOR); + this.add(panel, BorderLayout.NORTH); + } + + + public static JSliderPane getInstance() { + return new JSliderPane(); + } + + private void initSlider() { + slider = new UISlider(0, HUNDRED, HALF_HUNDRED) { + public Point getToolTipLocation(MouseEvent event) { + return new Point(event.getX(), event.getY() - TOOLTIP_Y); + } + }; + slider.setUI(new JSliderPaneUI(slider)); + slider.addChangeListener(listener); + slider.setPreferredSize(new Dimension(220, 20)); + //去掉虚线框 + slider.setFocusable(false); + slider.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Slider")); + } + + private void initShowValSpinner() { + showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, 0, FOUR_HUNDRED, 1)) { + public Point getToolTipLocation(MouseEvent event) { + return new Point(event.getX(), event.getY() - TOOLTIP_Y); + } + }; + showValSpinner.setUI(new UISpinnerUI()); + showValSpinner.setEnabled(true); + showValSpinner.addChangeListener(showValSpinnerChangeListener); + showValSpinner.setPreferredSize(new Dimension(SPINNER_WIDTH, SPINNER_HEIGHT)); + } + + private void initDownUpButton() { + downButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/normalDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png")) { + public Point getToolTipLocation(MouseEvent event) { + return new Point(event.getX(), event.getY() - TOOLTIP_Y); + } + }; + downButton.setOpaque(false); + downButton.setBorderPainted(false); + downButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Down")); + upButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/normalUp20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverUp20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverUp20.png")) { + public Point getToolTipLocation(MouseEvent event) { + return new Point(event.getX(), event.getY() - TOOLTIP_Y); + } + }; + upButton.setOpaque(false); + upButton.setBorderPainted(false); + upButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Up")); + downButton.setActionCommand("less"); + upButton.setActionCommand("more"); + downButton.addActionListener(buttonActionListener); + upButton.addActionListener(buttonActionListener); + } + + private void initShowValButton() { + showValButton = new UISliderButton(showValSpinner.getValue() + "%"); + showValButton.setBackground(BACK_COLOR); + showValButton.setBorderPainted(false); + showValButton.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH)); + showValButton.addActionListener(showValButtonActionListener); + showValButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Grade")); + } + + private void initUIRadioButton() { + twoHundredButton = new UIRadioButton("200%"); + oneHundredButton = new UIRadioButton("100%"); + sevenFiveButton = new UIRadioButton("75%"); + fiveTenButton = new UIRadioButton("50%"); + twoFiveButton = new UIRadioButton("25%"); + selfAdaptButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Self_Adapt_Button")); + selfAdaptButton.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); + customButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Custom_Button")); + customButton.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); + twoHundredButton.addItemListener(radioButtonItemListener); + oneHundredButton.addItemListener(radioButtonItemListener); + sevenFiveButton.addItemListener(radioButtonItemListener); + fiveTenButton.addItemListener(radioButtonItemListener); + twoFiveButton.addItemListener(radioButtonItemListener); + customButton.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + JRadioButton temp = (JRadioButton) e.getSource(); + if (temp.isSelected()) { + JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); + textField.requestFocus(); + textField.selectAll(); + } + } + }); + + ButtonGroup bg = new ButtonGroup();// 初始化按钮组 + bg.add(twoHundredButton);// 加入按钮组 + bg.add(oneHundredButton); + bg.add(sevenFiveButton); + bg.add(fiveTenButton); + bg.add(twoFiveButton); + bg.add(selfAdaptButton); + bg.add(customButton); + customButton.setSelected(true); + } + + private void initPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p, p, p, p, p, p, p, p}; + UILabel upLabel = new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_EnlargeOrReduce")); + upLabel.setOpaque(false); + JPanel septPane = new JPanel(new BorderLayout()); + JSeparator sept = new JSeparator(); + sept.setBackground(new Color(232, 232, 233)); + septPane.add(sept, BorderLayout.NORTH); + septPane.setBorder(BorderFactory.createEmptyBorder(2, 5, 1, 10)); + septPane.setBackground(BACK_COLOR); + twoHundredButton.setBackground(BACK_COLOR); + oneHundredButton.setBackground(BACK_COLOR); + sevenFiveButton.setBackground(BACK_COLOR); + fiveTenButton.setBackground(BACK_COLOR); + twoFiveButton.setBackground(BACK_COLOR); + selfAdaptButton.setBackground(BACK_COLOR); + customButton.setBackground(BACK_COLOR); + Component[][] components = new Component[][]{ + new Component[]{upLabel, null}, + new Component[]{septPane, null}, + new Component[]{twoHundredButton, null}, + new Component[]{oneHundredButton, null}, + new Component[]{sevenFiveButton, null}, + new Component[]{fiveTenButton, null}, + new Component[]{twoFiveButton, null}, + new Component[]{selfAdaptButton, null}, + new Component[]{customButton, createSpinnerPanel()} + }; + dialogContentPanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, LayoutConstants.VGAP_MEDIUM, 0); + dialogContentPanel.setBackground(BACK_COLOR); + dialogContentPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + } + + private JPanel createSpinnerPanel() { + JPanel spinnerPanel = new JPanel(new FlowLayout()); + spinnerPanel.add(showValSpinner); + UILabel percent = new UILabel("%"); + percent.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); + spinnerPanel.add(percent); + spinnerPanel.setBackground(BACK_COLOR); + return spinnerPanel; + } + + private ActionListener showValButtonActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + popupDialog(); + } + }; + + private ChangeListener showValSpinnerChangeListener = new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + int val = (int) ((UIBasicSpinner) e.getSource()).getValue(); + isButtonOrIsTxt = true; + resolutionTimes = divide(showValue, 100, 2); + if (val > FOUR_HUNDRED) { + showValSpinner.setValue(FOUR_HUNDRED); + val = FOUR_HUNDRED; + } + if (val < TEN) { + showValSpinner.setValue(TEN); + val = TEN; + } + refreshSlider(val); + refreshBottun(val); + JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); + textField.setCaretPosition(showValSpinner.getValue().toString().length()); + } + }; + + + //定义一个监听器,用于监听所有滑动条 + private ChangeListener listener = new ChangeListener() { + public void stateChanged(ChangeEvent event) { + //取出滑动条的值,并在文本中显示出来 + if (!isButtonOrIsTxt) { + customButton.setSelected(true); + EventQueue.invokeLater(new Runnable() { + public void run() { + sliderValue = slider.getValue(); + getTimes(sliderValue); + showValue = times; + showValSpinner.setValue(times); + customButton.setSelected(true); + } + }); + } else { + isButtonOrIsTxt = false; + } + } + }; + + private ItemListener radioButtonItemListener = new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + JRadioButton temp = (JRadioButton) e.getSource(); + if (temp.isSelected()) { + showValSpinner.setValue(Integer.valueOf(temp.getText().substring(0, temp.getText().indexOf("%")))); + } + } + }; + + private void refreshSlider(int val) { + showValue = val; + if (showValue > HUNDRED) { + slider.setValue((int) (showValue + TWO_HUNDRED) / SIX); + } else if (showValue < HUNDRED) { + slider.setValue((int) ((showValue - TEN) / ONEPOINTEIGHT)); + } else { + slider.setValue(HALF_HUNDRED); + } + } + + + private void refreshBottun(int val) { + showValButton.setText(val + "%"); + } + + public double getResolutionTimes() { + return this.resolutionTimes; + } + + public int getshowValue() { + return this.showValue; + } + + public void reset() { + this.showValSpinner.setValue(HUNDRED); + } + + public static double divide(double v1, double v2, int scale) { + BigDecimal b1 = new BigDecimal(Double.toString(v1)); + BigDecimal b2 = new BigDecimal(Double.toString(v2)); + return b1.divide(b2, scale).doubleValue(); + } + + private ActionListener buttonActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + showValue = (int) showValSpinner.getValue(); + isButtonOrIsTxt = true; + if ("less".equals(e.getActionCommand())) { + int newDownVal = showValue - TEN; + if (newDownVal >= TEN) { + showValue = newDownVal; + showValSpinner.setValue(newDownVal); + } else { + showValue = newDownVal; + showValSpinner.setValue(TEN); + } + } + if ("more".equals(e.getActionCommand())) { + int newUpVal = showValue + TEN; + if (newUpVal <= FOUR_HUNDRED) { + showValue = newUpVal; + showValSpinner.setValue(newUpVal); + } else { + showValue = newUpVal; + showValSpinner.setValue(FOUR_HUNDRED); + } + } + isButtonOrIsTxt = true; + customButton.setSelected(true); + } + }; + + + private void getTimes(int value) { + if (value == HALF_HUNDRED) { + times = HUNDRED; + } else if (value < HALF_HUNDRED) { + times = (int) Math.round(ONEPOINTEIGHT * value + TEN); + } else { + times = SIX * value - TWO_HUNDRED; + } + } + + + public JSpinner getShowVal() { + return this.showValSpinner; + } + + public UIRadioButton getSelfAdaptButton() { + return this.selfAdaptButton; + } + + private void popupDialog() { + Point btnCoords = upButton.getLocationOnScreen(); + if (dialog == null) { + dialog = new PopupPane(upButton, dialogContentPanel); + if (upButtonX == 0) { + upButtonX = btnCoords.x; + GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height); + } + } else { + if (upButtonX == 0) { + upButtonX = btnCoords.x; + GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height); + } else { + GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height); + } + } + } + + public static void main(String[] args) { + JFrame jf = new JFrame("test"); + jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + JPanel content = (JPanel) jf.getContentPane(); + content.setLayout(new BorderLayout()); + content.add(JSliderPane.getInstance(), BorderLayout.CENTER); + GUICoreUtils.centerWindow(jf); + jf.setSize(400, 80); + jf.setVisible(true); + + } +} + +class JSliderPaneUI extends BasicSliderUI { + + private static final Color BACK_COLOR = new Color(245, 245, 247); + private static final int THUMB_XOFFSET = 8; + private static final int THUMB_YOFFSET = 3; + private static final int FOUR = 4; + private static final int FIVE = 5; + private static final int SIX = 6; + private static final int MID_X_SHIFT = 2; // 中点标记的水平位置偏移 + + public JSliderPaneUI(UISlider b) { + super(b); + } + + /** + * 绘制指示物 + */ + public void paintThumb(Graphics g) { + Rectangle knobBounds = thumbRect; + Graphics2D g2d = (Graphics2D) g; + g2d.drawImage(JSliderPane.APPFIT_V0, knobBounds.x - THUMB_XOFFSET, knobBounds.y + THUMB_YOFFSET, null); + g2d.dispose(); + } + + /** + * 绘制刻度轨迹 + */ + public void paintTrack(Graphics g) { + int cy, cw; + Rectangle trackBounds = trackRect; + if (slider.getOrientation() == UISlider.HORIZONTAL) { + Graphics2D g2 = (Graphics2D) g; + cy = (trackBounds.height / 2); + cw = trackBounds.width; + g2.setPaint(BACK_COLOR); + g2.fillRect(0, -cy, cw + 10, cy * 4); + g.setColor(new Color(216, 216, 216)); + g.drawLine(0, cy, cw + 3, cy); + g.drawLine(MID_X_SHIFT + cw / 2, cy - FOUR, MID_X_SHIFT + cw / 2, cy + FOUR); + } else { + super.paintTrack(g); + } + } + + public void setThumbLocation(int x, int y) { + super.setThumbLocation(x, y); + slider.repaint(); + } + +} + +class PopupPane extends UIPopupMenu { + private static final float REC = 8f; + private static final int INSERT_TOPBOTTOM = 10; + private static final int INSERT_LEFTRIGHT = 2; + private static final int DIALOG_WIDTH = 157; + private static final int DIALOG_HEIGHT = 205; + + PopupPane(JButton b, JPanel dialogContentPanel) { + this.add(dialogContentPanel, BorderLayout.CENTER); + this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); + this.setBackground(new Color(245, 245, 247)); + } + + public Insets getInsets() { + return new Insets(INSERT_TOPBOTTOM, INSERT_LEFTRIGHT, INSERT_TOPBOTTOM, INSERT_LEFTRIGHT); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java index 5c17d8f1a4..23c642dbd4 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java @@ -39,8 +39,12 @@ public class WestRegionContainerPane extends UIResizableContainer { @Override public void on(PluginEvent event) { - - setDownPane(TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); + + if (getDownPane() != null) { + replaceDownPane(TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); + } else { + setDownPane(TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); + } } }, new PluginFilter() { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java index b935eb11ea..1d67c47df1 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java @@ -8,6 +8,7 @@ import com.fr.design.ui.util.UIUtil; import com.fr.general.ComparatorUtils; import com.fr.general.log.Log4jConfig; import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; import com.fr.third.apache.log4j.Level; import com.fr.third.apache.log4j.spi.LoggingEvent; import com.fr.third.apache.log4j.spi.ThrowableInformation; @@ -53,12 +54,14 @@ public class DesignerLogHandler { private static final int SERVER_GAP_Y = -20; - private static final String ERROR_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + ":"; + private static final String ERROR_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Seriously") + ":"; - private static final String WARN_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Seriously") + ":"; + private static final String WARN_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + ":"; private static final String NORMAL_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Normal") + ":"; + private static final String ACTION_MAP_KEY = "clear"; + public static DesignerLogHandler getInstance() { return HOLDER.singleton; @@ -223,14 +226,14 @@ public class DesignerLogHandler { InputMap inputMap = resultPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), DefaultEditorKit.copyAction); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), DefaultEditorKit.selectAllAction); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_L, DEFAULT_MODIFIER), "clear"); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_L, DEFAULT_MODIFIER), ACTION_MAP_KEY); ActionMap actionMap = resultPane.getActionMap(); - actionMap.put("clear", new AbstractAction() { + actionMap.put(ACTION_MAP_KEY, new AbstractAction() { @Override public void actionPerformed(ActionEvent evt) { - resultPane.setText(""); + resultPane.setText(StringUtils.EMPTY); caption.clearMessage(); } }); @@ -293,10 +296,10 @@ public class DesignerLogHandler { SimpleAttributeSet attrSet = new SimpleAttributeSet(); if (style == DesignerLogger.ERROR_INT) { - StyleConstants.setForeground(attrSet, new Color(247, 148, 29)); + StyleConstants.setForeground(attrSet, Color.RED); StyleConstants.setBold(attrSet, true); } else if (style == DesignerLogger.WARN_INT) { - StyleConstants.setForeground(attrSet, Color.red); + StyleConstants.setForeground(attrSet, new Color(247, 148, 29)); StyleConstants.setBold(attrSet, true); } else if (style == DesignerLogger.INFO_INT) { StyleConstants.setForeground(attrSet, Color.black); @@ -330,9 +333,9 @@ public class DesignerLogHandler { LogMessageBar.getInstance().setMessage(message); if (level == DesignerLogger.INFO_INT && showInfo.isSelected()) { caption.infoAdd(); - } else if (level == DesignerLogger.ERROR_INT && showError.isSelected()) { + } else if (level == DesignerLogger.WARN_INT && showError.isSelected()) { caption.errorAdd(); - } else if (level == DesignerLogger.WARN_INT && showServer.isSelected()) { + } else if (level == DesignerLogger.ERROR_INT && showServer.isSelected()) { caption.serverAdd(); } } @@ -343,7 +346,7 @@ public class DesignerLogHandler { this.copy.setEnabled(true); this.clear.setEnabled(true); - if (ComparatorUtils.equals(this.jTextArea.getText(), "")) { + if (ComparatorUtils.equals(this.jTextArea.getText(), StringUtils.EMPTY)) { this.selectAll.setEnabled(false); this.clear.setEnabled(false); } @@ -367,7 +370,7 @@ public class DesignerLogHandler { } else if (ComparatorUtils.equals(evt.getActionCommand(), LogHandlerArea.this.copy.getText())) { LogHandlerArea.this.jTextArea.copy(); } else if (ComparatorUtils.equals(evt.getActionCommand(), LogHandlerArea.this.clear.getText())) { - LogHandlerArea.this.jTextArea.setText(""); + LogHandlerArea.this.jTextArea.setText(StringUtils.EMPTY); caption.clearMessage(); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index bc4b85ced8..c81c6749f8 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -11,12 +11,14 @@ import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.community.BBSAction; import com.fr.design.actions.community.BugAction; +import com.fr.design.actions.community.BugNeedAction; import com.fr.design.actions.community.CenterAction; import com.fr.design.actions.community.FacebookFansAction; import com.fr.design.actions.community.NeedAction; import com.fr.design.actions.community.QuestionAction; import com.fr.design.actions.community.SignAction; import com.fr.design.actions.community.TechSolutionAction; +import com.fr.design.actions.community.TechSupportAction; import com.fr.design.actions.community.VideoAction; import com.fr.design.actions.file.CloseCurrentTemplateAction; import com.fr.design.actions.file.ExitDesignerAction; @@ -529,11 +531,30 @@ public abstract class ToolBarMenuDock { */ public ShortCut[] createHelpShortCuts() { final java.util.List shortCuts = new ArrayList(); - // 英文,把 video 和帮助文档放到 Help 下面 - if (GeneralContext.getLocale().equals(Locale.US)) { - shortCuts.add(new VideoAction()); - shortCuts.add(new TutorialAction()); - } + + Locale locale = GeneralContext.getLocale(); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new VideoAction()); + } + }, SupportLocaleImpl.VIDEO); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new TutorialAction()); + } + }, SupportLocaleImpl.TUTORIAL_HELP); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new TechSupportAction()); + } + }, SupportLocaleImpl.TECH_SUPPORT_HELP); + //远程不使用更新升级,产品演示 if (WorkContext.getCurrent().isLocal()) { shortCuts.add(new WebDemoAction()); @@ -571,14 +592,44 @@ public abstract class ToolBarMenuDock { shortCuts.add(SeparatorDef.DEFAULT); shortCuts.add(new VideoAction()); - shortCuts.add(new TutorialAction()); + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new TutorialAction()); + } + }, SupportLocaleImpl.TUTORIAL_COMMUNITY); shortCuts.add(new QuestionAction()); shortCuts.add(new TechSolutionAction()); shortCuts.add(SeparatorDef.DEFAULT); - - shortCuts.add(new BugAction()); - shortCuts.add(new NeedAction()); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new BugAction()); + } + }, SupportLocaleImpl.BUG); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new NeedAction()); + } + }, SupportLocaleImpl.NEED); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new BugNeedAction()); + } + }, SupportLocaleImpl.BUG_AND_NEED); + + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new TechSupportAction()); + } + }, SupportLocaleImpl.TECH_SUPPORT_COMMUNITY); shortCuts.add(SeparatorDef.DEFAULT); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java index 67ab8dfb06..16062c2936 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.vcs.common; +import com.fr.io.FineEncryptUtils; import com.fr.base.io.XMLEncryptUtils; import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; @@ -48,7 +49,7 @@ public class VcsCacheFileNodeFile extends FileNodeFILE { ); return envPath.endsWith(".cpt") || envPath.endsWith(".frm") - ? XMLEncryptUtils.decodeInputStream(in) : in; + ? XMLEncryptUtils.decodeInputStream(FineEncryptUtils.decode(in)) : in; } diff --git a/designer-base/src/main/java/com/fr/design/os/impl/PopupDialogSaveAction.java b/designer-base/src/main/java/com/fr/design/os/impl/PopupDialogSaveAction.java new file mode 100644 index 0000000000..019ee3d97e --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/os/impl/PopupDialogSaveAction.java @@ -0,0 +1,39 @@ +package com.fr.design.os.impl; + +import com.fr.design.gui.controlpane.UIListControlPane; +import com.fr.stable.os.OperatingSystem; +import com.fr.stable.os.support.OSBasedAction; + +import java.awt.*; + +/** + * linux下超链弹窗等保存问题 + * + * @author hades + * @version 10.0 + * Created by hades on 2020/7/21 + */ +public class PopupDialogSaveAction implements OSBasedAction { + + private UIListControlPane currentControlPane; + private Window popupDialog; + + @Override + public void execute(Object... objects) { + boolean canSave = OperatingSystem.isLinux() && popupDialog != null && popupDialog.isVisible() && currentControlPane != null; + if (canSave) { + currentControlPane.saveSettings(); + } + } + + public void register(UIListControlPane currentControlPane, Window popupDialog) { + this.currentControlPane = currentControlPane; + this.popupDialog = popupDialog; + } + + public void unregister() { + this.currentControlPane = null; + this.popupDialog = null; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java b/designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java index 366e7d565c..88fe2a2758 100644 --- a/designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java +++ b/designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java @@ -117,6 +117,13 @@ public enum SupportOSImpl implements SupportOS { public boolean support() { return OperatingSystem.isWindows(); } + }, + + KOREAN_INPUT { + @Override + public boolean support() { + return OperatingSystem.isWindows(); + } } } diff --git a/designer-base/src/main/java/com/fr/design/os/impl/UpdateDialogAction.java b/designer-base/src/main/java/com/fr/design/os/impl/UpdateDialogAction.java index 64f8f21120..f71493cd6b 100644 --- a/designer-base/src/main/java/com/fr/design/os/impl/UpdateDialogAction.java +++ b/designer-base/src/main/java/com/fr/design/os/impl/UpdateDialogAction.java @@ -2,8 +2,6 @@ package com.fr.design.os.impl; import com.fr.design.mainframe.DesignerContext; import com.fr.design.update.ui.dialog.UpdateMainDialog; -import com.fr.design.utils.DesignUtils; -import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.support.OSBasedAction; /** @@ -12,14 +10,10 @@ import com.fr.stable.os.support.OSBasedAction; * @date 2019/10/9 */ public class UpdateDialogAction implements OSBasedAction { - private static String UPDATE_ROUTE = "#management/backup"; + @Override public void execute(Object... objects) { - if(!OperatingSystem.isLinux()) { - UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame()); - dialog.showDialog(); - }else{ - DesignUtils.visitEnvServerByParameters( UPDATE_ROUTE,null,null); - } + UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame()); + dialog.showDialog(); } } diff --git a/designer-base/src/main/java/com/fr/design/parameter/ParameterDesignerProvider.java b/designer-base/src/main/java/com/fr/design/parameter/ParameterDesignerProvider.java index abd27f89bf..efafa7cb2e 100644 --- a/designer-base/src/main/java/com/fr/design/parameter/ParameterDesignerProvider.java +++ b/designer-base/src/main/java/com/fr/design/parameter/ParameterDesignerProvider.java @@ -50,6 +50,10 @@ public interface ParameterDesignerProvider { void addingAllParameter2Editor(Parameter[] parameterArray, int currentIndex); + default int addingAllParameter2EditorWithReturnValue(Parameter[] parameterArray, int currentIndex) { + return 0; + } + JPanel[] toolbarPanes4Form(); JComponent[] toolBarButton4Form(); diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java index efeffa4e49..46d1b9165b 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java +++ b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java @@ -11,6 +11,7 @@ import com.fr.design.style.color.ColorSelectDialog; import com.fr.design.style.color.ColorSelectable; import com.fr.stable.AssistUtils; +import com.fr.stable.os.OperatingSystem; import javax.swing.JComponent; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -124,14 +125,20 @@ public class GradientBar extends JComponent implements UIObserver, ColorSelectab protected void addMouseDragListener() { this.addMouseMotionListener(new MouseAdapter() { public void mouseDragged(MouseEvent e) { - + int oldIndex = index; for (int i = 0; i < list.size(); i++) { if (list.get(i).contains(e.getX(), e.getY())) { index = i; break; } } - + if(OperatingSystem.isLinux() && AssistUtils.equals(oldIndex,index)){ + if(Math.abs(p1.getX() - e.getX()) > Math.abs(p2.getX() - e.getX())){ + index = 1; + }else{ + index = 0; + } + } boolean x = e.getX() <= max && e.getX() >= min; if (x && e.getY() < MAX_VERTICAL) { list.get(index).setX(e.getX()); diff --git a/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java b/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java index 827a39fd39..bf874c632f 100644 --- a/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java +++ b/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java @@ -24,6 +24,8 @@ public class RecoverForDesigner implements Recover { private final String installHome = StableUtils.getInstallHome(); + private static final String HYPHEN = "-"; + @Override public boolean recover() { try{ @@ -41,7 +43,8 @@ public class RecoverForDesigner implements Recover { @Override public boolean backup() { //jar包备份文件的目录为"backup/"+jar包当前版本号 - String todayBackupDir = StableUtils.pathJoin(installHome, UpdateConstants.DESIGNER_BACKUP_DIR, (GeneralUtils.readBuildNO())); + String versionBuildNo = GeneralUtils.getVersion() + HYPHEN + GeneralUtils.readBuildNO(); + String todayBackupDir = StableUtils.pathJoin(installHome, UpdateConstants.DESIGNER_BACKUP_DIR, versionBuildNo); String envHome = ProjectLibrary.getInstance().getLibHome(); backupFilesFromInstallEnv(envHome, todayBackupDir); backupFilesFromInstallLib(installHome, todayBackupDir); diff --git a/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateDialog.java b/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateDialog.java index d35b1dd543..e37877a4bb 100644 --- a/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateDialog.java @@ -79,7 +79,7 @@ class DesignerPushUpdateDialog extends UIDialog { private Model createModel(DesignerUpdateInfo updateInfo) { Model model = new Model(); - model.setVersion(updateInfo.getLatestVersion()); + model.setVersion(updateInfo.getLatestFullVersion()); model.setContent(updateInfo.getPushContent()); model.setMoreInfoUrl(updateInfo.getMoreInfoUrl()); model.setBackgroundUrl(updateInfo.getBackgroundUrl()); diff --git a/designer-base/src/main/java/com/fr/design/update/push/DesignerUpdateInfo.java b/designer-base/src/main/java/com/fr/design/update/push/DesignerUpdateInfo.java index 5d5e02a47f..3f7c23cd30 100644 --- a/designer-base/src/main/java/com/fr/design/update/push/DesignerUpdateInfo.java +++ b/designer-base/src/main/java/com/fr/design/update/push/DesignerUpdateInfo.java @@ -1,7 +1,12 @@ package com.fr.design.update.push; +import com.fr.general.CloudCenter; import com.fr.general.ComparatorUtils; +import com.fr.general.http.HttpToolbox; +import com.fr.json.JSON; +import com.fr.json.JSONFactory; import com.fr.json.JSONObject; +import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import java.security.InvalidParameterException; @@ -14,9 +19,12 @@ class DesignerUpdateInfo { private static final String KEY_CONTENT = "content"; private static final String KEY_BACKGROUND_URL = "background"; private static final String KEY_MORE_INFO_URL = "more"; + private static final String SPLIT_CHAR = "-"; + private final String currentVersion; // 当前版本 private final String latestVersion; // 最新版本 + private final String latestFullVersion; // 最新版本的完整信息 private final String lastIgnoredVersion; // 最近一次跳过的版本 private final String pushVersion; // 推送版本 @@ -27,6 +35,7 @@ class DesignerUpdateInfo { DesignerUpdateInfo(String currentVersion, String latestVersion, String lastIgnoredVersion, JSONObject pushData) { this.currentVersion = currentVersion; this.latestVersion = latestVersion; + this.latestFullVersion = initLatestFullVersion(); this.lastIgnoredVersion = lastIgnoredVersion; this.pushVersion = pushData.optString(KEY_VERSION); @@ -58,6 +67,30 @@ class DesignerUpdateInfo { return latestVersion; } + String initLatestFullVersion() { + try { + String url = CloudCenter.getInstance().acquireUrlByKind("jar10.new.update"); + if (StringUtils.isBlank(url)) { + return StringUtils.EMPTY; + } + String res = HttpToolbox.get(url); + if (StringUtils.isBlank(res)) { + return StringUtils.EMPTY; + } + JSONObject jsonObject = JSONFactory.createJSON(JSON.OBJECT, res); + String version = jsonObject.getString("version"); + String build = jsonObject.getString("build"); + return version + SPLIT_CHAR + build; + } catch (Throwable e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return StringUtils.EMPTY; + } + + String getLatestFullVersion() { + return latestFullVersion; + } + String getLastIgnoredVersion() { return lastIgnoredVersion; } diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java index 78df599c57..3992be6a91 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java @@ -29,6 +29,7 @@ import com.fr.general.*; import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; import com.fr.json.JSONObject; +import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; import com.fr.process.engine.core.FineProcessContext; import com.fr.process.engine.core.FineProcessEngineEvent; @@ -80,6 +81,8 @@ public class UpdateMainDialog extends UIDialog { private static final String UPDATE_CACHE_STATE_FAIL = "fail"; private static final String UPDATE_CACHE_STATE_SUCCESS = "success"; + private static final String HYPHEN = "-"; + private final SimpleDateFormat CHANGELOG_FORMAT = new SimpleDateFormat("M/d/y, h:m:s a", Locale.ENGLISH); private final SimpleDateFormat UPDATE_INFO_TABLE_FORMAT = new SimpleDateFormat("yyyy.MM.dd"); @@ -303,8 +306,9 @@ public class UpdateMainDialog extends UIDialog { new UILabel(UpdateConstants.DEFAULT_APP_NAME + StringUtils.BLANK + ProductConstants.VERSION) ); - - jarCurrentLabel = new UILabel(StringUtils.isEmpty(GeneralUtils.readBuildNO()) ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Not_Install_Version") : GeneralUtils.readBuildNO(), SwingConstants.CENTER); + String notInstallVersion = InterProviderFactory.getProvider().getLocText("Fine-Core_Basic_About_No_Build"); + String versionBuildNo = GeneralUtils.getVersion() + HYPHEN + GeneralUtils.readBuildNO(); + jarCurrentLabel = new UILabel(ComparatorUtils.equals(notInstallVersion, GeneralUtils.readBuildNO()) ? notInstallVersion : versionBuildNo, SwingConstants.CENTER); UILabel noJarPreviousRevision = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_No_Previous_Version")); UpdateActionLabel jarRestorePreviousRevision = new UpdateActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Restore"), false); jarRestorePreviousRevision.setForeground(new Color(RESTORE_LABEL_COLOR)); diff --git a/designer-base/src/main/java/com/fr/design/utils/ParameterUtils.java b/designer-base/src/main/java/com/fr/design/utils/ParameterUtils.java new file mode 100644 index 0000000000..b50e9950e1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/utils/ParameterUtils.java @@ -0,0 +1,61 @@ +package com.fr.design.utils; + +import com.fr.base.Parameter; +import com.fr.base.ParameterHelper; +import com.fr.general.ComparatorUtils; +import com.fr.stable.ArrayUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +/** + * @Author: Yuan.Wang + * @Date: 2020/8/11 + */ +public class ParameterUtils { + /** + * 获得新的参数集合,返回的集合中的参数的顺序为:新增参数全部放在后面,以保证原有参数的相对顺序 + * + * @param paramTexts sql语句 + * @param oldParameters 旧的参数集合 + * @return 新参数集合 + */ + public static Parameter[] analyzeAndUnionParameters(String[] paramTexts, Parameter[] oldParameters) { + Parameter[] newParameters = ParameterHelper.analyze4Parameters(paramTexts, false); + return unionParametersInRelativeOrder(oldParameters, newParameters); + } + + /** + * 合并新旧参数集合,新增参数全部放在后面,以保证原有参数的相对顺序 + * + * @param oldParameters 旧的参数集合 + * @param newParameters 新的参数集合 + * @return 新参数集合 + */ + private static Parameter[] unionParametersInRelativeOrder(Parameter[] oldParameters, Parameter[] newParameters) { + if (ArrayUtils.isEmpty(newParameters) || ArrayUtils.isEmpty(oldParameters)) { + return newParameters; + } + + Parameter[] result = new Parameter[newParameters.length]; + List newParameterList = new ArrayList<>(Arrays.asList(newParameters)); + int i = 0; + //遍历旧参数数组中的参数,如果新参数list中存在同名参数,将该参数加入到result里,同时删除list中的同名参数 + for (Parameter oldParameter : oldParameters) { + Iterator iterator = newParameterList.listIterator(); + while (iterator.hasNext()) { + Parameter newParameter = iterator.next(); + if (ComparatorUtils.equals(oldParameter.getName(), newParameter.getName())) { + result[i++] = oldParameter; + iterator.remove(); + break; + } + } + } + //将新参数list中的剩余参数添加到result中 + System.arraycopy(newParameterList.toArray(new Parameter[0]), 0, result, i, newParameterList.size()); + return result; + } +} diff --git a/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java index 9134d6429f..efee9bfdfc 100644 --- a/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java +++ b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java @@ -59,10 +59,13 @@ public class CheckServiceDialog extends JDialog implements ActionListener { label.setPreferredSize(new Dimension(650,30)); String text = Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Local_Designer") + localBranch - + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") + remoteBranch; + + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") + + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Is_Old") + + localBranch; String delimiter = DisplayUtils.getDisplayLength(text) > 70? "
":"/"; JLabel label2 = new JLabel(""+Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Local_Designer") - + localBranch + delimiter + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") + remoteBranch+""); + + localBranch + delimiter + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") + + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Is_Old")+ localBranch +""); label2.setPreferredSize(new Dimension(600,30)); JTextPane tipsPane = new JTextPane(); diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index 3c481ba303..37c4cd41a1 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -44,6 +44,7 @@ import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; +import java.util.function.Supplier; import static com.fr.design.layout.TableLayout.FILL; import static com.fr.design.layout.TableLayout.PREFERRED; @@ -439,20 +440,29 @@ public class RemoteEnvPane extends BasicBeanPane { * 设置 app 和 servlet 默认值 */ private void setDefaultAppAndServlet() { - String appName; - String servletName; - try { - appName = FRContext.getCommonOperator().getAppName(); - } catch (Exception ignored) { - appName = RemoteWorkspaceURL.DEFAULT_WEB_APP_NAME; - } - try { - servletName = ServerConfig.getInstance().getServletName(); - } catch (Exception ignored) { - servletName = RemoteWorkspaceURL.DEFAULT_SERVLET_NAME; - } - webAppNameInput.setText(appName); - servletNameInput.setText(servletName); + setWrap(webAppNameInput, () -> FRContext.getCommonOperator().getAppName(), RemoteWorkspaceURL.DEFAULT_WEB_APP_NAME); + setWrap(servletNameInput, () -> ServerConfig.getInstance().getServletName(), RemoteWorkspaceURL.DEFAULT_SERVLET_NAME); + } + + private void setWrap(final UITextField textField, final Supplier supplier, final String defaultName) { + new SwingWorker() { + + @Override + protected String doInBackground() throws Exception { + return supplier.get(); + } + + @Override + protected void done() { + String name = defaultName; + try { + name = get(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage() , e); + } + textField.setText(name); + } + }.execute(); } diff --git a/designer-base/src/main/java/com/fr/file/FileFILE.java b/designer-base/src/main/java/com/fr/file/FileFILE.java index c4f58fa1a3..fca6835bff 100644 --- a/designer-base/src/main/java/com/fr/file/FileFILE.java +++ b/designer-base/src/main/java/com/fr/file/FileFILE.java @@ -1,5 +1,6 @@ package com.fr.file; +import com.fr.io.FineEncryptUtils; import com.fr.base.io.XMLEncryptUtils; import com.fr.design.gui.itree.filetree.FileComparator; import com.fr.design.gui.itree.filetree.FileTreeIcon; @@ -186,7 +187,7 @@ public class FileFILE implements FILE { public InputStream asInputStream() throws Exception { InputStream in = new java.io.FileInputStream(file); return file.getName().endsWith(".cpt") || file.getName().endsWith(".frm") - ? XMLEncryptUtils.decodeInputStream(EncryptUtils.decodeInputStream(in)) : in; + ? XMLEncryptUtils.decodeInputStream(EncryptUtils.decodeInputStream(FineEncryptUtils.decode(in))) : in; } /** diff --git a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java index 138cfe3456..b033d229b9 100644 --- a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java @@ -2,6 +2,7 @@ package com.fr.file; import com.fr.base.BaseUtils; import com.fr.base.FRContext; +import com.fr.io.FineEncryptUtils; import com.fr.base.io.XMLEncryptUtils; import com.fr.design.file.NodeAuthProcessor; import com.fr.design.gui.itree.filetree.FileNodeComparator; @@ -388,7 +389,7 @@ public class FileNodeFILE implements FILE { ); return envPath.endsWith(".cpt") || envPath.endsWith(".frm") - ? XMLEncryptUtils.decodeInputStream(EncryptUtils.decodeInputStream(in)) : in; + ? XMLEncryptUtils.decodeInputStream(EncryptUtils.decodeInputStream(FineEncryptUtils.decode(in))) : in; } /** diff --git a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java index 0783721832..7e95c48d27 100644 --- a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java +++ b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java @@ -2,12 +2,18 @@ package com.fr.start.server; import com.fr.concurrent.NamedThreadFactory; import com.fr.design.gui.iprogressbar.ProgressDialog; +import com.fr.design.i18n.Toolkit; +import com.fr.design.locale.impl.SupportLocaleImpl; import com.fr.design.mainframe.DesignerContext; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; import com.fr.event.Null; +import com.fr.general.FRFont; +import com.fr.general.locale.LocaleAction; +import com.fr.general.locale.LocaleCenter; +import javax.swing.plaf.ColorUIResource; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -27,6 +33,11 @@ public class FineEmbedServerMonitor { private static final int STEP_HEARTBEAT = 40; private static volatile FineEmbedServerMonitor monitor; private static ProgressDialog progressBar = DesignerContext.getDesignerFrame().getProgressDialog(); + //由于默认值的字体不支持韩文,所以要对韩文单独生成字体 + private FRFont font = null; + private static final int FONT_RGB = 333334; + private static final int FONT_SIZE = 14; + private static final String FONT_NAME = "Dialog"; private FineEmbedServerMonitor() { } @@ -86,8 +97,15 @@ public class FineEmbedServerMonitor { } if (!DesignerContext.getDesignerFrame().getProgressDialog().isVisible()) { DesignerContext.getDesignerFrame().showProgressDialog(); - DesignerContext.getDesignerFrame().getProgressDialog() - .updateLoadingText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Embed_Server")); + //如果为韩文则改变字体 + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + font = FRFont.getInstance().applySize(FONT_SIZE).applyForeground(new ColorUIResource(FONT_RGB)).applyName(FONT_NAME); + } + }, SupportLocaleImpl.SUPPORT_KOREA); + String text = Toolkit.i18nText("Fine-Design_Basic_Loading_Embed_Server"); + DesignerContext.getDesignerFrame().getProgressDialog().updateLoadingText(text, font); } DesignerContext.getDesignerFrame().updateProgress(getProgress()); } diff --git a/designer-base/src/main/resources/com/fr/design/images/bbs/support.png b/designer-base/src/main/resources/com/fr/design/images/bbs/support.png new file mode 100644 index 0000000000..a19c313c67 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/bbs/support.png differ diff --git a/designer-base/src/main/resources/com/fr/design/ui/update/push/pushUpdate.css b/designer-base/src/main/resources/com/fr/design/ui/update/push/pushUpdate.css index 58c03ecba5..f8a9eb7133 100644 --- a/designer-base/src/main/resources/com/fr/design/ui/update/push/pushUpdate.css +++ b/designer-base/src/main/resources/com/fr/design/ui/update/push/pushUpdate.css @@ -1,6 +1,6 @@ body { padding-left: 30px; - padding-top: 30px; + padding-top: 25px; color: white; background-size: 100% 100% !important; -moz-background-size: 100% 100% !important; diff --git a/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java b/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java index c82423daa3..4ac71b5ac0 100644 --- a/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java +++ b/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java @@ -22,4 +22,12 @@ public class FormulaPaneTest extends TestCase { Assert.assertArrayEquals(result, strs); } -} \ No newline at end of file + @Test + public void test4SimilarComparator() { + String[] strs = new String[]{"TESTB", "TESTACD", "Ftest", "Gtest", "TEST"}; + String[] result = new String[]{"TEST", "TESTACD", "TESTB", "Ftest", "Gtest"}; + Arrays.sort(strs, new FormulaPane.SimilarComparator("test")); + Assert.assertArrayEquals(result, strs); + } + +} diff --git a/designer-base/src/test/java/com/fr/design/mainframe/JFormSliderPaneTest.java b/designer-base/src/test/java/com/fr/design/mainframe/JFormSliderPaneTest.java new file mode 100644 index 0000000000..697bc89381 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/mainframe/JFormSliderPaneTest.java @@ -0,0 +1,39 @@ +package com.fr.design.mainframe; + +import com.fr.invoke.Reflect; +import org.junit.Assert; +import org.junit.Test; + +/** + * Created by kerry on 2020-07-28 + */ +public class JFormSliderPaneTest { + + + @Test + public void testGetPreferredValue() { + JFormSliderPane sliderPane = new JFormSliderPane(); + int result = Reflect.on(sliderPane).call("getPreferredValue", 100).get(); + Assert.assertEquals(100, result); + result = Reflect.on(sliderPane).call("getPreferredValue", 0).get(); + Assert.assertEquals(10, result); + result = Reflect.on(sliderPane).call("getPreferredValue", 1000).get(); + Assert.assertEquals(400, result); + } + + @Test + public void testCalSliderValue() { + JFormSliderPane sliderPane = new JFormSliderPane(); + int result = Reflect.on(sliderPane).call("calSliderValue", 10).get(); + Assert.assertEquals(0, result); + result = Reflect.on(sliderPane).call("calSliderValue", 90).get(); + Assert.assertEquals(44, result); + result = Reflect.on(sliderPane).call("calSliderValue", 100).get(); + Assert.assertEquals(50, result); + result = Reflect.on(sliderPane).call("calSliderValue", 200).get(); + Assert.assertEquals(66, result); + result = Reflect.on(sliderPane).call("calSliderValue", 400).get(); + Assert.assertEquals(100, result); + + } +} diff --git a/designer-base/src/test/java/com/fr/design/utils/ParameterUtilsTest.java b/designer-base/src/test/java/com/fr/design/utils/ParameterUtilsTest.java new file mode 100644 index 0000000000..26a470e34d --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/utils/ParameterUtilsTest.java @@ -0,0 +1,38 @@ +package com.fr.design.utils; + +import com.fr.base.Parameter; +import junit.framework.TestCase; + +/** + * @Author: Yuan.Wang + * @Date: 2020/8/11 + */ +public class ParameterUtilsTest extends TestCase { + public void testAnalyzeAndUnionParameters() { + String[] paramTexts = {"${a}${b}${d}", ""}; + Parameter[] oldParameters = new Parameter[]{new Parameter("c"), new Parameter("b"), new Parameter("a")}; + Parameter[] rightResult = new Parameter[]{new Parameter("b"), new Parameter("a"), new Parameter("d")}; + Parameter[] result = ParameterUtils.analyzeAndUnionParameters(paramTexts, oldParameters); + assertEquals(result.length, rightResult.length); + for (int i = 0; i < rightResult.length; i++) { + assertEquals(rightResult[i].getName(), result[i].getName()); + } + + paramTexts = new String[]{"${a}${b}${d}", ""}; + oldParameters = new Parameter[]{}; + rightResult = new Parameter[]{new Parameter("a"), new Parameter("b"), new Parameter("d")}; + result = ParameterUtils.analyzeAndUnionParameters(paramTexts, oldParameters); + assertEquals(result.length,rightResult.length); + + paramTexts = new String[]{"${b}", ""}; + oldParameters = new Parameter[]{new Parameter("b"), new Parameter("a"), new Parameter("d")}; + rightResult = new Parameter[]{new Parameter("b")}; + result = ParameterUtils.analyzeAndUnionParameters(paramTexts, oldParameters); + assertEquals(result.length,rightResult.length); + assertEquals(result.length, rightResult.length); + for (int i = 0; i < rightResult.length; i++) { + assertEquals(rightResult[i].getName(), result[i].getName()); + } + + } +} diff --git a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java index 8480d24647..b50c740a32 100644 --- a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java @@ -49,6 +49,7 @@ import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.PiePlot4VanChart; import com.fr.plugin.chart.area.VanChartAreaPlot; +import com.fr.plugin.chart.box.VanChartBoxPlot; import com.fr.plugin.chart.bubble.VanChartBubblePlot; import com.fr.plugin.chart.column.VanChartColumnPlot; import com.fr.plugin.chart.custom.VanChartCustomPlot; @@ -79,6 +80,7 @@ import com.fr.stable.StringUtils; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import com.fr.van.chart.area.AreaIndependentVanChartInterface; import com.fr.van.chart.bar.BarIndependentVanChartInterface; +import com.fr.van.chart.box.BoxIndependentVanChartInterface; import com.fr.van.chart.bubble.BubbleIndependentVanChartInterface; import com.fr.van.chart.column.VanColumnChartTypeUI; import com.fr.van.chart.custom.CustomIndependentVanChartInterface; @@ -202,6 +204,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr addChartTypeInterface(VAN_CHART_PRIORITY, VanChartWordCloudPlot.WORD_CLOUD_PLOT_ID, new WordCloudIndependentVanChartInterface()); addChartTypeInterface(VAN_CHART_PRIORITY, VanChartGanttPlot.VAN_CHART_GANTT_PLOT_ID, new GanttIndependentVanChartInterface()); addChartTypeInterface(VAN_CHART_PRIORITY, VanChartStructurePlot.STRUCTURE_PLOT_ID, new VanStructureChartTypeUI()); + addChartTypeInterface(VAN_CHART_PRIORITY, VanChartBoxPlot.VAN_CHART_BOX_PLOT_ID, new BoxIndependentVanChartInterface()); } diff --git a/designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java b/designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java index 6e347d34b0..a9dbb0b132 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java +++ b/designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java @@ -1,85 +1,29 @@ package com.fr.design.chart; import com.fr.base.chart.BaseChartPainter; -import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.base.chart.result.WebChartIDInfo; -import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; -import com.fr.design.ChartTypeInterfaceManager; -import com.fr.design.file.HistoryTemplateListCache; import com.fr.script.Calculator; -import javax.swing.Icon; -import java.awt.Color; -import java.awt.Component; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Paint; - /** * @author Bjorn * @version 10.0 * Created by Bjorn on 2020-05-29 */ -public class AutoChartIcon implements Icon { +public class AutoChartIcon extends ChartIcon { private static final int WIDTH = 500; private static final int HEIGHT = 281; - private ChartCollection chartCollection; - private CallbackEvent callbackEvent; - - private String chartName; - public AutoChartIcon(ChartCollection chartCollection) { - this.chartCollection = chartCollection; - initChartName(); - } - - public ChartCollection getChartCollection() { - return chartCollection; + super(chartCollection); } - public String getChartName() { - return chartName; - } - - private void initChartName() { - Chart chart = chartCollection.getSelectedChart(Chart.class); - String[] subName = ChartTypeInterfaceManager.getInstance().getSubName(chart.getPlot().getPlotID()); - chartName = subName[0]; - } - - public void registerCallBackEvent(CallbackEvent callbackEvent) { - this.callbackEvent = callbackEvent; - } - - /** - * 画出缩略图Icon - * - * @param g 图形的上下文 - * @param c 所在的Component - * @param x 缩略图的起始坐标x - * @param y 缩略图的起始坐标y - */ @Override - public void paintIcon(Component c, Graphics g, int x, int y) { - - BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(), + protected BaseChartPainter getChartPainter() { + BaseChartPainter painter = getChartCollection().createResultChartPainterWithOutDealFormula(Calculator.createCalculator(), WebChartIDInfo.createAutoTypeInfo(), getIconWidth(), getIconHeight()); - - int resolution = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getJTemplateResolution(); - - Graphics2D g2d = (Graphics2D) g; - Paint oldPaint = g2d.getPaint(); - g.translate(x, y); - g2d.setPaint(Color.white); - g2d.fillRect(0, 0, getIconWidth(), getIconHeight()); - - painter.paint(g2d, getIconWidth(), getIconHeight(), resolution, null, callbackEvent); - - g.translate(-x, -y); - g2d.setPaint(oldPaint); + return painter; } /** diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java b/designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java index 098b965d06..0cd81f783e 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java @@ -6,9 +6,7 @@ import com.fr.design.actions.core.ActionFactory; import com.fr.design.chart.gui.ChartComponent; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.mainframe.ChartPropertyPane; -import com.fr.design.module.ChartEmptyDataStyleAction; import com.fr.design.module.ChartHyperlinkGroup; -import com.fr.design.module.ChartPreStyleAction; import com.fr.design.module.DesignModuleFactory; import com.fr.form.ui.ChartEditor; import com.fr.locale.InterMutableKey; @@ -20,7 +18,6 @@ import com.fr.plugin.chart.vanchart.export.ImagePainter; import com.fr.stable.bridge.StableFactory; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import com.fr.van.chart.DownloadOnlineSourcesHelper; -import com.fr.van.chart.map.server.ChartMapEditorAction; /** * Created by juhaoyu on 2018/6/27. @@ -43,10 +40,6 @@ public class ChartDesignerActivator extends Activator implements Prepare { DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class); - ActionFactory.registerChartPreStyleAction(new ChartPreStyleAction()); - ActionFactory.registerChartEmptyDataStyleAction(new ChartEmptyDataStyleAction()); - ActionFactory.registerChartMapEditorAction(new ChartMapEditorAction()); - ActionFactory.registerChartCollection(ChartCollection.class); DesignModuleFactory.registerExtraWidgetOptions(ChartTypeInterfaceManager.initWidgetOption()); diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartIcon.java b/designer-chart/src/main/java/com/fr/design/chart/ChartIcon.java index 854505d630..16e13db70b 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartIcon.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartIcon.java @@ -1,8 +1,13 @@ package com.fr.design.chart; -import com.fr.base.GraphHelper; -import com.fr.general.IOUtils; -import com.fr.stable.Constants; +import com.fr.base.chart.BaseChartPainter; +import com.fr.base.chart.chartdata.CallbackEvent; +import com.fr.base.chart.result.WebChartIDInfo; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chartx.attr.ChartProvider; +import com.fr.design.ChartTypeInterfaceManager; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.script.Calculator; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLable; import com.fr.stable.xml.XMLableReader; @@ -13,7 +18,6 @@ import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Paint; -import java.awt.image.BufferedImage; /** * 图表的缩略图Icon, 在选择图表类型界面 用到. @@ -21,21 +25,47 @@ import java.awt.image.BufferedImage; public class ChartIcon implements Icon, XMLable { private static final int WIDTH = 400; private static final int HEIGHT = 225; - /** - * 缩略图中的图片路径 - */ - private String imagePath; + + + private ChartCollection chartCollection; + private CallbackEvent callbackEvent; private String chartName; /** * 构造Chart的缩略图Icon */ - public ChartIcon(String imagePath, String chartName) { - this.imagePath = imagePath; + public ChartIcon(ChartCollection chartCollection) { + this.chartCollection = chartCollection; + initChartName(); + } + + public ChartCollection getChartCollection() { + return chartCollection; + } + + public String getChartName() { + return chartName; + } + + public void setChartCollection(ChartCollection chartCollection) { + this.chartCollection = chartCollection; + } + + public void setChartName(String chartName) { this.chartName = chartName; } + private void initChartName() { + ChartProvider chart = chartCollection.getSelectedChartProvider(ChartProvider.class); + String[] subName = ChartTypeInterfaceManager.getInstance().getSubName(chart.getID()); + chartName = subName[0]; + } + + public void registerCallBackEvent(CallbackEvent callbackEvent) { + this.callbackEvent = callbackEvent; + } + /** * 画出缩略图Icon * @@ -47,21 +77,29 @@ public class ChartIcon implements Icon, XMLable { @Override public void paintIcon(Component c, Graphics g, int x, int y) { - Graphics2D g2d = (Graphics2D) g; + BaseChartPainter chartPainter = getChartPainter(); - Paint oldPaint = g2d.getPaint(); + int resolution = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getJTemplateResolution(); + Graphics2D g2d = (Graphics2D) g; + Paint oldPaint = g2d.getPaint(); g.translate(x, y); g2d.setPaint(Color.white); - g2d.fillRect(0, 0, getIconWidth(), getIconHeight()); - BufferedImage demoImage = IOUtils.readImageWithCache(imagePath); - GraphHelper.paintImage(g, getIconWidth(), getIconHeight(), demoImage, Constants.IMAGE_ADJUST, Constants.NULL, Constants.NULL, -1, -1); + + chartPainter.paint(g2d, getIconWidth(), getIconHeight(), resolution, null, callbackEvent); g.translate(-x, -y); g2d.setPaint(oldPaint); } + protected BaseChartPainter getChartPainter() { + BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(), + WebChartIDInfo.createEmptyDesignerInfo(), getIconWidth(), getIconHeight()); + return painter; + } + + /** * 返回缩略图的宽度 * @@ -83,20 +121,6 @@ public class ChartIcon implements Icon, XMLable { } - /** - * 返回缩略图中的图片路径 - * - * @return 缩略图中的图片路径 - */ - public String getImagePath() { - return imagePath; - } - - public String getChartName() { - return chartName; - } - - @Override public void readXML(XMLableReader reader) { //do nothing @@ -114,8 +138,11 @@ public class ChartIcon implements Icon, XMLable { @Override public Object clone() throws CloneNotSupportedException { ChartIcon cloned = (ChartIcon) super.clone(); - cloned.imagePath = this.imagePath; - cloned.chartName = this.chartName; + if (getChartCollection() != null) { + cloned.setChartCollection(this.getChartCollection()); + } + cloned.setChartName(this.getChartName()); + ; return cloned; } diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java index 2bb9a99f22..a5937c1d9d 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java @@ -3,6 +3,7 @@ package com.fr.design.chart; * the Pane of the Chart */ +import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chartx.attr.ChartProvider; @@ -12,7 +13,6 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.log.FineLoggerFactory; -import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.DefaultListCellRenderer; @@ -23,10 +23,12 @@ import javax.swing.JSplitPane; import javax.swing.ListCellRenderer; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.awt.Color; import java.awt.Component; -public class ChartTypePane extends ChartCommonWizardPane { +public class ChartTypePane extends ChartCommonWizardPane implements CallbackEvent { private static final long serialVersionUID = -1175602484968520546L; private String[] chartIDs = ChartTypeManager.getInstanceWithCheck().getAllChartIDs(); @@ -35,6 +37,8 @@ public class ChartTypePane extends ChartCommonWizardPane { private JList iconViewList = null; private DefaultListModel iconListModel = null; + private static Map map = new ConcurrentHashMap(); + public ChartTypePane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); DefaultListModel defaultListModel = new DefaultListModel(); @@ -96,14 +100,21 @@ public class ChartTypePane extends ChartCommonWizardPane { int main_index = mainTypeList.getSelectedIndex(); String id = ChartTypePane.this.chartIDs[main_index]; - String[] demoImagePath = ChartTypeInterfaceManager.getInstance().getDemoImagePath(id); + ChartProvider[] charts = ChartTypeManager.getInstance().getCharts(id); String[] subName = ChartTypeInterfaceManager.getInstance().getSubName(id); ChartTypePane.this.iconListModel.clear(); - for (int i = 0, len = subName.length; i < len; i++) { - String ImagePath = demoImagePath.length > i ? demoImagePath[i] : StringUtils.EMPTY; - String chartName = subName[i]; - ChartTypePane.this.iconListModel.addElement(new ChartIcon(ImagePath, chartName)); + for (int i = 0, len = charts.length; i < len; i++) { + ChartProvider chart = charts[i]; + if (map.get(chart) == null) { + ChartProvider chartProvider = chart.transformProperties(); + map.put(chart, chartProvider); + } + ChartCollection chartCollection = new ChartCollection(map.get(chart)); + ChartIcon chartIcon = new ChartIcon(chartCollection); + chartIcon.setChartName(subName[i]); + chartIcon.registerCallBackEvent(ChartTypePane.this); + ChartTypePane.this.iconListModel.addElement(chartIcon); } iconViewList.setSelectedIndex(0); } @@ -144,4 +155,9 @@ public class ChartTypePane extends ChartCommonWizardPane { update(chart4Update); } + + @Override + public void callback() { + this.repaint(); + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/chart/auto/AutoTypeCalculate.java b/designer-chart/src/main/java/com/fr/design/chart/auto/AutoTypeCalculate.java index db20af8cfb..c30679e0ee 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/auto/AutoTypeCalculate.java +++ b/designer-chart/src/main/java/com/fr/design/chart/auto/AutoTypeCalculate.java @@ -22,6 +22,8 @@ import com.fr.stable.StringUtils; import java.util.ArrayList; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * @author Bjorn @@ -30,6 +32,15 @@ import java.util.List; */ public class AutoTypeCalculate { + public static Pattern[] dataPatterns; + + static { + Pattern pattern1 = Pattern.compile("^(19|20)\\d{2}$"); + Pattern pattern2 = Pattern.compile("^\\d{4}(0?[1-9]|1[012])$"); + Pattern pattern3 = Pattern.compile("^\\d{4}(0?[1-9]|1[012])(0?[1-9]|[12]\\d|3[01])$"); + dataPatterns = new Pattern[]{pattern1, pattern2, pattern3}; + } + public static List calculateType(String tableName, List columns) { List columnValue = calculateField(tableName, columns); if (columnValue.isEmpty()) { @@ -86,9 +97,29 @@ public class AutoTypeCalculate { return false; } } + //不是日期型数字才是指标 + return !isNumberData(values); + } + + private static boolean isNumberData(List values) { + for (String value : values) { + if (!isNumberData(value)) { + return false; + } + } return true; } + private static boolean isNumberData(String value) { + for (Pattern pattern : dataPatterns) { + Matcher matcher = pattern.matcher(value); + if (matcher.matches()) { + return true; + } + } + return false; + } + private static List calculateField(String tableName, List columns) { NameTableData nameTableData = new NameTableData(tableName); TableDataSource dataSource = TableDataSourceTailor.extractTableData(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget()); 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 e93900ea6f..e4e27b7f49 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 @@ -1,19 +1,18 @@ package com.fr.design.chartx.component; import com.fr.data.util.function.AbstractDataFunction; +import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.chartx.component.correlation.AbstractCorrelationPane; import com.fr.design.chartx.component.correlation.CalculateComboBoxEditorComponent; import com.fr.design.chartx.component.correlation.FieldEditorComponentWrapper; import com.fr.design.chartx.component.correlation.UIComboBoxEditorComponent; import com.fr.design.chartx.component.correlation.UITextFieldEditorComponent; -import com.fr.design.gui.frpane.UIComboBoxPane; +import com.fr.design.chartx.data.DataLayoutHelper; +import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper; import com.fr.extended.chart.UIComboBoxWithNone; @@ -22,19 +21,25 @@ import com.fr.stable.StringUtils; import javax.swing.JPanel; import javax.swing.SwingConstants; -import java.util.ArrayList; -import java.util.List; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import java.awt.BorderLayout; +import java.awt.CardLayout; import java.awt.Component; -import java.awt.Dimension; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.List; /** * Created by shine on 2018/9/12. * 系列名使用字段名or字段值的抽象的pane 支持多种属性结构的存取 */ -public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane { +public abstract class AbstractCustomFieldComboBoxPane extends BasicBeanPane { + + private UIButtonGroup nameOrValue; + private JPanel cardPane; + private CardLayout cardLayout; private AbstractUseFieldValuePane useFieldValuePane; @@ -42,73 +47,43 @@ public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane< private List fieldList = new ArrayList(); - @Override - protected void initLayout() { - this.setLayout(new BorderLayout(0, 6)); - JPanel northPane = new JPanel(new BorderLayout()); - northPane.add(jcb, BorderLayout.CENTER); - UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name_From")); - label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, 20)); - northPane.add(label, BorderLayout.WEST); - this.add(northPane, BorderLayout.NORTH); - this.add(cardPane, BorderLayout.CENTER); - } + public AbstractCustomFieldComboBoxPane() { - @Override - protected List> initPaneList() { useFieldValuePane = createUseFieldValuePane(); customFieldNamePane = createCustomFieldNamePane(); - List> list = new ArrayList>(); - list.add(useFieldValuePane); - list.add(paneWrapper()); - return list; - } - private FurtherBasicBeanPane paneWrapper() { - FurtherBasicBeanPane pane = new FurtherBasicBeanPane() { + nameOrValue = new UIButtonGroup( + new String[]{useFieldValuePane.title4PopupWindow(), customFieldNamePane.title4PopupWindow()}, + new Boolean[]{false, true}); + nameOrValue.setSelectedItem(false); + nameOrValue.addChangeListener(new ChangeListener() { @Override - public String title4PopupWindow() { - return Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Name"); + public void stateChanged(ChangeEvent e) { + checkCardPane(); } + }); + JPanel northPane = DataLayoutHelper.createDataLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Series_Name_From"), nameOrValue); - @Override - public boolean accept(Object ob) { - return false; - } - - @Override - public void reset() { - } + cardLayout = new CardLayout(); + cardPane = new JPanel(cardLayout); + cardPane.add(useFieldValuePane, useFieldValuePane.title4PopupWindow()); + cardPane.add(customFieldNamePane, customFieldNamePane.title4PopupWindow()); - @Override - public void populateBean(Object ob) { - } - - @Override - public Object updateBean() { - return null; - } - }; - pane.setLayout(new BorderLayout(0, 6)); - pane.add(customFieldNamePane, BorderLayout.CENTER); - return pane; + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + this.add(cardPane, BorderLayout.CENTER); } protected abstract AbstractUseFieldValuePane createUseFieldValuePane(); protected abstract AbstractCustomFieldNamePane createCustomFieldNamePane(); - @Override - protected String title4PopupWindow() { - return StringUtils.EMPTY; - } - protected boolean valueComboBoxHasNone() { return false; } public void checkBoxUse(boolean hasUse) { - jcb.setEnabled(hasUse); + nameOrValue.setEnabled(hasUse); useFieldValuePane.checkBoxUse(hasUse); } @@ -122,6 +97,19 @@ public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane< fieldList = columnNameList; } + private void checkCardPane() { + cardLayout.show(cardPane, nameOrValue.getSelectedItem() ? customFieldNamePane.title4PopupWindow() : useFieldValuePane.title4PopupWindow()); + } + + protected void populateNameOrValue(boolean b) { + nameOrValue.setSelectedItem(b); + checkCardPane(); + } + + protected boolean updateNameOrValue() { + return nameOrValue.getSelectedItem(); + } + protected void populateCustomFieldNamePane(T t) { customFieldNamePane.populateBean(t); } @@ -138,6 +126,16 @@ public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane< useFieldValuePane.updateBean(t); } + @Override + public T updateBean() { + return null; + } + + @Override + protected String title4PopupWindow() { + return null; + } + protected abstract class AbstractUseFieldValuePane extends FurtherBasicBeanPane { private UIComboBox series; private UIComboBox value; @@ -169,11 +167,7 @@ public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane< new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Summary_Method"), SwingConstants.LEFT), function}, }; - double p = TableLayout.PREFERRED; - double[] columnSize = {78, 122}; - double[] rowSize = {p, p, p}; - - JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + JPanel panel = DataLayoutHelper.createDataLayoutPane(components); this.setLayout(new BorderLayout(0, 6)); this.add(panel, BorderLayout.CENTER); @@ -258,5 +252,10 @@ public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane< protected Object[] createLine() { return new String[]{StringUtils.EMPTY, StringUtils.EMPTY, Toolkit.i18nText("Fine-Design_Chart_Use_None")}; } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Name"); + } } } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java index 4372cf0db1..e38b3965d4 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java @@ -27,23 +27,21 @@ public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPan @Override public void populateBean(SeriesValueCorrelationDefinition ob) { + populateNameOrValue(ob.isCustomFieldValue()); if (ob.isCustomFieldValue()) { populateCustomFieldNamePane(ob); - jcb.setSelectedIndex(1); } else { populateUseFieldValuePane(ob); - jcb.setSelectedIndex(0); } } @Override public void updateBean(SeriesValueCorrelationDefinition ob) { - if (jcb.getSelectedIndex() == 0) { - ob.setCustomFieldValue(false); - updateUseFieldValuePane(ob); - } else { - ob.setCustomFieldValue(true); + ob.setCustomFieldValue(updateNameOrValue()); + if (ob.isCustomFieldValue()) { updateCustomFieldNamePane(ob); + } else { + updateUseFieldValuePane(ob); } } 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 e7a7ab929b..e09362cb64 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/chartx/data/DataLayoutHelper.java b/designer-chart/src/main/java/com/fr/design/chartx/data/DataLayoutHelper.java new file mode 100644 index 0000000000..98ae28085c --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/data/DataLayoutHelper.java @@ -0,0 +1,69 @@ +package com.fr.design.chartx.data; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; + +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.Component; +import java.util.Arrays; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2020/7/22 + */ +public class DataLayoutHelper { + + public static int WIDTH = 150; + public static int LABEL_HEIGHT = 20; + public static int LABEL_WIDTH = 65; + + public static int LEFT_GAP = 15; + public static int RIGHT_GAP = 10; + + public static void setWIDTH(int WIDTH) { + DataLayoutHelper.WIDTH = WIDTH; + } + + public static void setLabelHeight(int labelHeight) { + LABEL_HEIGHT = labelHeight; + } + + public static void setLabelWidth(int labelWidth) { + LABEL_WIDTH = labelWidth; + } + + public static void setLeftGap(int leftGap) { + LEFT_GAP = leftGap; + } + + public static void setRightGap(int rightGap) { + RIGHT_GAP = rightGap; + } + + public static JPanel createDataLayoutPane(Component[][] components) { + int len = components.length; + double p = TableLayout.PREFERRED; + double[] columnSize = {DataLayoutHelper.LABEL_WIDTH, DataLayoutHelper.WIDTH}; + double[] rowSize = new double[len]; + Arrays.fill(rowSize, p); + + return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + } + + public static JPanel createDataLayoutPane(String label, Component component) { + Component[][] components = new Component[][]{ + new Component[]{new UILabel(label, SwingConstants.LEFT), component} + }; + + return createDataLayoutPane(components); + } + + public static void addNormalBorder(JComponent component) { + component.setBorder(BorderFactory.createEmptyBorder(0, DataLayoutHelper.LEFT_GAP, 0, DataLayoutHelper.RIGHT_GAP)); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/data/map/AbstractAreaLngLatPane.java b/designer-chart/src/main/java/com/fr/design/chartx/data/map/AbstractAreaLngLatPane.java index 09393918a5..53c1cde759 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/data/map/AbstractAreaLngLatPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/data/map/AbstractAreaLngLatPane.java @@ -1,18 +1,15 @@ package com.fr.design.chartx.data.map; +import com.fr.design.chartx.data.DataLayoutHelper; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.chart.gui.ChartDataPane; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import java.util.Arrays; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Component; @@ -67,8 +64,10 @@ public abstract class AbstractAreaLngLatPane extends JPanel { locationType.setSelectedIndex(0); + JPanel northPane = DataLayoutHelper.createDataLayoutPane(Toolkit.i18nText("FR-Plugin_Design_Geographic_Location"), locationType); + this.setLayout(new BorderLayout(0, 6)); - this.add(locationType, BorderLayout.NORTH); + this.add(northPane, BorderLayout.NORTH); this.add(centerPane, BorderLayout.CENTER); } @@ -103,12 +102,8 @@ public abstract class AbstractAreaLngLatPane extends JPanel { for (int i = 0; i < len; i++) { components[i] = new Component[]{new UILabel(labels[i], SwingConstants.LEFT), fieldComponents[i]}; } - double p = TableLayout.PREFERRED; - double[] columnSize = {ChartDataPane.LABEL_WIDTH, 122}; - double[] rowSize = new double[len]; - Arrays.fill(rowSize, p); - return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 6); + return DataLayoutHelper.createDataLayoutPane(components); } } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/data/map/MapChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/data/map/MapChartDataPane.java index fd4790d57d..148bcd7ca2 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/data/map/MapChartDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/data/map/MapChartDataPane.java @@ -38,6 +38,7 @@ public class MapChartDataPane extends AbstractChartDataPane { this.setLayout(new BorderLayout()); this.add(cellDataFieldsPane, BorderLayout.CENTER); + DataLayoutHelper.addNormalBorder(this); } @Override diff --git a/designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java b/designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java index cfb9a2c18a..3df0d3d6d5 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java @@ -3,25 +3,20 @@ package com.fr.design.chartx.single; import com.fr.chartx.data.DataSetDefinition; import com.fr.data.impl.NameTableData; import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.chartx.data.DataLayoutHelper; import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; -import com.fr.design.gui.ilable.BoldFontTextLabel; -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.DatabaseTableDataPane; -import com.fr.design.utils.gui.UIComponentUtils; -import java.util.List; +import javax.swing.JPanel; import java.awt.BorderLayout; -import java.awt.Dimension; +import java.util.List; /** * Created by shine on 2019/5/21. */ public class DataSetPane extends FurtherBasicBeanPane { - private static final int TABLE_DATA_LABEL_LINE_WRAP_WIDTH = 65; - private static final int TABLE_DATA_PANE_WIDTH = 246; private DatabaseTableDataPane tableDataPane; @@ -32,24 +27,27 @@ public class DataSetPane extends FurtherBasicBeanPane { } private void initComps(AbstractDataSetFieldsPane dataSetFieldsPane) { - UILabel label = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data")); - UIComponentUtils.setLineWrap(label, TABLE_DATA_LABEL_LINE_WRAP_WIDTH); - UIComponentUtils.setPreferedWidth(label, ChartDataPane.LABEL_WIDTH); - - tableDataPane = new DatabaseTableDataPane(label) { + tableDataPane = new DatabaseTableDataPane(null) { @Override protected void userEvent() { refreshBoxListAndTableName(); checkBoxUse(); } + + @Override + protected void setBorder() { + } + }; - tableDataPane.setPreferredSize(new Dimension(TABLE_DATA_PANE_WIDTH, tableDataPane.getPreferredSize().height)); + this.dataSetFieldsPane = dataSetFieldsPane; - this.setLayout(new BorderLayout()); - this.add(tableDataPane, BorderLayout.NORTH); + JPanel northPane = DataLayoutHelper.createDataLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Table_Data"), tableDataPane); + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); this.add(dataSetFieldsPane, BorderLayout.CENTER); + DataLayoutHelper.addNormalBorder(this); checkBoxUse(); } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java index dc4dfc65ad..06ed06649b 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java @@ -3,28 +3,22 @@ package com.fr.design.chartx.single; import com.fr.chartx.data.AbstractDataDefinition; import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.chartx.data.DataLayoutHelper; import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; -import com.fr.design.constants.LayoutConstants; import com.fr.design.gui.frpane.UIComboBoxPane; -import com.fr.design.gui.ilable.BoldFontTextLabel; -import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; -import com.fr.design.utils.gui.UIComponentUtils; -import javax.swing.BorderFactory; import javax.swing.JPanel; +import java.awt.BorderLayout; import java.util.ArrayList; import java.util.List; -import java.awt.BorderLayout; /** * Created by shine on 2019/5/21. */ public class SingleDataPane extends BasicBeanPane { - private static final int TABLE_DATA_LABEL_LINE_WIDTH = 81; - private UIComboBoxPane comboBoxPane; private DataSetPane dataSetPane; @@ -50,18 +44,12 @@ public class SingleDataPane extends BasicBeanPane { } protected void initLayout() { - this.setLayout(new BorderLayout(LayoutConstants.HGAP_LARGE, 6)); - JPanel northPane = new JPanel(new BorderLayout(LayoutConstants.HGAP_LARGE, 0)); + this.setLayout(new BorderLayout(0, 6)); + JPanel northPane = DataLayoutHelper.createDataLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Data_Source"), jcb); + DataLayoutHelper.addNormalBorder(northPane); - UILabel label = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Source")); - UIComponentUtils.setPreferedWidth(label, TABLE_DATA_LABEL_LINE_WIDTH); - northPane.add(label,BorderLayout.WEST); - northPane.add(jcb, BorderLayout.CENTER); - - northPane.setBorder(BorderFactory.createEmptyBorder(5,24,0,15)); this.add(northPane, BorderLayout.NORTH); this.add(cardPane, BorderLayout.CENTER); - } @Override diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/ChartDataFilterPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/ChartDataFilterPane.java index 9db2fe7b21..c24a192441 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/ChartDataFilterPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/ChartDataFilterPane.java @@ -9,11 +9,11 @@ import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.style.AbstractChartTabPane; import com.fr.design.mainframe.chart.gui.style.ThirdTabPane; - import com.fr.stable.StringUtils; import com.fr.van.chart.designer.TableLayout4VanChartHelper; @@ -21,12 +21,12 @@ import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import java.util.ArrayList; +import java.util.List; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; import java.awt.FlowLayout; -import java.util.ArrayList; -import java.util.List; /** * 图表数据 分类 系列 过滤界面. @@ -37,7 +37,7 @@ import java.util.List; public class ChartDataFilterPane extends ThirdTabPane { private static final long serialVersionUID = 3650522989381790194L; private static final int PAN_WIDTH = 246; - private static final int FIL_HEIGHT = 150; + private static final int FIL_HEIGHT = 200; private CategoryFilterPane categoryPane; private SeriesFilterPane seriesPane; @@ -50,6 +50,11 @@ public class ChartDataFilterPane extends ThirdTabPane { this.isNeedPresent = true; } + public ChartDataFilterPane(Plot plot, ChartDataPane parent, boolean isNeedPresent) { + super(plot, parent); + this.isNeedPresent = isNeedPresent; + } + protected void initTabPane() { super.initTabPane(); tabPane.setPreferredSize(new Dimension(221, 25)); @@ -109,7 +114,7 @@ public class ChartDataFilterPane extends ThirdTabPane { * @return 返回标题. */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Filter"); + return Toolkit.i18nText("Fine-Design_Chart_Data_Filter"); } /** @@ -144,12 +149,17 @@ public class ChartDataFilterPane extends ThirdTabPane { } public void populateBean(ChartCollection collection, boolean isNeedPresent) { - relayoutPane(isNeedPresent); + TopDefinitionProvider topDefinition = collection.getSelectedChart().getFilterDefinition(); + populateDefinition(topDefinition, isNeedPresent); + } + + public void populateDefinition(TopDefinitionProvider topDefinition, boolean isNeedSummary) { + relayoutPane(isNeedSummary); if (categoryPane != null) { - categoryPane.populateBean(collection.getSelectedChart().getFilterDefinition()); + categoryPane.populateBean(topDefinition); } if (seriesPane != null) { - seriesPane.populateBean(collection.getSelectedChart().getFilterDefinition()); + seriesPane.populateBean(topDefinition); } checkBoxUse(); } @@ -165,11 +175,16 @@ public class ChartDataFilterPane extends ThirdTabPane { * 保存界面数据筛选. */ public void updateBean(ChartCollection collection) { + TopDefinitionProvider topDefinition = collection.getSelectedChart().getFilterDefinition(); + updateDefinition(topDefinition); + } + + public void updateDefinition(TopDefinitionProvider topDefinition) { if (categoryPane != null) { - categoryPane.updateBean(collection.getSelectedChart().getFilterDefinition()); + categoryPane.updateBean(topDefinition); } if (seriesPane != null) { - seriesPane.updateBean(collection.getSelectedChart().getFilterDefinition()); + seriesPane.updateBean(topDefinition); } } @@ -222,13 +237,13 @@ public class ChartDataFilterPane extends ThirdTabPane { } protected JPanel initOtherPane() { - onlyPreData = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Only_Use_Before_Records")); + onlyPreData = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Only_Use_Before_Records")); JPanel panel1 = new JPanel(new BorderLayout()); JPanel panel2 = new JPanel(new BorderLayout()); panel1.add(onlyPreData, BorderLayout.NORTH); preDataNum = new UITextField(); - UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Records_Num")); - combineOther = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_CombineOther")); + UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Records_Num")); + combineOther = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Data_CombineOther")); combineOther.setSelected(true); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; @@ -244,7 +259,7 @@ public class ChartDataFilterPane extends ThirdTabPane { //默认不显示 preDataNumPane.setVisible(false); panel1.add(preDataNumPane, BorderLayout.CENTER); - notShowNull = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Not_Show_Cate")); + notShowNull = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Data_Not_Show_Cate")); panel2.add(notShowNull, BorderLayout.NORTH); onlyPreData.addChangeListener(new ChangeListener() { @@ -258,7 +273,7 @@ public class ChartDataFilterPane extends ThirdTabPane { fire(); } }; - presentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Present") ,present); + presentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Style_Present") ,present); panel2.add(presentPane, BorderLayout.SOUTH); double[] column = {f}; @@ -281,7 +296,7 @@ public class ChartDataFilterPane extends ThirdTabPane { * 界面标题 "分类" */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Category"); + return Toolkit.i18nText("Fine-Design_Chart_Style_Category"); } /** @@ -397,13 +412,13 @@ public class ChartDataFilterPane extends ThirdTabPane { protected JPanel initOtherPane() { - onlyPreData = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Only_Use_Before_Records")); + onlyPreData = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Only_Use_Before_Records")); JPanel panel1 = new JPanel(new BorderLayout()); JPanel panel2 = new JPanel(new BorderLayout()); panel1.add(onlyPreData, BorderLayout.NORTH); preDataNum = new UITextField(); - UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Records_Num")); - combineOther = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_CombineOther")); + UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Records_Num")); + combineOther = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Data_CombineOther")); combineOther.setSelected(true); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; @@ -419,7 +434,7 @@ public class ChartDataFilterPane extends ThirdTabPane { //默认不显示 preDataNumPane.setVisible(false); panel1.add(preDataNumPane, BorderLayout.CENTER); - notShowNull = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Not_Show_Series")); + notShowNull = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Data_Not_Show_Series")); panel2.add(notShowNull, BorderLayout.NORTH); onlyPreData.addChangeListener(new ChangeListener() { @@ -433,7 +448,7 @@ public class ChartDataFilterPane extends ThirdTabPane { fire(); } }; - presentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Present") ,present); + presentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Style_Present") ,present); panel2.add(presentPane, BorderLayout.SOUTH); double[] column = {f}; @@ -457,7 +472,7 @@ public class ChartDataFilterPane extends ThirdTabPane { * 界面标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series"); + return Toolkit.i18nText("Fine-Design_Chart_Series"); } /** diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotReportDataContentPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotReportDataContentPane.java index 68e5881c00..65f8ea01b7 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotReportDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotReportDataContentPane.java @@ -8,6 +8,7 @@ import com.fr.chart.chartdata.NormalReportDataDefinition; import com.fr.chart.chartdata.SeriesDefinition; import com.fr.design.formula.TinyFormulaPane; 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.ChartDataFilterPane; import com.fr.stable.StringUtils; @@ -26,35 +27,35 @@ public class CategoryPlotReportDataContentPane extends AbstractReportDataContent protected TinyFormulaPane categoryName; protected ChartDataFilterPane filterPane; - + public CategoryPlotReportDataContentPane(){ - + } public CategoryPlotReportDataContentPane(ChartDataPane parent) { initEveryPane(); - categoryName = initCategoryBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Category_Name")); + categoryName = initCategoryBox(Toolkit.i18nText("Fine-Design_Chart_Category_Name")); categoryName.setPreferredSize(new Dimension(236,30)); categoryName.setBorder(BorderFactory.createEmptyBorder(0,24,0,20)); this.add(categoryName, "0,0,1,0"); filterPane = new ChartDataFilterPane(new Bar2DPlot(), parent); - JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Filter"),filterPane); + JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"),filterPane); panel.setBorder(getSidesBorder()); filterPane.setBorder(getFilterPaneBorder()); this.add(panel, "0,6,1,4"); } - + protected TinyFormulaPane initCategoryBox(final String leftLabel) { TinyFormulaPane categoryName = new TinyFormulaPane() { @Override protected void initLayout() { this.setLayout(new BorderLayout(4, 0)); - + if(StringUtils.isNotEmpty(leftLabel)) { - UILabel label1 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Category_Name")); + UILabel label1 = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Category_Name")); label1.setPreferredSize(new Dimension(75, 20)); this.add(label1, BorderLayout.WEST); } - + formulaTextField.setPreferredSize(new Dimension(100, 20)); this.add(formulaTextField, BorderLayout.CENTER); this.add(formulaTextFieldButton, BorderLayout.EAST); @@ -83,15 +84,15 @@ public class CategoryPlotReportDataContentPane extends AbstractReportDataContent checkBoxUse(); } }); - + return categoryName; } @Override protected String[] columnNames() { return new String[]{ - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Value") + Toolkit.i18nText("Fine-Design_Chart_Series_Name"), + Toolkit.i18nText("Fine-Design_Chart_Series_Value") }; } @@ -99,6 +100,10 @@ public class CategoryPlotReportDataContentPane extends AbstractReportDataContent checkBoxUse(); TopDefinitionProvider definition = collection.getSelectedChart().getFilterDefinition(); + populateDefinition(definition); + } + + public void populateDefinition(TopDefinitionProvider definition) { if (definition instanceof NormalReportDataDefinition) { NormalReportDataDefinition reportDefinition = (NormalReportDataDefinition) definition; if (reportDefinition.getCategoryName() != null) { @@ -109,20 +114,25 @@ public class CategoryPlotReportDataContentPane extends AbstractReportDataContent populateList(list); } } - + seriesPane.doLayout(); } - filterPane.populateBean(collection); + filterPane.populateDefinition(definition, true); } public void updateBean(ChartCollection collection) { collection.getSelectedChart().setFilterDefinition(new NormalReportDataDefinition()); TopDefinitionProvider definition = collection.getSelectedChart().getFilterDefinition(); + updateDefinition(definition); + } + + public void updateDefinition(TopDefinitionProvider definition) { + if (definition instanceof NormalReportDataDefinition) { NormalReportDataDefinition reportDefinition = (NormalReportDataDefinition) definition; - + reportDefinition.setCategoryName(canBeFormula(categoryName.getUITextField().getText())); List list = updateList(); @@ -135,6 +145,7 @@ public class CategoryPlotReportDataContentPane extends AbstractReportDataContent reportDefinition.add(sd); } } - filterPane.updateBean(collection); + + filterPane.updateDefinition(definition); } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotTableDataContentPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotTableDataContentPane.java index 8c988ce294..7d12e3e52d 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotTableDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotTableDataContentPane.java @@ -11,6 +11,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; +import com.fr.design.i18n.Toolkit; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; @@ -28,24 +29,24 @@ import java.util.List; */ public class CategoryPlotTableDataContentPane extends AbstractTableDataContentPane{ private static final long serialVersionUID = 7284078589672079657L; - + protected UIComboBox categoryCombox; protected SeriesTypeUseComboxPane seriesTypeComboxPane; - + public CategoryPlotTableDataContentPane() { - + } - + public CategoryPlotTableDataContentPane(ChartDataPane parent) { - + categoryCombox = new UIComboBox(); JPanel categoryPane = new JPanel(new BorderLayout(4,0)); categoryPane.setBorder(BorderFactory.createMatteBorder(0, 0, 6, 1, getBackground())); - UILabel label1 = new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Category")) ; + UILabel label1 = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Style_Category")) ; label1.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH,ChartDataPane.LABEL_HEIGHT)); categoryCombox.setPreferredSize(new Dimension(100,20)); - categoryCombox.addItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")); + categoryCombox.addItem(Toolkit.i18nText("Fine-Design_Chart_Use_None")); categoryPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{categoryCombox,null,null,label1,null})); categoryPane.setPreferredSize(new Dimension(246,30)); categoryPane.setBorder(BorderFactory.createEmptyBorder(0,24,10,15)); @@ -56,7 +57,7 @@ public class CategoryPlotTableDataContentPane extends AbstractTableDataContentPa this.add(getJSeparator()); seriesTypeComboxPane = new SeriesTypeUseComboxPane(parent, new Bar2DPlot()); this.add(seriesTypeComboxPane, BorderLayout.SOUTH); - + categoryCombox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { checkSeriseUse(categoryCombox.getSelectedItem() != null); @@ -64,7 +65,7 @@ public class CategoryPlotTableDataContentPane extends AbstractTableDataContentPa } }); } - + protected void makeToolTipUse(UIComboBox comBox) { if(comBox.getSelectedItem() != null) { comBox.setToolTipText(comBox.getSelectedItem().toString()); @@ -72,7 +73,7 @@ public class CategoryPlotTableDataContentPane extends AbstractTableDataContentPa comBox.setToolTipText(null); } } - + /** * 检查 某些Box是否可用 * @param hasUse 是否使用. @@ -81,16 +82,16 @@ public class CategoryPlotTableDataContentPane extends AbstractTableDataContentPa categoryCombox.setEnabled(hasUse); checkSeriseUse(hasUse); } - + protected void checkSeriseUse(boolean hasUse) { if(seriesTypeComboxPane != null) { seriesTypeComboxPane.checkUseBox(hasUse && categoryCombox.getSelectedItem() != null); } } - + protected void refreshBoxListWithSelectTableData(List list) { refreshBoxItems(categoryCombox, list); - categoryCombox.addItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")); + categoryCombox.addItem(Toolkit.i18nText("Fine-Design_Chart_Use_None")); seriesTypeComboxPane.refreshBoxListWithSelectTableData(list); } @@ -100,10 +101,10 @@ public class CategoryPlotTableDataContentPane extends AbstractTableDataContentPa */ public void clearAllBoxList(){ clearBoxItems(categoryCombox); - categoryCombox.addItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")); + categoryCombox.addItem(Toolkit.i18nText("Fine-Design_Chart_Use_None")); seriesTypeComboxPane.clearAllBoxList(); } - + /** * 保存界面内容到ChartCollection */ @@ -129,15 +130,15 @@ public class CategoryPlotTableDataContentPane extends AbstractTableDataContentPa public void populateBean(ChartCollection collection) { super.populateBean(collection); TopDefinition top = (TopDefinition)collection.getSelectedChart().getFilterDefinition(); - + if(!(top instanceof NormalTableDataDefinition)) { return; } NormalTableDataDefinition data = (NormalTableDataDefinition)top; - if(data == null || ComparatorUtils.equals(data.getCategoryName(), StringUtils.EMPTY)) { - categoryCombox.setSelectedItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")); - } else if(data!= null && !this.boxItemsContainsObject(categoryCombox,data.getCategoryName())){ + if(ComparatorUtils.equals(data.getCategoryName(), StringUtils.EMPTY)) { + categoryCombox.setSelectedItem(Toolkit.i18nText("Fine-Design_Chart_Use_None")); + } else if(!DataPaneHelper.boxItemsContainsObject(categoryCombox,data.getCategoryName())){ categoryCombox.setSelectedItem(null); }else { combineCustomEditValue(categoryCombox, data.getCategoryName()); @@ -146,20 +147,6 @@ public class CategoryPlotTableDataContentPane extends AbstractTableDataContentPa seriesTypeComboxPane.populateBean(collection,this.isNeedSummaryCaculateMethod()); } - private 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; - } - /** * 重新布局整个面板 */ diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/DataPaneHelper.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/DataPaneHelper.java index 69cf88286f..7f5373c665 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/DataPaneHelper.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/DataPaneHelper.java @@ -7,6 +7,7 @@ import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; +import javax.swing.ComboBoxModel; import java.util.List; /** @@ -24,6 +25,30 @@ public class DataPaneHelper { box.refreshBoxItems(list); } + 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; + } + + public static void combineCustomEditValue(UIComboBox comBox, String value) { + if(comBox != null) { + comBox.setEditable(true); + comBox.setSelectedItem(value); + comBox.setEditable(false); + } + } + /** * 清空box里所有东西 * diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldNamePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldNamePane.java index 0c643cf8c1..3f5f70aae3 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldNamePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesNameUseFieldNamePane.java @@ -14,6 +14,7 @@ import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.itable.UITable; import com.fr.design.gui.itable.UITableEditor; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; @@ -23,6 +24,8 @@ import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.event.ChangeEvent; +import java.util.ArrayList; +import java.util.List; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Container; @@ -30,8 +33,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; -import java.util.ArrayList; -import java.util.List; /** * 属性表 数据集界面: 系列名 使用字段名. @@ -40,8 +41,15 @@ import java.util.List; * @version 创建时间:2012-12-26 下午04:39:46 */ public class SeriesNameUseFieldNamePane extends FurtherBasicBeanPane { - private static final String[] HEADS = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Field_Name"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Summary_Method")}; - private static final String[] HEADS_NO_SUMMARY = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Field_Name"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name")}; + private static final String[] HEADS = { + Toolkit.i18nText("Fine-Design_Chart_Field_Name"), + Toolkit.i18nText("Fine-Design_Chart_Series_Name"), + Toolkit.i18nText("Fine-Design_Chart_Summary_Method")}; + + private static final String[] HEADS_NO_SUMMARY = { + Toolkit.i18nText("Fine-Design_Chart_Field_Name"), + Toolkit.i18nText("Fine-Design_Chart_Series_Name")}; + private UICorrelationPane seriesDataPane; private List field = new ArrayList(); private JPanel centerPane; @@ -62,7 +70,7 @@ public class SeriesNameUseFieldNamePane extends FurtherBasicBeanPane { +public class SeriesTypeUseComboxPane extends BasicBeanPane { private SeriesNameUseFieldValuePane nameFieldValuePane; private SeriesNameUseFieldNamePane nameFieldNamePane; @@ -39,50 +40,106 @@ public class SeriesTypeUseComboxPane extends UIComboBoxPane { private ChartDataPane parent; private Plot initplot; - private boolean isNeedSummary = true; + private boolean isNeedSummary; + + protected UIButtonGroup content; + protected JPanel cardPane; public SeriesTypeUseComboxPane(ChartDataPane parent, Plot initplot) { this.initplot = initplot; this.parent = parent; - cards = initPaneList(); this.isNeedSummary = true; initComponents(); } + protected void initComponents() { + nameFieldValuePane = createValuePane(); + nameFieldNamePane = createNamePane(); + + cardPane = new JPanel(new CardLayout()) { + @Override + public Dimension getPreferredSize() { + if (content.getSelectedIndex() == 0) { + return nameFieldValuePane.getPreferredSize(); + } else { + return nameFieldNamePane.getPreferredSize(); + } + } + }; + cardPane.add(nameFieldValuePane, nameFieldValuePane.title4PopupWindow()); + cardPane.add(nameFieldNamePane, nameFieldNamePane.title4PopupWindow()); + + content = new UIButtonGroup<>(new String[]{nameFieldValuePane.title4PopupWindow(), nameFieldNamePane.title4PopupWindow()}); + + addItemChangeEvent(); + + initLayout(); + content.setSelectedIndex(0); + } + + private void addItemChangeEvent() { + content.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkCardPane(); + + } + }); + } + + protected void checkCardPane() { + comboBoxItemStateChanged(); + CardLayout cl = (CardLayout) cardPane.getLayout(); + if (content.getSelectedIndex() == 0) { + cl.show(cardPane, nameFieldValuePane.title4PopupWindow()); + } else { + cl.show(cardPane, nameFieldNamePane.title4PopupWindow()); + } + } + protected void initLayout() { this.setLayout(new BorderLayout(4, LayoutConstants.VGAP_MEDIUM)); JPanel northPane = new JPanel(new BorderLayout(4, 0)); - UILabel label1 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name_From")); - label1.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); - northPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{jcb, null, null, label1, null})); - northPane.setBorder(BorderFactory.createEmptyBorder(10, 24, 0, 15)); - cardPane.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 15)); + + //使用系列名/系列值选项面板 + UILabel seriesLabel = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Series_Name_From")); + seriesLabel.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); + JPanel borderLayoutPane = GUICoreUtils.createBorderLayoutPane(new Component[]{content, null, null, seriesLabel, null}); + northPane.add(borderLayoutPane); + northPane.setBorder(BorderFactory.createEmptyBorder(10, 24, 0, 16)); this.add(northPane, BorderLayout.NORTH); + + //系列名/系列值配置面板 + cardPane.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 15)); this.add(cardPane, BorderLayout.CENTER); - dataScreeningPane = new ChartDataFilterPane(this.initplot, parent); - JPanel panel = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), 290, 24, dataScreeningPane); - panel.setBorder(BorderFactory.createEmptyBorder(0,5,0,5)); - dataScreeningPane.setBorder(BorderFactory.createEmptyBorder(10,5,0,5)); + + //数据筛选 + dataScreeningPane = new ChartDataFilterPane(this.initplot, parent); + JPanel panel = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), 250, 24, dataScreeningPane); + panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15)); + dataScreeningPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); this.add(panel, BorderLayout.SOUTH); } - protected UIComboBox createComboBox() { - UIComboBox uiComboBox = new UIComboBox(); - UIComponentUtils.setPreferedWidth(uiComboBox, 100); - return uiComboBox; + public Dimension getPreferredSize() { + Dimension preferredSize = super.getPreferredSize(); + return new Dimension(246, (int) preferredSize.getHeight()); } + /** * 检查box 是否使用, hasUse, 表示上层已经使用, 否则, 则此界面都可使用 + * * @param hasUse 是否使用 */ public void checkUseBox(boolean hasUse) { - jcb.setEnabled(hasUse); + content.setEnabled(hasUse); nameFieldValuePane.checkUse(hasUse); dataScreeningPane.checkBoxUse(); } /** * 切换 变更数据集时, 刷新Box选中项目 + * * @param list 列表 */ public void refreshBoxListWithSelectTableData(List list) { @@ -93,28 +150,20 @@ public class SeriesTypeUseComboxPane extends UIComboBoxPane { /** * 清空所有的box设置 */ - public void clearAllBoxList(){ + public void clearAllBoxList() { nameFieldValuePane.clearAllBoxList(); nameFieldNamePane.clearAllBoxList(); } /** * 界面标题 + * * @return 界面标题 */ protected String title4PopupWindow() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name_From"); } - @Override - protected List> initPaneList() { - nameFieldValuePane = createValuePane(); - nameFieldNamePane = createNamePane(); - List> paneList = new ArrayList>(); - paneList.add(nameFieldValuePane); - paneList.add(nameFieldNamePane); - return paneList; - } protected SeriesNameUseFieldValuePane createValuePane() { return new SeriesNameUseFieldValuePane(); @@ -135,15 +184,17 @@ public class SeriesTypeUseComboxPane extends UIComboBoxPane { nameFieldNamePane.populateBean(ob, isNeedSummary); } dataScreeningPane.populateBean(ob, isNeedSummary); + checkCardPane(); } /** * 重新布局整个面板 + * * @param isNeedSummary 是否需要汇总 */ public void relayoutPane(boolean isNeedSummary) { this.isNeedSummary = isNeedSummary; - if (jcb.getSelectedIndex() == 0) { + if (this.getSelectedIndex() == 0) { nameFieldValuePane.relayoutPane(this.isNeedSummary); } else { nameFieldNamePane.relayoutPane(this.isNeedSummary); @@ -152,9 +203,8 @@ public class SeriesTypeUseComboxPane extends UIComboBoxPane { } - @Override protected void comboBoxItemStateChanged() { - if (jcb.getSelectedIndex() == 0) { + if (this.getSelectedIndex() == 0) { nameFieldValuePane.relayoutPane(this.isNeedSummary); } else { nameFieldNamePane.relayoutPane(this.isNeedSummary); @@ -178,4 +228,21 @@ public class SeriesTypeUseComboxPane extends UIComboBoxPane { dataScreeningPane.updateBean(ob); } + /** + * 保存数据 + * + * @return 待保存的对象 + */ + public ChartCollection updateBean() { + return null; + } + + + public int getSelectedIndex() { + return content.getSelectedIndex(); + } + + public void setSelectedIndex(int index) { + content.setSelectedIndex(index); + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ThirdTabPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ThirdTabPane.java index a0580ba468..a58a889164 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ThirdTabPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ThirdTabPane.java @@ -10,6 +10,7 @@ import com.fr.design.gui.ibutton.UIButtonGroup; import javax.swing.JPanel; import javax.swing.border.Border; +import java.util.List; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Component; @@ -20,7 +21,6 @@ import java.awt.Graphics2D; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.List; public abstract class ThirdTabPane extends BasicBeanPane{ @@ -74,16 +74,6 @@ public abstract class ThirdTabPane extends BasicBeanPane{ } } - @Override - public void paint(Graphics g) { - super.paint(g); - if (!paneList.isEmpty()) { - Graphics2D g2d = (Graphics2D)g; - g2d.setColor(UIConstants.LINE_COLOR); - g2d.drawLine(getWidth() - 2, tabPane.getPreferredSize().height, getWidth() - 2, getHeight() - 1); - } - } - protected void initLayout() { this.setLayout(new BorderLayout()); if (!paneList.isEmpty()) { diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java index c9a6caf80a..25b8760339 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java @@ -18,7 +18,6 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.style.color.ColorControlWindow; import com.fr.design.style.color.ColorSelectBox; import com.fr.design.utils.gui.GUICoreUtils; - import com.fr.stable.StringUtils; import com.fr.van.chart.designer.TableLayout4VanChartHelper; @@ -29,6 +28,8 @@ import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import java.util.ArrayList; +import java.util.List; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -40,8 +41,6 @@ import java.awt.LayoutManager; import java.awt.Point; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.List; public class UIColorPickerPane extends BasicPane implements UIObserver { private static final int MARGIN_TOP = 7; @@ -635,7 +634,7 @@ public class UIColorPickerPane extends BasicPane implements UIObserver { @Override public void layoutContainer(Container parent) { - upControlPane.setBounds(MARGIN_LEFT, MARGIN_TOP, UPCONTROLPANE_WIDTH, upControlPane.getPreferredSize().height); + upControlPane.setBounds(getBoundX(), getBoundY(), getBoundWidth(), upControlPane.getPreferredSize().height); colorGroup.setBounds(COLORGROUP_MARGIN_LEFT, 2 * MARGIN_TOP + upControlPane.getPreferredSize().height + LAYOUR_DET, colorGroup.getPreferredSize().width, colorGroup.getPreferredSize().height + upControlPane.getPreferredSize().height); textGroup.setBounds(colorGroup.getPreferredSize().width + COLORGROUP_MARGIN_LEFT, MARGIN_TOP + upControlPane.getPreferredSize().height + LAYOUR_DET, textGroup.getPreferredSize().width, textGroup.getPreferredSize().height); } @@ -646,6 +645,17 @@ public class UIColorPickerPane extends BasicPane implements UIObserver { } }; + protected int getBoundX() { + return MARGIN_LEFT; + } + + protected int getBoundY() { + return MARGIN_TOP; + } + + protected int getBoundWidth() { + return UPCONTROLPANE_WIDTH; + } /** *刷新颜色选取器 diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java index 34f917f153..09ba3d3ce6 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java @@ -2,14 +2,16 @@ package com.fr.design.module; import com.fr.base.ChartColorMatching; import com.fr.design.beans.BasicBeanPane; -import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.style.ChartColorAdjustPane; import com.fr.design.style.background.gradient.FixedGradientBar; +import javax.swing.BorderFactory; import javax.swing.JPanel; import java.util.ArrayList; import java.util.Collections; @@ -19,7 +21,6 @@ import java.awt.CardLayout; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; -import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -35,8 +36,7 @@ public class ChartPreFillStylePane extends BasicBeanPane { private JPanel changeColorSetPane; private CardLayout cardLayout; - private UIButton accButton; - private UIButton gradientButton; + private UIButtonGroup groupButton; private ChartColorAdjustPane colorAdjustPane; private FixedGradientBar colorGradient; @@ -52,25 +52,22 @@ public class ChartPreFillStylePane extends BasicBeanPane { JPanel customPane = new JPanel(FRGUIPaneFactory.createBorderLayout()); - JPanel buttonPane = new JPanel(); - buttonPane.setLayout(new FlowLayout(FlowLayout.LEFT)); - buttonPane.add(accButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Color"))); - buttonPane.add(gradientButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gradient_Color"))); - customPane.add(buttonPane, BorderLayout.NORTH); + groupButton = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Custom_Color"), Toolkit.i18nText("Fine-Design_Chart_Gradient_Color")}); + groupButton.setSelectedIndex(0); + customPane.add(groupButton, BorderLayout.NORTH); changeColorSetPane = new JPanel(cardLayout = new CardLayout()); - changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 130), "gradient"); + changeColorSetPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); + changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 150), "gradient"); changeColorSetPane.add(colorAdjustPane = new ChartColorAdjustPane(), "acc"); cardLayout.show(changeColorSetPane, "acc"); customPane.add(changeColorSetPane, BorderLayout.CENTER); - accButton.setSelected(true); - - customPane.setPreferredSize(new Dimension(200, 200)); - colorGradient.setPreferredSize(new Dimension(120, 30)); + customPane.setPreferredSize(new Dimension(155, 300)); + colorGradient.setPreferredSize(new Dimension(155, 30)); colorGradient.getSelectColorPointBtnP1().setColorInner(Color.WHITE); colorGradient.getSelectColorPointBtnP2().setColorInner(FixedGradientBar.NEW_CHARACTER); - + double p = TableLayout.PREFERRED; double[] columnSize = {p, p}; double[] rowSize = {p, p, p}; @@ -84,24 +81,20 @@ public class ChartPreFillStylePane extends BasicBeanPane { } private void initListener() { - - accButton.addActionListener(new ActionListener() { + groupButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - accButton.setSelected(true); - gradientButton.setSelected(false); - cardLayout.show(changeColorSetPane, "acc"); + checkCardPane(); } }); + } - gradientButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - gradientButton.setSelected(true); - accButton.setSelected(false); - cardLayout.show(changeColorSetPane, "gradient"); - } - }); + private void checkCardPane() { + if (groupButton.getSelectedIndex() == 0) { + cardLayout.show(changeColorSetPane, "acc"); + } else { + cardLayout.show(changeColorSetPane, "gradient"); + } } @Override @@ -117,8 +110,7 @@ public class ChartPreFillStylePane extends BasicBeanPane { boolean isGradient = condition.getGradient(); List colorList = condition.getColorList(); if (isGradient) { - gradientButton.setSelected(true); - accButton.setSelected(false); + groupButton.setSelectedIndex(1); cardLayout.show(changeColorSetPane, "gradient"); if (colorList.size() == 2) { @@ -127,8 +119,7 @@ public class ChartPreFillStylePane extends BasicBeanPane { colorGradient.repaint(); } } else { - accButton.setSelected(true); - gradientButton.setSelected(false); + groupButton.setSelectedIndex(0); cardLayout.show(changeColorSetPane, "acc"); if (colorList.isEmpty()) { @@ -148,7 +139,7 @@ public class ChartPreFillStylePane extends BasicBeanPane { List colorList = new ArrayList(); - if (gradientButton.isSelected()) { + if (groupButton.getSelectedIndex() == 1) { chartColorMatching.setGradient(true); Color start = colorGradient.getSelectColorPointBtnP1().getColorInner(); 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 0000000000..f2f5c3cf6f --- /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 abae5118b3..44b504ef3f 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,114 @@ 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 com.fr.van.chart.designer.TableLayout4VanChartHelper; -import java.util.ArrayList; +import javax.swing.JPanel; import java.util.Iterator; - +import java.util.LinkedHashMap; +import java.util.Map; +import java.awt.BorderLayout; +import java.awt.Dimension; /** * 图表预定义管理 界面, 在工具栏-服务器管理中. + * * @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); + defaultColorBox.setPreferredSize(new Dimension(TableLayout4VanChartHelper.EDIT_AREA_WIDTH, 20)); + } + + 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 5bd4c38978..9cce2be7c3 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(); diff --git a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java index 108d4b605e..119d73bda6 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java @@ -27,21 +27,19 @@ public class ExtendedCustomFieldComboBoxPane extends AbstractCustomFieldComboBox public void populateBean(AbstractDataConfig ob) { if (ob.isCustomName()) { populateCustomFieldNamePane(ob); - jcb.setSelectedIndex(1); } else { populateUseFieldValuePane(ob); - jcb.setSelectedIndex(0); } + populateNameOrValue(ob.isCustomName()); } @Override public void updateBean(AbstractDataConfig ob) { - if (jcb.getSelectedIndex() == 0) { - ob.setCustomName(false); - updateUseFieldValuePane(ob); - } else { - ob.setCustomName(true); + ob.setCustomName(updateNameOrValue()); + if (ob.isCustomName()) { updateCustomFieldNamePane(ob); + } else { + updateUseFieldValuePane(ob); } } diff --git a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedOtherPane.java b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedOtherPane.java index 6fba552b76..74bc01282b 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedOtherPane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedOtherPane.java @@ -109,7 +109,7 @@ public class ExtendedOtherPane extends AbstractChartAtt } }); - autoRefreshTime = new UISpinner(0, Integer.MAX_VALUE, 1, 0); + autoRefreshTime = createIntervalTime(); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] columnSize = {p, f, 20}; @@ -129,6 +129,10 @@ public class ExtendedOtherPane extends AbstractChartAtt return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Refresh"), gapPane); } + protected UISpinner createIntervalTime() { + return new UISpinner(1, Integer.MAX_VALUE, 5, 60); + } + private JPanel createHyperlinkPane() { hyperLinkPane = new ExtendedChartHyperLinkPane(); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_Insert_Hyperlink"), hyperLinkPane); diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/BoxIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/box/BoxIndependentVanChartInterface.java new file mode 100644 index 0000000000..e4906b6254 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/BoxIndependentVanChartInterface.java @@ -0,0 +1,96 @@ +package com.fr.van.chart.box; + +import com.fr.chart.chartattr.Chart; +import com.fr.chart.chartattr.Plot; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.condition.ConditionAttributesPane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.chart.AbstractChartAttrPane; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.design.mainframe.chart.gui.ChartStylePane; +import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; +import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; +import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.plugin.chart.attr.plot.VanChartPlot; +import com.fr.van.chart.box.data.report.BoxPlotReportDataContentPane; +import com.fr.van.chart.box.data.table.BoxPlotTableDataContentPane; +import com.fr.van.chart.designer.other.AutoRefreshPane; +import com.fr.van.chart.designer.other.AutoRefreshPaneWithoutTooltip; +import com.fr.van.chart.designer.other.VanChartInteractivePane; +import com.fr.van.chart.designer.other.VanChartOtherPane; +import com.fr.van.chart.designer.other.zoom.ZoomPane; +import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; + +import java.awt.Component; + +public class BoxIndependentVanChartInterface extends AbstractIndependentVanChartUI { + + public String getName() { + return Toolkit.i18nText("Fine-Design_Chart_New_Box"); + } + + public String[] getSubName() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_New_Box") + }; + } + + public String[] getDemoImagePath() { + return new String[]{ + "com/fr/plugin/chart/demo/image/box.png" + }; + } + + public String getIconPath() { + return "com/fr/design/images/form/toolbar/box.png"; + } + + public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { + return new BoxPlotTableDataContentPane(plot, parent); + } + + public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { + return new BoxPlotReportDataContentPane(plot, parent); + } + + public AbstractChartTypePane getPlotTypePane() { + return new VanChartBoxPlotPane(); + } + + public ConditionAttributesPane getPlotConditionPane(Plot plot) { + return new VanChartBoxConditionPane(plot); + } + + public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot) { + return new VanChartBoxSeriesPane(parent, plot); + } + + public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener) { + VanChartStylePane stylePane = new VanChartBoxStylePane(listener); + VanChartOtherPane otherPane = new VanChartOtherPane() { + + protected BasicBeanPane createInteractivePane() { + return new VanChartInteractivePane() { + + protected Component[][] createToolBarComponents() { + return createToolBarComponentsWithOutSort(); + } + + protected AutoRefreshPane getMoreLabelPane(VanChartPlot plot) { + boolean isLargeModel = largeModel(plot); + return new AutoRefreshPaneWithoutTooltip(chart, isLargeModel); + } + + protected ZoomPane createZoomPane() { + return new ZoomPane(); + } + }; + } + }; + + return new AbstractChartAttrPane[]{stylePane, otherPane}; + } + +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxBorderPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxBorderPane.java new file mode 100644 index 0000000000..a5a9bec1b0 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxBorderPane.java @@ -0,0 +1,83 @@ +package com.fr.van.chart.box; + +import com.fr.base.background.ColorBackground; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.plugin.chart.base.AttrBorderWithWidth; +import com.fr.stable.StringUtils; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.component.background.VanChartMarkerBackgroundPane; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; + +public class VanChartBoxBorderPane extends BasicBeanPane { + + private VanChartMarkerBackgroundPane colorBackground; + private UISpinner lineWidth; + + public VanChartBoxBorderPane() { + colorBackground = new VanChartMarkerBackgroundPane() { + + protected Component[][] getPaneComponents() { + return new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), typeComboBox}, + new Component[]{null, centerPane}, + }; + } + }; + lineWidth = new UISpinner(0.5, Double.MAX_VALUE, 0.5, 0.5); + + Component[][] components = new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Line_Width")), lineWidth}, + new Component[]{colorBackground, null} + }; + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + + double[] columnSize = {f, e}; + double[] rowSize = {p, p, p}; + + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); + this.setLayout(new BorderLayout()); + this.add(panel, BorderLayout.CENTER); + } + + public void populateBean(AttrBorderWithWidth border) { + if (border.getBorderColor() != null) { + this.colorBackground.populate(ColorBackground.getInstance(border.getBorderColor())); + } + + this.lineWidth.setValue(border.getLineWidth()); + } + + public AttrBorderWithWidth updateBean() { + AttrBorderWithWidth border = new AttrBorderWithWidth(); + + ColorBackground colorBackground = this.colorBackground.update(); + + if (colorBackground == null) { + border.setBorderColor(null); + } else { + border.setBorderColor(colorBackground.getColor()); + } + + if (this.lineWidth != null) { + border.setLineWidth(this.lineWidth.getValue()); + } + + return border; + } + + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxConditionPane.java new file mode 100644 index 0000000000..3ae76a2476 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxConditionPane.java @@ -0,0 +1,62 @@ +package com.fr.van.chart.box; + +import com.fr.chart.base.AttrAlpha; +import com.fr.chart.base.AttrBackground; +import com.fr.chart.chartattr.Plot; +import com.fr.design.chart.series.SeriesCondition.ChartConditionPane; +import com.fr.design.chart.series.SeriesCondition.DataSeriesConditionPane; +import com.fr.design.chart.series.SeriesCondition.LabelAlphaPane; +import com.fr.plugin.chart.base.AttrBorderWithWidth; +import com.fr.plugin.chart.box.VanChartAttrNormalMarker; +import com.fr.plugin.chart.box.VanChartAttrOutlierMarker; +import com.fr.plugin.chart.box.VanChartBoxPlot; +import com.fr.plugin.chart.type.ConditionKeyType; +import com.fr.van.chart.box.condition.VanChartBoxBorderConditionPane; +import com.fr.van.chart.box.condition.VanChartBoxNormalMarkerConditionPane; +import com.fr.van.chart.box.condition.VanChartBoxOutlierMarkerConditionPane; +import com.fr.van.chart.designer.other.condition.item.VanChartSeriesColorConditionPane; + +import java.awt.Dimension; + +public class VanChartBoxConditionPane extends DataSeriesConditionPane { + + public VanChartBoxConditionPane(Plot plot) { + super(plot); + } + + protected void initComponents() { + super.initComponents(); + + liteConditionPane.setPreferredSize(new Dimension(300, 400)); + } + + protected void addBasicAction() { + classPaneMap.put(AttrBackground.class, new VanChartSeriesColorConditionPane(this)); + classPaneMap.put(AttrAlpha.class, new LabelAlphaPane(this)); + classPaneMap.put(AttrBorderWithWidth.class, new VanChartBoxBorderConditionPane(this)); + + if (((VanChartBoxPlot) plot).isDetailed()) { + classPaneMap.put(VanChartAttrNormalMarker.class, new VanChartBoxNormalMarkerConditionPane(this)); + classPaneMap.put(VanChartAttrOutlierMarker.class, new VanChartBoxOutlierMarkerConditionPane(this)); + } + } + + protected void addStyleAction() { + } + + protected ChartConditionPane createListConditionPane() { + + return new ChartConditionPane() { + + @Override + protected ConditionKeyType[] conditionKeyTypes() { + return ConditionKeyType.BOX_CONDITION_KEY_TYPES; + } + }; + } + + + public Class class4Correspond() { + return VanChartBoxPlot.class; + } +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxPlotPane.java new file mode 100644 index 0000000000..f019bc99e7 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxPlotPane.java @@ -0,0 +1,51 @@ +package com.fr.van.chart.box; + +import com.fr.chart.chartattr.Chart; +import com.fr.chart.chartattr.Plot; +import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.base.VanChartTools; +import com.fr.plugin.chart.box.BoxIndependentVanChart; +import com.fr.plugin.chart.box.VanChartBoxPlot; +import com.fr.van.chart.designer.type.AbstractVanChartTypePane; + +public class VanChartBoxPlotPane extends AbstractVanChartTypePane { + + protected String[] getTypeIconPath() { + return new String[]{"/com/fr/van/chart/box.images/box.png" + }; + } + + protected Plot getSelectedClonedPlot() { + VanChartBoxPlot newPlot = null; + + Chart[] boxChartGroup = BoxIndependentVanChart.BoxVanChartTypes; + + for (int i = 0, len = boxChartGroup.length; i < len; i++) { + if (typeDemo.get(i).isPressing) { + newPlot = boxChartGroup[i].getPlot(); + } + } + + Plot cloned = null; + + try { + if (newPlot != null) { + cloned = (Plot) newPlot.clone(); + } + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error("Error In ColumnChart"); + } + + return cloned; + } + + public Chart getDefaultChart() { + return BoxIndependentVanChart.BoxVanChartTypes[0]; + } + + protected VanChartTools createVanChartTools() { + VanChartTools tools = new VanChartTools(); + tools.setSort(false); + return tools; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxPlotTooltipPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxPlotTooltipPane.java new file mode 100644 index 0000000000..f1cae6e3bf --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxPlotTooltipPane.java @@ -0,0 +1,28 @@ +package com.fr.van.chart.box; + +import com.fr.chart.chartattr.Plot; +import com.fr.plugin.chart.base.AttrTooltip; +import com.fr.plugin.chart.box.VanChartBoxPlot; +import com.fr.plugin.chart.box.attr.AttrBoxTooltip; +import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.van.chart.designer.style.tooltip.VanChartPlotTooltipPane; + +public class VanChartBoxPlotTooltipPane extends VanChartPlotTooltipPane { + + public VanChartBoxPlotTooltipPane(Plot plot, VanChartStylePane parent) { + super(plot, parent); + } + + protected void initTooltipContentPane(Plot plot) { + boolean isDetailed = ((VanChartBoxPlot) plot).isDetailed(); + tooltipContentPane = new VanChartBoxTooltipContentPane(parent, VanChartBoxPlotTooltipPane.this, isDetailed); + } + + protected AttrTooltip getAttrTooltip() { + return new AttrBoxTooltip(); + } + + protected boolean hasTooltipSeriesType() { + return false; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxSeriesPane.java new file mode 100644 index 0000000000..8f0b5480bb --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxSeriesPane.java @@ -0,0 +1,115 @@ +package com.fr.van.chart.box; + +import com.fr.chart.chartattr.Plot; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.gui.ChartStylePane; +import com.fr.plugin.chart.box.VanChartBoxPlot; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.component.VanChartBeautyPane; +import com.fr.van.chart.designer.component.VanChartMarkerPane; +import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; + +public class VanChartBoxSeriesPane extends VanChartAbstractPlotSeriesPane { + + private VanChartBoxBorderPane boxBorderPane; + + private JPanel normalMarker; + private JPanel outlierMarker; + + private VanChartMarkerPane normalValuePane; + private VanChartMarkerPane outlierValuePane; + + public VanChartBoxSeriesPane(ChartStylePane parent, Plot plot) { + super(parent, plot); + } + + protected JPanel getContentInPlotType() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + + double[] columnSize = {f}; + double[] rowSize = {p, p, p}; + + Component[][] components = new Component[][]{ + new Component[]{createBoxBorderPane()}, + new Component[]{createNormalValuePane()}, + new Component[]{createOutlierValuePane()} + }; + + contentPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + + return contentPane; + } + + private JPanel createBoxBorderPane() { + boxBorderPane = new VanChartBoxBorderPane(); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), boxBorderPane); + } + + private JPanel createNormalValuePane() { + normalValuePane = new VanChartMarkerPane(); + normalMarker = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Normal_Value"), normalValuePane); + + return normalMarker; + } + + private JPanel createOutlierValuePane() { + outlierValuePane = new VanChartMarkerPane(); + outlierMarker = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Outlier_Value"), outlierValuePane); + + return outlierMarker; + } + + private void checkMarkerPane(boolean isDetailed) { + normalMarker.setVisible(isDetailed); + outlierMarker.setVisible(isDetailed); + } + + protected void setColorPaneContent(JPanel panel) { + panel.add(createAlphaPane(), BorderLayout.SOUTH); + } + + protected VanChartBeautyPane createStylePane() { + return null; + } + + public void populateBean(Plot plot) { + if (plot == null) { + return; + } + + super.populateBean(plot); + + if (plot instanceof VanChartBoxPlot) { + VanChartBoxPlot boxPlot = (VanChartBoxPlot) plot; + + boxBorderPane.populateBean(boxPlot.getBorder()); + normalValuePane.populate(boxPlot.getNormalValue()); + outlierValuePane.populate(boxPlot.getOutlierValue()); + + checkMarkerPane(boxPlot.isDetailed()); + } + } + + public void updateBean(Plot plot) { + if (plot == null) { + return; + } + + if (plot instanceof VanChartBoxPlot) { + VanChartBoxPlot boxPlot = (VanChartBoxPlot) plot; + + boxPlot.setBorder(boxBorderPane.updateBean()); + boxPlot.setNormalValue(normalValuePane.update()); + boxPlot.setOutlierValue(outlierValuePane.update()); + } + + super.updateBean(plot); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxStylePane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxStylePane.java new file mode 100644 index 0000000000..53cf8083fe --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxStylePane.java @@ -0,0 +1,21 @@ +package com.fr.van.chart.box; + +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import java.util.List; + +public class VanChartBoxStylePane extends VanChartStylePane { + + public VanChartBoxStylePane(AttributeChangeListener listener) { + super(listener); + } + + protected void createVanChartLabelPane(List paneList) { + } + + protected void addVanChartTooltipPane(List paneList) { + paneList.add(new VanChartBoxTooltipPane(VanChartBoxStylePane.this)); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java new file mode 100644 index 0000000000..77b16b4993 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java @@ -0,0 +1,226 @@ +package com.fr.van.chart.box; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.box.attr.AttrBoxTooltipContent; +import com.fr.van.chart.designer.component.VanChartTooltipContentPane; +import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithCheckBox; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; + +public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { + + private boolean detailed; + + private VanChartFormatPaneWithCheckBox number; + private VanChartFormatPaneWithCheckBox max; + private VanChartFormatPaneWithCheckBox q3; + private VanChartFormatPaneWithCheckBox median; + private VanChartFormatPaneWithCheckBox q1; + private VanChartFormatPaneWithCheckBox min; + private VanChartFormatPaneWithCheckBox outlier; + + private JPanel dataNumberPane; + private JPanel dataOutlierPane; + + public VanChartBoxTooltipContentPane(VanChartStylePane parent, JPanel showOnPane, boolean isDetailed) { + super(parent, showOnPane); + checkFormatVisible(isDetailed); + } + + protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { + categoryNameFormatPane = new CategoryNameFormatPaneWithCheckBox(parent, showOnPane); + seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane); + + number = new VanChartFormatPaneWithCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Data_Number"); + } + }; + max = new VanChartFormatPaneWithCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Max_Value"); + } + }; + q3 = new VanChartFormatPaneWithCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Data_Q3"); + } + }; + median = new VanChartFormatPaneWithCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Data_Median"); + } + }; + q1 = new VanChartFormatPaneWithCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Data_Q1"); + } + }; + min = new VanChartFormatPaneWithCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Min_Value"); + } + }; + outlier = new VanChartFormatPaneWithCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Outlier_Value"); + } + }; + } + + protected JPanel createCommonPanel() { + JPanel commonPanel = new JPanel(new BorderLayout()); + + commonPanel.add(createCateAndSeriesPane(), BorderLayout.NORTH); + commonPanel.add(createDataNumberPane(), BorderLayout.CENTER); + commonPanel.add(createDataDetailPane(), BorderLayout.SOUTH); + + return commonPanel; + } + + protected double[] getRowSize(double p) { + return new double[]{p, p, p, p, p, p, p, p, p, p, p, p}; + } + + private JPanel createCateAndSeriesPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + + double[] columnSize = {f, p}; + double[] rowSize = {p, p}; + + Component[][] cateAndSeries = new Component[][]{ + new Component[]{categoryNameFormatPane, null}, + new Component[]{seriesNameFormatPane, null} + }; + + return TableLayoutHelper.createTableLayoutPane(cateAndSeries, rowSize, columnSize); + } + + private JPanel createDataNumberPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + + double[] columnSize = {f, p}; + double[] rowSize = {p, p}; + + Component[][] dataNumber = new Component[][]{ + new Component[]{null, null}, + new Component[]{number, null}, + }; + + dataNumberPane = TableLayoutHelper.createTableLayoutPane(dataNumber, rowSize, columnSize); + + return dataNumberPane; + } + + private JPanel createDataDetailPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {f, p}; + + JPanel detailPane = new JPanel(new BorderLayout()); + + Component[][] dataDetail = new Component[][]{ + new Component[]{null, null}, + new Component[]{max, null}, + new Component[]{q3, null}, + new Component[]{median, null}, + new Component[]{q1, null}, + new Component[]{min, null} + }; + + Component[][] dataOutlier = new Component[][]{ + new Component[]{null, null}, + new Component[]{outlier, null}, + }; + + dataOutlierPane = TableLayoutHelper.createTableLayoutPane(dataOutlier, new double[]{p, p}, columnSize); + + detailPane.add(TableLayoutHelper.createTableLayoutPane(dataDetail, new double[]{p, p, p, p, p, p}, columnSize), BorderLayout.NORTH); + detailPane.add(dataOutlierPane, BorderLayout.CENTER); + + return detailPane; + } + + public boolean isDirty() { + return categoryNameFormatPane.isDirty() + || seriesNameFormatPane.isDirty() + || number.isDirty() + || max.isDirty() + || q3.isDirty() + || median.isDirty() + || q1.isDirty() + || min.isDirty() + || outlier.isDirty(); + } + + public void setDirty(boolean isDirty) { + categoryNameFormatPane.setDirty(isDirty); + seriesNameFormatPane.setDirty(isDirty); + number.setDirty(isDirty); + max.setDirty(isDirty); + q3.setDirty(isDirty); + median.setDirty(isDirty); + q1.setDirty(isDirty); + min.setDirty(isDirty); + outlier.setDirty(isDirty); + } + + protected AttrTooltipContent createAttrTooltip() { + return new AttrBoxTooltipContent(detailed); + } + + protected void populateFormatPane(AttrTooltipContent attrTooltipContent) { + categoryNameFormatPane.populate(attrTooltipContent.getCategoryFormat()); + seriesNameFormatPane.populate(attrTooltipContent.getSeriesFormat()); + + if (attrTooltipContent instanceof AttrBoxTooltipContent) { + AttrBoxTooltipContent boxTooltipContent = (AttrBoxTooltipContent) attrTooltipContent; + + number.populate(boxTooltipContent.getNumber()); + max.populate(boxTooltipContent.getMax()); + q3.populate(boxTooltipContent.getQ3()); + median.populate(boxTooltipContent.getMedian()); + q1.populate(boxTooltipContent.getQ1()); + min.populate(boxTooltipContent.getMin()); + outlier.populate(boxTooltipContent.getOutlier()); + + checkFormatVisible(boxTooltipContent.isDetailed()); + } + } + + protected void updateFormatPane(AttrTooltipContent attrTooltipContent) { + categoryNameFormatPane.update(attrTooltipContent.getCategoryFormat()); + seriesNameFormatPane.update(attrTooltipContent.getSeriesFormat()); + + if (attrTooltipContent instanceof AttrBoxTooltipContent) { + AttrBoxTooltipContent boxTooltipContent = (AttrBoxTooltipContent) attrTooltipContent; + + number.update(boxTooltipContent.getNumber()); + max.update(boxTooltipContent.getMax()); + q3.update(boxTooltipContent.getQ3()); + median.update(boxTooltipContent.getMedian()); + q1.update(boxTooltipContent.getQ1()); + min.update(boxTooltipContent.getMin()); + outlier.update(boxTooltipContent.getOutlier()); + + boxTooltipContent.setDetailed(this.detailed); + } + } + + public void checkFormatVisible(boolean detailed) { + this.detailed = detailed; + + dataNumberPane.setVisible(detailed); + dataOutlierPane.setVisible(detailed); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipPane.java new file mode 100644 index 0000000000..ad5840267a --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipPane.java @@ -0,0 +1,29 @@ +package com.fr.van.chart.box; + +import com.fr.chart.base.DataSeriesCondition; +import com.fr.chart.chartattr.Plot; +import com.fr.plugin.chart.attr.plot.VanChartPlot; +import com.fr.plugin.chart.base.AttrTooltip; +import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.van.chart.designer.style.tooltip.VanChartPlotTooltipPane; +import com.fr.van.chart.designer.style.tooltip.VanChartTooltipPane; + +public class VanChartBoxTooltipPane extends VanChartTooltipPane { + + public VanChartBoxTooltipPane(VanChartStylePane parent) { + super(parent); + } + + protected VanChartPlotTooltipPane getTooltipPane(Plot plot) { + return new VanChartBoxPlotTooltipPane(plot, parent); + } + + public void populateTooltipPane(Plot plot) { + DataSeriesCondition attr = ((VanChartPlot) plot).getAttrTooltipFromConditionCollection(); + VanChartPlotTooltipPane tooltipPane = getPlotTooltipPane(); + + if (tooltipPane instanceof VanChartBoxPlotTooltipPane) { + tooltipPane.populate((AttrTooltip) attr); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/condition/VanChartBoxBorderConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/condition/VanChartBoxBorderConditionPane.java new file mode 100644 index 0000000000..737c903d40 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/condition/VanChartBoxBorderConditionPane.java @@ -0,0 +1,49 @@ +package com.fr.van.chart.box.condition; + +import com.fr.chart.base.DataSeriesCondition; +import com.fr.design.condition.ConditionAttributesPane; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.base.AttrBorderWithWidth; +import com.fr.van.chart.box.VanChartBoxBorderPane; +import com.fr.van.chart.designer.other.condition.item.AbstractNormalMultiLineConditionPane; + +import javax.swing.JPanel; + +public class VanChartBoxBorderConditionPane extends AbstractNormalMultiLineConditionPane { + private VanChartBoxBorderPane borderPane; + + protected JPanel initContentPane() { + borderPane = new VanChartBoxBorderPane(); + return borderPane; + } + + public VanChartBoxBorderConditionPane(ConditionAttributesPane conditionAttributesPane) { + super(conditionAttributesPane); + } + + public String nameForPopupMenuItem() { + return Toolkit.i18nText("Fine-Design_Chart_Border"); + } + + protected String getItemLabelString() { + return nameForPopupMenuItem(); + } + + protected String title4PopupWindow() { + return nameForPopupMenuItem(); + } + + public void setDefault() { + borderPane.populateBean(new AttrBorderWithWidth()); + } + + public void populate(DataSeriesCondition condition) { + if (condition instanceof AttrBorderWithWidth) { + this.borderPane.populateBean((AttrBorderWithWidth) condition); + } + } + + public DataSeriesCondition update() { + return this.borderPane.updateBean(); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/condition/VanChartBoxNormalMarkerConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/condition/VanChartBoxNormalMarkerConditionPane.java new file mode 100644 index 0000000000..017867decb --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/condition/VanChartBoxNormalMarkerConditionPane.java @@ -0,0 +1,51 @@ +package com.fr.van.chart.box.condition; + +import com.fr.chart.base.DataSeriesCondition; +import com.fr.design.condition.ConditionAttributesPane; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.base.VanChartAttrMarker; +import com.fr.plugin.chart.box.VanChartAttrNormalMarker; +import com.fr.plugin.chart.marker.type.MarkerType; +import com.fr.van.chart.designer.component.VanChartMarkerPane; +import com.fr.van.chart.designer.other.condition.item.VanChartMarkerConditionPane; + +public class VanChartBoxNormalMarkerConditionPane extends VanChartMarkerConditionPane { + + public VanChartBoxNormalMarkerConditionPane(ConditionAttributesPane conditionAttributesPane) { + super(conditionAttributesPane); + } + + public String nameForPopupMenuItem() { + return Toolkit.i18nText("Fine-Design_Chart_Normal_Value"); + } + + protected String getItemLabelString() { + return nameForPopupMenuItem(); + } + + protected void initMarkerPane() { + markerPane = new VanChartMarkerPane() { + + protected VanChartAttrMarker createNewAttrMarker() { + return new VanChartAttrNormalMarker(); + } + }; + } + + public void setDefault() { + VanChartAttrNormalMarker normalMarker = new VanChartAttrNormalMarker(); + normalMarker.setMarkerType(MarkerType.MARKER_CIRCLE); + + markerPane.populate(new VanChartAttrNormalMarker()); + } + + public void populate(DataSeriesCondition condition) { + if (condition instanceof VanChartAttrNormalMarker) { + markerPane.populate((VanChartAttrNormalMarker) condition); + } + } + + public DataSeriesCondition update() { + return markerPane.update(); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/condition/VanChartBoxOutlierMarkerConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/condition/VanChartBoxOutlierMarkerConditionPane.java new file mode 100644 index 0000000000..0c33a788c8 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/condition/VanChartBoxOutlierMarkerConditionPane.java @@ -0,0 +1,51 @@ +package com.fr.van.chart.box.condition; + +import com.fr.chart.base.DataSeriesCondition; +import com.fr.design.condition.ConditionAttributesPane; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.base.VanChartAttrMarker; +import com.fr.plugin.chart.box.VanChartAttrOutlierMarker; +import com.fr.plugin.chart.marker.type.MarkerType; +import com.fr.van.chart.designer.component.VanChartMarkerPane; +import com.fr.van.chart.designer.other.condition.item.VanChartMarkerConditionPane; + +public class VanChartBoxOutlierMarkerConditionPane extends VanChartMarkerConditionPane { + + public VanChartBoxOutlierMarkerConditionPane(ConditionAttributesPane conditionAttributesPane) { + super(conditionAttributesPane); + } + + public String nameForPopupMenuItem() { + return Toolkit.i18nText("Fine-Design_Chart_Outlier_Value"); + } + + protected String getItemLabelString() { + return nameForPopupMenuItem(); + } + + public void setDefault() { + VanChartAttrOutlierMarker outlierMarker = new VanChartAttrOutlierMarker(); + outlierMarker.setMarkerType(MarkerType.MARKER_CIRCLE_HOLLOW); + + markerPane.populate(outlierMarker); + } + + protected void initMarkerPane() { + markerPane = new VanChartMarkerPane() { + + protected VanChartAttrMarker createNewAttrMarker() { + return new VanChartAttrOutlierMarker(); + } + }; + } + + public void populate(DataSeriesCondition condition) { + if (condition instanceof VanChartAttrOutlierMarker) { + markerPane.populate((VanChartAttrOutlierMarker) condition); + } + } + + public DataSeriesCondition update() { + return markerPane.update(); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/data/report/BoxPlotReportDataContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/data/report/BoxPlotReportDataContentPane.java new file mode 100644 index 0000000000..037c0aa70b --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/data/report/BoxPlotReportDataContentPane.java @@ -0,0 +1,139 @@ +package com.fr.van.chart.box.data.report; + +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartattr.Plot; +import com.fr.design.gui.ibutton.UIButtonGroup; +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.report.AbstractReportDataContentPane; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.plugin.chart.box.VanChartBoxPlot; +import com.fr.plugin.chart.box.data.VanBoxReportDefinition; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class BoxPlotReportDataContentPane extends AbstractReportDataContentPane { + + private UIButtonGroup dataType; + + private BoxPlotReportDetailedDataSeriesPane detailedDataSeriesPane; + private BoxPlotReportResultDataSeriesPane resultDataSeriesPane; + + private Plot initplot; + + public BoxPlotReportDataContentPane(Plot plot, ChartDataPane parent) { + this.initplot = plot; + + this.setLayout(new BorderLayout()); + + this.add(createDataTypePane(), BorderLayout.NORTH); + this.add(createSeriesPane(parent), BorderLayout.CENTER); + + initDataTypeListener(); + checkDataPaneVisible(); + } + + private JPanel createDataTypePane() { + JPanel pane = new JPanel(new BorderLayout(4, 0)); + pane.setBorder(BorderFactory.createMatteBorder(0, 0, 6, 1, getBackground())); + + UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Form")); + label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); + + String[] names = new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Detailed_Data"), + Toolkit.i18nText("Fine-Design_Chart_Result_Data") + }; + + dataType = new UIButtonGroup(names); + dataType.setSelectedIndex(0); + dataType.setPreferredSize(new Dimension(100, 20)); + + pane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{dataType, null, null, label, null})); + pane.setPreferredSize(new Dimension(246, 30)); + pane.setBorder(BorderFactory.createEmptyBorder(0, 18, 10, 15)); + + return pane; + } + + private JPanel createSeriesPane(ChartDataPane parent) { + detailedDataSeriesPane = new BoxPlotReportDetailedDataSeriesPane(parent); + resultDataSeriesPane = new BoxPlotReportResultDataSeriesPane(); + + JPanel pane = new JPanel(new BorderLayout(4, 0)); + + pane.add(resultDataSeriesPane, BorderLayout.NORTH); + pane.add(detailedDataSeriesPane, BorderLayout.CENTER); + + return pane; + } + + private void initDataTypeListener() { + dataType.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + checkDataPaneVisible(); + } + }); + } + + private void checkDataPaneVisible() { + if (detailedDataSeriesPane != null) { + detailedDataSeriesPane.setVisible(dataType.getSelectedIndex() == 0); + } + if (resultDataSeriesPane != null) { + resultDataSeriesPane.setVisible(dataType.getSelectedIndex() == 1); + } + } + + public void updateBean(ChartCollection collection) { + collection.getSelectedChart().setFilterDefinition(new VanBoxReportDefinition()); + VanBoxReportDefinition report = BoxReportDefinitionHelper.getBoxReportDefinition(collection); + + if (report != null) { + boolean isDetailed = dataType.getSelectedIndex() == 0; + + report.setDetailed(isDetailed); + ((VanChartBoxPlot) initplot).updateDetailedAttr(isDetailed); + } + if (detailedDataSeriesPane != null) { + detailedDataSeriesPane.updateBean(collection); + } + if (resultDataSeriesPane != null) { + resultDataSeriesPane.updateBean(collection); + } + } + + public void populateBean(ChartCollection collection) { + VanBoxReportDefinition report = BoxReportDefinitionHelper.getBoxReportDefinition(collection); + + if (report == null) { + dataType.setSelectedIndex(0); + checkDataPaneVisible(); + return; + } + + if (dataType != null) { + dataType.setSelectedIndex(BoxReportDefinitionHelper.isDetailedReportDataType(collection) ? 0 : 1); + } + if (detailedDataSeriesPane != null) { + detailedDataSeriesPane.populateBean(collection); + } + if (resultDataSeriesPane != null) { + resultDataSeriesPane.populateBean(collection); + } + + checkDataPaneVisible(); + } + + protected String[] columnNames() { + return new String[0]; + } +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/data/report/BoxPlotReportDetailedDataSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/data/report/BoxPlotReportDetailedDataSeriesPane.java new file mode 100644 index 0000000000..9354ae384b --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/data/report/BoxPlotReportDetailedDataSeriesPane.java @@ -0,0 +1,38 @@ +package com.fr.van.chart.box.data.report; + +import com.fr.chart.chartattr.ChartCollection; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.design.mainframe.chart.gui.data.report.CategoryPlotReportDataContentPane; +import com.fr.plugin.chart.box.data.VanBoxReportDefinition; +import com.fr.plugin.chart.box.data.VanBoxReportDetailedDefinition; + +public class BoxPlotReportDetailedDataSeriesPane extends CategoryPlotReportDataContentPane { + + public BoxPlotReportDetailedDataSeriesPane(ChartDataPane parent) { + super(parent); + } + + public void populateBean(ChartCollection ob) { + VanBoxReportDetailedDefinition definition = BoxReportDefinitionHelper.getBoxReportDetailedDefinition(ob); + + if (definition == null) { + return; + } + + this.populateDefinition(definition); + } + + public void updateBean(ChartCollection ob) { + VanBoxReportDefinition report = BoxReportDefinitionHelper.getBoxReportDefinition(ob); + + if (report == null) { + return; + } + + VanBoxReportDetailedDefinition detailedDefinition = new VanBoxReportDetailedDefinition(); + + this.updateDefinition(detailedDefinition); + + report.setDetailedDefinition(detailedDefinition); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/data/report/BoxPlotReportResultDataSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/data/report/BoxPlotReportResultDataSeriesPane.java new file mode 100644 index 0000000000..347d150f98 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/data/report/BoxPlotReportResultDataSeriesPane.java @@ -0,0 +1,168 @@ +package com.fr.van.chart.box.data.report; + +import com.fr.chart.chartattr.ChartCollection; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; +import com.fr.plugin.chart.box.data.VanBoxReportDefinition; +import com.fr.plugin.chart.box.data.VanBoxReportResultDefinition; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; + +public class BoxPlotReportResultDataSeriesPane extends AbstractReportDataContentPane { + + private TinyFormulaPane category; + private TinyFormulaPane seriesName; + + private TinyFormulaWithEditLabel max; + private TinyFormulaWithEditLabel q3; + private TinyFormulaWithEditLabel median; + private TinyFormulaWithEditLabel q1; + private TinyFormulaWithEditLabel min; + + public BoxPlotReportResultDataSeriesPane() { + this.setLayout(new BorderLayout()); + + initContentComponents(); + + JPanel panel = createContentPane(); + + panel.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 15)); + + this.add(panel, BorderLayout.CENTER); + } + + private void initContentComponents() { + + category = createTinyFormulaPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Category")); + seriesName = createTinyFormulaPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Series_Name")); + + max = createTinyFormulaWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Max")); + q3 = createTinyFormulaWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Q3")); + median = createTinyFormulaWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Median")); + q1 = createTinyFormulaWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Q1")); + min = createTinyFormulaWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Min")); + } + + private JPanel createContentPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] row = {p, p, p, p, p, p, p}; + double[] col = {f}; + + Component[][] components = new Component[][]{ + new Component[]{category}, + new Component[]{seriesName}, + new Component[]{max}, + new Component[]{q3}, + new Component[]{median}, + new Component[]{q1}, + new Component[]{min} + }; + + return TableLayoutHelper.createTableLayoutPane(components, row, col); + } + + private TinyFormulaPane createTinyFormulaPaneWithTitle(final String title) { + + return new TinyFormulaPane() { + protected void initLayout() { + this.setLayout(new BorderLayout(4, 0)); + + UILabel label = new UILabel(title); + label.setPreferredSize(new Dimension(75, 20)); + this.add(label, BorderLayout.WEST); + + formulaTextField.setPreferredSize(new Dimension(100, 20)); + this.add(formulaTextField, BorderLayout.CENTER); + this.add(formulaTextFieldButton, BorderLayout.EAST); + } + }; + } + + private TinyFormulaWithEditLabel createTinyFormulaWithEditLabel(String title) { + + return new TinyFormulaWithEditLabel(title) { + protected void clearAllBackground() { + clearAllLabelBackground(); + } + }; + } + + private void clearAllLabelBackground() { + TinyFormulaWithEditLabel[] editLabels = new TinyFormulaWithEditLabel[]{max, q3, median, q1, min}; + + for (TinyFormulaWithEditLabel label : editLabels) { + if (label != null) { + label.clearBackGround(); + } + } + } + + public void populateBean(ChartCollection ob) { + VanBoxReportResultDefinition detailedDefinition = BoxReportDefinitionHelper.getBoxReportResultDefinition(ob); + + if (detailedDefinition == null) { + return; + } + + populateFormulaPane(category, detailedDefinition.getCategoryName()); + populateFormulaPane(seriesName, detailedDefinition.getSeriesName()); + + max.setHeaderName(detailedDefinition.getMaxLabel()); + q3.setHeaderName(detailedDefinition.getQ3Label()); + median.setHeaderName(detailedDefinition.getMedianLabel()); + q1.setHeaderName(detailedDefinition.getQ1Label()); + min.setHeaderName(detailedDefinition.getMinLabel()); + + max.populateFormula(detailedDefinition.getMax()); + q3.populateFormula(detailedDefinition.getQ3()); + median.populateFormula(detailedDefinition.getMedian()); + q1.populateFormula(detailedDefinition.getQ1()); + min.populateFormula(detailedDefinition.getMin()); + } + + private void populateFormulaPane(TinyFormulaPane pane, Object ob) { + if (ob != null) { + pane.populateBean(ob.toString()); + } + } + + public void updateBean(ChartCollection ob) { + VanBoxReportDefinition report = BoxReportDefinitionHelper.getBoxReportDefinition(ob); + + if (report == null) { + return; + } + + VanBoxReportResultDefinition resultDefinition = new VanBoxReportResultDefinition(); + + resultDefinition.setCategoryName(canBeFormula(category.getUITextField().getText())); + resultDefinition.setSeriesName(canBeFormula(seriesName.getUITextField().getText())); + + resultDefinition.setMaxLabel(max.getHeaderName()); + resultDefinition.setQ3Label(q3.getHeaderName()); + resultDefinition.setMedianLabel(median.getHeaderName()); + resultDefinition.setQ1Label(q1.getHeaderName()); + resultDefinition.setMinLabel(min.getHeaderName()); + + resultDefinition.setMax(canBeFormula(max.updateFormula())); + resultDefinition.setQ3(canBeFormula(q3.updateFormula())); + resultDefinition.setMedian(canBeFormula(median.updateFormula())); + resultDefinition.setQ1(canBeFormula(q1.updateFormula())); + resultDefinition.setMin(canBeFormula(min.updateFormula())); + + report.setResultDefinition(resultDefinition); + } + + protected String[] columnNames() { + return new String[0]; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/data/report/BoxReportDefinitionHelper.java b/designer-chart/src/main/java/com/fr/van/chart/box/data/report/BoxReportDefinitionHelper.java new file mode 100644 index 0000000000..28bf92fe1b --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/data/report/BoxReportDefinitionHelper.java @@ -0,0 +1,58 @@ +package com.fr.van.chart.box.data.report; + +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.chart.chartattr.Chart; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.plugin.chart.box.data.VanBoxReportDefinition; +import com.fr.plugin.chart.box.data.VanBoxReportDetailedDefinition; +import com.fr.plugin.chart.box.data.VanBoxReportResultDefinition; + +public class BoxReportDefinitionHelper { + + public static VanBoxReportDefinition getBoxReportDefinition(ChartCollection collection) { + if (collection != null) { + + Chart chart = collection.getSelectedChart(); + + if (chart != null) { + TopDefinitionProvider definitionProvider = chart.getFilterDefinition(); + + if (definitionProvider instanceof VanBoxReportDefinition) { + return (VanBoxReportDefinition) definitionProvider; + } + } + } + + return null; + } + + public static VanBoxReportResultDefinition getBoxReportResultDefinition(ChartCollection collection) { + VanBoxReportDefinition report = getBoxReportDefinition(collection); + + if (report != null) { + return report.getResultDefinition(); + } + + return null; + } + + public static VanBoxReportDetailedDefinition getBoxReportDetailedDefinition(ChartCollection collection) { + VanBoxReportDefinition report = getBoxReportDefinition(collection); + + if (report != null) { + return report.getDetailedDefinition(); + } + + return null; + } + + public static boolean isDetailedReportDataType(ChartCollection collection) { + VanBoxReportDefinition report = getBoxReportDefinition(collection); + + if (report != null) { + return report.isDetailed(); + } + + return true; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/data/report/TinyFormulaWithEditLabel.java b/designer-chart/src/main/java/com/fr/van/chart/box/data/report/TinyFormulaWithEditLabel.java new file mode 100644 index 0000000000..2c99230e3b --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/data/report/TinyFormulaWithEditLabel.java @@ -0,0 +1,71 @@ +package com.fr.van.chart.box.data.report; + +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.mainframe.chart.gui.UIEditLabel; + +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Dimension; + +public abstract class TinyFormulaWithEditLabel extends JPanel implements UIObserver { + + private UIEditLabel editLabel; + private TinyFormulaPane tinyFormulaPane; + + protected UIObserverListener listener; + + public TinyFormulaWithEditLabel(String text) { + editLabel = new UIEditLabel(text, SwingConstants.LEFT) { + protected void doAfterMousePress() { + clearAllBackground(); + } + + protected boolean appendOriginalLabel() { + return false; + } + }; + + editLabel.setPreferredSize(new Dimension(75, 20)); + tinyFormulaPane = new TinyFormulaPane(); + + this.setLayout(new BorderLayout(4, 0)); + this.add(editLabel, BorderLayout.WEST); + this.add(tinyFormulaPane, BorderLayout.CENTER); + } + + protected abstract void clearAllBackground(); + + public void clearBackGround() { + editLabel.resetNomalrBackground(); + } + + public boolean shouldResponseChangeListener() { + return true; + } + + public void registerChangeListener(UIObserverListener listener) { + this.listener = listener; + editLabel.registerChangeListener(listener); + } + + public void populateFormula(Object ob) { + if (ob != null) { + tinyFormulaPane.populateBean(ob.toString()); + } + } + + public Object updateFormula() { + return tinyFormulaPane.getUITextField().getText(); + } + + public String getHeaderName() { + return editLabel.getText(); + } + + public void setHeaderName(String text) { + editLabel.setText(text); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableDataContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableDataContentPane.java new file mode 100644 index 0000000000..4fa2296aa0 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableDataContentPane.java @@ -0,0 +1,210 @@ +package com.fr.van.chart.box.data.table; + +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartattr.Plot; +import com.fr.chart.chartdata.NormalTableDataDefinition; +import com.fr.design.foldablepane.UIExpandablePane; +import com.fr.design.gui.ibutton.UIButtonGroup; +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.ChartDataFilterPane; +import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.plugin.chart.box.VanChartBoxPlot; +import com.fr.plugin.chart.box.data.VanBoxTableDefinition; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; + +public class BoxPlotTableDataContentPane extends AbstractTableDataContentPane { + + private UIButtonGroup dataType; + + private BoxPlotTableSeriesTypeUsePane seriesTypeComboxPane; + private BoxPlotTableResultDataSeriesPane resultDataSeriesPane; + + private JPanel filterPane; + private ChartDataFilterPane dataScreeningPane; + + private ChartDataPane parent; + private Plot initplot; + + public BoxPlotTableDataContentPane(Plot plot, ChartDataPane parent) { + this.initplot = plot; + this.parent = parent; + + this.setLayout(new BorderLayout()); + + this.add(createDataTypePane(), BorderLayout.NORTH); + this.add(createSeriesPane(), BorderLayout.CENTER); + this.add(createFilterPane(), BorderLayout.SOUTH); + + initDataTypeListener(); + checkDataPaneVisible(); + } + + private JPanel createDataTypePane() { + JPanel pane = new JPanel(new BorderLayout(4, 0)); + pane.setBorder(BorderFactory.createMatteBorder(0, 0, 6, 1, getBackground())); + + UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Form")); + label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); + + String[] names = new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Detailed_Data"), + Toolkit.i18nText("Fine-Design_Chart_Result_Data") + }; + + dataType = new UIButtonGroup(names); + dataType.setSelectedIndex(0); + dataType.setPreferredSize(new Dimension(100, 20)); + + pane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{dataType, null, null, label, null})); + pane.setPreferredSize(new Dimension(246, 30)); + pane.setBorder(BorderFactory.createEmptyBorder(0, 24, 10, 15)); + + return pane; + } + + private JPanel createSeriesPane() { + seriesTypeComboxPane = new BoxPlotTableSeriesTypeUsePane(); + resultDataSeriesPane = new BoxPlotTableResultDataSeriesPane(); + + JPanel pane = new JPanel(new BorderLayout(4, 0)); + + pane.add(seriesTypeComboxPane, BorderLayout.CENTER); + pane.add(resultDataSeriesPane, BorderLayout.SOUTH); + + return pane; + } + + private JPanel createFilterPane() { + dataScreeningPane = new ChartDataFilterPane(initplot, parent, false); + dataScreeningPane.setBorder(BorderFactory.createEmptyBorder(10, 24, 10, 15)); + + filterPane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), 290, 24, dataScreeningPane); + filterPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); + + return filterPane; + } + + private void initDataTypeListener() { + dataType.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + checkDataPaneVisible(); + } + }); + } + + private void checkDataPaneVisible() { + if (seriesTypeComboxPane != null) { + seriesTypeComboxPane.setVisible(dataType.getSelectedIndex() == 0); + } + if (resultDataSeriesPane != null) { + resultDataSeriesPane.setVisible(dataType.getSelectedIndex() == 1); + } + + if (filterPane != null) { + filterPane.setVisible(dataType.getSelectedIndex() == 0); + } + } + + public void checkBoxUse(boolean hasUse) { + if (dataType.getSelectedIndex() == 0 && seriesTypeComboxPane != null) { + seriesTypeComboxPane.checkBoxUse(hasUse); + } + + if (dataType.getSelectedIndex() == 1 && resultDataSeriesPane != null) { + resultDataSeriesPane.checkBoxUse(hasUse); + } + + dataScreeningPane.checkBoxUse(); + } + + protected void refreshBoxListWithSelectTableData(List list) { + if (seriesTypeComboxPane != null) { + seriesTypeComboxPane.refreshBoxListWithSelectTableData(list); + } + if (resultDataSeriesPane != null) { + resultDataSeriesPane.refreshBoxListWithSelectTableData(list); + } + } + + public void clearAllBoxList() { + if (seriesTypeComboxPane != null) { + seriesTypeComboxPane.clearAllBoxList(); + } + if (resultDataSeriesPane != null) { + resultDataSeriesPane.clearAllBoxList(); + } + } + + public void updateBean(ChartCollection collection) { + collection.getSelectedChart().setFilterDefinition(new VanBoxTableDefinition()); + VanBoxTableDefinition table = BoxTableDefinitionHelper.getBoxTableDefinition(collection); + + if (table != null) { + boolean isDetailed = dataType.getSelectedIndex() == 0; + + table.setDetailed(isDetailed); + ((VanChartBoxPlot) initplot).updateDetailedAttr(isDetailed); + } + if (seriesTypeComboxPane != null) { + seriesTypeComboxPane.updateBean(collection); + } + if (resultDataSeriesPane != null) { + resultDataSeriesPane.updateBean(collection); + } + if (dataScreeningPane != null) { + updateDataScreeningPane(dataScreeningPane, collection); + } + } + + public void populateBean(ChartCollection collection) { + VanBoxTableDefinition table = BoxTableDefinitionHelper.getBoxTableDefinition(collection); + + if (table == null) { + dataType.setSelectedIndex(0); + checkDataPaneVisible(); + return; + } + + if (dataType != null) { + dataType.setSelectedIndex(BoxTableDefinitionHelper.isDetailedTableDataType(collection) ? 0 : 1); + } + if (seriesTypeComboxPane != null) { + seriesTypeComboxPane.populateBean(collection); + } + if (resultDataSeriesPane != null) { + resultDataSeriesPane.populateBean(collection); + } + if (dataScreeningPane != null) { + populateDataScreeningPane(dataScreeningPane, collection); + } + + checkDataPaneVisible(); + } + + private void populateDataScreeningPane(ChartDataFilterPane dataScreeningPane, ChartCollection collection) { + NormalTableDataDefinition detailedDefinition = BoxTableDefinitionHelper.getBoxTableDetailedDefinition(collection); + + if (detailedDefinition != null) { + dataScreeningPane.populateDefinition(detailedDefinition, false); + } + } + + private void updateDataScreeningPane(ChartDataFilterPane dataScreeningPane, ChartCollection collection) { + NormalTableDataDefinition detailedDefinition = BoxTableDefinitionHelper.getBoxTableDetailedDefinition(collection); + + if (detailedDefinition != null) { + dataScreeningPane.updateDefinition(detailedDefinition); + } + } +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableResultDataSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableResultDataSeriesPane.java new file mode 100644 index 0000000000..cfd3ea8d5b --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableResultDataSeriesPane.java @@ -0,0 +1,237 @@ +package com.fr.van.chart.box.data.table; + +import com.fr.chart.base.ChartConstants; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; +import com.fr.plugin.chart.box.data.VanBoxTableDefinition; +import com.fr.plugin.chart.box.data.VanBoxTableResultDefinition; +import com.fr.stable.ArrayUtils; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.util.List; + +public class BoxPlotTableResultDataSeriesPane extends AbstractTableDataContentPane { + + private UIComboBox category; + private UIComboBox seriesName; + + private JPanel categoryPane; + private JPanel seriesNamePane; + + private UIComboBoxWithEditLabel max; + private UIComboBoxWithEditLabel q3; + private UIComboBoxWithEditLabel median; + private UIComboBoxWithEditLabel q1; + private UIComboBoxWithEditLabel min; + + public BoxPlotTableResultDataSeriesPane() { + + initComboxSize(); + + this.setLayout(new BorderLayout()); + this.add(createDataSeriesPane(), BorderLayout.CENTER); + + addItemListener(); + } + + private void initComboxSize() { + category = new UIComboBox(); + seriesName = new UIComboBox(); + + categoryPane = createUIComboBoxPane(category, Toolkit.i18nText("Fine-Design_Chart_Category")); + seriesNamePane = createUIComboBoxPane(seriesName, Toolkit.i18nText("Fine-Design_Chart_Series_Name")); + + max = createUIComboBoxWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Max")); + q3 = createUIComboBoxWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Q3")); + median = createUIComboBoxWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Median")); + q1 = createUIComboBoxWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Q1")); + min = createUIComboBoxWithEditLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Min")); + + addNoneItem(); + + seriesName.setSelectedItem(null); + median.populateComboBox(null); + } + + private JPanel createUIComboBoxPane(UIComboBox comboBox, String title) { + UILabel label = new UILabel(title); + label.setPreferredSize(new Dimension(80, 20)); + + JPanel panel = new JPanel(); + + panel.setLayout(new BorderLayout(4, 0)); + panel.add(label, BorderLayout.WEST); + panel.add(comboBox, BorderLayout.CENTER); + + return panel; + } + + private UIComboBoxWithEditLabel createUIComboBoxWithEditLabel(String title) { + + return new UIComboBoxWithEditLabel(title) { + protected void clearAllBackground() { + clearAllLabelBackground(); + } + }; + } + + private void clearAllLabelBackground() { + UIComboBoxWithEditLabel[] editLabels = new UIComboBoxWithEditLabel[]{max, q3, median, q1, min}; + + for (UIComboBoxWithEditLabel label : editLabels) { + if (label != null) { + label.clearBackGround(); + } + } + } + + private void addItemListener() { + category.addItemListener(tooltipListener); + seriesName.addItemListener(tooltipListener); + max.addItemListener(tooltipListener); + q3.addItemListener(tooltipListener); + median.addItemListener(tooltipListener); + q1.addItemListener(tooltipListener); + min.addItemListener(tooltipListener); + } + + private JPanel createDataSeriesPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] row = {p, p, p, p, p, p, p}; + double[] col = {f}; + + Component[][] components = new Component[][]{ + new Component[]{categoryPane}, + new Component[]{seriesNamePane}, + new Component[]{max}, + new Component[]{q3}, + new Component[]{median}, + new Component[]{q1}, + new Component[]{min} + }; + + JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col); + panel.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 15)); + + return panel; + } + + public void checkBoxUse(boolean hasUse) { + } + + protected void refreshBoxListWithSelectTableData(List list) { + refreshBoxItems(category, list); + refreshBoxItems(seriesName, list); + + refreshBoxItems(max.getComboBox(), list); + refreshBoxItems(q3.getComboBox(), list); + refreshBoxItems(median.getComboBox(), list); + refreshBoxItems(q1.getComboBox(), list); + refreshBoxItems(min.getComboBox(), list); + + addNoneItem(); + } + + public void clearAllBoxList() { + clearBoxItems(category); + clearBoxItems(seriesName); + + clearBoxItems(max.getComboBox()); + clearBoxItems(q3.getComboBox()); + clearBoxItems(median.getComboBox()); + clearBoxItems(q1.getComboBox()); + clearBoxItems(min.getComboBox()); + + addNoneItem(); + } + + private void addNoneItem() { + seriesName.addItem(Toolkit.i18nText("Fine-Design_Chart_Use_None")); + median.addItem(Toolkit.i18nText("Fine-Design_Chart_Use_None")); + } + + public void populateBean(ChartCollection collection) { + super.populateBean(collection); + + VanBoxTableResultDefinition definition = BoxTableDefinitionHelper.getBoxTableResultDefinition(collection); + + if (definition == null) { + return; + } + + combineCustomEditValue(category, definition.getCategoryName()); + combineCustomEditValue(seriesName, definition.getSeriesName()); + + max.populateComboBox(definition.getMax()); + q3.populateComboBox(definition.getQ3()); + median.populateComboBox(definition.getMedian()); + q1.populateComboBox(definition.getQ1()); + min.populateComboBox(definition.getMin()); + + max.setHeaderName(definition.getMaxLabel()); + q3.setHeaderName(definition.getQ3Label()); + median.setHeaderName(definition.getMedianLabel()); + q1.setHeaderName(definition.getQ1Label()); + min.setHeaderName(definition.getMinLabel()); + } + + public void updateBean(ChartCollection collection) { + VanBoxTableDefinition table = BoxTableDefinitionHelper.getBoxTableDefinition(collection); + + VanBoxTableResultDefinition definition = new VanBoxTableResultDefinition(); + + Object resultCategory = category.getSelectedItem(); + Object resultSeries = seriesName.getSelectedItem(); + + Object resultMax = max.updateComboBox(); + Object resultQ3 = q3.updateComboBox(); + Object resultMedian = median.updateComboBox(); + Object resultQ1 = q1.updateComboBox(); + Object resultMin = min.updateComboBox(); + + if (resultCategory == null || ArrayUtils.contains(ChartConstants.getNoneKeys(), resultCategory)) { + definition.setCategoryName(StringUtils.EMPTY); + } else { + definition.setCategoryName(resultCategory.toString()); + } + if (resultSeries == null || ArrayUtils.contains(ChartConstants.getNoneKeys(), resultSeries)) { + definition.setSeriesName(StringUtils.EMPTY); + } else { + definition.setSeriesName(resultSeries.toString()); + } + if (resultMax != null) { + definition.setMax(resultMax.toString()); + } + if (resultQ3 != null) { + definition.setQ3(resultQ3.toString()); + } + if (resultMedian != null) { + definition.setMedian(resultMedian.toString()); + } + if (resultQ1 != null) { + definition.setQ1(resultQ1.toString()); + } + if (resultMin != null) { + definition.setMin(resultMin.toString()); + } + + definition.setMaxLabel(max.getHeaderName()); + definition.setQ3Label(q3.getHeaderName()); + definition.setMedianLabel(median.getHeaderName()); + definition.setQ1Label(q1.getHeaderName()); + definition.setMinLabel(min.getHeaderName()); + + table.setResultDefinition(definition); + } +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableSeriesNameUseFieldNamePane.java b/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableSeriesNameUseFieldNamePane.java new file mode 100644 index 0000000000..8fc7d7e684 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableSeriesNameUseFieldNamePane.java @@ -0,0 +1,12 @@ +package com.fr.van.chart.box.data.table; + +import com.fr.chart.chartdata.MoreNameCDDefinition; +import com.fr.design.mainframe.chart.gui.data.table.SeriesNameUseFieldNamePane; +import com.fr.plugin.chart.box.data.VanBoxMoreNameCDDefinition; + +public class BoxPlotTableSeriesNameUseFieldNamePane extends SeriesNameUseFieldNamePane { + + protected MoreNameCDDefinition createMoreNameCDDefinition() { + return new VanBoxMoreNameCDDefinition(); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableSeriesNameUseFieldValuePane.java b/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableSeriesNameUseFieldValuePane.java new file mode 100644 index 0000000000..f8069d30c7 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableSeriesNameUseFieldValuePane.java @@ -0,0 +1,19 @@ +package com.fr.van.chart.box.data.table; + +import com.fr.chart.chartdata.OneValueCDDefinition; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.design.mainframe.chart.gui.data.table.SeriesNameUseFieldValuePane; +import com.fr.plugin.chart.box.data.VanBoxOneValueCDDefinition; + +import java.awt.Dimension; + +public class BoxPlotTableSeriesNameUseFieldValuePane extends SeriesNameUseFieldValuePane { + + protected OneValueCDDefinition createOneValueCDDefinition() { + return new VanBoxOneValueCDDefinition(); + } + + protected Dimension getLabelDimension() { + return new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableSeriesTypeUsePane.java b/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableSeriesTypeUsePane.java new file mode 100644 index 0000000000..ab0bcfae31 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableSeriesTypeUsePane.java @@ -0,0 +1,275 @@ +package com.fr.van.chart.box.data.table; + +import com.fr.chart.base.ChartConstants; +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.BasicBeanPane; +import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.BoldFontTextLabel; +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.DataPaneHelper; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.ComparatorUtils; +import com.fr.plugin.chart.box.data.VanBoxTableDefinition; +import com.fr.stable.ArrayUtils; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.List; + +public class BoxPlotTableSeriesTypeUsePane extends BasicBeanPane { + + private static final boolean NEED_SUMMERY = false; + + private UIComboBox categoryCombox; + + private BoxPlotTableSeriesNameUseFieldValuePane nameFieldValuePane; + private BoxPlotTableSeriesNameUseFieldNamePane nameFieldNamePane; + + private UIButtonGroup seriesFrom; + private JPanel cardPane; + + public BoxPlotTableSeriesTypeUsePane() { + initComponents(); + initLayout(); + initListener(); + } + + private void initComponents() { + nameFieldValuePane = new BoxPlotTableSeriesNameUseFieldValuePane(); + nameFieldNamePane = new BoxPlotTableSeriesNameUseFieldNamePane(); + + nameFieldValuePane.relayoutPane(NEED_SUMMERY); + nameFieldNamePane.relayoutPane(NEED_SUMMERY); + + cardPane = new JPanel(new CardLayout()) { + public Dimension getPreferredSize() { + if (seriesFrom.getSelectedIndex() == 0) { + return nameFieldValuePane.getPreferredSize(); + } else { + return nameFieldNamePane.getPreferredSize(); + } + } + }; + + cardPane.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 15)); + cardPane.add(nameFieldValuePane, nameFieldValuePane.title4PopupWindow()); + cardPane.add(nameFieldNamePane, nameFieldNamePane.title4PopupWindow()); + + seriesFrom = new UIButtonGroup<>(new String[]{nameFieldValuePane.title4PopupWindow(), nameFieldNamePane.title4PopupWindow()}); + seriesFrom.setSelectedIndex(0); + + addItemChangeEvent(); + } + + private void addItemChangeEvent() { + seriesFrom.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + checkCardPane(); + } + }); + } + + private void checkCardPane() { + comboBoxItemStateChanged(); + + CardLayout cl = (CardLayout) cardPane.getLayout(); + if (seriesFrom.getSelectedIndex() == 0) { + cl.show(cardPane, nameFieldValuePane.title4PopupWindow()); + } else { + cl.show(cardPane, nameFieldNamePane.title4PopupWindow()); + } + } + + private void initLayout() { + this.setLayout(new BorderLayout(4, LayoutConstants.VGAP_MEDIUM)); + + this.add(createNorthPane(), BorderLayout.NORTH); + this.add(createCenterPane(), BorderLayout.CENTER); + this.add(cardPane, BorderLayout.SOUTH); + } + + private JPanel createNorthPane() { + JPanel north = new JPanel(new BorderLayout(4, 0)); + north.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, getBackground())); + UILabel label = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Style_Category")); + label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); + + categoryCombox = new UIComboBox(); + categoryCombox.setPreferredSize(new Dimension(100, 20)); + categoryCombox.addItem(Toolkit.i18nText("Fine-Design_Chart_Use_None")); + categoryCombox.setSelectedItem(null); + + north.add(GUICoreUtils.createBorderLayoutPane(new Component[]{categoryCombox, null, null, label, null})); + north.setPreferredSize(new Dimension(246, 20)); + north.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 15)); + + return north; + } + + private JPanel createCenterPane() { + JPanel center = 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)); + center.add(GUICoreUtils.createBorderLayoutPane(new Component[]{seriesFrom, null, null, label, null})); + center.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 15)); + + return center; + } + + private void initListener() { + categoryCombox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + checkBoxUse(categoryCombox.getSelectedItem() != null); + makeToolTipUse(categoryCombox); + } + }); + } + + public void checkBoxUse(boolean hasUse) { + categoryCombox.setEnabled(hasUse); + seriesFrom.setEnabled(hasUse); + nameFieldValuePane.checkUse(hasUse); + } + + private void makeToolTipUse(UIComboBox comBox) { + if (comBox.getSelectedItem() != null) { + comBox.setToolTipText(comBox.getSelectedItem().toString()); + } else { + comBox.setToolTipText(null); + } + } + + public void refreshBoxListWithSelectTableData(List list) { + DataPaneHelper.refreshBoxItems(categoryCombox, list); + + categoryCombox.addItem(Toolkit.i18nText("Fine-Design_Chart_Use_None")); + + nameFieldValuePane.refreshBoxListWithSelectTableData(list); + nameFieldNamePane.refreshBoxListWithSelectTableData(list); + } + + public void clearAllBoxList() { + DataPaneHelper.clearBoxItems(categoryCombox); + + categoryCombox.addItem(Toolkit.i18nText("Fine-Design_Chart_Use_None")); + + nameFieldValuePane.clearAllBoxList(); + nameFieldNamePane.clearAllBoxList(); + } + + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Series_Name_From"); + } + + protected List> initPaneList() { + nameFieldValuePane = new BoxPlotTableSeriesNameUseFieldValuePane(); + nameFieldNamePane = new BoxPlotTableSeriesNameUseFieldNamePane(); + + nameFieldValuePane.relayoutPane(NEED_SUMMERY); + nameFieldNamePane.relayoutPane(NEED_SUMMERY); + + List> paneList = new ArrayList>(); + + paneList.add(nameFieldValuePane); + paneList.add(nameFieldNamePane); + + return paneList; + } + + public void relayoutPane() { + if (seriesFrom.getSelectedIndex() == 0) { + nameFieldValuePane.relayoutPane(NEED_SUMMERY); + } else { + nameFieldNamePane.relayoutPane(NEED_SUMMERY); + } + } + + private void comboBoxItemStateChanged() { + if (seriesFrom.getSelectedIndex() == 0) { + nameFieldValuePane.relayoutPane(NEED_SUMMERY); + } else { + nameFieldNamePane.relayoutPane(NEED_SUMMERY); + } + } + + public void populateBean(ChartCollection collection) { + NormalTableDataDefinition definition = BoxTableDefinitionHelper.getBoxTableDetailedDefinition(collection); + + if (definition == null) { + categoryCombox.setSelectedItem(Toolkit.i18nText("Fine-Design_Chart_Use_None")); + return; + } + + if (definition instanceof OneValueCDDefinition) { + seriesFrom.setSelectedIndex(0); + nameFieldValuePane.populateDefinition(definition, NEED_SUMMERY); + } else if (definition instanceof MoreNameCDDefinition) { + seriesFrom.setSelectedIndex(1); + nameFieldNamePane.populateDefinition(definition, NEED_SUMMERY); + } + + populateCategoryItem(categoryCombox, definition.getCategoryName()); + + checkCardPane(); + } + + public void updateBean(ChartCollection collection) { + VanBoxTableDefinition table = BoxTableDefinitionHelper.getBoxTableDefinition(collection); + + if (table == null) { + return; + } + + NormalTableDataDefinition definition; + + if (seriesFrom.getSelectedIndex() == 0) { + definition = nameFieldValuePane.updateDefinition(); + } else { + definition = nameFieldNamePane.updateDefinition(table.getDetailedDefinition()); + } + + Object categoryName = categoryCombox.getSelectedItem(); + + if (ArrayUtils.contains(ChartConstants.getNoneKeys(), categoryName)) { + definition.setCategoryName(StringUtils.EMPTY); + } else { + definition.setCategoryName(categoryName == null ? null : categoryName.toString()); + } + + table.setDetailedDefinition(definition); + } + + private void populateCategoryItem(UIComboBox categoryCombox, String item) { + if (ComparatorUtils.equals(item, StringUtils.EMPTY)) { + categoryCombox.setSelectedItem(Toolkit.i18nText("Fine-Design_Chart_Use_None")); + } else if (!DataPaneHelper.boxItemsContainsObject(categoryCombox, item)) { + categoryCombox.setSelectedItem(null); + } else { + DataPaneHelper.combineCustomEditValue(categoryCombox, item); + } + } + + public ChartCollection updateBean() { + return null; + } + +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxTableDefinitionHelper.java b/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxTableDefinitionHelper.java new file mode 100644 index 0000000000..9242b4c7b8 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxTableDefinitionHelper.java @@ -0,0 +1,59 @@ +package com.fr.van.chart.box.data.table; + +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.chart.chartattr.Chart; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartdata.NormalTableDataDefinition; +import com.fr.plugin.chart.box.data.VanBoxTableDefinition; +import com.fr.plugin.chart.box.data.VanBoxTableResultDefinition; + +public class BoxTableDefinitionHelper { + + public static VanBoxTableDefinition getBoxTableDefinition(ChartCollection collection) { + if (collection != null) { + + Chart chart = collection.getSelectedChart(); + + if (chart != null) { + TopDefinitionProvider definitionProvider = chart.getFilterDefinition(); + + if (definitionProvider instanceof VanBoxTableDefinition) { + return (VanBoxTableDefinition) definitionProvider; + } + } + } + + return null; + } + + public static VanBoxTableResultDefinition getBoxTableResultDefinition(ChartCollection collection) { + VanBoxTableDefinition table = getBoxTableDefinition(collection); + + if (table != null) { + return table.getResultDefinition(); + } + + return null; + } + + public static NormalTableDataDefinition getBoxTableDetailedDefinition(ChartCollection collection) { + VanBoxTableDefinition table = getBoxTableDefinition(collection); + + if (table != null) { + return table.getDetailedDefinition(); + } + + return null; + } + + public static boolean isDetailedTableDataType(ChartCollection collection) { + VanBoxTableDefinition table = getBoxTableDefinition(collection); + + if (table != null) { + return table.isDetailed(); + } + + return true; + } +} + diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/data/table/UIComboBoxWithEditLabel.java b/designer-chart/src/main/java/com/fr/van/chart/box/data/table/UIComboBoxWithEditLabel.java new file mode 100644 index 0000000000..3ba858364a --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/data/table/UIComboBoxWithEditLabel.java @@ -0,0 +1,90 @@ +package com.fr.van.chart.box.data.table; + +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.mainframe.chart.gui.UIEditLabel; + +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ItemListener; + +public abstract class UIComboBoxWithEditLabel extends JPanel implements UIObserver { + + private UIEditLabel editLabel; + private UIComboBox comboBox; + + protected UIObserverListener listener; + + public UIComboBoxWithEditLabel(String text) { + editLabel = new UIEditLabel(text, SwingConstants.LEFT) { + protected void doAfterMousePress() { + clearAllBackground(); + } + + protected boolean appendOriginalLabel() { + return false; + } + }; + + editLabel.setPreferredSize(new Dimension(80, 20)); + comboBox = new UIComboBox(); + + this.setLayout(new BorderLayout(4, 0)); + this.add(editLabel, BorderLayout.WEST); + this.add(comboBox, BorderLayout.CENTER); + } + + public UIComboBox getComboBox() { + return comboBox; + } + + public void setComboBox(UIComboBox comboBox) { + this.comboBox = comboBox; + } + + public void addItem(String value) { + comboBox.addItem(value); + } + + protected void addItemListener(ItemListener aListener) { + comboBox.addItemListener(aListener); + } + + protected abstract void clearAllBackground(); + + public void clearBackGround() { + editLabel.resetNomalrBackground(); + } + + public boolean shouldResponseChangeListener() { + return true; + } + + public void registerChangeListener(UIObserverListener listener) { + this.listener = listener; + editLabel.registerChangeListener(listener); + } + + public void populateComboBox(String value) { + if (comboBox != null) { + comboBox.setEditable(true); + comboBox.setSelectedItem(value); + comboBox.setEditable(false); + } + } + + public Object updateComboBox() { + return comboBox.getSelectedItem(); + } + + public String getHeaderName() { + return editLabel.getText(); + } + + public void setHeaderName(String text) { + editLabel.setText(text); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java index 3ec2af314c..9a4e9bc795 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java @@ -2,8 +2,8 @@ package com.fr.van.chart.bubble; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; -import com.fr.design.i18n.Toolkit; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; @@ -12,7 +12,7 @@ import com.fr.plugin.chart.bubble.attr.VanChartAttrBubble; import com.fr.van.chart.bubble.component.VanChartBubblePane; import com.fr.van.chart.custom.component.VanChartCustomAxisConditionPane; import com.fr.van.chart.designer.TableLayout4VanChartHelper; -import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; +import com.fr.van.chart.designer.style.series.VanChartColorValueSeriesPane; import com.fr.van.chart.designer.style.series.VanChartStackedAndAxisListControlPane; import javax.swing.JPanel; @@ -22,7 +22,7 @@ import java.awt.Component; /** * Created by Mitisky on 16/3/31. */ -public class VanChartBubbleSeriesPane extends VanChartAbstractPlotSeriesPane { +public class VanChartBubbleSeriesPane extends VanChartColorValueSeriesPane { private static final long serialVersionUID = 5595016643808487932L; private VanChartBubblePane bubblePane; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHeatValueColorPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHeatValueColorPane.java new file mode 100644 index 0000000000..dac55c81c1 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHeatValueColorPane.java @@ -0,0 +1,74 @@ +package com.fr.van.chart.designer.component; + +import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.frpane.UINumberDragPane; +import com.fr.design.gui.ilable.BoldFontTextLabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.chart.gui.ColorSelectBoxWithOutTransparent; +import com.fr.design.mainframe.chart.gui.style.series.MapColorPickerPaneWithFormula; +import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.van.chart.designer.style.axis.component.MinMaxValuePaneWithOutTick; +import com.fr.van.chart.range.component.GradualIntervalConfigPane; +import com.fr.van.chart.range.component.GradualLegendPane; +import com.fr.van.chart.range.component.LegendGradientBar; +import com.fr.van.chart.range.component.SectionIntervalConfigPaneWithOutNum; +import com.fr.van.chart.range.component.SectionLegendPane; + +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-08-04 + */ +public class VanChartHeatValueColorPane extends VanChartValueColorPane { + + public VanChartHeatValueColorPane(VanChartStylePane parent) { + super(parent); + } + + protected GradualLegendPane createGradualLegendPane() { + return new GradualLegendPane() { + @Override + protected GradualIntervalConfigPane createGradualIntervalConfigPane() { + return new GradualIntervalConfigPane() { + @Override + protected Component[][] getPaneComponents(MinMaxValuePaneWithOutTick minMaxValuePane, ColorSelectBoxWithOutTransparent colorSelectBox, UINumberDragPane numberDragPane, LegendGradientBar legendGradientBar) { + return new Component[][]{ + new Component[]{minMaxValuePane, null}, + new Component[]{new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Value_Divided_Stage")), numberDragPane}, + new Component[]{null, legendGradientBar} + }; + } + }; + } + }; + } + + protected SectionLegendPane createSectionLegendPane() { + return new SectionLegendPane(getVanChartStylePane()) { + @Override + protected MapColorPickerPaneWithFormula createSectionIntervalConfigPane(AbstractAttrNoScrollPane parent) { + return new SectionIntervalConfigPaneWithOutNum(parent) { + private static final int WIDTH = 227; + + @Override + protected int getBoundX() { + return 0; + } + + @Override + protected int getBoundY() { + return 0; + } + + @Override + protected int getBoundWidth() { + return WIDTH; + } + }; + } + }; + } + +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartMarkerPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartMarkerPane.java index 58d717af1b..1f8b55cfbf 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartMarkerPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartMarkerPane.java @@ -104,9 +104,13 @@ public class VanChartMarkerPane extends BasicPane { return Toolkit.i18nText("Fine-Design_Chart_Marker"); } + protected VanChartAttrMarker createNewAttrMarker(){ + return new VanChartAttrMarker(); + } + public void populate(VanChartAttrMarker marker) { if(marker == null){ - marker = new VanChartAttrMarker(); + marker = createNewAttrMarker(); } commonORCustom.setSelectedIndex(marker.isCommon() ? 0 : 1); if(marker.isCommon()){ @@ -120,7 +124,7 @@ public class VanChartMarkerPane extends BasicPane { } public VanChartAttrMarker update() { - VanChartAttrMarker marker = new VanChartAttrMarker(); + VanChartAttrMarker marker = createNewAttrMarker(); if(commonORCustom.getSelectedIndex() == 0){ commonMarkerPane.updateBean(marker); } else { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java index af03afbe91..5920dd969f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java @@ -42,6 +42,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane valueColorTypeButton; + + //连续渐变面板 + private GradualLegendPane gradualLegendPane; + //区域渐变面板 + private SectionLegendPane sectionLegendPane; + + private VanChartStylePane parent; + + private JPanel rangeLegendPane; + + public VanChartValueColorPane(VanChartStylePane parent) { + this.parent = parent; + initComponents(); + } + + public VanChartStylePane getVanChartStylePane() { + return parent; + } + + public void initComponents() { + valueColorTypeButton = createLegendTypeButton(); + valueColorTypeButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkCardPane(); + } + }); + valueColorTypeButton.setSelectedIndex(0); + + UILabel label = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Color_Type")); + Component[][] labelComponent = new Component[][]{ + new Component[]{label, valueColorTypeButton}, + }; + JPanel legendTypeButtonWithTilePane = TableLayout4VanChartHelper.createGapTableLayoutPane(labelComponent); + legendTypeButtonWithTilePane.setBorder(BorderFactory.createEmptyBorder(10,0,0,0)); + //渐变色图例面板 + gradualLegendPane = createGradualLegendPane(); + //区域段图例面板 + sectionLegendPane = createSectionLegendPane(); + + rangeLegendPane = new JPanel(new CardLayout()) { + @Override + public Dimension getPreferredSize() { + if (valueColorTypeButton.getSelectedItem() == LegendType.GRADUAL) { + return gradualLegendPane.getPreferredSize(); + } else { + return sectionLegendPane.getPreferredSize(); + } + } + }; + + rangeLegendPane.add(gradualLegendPane, LegendType.GRADUAL.getStringType()); + rangeLegendPane.add(sectionLegendPane, LegendType.SECTION.getStringType()); + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] col = {f}; + double[] row = {p, p}; + Component[][] components = new Component[][]{ + new Component[]{legendTypeButtonWithTilePane}, + new Component[]{rangeLegendPane} + }; + JPanel tableLayoutPane = TableLayoutHelper.createTableLayoutPane(components, row, col); + + this.setLayout(new BorderLayout()); + this.add(tableLayoutPane, BorderLayout.CENTER); + } + + private void checkCardPane() { + CardLayout cardLayout = (CardLayout) rangeLegendPane.getLayout(); + cardLayout.show(rangeLegendPane, valueColorTypeButton.getSelectedItem().getStringType()); + this.validate(); + this.repaint(); + } + + private UIButtonGroup createLegendTypeButton() { + return new UIButtonGroup<>(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Continuous_Gradient"), + Toolkit.i18nText("Fine-Design_Chart_Area_Gradient") + }, new LegendType[]{LegendType.GRADUAL, LegendType.SECTION}); + } + + protected GradualLegendPane createGradualLegendPane() { + return new GradualLegendPane(); + } + + protected SectionLegendPane createSectionLegendPane() { + return new SectionLegendPane(parent); + } + + /** + * 标题 + * + * @return 标题 + */ + public String title4PopupWindow() { + return PaneTitleConstants.CHART_STYLE_SERIES_TITLE; + } + + public void updateBean(VanChartRangeLegend legend) { + LegendType legendType = valueColorTypeButton.getSelectedItem(); + legend.setLegendType(legendType); + if (legendType == LegendType.GRADUAL) { + gradualLegendPane.update(legend.getGradualLegend()); + } else if (legendType == LegendType.SECTION) { + sectionLegendPane.update(legend.getSectionLegend()); + } + } + + public void populateBean(VanChartRangeLegend legend) { + //范围图例部分 + if (legend.getLegendType() != LegendType.ORDINARY) { + valueColorTypeButton.setSelectedItem(legend.getLegendType()); + } + gradualLegendPane.populate(legend.getGradualLegend()); + sectionLegendPane.populate(legend.getSectionLegend()); + checkCardPane(); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java index f402418d7d..49ed070239 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java @@ -22,6 +22,7 @@ import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; import com.fr.plugin.chart.axis.type.AxisPlotType; import com.fr.plugin.chart.base.AttrEffect; +import com.fr.plugin.chart.base.AttrFloatColor; import com.fr.plugin.chart.base.AttrLabel; import com.fr.plugin.chart.base.RefreshMoreLabel; import com.fr.plugin.chart.base.VanChartAttrMarker; @@ -434,6 +435,7 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { conditionAttr.remove(ScatterAttrLabel.class); conditionAttr.remove(AttrEffect.class); conditionAttr.remove(AttrLineEffect.class); + conditionAttr.remove(AttrFloatColor.class); VanChartAttrMarker attrMarker = conditionAttr.getExisted(VanChartAttrMarker.class); if (attrMarker != null && !attrMarker.isCommon()) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartLineMapTooltipConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartLineMapTooltipConditionPane.java index 408480a791..d3ed1ab7a5 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartLineMapTooltipConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartLineMapTooltipConditionPane.java @@ -4,7 +4,7 @@ package com.fr.van.chart.designer.other.condition.item; import com.fr.chart.chartattr.Plot; import com.fr.design.condition.ConditionAttributesPane; import com.fr.van.chart.designer.style.tooltip.VanChartPlotTooltipPane; -import com.fr.van.chart.map.line.VanChartLineMapPlotTooltipPane; +import com.fr.van.chart.map.line.VanChartLineMapPlotTooltipNoCheckPane; /** * Created by hufan on 2016/12/23. @@ -16,6 +16,6 @@ public class VanChartLineMapTooltipConditionPane extends VanChartTooltipConditio } protected VanChartPlotTooltipPane createTooltipContentsPane() { - return new VanChartLineMapPlotTooltipPane(getPlot(), null); + return new VanChartLineMapPlotTooltipNoCheckPane(getPlot(), null); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/HeatMapRangeLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/HeatMapRangeLegendPane.java index 60c535ceb9..cb316dffeb 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/HeatMapRangeLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/HeatMapRangeLegendPane.java @@ -1,22 +1,6 @@ package com.fr.van.chart.designer.style; -import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; -import com.fr.design.gui.frpane.UINumberDragPane; -import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.i18n.Toolkit; -import com.fr.design.gui.ilable.BoldFontTextLabel; -import com.fr.design.mainframe.chart.gui.ColorSelectBoxWithOutTransparent; -import com.fr.design.mainframe.chart.gui.style.series.MapColorPickerPaneWithFormula; -import com.fr.plugin.chart.type.LegendType; -import com.fr.van.chart.designer.style.axis.component.MinMaxValuePaneWithOutTick; -import com.fr.van.chart.range.component.GradualIntervalConfigPane; -import com.fr.van.chart.range.component.GradualLegendPane; -import com.fr.van.chart.range.component.LegendGradientBar; -import com.fr.van.chart.range.component.SectionIntervalConfigPaneWithOutNum; -import com.fr.van.chart.range.component.SectionLegendPane; - import javax.swing.JPanel; -import java.awt.Component; /** * Created by Mitisky on 16/10/20. @@ -35,41 +19,4 @@ public class HeatMapRangeLegendPane extends VanChartRangeLegendPane { protected JPanel createCommonLegendPane(){ return this.createLegendPaneWithoutHighlight(); } - - @Override - protected UIButtonGroup createLegendTypeButton(){ - return new UIButtonGroup(new String[]{ - Toolkit.i18nText("Fine-Design_Chart_Legend_Gradual"), - Toolkit.i18nText("Fine-Design_Chart_Legend_Section") - }, new LegendType[]{LegendType.GRADUAL, LegendType.SECTION}); - } - - @Override - protected GradualLegendPane createGradualLegendPane() { - return new GradualLegendPane(){ - @Override - protected GradualIntervalConfigPane createGradualIntervalConfigPane() { - return new GradualIntervalConfigPane(){ - @Override - protected Component[][] getPaneComponents(MinMaxValuePaneWithOutTick minMaxValuePane, ColorSelectBoxWithOutTransparent colorSelectBox, UINumberDragPane numberDragPane, LegendGradientBar legendGradientBar) { - return new Component[][]{ - new Component[]{minMaxValuePane, null}, - new Component[]{new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Value_Divided_Stage")), numberDragPane}, - new Component[]{null, legendGradientBar} - }; - } - }; - } - }; - } - - @Override - protected SectionLegendPane createSectionLegendPane() { - return new SectionLegendPane(this.getLegendPaneParent()) { - @Override - protected MapColorPickerPaneWithFormula createSectionIntervalConfigPane(AbstractAttrNoScrollPane parent) { - return new SectionIntervalConfigPaneWithOutNum(parent); - } - }; - } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java index 3c5e992b92..241a93ea09 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java @@ -1,7 +1,6 @@ package com.fr.van.chart.designer.style; import com.fr.base.BaseUtils; -import com.fr.base.Style; import com.fr.chart.chartattr.Plot; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.UIBubbleFloatPane; @@ -61,6 +60,7 @@ public class VanChartPlotLegendPane extends BasicPane { private UIButtonGroup layoutButton; private JPanel layoutPane; private VanChartFloatPositionPane customFloatPositionPane; + private UIBubbleFloatPane uiBubbleFloatPane; //区域显示策略 恢复用注释。下面4行删除。 private UIButtonGroup customSize; @@ -80,7 +80,7 @@ public class VanChartPlotLegendPane extends BasicPane { initComponents(); } - public VanChartPlotLegendPane(VanChartStylePane parent){ + public VanChartPlotLegendPane(VanChartStylePane parent) { this.parent = parent; initComponents(); } @@ -118,9 +118,9 @@ public class VanChartPlotLegendPane extends BasicPane { new Component[]{legendPane}, }; - JPanel panel = TableLayoutHelper.createTableLayoutPane(components,row,col); + JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col); this.setLayout(new BorderLayout()); - this.add(panel,BorderLayout.CENTER); + this.add(panel, BorderLayout.CENTER); addLegendListener(); } @@ -133,7 +133,7 @@ public class VanChartPlotLegendPane extends BasicPane { }); } - protected JPanel createLegendPaneWithoutHighlight(){ + protected JPanel createLegendPaneWithoutHighlight() { borderPane = new VanChartBorderWithRadiusPane(); backgroundPane = new VanChartBackgroundWithOutImagePane(); @@ -141,19 +141,19 @@ public class VanChartPlotLegendPane extends BasicPane { double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double[] columnSize = {f, e}; - double[] rowSize = { p,p,p,p,p,p,p}; + double[] rowSize = {p, p, p, p, p, p, p}; Component[][] components = new Component[][]{ - new Component[]{createTitlePositionPane(new double[]{p,p,p},columnSize),null}, - new Component[]{createTitleStylePane(),null} , - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"),borderPane),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), createDisplayStrategy()),null} + new Component[]{createTitlePositionPane(new double[]{p, p, p}, columnSize), null}, + new Component[]{createTitleStylePane(), null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane), null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane), null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), createDisplayStrategy()), null} }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } - protected JPanel createLegendPane(){ + protected JPanel createLegendPane() { borderPane = new VanChartBorderWithRadiusPane(); backgroundPane = new VanChartBackgroundWithOutImagePane(); highlightPane = createHighlightPane(); @@ -166,14 +166,14 @@ public class VanChartPlotLegendPane extends BasicPane { double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double[] columnSize = {f, e}; - double[] rowSize = { p,p,p,p,p,p,p,p}; + double[] rowSize = {p, p, p, p, p, p, p, p}; Component[][] components = new Component[][]{ - new Component[]{createTitlePositionPane(new double[]{p,p,p},columnSize),null}, - new Component[]{createTitleStylePane(),null} , - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"),borderPane),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel),null}, + new Component[]{createTitlePositionPane(new double[]{p, p, p}, columnSize), null}, + new Component[]{createTitleStylePane(), null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane), null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane), null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel), null}, }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } @@ -205,12 +205,12 @@ public class VanChartPlotLegendPane extends BasicPane { customFloatPositionButton.setEventBannded(true); Component[][] components = new Component[][]{ - new Component[]{null,null}, - new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Layout_Position")),location}, - new Component[]{null,customFloatPositionButton} + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Layout_Position")), location}, + new Component[]{null, customFloatPositionButton} }; - customFloatPositionPane = new VanChartFloatPositionPane(); + customFloatPositionPane = new VanChartFloatPositionPane(); layoutPane = createLayoutPane(); initPositionListener(); @@ -241,7 +241,7 @@ public class VanChartPlotLegendPane extends BasicPane { return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p}, new double[]{f, e}); } - private void initPositionListener(){ + private void initPositionListener() { location.addChangeListener(new ChangeListener() { @Override @@ -262,18 +262,20 @@ public class VanChartPlotLegendPane extends BasicPane { checkLayoutPaneVisible(); checkDisplayStrategyUse(); - if(customFloatPositionPane == null) { - customFloatPositionPane = new VanChartFloatPositionPane(); + if (customFloatPositionPane == null) { + customFloatPositionPane = new VanChartFloatPositionPane(); + } + if (uiBubbleFloatPane == null) { + Point comPoint = customFloatPositionButton.getLocationOnScreen(); + Point arrowPoint = new Point(comPoint.x + customFloatPositionButton.getWidth() / 2 - GAP, comPoint.y + customFloatPositionButton.getHeight()); + uiBubbleFloatPane = new UIBubbleFloatPane(Constants.TOP, arrowPoint, customFloatPositionPane, WIDTH, HEIGHT) { + @Override + public void updateContentPane() { + parent.attributeChanged(); + } + }; } - Point comPoint = customFloatPositionButton.getLocationOnScreen(); - Point arrowPoint = new Point(comPoint.x + customFloatPositionButton.getWidth()/2 - GAP, comPoint.y + customFloatPositionButton.getHeight()); - UIBubbleFloatPane