diff --git a/build.gradle b/build.gradle index 707c8f2d06..d58f83f44b 100644 --- a/build.gradle +++ b/build.gradle @@ -60,10 +60,10 @@ allprojects { implementation 'com.fr.third:jxbrowser:6.23' implementation 'com.fr.third:jxbrowser-mac:6.23' implementation 'com.fr.third:jxbrowser-win64:6.23' - implementation 'com.fr.third:jxbrowser-v7:7.7' - implementation 'com.fr.third:jxbrowser-mac-v7:7.7' - implementation 'com.fr.third:jxbrowser-win64-v7:7.7' - implementation 'com.fr.third:jxbrowser-swing-v7:7.7' + implementation 'com.fr.third:jxbrowser-v7:7.15' + implementation 'com.fr.third:jxbrowser-mac-v7:7.15' + implementation 'com.fr.third:jxbrowser-win64-v7:7.15' + implementation 'com.fr.third:jxbrowser-swing-v7:7.15' implementation 'com.fr.third.server:servlet-api:3.0' implementation 'org.swingexplorer:swexpl:2.0.1' implementation 'org.swingexplorer:swag:1.0' diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 97b4d0f6ce..effd32b14a 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -17,9 +17,9 @@ import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.i18n.Toolkit; import com.fr.design.locale.impl.ProductImproveMark; -import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo; import com.fr.design.login.DesignerLoginType; import com.fr.design.login.config.DesignerLoginConfigManager; +import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.notification.SnapChatConfig; import com.fr.design.port.DesignerPortContext; @@ -87,6 +87,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private static final int MAX_SHOW_NUM = 10; private static final String VERSION_80 = "80"; + private static final String VERSION_90 = "90"; + private static final String VERSION100 = "100"; private static final int CACHINGTEMPLATE_LIMIT = 5; private static final String WEB_NAME = "webapps"; /** @@ -157,7 +159,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { //记录当前激活码的在线激活状态. private int activeKeyStatus = -1; private boolean joinProductImprove = true; - + private boolean startWithEmptyFile = false; private boolean embedServerLazyStartup = false; //最近使用的颜色 private ColorSelectConfigManager configManager = new ColorSelectConfigManager(); @@ -192,6 +194,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private static List mapWorkerList = new ArrayList(); private boolean imageCompress = false;//图片压缩 + private boolean showImageCompressMoveTip = true; // 开启内嵌web页面的调试窗口 private boolean openDebug = false; @@ -353,14 +356,21 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { try { fileWriter = new FileWriter(envFile); File oldEnvFile = new File(ProductConstants.getEnvHome() + File.separator + ProductConstants.APP_NAME + "6-1" + "Env.xml"); - File envFile80 = new File(getEnvHome(VERSION_80) + File.separator + getEnvFile().getName()); - if (oldEnvFile.exists()) { + File envFile80 = getOldEnvFile(VERSION_80); + File envFile90 = getOldEnvFile(VERSION_90); + File envFile100 = getOldEnvFile(VERSION100); + // 从10.0往前递进是否存在更老版本的配置文件 + if (envFile100.exists()) { + compatibilityPrevVersion(envFile100); + } else if (envFile90.exists()) { + compatibilityPrevVersion(envFile90); + } else if (envFile80.exists()) { + compatibilityPrevVersion(envFile80); + } else if (oldEnvFile.exists()) { // marks:兼容DesignerEnv6-1.xml FileReader fileReader = new FileReader(oldEnvFile); Utils.copyCharTo(fileReader, fileWriter); fileReader.close(); - } else if (envFile80.exists()) { - compatibilityPrevVersion(envFile80); } else { // marks:生成一个新的xml文件 StringReader stringReader = new StringReader(""); @@ -382,6 +392,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } } + private File getOldEnvFile(String version) { + return new File(getEnvHome(version) + File.separator + getEnvFile().getName()); + } + private static String getEnvHome(String version) { String userHome = System.getProperty("user.home"); if (userHome == null) { @@ -1351,6 +1365,24 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.maxNumberOrPreviewRow = maxNumberOrPreviewRow; } + /** + * 启动时是否打开空报表 + * + * @return 是否打开空报表 + */ + public boolean isStartWithEmptyFile() { + return startWithEmptyFile; + } + + /** + * 设置启动时是否打开空报表 + * + * @param startWithEmptyFile 是否打开空报表 + */ + public void setStartWithEmptyFile(boolean startWithEmptyFile) { + this.startWithEmptyFile = startWithEmptyFile; + } + /** * 是否展示工程界面 * @@ -1637,6 +1669,15 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.imageCompress = imageCompress; } + public boolean isShowImageCompressMoveTip() { + return showImageCompressMoveTip; + } + + public void setShowImageCompressMoveTip(boolean showImageCompressMoveTip) { + this.showImageCompressMoveTip = showImageCompressMoveTip; + } + + public boolean isOpenDebug() { return openDebug; } @@ -1792,6 +1833,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.setCachingTemplateLimit(reader.getAttrAsInt("cachingTemplateLimit", CACHINGTEMPLATE_LIMIT)); this.setJoinProductImprove(reader.getAttrAsBoolean("joinProductImprove", true)); this.setImageCompress(reader.getAttrAsBoolean("imageCompress", true)); + this.setShowImageCompressMoveTip(reader.getAttrAsBoolean("showImageCompressMoveTip", true)); this.setAutoBackUp(reader.getAttrAsBoolean("autoBackUp", true)); this.setTemplateTreePaneExpanded(reader.getAttrAsBoolean("templateTreePaneExpanded", false)); // peter:读取webinfLocation @@ -1828,6 +1870,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.setSupportCellEditorDef(reader.getAttrAsBoolean("supportCellEditorDef", false)); this.setDragPermited(reader.getAttrAsBoolean("isDragPermited", false)); this.setUndoLimit(reader.getAttrAsInt("undoLimit", 5)); + this.setStartWithEmptyFile(reader.getAttrAsBoolean("startWithEmptyFile", false)); this.setDefaultStringToFormula(reader.getAttrAsBoolean("defaultStringToFormula", false)); if ((tmpVal = reader.getAttrAsString("gridLineColor", null)) != null) { this.setGridLineColor(new Color(Integer.parseInt(tmpVal))); @@ -2072,6 +2115,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if (!this.isImageCompress()) { writer.attr("imageCompress", this.isImageCompress()); } + writer.attr("showImageCompressMoveTip", this.isShowImageCompressMoveTip()); if (!this.isAutoBackUp()) { writer.attr("autoBackUp", this.isAutoBackUp()); } @@ -2202,6 +2246,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { .attr("gridLineColor", this.getGridLineColor().getRGB()) .attr("paginationLineColor", this.getPaginationLineColor().getRGB()) .attr("undoLimit", this.getUndoLimit()) + .attr("startWithEmptyFile", this.isStartWithEmptyFile()) .end(); } 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 14145d1197..cd9c835f39 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -6,9 +6,9 @@ import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; -import com.fr.design.dialog.link.MessageWithLink; import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceInfoContext; import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.env.RemoteWorkspace; @@ -21,14 +21,11 @@ import com.fr.design.notification.NotificationCenter; import com.fr.design.utils.DesignUtils; import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.env.EnvListPane; -import com.fr.env.RemoteWorkspaceURL; -import com.fr.env.TestConnectionResult; +import com.fr.env.handler.WorkspaceExceptionHandler; import com.fr.exit.DesignerExiter; -import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import com.fr.invoke.Reflect; import com.fr.json.JSONArray; -import com.fr.license.exception.RegistEditionException; import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; import com.fr.process.ProcessEventPipe; @@ -46,8 +43,6 @@ import com.fr.workspace.base.WorkspaceAPI; import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.engine.base.FineObjectPool; import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; -import com.fr.workspace.engine.exception.WorkspaceAuthException; -import com.fr.workspace.engine.exception.WorkspaceCheckException; import com.fr.workspace.engine.exception.WorkspaceConnectionException; import com.fr.workspace.engine.rpc.WorkspaceProxyPool; @@ -66,7 +61,6 @@ import java.util.List; import java.util.Set; import java.util.HashSet; -import static javax.swing.JOptionPane.ERROR_MESSAGE; import static javax.swing.JOptionPane.QUESTION_MESSAGE; public class EnvChangeEntrance { @@ -79,6 +73,8 @@ public class EnvChangeEntrance { private static EnvChangeEntrance singleton = new EnvChangeEntrance(); } + private BasicDialog dialog; + private EnvChangeEntrance() { @@ -110,19 +106,13 @@ public class EnvChangeEntrance { private boolean switch2Env(final String envName, PopTipStrategy strategy) { DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); + DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv); WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); try { Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); boolean checkValid = workspace != null && selectedEnv.checkValid(); if (!checkValid) { - strategy.showTip(new PopTip() { - @Override - public void show() { - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); - } - }); return false; } @@ -149,34 +139,9 @@ public class EnvChangeEntrance { template.refreshToolArea(); } pluginErrorRemind(); - } catch (WorkspaceAuthException | RegistEditionException e) { - // String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"); - // String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote"); - strategy.showTip(new PopTip() { - @Override - public void show() { - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), - Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), - Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), - ERROR_MESSAGE, - UIManager.getIcon("OptionPane.errorIcon")); - } - }); - return false; - } catch (WorkspaceCheckException e) { - handleWorkspaceCheckException(e, strategy, connectionInfo); - return false; } catch (Exception exception) { - if (exception.getCause() instanceof WorkspaceCheckException) { - handleWorkspaceCheckException((WorkspaceCheckException) exception.getCause(), strategy, connectionInfo); - } else { - FineLoggerFactory.getLogger().error(exception.getMessage(), exception); - strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), - Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), - Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), - ERROR_MESSAGE, - UIManager.getIcon("OptionPane.errorIcon"))); - } + // 失败的处理 + WorkspaceExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv); return false; } TemplateTreePane.getInstance().refreshDockingView(); @@ -188,29 +153,6 @@ public class EnvChangeEntrance { return true; } - public void handleWorkspaceCheckException(WorkspaceCheckException e, PopTipStrategy strategy, WorkspaceConnectionInfo info) { - TestConnectionResult result = TestConnectionResult.parseByException(e); - FineLoggerFactory.getLogger().error(e.getMessage(), e); - if (ComparatorUtils.equals(result, TestConnectionResult.AUTH_FAILED)) { - strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), - Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), - Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), - ERROR_MESSAGE, - UIManager.getIcon("OptionPane.errorIcon"))); - } else { - if (result.isVerifyResult()) { - FineLoggerFactory.getLogger().error(result.getText().replaceAll(TestConnectionResult.WRAP, StringUtils.EMPTY) + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord")); - } - strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), - result.isVerifyResult() - ? new MessageWithLink(result.getText(), Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"), info.getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH) - : result.getText(), - Toolkit.i18nText("Fine-Design_Basic_Error"), - ERROR_MESSAGE, - UIManager.getIcon("OptionPane.errorIcon"))); - } - } - /** * 这个功能留着,可能会加回来,先做注释处理 * 切换远程环境之前,进行版本检测,当版本不一致的时候,提示。 @@ -440,7 +382,7 @@ public class EnvChangeEntrance { public void chooseEnv(final String envName) { final EnvListPane envListPane = new EnvListPane(); final BasicDialog envListDialog = envListPane.showWindow(DesignerContext.getDesignerFrame()); - + dialog = envListDialog; envListPane.populateEnvManager(envName); envListDialog.addDialogActionListener(new DialogActionAdapter() { @@ -450,13 +392,14 @@ public class EnvChangeEntrance { // 切换完成后清理密码 updateNotRememberPwdEnv(); if (changeResult) { - VersionCheckUtils.showVersionCheckDialog(envListPane.updateEnvManager()); + VersionCheckUtils.showVersionCheckDialog(envListPane.getSelectedName()); } } @Override public void doCancel() { envListDialog.dispose(); + dialog = null; // todo 断开了但是没选择新的环境,那么尝试重连旧环境,等接口 } }); @@ -466,7 +409,7 @@ public class EnvChangeEntrance { /** * 处理异常 */ - public void dealEvnExceptionWhenStartDesigner() { + public void dealEvnExceptionWhenStartDesigner(Throwable e, DesignerWorkspaceInfo workspaceInfo) { ProcessEventPipe eventPipe = FineProcessContext.getParentPipe(); if (eventPipe != null) { eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue())); @@ -474,6 +417,7 @@ public class EnvChangeEntrance { final EnvListPane envListPane = new EnvListPane(); envListPane.populateEnvManager(DesignerEnvManager.getEnvManager().getCurEnvName()); BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); + dialog = envListDialog; envListDialog.addDialogActionListener(new DialogActionAdapter() { @Override @@ -483,15 +427,19 @@ public class EnvChangeEntrance { DesignerExiter.getInstance().execute(); } else { updateNotRememberPwdEnv(); - VersionCheckUtils.showVersionCheckDialog(envListPane.updateEnvManager()); + VersionCheckUtils.showVersionCheckDialog(envListPane.getSelectedName()); } } @Override public void doCancel() { + dialog = null; DesignerExiter.getInstance().execute(); } }); + if (e != null) { + WorkspaceExceptionHandler.getInstance().handleInStart(e, workspaceInfo); + } envListDialog.setVisible(true); } @@ -523,6 +471,9 @@ public class EnvChangeEntrance { return false; } + public BasicDialog getDialog() { + return dialog; + } /** * 提示显示策略 @@ -559,14 +510,4 @@ public class EnvChangeEntrance { interface PopTip { void show(); } - - private static class SuccessPopTip implements PopTip { - @Override - public void show() { - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), - Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Success"), - Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), - FineJOptionPane.INFORMATION_MESSAGE); - } - } } diff --git a/designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java b/designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java index 4aa48591fd..4d1493e01b 100644 --- a/designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java +++ b/designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java @@ -18,6 +18,7 @@ import com.fr.design.fun.TableDataDefineProvider; import com.fr.design.fun.ToolbarItemProvider; import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOptionFactory; +import com.fr.design.mainframe.mobile.utils.MobileStyleProviderManager; import com.fr.design.menu.ShortCut; import com.fr.design.widget.Appearance; import com.fr.design.widget.mobile.WidgetMobilePane; @@ -269,11 +270,10 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement public MobileWidgetStyleProvider[] getMobileStyleOfWidget(String xType) { Set set = getArray(MobileWidgetStyleProvider.XML_TAG); - if (set.isEmpty()) { - return new MobileWidgetStyleProvider[0]; - } + Set allSet = MobileStyleProviderManager.getArray(MobileWidgetStyleProvider.XML_TAG); + allSet.addAll(set); List providers = new ArrayList<>(); - for (MobileWidgetStyleProvider provider : set) { + for (MobileWidgetStyleProvider provider : allSet) { if (ComparatorUtils.equalsIgnoreCase(provider.xTypeForWidget(), xType)) { providers.add(provider); } diff --git a/designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java b/designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java index 9e1d57dfd9..4e81a7ece4 100644 --- a/designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java +++ b/designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java @@ -4,6 +4,8 @@ import com.fr.design.constants.DesignerLaunchStatus; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.fun.HyperlinkProvider; import com.fr.design.fun.TableDataDefineProvider; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.ui.util.UIUtil; import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; import com.fr.plugin.observer.PluginEventType; @@ -28,7 +30,7 @@ public class PluginClassRefreshManager { @Override public void on(PluginEvent event) { // 重载模版之前 触发下hide - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange(); + fireTabChange(); // 兼容之前版本特性 for (String tag : context) { if (event.getContext().contain(tag)) { @@ -53,12 +55,24 @@ public class PluginClassRefreshManager { public void on(PluginEvent event) { PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, pluginAfterRunEventListener); if (DesignerLaunchStatus.getStatus() != DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE) { - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange(); + fireTabChange(); HistoryTemplateListCache.getInstance().reloadAllEditingTemplate(); } } }; + public void fireTabChange() { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + template.fireTabChange(); + } + }); + } + } + public static PluginClassRefreshManager getInstance() { return INSTANCE; 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 133bbb03f2..2e32eb88cb 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 @@ -12,9 +12,13 @@ import com.fr.design.editor.editor.IntegerEditor; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.ibutton.UINoThemeColorButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIDictionaryComboBox; +import com.fr.design.gui.ifilechooser.FileChooserProvider; +import com.fr.design.gui.ifilechooser.FileSelectionMode; +import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser; import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.iprogressbar.UIProgressBarUI; @@ -47,6 +51,8 @@ import com.fr.transaction.Worker; import com.fr.workspace.WorkContext; import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.git.config.GcConfig; +import com.sun.javafx.tk.FileChooserType; +import javafx.stage.FileChooser; import javax.swing.BorderFactory; import javax.swing.BoxLayout; @@ -165,6 +171,7 @@ public class PreferencePane extends BasicPane { private UICheckBox joinProductImproveCheckBox; private UICheckBox autoPushUpdateCheckBox; private UICheckBox embedServerLazyStartupCheckBox; + private UICheckBox imageCompressPanelCheckBox; private UICheckBox vcsEnableCheckBox; private UICheckBox saveCommitCheckBox; @@ -173,7 +180,7 @@ public class PreferencePane extends BasicPane { private UICheckBox gcEnableCheckBox; private UIButton gcButton; private UILabel remindVcsLabel; - + private UICheckBox startWithEmptyFile; private JDialog gcDialog; private UILabel gcMessage = new UILabel(); private JPanel gcDialogDownPane = new JPanel(); @@ -256,6 +263,10 @@ public class PreferencePane extends BasicPane { embedServerPanel.add(embedServerLazyStartupCheckBox); advancePane.add(embedServerPanel); + JPanel imageCompressPanel = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Template_Preview_Performance")); + imageCompressPanelCheckBox = new UICheckBox(i18nText("Fine-Design_Image_Compress")); + imageCompressPanel.add(imageCompressPanelCheckBox); + advancePane.add(imageCompressPanel); } private void createVcsSettingPane(JPanel generalPane) { @@ -336,18 +347,23 @@ public class PreferencePane extends BasicPane { } private void createFunctionPane(JPanel generalPane) { - JPanel functionPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Function")); - generalPane.add(functionPane); + JPanel topVerticalTitledBorderPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Function")); + JPanel upper = new JPanel(FRGUIPaneFactory.createLeftZeroVgapNormalHgapLayout()); + JPanel lower = new JPanel(FRGUIPaneFactory.createLeftZeroVgapNormalHgapLayout()); + topVerticalTitledBorderPane.add(upper); + topVerticalTitledBorderPane.add(lower); + generalPane.add(topVerticalTitledBorderPane); + //添加supportUndo选择项 supportUndoCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Preference_Support_Undo")); - functionPane.add(supportUndoCheckBox); + upper.add(supportUndoCheckBox); //添加maxUndoLimit //String[] undoTimes = {"最大撤销次数","5次","10次","15次","20次","50次"}; String[] undoTimes = {i18nText("Fine-Design_Basic_Max_Undo_Limit"), MAX_UNDO_LIMIT_5 + i18nText("Fine-Design_Basic_Time(s)"), MAX_UNDO_LIMIT_10 + i18nText("Fine-Design_Basic_Time(s)") , MAX_UNDO_LIMIT_15 + i18nText("Fine-Design_Basic_Time(s)"), MAX_UNDO_LIMIT_20 + i18nText("Fine-Design_Basic_Time(s)"), MAX_UNDO_LIMIT_50 + i18nText("Fine-Design_Basic_Time(s)")}; maxUndoLimit = new UIComboBox(undoTimes); - functionPane.add(maxUndoLimit); + upper.add(maxUndoLimit); //不支持撤销则不能选择撤销可缓存,也不能设置最大撤销次数 supportUndoCheckBox.addActionListener(new ActionListener() { @@ -361,12 +377,14 @@ public class PreferencePane extends BasicPane { //添加supportDefaultParentCalculate选择项 supportDefaultParentCalculateCheckBox = new UICheckBox( i18nText("Fine-Design_Basic_Preference_Support_Default_Parent_Calculate")); - functionPane.add(supportDefaultParentCalculateCheckBox); + upper.add(supportDefaultParentCalculateCheckBox); //添加是否展示打开模板提示缺少插件选择项 showTemplateMissingPlugin = new UICheckBox( i18nText("Fine-Design_Basic_Preference_Show-Template-Missing-Plugin")); - functionPane.add(showTemplateMissingPlugin); + upper.add(showTemplateMissingPlugin); + startWithEmptyFile = new UICheckBox(i18nText("Fine-Design_Basic_Preference_Start_Empty_File")); + lower.add(startWithEmptyFile); } private void createEditPane(JPanel generalPane) { @@ -457,10 +475,10 @@ public class PreferencePane extends BasicPane { JPanel colorSettingPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Setting_Colors")); generalPane.add(colorSettingPane); - gridLineColorTBButton = new UIColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); + gridLineColorTBButton = new UINoThemeColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); gridLineColorTBButton.setEnabled(this.isEnabled()); - paginationLineColorTBButton = new UIColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); + paginationLineColorTBButton = new UINoThemeColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); paginationLineColorTBButton.setEnabled(this.isEnabled()); JPanel leftPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); @@ -489,11 +507,13 @@ public class PreferencePane extends BasicPane { chooseDirBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - int saveValue = fileChooser.showOpenDialog(DesignerContext.getDesignerFrame()); + FileChooserProvider fileChooserProvider = + new JavaFxNativeFileChooser.Builder(). + fileSelectionMode(FileSelectionMode.DIR). + build(); + int saveValue = fileChooserProvider.showDialog(chooseDirBtn); if (saveValue == JFileChooser.APPROVE_OPTION) { - File selectedFile = fileChooser.getSelectedFile(); + File selectedFile = fileChooserProvider.getSelectedFile(); logExportDirectoryField.setText(selectedFile.getAbsolutePath()); } } @@ -665,7 +685,7 @@ public class PreferencePane extends BasicPane { defaultStringToFormulaBox.setSelected(false); } VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager(); - if (WorkContext.getCurrent().isCluster()){ + if (WorkContext.getCurrent().isCluster()) { vcsEnableCheckBox.setEnabled(false); gcEnableCheckBox.setEnabled(false); } @@ -717,6 +737,9 @@ public class PreferencePane extends BasicPane { } this.embedServerLazyStartupCheckBox.setSelected(designerEnvManager.isEmbedServerLazyStartup()); + this.startWithEmptyFile.setSelected(designerEnvManager.isStartWithEmptyFile()); + + this.imageCompressPanelCheckBox.setSelected(designerEnvManager.isImageCompress()); } private int chooseCase(int sign) { @@ -775,6 +798,7 @@ public class PreferencePane extends BasicPane { designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue()); designerEnvManager.setJoinProductImprove(this.joinProductImproveCheckBox.isSelected()); designerEnvManager.setEmbedServerLazyStartup(this.embedServerLazyStartupCheckBox.isSelected()); + designerEnvManager.setImageCompress(this.imageCompressPanelCheckBox.isSelected()); VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager(); vcsConfigManager.setSaveInterval(this.saveIntervalEditor.getValue()); vcsConfigManager.setVcsEnable(this.vcsEnableCheckBox.isSelected()); @@ -800,7 +824,7 @@ public class PreferencePane extends BasicPane { if (maxUndoLimit.getSelectedIndex() == SELECTED_INDEX_5) { designerEnvManager.setUndoLimit(MAX_UNDO_LIMIT_50); } - + designerEnvManager.setStartWithEmptyFile(startWithEmptyFile.isSelected()); if (WorkContext.getCurrent().isLocal()) { Configurations.update(new Worker() { @Override diff --git a/designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardHelper.java b/designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardHelper.java new file mode 100644 index 0000000000..870af0be5a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardHelper.java @@ -0,0 +1,24 @@ +package com.fr.design.base.clipboard; + +import java.util.List; + +public class ClipboardHelper { + public static String formatExcelString(List> table) { + StringBuffer stringBuffer = new StringBuffer(); + + for (int row = 0; row < table.size(); row++) { + List rowValue = table.get(row); + for (int col = 0; col < rowValue.size(); col++) { + Object cell = rowValue.get(col); + stringBuffer.append(cell); + if (col != rowValue.size() - 1) { + stringBuffer.append("\t"); + } + } + if (row != table.size() - 1) { + stringBuffer.append("\n"); + } + } + return stringBuffer.toString(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java b/designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java index 9c43f7f50a..1352833e6c 100644 --- a/designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java +++ b/designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java @@ -3,6 +3,7 @@ package com.fr.design.base.mode; import com.fr.design.designer.TargetComponent; import static com.fr.design.base.mode.DesignerMode.AUTHORITY; +import static com.fr.design.base.mode.DesignerMode.DUCHAMP; public class DesignModeContext { @@ -42,6 +43,9 @@ public class DesignModeContext { return mode == AUTHORITY; } + public static boolean isDuchampMode() { + return mode == DUCHAMP; + } public static void doCopy(TargetComponent principal) { if (isBanCopyAndCut() || principal == null) { diff --git a/designer-base/src/main/java/com/fr/design/base/mode/DesignerMode.java b/designer-base/src/main/java/com/fr/design/base/mode/DesignerMode.java index b0dd4baafc..d3dc1e5f4a 100644 --- a/designer-base/src/main/java/com/fr/design/base/mode/DesignerMode.java +++ b/designer-base/src/main/java/com/fr/design/base/mode/DesignerMode.java @@ -4,5 +4,6 @@ public enum DesignerMode { NORMAL, BAN_COPY_AND_CUT, VCS, - AUTHORITY + AUTHORITY, + DUCHAMP } 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 f1758f0689..ab86a0d6f2 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 @@ -161,10 +161,18 @@ public abstract class DesignTableDataManager { } public static String getChangedDsNameByOldDsName(String oldDsName) { + String changeName; + if (isDsNameChanged(oldDsName)) { - return dsNameChangedMap.get(oldDsName); + changeName = dsNameChangedMap.get(oldDsName); + } else { + changeName = StringUtils.EMPTY; + } + + if (StringUtils.isNotEmpty(changeName)) { + return getChangedDsNameByOldDsName(changeName); } else { - return StringUtils.EMPTY; + return oldDsName; } } diff --git a/designer-base/src/main/java/com/fr/design/data/DesignerStrategyConfigUtils.java b/designer-base/src/main/java/com/fr/design/data/StrategyConfigAttrUtils.java similarity index 88% rename from designer-base/src/main/java/com/fr/design/data/DesignerStrategyConfigUtils.java rename to designer-base/src/main/java/com/fr/design/data/StrategyConfigAttrUtils.java index 8bc5f36444..e2a75fc11b 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignerStrategyConfigUtils.java +++ b/designer-base/src/main/java/com/fr/design/data/StrategyConfigAttrUtils.java @@ -5,6 +5,7 @@ import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.mainframe.JTemplate; import com.fr.esd.core.strategy.config.StrategyConfig; import com.fr.esd.core.strategy.config.StrategyConfigHelper; +import com.fr.esd.core.strategy.config.service.StrategyConfigService; import com.fr.esd.core.strategy.persistence.StrategyConfigsAttr; import com.fr.esd.event.DSMapping; import com.fr.esd.event.DsNameTarget; @@ -25,7 +26,7 @@ import java.util.Set; * @version 10.0 * Created by rinoux on 2020/10/28 */ -public class DesignerStrategyConfigUtils { +public class StrategyConfigAttrUtils { /** * 获取当前编辑模版的数据集缓存配置属性 @@ -55,25 +56,6 @@ public class DesignerStrategyConfigUtils { } - /** - * 当前编辑的模版是否被批量开启 - * - * @return - */ - public static boolean isEditingTemplateRecommended() { - JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - - if (jTemplate != null) { - FILE file = jTemplate.getEditingFILE(); - if (file != null) { - String path = file.getPath(); - return StrategyConfigHelper.recommended(path); - } - } - return false; - } - - /** * 获取模版数据集配置 * diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java index b95c03ac6b..493d40d796 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java @@ -11,7 +11,7 @@ import com.fr.design.constants.UIConstants; import com.fr.design.data.BasicTableDataTreePane; import com.fr.design.data.BasicTableDataUtils; import com.fr.design.data.DesignTableDataManager; -import com.fr.design.data.DesignerStrategyConfigUtils; +import com.fr.design.data.StrategyConfigAttrUtils; import com.fr.design.data.tabledata.StoreProcedureWorkerListener; import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; import com.fr.design.data.tabledata.tabledatapane.DBTableDataPane; @@ -291,10 +291,10 @@ public class TableDataTreePane extends BasicTableDataTreePane { editingConfig.setDsName(tdName); if (!ComparatorUtils.equals(oldName, tdName)) { //重命名 - DesignerStrategyConfigUtils.removeStrategyConfig(oldName); + StrategyConfigAttrUtils.removeStrategyConfig(oldName); } - DesignerStrategyConfigUtils.addStrategyConfig(editingConfig); + StrategyConfigAttrUtils.addStrategyConfig(editingConfig); } ((DBTableData) td).setDsName(tdName); } @@ -588,7 +588,7 @@ public class TableDataTreePane extends BasicTableDataTreePane { if (wrapper.getTableData() instanceof DBTableData) { DBTableData td = (DBTableData) wrapper.getTableData(); - StrategyConfig config = DesignerStrategyConfigUtils.getStrategyConfig(wrapper.getTableDataName()); + StrategyConfig config = StrategyConfigAttrUtils.getStrategyConfig(wrapper.getTableDataName()); if (config == null) { result.put(td, td.isShare() ? ESDStatus.SINGLE_ON : ESDStatus.SINGLE_OFF); } else { @@ -632,14 +632,14 @@ public class TableDataTreePane extends BasicTableDataTreePane { StrategyConfig strategyConfig = getOrCreateStrategyConfig(dsName); strategyConfig.setEnable(true); strategyConfig.setUseGlobal(false); - DesignerStrategyConfigUtils.addStrategyConfig(strategyConfig); + StrategyConfigAttrUtils.addStrategyConfig(strategyConfig); DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); } } } private @NotNull StrategyConfig getOrCreateStrategyConfig(String dsName) { - StrategyConfig config = DesignerStrategyConfigUtils.getStrategyConfig(dsName); + StrategyConfig config = StrategyConfigAttrUtils.getStrategyConfig(dsName); if (config == null) { config = StrategyConfigHelper.createStrategyConfig(true); @@ -680,7 +680,7 @@ public class TableDataTreePane extends BasicTableDataTreePane { StrategyConfig strategyConfig = getOrCreateStrategyConfig(dsName); strategyConfig.setEnable(false); strategyConfig.setUseGlobal(false); - DesignerStrategyConfigUtils.addStrategyConfig(strategyConfig); + StrategyConfigAttrUtils.addStrategyConfig(strategyConfig); DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); } } @@ -814,7 +814,7 @@ public class TableDataTreePane extends BasicTableDataTreePane { checkButtonEnabled(); //删掉缓存配置 - DesignerStrategyConfigUtils.removeStrategyConfig(selectedNO.getName()); + StrategyConfigAttrUtils.removeStrategyConfig(selectedNO.getName()); // 如果一个模版是平台开启,这个数据集的配置不会存xml,预览模版时直接从全局配置copy,这样 // 导致删除的时候StrategyConfigsAttrSavedHook没有通过前后配置比较感知数据集被删除,因此不会发出事件让其失效 diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java b/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java index 8964ff8de0..422a3a49a8 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java @@ -9,6 +9,7 @@ import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.file.TableDataConfig; +import com.fr.stable.StringUtils; import javax.swing.*; import java.awt.*; @@ -80,12 +81,13 @@ public class TreeTableDataComboBox extends UIComboBox { } public void setSelectedTableDataByName(String name) { + refresh(); TableDataWrapper tableDataWrapper; - if (res_map.get(name) != null) { - tableDataWrapper = res_map.get(name); - } else { - String changeName = DesignTableDataManager.getChangedDsNameByOldDsName(name); + String changeName = DesignTableDataManager.getChangedDsNameByOldDsName(name); + if (StringUtils.isNotEmpty(changeName)) { tableDataWrapper = res_map.get(changeName); + } else { + tableDataWrapper = res_map.get(name); } this.getModel().setSelectedItem(tableDataWrapper); } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataDictPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataDictPane.java index f1f1c6c75e..175ddbfda3 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataDictPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataDictPane.java @@ -64,7 +64,7 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable { tableFlowPane.add(tableDataNameComboBox); tableDataNameComboBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { - tdChange(); + tdChange(true); } }); tableFlowPane.add(new PreviewLabel(this)); @@ -73,19 +73,21 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable { this.add(centerPane, BorderLayout.CENTER); parentMarkRadio = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Build_Tree_Accord_Parent_Marked_Filed"), true); lengthMarkRadio = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Build_Tree_Accord_Marked_Filed_Length")); - parentMarkRadio.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + parentMarkRadio.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { if (isBuildByParentFiled()) { makeParentEnable(); - tdChange(); + tdChange(false); } } }); - lengthMarkRadio.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + lengthMarkRadio.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { if (!isBuildByParentFiled()) { makeLengthEnable(); - tdChange(); + tdChange(false); } } }); @@ -169,7 +171,7 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable { } - private void tdChange() { + private void tdChange(boolean isChangeDS) { TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); if (tableDataWrappe == null) { return; @@ -186,7 +188,9 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable { String[] columnNames = new String[len]; namelist.toArray(columnNames); for (int i = 0; i < valueEditorPanes.length; i++) { - valueEditorPanes[i].setEditors(new Editor[]{new ColumnNameEditor(columnNames), new ColumnIndexEditor(len)}, columnNames[0]); + if (isChangeDS || isNoSelectedColumnName(valueEditorPanes[i])) { + valueEditorPanes[i].setEditors(new Editor[]{new ColumnNameEditor(columnNames), new ColumnIndexEditor(len)}, columnNames[0]); + } } } catch (Exception e) { for (int i = 0; i < valueEditorPanes.length; i++) { @@ -197,6 +201,10 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable { } } + private boolean isNoSelectedColumnName(ValueEditorPane valueEditorPane) { + return (Integer) valueEditorPane.update() == -1; + } + @Override protected String title4PopupWindow() { return "TreeTableDataDictionay"; diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java index 8a9a9779c1..0da46965b1 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java @@ -255,7 +255,6 @@ public class JDBCDefPane extends JPanel { this.dbtypeComboBox.setSelectedItem(OTHER_DB); } } - this.jdbcDatabase.setIdentity(jdbcDatabase.getIdentity()); this.driverComboBox.setSelectedItem(jdbcDatabase.getDriver()); this.urlTextField.setText(jdbcDatabase.getURL()); this.userNameTextField.setText(jdbcDatabase.getUser()); @@ -496,7 +495,7 @@ public class JDBCDefPane extends JPanel { if (isPortValid(port)) { updateURL(); } else { - portTextField.setText(port.replaceAll(getCharNeedReplace(e.getKeyChar()) , "")); + portTextField.setText(port.replaceAll(getCharNeedReplace(e.getKeyChar()), "")); if (!isPortValid(portTextField.getText())) { portTextField.setText(StringUtils.EMPTY); updateURL(); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java new file mode 100644 index 0000000000..eb8d188a1f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java @@ -0,0 +1,311 @@ +package com.fr.design.data.datapane.preview; + +import com.fr.design.base.clipboard.ClipboardHelper; +import com.fr.design.gui.itable.SortableJTable; +import com.fr.design.gui.itable.TableSorter; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.os.OperatingSystem; + +import javax.swing.*; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumnModel; +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; + +public class CopyableJTable extends SortableJTable { + + //区域选中用到的定位数据 + public int startRow = -1; + public int startCol = -1; + public int endRow = -1; + public int endCol = -1; + //单元格不连续多选用到的定位数据 + java.util.List pointList = new ArrayList<>(); + //shift键是否被按下 + public boolean isShiftDown = false; + //control\command键是否被按下 + public boolean isControlDown = false; + //是否可以复制 + public boolean isCopy = true; + int ctrlKeyCode = 17; + int cKeyCode = 67; + int shiftKeyCode = 16; + int commandKeyCode = 157; + //选中单元格的背景色 + Color selectBackGround = new Color(54, 133, 242, 63); + Color headerBackGround = new Color(229, 229, 229); + boolean mouseDrag = false; + boolean headerSelect = false; + + + class CopyableTableHeaderCellRenderer implements TableCellRenderer { + TableCellRenderer tableCellRenderer; + + CopyableTableHeaderCellRenderer(TableCellRenderer tableCellRenderer) { + this.tableCellRenderer = tableCellRenderer; + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + JComponent comp = (JComponent) this.tableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + if (isChoose(row, column)) { + comp.setBackground(selectBackGround); + } else { + comp.setBackground(headerBackGround); + } + return comp; + } + } + + + public CopyableJTable(TableSorter tableModel) { + super(tableModel); + initListener(); + this.getTableHeader().setDefaultRenderer(new CopyableTableHeaderCellRenderer(this.getTableHeader().getDefaultRenderer())); + } + + private void initListener() { + CopyableJTable self = this; + this.getTableHeader().addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + if (mouseDrag) { + headerSelect = true; + int column = getColumn(e); + self.updateEndPoint(-1, column); + self.getTableHeader().repaint(); + } + } + + @Override + public void mouseExited(MouseEvent e) { + if (mouseDrag) { + headerSelect = false; + } + } + + @Override + public void mouseClicked(MouseEvent e) { + headerSelect = true; + int column = getColumn(e); + if (column != -1) { + self.clearPoint(); + self.addPoint(-1, column); + self.updateStartPoint(-1, column); + self.updateEndPoint(-1, column); + self.refreshTable(); + } + } + + private int getColumn(MouseEvent e) { + JTableHeader h = (JTableHeader) e.getSource(); + TableColumnModel columnModel = h.getColumnModel(); + int viewColumn = columnModel.getColumnIndexAtX(e.getX()); + return viewColumn; + } + }); + this.getTableHeader().addMouseMotionListener(new MouseAdapter() { + @Override + public void mouseMoved(MouseEvent e) { + mouseDrag = false; + } + + @Override + public void mouseDragged(MouseEvent e) { + self.clearPoint(); + self.updateStartPoint(-1, -1); + self.updateEndPoint(-1, -1); + self.refreshTable(); + } + + }); + + + this.addMouseMotionListener(new java.awt.event.MouseAdapter() { + @Override + public void mouseDragged(MouseEvent evt) { + mouseDrag = true; + int row = self.rowAtPoint(evt.getPoint()); + int col = self.columnAtPoint(evt.getPoint()); + if (self.updateEndPoint(row, col)) { + self.refreshTable(); + } + } + + public void mouseMoved(MouseEvent e) { + mouseDrag = false; + } + }); + this.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + headerSelect = false; + int row = self.rowAtPoint(e.getPoint()); + int col = self.columnAtPoint(e.getPoint()); + if (!self.isControlDown) { + self.clearPoint(); + } + if (self.isShiftDown) { + self.clearPoint(); + } else { + self.updateStartPoint(row, col); + } + self.addPoint(row, col); + self.updateEndPoint(row, col); + + self.refreshTable(); + } + + }); + this.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (isControlKey(e)) { + isControlDown = true; + } else if (e.getKeyCode() == shiftKeyCode) { + isShiftDown = true; + } else if (e.getKeyCode() == cKeyCode) { + if (isControlDown && isCopy) { + self.copy(); + isCopy = false; + } + } + } + + @Override + public void keyReleased(KeyEvent e) { + if (isControlKey(e)) { + isControlDown = false; + isCopy = true; + } else if (e.getKeyCode() == shiftKeyCode) { + isShiftDown = false; + } + } + + private boolean isControlKey(KeyEvent e) { + if (e.getKeyCode() == ctrlKeyCode) { + return true; + } + if (e.getKeyCode() == commandKeyCode && OperatingSystem.isMacos()) { + return true; + } + return false; + } + }); + } + + + @Override + public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { + Component comp = super.prepareRenderer(renderer, row, column); + if (isChoose(row, column)) { + comp.setBackground(selectBackGround); + } else { + comp.setBackground(this.getBackground()); + } + return comp; + } + + + private boolean updateEndPoint(int row, int col) { + if (headerSelect && row != -1) + return false; + if (endRow != row || endCol != col) { + endRow = row; + endCol = col; + return true; + } + return false; + } + + private boolean updateStartPoint(int row, int col) { + if (startRow != row || startCol != col) { + startRow = row; + startCol = col; + return true; + } + return false; + } + + private void addPoint(int row, int col) { + pointList.add(new Point(row, col)); + } + + private void clearPoint() { + pointList = new ArrayList<>(); + } + + private void copy() { + FineLoggerFactory.getLogger().info("copy cell value"); + java.util.List> table = new ArrayList<>(); + if ((startRow != endRow || startCol != endCol) && Math.min(startCol, endCol) > -1) { + for (int i = Math.min(startRow, endRow); i <= Math.max(startRow, endRow); i++) { + table.add(new ArrayList<>()); + for (int j = Math.min(startCol, endCol); j <= Math.max(startCol, endCol); j++) { + Object text = this.getTableValue(i, j); + table.get(table.size() - 1).add(text); + } + } + } else if (pointList.size() > 0) { + Collections.sort(pointList, Comparator.comparing(Point::getX).thenComparing(Point::getY)); + int startRow = pointList.get(0).x; + int currentRow = startRow; + table.add(new ArrayList<>()); + for (Point point : pointList) { + while (currentRow < point.x) { + table.add(new ArrayList<>()); + currentRow++; + } + Object text = this.getTableValue(point.x, point.y); + table.get(table.size() - 1).add(text); + } + } + + Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard(); + Transferable tText = new StringSelection(ClipboardHelper.formatExcelString(table)); + clip.setContents(tText, null); + } + + private Object getTableValue(int row, int col) { + Object value = null; + if (col > -1) { + if (row > -1) { + value = this.getValueAt(row, col); + } else if (row == -1) { + col = columnModel.getColumn(col).getModelIndex(); + value = this.getModel().getColumnName(col); + } + } + return value; + } + + private void refreshTable() { + this.repaint(); + this.getTableHeader().repaint(); + } + + private boolean isChoose(int row, int col) { + if (row >= Math.min(startRow, endRow) && row <= Math.max(startRow, endRow)) { + if (col >= Math.min(startCol, endCol) && col <= Math.max(startCol, endCol)) { + return true; + } + } + for (Point point : pointList) { + if (point.x == row && point.y == col) { + return true; + } + } + return false; + } + +} 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 e95a5999ad..409ae7f7fa 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 @@ -26,7 +26,6 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.ui.util.UIUtil; -import com.fr.design.utils.gui.GUICoreUtils; import com.fr.function.TIME; import com.fr.general.FRFont; import com.fr.log.FineLoggerFactory; @@ -162,7 +161,7 @@ public class PreviewTablePane extends BasicPane { } }); - preveiwTable = new SortableJTable(new TableSorter()); + preveiwTable = new CopyableJTable(new TableSorter()); preveiwTable.setRowSelectionAllowed(false); preveiwTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/strategy/StrategyConfigHandler.java b/designer-base/src/main/java/com/fr/design/data/tabledata/strategy/StrategyConfigHandler.java new file mode 100644 index 0000000000..5b6a744d0d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/strategy/StrategyConfigHandler.java @@ -0,0 +1,37 @@ +package com.fr.design.data.tabledata.strategy; + +import com.fr.esd.core.strategy.config.StrategyConfig; +import com.fr.esd.query.StrategicTableData; + +/** + * @author rinoux + * @version 10.0 + * Created by rinoux on 2021/3/19 + */ +public abstract class StrategyConfigHandler { + + private final T tableData; + + public StrategyConfigHandler(T tableData) { + this.tableData = tableData; + } + + protected T getTableData() { + return tableData; + } + + /** + * 查找配置 + * + * @return 缓存配置 + */ + public abstract StrategyConfig find(); + + + /** + * 保存配置 + * + * @param config 缓存配置 + */ + public abstract void save(T saved, StrategyConfig config); +} 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 ec3276b92b..c57dfe00dd 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 @@ -12,19 +12,18 @@ import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.UIConstants; -import com.fr.design.data.DesignerStrategyConfigUtils; +import com.fr.design.data.StrategyConfigAttrUtils; import com.fr.design.data.datapane.ESDStrategyConfigPane; import com.fr.design.data.datapane.connect.ConnectionTableProcedurePane; import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.datapane.preview.sql.PreviewPerformedSqlPane; import com.fr.design.data.datapane.sqlpane.SQLEditPane; -import com.fr.design.data.tabledata.tabledatapane.db.ServerStrategyConfigHandler; +import com.fr.design.data.tabledata.strategy.StrategyConfigHandler; import com.fr.design.data.tabledata.tabledatapane.db.StrategyConfigFrom; -import com.fr.design.data.tabledata.tabledatapane.db.StrategyConfigHandler; -import com.fr.design.data.tabledata.tabledatapane.db.TemplateStrategyConfigHandler; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.fun.DBTableDataMenuHandler; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; @@ -43,7 +42,12 @@ import com.fr.design.menu.ToolBarDef; import com.fr.design.utils.ParameterUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.esd.core.strategy.config.StrategyConfig; +import com.fr.esd.core.strategy.config.StrategyConfigHelper; import com.fr.esd.core.strategy.config.service.StrategyConfigService; +import com.fr.esd.data.db.DBTableDataSavedHook; +import com.fr.esd.event.DSMapping; +import com.fr.esd.event.DsNameTarget; +import com.fr.esd.event.StrategyEventsNotifier; import com.fr.esd.query.StrategicTableData; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; @@ -53,6 +57,7 @@ import com.fr.script.Calculator; import com.fr.stable.ArrayUtils; import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; +import com.fr.workspace.WorkContext; import javax.swing.BorderFactory; import javax.swing.Box; @@ -101,7 +106,7 @@ public class DBTableDataPane extends AbstractTableDataPane { //配置 private StrategyConfig strategyConfig; - private StrategyConfigHandler configHandler; + private StrategyConfigHandler configHandler; public DBTableDataPane() { @@ -348,7 +353,8 @@ public class DBTableDataPane extends AbstractTableDataPane { //判断是不是模版数据集 switch (this.dbTableData.getScope()) { case TEMPLATE: - setEsdEnableStatus(DesignerStrategyConfigUtils.isEditingTemplateRecommended(), false); + String tplPath = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath(); + setEsdEnableStatus(StrategyConfigService.isTemplateEnabled(tplPath), false); break; case SERVER: //不会走到这里 @@ -619,4 +625,116 @@ public class DBTableDataPane extends AbstractTableDataPane { return this.title; } } + + /** + * 服务器数据集配置处理器 + */ + private static class ServerStrategyConfigHandler extends StrategyConfigHandler { + private final String origName; + + private final String origConnection; + + private final String origQuery; + + public ServerStrategyConfigHandler(DBTableData tableData) { + super(tableData); + this.origName = tableData.getDsName(); + this.origConnection = tableData.getDatabase().toString(); + this.origQuery = tableData.getQuery(); + } + + @Override + public StrategyConfig find() { + StrategyConfig strategyConfig = null; + if (getTableData() != null) { + try { + strategyConfig = getTableData().getStrategyConfig() == null ? null : getTableData().getStrategyConfig().clone(); + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + return strategyConfig; + } + + @Override + public void save(DBTableData saved, StrategyConfig strategyConfig) { + String conn = saved.getDatabase().toString(); + String query = saved.getQuery(); + + + //检查数据链接和sql是否修改,如果修改需要触发缓存监听事件 + if (!conn.equals(origConnection) || !query.equals(origQuery)) { + if (StringUtils.isNotEmpty(origName)) { + //新建数据集的origName为null,不用触发 + StrategyEventsNotifier.modifyDataSet(DSMapping.ofServerDS(new DsNameTarget(origName))); + } + } + + + //配置变动事件 + try { + final StrategyConfig orig = getTableData().getStrategyConfig(); + saved.setStrategyConfig(strategyConfig.clone()); + StrategyEventsNotifier.compareAndFireConfigEvents(orig, strategyConfig, DSMapping.ofServerDS(new DsNameTarget(saved.getDsName()))); + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + } + + + /** + * 模版数据集配置处理器 + */ + private static class TemplateStrategyConfigHandler extends StrategyConfigHandler { + public TemplateStrategyConfigHandler(DBTableData tableData) { + super(tableData); + } + + @Override + public StrategyConfig find() { + StrategyConfig strategyConfig = null; + String tplPath = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath(); + if (getTableData() != null && StringUtils.isNotEmpty(tplPath)) { + //设置保存数据集的事件检查钩子 + //新建模版此时不存在,不需要注册钩子 + if (getTableData().getXmlSavedHook() == null && WorkContext.getWorkResource().exist(tplPath)) { + getTableData().setXmlSavedHook(new DBTableDataSavedHook(tplPath, getTableData())); + } + + //获取当前的缓存配置,没有就创建一份 + String dsName = getTableData().getDsName(); + + //这里为了之前兼容插件创建的配置,缓存配置不在DBTableData,而是从模版attr读取 + strategyConfig = StrategyConfigAttrUtils.getStrategyConfig(dsName); + + + if (useGlobal(getTableData(), strategyConfig)) { + //使用全局配置 + strategyConfig = StrategyConfigHelper.createStrategyConfig(true); + } else if (getTableData().isShare()) { + //使用共享数据集兼容配置 + strategyConfig = StrategyConfigHelper.createStrategyConfig(true, false, true); + } + } + + return strategyConfig; + } + + private boolean useGlobal(DBTableData dbTableData, StrategyConfig strategyConfig) { + //非共享且配置为空或者指定使用全局配置时,检查是否全局开启 + if (strategyConfig == null) { + return !dbTableData.isShare(); + } else { + return strategyConfig.isUseGlobal(); + } + } + + @Override + public void save(DBTableData saved, StrategyConfig config) { + + //DBTableDataSavedHook处理了 + } + } } diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/db/DBTableDataSavedHook.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/db/DBTableDataSavedHook.java deleted file mode 100644 index 8d9a51249d..0000000000 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/db/DBTableDataSavedHook.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.fr.design.data.tabledata.tabledatapane.db; - -import com.fr.data.impl.DBTableData; -import com.fr.esd.event.DSMapping; -import com.fr.esd.event.DsNameTarget; -import com.fr.esd.event.StrategyEventsNotifier; -import com.fr.esd.event.xml.XMLSavedHook; -import com.fr.stable.StringUtils; - -public class DBTableDataSavedHook implements XMLSavedHook { - - private static final long serialVersionUID = 4925391747683335372L; - - private final String tplPath; - private String origName; - - private String origConnection; - - private String origQuery; - - public DBTableDataSavedHook(String tplPath, DBTableData origDBTableData) { - this.tplPath = tplPath; - this.origName = origDBTableData.getDsName(); - this.origConnection = origDBTableData.getDatabase().toString(); - this.origQuery = origDBTableData.getQuery(); - } - - @Override - public void doAfterSaved(DBTableData saved) { - String dsName = saved.getDsName(); - String conn = saved.getDatabase().toString(); - String query = saved.getQuery(); - - - //检查数据集名称、数据链接和sql是否修改,如果修改需要触发缓存监听事件 - if (!dsName.equals(origName) || !conn.equals(origConnection) || !query.equals(origQuery)) { - if (StringUtils.isNotEmpty(tplPath) && StringUtils.isNotEmpty(origName)) { - //新建数据集的origName为null,不用触发 - StrategyEventsNotifier.modifyDataSet(new DSMapping(tplPath, new DsNameTarget(origName))); - } - } - - this.origName = dsName; - this.origConnection = conn; - this.origQuery = query; - } -} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/db/ServerStrategyConfigHandler.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/db/ServerStrategyConfigHandler.java deleted file mode 100644 index 467c294822..0000000000 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/db/ServerStrategyConfigHandler.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.fr.design.data.tabledata.tabledatapane.db; - -import com.fr.data.impl.DBTableData; -import com.fr.esd.core.strategy.config.StrategyConfig; -import com.fr.esd.event.DSMapping; -import com.fr.esd.event.DsNameTarget; -import com.fr.esd.event.StrategyEventsNotifier; -import com.fr.log.FineLoggerFactory; -import com.fr.stable.StringUtils; - -/** - * @author rinoux - * @version 10.0 - * Created by rinoux on 2021/3/19 - */ -public class ServerStrategyConfigHandler implements StrategyConfigHandler { - private final DBTableData tableData; - - private final String origName; - - private final String origConnection; - - private final String origQuery; - - public ServerStrategyConfigHandler(DBTableData tableData) { - this.tableData = tableData; - this.origName = tableData.getDsName(); - this.origConnection = tableData.getDatabase().toString(); - this.origQuery = tableData.getQuery(); - } - - @Override - public StrategyConfig find() { - StrategyConfig strategyConfig = null; - if (tableData != null) { - try { - strategyConfig = tableData.getStrategyConfig() == null ? null : tableData.getStrategyConfig().clone(); - } catch (CloneNotSupportedException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - - return strategyConfig; - } - - @Override - public void save(DBTableData saved, StrategyConfig strategyConfig) { - String conn = saved.getDatabase().toString(); - String query = saved.getQuery(); - - - //检查数据链接和sql是否修改,如果修改需要触发缓存监听事件 - if (!conn.equals(origConnection) || !query.equals(origQuery)) { - if (StringUtils.isNotEmpty(origName)) { - //新建数据集的origName为null,不用触发 - StrategyEventsNotifier.modifyDataSet(DSMapping.ofServerDS(new DsNameTarget(origName))); - } - } - - - //配置变动事件 - try { - final StrategyConfig orig = tableData.getStrategyConfig(); - saved.setStrategyConfig(strategyConfig.clone()); - StrategyEventsNotifier.compareAndFireConfigEvents(orig, strategyConfig, DSMapping.ofServerDS(new DsNameTarget(saved.getDsName()))); - } catch (CloneNotSupportedException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } -} diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/db/StrategyConfigHandler.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/db/StrategyConfigHandler.java deleted file mode 100644 index 346410e0e5..0000000000 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/db/StrategyConfigHandler.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.fr.design.data.tabledata.tabledatapane.db; - -import com.fr.data.impl.DBTableData; -import com.fr.esd.core.strategy.config.StrategyConfig; - -/** - * @author rinoux - * @version 10.0 - * Created by rinoux on 2021/3/19 - */ -public interface StrategyConfigHandler { - - StrategyConfig find(); - - void save(DBTableData saved, StrategyConfig config); -} diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/db/TemplateStrategyConfigHandler.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/db/TemplateStrategyConfigHandler.java deleted file mode 100644 index 4b0c98add2..0000000000 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/db/TemplateStrategyConfigHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.fr.design.data.tabledata.tabledatapane.db; - -import com.fr.base.TableData; -import com.fr.data.impl.DBTableData; -import com.fr.design.data.DesignerStrategyConfigUtils; -import com.fr.design.file.HistoryTemplateListCache; -import com.fr.esd.core.strategy.config.StrategyConfig; -import com.fr.esd.query.StrategicTableData; -import com.fr.workspace.WorkContext; - -/** - * @author rinoux - * @version 10.0 - * Created by rinoux on 2021/3/19 - */ -public class TemplateStrategyConfigHandler implements StrategyConfigHandler { - - DBTableData tableData; - - public TemplateStrategyConfigHandler(DBTableData tableData) { - this.tableData = tableData; - } - - @Override - public StrategyConfig find() { - StrategyConfig strategyConfig = null; - if (tableData != null) { - //设置保存数据集的事件检查钩子 - String tplPath = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath(); - - //新建模版此时不存在,不需要注册钩子 - if (tableData.getXmlSavedHook() == null && WorkContext.getWorkResource().exist(tplPath)) { - tableData.setXmlSavedHook(new DBTableDataSavedHook(tplPath, tableData)); - } - - //获取当前的缓存配置,没有就创建一份 - String dsName = tableData.getDsName(); - - //这里为了之前兼容插件创建的配置,缓存配置不在DBTableData,而是从模版attr读取 - strategyConfig = DesignerStrategyConfigUtils.getStrategyConfig(dsName); - } - - return strategyConfig; - } - - @Override - public void save(DBTableData saved, StrategyConfig config) { - - } -} diff --git a/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java b/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java index 930dde76c7..d3c592a4ed 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java +++ b/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java @@ -410,6 +410,4 @@ public abstract class BasicPane extends JPanel { } } - - } diff --git a/designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java b/designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java index b136f50c89..258a6cf8a5 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java +++ b/designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java @@ -3,6 +3,7 @@ package com.fr.design.dialog; import com.fr.concurrent.NamedThreadFactory; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.DesignSizeI18nManager; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; @@ -10,6 +11,7 @@ import com.fr.design.notification.Notification; import com.fr.design.notification.NotificationCenter; import com.fr.module.ModuleContext; import com.fr.stable.StringUtils; + import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; @@ -40,9 +42,17 @@ public class NotificationDialog extends JDialog { private UILabel messageText; private NotificationDialogAction notificationDialogAction; private ScheduledExecutorService TIMER; + private Dimension dialogSize = new Dimension(230, 95); public NotificationDialog(Frame owner, String title, boolean isModal, int messageType, String message, NotificationDialogAction action) { + this(owner, title, isModal, messageType, message, action, null); + } + + public NotificationDialog(Frame owner, String title, boolean isModal, int messageType, String message, NotificationDialogAction action, Dimension dimension) { super(owner); + if (dimension != null) { + this.dialogSize = dimension; + } setTitle(title); initComponents(StringUtils.EMPTY, messageType, message, isModal, action); } @@ -77,7 +87,7 @@ public class NotificationDialog extends JDialog { JScrollPane jScrollPane = new JScrollPane(messageText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jScrollPane.setBorder(BorderFactory.createEmptyBorder()); centerPanel.add(jScrollPane, BorderLayout.CENTER); - centerPanel.setPreferredSize(new Dimension(230, 95)); + centerPanel.setPreferredSize(dialogSize); body.add(centerPanel, BorderLayout.CENTER); //查看详情 diff --git a/designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java b/designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java new file mode 100644 index 0000000000..b9854c6bcd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java @@ -0,0 +1,251 @@ +package com.fr.design.dialog; + +import com.fr.base.GraphHelper; +import com.fr.design.dialog.link.MessageWithLink; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextarea.UITextArea; +import com.fr.design.i18n.Toolkit; +import com.fr.design.utils.DesignUtils; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.IOUtils; +import com.fr.stable.StringUtils; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.PrintWriter; +import java.io.StringWriter; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +/** + * 带链接的错误详情弹窗 + * + * @author hades + * @version 10.0 + * Created by hades on 2021/8/2 + */ +public class UIDetailErrorLinkDialog extends UIDialog { + + private static final Color LINK_COLOR = new Color(51, 152, 253); + private static final int GAP_5 = 5; + private static final int GAP_10 = 10; + private static final String TAG_A_START = ""; + private static final String TAG_A_END = ""; + private static final double SCALE = 1.2; + + private final Dimension dimension = new Dimension(300, 180); + + public static Builder newBuilder() { + return new Builder(); + } + + private UIDetailErrorLinkDialog(Frame parent, Builder builder) { + super(parent); + init(builder); + } + + private UIDetailErrorLinkDialog(Dialog parent, Builder builder) { + super(parent); + init(builder); + } + + private void init(Builder builder) { + this.setTitle(builder.title); + // 顶部 图标和提示 + UILabel errorIcon = new UILabel(IOUtils.readIcon("com/fr/design/images/lookandfeel/Information_Icon_Error_32x32.png")); + UILabel errorInfo= new UILabel(builder.reason); + JPanel topPane = new JPanel(new FlowLayout(FlowLayout.LEFT, GAP_10, GAP_5)); + topPane.add(errorIcon); + topPane.add(errorInfo); + + // 中部 详细内容 + JPanel contentPane = new JPanel(new BorderLayout()); + contentPane.setBorder(BorderFactory.createEmptyBorder(0, GAP_5,0,0)); + UILabel errorCodeLabel = new UILabel(Toolkit.i18nText("Fine_Design_Basic_Error_Code", builder.errorCode)); + UILabel link = new UILabel(Toolkit.i18nText("Fine_Design_Basic_Show_Error_Stack")); + link.setForeground(LINK_COLOR); + link.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + StringWriter stackTraceWriter = new StringWriter(); + builder.throwable.printStackTrace(new PrintWriter(stackTraceWriter)); + StackPane stackPane = new StackPane(stackTraceWriter.toString()); + BasicDialog dialog = stackPane.showLargeWindow(UIDetailErrorLinkDialog.this, null); + dialog.setVisible(true); + } + }); + contentPane.add(errorCodeLabel, BorderLayout.NORTH); + contentPane.add(createComponent(builder), BorderLayout.CENTER); + contentPane.add(link, BorderLayout.SOUTH); + + // 确定 + 取消 + JPanel actionPane = new JPanel(new FlowLayout(FlowLayout.RIGHT, GAP_10, GAP_10)); + actionPane.add(createButton(Toolkit.i18nText("Fine-Design_Report_OK"))); + actionPane.add(createButton(Toolkit.i18nText("Fine-Design_Basic_Cancel"))); + this.getContentPane().add(topPane, BorderLayout.NORTH); + this.getContentPane().add(contentPane, BorderLayout.CENTER); + this.getContentPane().add(actionPane, BorderLayout.SOUTH); + this.setSize(dimension); + this.setResizable(false); + this.setModal(true); + GUICoreUtils.centerWindow(this); + } + + private UIButton createButton(String content) { + UIButton button = new UIButton(content); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + UIDetailErrorLinkDialog.this.dispose(); + } + }); + return button; + } + + private JComponent createComponent(Builder builder) { + JPanel panel = new JPanel(new BorderLayout()); + boolean existDetailReason = StringUtils.isNotEmpty(builder.detailReason); + int maxWidth = dimension.width; + if (existDetailReason) { + String message = Toolkit.i18nText("Fine_Design_Basic_Detail_Error_Info", builder.detailReason); + UILabel label = new UILabel(message); + maxWidth = Math.max(maxWidth, GraphHelper.getWidth(message, label.getFont())); + panel.add(label, BorderLayout.NORTH); + } + String solution = existDetailReason ? builder.solution : Toolkit.i18nText("Fine_Design_Basic_Detail_Error_Info", builder.solution); + if (builder.solution.contains(TAG_A_START)) { + String[] solutionP1 = solution.split(TAG_A_START); + String[] solutionP2 = solutionP1[1].split(TAG_A_END); + MessageWithLink messageWithLink; + if (solutionP2.length == 2) { + messageWithLink = new MessageWithLink(solutionP1[0], solutionP2[0], builder.link, solutionP2[1]); + } else { + messageWithLink = new MessageWithLink(solutionP1[0], solutionP2[0], builder.link); + } + + panel.add(messageWithLink, BorderLayout.CENTER); + } else { + UILabel solutionLabel = new UILabel(solution); + panel.add(solutionLabel, BorderLayout.CENTER); + } + dimension.width = getMaxDimensionWidth(maxWidth, solution); + return panel; + + } + + private int getMaxDimensionWidth(int width, String solution) { + int maxWidth = GraphHelper.getWidth(solution, DesignUtils.getDefaultGUIFont()); + if (maxWidth >= width) { + maxWidth = (int) (SCALE * maxWidth); + } else { + maxWidth = width; + } + return maxWidth; + } + + @Override + public void checkValid() throws Exception { + // do nothing + } + + class StackPane extends BasicPane { + + public StackPane(String stack) { + setLayout(new BorderLayout()); + UITextArea textArea = new UITextArea(); + textArea.setEditable(false); + textArea.setText(stack); + UIScrollPane scrollPane = new UIScrollPane(textArea); + add(scrollPane); + // 滚动条默认在顶部 + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + scrollPane.getViewport().setViewPosition(new Point(0, 0)); + } + }); + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine_Design_Basic_Error_Stack"); + } + } + + public static class Builder { + private Window window; + private String title; + private String reason; + private String errorCode; + private String detailReason; + private String solution; + private String link; + private Throwable throwable; + + private Builder() { + + } + + public Builder setTitle(String title) { + this.title = title; + return this; + } + + public Builder setReason(String reason) { + this.reason = reason; + return this; + } + + public Builder setErrorCode(String errorCode) { + this.errorCode = errorCode; + return this; + } + + public Builder setSolution(String solution) { + this.solution = solution; + return this; + } + + public Builder setDetailReason(String detailReason) { + this.detailReason = detailReason; + return this; + } + + public Builder setThrowable(Throwable throwable) { + this.throwable = throwable; + return this; + } + + public Builder setWindow(Window window) { + this.window = window; + return this; + } + + public Builder setLink(String link) { + this.link = link; + return this; + } + + public UIDetailErrorLinkDialog build() { + if (this.window instanceof Frame) { + return new UIDetailErrorLinkDialog((Frame) window, this); + } else { + return new UIDetailErrorLinkDialog((Dialog) window, this); + } + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java index ccc98bfe37..3882291d00 100644 --- a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java @@ -15,5 +15,5 @@ public interface DesignerWorkspaceInfo extends XMLable { WorkspaceConnectionInfo getConnection(); - boolean checkValid(); + boolean checkValid() throws Exception; } diff --git a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.java b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.java new file mode 100644 index 0000000000..ba8a5b09f4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.java @@ -0,0 +1,20 @@ +package com.fr.design.env; + +/** + * + * @author hades + * @version 10.0 + * Created by hades on 2021/8/24 + */ +public class DesignerWorkspaceInfoContext { + + private static DesignerWorkspaceInfo workspaceInfo; + + public static DesignerWorkspaceInfo getWorkspaceInfo() { + return workspaceInfo; + } + + public static void setWorkspaceInfo(DesignerWorkspaceInfo workspaceInfo) { + DesignerWorkspaceInfoContext.workspaceInfo = workspaceInfo; + } +} diff --git a/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java index ef1f420d62..a7d6eb6c17 100644 --- a/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java @@ -1,18 +1,38 @@ package com.fr.design.env; import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralUtils; +import com.fr.locale.InterProviderFactory; +import com.fr.stable.CoreConstants; +import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; +import com.fr.stable.project.ProjectConstants; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; import com.fr.workspace.connect.WorkspaceConnectionInfo; +import com.fr.workspace.engine.exception.MainVersionNotMatchException; import java.io.File; +import java.util.Properties; /** * Created by juhaoyu on 2018/6/15. */ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { - + + private static final String REPORT_ENGINE_KEY = "report-engine-key"; + private static final String REPORT_ENGINE_JAR; + private static final String PROP_PATH = "/com/fr/env/jarVersion.properties"; + + static { + Properties properties = new Properties(); + try { + properties.load(LocalDesignerWorkspaceInfo.class.getResourceAsStream(PROP_PATH)); + } catch (Exception ignored) { + } + REPORT_ENGINE_JAR = properties.getProperty(REPORT_ENGINE_KEY, "default.jar"); + } + private String name; private String path; @@ -86,6 +106,14 @@ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { return false; } + File engineLib = new File(StableUtils.pathJoin(this.path, ProjectConstants.LIB_NAME, REPORT_ENGINE_JAR)); + // 非安装版本允许自由切换 + boolean notExistLib = !CoreConstants.DOT.equals(StableUtils.getInstallHome()) + && !engineLib.exists(); + if (notExistLib) { + throw new MainVersionNotMatchException(); + } + return true; } } diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java index 96069b4356..920a13dbfb 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java @@ -168,8 +168,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { @Override - public boolean checkValid() { - boolean result = false; + public boolean checkValid() throws Exception { String newPort = Integer.toString(DesignerEnvManager.getEnvManager().getEmbedServerPort()); if (!ComparatorUtils.equals(port, newPort)) { // 使用过程中 更改了内置服务器端口 重新初始化下 @@ -177,15 +176,9 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { } if (FILTER_SET.contains(connection.getUrl())) { FineLoggerFactory.getLogger().error("url is same with local designer"); - return result; + return false; } - try { - WorkContext.getConnector().validateVT(connection); - result = true; - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - return result; - } - return result; + WorkContext.getConnector().validateVT(connection); + return true; } } 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 f3c85f6fbb..363eb1ab07 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 @@ -93,7 +93,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { @Override public void mousePressed(MouseEvent evt) { - if (evt.getClickCount() == 2) { + if (reportletsTree.getPathForLocation(evt.getX(), evt.getY()) != null && evt.getClickCount() == 2) { openFile(); } } 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 8b68dcdbe4..77074ab96f 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 @@ -2,32 +2,77 @@ package com.fr.design.formula; import com.fr.base.BaseFormula; import com.fr.base.BaseUtils; +import com.fr.base.Parameter; +import com.fr.base.ParameterMapNameSpace; +import com.fr.base.TableDataNameSpace; +import com.fr.base.Utils; +import com.fr.base.io.IOFile; +import com.fr.data.TableDataSource; import com.fr.design.actions.UpdateAction; import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.UIConstants; 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.file.HistoryTemplateListCache; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilist.QuickList; +import com.fr.design.gui.itableeditorpane.ParameterTableModel; +import com.fr.design.gui.itableeditorpane.UITableEditorPane; import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.parameter.ParameterInputPane; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; +import com.fr.general.FArray; import com.fr.log.FineLoggerFactory; +import com.fr.parser.ArrayExpression; +import com.fr.parser.BlockIntervalLiteral; +import com.fr.parser.ColumnRowRangeInPage; import com.fr.parser.FRLexer; import com.fr.parser.FRParser; +import com.fr.parser.NumberLiteral; +import com.fr.parser.SheetIntervalLiteral; +import com.fr.report.core.namespace.SimpleCellValueNameSpace; +import com.fr.script.Calculator; +import com.fr.script.ScriptConstants; +import com.fr.script.checker.FunctionCheckerDispatcher; +import com.fr.script.checker.exception.ConditionCheckWrongException; +import com.fr.script.checker.exception.FunctionCheckWrongException; +import com.fr.script.rules.FunctionParameterType; +import com.fr.script.rules.FunctionRule; import com.fr.stable.EncodeConstants; +import com.fr.stable.EssentialUtils; +import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; +import com.fr.stable.UtilEvalError; +import com.fr.stable.script.ColumnRowRange; import com.fr.stable.script.Expression; - -import javax.swing.*; +import com.fr.stable.script.Node; +import com.fr.stable.script.Tiny; +import com.fr.stable.script.TinyHunter; + +import javax.swing.BorderFactory; +import javax.swing.DefaultListCellRenderer; +import javax.swing.DefaultListModel; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JTree; +import javax.swing.SwingUtilities; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.event.TreeSelectionEvent; @@ -37,7 +82,10 @@ import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.MutableTreeNode; import javax.swing.tree.TreePath; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; @@ -52,10 +100,16 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; +import java.text.NumberFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; +import java.util.Map; +import java.util.Set; /** * 公式编辑面板 @@ -65,6 +119,10 @@ import java.util.List; */ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { + public static final String VALID_FORMULA = Toolkit.i18nText("Fine-Design_Basic_FormulaD_Valid_Formula"); + public static final String INVALID_FORMULA = Toolkit.i18nText("Fine-Design_Basic_FormulaD_Invalid_Formula"); + public static final int DEFUAL_FOMULA_LENGTH = 103; + public static final String ELLIPSIS = "..."; private VariableTreeAndDescriptionArea variableTreeAndDescriptionArea; private RSyntaxTextArea formulaTextArea; private UITextField keyWordTextField = new UITextField(18); @@ -78,6 +136,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { private QuickList functionTypeList; private DefaultListModel functionNameModel; private JList functionNameList; + private UITableEditorPane editor4CalPane; public FormulaPane() { initComponents(); @@ -201,6 +260,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { private void initTextPane() { // text + JPanel textPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); this.add(textPane, BorderLayout.CENTER); JPanel checkBoxandbuttonPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); @@ -217,13 +277,19 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { UIButton checkValidButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Check_Valid")); + UIButton calButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Button")); checkValidButton.addActionListener(checkValidActionListener); + calButton.addActionListener(calculateActionListener); JPanel checkBoxPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); checkBoxPane.setPreferredSize(new Dimension(450, 30)); checkBoxandbuttonPane.add(checkBoxPane, BorderLayout.WEST); checkBoxandbuttonPane.add(checkValidButton, BorderLayout.EAST); + checkBoxandbuttonPane.add(calButton, BorderLayout.EAST); extendCheckBoxPane(checkBoxPane); + + ParameterTableModel model = new ParameterTableModel(0); + editor4CalPane = new UITableEditorPane<>(model); } @@ -585,40 +651,253 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { } // check valid - private ActionListener checkValidActionListener = new ActionListener() { + private final ActionListener checkValidActionListener = new ActionListener() { public void actionPerformed(ActionEvent evt) { // Execute Formula default cell element. String formulaText = formulaTextArea.getText().trim(); + String formulaValidMessage = getFormulaValidMessage(formulaText); + FineJOptionPane.showMessageDialog( + FormulaPane.this, + formulaValidMessage + ".", + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + JOptionPane.INFORMATION_MESSAGE); + } + }; - if (formulaText != null && formulaText.length() > 0) { - StringReader in = new StringReader(formulaText); - - FRLexer lexer = new FRLexer(in); - FRParser parser = new FRParser(lexer); - - Expression expression = null; - try { - expression = parser.parse(); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - // alex:继续往下面走,expression为null时告知不合法公式 + private static String getFormulaValidMessage(String formulaText) { + StringReader in = new StringReader(formulaText); + + FRLexer lexer = new FRLexer(in); + FRParser parser = new FRParser(lexer); + + try { + Expression expression = parser.parse(); + Node node = expression.getConditionalExpression(); + return FunctionCheckerDispatcher.getInstance() + .getFunctionChecker(node) + .checkFunction(node) ? VALID_FORMULA : INVALID_FORMULA; + } catch (ConditionCheckWrongException cce) { + String functionName = cce.getFunctionName(); + StringBuilder errorMsg = new StringBuilder(functionName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Condition_Tips") + ":"); + return errorMsg.toString(); + } catch (FunctionCheckWrongException ce) { + List rules = ce.getRules(); + String functionName = ce.getFunctionName(); + StringBuilder errorMsg = new StringBuilder(functionName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Error_Tips") + ":"); + for (int i = 0; i < rules.size(); i++) { + errorMsg.append("("); + if (rules.get(i).getParameterList().isEmpty()) { + errorMsg.append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_No_Param")); + } + for (FunctionParameterType functionParameterType : rules.get(i).getParameterList()) { + errorMsg.append(getTypeString(functionParameterType)).append(","); } + if (",".equals(errorMsg.charAt(errorMsg.length() - 1) + "")) { + errorMsg.deleteCharAt(errorMsg.length() - 1); + } + errorMsg.append(")"); + if (i != rules.size() - 1) { + errorMsg.append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Or")); + } + } + return errorMsg.toString(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + return INVALID_FORMULA; + // alex:继续往下面走,expression为null时告知不合法公式 + } + } + + private static String getTypeString(FunctionParameterType type) { + switch (type) { + case NUMBER: + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Number"); + case STRING: + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_String"); + case ANY: + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Any"); + case DATE: + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Date"); + case BOOLEAN: + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Boolean"); + case ARRAY: + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Array"); + } + return ""; + } + private final ActionListener calculateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String formulaText = formulaTextArea.getText().trim(); + String formulaValidMessage = getFormulaValidMessage(formulaText); + String unSupportFormula = containsUnsupportedSimulationFormulas(formulaText); + if (unSupportFormula != null) { FineJOptionPane.showMessageDialog( FormulaPane.this, - /* - * alex:仅仅只需要根据expression是否为null作合法性判断 - * 不需要eval - * TODO 但有个问题,有些函数的参数个数是有规定的,何以判别之 - */ - (expression != null ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Valid_Formula") : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Invalid_Formula")) + ".", + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Unsupported_Formulas") + ":" + unSupportFormula, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE); + return; + } + String messageTips; + if (formulaValidMessage.equals(INVALID_FORMULA)) { + messageTips = INVALID_FORMULA; + } else { + messageTips = formulaValidMessage.equals(VALID_FORMULA) ? "" : formulaValidMessage + "\n"; + Map paramsMap = setParamsIfExist(formulaText); + Calculator calculator = Calculator.createCalculator(); + ParameterMapNameSpace parameterMapNameSpace = ParameterMapNameSpace.create(paramsMap); + calculator.pushNameSpace(parameterMapNameSpace); + + JTemplate currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (currentEditingTemplate != null) { + IOFile file = (IOFile) currentEditingTemplate.getTarget(); + calculator.setAttribute(TableDataSource.KEY, file); + calculator.pushNameSpace(TableDataNameSpace.getInstance()); + calculator.pushNameSpace(SimpleCellValueNameSpace.getInstance()); + } + + BaseFormula baseFormula = BaseFormula.createFormulaBuilder().build(formulaText); + try { + Object value = calculator.evalValue(baseFormula); + String objectToString = EssentialUtils.objectToString(value); + String result = objectToString.length() > DEFUAL_FOMULA_LENGTH ? + objectToString.substring(0, DEFUAL_FOMULA_LENGTH - ELLIPSIS.length()) + ELLIPSIS : objectToString; + messageTips = messageTips + + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Result") + ":" + result; + FineLoggerFactory.getLogger().info("value:{}", value); + } catch (UtilEvalError utilEvalError) { + FineLoggerFactory.getLogger().error("", utilEvalError); + } } + FineJOptionPane.showMessageDialog( + FormulaPane.this, + messageTips, + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + JOptionPane.INFORMATION_MESSAGE); } }; + private String containsUnsupportedSimulationFormulas(String formulaText) { + try { + Expression expression = Calculator.createCalculator().parse(formulaText); + UnsupportedFormulaScanner scanner = new UnsupportedFormulaScanner(); + if (!scanner.travelFormula(expression.getConditionalExpression())) { + return scanner.getUnSupportFormula(); + } + + UnsupportedSimulationNodeHunter unsupportedSimulationFormulaHunter = new UnsupportedSimulationNodeHunter(); + expression.traversal4Tiny(unsupportedSimulationFormulaHunter); + return unsupportedSimulationFormulaHunter.isSupported() ? null : unsupportedSimulationFormulaHunter.getUnSupportedNode(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error("", e); + } + return null; + } + + private Map setParamsIfExist(String formulaText) { + Map parameterMap = new HashMap<>(); + try { + Calculator calculator = Calculator.createCalculator(); + Expression expression = calculator.parse(formulaText); + ParameterCellHunter parameterCellHunter = new ParameterCellHunter(); + expression.traversal4Tiny(parameterCellHunter); + Parameter[] parameters = parameterCellHunter.getParameterBooty(); + + if (parameters.length < 1 && editor4CalPane.update().size() < 1) { + return parameterMap; + } + ParameterInputPane pPane = new ParameterInputPane(parameters); + pPane.showSmallWindow(new JFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + parameterMap.putAll(pPane.update()); + } + }).setVisible(true); + //过滤出数组参数,如:[1,2] + for (Map.Entry entry : parameterMap.entrySet()) { + if (entry.getValue().toString().startsWith("[") && entry.getValue().toString().endsWith("]")) { + Expression parse = calculator.parse(entry.getValue()); + ArrayExpression arrayExpression = (ArrayExpression) parse.getConditionalExpression(); + Node[] arrays = arrayExpression.getArrays(); + List arrayList = new ArrayList<>(); + for (Node array : arrays) { + if (array instanceof NumberLiteral) { + arrayList.add(NumberFormat.getInstance().parse(array.toString())); + } else { + arrayList.add(array); + } + } + FArray fArray = new FArray<>(arrayList); + parameterMap.put(entry.getKey(), fArray); + } else if (Utils.isNumeric(entry.getValue().toString())) { + try { + Number number = NumberFormat.getInstance().parse(entry.getValue().toString()); + parameterMap.put(entry.getKey(), number); + } catch (Exception e) { + FineLoggerFactory.getLogger().warn("", e); + } + } + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error("", e); + } + return parameterMap; + } + + private static class ParameterCellHunter extends TinyHunter { + + private final Set parameterList = new HashSet<>(); + + Parameter[] getParameterBooty() { + return parameterList.toArray(new Parameter[0]); + } + + public void hunter4Tiny(Tiny tiny) { + String statement = tiny.getStatement(); + if (StringUtils.isNotBlank(statement) && statement.startsWith(ScriptConstants.DETAIL_TAG)) { + if (statement.startsWith(ScriptConstants.SUMMARY_TAG)) { + parameterList.add(new Parameter(statement)); + } else { + parameterList.add(new Parameter(statement.substring(1))); + } + } else if (tiny.getClass() == ColumnRowRange.class || + tiny.getClass() == SheetIntervalLiteral.class || tiny.getClass() == BlockIntervalLiteral.class) { + parameterList.add(new Parameter(tiny.toString())); + } + } + } + + private static class UnsupportedSimulationNodeHunter extends TinyHunter { + + private boolean supported = true; + + private String unSupportedNode; + + private String[] curReportVariables; + + public UnsupportedSimulationNodeHunter() { + curReportVariables = VariableResolver.DEFAULT.resolveCurReportVariables(); + } + + public boolean isSupported() { + return supported; + } + + public String getUnSupportedNode() { + return unSupportedNode; + } + + public void hunter4Tiny(Tiny tiny) { + if (tiny.getClass() == ColumnRowRangeInPage.class || Arrays.asList(curReportVariables).contains(tiny.toString())) { + supported = false; + unSupportedNode = tiny.toString(); + } + } + } + public class VariableTreeAndDescriptionArea extends JPanel { private JTree variablesTree; @@ -805,13 +1084,13 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode selectedTreeNode = (DefaultMutableTreeNode) variablesTree.getLastSelectedPathComponent(); Object selectedValue = selectedTreeNode.getUserObject(); - Object selectedParentValue = ((DefaultMutableTreeNode)selectedTreeNode.getParent()).getUserObject(); + Object selectedParentValue = ((DefaultMutableTreeNode) selectedTreeNode.getParent()).getUserObject(); if (selectedValue == null) { return; } - if (selectedValue instanceof TextUserObject) { + if (selectedValue instanceof TextUserObject) { //有公式说明的条件:1.属于TextUserObject 2.parent是系统参数 if (ComparatorUtils.equals(((TextFolderUserObject) selectedParentValue).getText(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaPane_Variables"))) { @@ -1010,6 +1289,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { /** * 把以关键词开头的和不以关键词开头的分别按照字母表顺序排序 + * * @param o1 待比较对象1 * @param o2 待比较对象2 * @return 比较结果,1表示 o1 > o2, -1表示 o1 < o2, 0表示 o1 = o2 diff --git a/designer-base/src/main/java/com/fr/design/formula/UnsupportedFormulaScanner.java b/designer-base/src/main/java/com/fr/design/formula/UnsupportedFormulaScanner.java new file mode 100644 index 0000000000..88f7a24b3a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/formula/UnsupportedFormulaScanner.java @@ -0,0 +1,54 @@ +package com.fr.design.formula; + +import com.fr.parser.BinaryExpression; +import com.fr.parser.DatasetFunctionCall; +import com.fr.parser.FunctionCall; +import com.fr.stable.script.Node; + +import java.util.Arrays; + +/** + * @author Hoky + * @date 2021/8/30 + */ +public class UnsupportedFormulaScanner { + public final static String[] UNSUPPORTED_FORMULAS = new String[]{"PROPORTION", "TOIMAGE", + "WEBIMAGE", "SORT", "CROSSLAYERTOTAL", "CIRCULAR", "LAYERTOTAL", "MOM", "HIERARCHY", + "FILENAME", "FILESIZE", "FILETYPE", "TREELAYER", "GETUSERDEPARTMENTS", "GETUSERJOBTITLES"}; + + private String unSupportFormula = ""; + + public boolean travelFormula(Node node) { + if (node instanceof FunctionCall) { + if (isUnsupportedFomula(((FunctionCall) node).getName())) { + unSupportFormula = ((FunctionCall) node).getName(); + return false; + } else { + for (Node argument : ((FunctionCall) node).getArguments()) { + if (!travelFormula(argument)) { + return false; + } + } + } + } else if (node instanceof BinaryExpression) { + for (Node array : ((BinaryExpression) node).getNodes()) { + if (!travelFormula(array)) { + return false; + } + } + } else if (node instanceof DatasetFunctionCall) { + DatasetFunctionCall datasetFunctionCall = (DatasetFunctionCall) node; + unSupportFormula = datasetFunctionCall.getSourceName() + "." + datasetFunctionCall.getFnName() + "()"; + return false; + } + return true; + } + + public String getUnSupportFormula() { + return unSupportFormula; + } + + private static boolean isUnsupportedFomula(String formula) { + return Arrays.asList(UNSUPPORTED_FORMULAS).contains(formula.toUpperCase()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/fun/PcFitProvider.java b/designer-base/src/main/java/com/fr/design/fun/PcFitProvider.java new file mode 100644 index 0000000000..46437917e9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/PcFitProvider.java @@ -0,0 +1,19 @@ +package com.fr.design.fun; + +import com.fr.stable.fun.mark.Mutable; + + +public interface PcFitProvider extends Mutable { + String XML_TAG = "PcFitProvider"; + int CURRENT_LEVEL = 1; + + //设计器上看到的选项 + String getContentDisplayValue(); + + //返回给前端的值 + int getContentDisplayKey(); + + //设计器上的提示信息 + String getContentDisplayTip(); + +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPcFitProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPcFitProvider.java new file mode 100644 index 0000000000..b3a43754ef --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPcFitProvider.java @@ -0,0 +1,19 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.PcFitProvider; +import com.fr.stable.fun.mark.API; + + +@API(level = PcFitProvider.CURRENT_LEVEL) +public abstract class AbstractPcFitProvider implements PcFitProvider { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/DesignerStartWithEmptyFile.java b/designer-base/src/main/java/com/fr/design/fun/impl/DesignerStartWithEmptyFile.java new file mode 100644 index 0000000000..12ad01dccd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/DesignerStartWithEmptyFile.java @@ -0,0 +1,28 @@ +package com.fr.design.fun.impl; + +import com.fr.file.FILE; +import com.fr.intelli.record.Focus; +import com.fr.intelli.record.Original; +import com.fr.record.analyzer.EnableMetrics; + +/** + * Created by rinoux on 2016/12/16. + */ +@EnableMetrics +public class DesignerStartWithEmptyFile extends AbstractDesignerStartOpenFileProcessor { + + private static final DesignerStartWithEmptyFile INSTANCE = new DesignerStartWithEmptyFile(); + + private DesignerStartWithEmptyFile() { + } + + public static DesignerStartWithEmptyFile getInstance() { + return INSTANCE; + } + + @Override + @Focus(id = "com.fr.dzstartemptyfile", text = "Fine_Design_Start_Empty_File", source = Original.REPORT) + public FILE fileToShow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/chart/ChartEditPaneActionListener.java b/designer-base/src/main/java/com/fr/design/gui/chart/ChartEditPaneActionListener.java new file mode 100644 index 0000000000..f7678475f4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/chart/ChartEditPaneActionListener.java @@ -0,0 +1,16 @@ +package com.fr.design.gui.chart; + +import com.fr.chart.chartattr.ChartCollection; + +import java.util.EventListener; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/5/26 + */ +public interface ChartEditPaneActionListener extends EventListener { + + void attributeChange(ChartCollection chartCollection); + +} diff --git a/designer-base/src/main/java/com/fr/design/gui/chart/ChartEditPaneProvider.java b/designer-base/src/main/java/com/fr/design/gui/chart/ChartEditPaneProvider.java index 3d4119ab7f..3003800364 100644 --- a/designer-base/src/main/java/com/fr/design/gui/chart/ChartEditPaneProvider.java +++ b/designer-base/src/main/java/com/fr/design/gui/chart/ChartEditPaneProvider.java @@ -10,4 +10,10 @@ public interface ChartEditPaneProvider { void fire(); + default void addChartEditPaneActionListener(ChartEditPaneActionListener l) { + } + + default void removeChartEditPaneActionListener(ChartEditPaneActionListener l) { + } + } diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java index ebe41b2bc7..3ddb144a5f 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java @@ -10,6 +10,7 @@ import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.form.event.Listener; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; @@ -76,9 +77,12 @@ class JControlUpdatePane extends JPanel { cardPane.add(updatePanes[i], String.valueOf(i)); } card.show(cardPane, String.valueOf(i)); - try{ + try { + if (ob2Populate instanceof Listener) { + listControlPane.wrapperListener((Listener) ob2Populate); + } updatePanes[i].populateBean(ob2Populate); - }catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } break; @@ -103,12 +107,15 @@ class JControlUpdatePane extends JPanel { if (pane != null && pane.isVisible()) { Object bean = pane.updateBean(); try { + if (bean instanceof Listener) { + listControlPane.wrapperListener((Listener) bean); + } if (bean instanceof RemoteDesignerWorkspaceInfo) { DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(elEditing.wrapper.getName()); String remindTime = info.getRemindTime(); ((RemoteDesignerWorkspaceInfo) bean).setRemindTime(remindTime); } - }catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().info("remindTime is not exist"); } if (i < creators.length) { diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java index b82a584679..f119c55cd3 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java @@ -6,6 +6,7 @@ import com.fr.design.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ModNameActionListener; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.form.event.Listener; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; import com.fr.invoke.Reflect; @@ -417,4 +418,10 @@ public abstract class JListControlPane extends JControlPane implements ListContr public JControlUpdatePane getControlUpdatePane() { return (JControlUpdatePane) controlUpdatePane; } + + @Override + public void wrapperListener(Listener listener){ + + } + } diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneProvider.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneProvider.java index 1565f348d0..6d000c1153 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneProvider.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneProvider.java @@ -3,6 +3,7 @@ package com.fr.design.gui.controlpane; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.ListModelElement; +import com.fr.form.event.Listener; import com.fr.stable.Nameable; import javax.swing.DefaultListModel; @@ -32,4 +33,6 @@ public interface ListControlPaneProvider extends UnrepeatedNameHelper { void showSelectPane(); void showEditPane(); ShortCut4JControlPane[] getShorts(); + + void wrapperListener(Listener listener); } 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 b15b9eab92..648cb03f33 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 @@ -3,6 +3,7 @@ package com.fr.design.gui.controlpane; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.controlpane.shortcutfactory.ShortCutFactory; +import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itoolbar.UIToolBarUI; import com.fr.design.gui.itoolbar.UIToolbar; @@ -277,6 +278,10 @@ public abstract class UIControlPane extends JControlPane { this.requestFocus(); return; } + if (JavaFxNativeFileChooser.isShowDialogState()) { + JavaFxNativeFileChooser.setShowDialogState(false); + return; + } saveSettings(); setVisible(false); PopupDialogSaveAction saveAction = OSSupportCenter.getAction(PopupDialogSaveAction.class); 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 b7b8674be7..7ba536492a 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 @@ -6,6 +6,7 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.UINameEdList; +import com.fr.form.event.Listener; import com.fr.stable.ArrayUtils; import com.fr.stable.Nameable; @@ -314,4 +315,10 @@ public abstract class UIListControlPane extends UIControlPane implements ListCon public JNameEdList getNameableList() { return nameableList; } + + @Override + public void wrapperListener(Listener listener){ + + } + } diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java index 82bf99bf33..6ec5f496a6 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java @@ -391,7 +391,7 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li @Override public Nameable[] update() { - java.util.List res = new java.util.ArrayList(); + List res = new ArrayList(); getControlUpdatePane().update(); Iterator> iterator = nameEdListMap.entrySet().iterator(); while (iterator.hasNext()) { @@ -516,6 +516,11 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li return StringUtils.EMPTY; } + @Override + public void wrapperListener(Listener listener){ + + } + private class ListWrapperPane extends JPanel { private UINameEdList nameEdList; diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java index 6af1194265..381a9cd761 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java @@ -46,8 +46,10 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane { protected void initContentPane() { leftContentPane = createContentPane(); - leftContentPane.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, original)); - this.add(leftContentPane, BorderLayout.CENTER); + if (leftContentPane != null) { + leftContentPane.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, original)); + this.add(leftContentPane, BorderLayout.CENTER); + } } protected abstract JPanel createContentPane(); diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/JTreeAutoBuildPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/JTreeAutoBuildPane.java index 6103e68002..83c52ac784 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/JTreeAutoBuildPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/JTreeAutoBuildPane.java @@ -27,13 +27,16 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.stable.StringUtils; -import java.awt.*; + +import javax.swing.JPanel; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.List; -import javax.swing.*; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; public class JTreeAutoBuildPane extends BasicPane implements PreviewLabel.Previewable, EditOrNewLabel.Editable { private TreeTableDataComboBox treeTableDataComboBox; diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java index bab3e8851c..5769fdacfe 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java @@ -10,6 +10,7 @@ import com.fr.design.gui.ispinner.UIBasicSpinner; import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.GeneralUtils; import com.fr.stable.AssistUtils; import com.fr.stable.StringUtils; @@ -27,7 +28,8 @@ import java.math.BigDecimal; * For input Number. */ public abstract class UnitInputPane extends BasicPane { - private static final double NUM_POINT = 0.000001; + private static final double MAX_NUM = 3000.0D; + private static final double NUM_POINT = 0.000001; private int scale = -1; String title; @@ -46,7 +48,7 @@ public abstract class UnitInputPane extends BasicPane { centerPane.add(titleLabel); // Denny:在对话框中加入JSpinner对象 - numberFieldSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, 999, 1)); + numberFieldSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, MAX_NUM, 1)); GUICoreUtils.setColumnForSpinner(numberFieldSpinner, 24); numberFieldSpinner.setPreferredSize(new Dimension(60, 20)); numberFieldSpinner.setMinimumSize(new Dimension(60, 20)); @@ -71,17 +73,17 @@ public abstract class UnitInputPane extends BasicPane { public void populate(float floatValue) { popValue = floatValue; - numberFieldSpinner.setModel(new SpinnerNumberModel(0.00, 0.00, 999.00, 0.01)); + numberFieldSpinner.setModel(new SpinnerNumberModel(0.00, 0.00, MAX_NUM, 0.01)); JFormattedTextField temp = GUICoreUtils.getSpinnerTextField(numberFieldSpinner); addChangeListener(temp); - BigDecimal de = new BigDecimal(floatValue + ""); + BigDecimal de = new BigDecimal(GeneralUtils.objectToString(floatValue)); if (scale > 0) { floatValue = de.setScale(scale, BigDecimal.ROUND_DOWN).floatValue(); } else { floatValue = de.floatValue(); } - //选中多列, 并且列宽不完全一致的话, 就不显示值了. + //选中多列, 并且列宽不完全一致的话, 就不显示值了. temp.setText(AssistUtils.equals(floatValue, 0) ? StringUtils.EMPTY : Utils.convertNumberStringToString(new Float(floatValue))); // denny:默认应该为选中,方便用户修改 @@ -99,8 +101,8 @@ public abstract class UnitInputPane extends BasicPane { public double update() throws ValueNotChangeException { // 值没变就不改 if (!changed) { - throw vncExp; - } + throw vncExp; + } // Denny: get numberFieldSpinner 的 TextField JFormattedTextField temp = GUICoreUtils.getSpinnerTextField(numberFieldSpinner); @@ -108,7 +110,8 @@ public abstract class UnitInputPane extends BasicPane { if (temp.getText().length() == 0) { return 0; } - BigDecimal de = new BigDecimal(temp.getText()); + + BigDecimal de = new BigDecimal(GeneralUtils.objectToString(temp.getValue())); if (scale > 0) { return de.setScale(scale, BigDecimal.ROUND_DOWN).floatValue(); } else { @@ -176,4 +179,4 @@ public abstract class UnitInputPane extends BasicPane { // 鼠标按键在组件上单击时 } }; -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java index 28f5830619..8171f31cb7 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java @@ -154,18 +154,22 @@ public class UIColorButton extends UIButton implements PopupHider, UIObserver, G protected ColorControlWindow getColorControlWindow() { //find parant. if (this.popupWin == null) { - this.popupWin = new ColorControlWindow(UIColorButton.this) { - @Override - protected void colorChanged() { - UIColorButton.this.setColor(this.getColor()); - } - - }; + this.popupWin = initColorControlWindow(); } return popupWin; } + protected ColorControlWindow initColorControlWindow(){ + return new ColorControlWindow(UIColorButton.this) { + @Override + protected void colorChanged() { + UIColorButton.this.setColor(this.getColor()); + } + + }; + } + /** * 添加监听 * diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIHead.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIHead.java new file mode 100644 index 0000000000..0a41aae172 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIHead.java @@ -0,0 +1,63 @@ +package com.fr.design.gui.ibutton; + +import com.fr.stable.StringUtils; + +import javax.swing.Icon; + +public class UIHead { + private String text = StringUtils.EMPTY; + private Icon icon = null; + private boolean enable = true; + private int index = 0; + + public UIHead(String text, int index) { + this.text = text; + this.index = index; + } + + public UIHead(String text, int index, boolean enable) { + this(text, index); + this.enable = enable; + } + + public UIHead(Icon icon, int index) { + this.icon = icon; + this.index = index; + } + + public UIHead(Icon icon, int index, boolean enable) { + this(icon, index); + this.enable = enable; + } + + public UIHead(String text, Icon icon, int index) { + this.text = text; + this.icon = icon; + this.index = index; + } + + public UIHead(String text, Icon icon, int index, boolean enable) { + this(text, icon, index); + this.enable = enable; + } + + public boolean isOnlyText() { + return StringUtils.isNotEmpty(text) && icon == null; + } + + public String getText() { + return text; + } + + public Icon getIcon() { + return icon; + } + + public boolean isEnable() { + return enable; + } + + public int getIndex() { + return index; + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIHeadGroup.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIHeadGroup.java index e21f4c2170..0cfe7c3903 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIHeadGroup.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIHeadGroup.java @@ -10,7 +10,6 @@ import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.Color; import java.awt.Dimension; -import java.awt.Graphics; import java.awt.GridLayout; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -18,8 +17,10 @@ import java.awt.event.MouseListener; import java.util.ArrayList; import java.util.List; +// fanglei:不是原作者,只是优化如下问题:代码冗余,无法拓展(例如我想加个enable属性没法加),甚至还有数组越界的问题。 public class UIHeadGroup extends JPanel { private static final int MIN_HEIGHT = 25; + private List uiHeads = new ArrayList<>(); protected List labelButtonList; private boolean isNeedLeftRightOutLine = true; protected int selectedIndex = -1; @@ -29,76 +30,46 @@ public class UIHeadGroup extends JPanel { } public UIHeadGroup(String[] textArray) { - labelButtonList = new ArrayList(textArray.length); - this.setBackground(UIConstants.TREE_BACKGROUND); - this.setLayout(new GridLayout(0, textArray.length, 0, 0)); for (int i = 0; i < textArray.length; i++) { - final int index = i; - String text = textArray[i]; - final UIToggleButton labelButton = new UIToggleButton(text) { - @Override - protected MouseListener getMouseListener() { - return new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - setSelectedIndex(index); - UIHeadGroup.this.repaint(); - } - }; - } - }; - initButton(labelButton); + uiHeads.add(new UIHead(textArray[i], i)); } - setSelectedIndex(0); + initUIHeadGroup(uiHeads); } public UIHeadGroup(Icon[] iconArray) { - labelButtonList = new ArrayList(iconArray.length); - this.setBackground(UIConstants.NORMAL_BACKGROUND); - this.setLayout(new GridLayout(0, iconArray.length, 1, 0)); for (int i = 0; i < iconArray.length; i++) { - final int index = i; - Icon icon = iconArray[i]; - final UIToggleButton labelButton = new UIToggleButton(icon) { - @Override - protected MouseListener getMouseListener() { - return new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - setSelectedIndex(index); - UIHeadGroup.this.repaint(); - } - }; - } - }; - initButton(labelButton); + uiHeads.add(new UIHead(iconArray[i], i)); } - setSelectedIndex(0); + initUIHeadGroup(uiHeads); } public UIHeadGroup(Icon[] iconArray, String[] textArray) { - labelButtonList = new ArrayList(Math.min(textArray.length, iconArray.length)); - this.setBackground(UIConstants.NORMAL_BACKGROUND); - this.setLayout(new GridLayout(0, textArray.length, 1, 0)); - for (int i = 0; i < textArray.length; i++) { - final int index = i; - String text = textArray[i]; - Icon icon = iconArray[i]; - final UIToggleButton labelButton = new UIToggleButton(text, icon) { - @Override - protected MouseListener getMouseListener() { - return new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - setSelectedIndex(index); - UIHeadGroup.this.repaint(); - } - }; + int length = Math.min(textArray.length, iconArray.length); + for (int i = 0; i < length; i++) { + uiHeads.add(new UIHead(textArray[i], iconArray[i], i)); + } + initUIHeadGroup(uiHeads); + } + + public UIHeadGroup(List uiHeads) { + initUIHeadGroup(uiHeads); + } + + public void initUIHeadGroup(List uiHeads) { + if (uiHeads != null) { + labelButtonList = new ArrayList(uiHeads.size()); + this.setLayout(new GridLayout(0, uiHeads.size(), 1, 0)); + + for (UIHead head : uiHeads) { + if (head.isOnlyText()) { + this.setBackground(UIConstants.TREE_BACKGROUND); + } else { + this.setBackground(UIConstants.NORMAL_BACKGROUND); } - }; - initButton(labelButton); + initButton(createUIToggleButton(head)); + } + setSelectedIndex(0); } - setSelectedIndex(0); } @Override @@ -110,32 +81,6 @@ public class UIHeadGroup extends JPanel { return dim; } - @Override - protected void paintBorder(Graphics g) { -// Graphics2D g2d = (Graphics2D)g; -// g2d.setColor(UIConstants.LINE_COLOR); -// -// int width = 0; -// for(int i = 0; i < labelButtonList.size() - 1; i++) { -// int height = labelButtonList.get(i).getHeight(); -// width += labelButtonList.get(i).getWidth() + 1; -// g.drawLine(width, 0, width, height); -// } -// -// width += labelButtonList.get(labelButtonList.size() - 1).getWidth() + 1; -// if(isNeedLeftRightOutLine) { -// g2d.drawRect(0, 0, width, getHeight() - 1); -// } else { -// g2d.drawLine(1, 0, width - 1, 0); -// g2d.drawLine(1, getHeight() - 1, width - 1, getHeight() - 1); -// } -// -// -// g2d.setColor(UIConstants.NORMAL_BACKGROUND); -// UIToggleButton headButton = labelButtonList.get(selectedIndex); -// g2d.drawLine(headButton.getX(), headButton.getHeight() + 1, headButton.getX() + headButton.getWidth() - 1, headButton.getHeight() + 1); - } - private void initButton(UIToggleButton labelButton) { labelButton.setRoundBorder(false); labelButton.setBorderPainted(false); @@ -172,6 +117,26 @@ public class UIHeadGroup extends JPanel { return selectedIndex; } + public UIToggleButton createUIToggleButton(final UIHead head) { + UIToggleButton uiToggleButton = new UIToggleButton(head.getText(), head.getIcon()) { + @Override + protected MouseListener getMouseListener() { + return new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + if (head.isEnable()) { + setSelectedIndex(head.getIndex()); + UIHeadGroup.this.repaint(); + } + } + }; + } + }; + + uiToggleButton.setEnabled(head.isEnable()); + return uiToggleButton; + } + public static void main(String... args) { JFrame jf = new JFrame("test"); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UINoThemeColorButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UINoThemeColorButton.java new file mode 100644 index 0000000000..da071458a1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UINoThemeColorButton.java @@ -0,0 +1,36 @@ +package com.fr.design.gui.ibutton; + +import com.fr.design.gui.ipoppane.PopupHider; +import com.fr.design.style.color.ColorControlWindow; + +import javax.swing.Icon; + + +public class UINoThemeColorButton extends UIColorButton{ + + public UINoThemeColorButton(Icon icon) { + super(icon); + } + + protected ColorControlWindow initColorControlWindow(){ + return new NoThemeColorControlWindow(this); + } + + private class NoThemeColorControlWindow extends ColorControlWindow{ + + + public NoThemeColorControlWindow(PopupHider popupHider) { + super(popupHider); + } + + protected boolean supportThemeColor(){ + return false; + } + + + @Override + protected void colorChanged() { + UINoThemeColorButton.this.setColor(this.getColor()); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/ColorSchemeComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/ColorSchemeComboBox.java index 044bb65188..f8816a1844 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/ColorSchemeComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/ColorSchemeComboBox.java @@ -2,14 +2,18 @@ package com.fr.design.gui.icombobox; import com.fr.base.ChartColorMatching; import com.fr.base.ChartPreStyleConfig; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.settings.chart.ThemedChartSeriesColor; import com.fr.cert.token.lang.Collections; import com.fr.chart.base.ChartConstants; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.i18n.Toolkit; import com.fr.general.GeneralUtils; import javax.swing.DefaultComboBoxModel; import javax.swing.JLabel; import javax.swing.JList; +import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; @@ -65,7 +69,21 @@ public class ColorSchemeComboBox extends UIComboBox { Iterator names = config.names(); if (preDefined) { - colorSchemes.put(Toolkit.i18nText("Fine-Design_Chart_Predefined"), null); + ColorInfo colorInfo = new ColorInfo(); + List list = new ArrayList<>(); + colorInfo.setColors(list); + TemplateTheme templateTheme = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplateTheme(); + ThemedChartSeriesColor themedChartSeriesColor = templateTheme.getChartStyle().getThemedChartSeriesColor(); + if (themedChartSeriesColor.isCombineColor()) { + colorInfo.setGradient(false); + list.addAll(templateTheme.getColorScheme().getColors()); + } else { + colorInfo.setGradient(true); + list.add(themedChartSeriesColor.getBeginColor()); + list.add(themedChartSeriesColor.getEndColor()); + } + colorSchemes.put(Toolkit.i18nText("Fine-Design_Chart_Follow_Theme"), colorInfo); + } else { //添加默认的方案和第一个方案 String defaultName = config.getCurrentStyle(); diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxUI.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxUI.java index f15bbc52a0..d4de4e8501 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxUI.java @@ -10,12 +10,26 @@ import com.fr.stable.Constants; import com.fr.stable.StringUtils; import sun.swing.DefaultLookup; -import javax.swing.*; +import javax.swing.AbstractButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListCellRenderer; +import javax.swing.ScrollPaneConstants; +import javax.swing.UIManager; import javax.swing.plaf.ButtonUI; import javax.swing.plaf.basic.BasicComboBoxUI; import javax.swing.plaf.basic.BasicComboPopup; import javax.swing.plaf.basic.ComboPopup; -import java.awt.*; +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.RenderingHints; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; @@ -159,6 +173,10 @@ public class UIComboBoxUI extends BasicComboBoxUI implements MouseListener { return new UIComboPopup(comboBox); } + protected ComboPopup createHorizontalNeverUIComboPopUp() { + return new HorizontalNeverUIComboPopup(comboBox); + } + private void setRollover(boolean isRollover) { if (this.isRollover != isRollover) { this.isRollover = isRollover; @@ -270,4 +288,16 @@ public class UIComboBoxUI extends BasicComboBoxUI implements MouseListener { } } + + private class HorizontalNeverUIComboPopup extends UIComboPopup { + + public HorizontalNeverUIComboPopup(JComboBox comboBox) { + super(comboBox); + } + + @Override + protected JScrollPane createScroller() { + return new UIScrollPane(list, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + } + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIScrollPane.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIScrollPane.java index a14c10f3c4..55ba64b0e9 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIScrollPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIScrollPane.java @@ -3,8 +3,11 @@ package com.fr.design.gui.icontainer; import com.fr.design.constants.UIConstants; import com.fr.design.gui.iscrollbar.UIScrollBar; -import javax.swing.*; -import java.awt.*; +import javax.swing.JScrollBar; +import javax.swing.JScrollPane; +import javax.swing.ScrollPaneConstants; +import java.awt.Color; +import java.awt.Component; /** * @author zhou @@ -16,7 +19,11 @@ public class UIScrollPane extends JScrollPane { private static final int INCREAMENT = 30; public UIScrollPane(Component c) { - super(c, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + this(c, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + } + + public UIScrollPane(Component c, int vertical, int horizontal) { + super(c, vertical, horizontal); this.setHorizontalScrollBar(createHorizontalScrollBar()); this.getVerticalScrollBar().setUnitIncrement(INCREAMENT); this.getVerticalScrollBar().setBlockIncrement(INCREAMENT); diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java index ee61fd81f5..b9a70557dc 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java +++ b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java @@ -9,7 +9,8 @@ import java.io.File; * @version 10.0 * Created by hades on 2020/3/31 */ -public abstract class AbstractFileChooser { +@Deprecated +public abstract class AbstractFileChooser { /** * 返回当前目录 @@ -57,7 +58,7 @@ public abstract class AbstractFileChooser { * 设置当前的文件过滤器 * */ - public abstract void setFileFilter(final FileFilter filter); + public abstract void setFileFilter(final T filter); /** * 设置文件选择器模式 @@ -66,7 +67,7 @@ public abstract class AbstractFileChooser { * JFileChooser.DIRECTORIES_ONLY * JFileChooser.FILES_AND_DIRECTORIES */ - public abstract void setFileSelectionMode(int selectionMode); + public abstract void setFileSelectionMode(E selectionMode); /** * 设置是否允许选择多个文件 diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileChooserProvider.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileChooserProvider.java new file mode 100644 index 0000000000..aa95fe27bd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileChooserProvider.java @@ -0,0 +1,12 @@ +package com.fr.design.gui.ifilechooser; + +import java.awt.*; +import java.io.File; + +public interface FileChooserProvider { + File[] getSelectedFiles(); + + File getSelectedFile(); + + int showDialog(Component parent); +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileSelectionMode.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileSelectionMode.java new file mode 100644 index 0000000000..bee326f6af --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileSelectionMode.java @@ -0,0 +1,5 @@ +package com.fr.design.gui.ifilechooser; + +public enum FileSelectionMode { + FILE, MULTIPLE_FILE, DIR +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java new file mode 100644 index 0000000000..8be4678106 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java @@ -0,0 +1,235 @@ +package com.fr.design.gui.ifilechooser; + + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; +import com.fr.log.FineLoggerFactory; +import com.sun.javafx.application.PlatformImpl; +import javafx.application.Platform; +import javafx.scene.Scene; +import javafx.scene.control.Label; +import javafx.scene.layout.Background; +import javafx.scene.layout.BackgroundFill; +import javafx.scene.paint.Color; +import javafx.stage.DirectoryChooser; +import javafx.stage.FileChooser; +import javafx.stage.Modality; +import javafx.stage.Stage; +import javafx.stage.StageStyle; + +import javax.swing.*; +import java.awt.*; +import java.io.File; +import java.util.List; +import java.util.concurrent.CountDownLatch; + +public class JavaFxNativeFileChooser implements FileChooserProvider { + private static boolean showDialogState = false; + private File[] selectedFiles = new File[0]; + private FileSelectionMode fileSelectionMode = FileSelectionMode.FILE; + private String title = Toolkit.i18nText("Fine-Design_Basic_Open"); + private FileChooser.ExtensionFilter[] filters; + private File currentDirectory; + + @Override + public File[] getSelectedFiles() { + return selectedFiles; + } + + @Override + public File getSelectedFile() { + if (selectedFiles.length > 0) { + return selectedFiles[0]; + } + return null; + } + + public static boolean isShowDialogState() { + return showDialogState; + } + + public static void setShowDialogState(boolean showDialogState) { + JavaFxNativeFileChooser.showDialogState = showDialogState; + } + + @Override + public int showDialog(Component parent) { + setShowDialogState(true); + final CountDownLatch latch = new CountDownLatch(1); + PlatformImpl.startup(() -> { + }); + Platform.setImplicitExit(false); + Platform.runLater(new Runnable() { + @Override + public void run() { + Component fileChooserParent = parent; + if (fileChooserParent == null) { + fileChooserParent = DesignerContext.getDesignerFrame(); + } + Stage stage = showCoverStage(fileChooserParent); + try { + if (fileSelectionMode == FileSelectionMode.FILE || fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) { + FileChooser fileChooser = new FileChooser(); + fileChooser.setTitle(title); + fileChooser.getExtensionFilters().addAll(filters); + fileChooser.setInitialDirectory(currentDirectory); + if (fileSelectionMode == FileSelectionMode.FILE) { + File file = fileChooser.showOpenDialog(stage); + if (file != null) { + selectedFiles = new File[]{file}; + } + } else if (fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) { + List fileList = fileChooser.showOpenMultipleDialog(stage); + if (fileList != null) { + selectedFiles = new File[fileList.size()]; + fileList.toArray(selectedFiles); + } + } + } else if (fileSelectionMode == FileSelectionMode.DIR) { + DirectoryChooser directoryChooser = new DirectoryChooser(); + directoryChooser.setTitle(title); + directoryChooser.setInitialDirectory(currentDirectory); + File folder = directoryChooser.showDialog(stage); + if (folder != null) { + selectedFiles = new File[]{folder}; + } + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } finally { + latch.countDown(); + closeCoverStage(stage); + } + } + + private void closeCoverStage(Stage stage) { + if (stage != null) { + stage.close(); + closeCoverStage((Stage) stage.getOwner()); + } + + } + + + private Stage showCoverStage(Component component) { + try { + if (component == null) + return null; + Stage parentStage = showCoverStage(component.getParent()); + if (component instanceof JDialog || component instanceof JFrame) { + return createStage(component.getX(), component.getY(), component.getWidth(), component.getHeight(), parentStage); + } else { + return parentStage; + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + return null; + } + } + + private Stage createStage(double x, double y, double w, double h, Stage parentStage) { + try { + Stage stage = new Stage(); + stage.setX(x); + stage.setY(y); + stage.setWidth(w); + stage.setHeight(h); + stage.setOpacity(0.2); + stage.setResizable(false); + stage.initStyle(StageStyle.UNDECORATED); + + Label label = new Label(); + label.setBackground( + new Background(new BackgroundFill(Color.color(0.78, 0.78, 0.80, 0.5), null, null))); + stage.setScene(new Scene(label)); + + + if (parentStage != null) { + stage.initOwner(parentStage); + stage.initModality(Modality.WINDOW_MODAL); + } + stage.show(); + return stage; + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + return null; + } + } + }); + + try { + latch.await(); + } catch (InterruptedException ignore) { + } + return selectedFiles.length > 0 ? JFileChooser.APPROVE_OPTION : JFileChooser.CANCEL_OPTION; + } + + public void setSelectionMode(FileSelectionMode fileSelectionMode) { + this.fileSelectionMode = fileSelectionMode; + } + + public void setCurrentDirectory(File currentDirectory) { + this.currentDirectory = currentDirectory; + } + + + public static class Builder { + private FileSelectionMode fileSelectionMode = FileSelectionMode.FILE; + private String title = Toolkit.i18nText("Fine-Design_Basic_Open"); + private FileChooser.ExtensionFilter[] filters = new FileChooser.ExtensionFilter[0]; + private File currentDirectory; + + public Builder fileSelectionMode(FileSelectionMode fileSelectionMode) { + this.fileSelectionMode = fileSelectionMode; + return this; + } + + public Builder title(String title) { + this.title = title; + return this; + } + + public Builder filters(FileChooser.ExtensionFilter[] filters) { + this.filters = filters; + return this; + } + + public Builder filter(String des, String... extensions) { + if (extensions != null) { + this.filters = new FileChooser.ExtensionFilter[]{new FileChooser.ExtensionFilter(des, extensions)}; + } + return this; + } + + + public Builder currentDirectory(File currentDirectory) { + if (currentDirectory != null) { + if (!currentDirectory.isDirectory()) { + currentDirectory = currentDirectory.getParentFile(); + } + if (currentDirectory != null && currentDirectory.isDirectory()) { + this.currentDirectory = currentDirectory; + } + } + return this; + } + + public Builder currentDirectory(String path) { + if (path != null) { + return currentDirectory(new File(path)); + } + return this; + } + + public JavaFxNativeFileChooser build() { + return new JavaFxNativeFileChooser(this); + } + } + + private JavaFxNativeFileChooser(Builder builder) { + this.fileSelectionMode = builder.fileSelectionMode; + this.title = builder.title; + this.filters = builder.filters; + this.currentDirectory = builder.currentDirectory; + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java index c1418f834b..025edcf080 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java +++ b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java @@ -22,7 +22,8 @@ import java.io.FilenameFilter; * @version 10.0 * Created by hades on 2020/3/31 */ -public class UINativeFileChooser extends AbstractFileChooser { +@Deprecated +public class UINativeFileChooser extends AbstractFileChooser { private final FileDialog fileDialog; private FileFilter fileFilter; @@ -88,7 +89,7 @@ public class UINativeFileChooser extends AbstractFileChooser { } @Override - public void setFileSelectionMode(int selectionMode) { + public void setFileSelectionMode(Integer selectionMode) { this.selectionMode = selectionMode; } diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/EditTextField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/EditTextField.java index 694c3e507e..9ed9068273 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/EditTextField.java +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/EditTextField.java @@ -13,6 +13,9 @@ import javax.swing.text.PlainDocument; * Number Field. */ public class EditTextField extends UIGridTextField { + + private static final String I18NProperty = "i18n"; + private int maxLength = 24; public EditTextField() { @@ -39,7 +42,11 @@ public class EditTextField extends UIGridTextField { } class TextDocument extends PlainDocument { + + private Object defaultI18NProperty; + public TextDocument() { + defaultI18NProperty = getProperty(I18NProperty); } @Override @@ -49,6 +56,7 @@ public class EditTextField extends UIGridTextField { Toolkit.getDefaultToolkit().beep(); return; } + putProperty(I18NProperty, defaultI18NProperty); super.insertString(offset, s, a); } } diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/UIIntNumberField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/UIIntNumberField.java index 37b1e74e4a..862eedaff0 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/UIIntNumberField.java +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/UIIntNumberField.java @@ -12,6 +12,7 @@ import java.awt.Toolkit; * Date: 13-3-29 * Time: 下午12:02 * To change this template use File | Settings | File Templates. + * fanglei: 这个类名字虽然叫整数输入框,但是里面的业务仅支持输入正整数,由于被引用的地方太多无法更改,知道就行 */ public class UIIntNumberField extends UINumberField { public void setFieldDocument() { diff --git a/designer-base/src/main/java/com/fr/design/gui/style/AbstractBorderPackerPane.java b/designer-base/src/main/java/com/fr/design/gui/style/AbstractBorderPackerPane.java new file mode 100644 index 0000000000..4356f133ad --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/style/AbstractBorderPackerPane.java @@ -0,0 +1,20 @@ +package com.fr.design.gui.style; + +import com.fr.design.dialog.BasicPane; +import com.fr.general.act.BorderPacker; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/11 + */ +public abstract class AbstractBorderPackerPane extends BasicPane { + + public abstract void populateBean(BorderPacker style); + public abstract void updateBean(BorderPacker style); + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/style/AbstractTranslucentBackgroundSpecialPane.java b/designer-base/src/main/java/com/fr/design/gui/style/AbstractTranslucentBackgroundSpecialPane.java new file mode 100644 index 0000000000..fe6318ad3f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/style/AbstractTranslucentBackgroundSpecialPane.java @@ -0,0 +1,99 @@ +package com.fr.design.gui.style; + +import com.fr.design.designer.IntervalConstants; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.BasicScrollPane; +import com.fr.design.gui.frpane.UIPercentDragPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane; +import com.fr.general.Background; +import com.fr.general.act.BackgroundPacker; + +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/11 + */ +public abstract class AbstractTranslucentBackgroundSpecialPane extends BasicPane { + + private final int uiLabelWidth; + private final int uiSettingWidth; + // 背景名称:如主题背景 或 标题背景 + private final String backgroundName; + // 背景 + protected BackgroundSpecialPane backgroundPane = new LayoutBackgroundSpecialPane(); + // 背景透明度 + protected UIPercentDragPane opacityPane = new UIPercentDragPane(); + + public AbstractTranslucentBackgroundSpecialPane(int uiLabelWidth, int uiSettingWidth, String backgroundName) { + this.uiLabelWidth = uiLabelWidth; + this.uiSettingWidth = uiSettingWidth; + this.backgroundName = backgroundName; + this.initializePane(); + } + + private void initializePane() { + setLayout(new BorderLayout(0, 0)); + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f}; + + // 确保BackgroundSpecialPane高度变化时,Label依然保持与其顶部对齐 + JPanel backgroundLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + backgroundLabelPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0)); + backgroundLabelPane.add(new UILabel(backgroundName), BorderLayout.NORTH); + + JPanel backgroundComposedPane = TableLayoutHelper.createGapTableLayoutPane( + new JComponent[][]{ + {backgroundLabelPane, backgroundPane} + }, + new double[]{p}, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); + + JPanel opacityComposedPane = TableLayoutHelper.createGapTableLayoutPane( + new JComponent[][]{ + {new UILabel(""), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Alpha"))}, + {new UILabel(""), opacityPane} + }, + new double[]{p, p}, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); + opacityComposedPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0)); + opacityComposedPane.setVisible(false); + + backgroundPane.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + Background background = backgroundPane.update(); + opacityComposedPane.setVisible(background != null); + } + }); + + add(backgroundComposedPane, BorderLayout.NORTH, 0); + add(opacityComposedPane, BorderLayout.CENTER, 1); + } + + @Override + protected String title4PopupWindow() { + return null; + } + + public abstract void populateBean(T style); + + public abstract void updateBean(T style); + + protected static class LayoutBackgroundSpecialPane extends BackgroundSpecialPane { + @Override + protected GradientBackgroundQuickPane createGradientBackgroundQuickPane() { + return new GradientBackgroundQuickPane(140); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java b/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java index 9f948e7a18..2e04b6ce58 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java @@ -95,8 +95,14 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse borderPanel = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Border"), 280, 24, panel); this.add(borderPanel, BorderLayout.NORTH); + UILabel backgroundFillLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Background_Fill")); + backgroundFillLabel.setPreferredSize(new Dimension(60, 20)); + backgroundPane = new BackgroundPane(); - backgroundPanel = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"), 280, 24, backgroundPane); + JPanel backgroundContainPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{backgroundFillLabel, backgroundPane}}, + TableLayoutHelper.FILL_LASTCOLUMN, LayoutConstants.VGAP_SMALL, LayoutConstants.VGAP_MEDIUM); + + backgroundPanel = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"), 280, 24, backgroundContainPane); this.add(backgroundPanel, BorderLayout.CENTER); initAllNames(); outerToggleButton.addChangeListener(outerToggleButtonChangeListener); diff --git a/designer-base/src/main/java/com/fr/design/gui/style/ComponentBodyStylePane.java b/designer-base/src/main/java/com/fr/design/gui/style/ComponentBodyStylePane.java new file mode 100644 index 0000000000..8463ed6f54 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/style/ComponentBodyStylePane.java @@ -0,0 +1,33 @@ +package com.fr.design.gui.style; + +import com.fr.general.act.BorderPacker; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/11 + */ +public class ComponentBodyStylePane extends AbstractTranslucentBackgroundSpecialPane { + + public ComponentBodyStylePane(int uiLabelWidth) { + this(uiLabelWidth, -1); + } + + public ComponentBodyStylePane(int uiLabelWidth, int uiSettingWidth) { + super(uiLabelWidth, uiSettingWidth, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Fill")); + } + + @Override + public void populateBean(BorderPacker style) { + this.backgroundPane.populateBean(style.getBackground()); + if (this.opacityPane != null) { + this.opacityPane.populateBean(style.getAlpha()); + } + } + + @Override + public void updateBean(BorderPacker style) { + style.setBackground(backgroundPane.update()); + style.setAlpha((float)opacityPane.updateBean()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/style/ComponentIntegralStylePane.java b/designer-base/src/main/java/com/fr/design/gui/style/ComponentIntegralStylePane.java new file mode 100644 index 0000000000..ef47a148b1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/style/ComponentIntegralStylePane.java @@ -0,0 +1,109 @@ +package com.fr.design.gui.style; + +import com.fr.design.designer.IntervalConstants; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.general.act.BorderPacker; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.awt.BorderLayout; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/11 + */ +public class ComponentIntegralStylePane extends AbstractBorderPackerPane { + public static final String[] BORDER_STYLE = new String[]{ + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Common"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Shadow") + }; + + //渲染风格:有无阴影 + protected UIComboBox borderStyleCombo; + // 含图片类型边框的边框配置面板(图片类型边框 + 阴影时存在默认的阴影颜色) + protected TranslucentBorderSpecialPane borderPane; + //边框圆角或圆角裁剪 + protected UISpinner cornerSpinner; + + private final int uiLabelWidth; + private final int uiSettingWidth; + private final boolean supportBorderImage; + private final boolean supportCornerRadius; + + public ComponentIntegralStylePane(int uiLabelWidth, + boolean supportBorderImage, boolean supportCornerRadius) { + this(uiLabelWidth, -1, supportBorderImage, supportCornerRadius); + } + + public ComponentIntegralStylePane(int uiLabelWidth, int uiSettingWidth) { + this(uiLabelWidth, uiSettingWidth, true, true); + } + + public ComponentIntegralStylePane( + int uiLabelWidth, int uiSettingWidth, + boolean supportBorderImage, boolean supportCornerRadius) { + this.uiLabelWidth = uiLabelWidth; + this.uiSettingWidth = uiSettingWidth; + this.supportBorderImage = supportBorderImage; + this.supportCornerRadius = supportCornerRadius; + + this.initializePane(); + } + + private void initializeComponents() { + borderStyleCombo = new UIComboBox(BORDER_STYLE); + borderPane = new TranslucentBorderSpecialPane(this.supportBorderImage); + cornerSpinner = new UISpinner(0,1000,1,0); + } + + protected void initializePane() { + setLayout(FRGUIPaneFactory.createBorderLayout()); + this.initializeComponents(); + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] rowSize = supportCornerRadius ? new double[] {p, p, p} : new double[]{p, p}; + double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f}; + + JPanel content = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo}, + {this.borderPane, null}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner}, + }, + rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); + + this.add(content, BorderLayout.NORTH); + } + + @Override + public void populateBean(BorderPacker style) { + if (this.borderStyleCombo != null) { + this.borderStyleCombo.setSelectedIndex(style.getBorderStyle()); + } + if (cornerSpinner != null) { + this.cornerSpinner.setValue(style.getBorderRadius()); + } + if (this.borderPane != null) { + this.borderPane.populateBean(style); + } + } + + @Override + public void updateBean(BorderPacker style) { + if (borderStyleCombo != null) { + style.setBorderStyle(borderStyleCombo.getSelectedIndex()); + } + if (cornerSpinner != null) { + style.setBorderRadius((int) cornerSpinner.getValue()); + } + if (borderPane != null) { + borderPane.updateBean(style); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java b/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java new file mode 100644 index 0000000000..b7499fc149 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java @@ -0,0 +1,348 @@ +package com.fr.design.gui.style; + +import com.fr.base.Utils; +import com.fr.base.svg.IconUtils; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.ibutton.UIToggleButton; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.form.ui.LayoutBorderStyle; +import com.fr.form.ui.WidgetTitle; +import com.fr.general.FRFont; +import com.fr.general.IOUtils; +import com.fr.general.act.BorderPacker; +import com.fr.general.act.TitlePacker; +import com.fr.stable.Constants; + +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Font; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/11 + */ +public class ComponentTitleStylePane extends AbstractBorderPackerPane { + private static final Dimension BUTTON_SIZE = new Dimension(20, 20); + public static final TitlePacker DEFAULT_TITLE_PACKER = new WidgetTitle(); + + // 标题可见 + protected UICheckBox visibleCheckbox; + //标题文字内容 + protected TinyFormulaPane textContentPane; + //标题字体格式 + protected UIComboBox fontFamilyComboBox; + //标题字体大小 + protected UIComboBox fontSizeComboBox; + //标题字体颜色 + protected UIColorButton fontColorSelectPane; + //标题字体特殊效果:粗体、斜体、下划线 + private UIToggleButton fontBoldButton; + private UIToggleButton fontItalicButton; + private UIToggleButton fontUnderlineButton; + // 标题图文混排 + protected TextInsetImageBackgroundSpecialPane insetImagePane; + //对齐方式 + protected UIButtonGroup alignPane; + //标题整体背景 + protected TitleTranslucentBackgroundSpecialPane backgroundPane; + + // 是否支持用户编辑这些属性(不支持时: 设置面板总是不可见) + private boolean isSupportTitleVisible = true; + private boolean isSupportTitleContent = true; + private boolean isSupportTitleOtherSetting = true; + + // 用于控制各部分设置的可见性 + private JPanel titleVisiblePane; + private JPanel titleContentPane; + private JPanel titleOtherSettingPane; + + private final int uiLabelWidth; + private final int uiSettingWidth; + + public ComponentTitleStylePane(int uiLabelWidth) { + this(uiLabelWidth, -1); + } + + public ComponentTitleStylePane( + int uiLabelWidth, int uiSettingWidth) { + this.uiLabelWidth = uiLabelWidth; + this.uiSettingWidth = uiSettingWidth; + this.initializePane(); + } + + private void initializeComponents() { + visibleCheckbox = new UICheckBox(); + + textContentPane = new TinyFormulaPane(); + + fontFamilyComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); + FRFont frFont = DEFAULT_TITLE_PACKER.getFrFont(); + if (frFont != null) { + String fontFamily = frFont.getFamily(); + // 使用style中默认的字体初始化titleFontFamilyComboBox,保证UI和数据的一致性 + this.fontFamilyComboBox.setSelectedItem(fontFamily); + } + fontFamilyComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Family")); + + fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); + fontSizeComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Size")); + + fontColorSelectPane = new UIColorButton(); + fontColorSelectPane.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Foreground")); + fontColorSelectPane.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Foreground")); + + fontBoldButton = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); + fontBoldButton.setPreferredSize(BUTTON_SIZE); + fontBoldButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Bold")); + fontBoldButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Bold")); + + fontItalicButton = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); + fontItalicButton.setPreferredSize(BUTTON_SIZE); + fontItalicButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Italic")); + fontItalicButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Italic")); + + fontUnderlineButton = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png")); + fontUnderlineButton.setPreferredSize(BUTTON_SIZE); + fontUnderlineButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Underline")); + fontUnderlineButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Underline")); + + insetImagePane = new TextInsetImageBackgroundSpecialPane(); + + alignPane = new UIButtonGroup<>( + new Icon[]{ + IconUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), + IconUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), + IconUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png") + }, + new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT}); + alignPane.setAllToolTips( + new String[] { + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Left"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Center"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Right") + }); + alignPane.setSelectedItem(DEFAULT_TITLE_PACKER.getPosition()); + + backgroundPane = new TitleTranslucentBackgroundSpecialPane(this.uiLabelWidth, this.uiSettingWidth); + } + + private void initializePane() { + this.setLayout(new BorderLayout(0, 0)); + this.initializeComponents(); + + titleVisiblePane = this.createTitleVisiblePane(); + titleContentPane = this.createTitleContentPane(); + titleOtherSettingPane = this.createTitleOtherSettingPane(); + + if (isSupportTitleVisible) { + titleVisiblePane.setVisible(true); + } + if (isSupportTitleVisible) { + titleContentPane.setVisible(false); + } + if (isSupportTitleVisible) { + titleOtherSettingPane.setVisible(false); + } + + addComponents(titleVisiblePane, titleContentPane, titleOtherSettingPane); + } + + private JPanel createTitleVisiblePane() { + JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + + visibleCheckbox.setSelected(false); + + container.add(visibleCheckbox, BorderLayout.WEST); + container.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Visible")), BorderLayout.CENTER); + + visibleCheckbox.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + boolean visible = visibleCheckbox.isSelected(); + if (titleContentPane != null) { + titleContentPane.setVisible(visible && isSupportTitleContent); + } + if (titleOtherSettingPane != null) { + titleOtherSettingPane.setVisible(visible && isSupportTitleOtherSetting); + } + } + }); + return container; + } + + private JPanel createTitleContentPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] rowSize = {p}; + double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f}; + + return TableLayoutHelper.createCommonTableLayoutPane( + new JComponent[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Content")), textContentPane}}, + rowSize, columnSize, IntervalConstants.INTERVAL_L1); + } + + private JPanel createTitleOtherSettingPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] rowSize = {p, p, p, p, p}; + double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f}; + + JComponent[][] components = new JComponent[][]{ + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Format")), fontFamilyComboBox}, + {null, createTitleFontButtonPane()}, + {insetImagePane, null}, + {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Text_Align")), alignPane}, + {backgroundPane, null} + }; + + return TableLayoutHelper.createCommonTableLayoutPane(components, rowSize, columnSize, IntervalConstants.INTERVAL_L1); + } + + protected JPanel createTitleFontButtonPane(){ + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] rowSize = {p}; + double[] columnSize = {f, p, p, p, p}; + + JPanel buttonPane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][] { + {fontSizeComboBox, fontColorSelectPane, fontItalicButton, fontBoldButton, fontUnderlineButton}, + }, rowSize, columnSize, IntervalConstants.INTERVAL_W0); + + JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + containerPane.add(buttonPane, BorderLayout.NORTH); + + return containerPane; + } + + @Override + public void populateBean(BorderPacker style) { + TitlePacker widgetTitle = style == null ? new WidgetTitle() : style.getTitle(); + widgetTitle = widgetTitle == null ? new WidgetTitle() : widgetTitle; + boolean titleVisible = style != null && style.getType() != LayoutBorderStyle.STANDARD; + visibleCheckbox.setSelected(isSupportTitleVisible && titleVisible); + titleContentPane.setVisible(isSupportTitleContent && titleVisible); + titleOtherSettingPane.setVisible(isSupportTitleOtherSetting && titleVisible); + + this.textContentPane.populateBean(widgetTitle.getTextObject().toString()); + + FRFont frFont = widgetTitle.getFrFont(); + this.fontSizeComboBox.setSelectedItem(frFont.getSize()); + this.fontFamilyComboBox.setSelectedItem(frFont.getFamily()); + this.fontColorSelectPane.setColor(frFont.getForeground()); + this.fontColorSelectPane.repaint(); + fontBoldButton.setSelected(frFont.isBold()); + fontItalicButton.setSelected(frFont.isItalic()); + + int line = frFont.getUnderline(); + if (line == Constants.LINE_NONE) { + fontUnderlineButton.setSelected(false); + } else { + fontUnderlineButton.setSelected(true); + } + + alignPane.setSelectedItem(widgetTitle.getPosition()); + insetImagePane.populateBean(widgetTitle); + backgroundPane.populateBean(widgetTitle); + } + + @Override + public void updateBean(BorderPacker style) { + style.setType(visibleCheckbox != null && visibleCheckbox.isSelected() ? LayoutBorderStyle.TITLE : LayoutBorderStyle.STANDARD); + TitlePacker title = style.getTitle() == null ? new WidgetTitle() : style.getTitle(); + title.setTextObject(textContentPane.updateBean()); + FRFont frFont = title.getFrFont(); + frFont = frFont.applySize((Integer) fontSizeComboBox.getSelectedItem()); + frFont = frFont.applyName(fontFamilyComboBox.getSelectedItem().toString()); + frFont = frFont.applyForeground(fontColorSelectPane.getColor()); + frFont = updateTitleFontItalicBold(frFont); + int line = fontUnderlineButton.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE; + frFont = frFont.applyUnderline(line); + title.setFrFont(frFont); + title.setPosition((Integer) alignPane.getSelectedItem()); + insetImagePane.updateBean(title); + backgroundPane.updateBean(title); + style.setTitle(title); + } + + private FRFont updateTitleFontItalicBold(FRFont frFont) { + int italic_bold = frFont.getStyle(); + boolean isItalic = italic_bold == Font.ITALIC || italic_bold == (Font.BOLD + Font.ITALIC); + boolean isBold = italic_bold == Font.BOLD || italic_bold == (Font.BOLD + Font.ITALIC); + if (fontItalicButton.isSelected() && !isItalic) { + italic_bold += Font.ITALIC; + } else if (!fontItalicButton.isSelected() && isItalic) { + italic_bold -= Font.ITALIC; + } + frFont = frFont.applyStyle(italic_bold); + if (fontBoldButton.isSelected() && !isBold) { + italic_bold += Font.BOLD; + } else if (!fontBoldButton.isSelected() && isBold) { + italic_bold -= Font.BOLD; + } + frFont = frFont.applyStyle(italic_bold); + return frFont; + } + + private void addComponents(JComponent... components) { + if (components == null) { + return; + } + JPanel container = this; + for (JComponent component: components) { + if (component != null) { + container.add(component, BorderLayout.NORTH); + JPanel nextContainer = new JPanel(FRGUIPaneFactory.createBorderLayout()); + nextContainer.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0)); + container.add(nextContainer, BorderLayout.CENTER); + container = nextContainer; + } + } + } + + + public void setSupportTitleVisible(boolean supporting) { + isSupportTitleVisible = supporting; + if (titleVisiblePane != null) { + titleVisiblePane.setVisible(supporting); + } + } + + public void setSupportTitleContent(boolean supporting) { + isSupportTitleContent = supporting; + if (titleContentPane != null) { + boolean titleVisible = visibleCheckbox.isSelected(); + if (isSupportTitleContent) { + titleContentPane.setVisible(titleVisible); + } else { + titleContentPane.setVisible(false); + } + } + } + + public void setSupportOtherSetting(boolean supporting) { + isSupportTitleOtherSetting = supporting; + if (titleOtherSettingPane != null) { + boolean titleVisible = visibleCheckbox.isSelected(); + if (isSupportTitleOtherSetting) { + titleOtherSettingPane.setVisible(titleVisible); + } else { + titleOtherSettingPane.setVisible(false); + } + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java b/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java new file mode 100644 index 0000000000..55f4612a2b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java @@ -0,0 +1,138 @@ +package com.fr.design.gui.style; + +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.TemplateTheme; +import com.fr.design.dialog.BasicPane; +import com.fr.design.event.GlobalNameListener; +import com.fr.design.event.GlobalNameObserver; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.file.HistoryTemplateListCache; +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.JTemplate; + +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.ArrayList; +import java.util.List; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/19 + */ +public class FollowingThemePane extends BasicPane implements UIObserver { + public static final int SETTING_LABEL_WIDTH = 60; + + public static final String[] FOLLOWING_THEME_STRING_ARRAYS = new String[]{ + Toolkit.i18nText("Fine-Design_Style_Follow_Theme"), + Toolkit.i18nText("Fine-Design_Style_Not_Follow_Theme"), + }; + + private final UIButtonGroup followingThemeButtonGroup; + private final List changeListeners = new ArrayList<>(); + private UIObserverListener uiObserverListener; + + private JPanel container; + + public FollowingThemePane(String name) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + + followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); + followingThemeButtonGroup.setSelectedIndex(1); + followingThemeButtonGroup.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + for (FollowingThemeActionChangeListener changeListener : changeListeners) { + changeListener.onFollowingTheme(isFollowingTheme()); + } + invalidate(); + + // 与主题相关的属性面板更新完毕后,再通知外层更新数据 + if (uiObserverListener != null) { + uiObserverListener.doChange(); + } + } + }); + + UILabel followingThemeLabel = new UILabel(name); + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + JPanel followingThemePane = + TableLayoutHelper.createGapTableLayoutPane( new Component[][]{new Component[] { followingThemeLabel, followingThemeButtonGroup}}, + new double[] { p }, new double[] { SETTING_LABEL_WIDTH, f }, 10, 0); + followingThemePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + followingThemePane.setVisible(false); + + add(followingThemePane, BorderLayout.NORTH); + container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + add(container, BorderLayout.CENTER); + } + + public void addFollowThemePane(JPanel content, FollowingThemeActionChangeListener changeListener) { + if (content != null) { + container.add(content, BorderLayout.NORTH); + changeListeners.add(changeListener); + + JPanel nextContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); + container.add(nextContainer, BorderLayout.CENTER); + container = nextContainer; + } + } + + @Override + protected String title4PopupWindow() { + return null; + } + + @Override + public void registerChangeListener(UIObserverListener uiObserverListener) { + this.uiObserverListener = uiObserverListener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + public interface FollowingThemeActionChangeListener { + void onFollowingTheme(boolean following); + } + + public TemplateTheme getUsingTheme() { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + return template.getTemplateTheme(); + } + return null; + } + + public void supportFollowingTheme(boolean supporting) { + getComponent(0).setVisible(supporting); + if (!supporting) { + setFollowingTheme(false); + } + } + + public void setFollowingTheme(boolean following) { + followingThemeButtonGroup.setSelectedIndex(following ? 0 : 1); + for (FollowingThemeActionChangeListener changeListener : changeListeners) { + changeListener.onFollowingTheme(isFollowingTheme()); + } + } + public boolean isFollowingTheme() { + return followingThemeButtonGroup.getSelectedIndex() == 0; + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/style/ReportBackgroundSpecialPane.java b/designer-base/src/main/java/com/fr/design/gui/style/ReportBackgroundSpecialPane.java new file mode 100644 index 0000000000..aeb2938a27 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/style/ReportBackgroundSpecialPane.java @@ -0,0 +1,102 @@ +package com.fr.design.gui.style; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.event.UIObserverListener; +import com.fr.design.fun.BackgroundQuickUIProvider; +import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.ImageBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.NullBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.PatternBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.TextureBackgroundQuickPane; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/19 + */ +public class ReportBackgroundSpecialPane extends BackgroundPane { + public ReportBackgroundSpecialPane(){ + super(); + } + + @Override + protected BackgroundQuickPane[] supportKindsOfBackgroundUI() { + NullBackgroundQuickPane nullBackgroundPane = new NullBackgroundQuickPane(); + + ColorBackgroundQuickPane colorBackgroundPane = new ColorBackgroundQuickPane(); + colorBackgroundPane.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + fireStateChanged(); + } + }); + + ImageBackgroundQuickPane imageBackgroundPane = new ImageBackgroundQuickPane(); + imageBackgroundPane.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + fireStateChanged(); + } + }); + + GradientBackgroundQuickPane gradientBackgroundPane = createGradientBackgroundQuickPane(); + gradientBackgroundPane.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + fireStateChanged(); + } + }); + + TextureBackgroundQuickPane textureBackgroundPane = new TextureBackgroundQuickPane(); + textureBackgroundPane.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + fireStateChanged(); + } + }); + + PatternBackgroundQuickPane patternBackgroundPane = new PatternBackgroundQuickPane(); + patternBackgroundPane.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + fireStateChanged(); + } + }); + + + + List kinds = new ArrayList(); + + kinds.add(nullBackgroundPane); + kinds.add(colorBackgroundPane); + kinds.add(imageBackgroundPane); + kinds.add(gradientBackgroundPane); + kinds.add(textureBackgroundPane); + kinds.add(patternBackgroundPane); + + Set providers = ExtraDesignClassManager.getInstance().getArray(BackgroundQuickUIProvider.MARK_STRING); + for (BackgroundQuickUIProvider provider : providers) { + BackgroundQuickPane newTypePane = provider.appearanceForBackground(); + newTypePane.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + fireStateChanged(); + } + }); + kinds.add(newTypePane); + } + + return kinds.toArray(new BackgroundQuickPane[kinds.size()]); + } + + protected GradientBackgroundQuickPane createGradientBackgroundQuickPane() { + // 使用默认的150宽度构建渐变条 + return new GradientBackgroundQuickPane(); + } +} diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java b/designer-base/src/main/java/com/fr/design/gui/style/TextInsetImageBackgroundSpecialPane.java similarity index 95% rename from designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java rename to designer-base/src/main/java/com/fr/design/gui/style/TextInsetImageBackgroundSpecialPane.java index 3671259a20..b3556dc6f8 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/TextInsetImageBackgroundSpecialPane.java @@ -1,4 +1,4 @@ -package com.fr.design.gui.xpane; +package com.fr.design.gui.style; import com.fr.base.Style; import com.fr.base.background.ImageBackground; @@ -18,7 +18,6 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.backgroundpane.ImagePreviewPane; import com.fr.design.style.background.image.ImageFileChooser; -import com.fr.design.widget.ui.designer.component.UIBoundSpinner; import com.fr.form.ui.WidgetTitle; import com.fr.general.Background; import com.fr.general.IOUtils; @@ -26,11 +25,20 @@ import com.fr.general.ImageWithSuffix; import com.fr.general.act.TitlePacker; import com.fr.stable.Constants; -import javax.swing.*; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.plaf.basic.BasicButtonUI; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Rectangle; +import java.awt.Shape; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; @@ -42,8 +50,8 @@ import java.awt.geom.RoundRectangle2D; * @version 10.0.18 * Created by Starryi on 2021/7/3 */ -public class TitleInsetImagePane extends JPanel implements UIObserver { - private final int SETTING_LABEL_WIDTH = LayoutStylePane.SETTING_LABEL_WIDTH; +public class TextInsetImageBackgroundSpecialPane extends JPanel implements UIObserver { + private final int SETTING_LABEL_WIDTH = 60; private final int DELETE_BUTTON_SIZE = 24; private final int IMAGE_PREVIEW_SIZE = 145; private final Color IMAGE_PREVIEW_OVERLAY_COLOR = new Color(255, 255, 255, 51); @@ -62,7 +70,7 @@ public class TitleInsetImagePane extends JPanel implements UIObserver { private ImageFileChooser imageFileChooser; - public TitleInsetImagePane() { + public TextInsetImageBackgroundSpecialPane() { this.initComponents(); this.initLayout(); } @@ -198,7 +206,7 @@ public class TitleInsetImagePane extends JPanel implements UIObserver { com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Inset_Relative_Right_Tooltip"), }); - imagePaddingPane = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, WidgetTitle.DEFAULT_INSET_PADDING); + imagePaddingPane = new UISpinner(0, Integer.MAX_VALUE, 1, WidgetTitle.DEFAULT_INSET_PADDING); imagePaddingPane.setValue(DEFAULT_INSET_PADDING); } diff --git a/designer-base/src/main/java/com/fr/design/gui/style/TitleTranslucentBackgroundSpecialPane.java b/designer-base/src/main/java/com/fr/design/gui/style/TitleTranslucentBackgroundSpecialPane.java new file mode 100644 index 0000000000..db8c64e19c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/style/TitleTranslucentBackgroundSpecialPane.java @@ -0,0 +1,27 @@ +package com.fr.design.gui.style; + +import com.fr.general.act.TitlePacker; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/11 + */ +public class TitleTranslucentBackgroundSpecialPane extends AbstractTranslucentBackgroundSpecialPane { + + public TitleTranslucentBackgroundSpecialPane(int uiLabelWidth, int uiSettingWidth) { + super(uiLabelWidth, uiSettingWidth, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Background")); + } + + @Override + public void populateBean(TitlePacker style) { + backgroundPane.populateBean(style.getBackground()); + opacityPane.populateBean(style.getBackgroundOpacity()); + } + + @Override + public void updateBean(TitlePacker style) { + style.setBackground(backgroundPane.update()); + style.setBackgroundOpacity((float)opacityPane.updateBean()); + } +} diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java b/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java similarity index 96% rename from designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java rename to designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java index 0f2b853d1b..237a5659a7 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java @@ -1,8 +1,6 @@ -package com.fr.design.gui.xpane; +package com.fr.design.gui.style; -import com.fr.base.GraphHelper; import com.fr.base.Style; -import com.fr.base.Utils; import com.fr.base.background.ImageBackground; import com.fr.base.background.ImageFileBackground; import com.fr.design.border.UIRoundedBorder; @@ -16,8 +14,6 @@ import com.fr.design.event.UIObserverListener; import com.fr.design.gui.frpane.ImgChooseWrapper; import com.fr.design.gui.frpane.UIPercentDragPane; import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ibutton.UIButtonUI; -import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; @@ -28,9 +24,9 @@ import com.fr.design.mainframe.backgroundpane.ImagePreviewPane; import com.fr.design.style.background.image.ImageFileChooser; import com.fr.design.style.color.NewColorSelectBox; import com.fr.env.utils.DesignerInteractionHistory; -import com.fr.form.ui.LayoutBorderStyle; import com.fr.general.Background; import com.fr.general.IOUtils; +import com.fr.general.act.BorderPacker; import com.fr.stable.Constants; import com.fr.stable.GraphDrawHelper; import com.fr.stable.ProjectLibrary; @@ -78,8 +74,8 @@ import java.util.Arrays; * * 可配置图片类型边框的样式设置面板 */ -public class BorderLineAndImagePane extends JPanel implements UIObserver { - private final int SETTING_LABEL_WIDTH = LayoutStylePane.SETTING_LABEL_WIDTH; +public class TranslucentBorderSpecialPane extends AbstractBorderPackerPane implements UIObserver { + private final int SETTING_LABEL_WIDTH = 60; private final Style DEFAULT_IMAGE_LAYOUT_STYLE = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_DEFAULT); private final String TWEAK_NINE_POINT_HELP_URL = "https://help.fanruan.com/finereport/doc-view-4135.html"; @@ -98,7 +94,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { private int[] ninePoint = new int[] {-1, -1, -1, -1}; - public BorderLineAndImagePane(boolean supportBorderImage) { + public TranslucentBorderSpecialPane(boolean supportBorderImage) { this.initComponents(supportBorderImage); this.initLayout(); } @@ -273,7 +269,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { if (imagePreviewPane.getImage() != null) { tweakPane.previewPane.setNinePoint(ninePoint); - BasicDialog dialog = tweakPane.showWindow(SwingUtilities.getWindowAncestor(BorderLineAndImagePane.this)); + BasicDialog dialog = tweakPane.showWindow(SwingUtilities.getWindowAncestor(TranslucentBorderSpecialPane.this)); dialog.addDialogActionListener(new DialogActionAdapter() { @Override public void doOk() { @@ -287,7 +283,13 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { }); } - public void populateBean(LayoutBorderStyle style) { + @Override + protected String title4PopupWindow() { + return null; + } + + @Override + public void populateBean(BorderPacker style) { int borderLine = style.getBorder(); Color borderColor = style.getColor(); @@ -333,7 +335,8 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { this.borderColorPane.setSelectObject(style.getColor()); } - public void updateBean(LayoutBorderStyle style) { + @Override + public void updateBean(BorderPacker style) { style.setBorder(this.borderLineCombo.getSelectedLineStyle()); style.setColor(this.borderColorPane.getSelectObject()); @@ -366,24 +369,6 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { return true; } - protected UIButtonUI createButtonUI(final UIColorButton uiColorButton) { - return new UIButtonUI() { - - public void paint(Graphics g, JComponent c) { - UIButton b = (UIButton) c; - g.setColor(Color.black); - GraphHelper.draw(g, new RoundRectangle2D.Double(1, 1, b.getWidth() - 2, b.getHeight() - 2, 0, 0), 1); - - if (b.getModel().isEnabled()) { - g.setColor(uiColorButton.getColor()); - } else { - g.setColor(new Color(Utils.filterRGB(uiColorButton.getColor().getRGB(), 50))); - } - g.fillRect(2, 2, b.getWidth() - 3, b.getHeight() - 3); - } - }; - } - protected static class BorderLineAndImageComboBox extends LineComboBox { public static final int LINE_PICTURE = -1; public final static int[] BORDER_LINE_AND_IMAGE_STYLE_ARRAY = new int[] { diff --git a/designer-base/src/main/java/com/fr/design/hyperlink/popup/ContentSettingPane.java b/designer-base/src/main/java/com/fr/design/hyperlink/popup/ContentSettingPane.java new file mode 100644 index 0000000000..848ac9e57c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/hyperlink/popup/ContentSettingPane.java @@ -0,0 +1,328 @@ +package com.fr.design.hyperlink.popup; + +import com.fr.base.BaseFormula; +import com.fr.base.BaseUtils; +import com.fr.base.Parameter; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.frpane.ReportletParameterViewPane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.itableeditorpane.UITableEditAction; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.gui.itree.filetree.ReportletPane; +import com.fr.design.hyperlink.AbstractHyperLinkPane; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.module.DesignModuleFactory; +import com.fr.design.parameter.ParameterReader; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.js.MobilePopupHyperlink; +import com.fr.stable.CommonUtils; +import com.fr.stable.FormulaProvider; +import com.fr.stable.ParameterProvider; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; + +public class ContentSettingPane extends AbstractHyperLinkPane { + private JPanel popupTargetPane; + private UIRadioButton templatePopupButton; + private UIRadioButton textPopupButton; + private ButtonGroup popupTargetButtons; + + private JPanel templateContentPane; + private UITextField templatePathTextField; + private UICheckBox extendParametersCheckBox; + + private JPanel textSettingPanel; + private TinyFormulaPane textContentPane; + private CustomFontPane fontPane; + + public ContentSettingPane() { + super(); + this.initCompoennt(); + } + + public void addTargetRadioActionListener(ActionListener listener) { + templatePopupButton.addActionListener(listener); + textPopupButton.addActionListener(listener); + } + + public String getTargetType() { + if (templatePopupButton.isSelected()) { + return MobilePopupConstants.Target_Template; + } else { + return MobilePopupConstants.Target_Text; + } + + } + + private void initCompoennt() { + this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); + this.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Content"))); + + popupTargetPane = this.createPopupTargetPane(); + this.add(popupTargetPane, BorderLayout.NORTH); + + templateContentPane= this.createTemplateContentPane(); + textSettingPanel = this.createTextSettingPane(); + } + + private JPanel createPopupTargetPane() { + templatePopupButton = new UIRadioButton(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Template")); + templatePopupButton.addActionListener(radioActionListener); + + textPopupButton = new UIRadioButton(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Text")); + textPopupButton.addActionListener(radioActionListener); + + popupTargetButtons = new ButtonGroup(); + popupTargetButtons.add(templatePopupButton); + popupTargetButtons.add(textPopupButton); + + JPanel popupButtonsPanel = new JPanel(); + popupButtonsPanel.setLayout( new FlowLayout(FlowLayout.LEFT, 10, 0)); + popupButtonsPanel.add(templatePopupButton); + popupButtonsPanel.add(textPopupButton); + return MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Target"), popupButtonsPanel); + } + + private ActionListener radioActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if(templatePopupButton.isSelected()) { + ContentSettingPane.this.add(templateContentPane); + ContentSettingPane.this.remove(textSettingPanel); + } else if (textPopupButton.isSelected()) { + ContentSettingPane.this.add(textSettingPanel); + ContentSettingPane.this.remove(templateContentPane); + } + ContentSettingPane.this.revalidate(); + ContentSettingPane.this.repaint(); + } + }; + + private JPanel createTemplateContentPane() { + JPanel templateContentPane = new JPanel(); + templateContentPane.setLayout(new BorderLayout(0,8)); + + templateContentPane.add(this.createTemplateSelectPanel(), BorderLayout.NORTH); + + parameterViewPane = this.createReportletParameterViewPane(); + templateContentPane.add(parameterViewPane, BorderLayout.CENTER); + + extendParametersCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Extends_Report_Parameters")); + templateContentPane.add(GUICoreUtils.createFlowPane(extendParametersCheckBox, FlowLayout.LEFT), BorderLayout.SOUTH); + + return templateContentPane; + } + + private JPanel createTemplateSelectPanel() { + JPanel templatePanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + // 路径输入框 + templatePathTextField = new UITextField(20); + templatePanel.add(templatePathTextField, BorderLayout.CENTER); + + // 选择路径按钮 + UIButton templateSelectButton = new UIButton(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Select")); + templateSelectButton.setPreferredSize(new Dimension(templateSelectButton.getPreferredSize().width, 20)); + templatePanel.add(templateSelectButton, BorderLayout.EAST); + templateSelectButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent evt) { + final ReportletPane reportletPane = new ReportletPane(); + reportletPane.setSelectedReportletPath(templatePathTextField.getText()); + BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(ContentSettingPane.this)); + + reportletDialog.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + templatePathTextField.setText(reportletPane.getSelectedReportletPath()); + } + }); + reportletDialog.setVisible(true); + } + }); + return MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Template"), templatePanel); + } + + private ReportletParameterViewPane createReportletParameterViewPane() { + ReportletParameterViewPane templateParameterViewPane = new ReportletParameterViewPane( + new UITableEditAction[]{ + new HyperlinkParametersAction() + }, + getChartParaType(), + getValueEditorPane(), + getValueEditorPane() + ); + templateParameterViewPane.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Parameter"), null)); + templateParameterViewPane.setPreferredSize(new Dimension(this.getWidth(), 200)); + return templateParameterViewPane; + } + + private JPanel createTextSettingPane() { + JPanel textSettingPanel = new JPanel(); + textSettingPanel.setLayout(new BorderLayout(0,8)); + + textContentPane = new TinyFormulaPane(); + textContentPane.getUITextField().setColumns(20); + textSettingPanel.add( + MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Text"), textContentPane), + BorderLayout.CENTER); + + fontPane = new CustomFontPane(); + textSettingPanel.add( + MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Style"), fontPane), + BorderLayout.SOUTH); + return MobilePopupUIUtils.createTitleSplitLineContentPane("", textSettingPanel); + } + + private String getReportletName() { + String text = this.templatePathTextField.getText(); + return StringUtils.isBlank(text) ? StringUtils.EMPTY : text.substring(1); + } + + @Override + public void populateBean(MobilePopupHyperlink link) { + this.populatePopupTargetBean(link.getPopupTarget()); + this.populateTemplateContentBean(link); + this.populateTextContentBean(link); + + } + + @Override + public MobilePopupHyperlink updateBean() { + return null; + } + + @Override + public void updateBean(MobilePopupHyperlink link) { + this.updatePopupTargetBean(link); + this.updateTemplateContentBean(link); + this.updateTextContentBean(link); + } + + @Override + public String title4PopupWindow() { + return StringUtils.EMPTY; + } + + /** + * 自动添加模板参数的按钮操作 + */ + private class HyperlinkParametersAction extends UITableEditAction { + public HyperlinkParametersAction() { + this.setName(Toolkit.i18nText("Fine-Design_Basic_Template_Parameter")); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/p.gif")); + } + + @Override + public void actionPerformed(ActionEvent e) { + String tpl = getReportletName(); + if (StringUtils.isBlank(tpl)) { + JOptionPane.showMessageDialog( + ContentSettingPane.this, + Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Please_Select_Reportlet") + ".", + Toolkit.i18nText("Fine-Design_Basic_Message"), + JOptionPane.WARNING_MESSAGE); + return; + } + + //根据模板路径返回参数 + //与当前模块、当前文件无关 + Parameter[] parameters = new Parameter[0]; + + ParameterReader[] readers = DesignModuleFactory.getParameterReaders(); + for (ParameterReader reader : readers) { + Parameter[] ps = reader.readParameterFromPath(tpl); + if (ps != null) { + parameters = ps; + } + } + parameterViewPane.populate(parameters); + } + + @Override + public void checkEnabled() { + //do nothing + } + } + + private void populatePopupTargetBean(String target) { + if (StringUtils.equals(target, MobilePopupConstants.Target_Text)) { + popupTargetButtons.setSelected(textPopupButton.getModel(), true); + this.remove(templateContentPane); + this.add(textSettingPanel, BorderLayout.CENTER); + } else { + popupTargetButtons.setSelected(templatePopupButton.getModel(), true); + this.remove(textSettingPanel); + this.add(templateContentPane, BorderLayout.CENTER); + } + + } + + private void updatePopupTargetBean(MobilePopupHyperlink mobilePopupHyperlink) { + if (templatePopupButton.isSelected()) { + mobilePopupHyperlink.setPopupTarget(MobilePopupConstants.Target_Template); + } else if (textPopupButton.isSelected()) { + mobilePopupHyperlink.setPopupTarget(MobilePopupConstants.Target_Text); + } + } + + private void populateTemplateContentBean(MobilePopupHyperlink link) { + // 模板路径 + templatePathTextField.setText(link.getReportletPath()); + + // 参数面板 + List parameterList = this.parameterViewPane.update(); + parameterList.clear(); + ParameterProvider[] parameters =link.getParameters(); + parameterViewPane.populate(parameters); + + // 继承参数 + extendParametersCheckBox.setSelected(link.isExtendParameters()); + } + + private void updateTemplateContentBean(MobilePopupHyperlink link) { + link.setReportletPath(templatePathTextField.getText()); + + List parameterList = this.parameterViewPane.update(); + if (!parameterList.isEmpty()) { + Parameter[] parameters = new Parameter[parameterList.size()]; + parameterList.toArray(parameters); + link.setParameters(parameters); + } else { + link.setParameters(null); + } + + link.setExtendParameters(extendParametersCheckBox.isSelected()); + + } + + private void populateTextContentBean(MobilePopupHyperlink link) { + Object text = link.getPopupText(); + if (text instanceof FormulaProvider) { + textContentPane.populateBean(((FormulaProvider) text).getContent()); + } else { + textContentPane.populateBean(text == null ? StringUtils.EMPTY : text.toString()); + } + fontPane.populateBean(link.getFRFont()); + } + private void updateTextContentBean(MobilePopupHyperlink link) { + link.setPopupText(textContentPane.getUITextField().getText()); + String text = textContentPane.updateBean(); + if (CommonUtils.maybeFormula(text)) { + link.setPopupText(BaseFormula.createFormulaBuilder().build(textContentPane.updateBean())); + } else { + link.setPopupText(text); + } + + link.setFRFont(fontPane.updateBean()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/hyperlink/popup/CustomFontPane.java b/designer-base/src/main/java/com/fr/design/hyperlink/popup/CustomFontPane.java new file mode 100644 index 0000000000..aa3e3f8680 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/hyperlink/popup/CustomFontPane.java @@ -0,0 +1,100 @@ +package com.fr.design.hyperlink.popup; + +import com.fr.base.BaseUtils; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.ibutton.UIToggleButton; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.FRFont; +import com.fr.stable.Constants; + +import javax.swing.*; +import java.awt.*; +import java.util.Vector; + +public class CustomFontPane extends JPanel { + private static final int MAX_FONT_SIZE = 100; + private static final Dimension BUTTON_SIZE = new Dimension(20, 18); + + public static Vector getFontSizes() { + Vector FONT_SIZES = new Vector(); + for (int i = 1; i < MAX_FONT_SIZE; i++) { + FONT_SIZES.add(i); + } + return FONT_SIZES; + } + + private UIComboBox fontSizeComboBox; + private UIToggleButton bold; + private UIToggleButton italic; + private UIToggleButton underline; + private UIColorButton colorSelectPane; + + public CustomFontPane() { + this.initComponent(); + } + + private void initComponent() { + + fontSizeComboBox = new UIComboBox(getFontSizes()); + fontSizeComboBox.setPreferredSize(new Dimension(60, 20)); + fontSizeComboBox.setEditable(true); + + colorSelectPane = new UIColorButton(); + bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); + italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); + underline = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png")); + + this.setButtonsTips(); + this.setButtonsSize(BUTTON_SIZE); + + Component[] components_font = new Component[]{ + fontSizeComboBox, colorSelectPane, bold, underline, italic + }; + + JPanel buttonPane = new JPanel(new BorderLayout()); + buttonPane.add(GUICoreUtils.createFlowPane(components_font, FlowLayout.LEFT, LayoutConstants.HGAP_SMALL)); + + this.setLayout(new BorderLayout(0,0)); + this.add(buttonPane, BorderLayout.CENTER); + } + + private void setButtonsTips() { + colorSelectPane.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Foreground")); + italic.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Italic")); + bold.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Bold")); + underline.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Underline")); + } + + private void setButtonsSize(Dimension size) { + colorSelectPane.setPreferredSize(size); + bold.setPreferredSize(size); + italic.setPreferredSize(size); + underline.setPreferredSize(size); + } + + + public void populateBean(FRFont frFont) { + fontSizeComboBox.setSelectedItem(frFont.getSize()); + colorSelectPane.setColor(frFont.getForeground()); + bold.setSelected(frFont.isBold()); + italic.setSelected(frFont.isItalic()); + underline.setSelected(frFont.getUnderline() != Constants.LINE_NONE); + } + + public FRFont updateBean() { + int style = Font.PLAIN; + style += this.bold.isSelected() ? Font.BOLD : Font.PLAIN; + style += this.italic.isSelected() ? Font.ITALIC : Font.PLAIN; + return FRFont.getInstance( + FRFont.DEFAULT_FONTNAME, + style, + Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()), + colorSelectPane.getColor(), + underline.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE + ); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupConstants.java b/designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupConstants.java new file mode 100644 index 0000000000..d4423d6795 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupConstants.java @@ -0,0 +1,22 @@ +package com.fr.design.hyperlink.popup; + +import com.fr.stable.Constants; + +public interface MobilePopupConstants { + int[] BORDER_LINE_STYLE_ARRAY = new int[]{ + Constants.LINE_NONE, + Constants.LINE_THIN, + Constants.LINE_MEDIUM, + Constants.LINE_THICK, + }; + + String Target_Template= "template"; + String Target_Text = "text"; + String Regular_Custom = "custom"; + String Regular_Auto_Height = "auto_height"; + + double Popup_Center_Default_Width = 95; + double Popup_Center_Default_Height = 95; + double Popup_Follow_Default_Width = 40; + double Popup_Follow_Default_Height = 10; +} diff --git a/designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupPane.java b/designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupPane.java new file mode 100644 index 0000000000..f4389d9539 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupPane.java @@ -0,0 +1,81 @@ +package com.fr.design.hyperlink.popup; + +import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.i18n.Toolkit; +import com.fr.js.MobilePopupHyperlink; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class MobilePopupPane extends FurtherBasicBeanPane { + private ContentSettingPane contentSettingPane; + private StyleSettingPane styleSettingPane; + + public MobilePopupPane() { + this.initComponents(); + this.setDefaultBean(); + } + + protected void initComponents() { + this.setLayout(new BorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + + JPanel scrollContent = new JPanel(); + scrollContent.setLayout(new BorderLayout(10, 10)); + contentSettingPane = new ContentSettingPane(); + scrollContent.add(contentSettingPane, BorderLayout.NORTH); + styleSettingPane = new StyleSettingPane(); + scrollContent.add(styleSettingPane, BorderLayout.CENTER); + + contentSettingPane.addTargetRadioActionListener(radioActionListener); + + UIScrollPane scrollPane= new UIScrollPane(scrollContent); + scrollPane.setBorder(BorderFactory.createEmptyBorder()); + + JComponent scrollComponent = new JLayer(scrollPane, new WheelScrollLayerUI()); + + this.add(scrollComponent, BorderLayout.CENTER); + } + + private void setDefaultBean() { + this.populateBean(new MobilePopupHyperlink()); + } + private ActionListener radioActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + styleSettingPane.resetPane(contentSettingPane.getTargetType()); + } + }; + + @Override + public void populateBean(MobilePopupHyperlink mobilePopupHyperlink) { + contentSettingPane.populateBean(mobilePopupHyperlink); + styleSettingPane.populateBean(mobilePopupHyperlink); + } + + @Override + public MobilePopupHyperlink updateBean() { + MobilePopupHyperlink mobilePopupHyperlink = new MobilePopupHyperlink(); + contentSettingPane.updateBean(mobilePopupHyperlink); + styleSettingPane.updateBean(mobilePopupHyperlink); + return mobilePopupHyperlink; + } + + @Override + public boolean accept(Object ob) { + return ob instanceof MobilePopupHyperlink; + } + + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup"); + } + + @Override + public void reset() { + this.setDefaultBean(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupRegularPane.java b/designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupRegularPane.java new file mode 100644 index 0000000000..65e5085d15 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupRegularPane.java @@ -0,0 +1,157 @@ +package com.fr.design.hyperlink.popup; + +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ibutton.UIRadioButton; +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.VerticalFlowLayout; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class MobilePopupRegularPane extends BasicPane { + private String label; + + private JPanel radiosPane; + private UIRadioButton customRadio; + private UIRadioButton autoRadio; + private ButtonGroup radioButtons; + + private JPanel spinnerGroupPane; + private UISpinner widthSpinner; + private JPanel widthSpinnerPane; + private UISpinner heightSpinner; + private JPanel heightSpinnerPane; + + + public MobilePopupRegularPane(String label) { + this.label = label; + this.initComponent(); + } + + private void initComponent() { + this.setLayout(new BorderLayout()); + this.add(this.createRadioButtonGroupPane(), BorderLayout.NORTH); + spinnerGroupPane = this.createSpinnerPane(); + this.add(spinnerGroupPane, BorderLayout.CENTER); + } + + private JPanel createRadioButtonGroupPane() { + radiosPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5)); + + customRadio = new UIRadioButton(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Custom")); + customRadio.addActionListener(radioActionListener); + autoRadio = new UIRadioButton(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Height_Adaptive")); + autoRadio.addActionListener(radioActionListener); + + radioButtons = new ButtonGroup(); + radioButtons.add(customRadio); + radioButtons.add(autoRadio); + + radiosPane.add(customRadio); + radiosPane.add(autoRadio); + + return MobilePopupUIUtils.createLeftTileRightContentPanel(this.label, radiosPane); + } + + private ActionListener radioActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + resetSpinnerGroupPane(customRadio.isSelected()); + } + }; + + private JPanel createSpinnerPane() { + JPanel spinnerPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 15, 5)); + spinnerPane.setBorder(BorderFactory.createEmptyBorder(0, MobilePopupUIUtils.Left_Title_width, 0, 0)); + widthSpinner = new UISpinner(0, 100, 1, 95); + widthSpinnerPane = this.createSpinnerLabelPane(widthSpinner, Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Width")); + heightSpinner = new UISpinner(0, 100, 1, 95); + heightSpinnerPane = this.createSpinnerLabelPane(heightSpinner, Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Height")); + + spinnerPane.add(widthSpinnerPane); + spinnerPane.add(heightSpinnerPane); + + return spinnerPane; + } + + private JPanel createSpinnerLabelPane(UISpinner spinner, String labelText) { + JPanel spinnerLabelPane = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 5)); + + JPanel spinnerPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 2,0)); + Dimension dimension = new Dimension(60, 20); + spinner.setPreferredSize(dimension); + UILabel percent = new UILabel("%"); + spinnerPane.add(spinner); + spinnerPane.add(percent); + + UILabel label = new UILabel(labelText); + label.setPreferredSize(dimension); + label.setHorizontalAlignment(SwingConstants.CENTER); + + spinnerLabelPane.add(spinnerPane); + spinnerLabelPane.add(label); + + return spinnerLabelPane; + } + + private void resetSpinnerGroupPane(boolean showHeightSpinnerPane) { + spinnerGroupPane.removeAll(); + spinnerGroupPane.add(widthSpinnerPane); + if(showHeightSpinnerPane) { + spinnerGroupPane.add(heightSpinnerPane); + } + spinnerGroupPane.revalidate(); + spinnerGroupPane.repaint(); + } + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } + + public void setRegularType(String regularType) { + if (StringUtils.equals(regularType, MobilePopupConstants.Regular_Auto_Height)) { + radioButtons.setSelected(autoRadio.getModel(), true); + } else { + radioButtons.setSelected(customRadio.getModel(), true); + } + resetSpinnerGroupPane(customRadio.isSelected()); + } + + public String getRegularType() { + if (autoRadio.isSelected()) { + return MobilePopupConstants.Regular_Auto_Height; + } else { + return MobilePopupConstants.Regular_Custom; + } + } + + public void setWidthSpinnerValue(double width) { + widthSpinner.setValue(width); + } + + public double getWidthSpinnerValue() { + return widthSpinner.getValue(); + } + + public void setHeightSpinnerValue(double height) { + heightSpinner.setValue(height); + } + + public double getHeightSpinnerValue() { + return heightSpinner.getValue(); + } + + public void resetPane(String regularType, double width, double height) { + this.setRegularType(regularType); + this.setWidthSpinnerValue(width); + this.setHeightSpinnerValue(height); + resetSpinnerGroupPane(StringUtils.equals(regularType, MobilePopupConstants.Regular_Custom)); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupUIUtils.java b/designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupUIUtils.java new file mode 100644 index 0000000000..cb3fbad58e --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupUIUtils.java @@ -0,0 +1,36 @@ +package com.fr.design.hyperlink.popup; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.mainframe.widget.UITitleSplitLine; + +import javax.swing.*; +import java.awt.*; + +public class MobilePopupUIUtils { + static public int Line_Height = 20; + static public int SplitLineWidth = 520; + static public int Left_Title_width = 80; + + static public JPanel createLeftTileRightContentPanel(String title, JComponent contentPanel) { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(0,0,0, 30)); + jp.setLayout(new BorderLayout(10,0)); + UILabel titleLabel = new UILabel(title + ":"); + titleLabel.setPreferredSize(new Dimension(MobilePopupUIUtils.Left_Title_width, Line_Height)); + titleLabel.setHorizontalAlignment(SwingConstants.RIGHT); + jp.add(titleLabel, BorderLayout.WEST); + jp.add(contentPanel, BorderLayout.CENTER); + return jp; + } + + static public JPanel createTitleSplitLineContentPane(String title, JComponent contentPanel) { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); + jp.setLayout(new BorderLayout(0, 10)); + UITitleSplitLine titleLine = new UITitleSplitLine(title, SplitLineWidth); + titleLine.setPreferredSize(new Dimension(SplitLineWidth, Line_Height)); + jp.add(titleLine, BorderLayout.NORTH); + jp.add(contentPanel, BorderLayout.CENTER); + return jp; + } +} diff --git a/designer-base/src/main/java/com/fr/design/hyperlink/popup/StyleSettingPane.java b/designer-base/src/main/java/com/fr/design/hyperlink/popup/StyleSettingPane.java new file mode 100644 index 0000000000..1bebe3dfc8 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/hyperlink/popup/StyleSettingPane.java @@ -0,0 +1,205 @@ +package com.fr.design.hyperlink.popup; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.frpane.UINumberDragPane; +import com.fr.design.gui.icombobox.LineComboBox; +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.FRGUIPaneFactory; +import com.fr.design.layout.VerticalFlowLayout; +import com.fr.design.style.color.NewColorSelectBox; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.js.MobilePopupHyperlink; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import java.awt.*; + +public class StyleSettingPane extends BasicBeanPane { + private double maxNumber = 100; + private double maxBorderRadius = 24; + + JPanel typePane; + UILabel popupTypeLabel; + + JPanel stylePane; + LineComboBox borderType; + NewColorSelectBox borderColor; + UISpinner borderRadiusSpinner; + + NewColorSelectBox bgColor; + //透明度 + UINumberDragPane numberDragPane; + + MobilePopupRegularPane mobileRegularPane; + MobilePopupRegularPane padRegularPane; + + public StyleSettingPane() { + this.initComponent(); + } + + private void initComponent() { + this.setLayout(new BorderLayout(0, 10)); + this.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Style"))); + + typePane = this.createTypePane(); + this.add(typePane, BorderLayout.NORTH); + stylePane = this.createStylePane(); + this.add(stylePane, BorderLayout.CENTER); + } + + private JPanel createTypePane() { + JPanel typePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + popupTypeLabel = new UILabel(""); + typePane.add(popupTypeLabel, BorderLayout.CENTER); + return MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Type"), typePane); + } + + private JPanel createStylePane() { + JPanel stylePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + stylePane.add(this.createBorderSettingPane(), BorderLayout.NORTH); + stylePane.add(this.createBackgroundSettingPane(), BorderLayout.CENTER); + stylePane.add(this.createPopupSizePane(), BorderLayout.SOUTH); + return stylePane; + } + + private JPanel createBorderSettingPane() { + JPanel borderPane = new JPanel(); + VerticalFlowLayout layout = new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 10); + layout.setAlignLeft(true); + borderPane.setLayout(layout); + + borderType = new LineComboBox(MobilePopupConstants.BORDER_LINE_STYLE_ARRAY); + borderType.setPreferredSize(new Dimension(115, 20)); + borderPane.add(MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Line"), borderType)); + borderColor = new NewColorSelectBox(100); + borderPane.add(MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Colors"), borderColor)); + borderRadiusSpinner = new UISpinner(0, maxBorderRadius, 1, 20); + borderRadiusSpinner.setPreferredSize(new Dimension(120, 20)); + borderPane.add(MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Radius"), borderRadiusSpinner)); + return MobilePopupUIUtils.createTitleSplitLineContentPane(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Border"), borderPane); + } + + private JPanel createBackgroundSettingPane() { + JPanel bgPane = new JPanel(); + VerticalFlowLayout layout = new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 10); + layout.setAlignLeft(true); + bgPane.setLayout(layout); + + JPanel colorPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0,0)); + bgColor = new NewColorSelectBox(100); + colorPane.add(MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Colors"), bgColor)); + bgPane.add(colorPane); + + JPanel transparencyPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.numberDragPane = new UINumberDragPane(0,100); + this.numberDragPane.setPreferredSize(new Dimension(140, 20)); + transparencyPane.add(numberDragPane, BorderLayout.CENTER); + transparencyPane.add(new UILabel(" %"), BorderLayout.EAST); + bgPane.add(MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Opacity"), transparencyPane)); + return MobilePopupUIUtils.createTitleSplitLineContentPane(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Background"), bgPane); + } + + private JPanel createPopupSizePane() { + JPanel sizePane = new JPanel(new BorderLayout()); + + mobileRegularPane = new MobilePopupRegularPane(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Mobile_Rules")); + padRegularPane = new MobilePopupRegularPane(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Pad_Rules")); + + sizePane.add(mobileRegularPane, BorderLayout.NORTH); + sizePane.add(padRegularPane, BorderLayout.CENTER); + + return MobilePopupUIUtils.createTitleSplitLineContentPane(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Size"), sizePane); + } + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } + + public void resetPane(String popupTargetType) { + if (StringUtils.equals(popupTargetType, MobilePopupConstants.Target_Template)) { + popupTypeLabel.setText(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Center")); + mobileRegularPane.resetPane(MobilePopupConstants.Regular_Custom, MobilePopupConstants.Popup_Center_Default_Width, MobilePopupConstants.Popup_Center_Default_Height); + padRegularPane.resetPane(MobilePopupConstants.Regular_Custom, MobilePopupConstants.Popup_Center_Default_Width, MobilePopupConstants.Popup_Center_Default_Height); + } else { + popupTypeLabel.setText(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Follow")); + mobileRegularPane.resetPane(MobilePopupConstants.Regular_Custom, MobilePopupConstants.Popup_Follow_Default_Width, MobilePopupConstants.Popup_Follow_Default_Height); + padRegularPane.resetPane(MobilePopupConstants.Regular_Custom, MobilePopupConstants.Popup_Follow_Default_Width, MobilePopupConstants.Popup_Follow_Default_Height); + } + + } + + @Override + public void populateBean(MobilePopupHyperlink link) { + this.populateTypeBean(link); + this.populateBorderSettingBean(link); + this.populateBackgroundSettingBean(link); + this.populatePopupSizeBean(link); + } + + @Override + public MobilePopupHyperlink updateBean() { + return null; + } + + @Override + public void updateBean(MobilePopupHyperlink link) { + this.updateBorderSettingBean(link); + this.updateBackgroundSettingBean(link); + this.updatePopupSizeBean(link); + + } + + private void populateTypeBean(MobilePopupHyperlink link) { + if (StringUtils.equals(link.getPopupTarget(), MobilePopupConstants.Target_Text)) { + popupTypeLabel.setText(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Follow")); + } else { + popupTypeLabel.setText(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Center")); + } + } + + private void populateBorderSettingBean(MobilePopupHyperlink link) { + borderType.setSelectedLineStyle(link.getBorderType()); + borderColor.setSelectObject(link.getBorderColor()); + borderRadiusSpinner.setValue(link.getBorderRadius()); + + } + + private void updateBorderSettingBean(MobilePopupHyperlink link) { + link.setBorderType(borderType.getSelectedLineStyle()); + link.setBorderColor(borderColor.getSelectObject()); + link.setBorderRadius(borderRadiusSpinner.getValue()); + + } + + private void populateBackgroundSettingBean(MobilePopupHyperlink link) { + bgColor.setSelectObject(link.getBgColor()); + numberDragPane.populateBean(link.getBgOpacity() * maxNumber); + } + + private void updateBackgroundSettingBean(MobilePopupHyperlink link) { + link.setBgColor(bgColor.getSelectObject()); + link.setBgOpacity((float)(numberDragPane.updateBean() / maxNumber)); + } + + private void populatePopupSizeBean(MobilePopupHyperlink link) { + mobileRegularPane.setRegularType(link.getMobileRegularType()); + mobileRegularPane.setWidthSpinnerValue(link.getMobileWidth()); + mobileRegularPane.setHeightSpinnerValue(link.getMobileHeight()); + padRegularPane.setRegularType(link.getPadRegularType()); + padRegularPane.setWidthSpinnerValue(link.getPadWidth()); + padRegularPane.setHeightSpinnerValue(link.getPadHeight()); + + } + + private void updatePopupSizeBean(MobilePopupHyperlink link) { + link.setMobileRegularType(mobileRegularPane.getRegularType()); + link.setMobileWidth(mobileRegularPane.getWidthSpinnerValue()); + link.setMobileHeight(mobileRegularPane.getHeightSpinnerValue()); + link.setPadRegularType(padRegularPane.getRegularType()); + link.setPadWidth(padRegularPane.getWidthSpinnerValue()); + link.setPadHeight(padRegularPane.getHeightSpinnerValue()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/hyperlink/popup/WheelScrollLayerUI.java b/designer-base/src/main/java/com/fr/design/hyperlink/popup/WheelScrollLayerUI.java new file mode 100644 index 0000000000..8ab06766db --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/hyperlink/popup/WheelScrollLayerUI.java @@ -0,0 +1,42 @@ +package com.fr.design.hyperlink.popup; + +import com.fr.design.gui.icontainer.UIScrollPane; + +import javax.swing.*; +import javax.swing.plaf.LayerUI; +import java.awt.*; +import java.awt.event.MouseWheelEvent; + +class WheelScrollLayerUI extends LayerUI { + @Override + public void installUI(JComponent c) { + super.installUI(c); + if (c instanceof JLayer) { + ((JLayer) c).setLayerEventMask(AWTEvent.MOUSE_WHEEL_EVENT_MASK); + } + } + @Override + public void uninstallUI(JComponent c) { + if (c instanceof JLayer) { + ((JLayer) c).setLayerEventMask(0); + } + super.uninstallUI(c); + } + @Override + protected void processMouseWheelEvent(MouseWheelEvent e, JLayer l) { + Component c = e.getComponent(); + int dir = e.getWheelRotation(); + JScrollPane main = l.getView(); + if (c instanceof JScrollPane && !c.equals(main)) { + JScrollPane child = (JScrollPane) c; + BoundedRangeModel m = child.getVerticalScrollBar().getModel(); + int extent = m.getExtent(); + int minimum = m.getMinimum(); + int maximum = m.getMaximum(); + int value = m.getValue(); + if (value + extent >= maximum && dir > 0 || value <= minimum && dir < 0) { + main.dispatchEvent(SwingUtilities.convertMouseEvent(c, e, main)); + } + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java b/designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java index dbccb7c50c..e5100b54b3 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java @@ -1,16 +1,17 @@ package com.fr.design.javascript; -import com.fr.design.write.submit.DBManipulationPane; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.gui.frpane.CommitTabbedPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.layout.FRGUIPaneFactory; - +import com.fr.design.write.submit.DBManipulationPane; import com.fr.js.Commit2DBJavaScript; import com.fr.write.DBManipulation; -import javax.swing.*; -import java.awt.*; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Dimension; import java.util.ArrayList; import java.util.List; @@ -25,63 +26,64 @@ public class Commit2DBJavaScriptPane extends FurtherBasicBeanPane 1){ + /** + * 界面重置 + */ + public void reset() { + this.javaScriptActionPane.setCall(null); + //重置后只保留,只留第一个tab + while (dbmPaneList.size() > 1) { dbmPaneList.remove(1); } - ((DBManipulationPane)dbmPaneList.get(0)).populateBean(null); - } + ((DBManipulationPane) dbmPaneList.get(0)).populateBean(null); + } - @Override + @Override /** * 将JavaBean内的数据输出至界面上 */ @@ -131,11 +134,15 @@ public class Commit2DBJavaScriptPane extends FurtherBasicBeanPane { + + private ExportRadioGroup templateRadioGroup; + private UIRadioButton currentTemplateRadio; + private UIRadioButton otherTemplateRadio; + private UITextField reportPathTextField; + private UIButton browserButton; + private UIComboBox exportTypeComboBox; + private ExportRadioGroup fileNameRadioGroup; + private UIRadioButton defaultNameRadio; + private UIRadioButton customNameRadio; + private FormulaEditor fileNameFormulaEditor; + private UICheckBox extendParametersCheckBox; + private ReportletParameterViewPane parameterViewPane; + + private static final double p = TableLayout.PREFERRED; + private static final Map EXPORT_TYPES_MAP = new HashMap<>(); + private static final String CURRENT_TEMPLATE = "current"; + private static final String DEFAULT_FILENAME = "default"; + + + static { + EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_PDF, Toolkit.i18nText("Fine-Design_Basic_Export_JS_PDF")); + EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_PAGE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Page")); + EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_SIMPLE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Simple")); + EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_SHEET, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Sheet")); + EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_WORD, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Word")); + EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_IMAGE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Image")); + } + + public ExportJavaScriptPane() { + initComponents(); + } + + private void initComponents() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Toolkit.i18nText("Fine-Design_Basic_Export_JS_Setting"))); + + //导出模板+导出方式+导出文件名 + JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + + //导出模板 + JPanel chooseTemplatePane = initChooseTemplatePane(); + northPane.add(chooseTemplatePane, BorderLayout.NORTH); + + //导出方式 + JPanel exportTypePane = initExportTypePane(); + northPane.add(exportTypePane, BorderLayout.CENTER); + + //导出文件名 + JPanel fileNamePane = initFileNamePane(); + northPane.add(fileNamePane, BorderLayout.SOUTH); + + //参数 + JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel paramsPane = initParamsPane(); + centerPane.add(paramsPane); + + this.add(northPane, BorderLayout.NORTH); + this.add(centerPane, BorderLayout.CENTER); + } + + private JPanel initParamsPane() { + extendParametersCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Extends_Report_Parameters")); + extendParametersCheckBox.setSelected(true); + parameterViewPane = new ReportletParameterViewPane(getChartParaType(), getValueEditorPane(), getValueEditorPane()); + parameterViewPane.setVisible(false); + parameterViewPane.addTableEditorListener(new TableModelListener() { + public void tableChanged(TableModelEvent e) { + List list = parameterViewPane.update(); + HashSet tempSet = new HashSet<>(); + for (int i = 0; i < list.size(); i++) { + if (StringUtils.isEmpty(list.get(i).getName())) { + continue; + } + if (tempSet.contains(list.get(i).toString())) { + list.remove(i); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Duplicate_Name") + "!"); + return; + } + tempSet.add(list.get(i).toString()); + } + } + }); + extendParametersCheckBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + parameterViewPane.setVisible(e.getStateChange() == ItemEvent.DESELECTED); + } + }); + JPanel paramsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + paramsPane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Toolkit.i18nText("Fine-Design_Basic_Parameters"))); + paramsPane.add(extendParametersCheckBox, BorderLayout.NORTH); + JPanel dynamicPaneWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); + dynamicPaneWrapper.add(parameterViewPane); + paramsPane.add(dynamicPaneWrapper, BorderLayout.CENTER); + return paramsPane; + } + + private JPanel initFileNamePane() { + UILabel nameLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename") + ":"); + fileNameRadioGroup = new ExportRadioGroup(); + defaultNameRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Default")); + defaultNameRadio.setSelected(true); + customNameRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Custom")); + addRadioToGroup(fileNameRadioGroup, defaultNameRadio, customNameRadio); + fileNameFormulaEditor = new FormulaEditor(Toolkit.i18nText("Fine-Design_Report_Parameter_Formula")); + fileNameFormulaEditor.setEnabled(false); + fileNameRadioGroup.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (defaultNameRadio.isSelected()) { + fileNameFormulaEditor.setEnabled(false); + } else { + fileNameFormulaEditor.setEnabled(true); + } + } + }); + Component[][] components = new Component[][]{{nameLabel, defaultNameRadio, customNameRadio, fileNameFormulaEditor}}; + JPanel fileNameRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p, p}); + + JPanel fileNameTipPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + UILabel fileNameTipLabel = new UILabel("" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Front") + "\\/:*?\"<>|" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Back") + ""); + fileNameTipPane.add(fileNameTipLabel); + + JPanel fileNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + fileNamePane.add(fileNameRadioPane, BorderLayout.NORTH); + fileNamePane.add(fileNameTipPane, BorderLayout.CENTER); + fileNameTipPane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2)); + fileNamePane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2)); + return fileNamePane; + } + + private JPanel initExportTypePane() { + UILabel typeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Type") + ":"); + exportTypeComboBox = new UIComboBox(new DefaultComboBoxModel()); + DefaultComboBoxModel comboBoxModel = (DefaultComboBoxModel) exportTypeComboBox.getModel(); + String[] allExportTypes = new String[]{ExportJavaScript.EXPORT_PDF, ExportJavaScript.EXPORT_EXCEL_PAGE, ExportJavaScript.EXPORT_EXCEL_SIMPLE, ExportJavaScript.EXPORT_EXCEL_SHEET, ExportJavaScript.EXPORT_WORD, ExportJavaScript.EXPORT_IMAGE}; + for (int i = 0; i < allExportTypes.length; i++) { + comboBoxModel.addElement(allExportTypes[i]); + } + this.exportTypeComboBox.setRenderer(new UIComboBoxRenderer() { + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof String) { + this.setText(EXPORT_TYPES_MAP.get(value)); + } + return this; + } + }); + Component[][] components = new Component[][]{{typeLabel, exportTypeComboBox}}; + + JPanel exportTypePane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p}); + exportTypePane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2)); + return exportTypePane; + } + + private JPanel initChooseTemplatePane() { + UILabel templateLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template") + ":"); + templateRadioGroup = new ExportRadioGroup(); + currentTemplateRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current")); + currentTemplateRadio.setSelected(true); + otherTemplateRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Other")); + addRadioToGroup(templateRadioGroup, currentTemplateRadio, otherTemplateRadio); + templateRadioGroup.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (currentTemplateRadio.isSelected()) { + browserButton.setEnabled(false); + } else { + browserButton.setEnabled(true); + } + } + }); + Component[][] components = new Component[][]{{templateLabel, currentTemplateRadio, otherTemplateRadio}}; + JPanel reportletRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p}); + + JPanel reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + // 路径输入框 + reportPathTextField = new UITextField(20); + reportPathTextField.setEnabled(false); + reportletNamePane.add(reportPathTextField, BorderLayout.CENTER); + + // 选择路径按钮 + browserButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Select")); + browserButton.setPreferredSize(new Dimension(browserButton.getPreferredSize().width, 20)); + browserButton.setEnabled(false); + reportletNamePane.add(browserButton, BorderLayout.EAST); + browserButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent evt) { + final ReportletPane reportletPane = new ReportletPane(); + reportletPane.setSelectedReportletPath(reportPathTextField.getText()); + BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(ExportJavaScriptPane.this)); + + reportletDialog.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + reportPathTextField.setText(reportletPane.getSelectedReportletPath()); + } + }); + reportletDialog.setVisible(true); + } + }); + + JPanel chooseTemplatePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + chooseTemplatePane.add(reportletRadioPane, BorderLayout.NORTH); + chooseTemplatePane.add(reportletNamePane, BorderLayout.CENTER); + chooseTemplatePane.setBorder(BorderFactory.createEmptyBorder(0,2,5,2)); + + return chooseTemplatePane; + } + + @Override + public void populateBean(ExportJavaScript ob) { + if (ob == null) { + ob = new ExportJavaScript(); + } + this.templateRadioGroup.selectIndexButton(ob.isCurrentTemplate() ? 0 : 1); + if (ob.isCurrentTemplate()) { + this.browserButton.setEnabled(false); + } else { + this.browserButton.setEnabled(true); + this.reportPathTextField.setText(ob.getTemplatePath()); + } + this.exportTypeComboBox.setSelectedItem(ob.getExportType()); + this.fileNameRadioGroup.selectIndexButton(ob.isDefaultFileName() ? 0 : 1); + if (ob.isDefaultFileName()) { + this.fileNameFormulaEditor.setEnabled(false); + } else { + this.fileNameFormulaEditor.setEnabled(true); + this.fileNameFormulaEditor.setValue(BaseFormula.createFormulaBuilder().build(ob.getFileName())); + } + if (ob.isExtendParameters()) { + this.extendParametersCheckBox.setSelected(true); + } else { + this.extendParametersCheckBox.setSelected(false); + List parameterList = this.parameterViewPane.update(); + parameterList.clear(); + ParameterProvider[] parameters = ob.getParameters(); + this.parameterViewPane.populate(parameters); + } + } + + @Override + public ExportJavaScript updateBean() { + ExportJavaScript exportJavaScript = new ExportJavaScript(); + updateBean(exportJavaScript); + return exportJavaScript; + } + + @Override + public void updateBean(ExportJavaScript exportJavaScript) { + exportJavaScript.setCurrentTemplate(this.currentTemplateRadio.isSelected()); + exportJavaScript.setTemplatePath(getTemplatePath()); + exportJavaScript.setExportType(GeneralUtils.objectToString(this.exportTypeComboBox.getSelectedItem())); + exportJavaScript.setDefaultFileName(this.defaultNameRadio.isSelected()); + exportJavaScript.setFileName(getFileName()); + exportJavaScript.setExtendParameters(this.extendParametersCheckBox.isSelected()); + if (extendParametersCheckBox.isSelected()) { + exportJavaScript.setParameters(null); + } else { + List parameterList = this.parameterViewPane.update(); + if (!parameterList.isEmpty()) { + Parameter[] parameters = new Parameter[parameterList.size()]; + parameterList.toArray(parameters); + exportJavaScript.setParameters(parameters); + } + } + } + + private String getTemplatePath() { + return currentTemplateRadio.isSelected() ? CURRENT_TEMPLATE : reportPathTextField.getText(); + } + + private String getFileName() { + return defaultNameRadio.isSelected() ? DEFAULT_FILENAME : fileNameFormulaEditor.getUITextField().getText(); + } + + + @Override + public boolean accept(Object ob) { + return ob instanceof ExportJavaScript; + } + + @Override + public void reset() { + populateBean(null); + } + + @Override + public java.lang.String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Event"); + } + + private void addRadioToGroup(ButtonGroup buttonGroup, UIRadioButton... radios) { + for (UIRadioButton radio : radios) { + buttonGroup.add(radio); + } + } + + class ExportRadioGroup extends ButtonGroup { + private List radioButtons = new ArrayList<>(); + + @Override + public void add(AbstractButton button) { + super.add(button); + + UIRadioButton radioButton = (UIRadioButton) button; + radioButtons.add(radioButton); + } + + public void selectIndexButton(int index) { + if (index < 0 || index > radioButtons.size() - 1) { + return; + } + + UIRadioButton button = radioButtons.get(index); + button.setSelected(true); + } + + public void addActionListener(ActionListener actionListener) { + for (UIRadioButton radioButton : radioButtons) { + radioButton.addActionListener(actionListener); + } + } + } + + class ReportletPane extends BasicPane { + private TemplateFileTree templateReportletTree; + private JScrollPane t_panel; + + private JPanel cardPane; + + public ReportletPane() { + this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); + + JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.add(centerPane, BorderLayout.CENTER); + + cardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); + centerPane.add(cardPane, BorderLayout.CENTER); + cardPane.setLayout(new CardLayout()); + templateReportletTree = new TemplateFileTree(); + IOFileNodeFilter filter = new IOFileNodeFilter(new String[]{".cpt"}); + templateReportletTree.setFileNodeFilter(filter); + cardPane.add(t_panel = new JScrollPane(templateReportletTree), "TEMPLATE"); + + this.refreshEnv(); + } + + /** + * 检查是否符合规范 + * + * @throws Exception 抛错 + */ + @Override + public void checkValid() throws Exception { + String path = this.getSelectedReportletPath(); + if (path == null) { + throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Function_The_Selected_File_Cannot_Be_Null")); + } + } + + /** + * 刷新Env + */ + public void refreshEnv() { + this.templateReportletTree.refreshEnv(); + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Event"); + } + + /* + * 返回选中的Reportlet的路径 + */ + public String getSelectedReportletPath() { + if (t_panel.isVisible()) { + return templateReportletTree.getSelectedTemplatePath(); + } + return null; + } + + /* + * 选中某Reportlet + */ + public void setSelectedReportletPath(String reportletPath) { + if (reportletPath == null) { + return; + } + templateReportletTree.setSelectedTemplatePath(reportletPath); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java b/designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java index f54b070b0a..999a1a0295 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java @@ -7,11 +7,13 @@ import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.fun.JavaScriptActionProvider; import com.fr.design.gui.frpane.UIComboBoxPane; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.hyperlink.popup.MobilePopupPane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.write.submit.DBManipulationPane; import com.fr.form.ui.WebContentUtils; import com.fr.js.JavaScript; +import com.fr.write.JavaScriptResourceInfo; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -29,6 +31,8 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane { private List contentDBManiPane; + private JavaScriptResourceInfo resourceInfo; + private JavaScript call = null; public JavaScriptActionPane() { @@ -44,6 +48,11 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane { contentDBManiPane.add(createDBManipulationPane()); paneList.add(new Commit2DBJavaScriptPane(this, contentDBManiPane)); paneList.add(initEmaiPane()); + boolean workbook = DesignerContext.getDesignerFrame().getSelectedJTemplate().isJWorkBook(); + if (workbook) { + paneList.add(new ExportJavaScriptPane()); + } + paneList.add(new MobilePopupPane()); Set javaScriptActionProviders = ExtraDesignClassManager.getInstance().getArray(JavaScriptActionProvider.XML_TAG); if (javaScriptActionProviders != null) { for (JavaScriptActionProvider jsp : javaScriptActionProviders) { @@ -71,6 +80,14 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane { } + public JavaScriptResourceInfo getResourceInfo() { + return resourceInfo; + } + + public void setResourceInfo(JavaScriptResourceInfo resourceInfo) { + this.resourceInfo = resourceInfo; + } + /** * 生成回调函数的按钮 * @@ -178,8 +195,8 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane { * @return 返回生成的面板 */ - public static JavaScriptActionPane createDefault() { - return new JavaScriptActionPane() { + public static JavaScriptActionPane createDefault() { + return new JavaScriptActionPane() { @Override public DBManipulationPane createDBManipulationPane() { return new DBManipulationPane(); diff --git a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java index da0a2131c6..0077f9b871 100644 --- a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java @@ -2,8 +2,8 @@ package com.fr.design.layout; import com.fr.design.border.UITitledBorder; import com.fr.design.gui.ilable.UILabel; - import com.fr.stable.AssistUtils; + import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.Icon; @@ -46,6 +46,16 @@ public class FRGUIPaneFactory { return new FlowLayout(FlowLayout.LEFT, 0, 0); } + /** + * 创建一个靠左的布局,上下间隔为0,左右间隔为常量,首间隔为0 + * + * @return FlowLayout对象 + */ + public static LayoutManager createLeftZeroVgapNormalHgapLayout() { + return new FRLeftFlowLayout(0, 5, 0); + } + + /** * 创建一个靠右的布局 * @@ -581,6 +591,15 @@ public class FRGUIPaneFactory { return jp; } + public static JPanel createBorderLayout_NO_Opaque_Pane() { + JPanel jp = new JPanel(); + jp.setOpaque(false); + jp.setBackground(null); + jp.setLayout(FRGUIPaneFactory.createBorderLayout()); + return jp; + } + + /** * 创建卡片式布局 * diff --git a/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java new file mode 100644 index 0000000000..36507cf37d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java @@ -0,0 +1,278 @@ +package com.fr.design.mainframe; + +import com.fr.design.DesignState; +import com.fr.design.base.mode.DesignModeContext; +import com.fr.design.constants.UIConstants; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.file.MutilTempalteTabPane; +import com.fr.design.file.NewTemplatePane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.imenu.UIMenuHighLight; +import com.fr.design.gui.itoolbar.UILargeToolbar; +import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.toolbar.ToolBarMenuDock; +import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; +import org.jetbrains.annotations.Nullable; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.border.MatteBorder; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Insets; +import java.util.ArrayList; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/4/6 + */ +public class CenterRegionContainerPane extends JPanel { + + private static volatile CenterRegionContainerPane THIS; + + private static final int LEFT_ALIGN_GAP = -5; + + private DesktopCardPane centerTemplateCardPane; + + private JPanel toolbarPane;//撤销重做 等工具栏 + 模板tab标签 + maybe have cpt 字体 + + private JComponent toolbarComponent;//cpt 字体 等工具栏 + + private JPanel eastPane;//=largeToolbar+eastCenterPane + private UILargeToolbar largeToolbar;//预览 + + private JPanel eastCenterPane;//=combineUp + templateTabPane + + private UIToolbar combineUp;//撤销重做 等工具栏 + + private JPanel templateTabPane;//新建模板 + 模板tab标签 + private NewTemplatePane newWorkBookPane;//新建模板button + + + public static CenterRegionContainerPane getInstance() { + if (THIS == null) { + synchronized (CenterRegionContainerPane.class) { + if (THIS == null) { + THIS = new CenterRegionContainerPane(); + } + } + } + return THIS; + } + + public CenterRegionContainerPane() { + + toolbarPane = new JPanel() { + + @Override + public Dimension getPreferredSize() { + + Dimension dim = super.getPreferredSize(); + // dim.height = TOOLBAR_HEIGHT; + return dim; + } + }; + toolbarPane.setLayout(FRGUIPaneFactory.createBorderLayout()); + eastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + eastPane.add(largeToolbar = getToolBarMenuDock().createLargeToolbar(), BorderLayout.WEST); + eastCenterPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + combineUpTooBar(); + eastCenterPane.add(combineUp, BorderLayout.NORTH); + templateTabPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + templateTabPane.add(newWorkBookPane = getToolBarMenuDock().getNewTemplatePane(), BorderLayout.WEST); + templateTabPane.add(MutilTempalteTabPane.getInstance(), BorderLayout.CENTER); + eastCenterPane.add(templateTabPane, BorderLayout.CENTER); + + eastPane.add(eastCenterPane, BorderLayout.CENTER); + toolbarPane.add(eastPane, BorderLayout.NORTH); + toolbarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH); + + this.setLayout(new BorderLayout()); + this.add(centerTemplateCardPane = new DesktopCardPane(), BorderLayout.CENTER); + this.add(toolbarPane, BorderLayout.NORTH); + + } + + private ToolBarMenuDock getToolBarMenuDock() { + return DesignerContext.getDesignerFrame().getToolBarMenuDock(); + } + + /** + * 创建上工具栏 + */ + private void combineUpTooBar() { + combineUp = new UIToolbar(FlowLayout.LEFT); + combineUp.setBorder(new MatteBorder(new Insets(0, LEFT_ALIGN_GAP, 1, 0), UIConstants.LINE_COLOR)); + combineUp.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 2)); + setUpUpToolBar(null); + + } + + + /** + * 重置上工具栏 + */ + private void resetCombineUpTooBar(JComponent[] toolbar4Form, ToolBarMenuDockPlus plus) { + combineUp.removeAll(); + setUpUpToolBar(toolbar4Form); + plus.insertToCombineUpToolbar(combineUp); + } + + + /** + * 填充上工具栏的中的工具 + * + * @param toolbar4Form 目标组件 + */ + private void setUpUpToolBar(@Nullable JComponent[] toolbar4Form) { + UIButton[] fixButtons = getToolBarMenuDock().createUp(); + for (UIButton fixButton : fixButtons) { + combineUp.add(fixButton); + } + if (!DesignModeContext.isAuthorityEditing()) { + combineUp.addSeparator(new Dimension(2, 16)); + if (toolbar4Form != null) { + for (JComponent jComponent : toolbar4Form) { + combineUp.add(jComponent); + } + } + //添加检测按钮 + addCheckButton(); + } + //添加分享按钮 + addShareButton(); + //添加插件中的按钮 + addExtraButtons(); + } + + + private void addExtraButtons() { + + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jt == null) { + return; + } + + + UIButton[] extraButtons = jt.createExtraButtons(); + for (UIButton extraButton : extraButtons) { + combineUp.add(extraButton); + } + if (extraButtons.length > 0) { + combineUp.addSeparator(new Dimension(2, 16)); + } + } + + private void addCheckButton() { + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jt == null) { + return; + } + combineUp.addSeparator(new Dimension(2, 16)); + UIButton[] checkButtons = jt.createCheckButton(); + for (UIButton checkButton : checkButtons) { + combineUp.add(checkButton); + } + } + + private void addShareButton() { + + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jt == null) { + return; + } + + combineUp.addSeparator(new Dimension(2, 16)); + UIButton[] shareButtons = jt.createShareButton(); + for (UIButton shareButton : shareButtons) { + combineUp.add(shareButton); + } + } + + /** + * 检查 + * + * @param flag 组件是否可见 + * @param al 组件名称 + */ + protected void checkCombineUp(boolean flag, ArrayList al) { + //Yvan: 检查当前是否为WORK_SHEET状态,因为只有WORK_SHEET中含有格式刷组件,此时是不需要进行checkComponentsByNames的 + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jTemplate != null) { + // 第一个条件满足后还需要添加一重判断,判断是编辑报表块还是参数面板,编辑报表块时则直接return + if (jTemplate.getMenuState() == DesignState.WORK_SHEET && !jTemplate.isUpMode()) { + return; + } + combineUp.checkComponentsByNames(flag, al); + } + } + + + /** + * 重置相关的工具条. + * + * @param plus 工具条中相关信息 + */ + protected void resetToolkitByPlus(ToolBarMenuDockPlus plus, ToolBarMenuDock ad) { + + resetCombineUpTooBar(ad.resetUpToolBar(plus), plus); + + if (toolbarComponent != null) { + toolbarPane.remove(toolbarComponent); + } + + // 颜色,字体那些按钮的工具栏 + toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER); + + if (plus.hasToolBarPane()) { + this.add(toolbarPane, BorderLayout.NORTH); + } else { + this.remove(toolbarPane); + } + + resetByDesignMode(); + } + + private void resetByDesignMode() { + if (DesignModeContext.isDuchampMode()) { + eastPane.remove(largeToolbar); + eastCenterPane.remove(templateTabPane); + centerTemplateCardPane.refresh(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); + } else { + eastPane.add(largeToolbar, BorderLayout.WEST); + eastCenterPane.add(templateTabPane, BorderLayout.CENTER); + } + + } + + JComponent getToolbarComponent() { + + return this.toolbarComponent; + } + + /** + * 判断是否在权限编辑状态,若是在权限编辑状态,则需要有虚线框和关闭突变 + */ + protected void needToAddAuhtorityPaint() { + newWorkBookPane.setButtonGray(DesignModeContext.isAuthorityEditing()); + + } + + + protected DesktopCardPane getCenterTemplateCardPane() { + + return centerTemplateCardPane; + } + + protected void refreshUIToolBar() { + if (toolbarComponent instanceof UIToolbar) { + ((UIToolbar ) toolbarComponent).refreshUIToolBar(); + } + combineUp.refreshUIToolBar(); + getToolBarMenuDock().updateEnable(); + } + +} 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 b7bc518385..786deb8927 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 @@ -4,9 +4,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; -import com.fr.base.chart.exception.ChartNotFoundException; import com.fr.design.DesignModelAdapter; -import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.core.ActionFactory; @@ -22,24 +20,16 @@ import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; -import com.fr.design.file.NewTemplatePane; import com.fr.design.file.SaveSomeTemplatePane; import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.OemProcessor; -import com.fr.design.fun.TitlePlaceProcessor; import com.fr.design.fun.impl.AbstractTemplateTreeShortCutProvider; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.imenu.UIMenuHighLight; import com.fr.design.gui.iprogressbar.ProgressDialog; import com.fr.design.gui.iscrollbar.UIScrollBar; -import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.loghandler.LogMessageBar; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.vcs.common.VcsHelper; -import com.fr.design.menu.MenuManager; import com.fr.design.menu.ShortCut; import com.fr.design.os.impl.MacOsAddListenerAction; import com.fr.design.os.impl.SupportOSImpl; @@ -51,49 +41,32 @@ import com.fr.file.FILE; import com.fr.file.FILEFactory; import com.fr.file.FileFILE; import com.fr.general.ComparatorUtils; -import com.fr.general.GeneralContext; import com.fr.general.GeneralUtils; import com.fr.general.IOUtils; import com.fr.invoke.Reflect; import com.fr.log.FineLoggerFactory; -import com.fr.plugin.context.PluginContext; -import com.fr.plugin.injectable.PluginModule; -import com.fr.plugin.manage.PluginFilter; -import com.fr.plugin.observer.PluginEvent; -import com.fr.plugin.observer.PluginEventListener; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.image4j.codec.ico.ICODecoder; import com.fr.stable.os.OperatingSystem; -import com.fr.stable.os.support.OSBasedAction; import com.fr.stable.os.support.OSSupportCenter; import com.fr.stable.project.ProjectConstants; import com.fr.start.OemHandler; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.connect.WorkspaceConnectionInfo; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CopyOnWriteArrayList; -import org.jetbrains.annotations.Nullable; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLayeredPane; -import javax.swing.JMenuBar; import javax.swing.JOptionPane; import javax.swing.JPanel; -import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.WindowConstants; -import javax.swing.border.MatteBorder; import java.awt.BorderLayout; -import java.awt.Component; import java.awt.Dimension; -import java.awt.FlowLayout; import java.awt.Graphics; -import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; import java.awt.datatransfer.DataFlavor; @@ -116,9 +89,12 @@ import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; +import java.util.concurrent.CopyOnWriteArrayList; public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener { @@ -128,8 +104,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private static final long serialVersionUID = -8732559571067484460L; - private static final int LEFT_ALIGN_GAP = -5; - private static final int MENU_HEIGHT = 26; private static final Integer SECOND_LAYER = 100; @@ -140,22 +114,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private ToolBarMenuDock ad; - private DesktopCardPane centerTemplateCardPane; - - private JPanel toolbarPane; - - private JComponent toolbarComponent; - - private JPanel menuPane; - - private JMenuBar menuBar; - - private JPanel eastCenterPane; - - private UIToolbar combineUp; - - private NewTemplatePane newWorkBookPane; - private Icon closeMode; private JLayeredPane layeredPane = this.getLayeredPane(); @@ -177,6 +135,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta //用于判断设计器是否打开了 private boolean designerOpened = false; + private boolean serverConfig = false; + private int contentWidth = (int) (java.awt.Toolkit.getDefaultToolkit().getScreenSize().getWidth()); private int contentHeight = (int) (java.awt.Toolkit.getDefaultToolkit().getScreenSize().getHeight()); @@ -285,37 +245,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta // the content pane basePane.setLayout(new BorderLayout()); - toolbarPane = new JPanel() { - - @Override - public Dimension getPreferredSize() { - Dimension dim = super.getPreferredSize(); - // dim.height = TOOLBAR_HEIGHT; - return dim; - } - }; - toolbarPane.setLayout(FRGUIPaneFactory.createBorderLayout()); - JPanel eastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - eastPane.add(ad.createLargeToolbar(), BorderLayout.WEST); - eastCenterPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - combineUpTooBar(); - eastCenterPane.add(combineUp, BorderLayout.NORTH); - JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - panel.add(newWorkBookPane = ad.getNewTemplatePane(), BorderLayout.WEST); - panel.add(MutilTempalteTabPane.getInstance(), BorderLayout.CENTER); - eastCenterPane.add(panel, BorderLayout.CENTER); - - eastPane.add(eastCenterPane, BorderLayout.CENTER); - toolbarPane.add(eastPane, BorderLayout.NORTH); - toolbarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH); - - JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - centerPane.add(centerTemplateCardPane = new DesktopCardPane(), BorderLayout.CENTER); - centerPane.add(toolbarPane, BorderLayout.NORTH); - - - basePane.add(centerPane, BorderLayout.CENTER); + basePane.add(CenterRegionContainerPane.getInstance(), BorderLayout.CENTER); laoyoutWestPane(); basePane.add(EastRegionContainerPane.getInstance(), BorderLayout.EAST); basePane.setBounds(0, 0, contentWidth, contentHeight); @@ -346,6 +277,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta //刷新FixedPopupPane的位置 EastRegionContainerPane.getInstance().freshCurrentPopupPane(); } + + @Override + public void componentMoved(ComponentEvent e) { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + template.refreshFormDesigner(); + } + } }); this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); this.setVisible(false); @@ -423,7 +362,11 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta public DesktopCardPane getCenterTemplateCardPane() { - return centerTemplateCardPane; + return CenterRegionContainerPane.getInstance().getCenterTemplateCardPane(); + } + + public void refreshUIToolBar() { + CenterRegionContainerPane.getInstance().refreshUIToolBar(); } /** @@ -431,80 +374,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ protected void initMenuPane() { - menuPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - menuPane.add(new UIMenuHighLight(), BorderLayout.SOUTH); - menuPane.add(initNorthEastPane(ad), BorderLayout.EAST); - basePane.add(menuPane, BorderLayout.NORTH); + basePane.add(NorthRegionContainerPane.getInstance(), BorderLayout.NORTH); this.resetToolkitByPlus(null); } - /** - * @param ad 菜单栏 - * @return panel - */ protected JPanel initNorthEastPane(final ToolBarMenuDock ad) { - //hugh: private修改为protected方便oem的时候修改右上的组件构成 - //顶部日志+登陆按钮 - final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - //优先级为-1,保证最后全面刷新一次 - GeneralContext.listenPluginRunningChanged(new PluginEventListener(-1) { - - @Override - public void on(PluginEvent event) { - - refreshNorthEastPane(northEastPane, ad); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - if (DesignerContext.getDesignerFrame() == null) { - return; - } - DesignerContext.getDesignerFrame().refresh(); - DesignerContext.getDesignerFrame().repaint(); - } - }); - } - }, new PluginFilter() { - - @Override - public boolean accept(PluginContext context) { - - return context.contain(PluginModule.ExtraDesign); - } - }); - refreshNorthEastPane(northEastPane, ad); - return northEastPane; - } - - private void refreshNorthEastPane(final JPanel northEastPane, final ToolBarMenuDock ad) { - - northEastPane.removeAll(); - northEastPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); - northEastPane.add(LogMessageBar.getInstance()); - TitlePlaceProcessor processor = ExtraDesignClassManager.getInstance().getSingle(TitlePlaceProcessor.MARK_STRING); - if (processor != null) { - final Component[] bbsLoginPane = {null}; - OSSupportCenter.buildAction(new OSBasedAction() { - @Override - public void execute(Object... objects) { - bbsLoginPane[0] = ad.createBBSLoginPane(); - } - }, SupportOSImpl.USERINFOPANE); - processor.hold(northEastPane, LogMessageBar.getInstance(), bbsLoginPane[0]); - } - northEastPane.add(ad.createAlphaFinePane()); - if (!DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { - ad.createAlphaFinePane().setVisible(false); - } - northEastPane.add(ad.createNotificationCenterPane()); - - OSSupportCenter.buildAction(new OSBasedAction() { - @Override - public void execute(Object... objects) { - northEastPane.add(ad.createBBSLoginPane()); - } - }, SupportOSImpl.USERINFOPANE); - + return NorthRegionContainerPane.getInstance().initNorthEastPane(ad); } public void initTitleIcon() { @@ -698,94 +573,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta this.closeMode = closeMode; } - /** - * 创建上工具栏 - */ - private void combineUpTooBar() { - combineUp = new UIToolbar(FlowLayout.LEFT); - combineUp.setBorder(new MatteBorder(new Insets(0, LEFT_ALIGN_GAP, 1, 0), UIConstants.LINE_COLOR)); - combineUp.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 2)); - setUpUpToolBar(null); - - } - - /** - * 重置上工具栏 - */ - private void resetCombineUpTooBar(JComponent[] toolbar4Form) { - combineUp.removeAll(); - setUpUpToolBar(toolbar4Form); - } - - /** - * 填充上工具栏的中的工具 - * - * @param toolbar4Form 目标组件 - */ - private void setUpUpToolBar(@Nullable JComponent[] toolbar4Form) { - UIButton[] fixButtons = ad.createUp(); - for (UIButton fixButton : fixButtons) { - combineUp.add(fixButton); - } - if (!DesignModeContext.isAuthorityEditing()) { - combineUp.addSeparator(new Dimension(2, 16)); - if (toolbar4Form != null) { - for (JComponent jComponent : toolbar4Form) { - combineUp.add(jComponent); - } - } - //添加检测按钮 - addCheckButton(); - } - //添加分享按钮 - addShareButton(); - //添加插件中的按钮 - addExtraButtons(); - } - - private void addExtraButtons() { - - JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (jt == null) { - return; - } - - - UIButton[] extraButtons = jt.createExtraButtons(); - for (UIButton extraButton : extraButtons) { - combineUp.add(extraButton); - } - if (extraButtons.length > 0) { - combineUp.addSeparator(new Dimension(2, 16)); - } - } - - private void addCheckButton() { - JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (jt == null) { - return; - } - combineUp.addSeparator(new Dimension(2, 16)); - UIButton[] checkButtons = jt.createCheckButton(); - for (UIButton checkButton : checkButtons) { - combineUp.add(checkButton); - } - } - - private void addShareButton() { - - JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (jt == null) { - return; - } - - combineUp.addSeparator(new Dimension(2, 16)); - UIButton[] shareButtons = jt.createShareButton(); - for (UIButton shareButton : shareButtons) { - combineUp.add(shareButton); - } - } - /** * 检查 * @@ -793,17 +580,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta * @param al 组件名称 */ public void checkCombineUp(boolean flag, ArrayList al) { - //Yvan: 检查当前是否为WORK_SHEET状态,因为只有WORK_SHEET中含有格式刷组件,此时是不需要进行checkComponentsByNames的 - JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (jTemplate != null) { - // 第一个条件满足后还需要添加一重判断,判断是编辑报表块还是参数面板,编辑报表块时则直接return - if (jTemplate.getMenuState() == DesignState.WORK_SHEET && !jTemplate.isUpMode()) { - return; - } - combineUp.checkComponentsByNames(flag, al); - } + CenterRegionContainerPane.getInstance().checkCombineUp(flag, al); } + /** * 刷新工具条. */ @@ -812,6 +592,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta this.ad.updateToolBarDef(); } + ToolBarMenuDock getToolBarMenuDock() { + return this.ad; + } + /** * 重置相关的工具条. * @@ -823,39 +607,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta plus = ToolBarMenuDock.NULLAVOID; } - DesignState designState = new DesignState(plus); - MenuManager.getInstance().setMenus4Designer(designState); - if (menuBar == null) { - menuPane.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER); - } else { - ad.resetJMenuBar(menuBar, plus); - } + NorthRegionContainerPane.getInstance().resetToolkitByPlus(plus, ad); - resetCombineUpTooBar(ad.resetUpToolBar(plus)); - - if (toolbarComponent != null) { - toolbarPane.remove(toolbarComponent); - } - - // 颜色,字体那些按钮的工具栏 - toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER); + CenterRegionContainerPane.getInstance().resetToolkitByPlus(plus, ad); this.checkToolbarMenuEnable(); this.validate(); layeredPane.repaint(); } - public void refreshUIToolBar() { - if (toolbarComponent instanceof UIToolbar) { - ((UIToolbar ) toolbarComponent).refreshUIToolBar(); - } - combineUp.refreshUIToolBar(); - this.ad.updateEnable(); - } - public JComponent getToolbarComponent() { - return this.toolbarComponent; + return CenterRegionContainerPane.getInstance().getToolbarComponent(); } /** @@ -863,7 +626,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ public void needToAddAuhtorityPaint() { - newWorkBookPane.setButtonGray(DesignModeContext.isAuthorityEditing()); + CenterRegionContainerPane.getInstance().needToAddAuhtorityPaint(); // 进入或退出权限编辑模式,通知插件 Set extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); @@ -981,7 +744,43 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ public JTemplate getSelectedJTemplate() { - return this.centerTemplateCardPane.getSelectedJTemplate(); + return getCenterTemplateCardPane().getSelectedJTemplate(); + } + + /** + * 保存当前编辑的模板 + */ + + public void saveCurrentEditingTemplate() { + + JTemplate editingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (editingTemplate == null) { + return; + } + if (editingTemplate.isSaved()) {// isSaved == true表示已经保存过,或者新建的一张模板 + if (editingTemplate.getEditingFILE().exists()) {// 表示磁盘上的某一张已经保存过的模板,要添加到历史中 + // HistoryTemplateListPane.getInstance().addHistory(); + } + } else { + editingTemplate.stopEditing(); + if (!editingTemplate.getEditingFILE().exists()) { + int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + editingTemplate.getEditingFILE() + + "\" ?", Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); + if (returnVal == JOptionPane.YES_OPTION && editingTemplate.saveTemplate()) { + editingTemplate.saveTemplate(); + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", + editingTemplate.getEditingFILE().getName())); + } + } else { + if (editingTemplate.saveTemplate()) { + editingTemplate.saveTemplate(); + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", + editingTemplate.getEditingFILE().getName())); + } + } + } } /** @@ -1010,10 +809,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta if (jt == null || jt.getEditingFILE() == null) { return; } + if (currentTemplateDeactivateFail()) { + return; + } jt.addJTemplateActionListener(this); jt.addTargetModifiedListener(this); jt.addJTemplateActionListener(VcsHelper.getInstance()); - centerTemplateCardPane.showJTemplate(jt); + getCenterTemplateCardPane().showJTemplate(jt); + refreshBaseContentPane(jt); setTitle(); layeredPane.repaint(); } @@ -1031,11 +834,56 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta if (jt == null || jt.getEditingFILE() == null) { return; } - centerTemplateCardPane.showJTemplate(jt); + if (currentTemplateDeactivateFail()) { + return; + } + getCenterTemplateCardPane().showJTemplate(jt); + refreshBaseContentPane(jt); setTitle(); layeredPane.repaint(); } + /** + * 当前模板 停用失败 + * + * @return 是否停用失败 + */ + private boolean currentTemplateDeactivateFail() { + JTemplate currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + return currentEditingTemplate != null && !currentEditingTemplate.deactivateTemplate(); + } + + + /** + * 根据模板刷新 设计器整个界面 + * + * @param jTemplate 当前模板 + */ + public void refreshBaseContentPane(JTemplate jTemplate) { + + JComponent north = jTemplate.north4DesignerFrame(), + center = jTemplate.center4DesignerFrame(), + west = jTemplate.west4DesignerFrame(), + east = jTemplate.east4DesignerFrame(); + + basePane.removeAll(); + + if (north != null) { + basePane.add(north, BorderLayout.NORTH); + } + if (center != null) { + basePane.add(center, BorderLayout.CENTER); + } + if (west != null) { + basePane.add(west, BorderLayout.WEST); + } + if (east != null) { + basePane.add(east, BorderLayout.EAST); + } + + jTemplate.setComposite(); + } + /** * 对象侦听 * @@ -1107,16 +955,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta JOptionPane.WARNING_MESSAGE, UIManager.getIcon("OptionPane.errorIcon") ); - if (this.getSelectedJTemplate() == null) { - addAndActivateJTemplate(); - } - } catch (ChartNotFoundException e) { - FineJOptionPane.showMessageDialog(this, - Toolkit.i18nText("Fine-Design_Chart_Not_Found_Exception"), - Toolkit.i18nText("Fine-Design_Basic_Error"), - JOptionPane.ERROR_MESSAGE, - UIManager.getIcon("OptionPane.errorIcon")); - if (this.getSelectedJTemplate() == null) { addAndActivateJTemplate(); } @@ -1339,4 +1177,19 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta return designerOpened; } -} + /** + * 判断是否正在进行服务器配置 + * @return boolean + */ + public boolean isServerConfig() { + return serverConfig; + } + + /** + * 设置是否正在进行服务器配置 + * @param serverConfig + */ + public void setServerConfig(boolean serverConfig) { + this.serverConfig = serverConfig; + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java index f3afcacc98..0e26ff3ded 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java @@ -53,7 +53,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener // 判断是否切换设计器状态到禁止拷贝剪切 if (jt.getTarget().getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) { DesignModeContext.switchTo(DesignerMode.BAN_COPY_AND_CUT); - } else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing()) { + } else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing() && !DesignModeContext.isDuchampMode()) { DesignModeContext.switchTo(DesignerMode.NORMAL); } // 切换时 @@ -61,6 +61,11 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener component.fireTabChange(); } DesignerFrameFileDealerPane.getInstance().setCurrentEditingTemplate(jt); + + refresh(jt); + } + + protected void refresh(final JTemplate jt) { if (component != null) { layeredPane.remove(component); } 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 847a2dcba3..84993411e5 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 @@ -16,7 +16,6 @@ import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.mainframe.reuse.ReuseGuideDialog; import com.fr.design.mainframe.reuse.SnapChatKeys; import com.fr.design.mainframe.share.collect.ComponentCollector; -import com.fr.design.menu.SnapChatUtil; import com.fr.design.notification.SnapChat; import com.fr.design.notification.SnapChatFactory; import com.fr.design.ui.util.UIUtil; @@ -114,7 +113,8 @@ public class EastRegionContainerPane extends UIEastResizableContainer { POLY_REPORT, // 聚合报表-报表块 POLY_CHART(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Settings")), // 聚合报表-图表块 AUTHORITY_EDITION, // 权限编辑 - AUTHORITY_EDITION_DISABLED; // 权限编辑 + AUTHORITY_EDITION_DISABLED, // 权限编辑 + DUCHAMP_REPORT; private String title; @@ -280,15 +280,15 @@ public class EastRegionContainerPane extends UIEastResizableContainer { // 单元格元素 PropertyItem cellElement = new PropertyItem(KEY_CELL_ELEMENT, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cell_Element"), "cellelement", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART}, - new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT}); + new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT, PropertyMode.DUCHAMP_REPORT}); // 单元格属性 PropertyItem cellAttr = new PropertyItem(KEY_CELL_ATTR, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cell_Attributes"), "cellattr", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART}, - new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT}); + new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT, PropertyMode.DUCHAMP_REPORT}); // 悬浮元素 PropertyItem floatElement = new PropertyItem(KEY_FLOAT_ELEMENT, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Float_Element"), "floatelement", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART}, - new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_FLOAT, PropertyMode.POLY_REPORT}); + new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_FLOAT, PropertyMode.POLY_REPORT, PropertyMode.DUCHAMP_REPORT}); // 控件设置 PropertyItem widgetSettings = new PropertyItem(KEY_WIDGET_SETTINGS, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Settings"), "widgetsettings", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.FORM, PropertyMode.POLY}, @@ -296,11 +296,11 @@ public class EastRegionContainerPane extends UIEastResizableContainer { // 条件属性 PropertyItem conditionAttr = new PropertyItem(KEY_CONDITION_ATTR, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Condition_Attributes"), "conditionattr", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART}, - new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT}); + new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT, PropertyMode.DUCHAMP_REPORT}); // 超级链接 PropertyItem hyperlink = new PropertyItem(KEY_HYPERLINK, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Hyperlink"), "hyperlink", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART}, - new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_FLOAT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT}); + new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_FLOAT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT, PropertyMode.DUCHAMP_REPORT}); // 组件库 widgetLibSnapChat = SnapChatFactory.createSnapChat(false, SnapChatKeys.COMPONENT); PropertyItem widgetLib = new PropertyItem( diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index c3b82646bb..8d18bb0db3 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -6,7 +6,12 @@ import com.fr.base.extension.FileExtension; import com.fr.base.io.BaseBook; import com.fr.base.iofile.attr.DesignBanCopyAttrMark; import com.fr.base.iofile.attr.TemplateIdAttrMark; +import com.fr.base.iofile.attr.TemplateThemeAttrMark; +import com.fr.base.theme.TemplateThemeCompatible; +import com.fr.base.theme.ThemedTemplate; import com.fr.base.vcs.DesignerMode; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeConfig; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; @@ -27,7 +32,6 @@ import com.fr.design.dialog.InformationWarnPane; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.TemplateResourceManager; -import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.MenuHandler; import com.fr.design.fun.PreviewProvider; @@ -37,7 +41,6 @@ import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.imenu.UIMenuItem; -import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.chart.info.ChartInfoCollector; @@ -62,15 +65,16 @@ import com.fr.file.MemFILE; import com.fr.form.ui.NoneWidget; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; import com.fr.main.impl.WorkBook; -import com.fr.nx.app.designer.toolbar.CompileAction; import com.fr.nx.app.designer.utils.CptCompileUtil; import com.fr.nx.cptx.entry.metadata.CptxMetadata; import com.fr.nx.cptx.utils.CptxFileUtils; import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginRuntime; +import com.fr.nx.app.designer.toolbar.CompileAction; import com.fr.nx.app.designer.toolbar.TemplateTransformer; import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.manage.PluginFilter; @@ -92,25 +96,27 @@ import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JOptionPane; -import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.SwingConstants; import javax.swing.undo.UndoManager; import java.awt.BorderLayout; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.awt.Dimension; +import java.awt.FontMetrics; import java.util.Set; import java.util.concurrent.Callable; /** * 报表设计和表单设计的编辑区域(设计器编辑的IO文件) */ -public abstract class JTemplate> extends TargetComponent implements ToolBarMenuDockPlus, DesignerProxy, JTemplateSave, TabChangeListener { +public abstract class JTemplate> extends TargetComponent implements ToolBarMenuDockPlus, DesignerProxy, JTemplateSave, TabChangeListener, ThemedTemplate { // TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null + + private static final int PREDEFINED_ICON_WIDTH = 27; private static final int PREFIX_NUM = 3000; protected FILE editingFILE = null; // alex:初始状态为saved,这样不管是新建模板,还是打开模板,如果未做任何操作直接关闭,不提示保存 private boolean saved = true; private boolean authoritySaved = true; + private UIButton templateThemeButton; private UndoManager undoMananger; private UndoManager authorityUndoManager; protected U undoState; @@ -125,7 +131,6 @@ public abstract class JTemplate> protected TemplateProcessInfo processInfo; private JComponent centerPane; - private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复 private DesignModelAdapter designModel; private PreviewProvider previewType; /** @@ -145,13 +150,16 @@ public abstract class JTemplate> private final String runtimeId = UUID.randomUUID().toString(); private PluginEventListener pluginListener; + // 监听全局主题数据更新 + private TemplateThemeConfig.ThemeConfigChangeListener themeConfigChangeListener; public JTemplate() { initAndStartPlugin(); + startListenThemeConfig(); } public JTemplate(T t, String defaultFileName) { - this(t, new MemFILE(newTemplateNameByIndex(defaultFileName)), true); + this(t, new MemFILE(JTemplateNameHelper.newTemplateNameByIndex(defaultFileName)), true); } public JTemplate(T t, FILE file) { @@ -172,7 +180,7 @@ public abstract class JTemplate> // 判断是否切换设计器状态到禁止拷贝剪切 if (t.getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) { DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.BAN_COPY_AND_CUT); - } else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing()) { + } else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing() && !DesignModeContext.isDuchampMode()) { DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL); } this.template = t; @@ -189,6 +197,11 @@ public abstract class JTemplate> this.undoState = createUndoState(); initAndStartPlugin(); + + if (isNewFile) { + setUpTheme4NewTemplate(); + } + startListenThemeConfig(); } private void initAndStartPlugin() { @@ -218,6 +231,35 @@ public abstract class JTemplate> PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, this.pluginListener, filter); } + private void startListenThemeConfig() { + if (themeConfigChangeListener == null) { + themeConfigChangeListener = new TemplateThemeConfig.ThemeConfigChangeListener() { + @Override + public void onThemeConfigChanged(TemplateThemeConfig.ThemeConfigEvent event) { + TemplateTheme usingTheme = getTemplateTheme(); + boolean isUsingThemeChanged = StringUtils.equals(event.themName, usingTheme.getName()); + + if (isUsingThemeChanged && (event.action == TemplateThemeConfig.ThemeConfigAction.REMOVE || + event.action == TemplateThemeConfig.ThemeConfigAction.UPDATE)) { + checkAndResetTheme(); + } + } + }; + TemplateThemeConfig config = getUsingTemplateThemeConfig(); + if (config != null) { + config.addThemeConfigChangeListener(themeConfigChangeListener); + } + } + } + private void stopListenThemeConfig() { + if (themeConfigChangeListener != null) { + TemplateThemeConfig config = getUsingTemplateThemeConfig(); + if (config != null) { + config.addThemeConfigChangeListener(themeConfigChangeListener); + } + } + } + private void initPluginPane() { ExtraDesignClassManager classManager = PluginModule.getAgent(PluginModule.ExtraDesign); @@ -231,11 +273,15 @@ public abstract class JTemplate> public void fireTabChange() { // do nothing } - + protected void addPane(PropertyItemPaneProvider provider) { // do nothing } + public void refreshFormDesigner() { + // do nothing + } + /** * @deprecated move to cloud ops plugin,left only for compatible @@ -336,15 +382,6 @@ public abstract class JTemplate> return getEditingFILE().getPath(); } - private String getSuffix() { - CptxMetadata metadata = CptxFileUtils.getMetadata(this.getEditingFILE().getPath()); - if (metadata != null && metadata.isForceCpt()) { - //在不支持新引擎时,标题上需要显示分页引擎未生效 - return InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Paging_Engine_Not_Work"); - } - return StringUtils.EMPTY; - } - protected abstract JComponent createCenterPane(); /** @@ -386,6 +423,7 @@ public abstract class JTemplate> public void whenClose() { // stop的时候 pluginListener 和 PluginFilter 都会移除 PluginListenerRegistration.getInstance().stopListen(this.pluginListener); + stopListenThemeConfig(); } @@ -581,6 +619,8 @@ public abstract class JTemplate> */ public void undo() { this.getUndoManager().undo(); + // 撤销前模版使用主题可能已经被删除或修改,需要重置模版样式 + checkAndResetTheme(); fireSuperTargetModified(); } @@ -589,7 +629,8 @@ public abstract class JTemplate> */ public void redo() { this.getUndoManager().redo(); - + // 重做前模版使用主题可能已经被删除或修改,需要重置模版样式 + checkAndResetTheme(); fireSuperTargetModified(); } @@ -641,6 +682,14 @@ public abstract class JTemplate> super.fireTargetModified(); } + public void fireTargetModified(boolean shouldCreateNewUndoState) { + if (shouldCreateNewUndoState) { + fireTargetModified(); + } else { + super.fireTargetModified(); + } + } + protected abstract U createUndoState(); protected abstract void applyUndoState(U u); @@ -672,8 +721,6 @@ public abstract class JTemplate> /** * 添加图片到格子中 - * - * @return 返回图片URI */ public void setPictureElem(Elem elem, CellImage cellImage) { // 子类实现 @@ -893,7 +940,7 @@ public abstract class JTemplate> return false; } try { - this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(editingFILE)); + export(); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE); @@ -907,65 +954,9 @@ public abstract class JTemplate> return true; } - private static String newTemplateNameByIndex(String prefix) { - // 用于获取左侧模板的文件名,如左侧已包含"WorkBook1.cpt, WorkBook12.cpt, WorkBook177.cpt" - // 那么新建的文件名将被命名为"WorkBook178.cpt",即取最大数+1 - TemplateFileTree tt = TemplateTreePane.getInstance().getTemplateFileTree(); - DefaultMutableTreeNode gen = (DefaultMutableTreeNode) tt.getModel().getRoot(); - String[] str = new String[gen.getChildCount()]; - - List reportNum = new ArrayList<>(); - for (int j = 0; j < gen.getChildCount(); j++) { - str[j] = gen.getChildAt(j).toString(); - //返回文件名中的index(算法中没有再匹配文件后缀了,因为DefaultMutableTreeNode中已经匹配过了) - Integer index = getFileNameIndex(prefix, str[j]); - if (index != null) { - reportNum.add(index); - } - } - Collections.sort(reportNum); - int idx = reportNum.size() > 0 ? reportNum.get(reportNum.size() - 1) + 1 : 1; - - idx = idx + currentIndex; - currentIndex++; - return prefix + idx; - } - - /** - * @return java.lang.Integer WorkBook11.cpt则返回11,如果没有找到index返回null - * @Description 返回文件名中的index - * @param: prefix 前缀 - * @param: fileName 文件名称全名 - * @Author Henry.Wang - * @Date 2021/4/9 11:13 - **/ - private static Integer getFileNameIndex(String prefix, String fileName) { - char[] chars = new char[fileName.length()]; - int i = 0; - for (; i < fileName.length(); i++) { - char c = fileName.charAt(i); - //匹配前缀 - if (i < prefix.length()) { - if (c != prefix.charAt(i)) { - return null; - } - } else { - if (c == '.') { - break; - } else { - //匹配0~9 - if (c < 48 || c > 57) { - return null; - } - chars[i - prefix.length()] = c; - } - } - } - String s = new String(chars).substring(0, i - prefix.length()); - if (StringUtils.isBlank(s)) { - return null; - } - return Integer.valueOf(s); + protected boolean export() throws Exception { + return this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(editingFILE)); + } // /////////////////////////////toolbarMenuDock////////////////////////////////// @@ -1220,6 +1211,16 @@ public abstract class JTemplate> DesignerContext.getDesignerFrame().addAndActivateJTemplate(this); } + /** + * 将要激活打开其他模板,使当前模板灭活 + * 默认 do nothing 返回true + * + * @return true:成功停用当前模板 + */ + public boolean deactivateTemplate() { + return true; + } + /** * 返回当前支持的超链界面pane @@ -1332,15 +1333,6 @@ public abstract class JTemplate> */ public abstract Icon getIcon(); - /** - * 导出菜单项 - * - * @return 菜单项 - */ - @Override - public ShortCut[] shortcut4ExportMenu() { - return new ShortCut[0]; - } /** * 复制JS代码 @@ -1418,13 +1410,15 @@ public abstract class JTemplate> * @return 按钮组 */ public UIButton[] createExtraButtons() { - UIButton[] uiButtons = new UIButton[]{ + UIButton[] uiButtons = new UIButton[] { (UIButton) new CompileAction().createToolBarComponent() }; Set providers = ExtraDesignClassManager.getInstance().getArray(DesignerFrameUpButtonProvider.XML_TAG); for (DesignerFrameUpButtonProvider provider : providers) { uiButtons = ArrayUtils.addAll(uiButtons, provider.getUpButtons(getMenuState())); } + templateThemeButton = createTemplateThemeButton(); + uiButtons = ArrayUtils.addAll(uiButtons, templateThemeButton); return uiButtons; } @@ -1433,6 +1427,23 @@ public abstract class JTemplate> return new UIButton[]{new CheckButton()}; } + protected UIButton createTemplateThemeButton() { + UIButton button = new UIButton(IOUtils.readIcon("/com/fr/design/icon/icon_predefined_style.png")) { + @Override + public Dimension getPreferredSize() { + FontMetrics metrics = getFontMetrics(getFont()); + int width = Math.min(metrics.stringWidth(getText()) + PREDEFINED_ICON_WIDTH, 100); + return new Dimension(width, 20); + } + }; + button.setToolTipText(getTemplateTheme().getName()); + button.setText(getTemplateTheme().getName()); + button.setAlignmentX(SwingConstants.LEFT); + button.set4ToolbarButton(); + button.setEnabled(true); + return button; + } + /** * 由于老版本的模板没有模板ID,当勾选使用参数模板时候,就加一个模板ID attr * @@ -1461,10 +1472,61 @@ public abstract class JTemplate> } } + + private String getSuffix() { + //这里需要重写getPath(),getPath()方法中,使用到了getSuffix()方法 + CptxMetadata metadata = CptxFileUtils.getMetadata(this.getEditingFILE().getPath()); + if (metadata != null && metadata.isForceCpt()) { + //返回分页引擎未生效 + return InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Paging_Engine_Not_Work"); + } + return StringUtils.EMPTY; + } + public String getTemplatePredefinedStyle() { return StringUtils.EMPTY; } + /** + * 指定 设计器界面 NORTH组件 + * 默认是 菜单区域 + * + * @return NORTH组件 + */ + public JComponent north4DesignerFrame() { + return NorthRegionContainerPane.getInstance(); + } + + /** + * 指定 设计器界面 CENTER组件 + * 默认是 模板对应的工具栏区域+模板设计区域 + * + * @return CENTER组件 + */ + public JComponent center4DesignerFrame() { + return CenterRegionContainerPane.getInstance(); + } + + /** + * 指定 设计器界面 WEST组件 + * 默认是 模板目录树+数据集编辑区域 + * + * @return WEST组件 + */ + public JComponent west4DesignerFrame() { + return WestRegionContainerPane.getInstance(); + } + + /** + * 指定 设计器界面 EAST组件 + * 默认是 属性配置界面 + * + * @return EAST组件 + */ + public JComponent east4DesignerFrame() { + return EastRegionContainerPane.getInstance(); + } + private CallbackSaveWorker save(boolean showLoc) { FILE editingFILE = this.getEditingFILE(); // carl:editingFILE没有,当然不存了,虽然不会有这种情况 @@ -1489,7 +1551,6 @@ public abstract class JTemplate> callBackForSave(); //在保存后的回调中执行预编译流程 CptCompileUtil.compile(JTemplate.this); - } }); @@ -1554,12 +1615,13 @@ public abstract class JTemplate> worker.addSuccessCallback(new Runnable() { @Override public void run() { - //新添加代码,另存为流程中,有可能没有保存,在没有保存的情况下,应该进行预编译判断 + //在新建报表流程会走这个流程,应该进行预编译 if (!JTemplate.this.isSaved() && !DesignModeContext.isVcsMode()){ //这里要先调下面这行代码 callBackForSave(); CptCompileUtil.compile(JTemplate.this); } + callBackForSave(); // 当前打开的是正在保存的模板才刷新 if (ComparatorUtils.equals(JTemplate.this.template.getTemplateID(), HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().template.getTemplateID())) { @@ -1691,4 +1753,23 @@ public abstract class JTemplate> public String getRuntimeId() { return runtimeId; } -} + + protected void setUpTheme4NewTemplate() { + TemplateTheme theme = getUsingTemplateThemeConfig().cachedFetchTheme4NewTemplate(); + TemplateThemeAttrMark themeAttrMark = template.getAttrMark(TemplateThemeAttrMark.XML_TAG); + if (themeAttrMark == null) { + themeAttrMark = new TemplateThemeAttrMark(); + template.addAttrMark(themeAttrMark); + } + themeAttrMark.setName(theme.getName()); + themeAttrMark.setDark(theme.isDark()); + } + + @Override + public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) { + ThemedTemplate.super.setTemplateTheme(newTheme, compatible); + String name = newTheme.getName(); + templateThemeButton.setText(name); + templateThemeButton.setToolTipText(name); + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateNameHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateNameHelper.java new file mode 100644 index 0000000000..22d5985ba9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateNameHelper.java @@ -0,0 +1,86 @@ +package com.fr.design.mainframe; + +import com.fr.design.file.TemplateTreePane; +import com.fr.design.gui.itree.filetree.TemplateFileTree; +import com.fr.stable.StringUtils; + +import javax.swing.tree.DefaultMutableTreeNode; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/5/7 + */ +public class JTemplateNameHelper { + + private static final int PREFIX_NUM = 3000; + + private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复 + + public static String newTemplateNameByIndex(String prefix) { + // 用于获取左侧模板的文件名,如左侧已包含"WorkBook1.cpt, WorkBook12.cpt, WorkBook177.cpt" + // 那么新建的文件名将被命名为"WorkBook178.cpt",即取最大数+1 + TemplateFileTree tt = TemplateTreePane.getInstance().getTemplateFileTree(); + DefaultMutableTreeNode gen = (DefaultMutableTreeNode) tt.getModel().getRoot(); + String[] str = new String[gen.getChildCount()]; + + List reportNum = new ArrayList<>(); + for (int j = 0; j < gen.getChildCount(); j++) { + str[j] = gen.getChildAt(j).toString(); + //返回文件名中的index(算法中没有再匹配文件后缀了,因为DefaultMutableTreeNode中已经匹配过了) + Integer index = getFileNameIndex(prefix, str[j]); + if (index != null) { + reportNum.add(index); + } + } + Collections.sort(reportNum); + int idx = reportNum.size() > 0 ? reportNum.get(reportNum.size() - 1) + 1 : 1; + + idx = idx + currentIndex; + currentIndex++; + return prefix + idx; + } + + /** + * @return java.lang.Integer WorkBook11.cpt则返回11,如果没有找到index返回null + * @Description 返回文件名中的index + * @param: prefix 前缀 + * @param: fileName 文件名称全名 + * @Author Henry.Wang + * @Date 2021/4/9 11:13 + **/ + private static Integer getFileNameIndex(String prefix, String fileName) { + if (fileName.length() <= prefix.length()) { + return null; + } + char[] chars = new char[fileName.length()]; + int i = 0; + for (; i < fileName.length(); i++) { + char c = fileName.charAt(i); + //匹配前缀 + if (i < prefix.length()) { + if (c != prefix.charAt(i)) { + return null; + } + } else { + if (c == '.') { + break; + } else { + //匹配0~9 + if (c < 48 || c > 57) { + return null; + } + chars[i - prefix.length()] = c; + } + } + } + String s = new String(chars).substring(0, i - prefix.length()); + if (StringUtils.isBlank(s)) { + return null; + } + return Integer.valueOf(s); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java new file mode 100644 index 0000000000..b070710579 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java @@ -0,0 +1,144 @@ +package com.fr.design.mainframe; + +import com.fr.design.DesignState; +import com.fr.design.DesignerEnvManager; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.TitlePlaceProcessor; +import com.fr.design.gui.imenu.UIMenuHighLight; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.loghandler.LogMessageBar; +import com.fr.design.mainframe.toolbar.ToolBarMenuDock; +import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; +import com.fr.design.menu.MenuManager; +import com.fr.design.os.impl.SupportOSImpl; +import com.fr.general.GeneralContext; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; + +import javax.swing.JMenuBar; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/4/6 + */ +public class NorthRegionContainerPane extends JPanel { + + private static volatile NorthRegionContainerPane THIS; + + private JMenuBar menuBar; + + public static NorthRegionContainerPane getInstance() { + if (THIS == null) { + synchronized (NorthRegionContainerPane.class) { + if (THIS == null) { + THIS = new NorthRegionContainerPane(); + } + } + } + return THIS; + } + + public NorthRegionContainerPane() { + + ToolBarMenuDock ad = DesignerContext.getDesignerFrame().getToolBarMenuDock(); + + this.setLayout(new BorderLayout()); + this.add(new UIMenuHighLight(), BorderLayout.SOUTH); + this.add(initNorthEastPane(ad), BorderLayout.EAST); + } + + /** + * @param ad 菜单栏 + * @return panel + */ + protected JPanel initNorthEastPane(final ToolBarMenuDock ad) { + //hugh: private修改为protected方便oem的时候修改右上的组件构成 + //顶部日志+登陆按钮 + final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + //优先级为-1,保证最后全面刷新一次 + GeneralContext.listenPluginRunningChanged(new PluginEventListener(-1) { + + @Override + public void on(PluginEvent event) { + + refreshNorthEastPane(northEastPane, ad); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + if (DesignerContext.getDesignerFrame() == null) { + return; + } + DesignerContext.getDesignerFrame().refresh(); + DesignerContext.getDesignerFrame().repaint(); + } + }); + } + }, new PluginFilter() { + + @Override + public boolean accept(PluginContext context) { + + return context.contain(PluginModule.ExtraDesign); + } + }); + refreshNorthEastPane(northEastPane, ad); + return northEastPane; + } + + private void refreshNorthEastPane(final JPanel northEastPane, final ToolBarMenuDock ad) { + + northEastPane.removeAll(); + northEastPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); + northEastPane.add(LogMessageBar.getInstance()); + TitlePlaceProcessor processor = ExtraDesignClassManager.getInstance().getSingle(TitlePlaceProcessor.MARK_STRING); + if (processor != null) { + final Component[] bbsLoginPane = {null}; + OSSupportCenter.buildAction(new OSBasedAction() { + @Override + public void execute(Object... objects) { + bbsLoginPane[0] = ad.createBBSLoginPane(); + } + }, SupportOSImpl.USERINFOPANE); + processor.hold(northEastPane, LogMessageBar.getInstance(), bbsLoginPane[0]); + } + northEastPane.add(ad.createAlphaFinePane()); + if (!DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { + ad.createAlphaFinePane().setVisible(false); + } + northEastPane.add(ad.createNotificationCenterPane()); + + OSSupportCenter.buildAction(new OSBasedAction() { + @Override + public void execute(Object... objects) { + northEastPane.add(ad.createBBSLoginPane()); + } + }, SupportOSImpl.USERINFOPANE); + + } + + /** + * 重置相关的工具条. + * + * @param plus 工具条中相关信息 + */ + void resetToolkitByPlus(ToolBarMenuDockPlus plus, ToolBarMenuDock ad) { + DesignState designState = new DesignState(plus); + MenuManager.getInstance().setMenus4Designer(designState); + if (menuBar == null) { + this.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER); + } else { + ad.resetJMenuBar(menuBar, plus); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java index f9b4c160e5..2fbdb974e0 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java @@ -3,12 +3,8 @@ package com.fr.design.mainframe.backgroundpane; import com.fr.base.background.ColorBackground; import com.fr.design.event.UIObserverListener; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.style.color.NewColorSelectPane; +import com.fr.design.style.color.NewColorSelectBox; import com.fr.general.Background; - - -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import java.awt.BorderLayout; import java.awt.Color; @@ -18,13 +14,13 @@ import java.awt.Color; */ public class ColorBackgroundQuickPane extends BackgroundQuickPane { - private NewColorSelectPane detailColorSelectPane; + private NewColorSelectBox colorSelectBox; + public ColorBackgroundQuickPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); - - detailColorSelectPane = new NewColorSelectPane(); - this.add(detailColorSelectPane, BorderLayout.NORTH); + colorSelectBox = new NewColorSelectBox(100); + this.add(colorSelectBox, BorderLayout.NORTH); } public void populateBean(Background background) { @@ -37,12 +33,11 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane { } public void populateColor(Color color) { - this.detailColorSelectPane.setColor(color); + this.colorSelectBox.setSelectObject(color); } public Color updateColor() { - this.detailColorSelectPane.updateUsedColor(); - return this.detailColorSelectPane.getNotNoneColor(); + return this.colorSelectBox.getSelectObject(); } /** @@ -52,7 +47,7 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane { */ @Override public void registerChangeListener(final UIObserverListener listener) { - detailColorSelectPane.addChangeListener(new ChangeListenerImpl(listener)); + this.colorSelectBox.addSelectChangeListener(new ChangeListenerImpl(listener)); } @Override @@ -78,6 +73,6 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane { @Override public void reset() { - this.detailColorSelectPane.setColor(null); + this.colorSelectBox.setSelectObject(null); } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java index dc10d8883c..fded318188 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java @@ -48,6 +48,7 @@ public class LogMessageBar extends JPanel { public void mouseClicked(MouseEvent e) { if (dlg != null && dlg.isVisible()) { dlg.setExtendedState(JFrame.NORMAL); + dlg.requestFocus(); return; } dlg = new LogDetailPane().showDialog(); @@ -87,4 +88,8 @@ public class LogMessageBar extends JPanel { } THIS = null; } + + public JFrame getLogFrame() { + return dlg; + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/combo/SimpleComboCheckBoxStyleProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/combo/SimpleComboCheckBoxStyleProvider.java new file mode 100644 index 0000000000..027e95df3e --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/combo/SimpleComboCheckBoxStyleProvider.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.mobile.provider.combo; + +import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; +import com.fr.design.mainframe.mobile.ui.combo.SimpleComboPane; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.form.ui.mobile.combo.SimpleComboStyle; + +public class SimpleComboCheckBoxStyleProvider extends AbstractMobileWidgetStyleProvider { + @Override + public Class classForMobileStyle() { + return SimpleComboStyle.class; + } + + @Override + public Class classForWidgetAppearance() { + return SimpleComboPane.class; + } + + @Override + public String xTypeForWidget() { + return "tagcombocheckbox"; + } + + @Override + public String displayName() { + return Toolkit.i18nText("Fine-Plugin-SimpleCombo_SimpleComboStyle"); + } + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/combo/SimpleComboStyleProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/combo/SimpleComboStyleProvider.java new file mode 100644 index 0000000000..23aa3f9460 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/combo/SimpleComboStyleProvider.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.mobile.provider.combo; + +import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; +import com.fr.design.mainframe.mobile.ui.combo.SimpleComboPane; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.form.ui.mobile.combo.SimpleComboStyle; + +public class SimpleComboStyleProvider extends AbstractMobileWidgetStyleProvider{ + @Override + public Class classForMobileStyle() { + return SimpleComboStyle.class; + } + + @Override + public Class classForWidgetAppearance() { + return SimpleComboPane.class; + } + + @Override + public String xTypeForWidget() { + return "combo"; + } + + @Override + public String displayName() { + return Toolkit.i18nText("Fine-Plugin-SimpleCombo_SimpleComboStyle"); + } + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/date/NavigationStyleProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/date/NavigationStyleProvider.java new file mode 100644 index 0000000000..89a64eb6d3 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/date/NavigationStyleProvider.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.mobile.provider.date; + +import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; +import com.fr.design.mainframe.mobile.ui.date.NavigationCustomDefinePane; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.form.ui.mobile.date.NavigationMobileStyle; + +public class NavigationStyleProvider extends AbstractMobileWidgetStyleProvider { + @Override + public Class classForMobileStyle() { + return NavigationMobileStyle.class; + } + + @Override + public Class classForWidgetAppearance() { + return NavigationCustomDefinePane.class; + } + + @Override + public String xTypeForWidget() { + return "datetime"; + } + + @Override + public String displayName() { + return Toolkit.i18nText("Fine-Plugin-Date_Navigation_Calendar"); + } + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/date/SimpleDateStyleProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/date/SimpleDateStyleProvider.java new file mode 100644 index 0000000000..f9743acbf6 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/date/SimpleDateStyleProvider.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.mobile.provider.date; + +import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; +import com.fr.design.mainframe.mobile.ui.date.SimpleDateCustomDefinePane; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.form.ui.mobile.date.SimpleDateMobileStyle; + +public class SimpleDateStyleProvider extends AbstractMobileWidgetStyleProvider { + @Override + public Class classForMobileStyle() { + return SimpleDateMobileStyle.class; + } + + @Override + public Class classForWidgetAppearance() { + return SimpleDateCustomDefinePane.class; + } + + @Override + public String xTypeForWidget() { + return "datetime"; + } + + @Override + public String displayName() { + return Toolkit.i18nText("Fine-Plugin-SimpleDate_Style"); + } + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/date/SimpleStyleProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/date/SimpleStyleProvider.java new file mode 100644 index 0000000000..2fa34625e7 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/date/SimpleStyleProvider.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.mobile.provider.date; + +import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; +import com.fr.design.mainframe.mobile.ui.date.SimpleCustomDefinePane; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.form.ui.mobile.date.SimpleMobileStyle; + +public class SimpleStyleProvider extends AbstractMobileWidgetStyleProvider { + @Override + public Class classForMobileStyle() { + return SimpleMobileStyle.class; + } + + @Override + public Class classForWidgetAppearance() { + return SimpleCustomDefinePane.class; + } + + @Override + public String xTypeForWidget() { + return "datetime"; + } + + @Override + public String displayName() { + return Toolkit.i18nText("Fine-Plugin-Date_Simple_Calendar"); + } + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/radiogroup/CapsuleRadioGroupStyleProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/radiogroup/CapsuleRadioGroupStyleProvider.java new file mode 100644 index 0000000000..0f8f005eb5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/radiogroup/CapsuleRadioGroupStyleProvider.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.mobile.provider.radiogroup; + +import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; +import com.fr.design.mainframe.mobile.ui.radiogroup.CapsuleCustomDefinePane; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.form.ui.mobile.radiogroup.CapsuleMobileStyle; + +public class CapsuleRadioGroupStyleProvider extends AbstractMobileWidgetStyleProvider { + @Override + public Class classForMobileStyle() { + return CapsuleMobileStyle.class; + } + + @Override + public Class classForWidgetAppearance() { + return CapsuleCustomDefinePane.class; + } + + @Override + public String xTypeForWidget() { + return "radiogroup"; + } + + @Override + public String displayName() { + return Toolkit.i18nText("Fine-Plugin-RadioGroup_Capsule_Button"); + } + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/radiogroup/ImageRadioGroupStyleProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/radiogroup/ImageRadioGroupStyleProvider.java new file mode 100644 index 0000000000..1bdcc6a2cf --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/radiogroup/ImageRadioGroupStyleProvider.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.mobile.provider.radiogroup; + +import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; +import com.fr.design.mainframe.mobile.ui.radiogroup.ImageCustomDefinePane; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.form.ui.mobile.radiogroup.ImageMobileStyle; + +public class ImageRadioGroupStyleProvider extends AbstractMobileWidgetStyleProvider { + @Override + public Class classForMobileStyle() { + return ImageMobileStyle.class; + } + + @Override + public Class classForWidgetAppearance() { + return ImageCustomDefinePane.class; + } + + @Override + public String xTypeForWidget() { + return "radiogroup"; + } + + @Override + public String displayName() { + return Toolkit.i18nText("Fine-Plugin-RadioGroup_Graphic_Button"); + } + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/radiogroup/UnitedRadioGroupStyleProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/radiogroup/UnitedRadioGroupStyleProvider.java new file mode 100644 index 0000000000..91e1dde048 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/radiogroup/UnitedRadioGroupStyleProvider.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.mobile.provider.radiogroup; + +import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; +import com.fr.design.mainframe.mobile.ui.radiogroup.UnitedCustomDefinePane; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.form.ui.mobile.radiogroup.UnitedMobileStyle; + +public class UnitedRadioGroupStyleProvider extends AbstractMobileWidgetStyleProvider { + @Override + public Class classForMobileStyle() { + return UnitedMobileStyle.class; + } + + @Override + public Class classForWidgetAppearance() { + return UnitedCustomDefinePane.class; + } + + @Override + public String xTypeForWidget() { + return "radiogroup"; + } + + @Override + public String displayName() { + return Toolkit.i18nText("Fine-Plugin-RadioGroup_Linkage_Button"); + } + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/topparam/MobileTopParamStyleProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/topparam/MobileTopParamStyleProvider.java new file mode 100644 index 0000000000..9e91527a4d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/topparam/MobileTopParamStyleProvider.java @@ -0,0 +1,25 @@ +package com.fr.design.mainframe.mobile.provider.topparam; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.fun.impl.AbstractMobileParamUIProvider; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.mobile.ui.topparam.MobileTopParamPane; +import com.fr.form.ui.mobile.MobileParamStyle; +import com.fr.form.ui.mobile.impl.MobileTopParamStyle; + +public class MobileTopParamStyleProvider extends AbstractMobileParamUIProvider { + @Override + public Class classForMobileParamStyle() { + return MobileTopParamStyle.class; + } + + @Override + public Class> classForMobileParamAppearance() { + return MobileTopParamPane.class; + } + + @Override + public String displayName() { + return Toolkit.i18nText("Fine-Plugin-TopParam_Name"); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileParamSettingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileParamSettingPane.java index 7f1d270af5..eb7496607d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileParamSettingPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileParamSettingPane.java @@ -7,7 +7,7 @@ import com.fr.design.fun.MobileParamUIProvider; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.mobile.provider.DefaultMobileParamUIProvider; import com.fr.design.mainframe.mobile.provider.EmptyMobileParamUIProvider; -import com.fr.form.ui.container.WParameterLayout; +import com.fr.design.mainframe.mobile.utils.MobileStyleProviderManager; import com.fr.form.ui.mobile.MobileParamStyle; import com.fr.general.ComparatorUtils; import com.fr.report.ExtraReportClassManager; @@ -101,7 +101,7 @@ public class MobileParamSettingPane extends BasicPane { MobileParamUIProvider[] mobileParamUIProviders = getMobileParamUIProviders(); for (int i = 0; i < mobileParamUIProviders.length; i++) { MobileParamUIProvider provider = mobileParamUIProviders[i]; - if (ComparatorUtils.equals(mobileParamStyle.disPlayName(), provider.displayName())) { + if (ComparatorUtils.equals(mobileParamStyle.displayName(), provider.displayName())) { String displayName = provider.displayName(); paramStyleList.setSelectedIndex(i); // 如果是兼容空类型 无须填充面板 @@ -136,9 +136,11 @@ public class MobileParamSettingPane extends BasicPane { private MobileParamUIProvider[] getMobileParamUIProviders() { Set paramUIProviders = ExtraDesignClassManager.getInstance().getArray(MobileParamUIProvider.XML_TAG); + Set otherParamUIProviders = MobileStyleProviderManager.getArray(MobileParamUIProvider.XML_TAG); List result = new ArrayList<>(); result.add(new DefaultMobileParamUIProvider()); result.addAll(paramUIProviders); + result.addAll(otherParamUIProviders); Set nameSets = paramUIProviders.stream().map(MobileParamUIProvider::displayName).collect(Collectors.toSet()); // 兼容老接口 Set paramStyleProviders = ExtraReportClassManager.getInstance().getArray(MobileParamStyleProvider.MARK_STRING); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/combo/SimpleComboPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/combo/SimpleComboPane.java new file mode 100644 index 0000000000..b71588ebfd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/combo/SimpleComboPane.java @@ -0,0 +1,304 @@ +package com.fr.design.mainframe.mobile.ui.combo; + +import com.fr.design.dialog.AttrScrollPane; +import com.fr.design.dialog.BasicScrollPane; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.icombobox.LineComboBox; +import com.fr.design.gui.icombobox.UIComboBox; +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.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; +import com.fr.design.mainframe.mobile.utils.DesignerUtils; +import com.fr.design.mainframe.mobile.utils.FontConfigPane; +import com.fr.design.mainframe.mobile.utils.IconConfigPane; +import com.fr.design.style.color.NewColorSelectBox; +import com.fr.form.ui.Widget; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.form.ui.mobile.combo.SimpleComboStyle; +import com.fr.stable.Constants; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +public class SimpleComboPane extends MobileStyleCustomDefinePane { + + private JPanel scrollPanel; + private UIComboBox custom; + private JPanel centerPane; + private FontConfigPane labelFontPane; + private FontConfigPane valueFontPane; + private IconConfigPane expandIconPane; + private IconConfigPane unexpandIconPane; + private NewColorSelectBox background; + private LineComboBox borderType; + private NewColorSelectBox borderColor; + private UISpinner borderRadius; + private UIRadioButton fillButton; + private UIRadioButton customButton; + private UISpinner widthSpinner; + + private UIRadioButton floatFillButton; + private UIRadioButton floatSameWidthButton; + + public SimpleComboPane(Widget widget) { + super(widget); + } + + @Override + protected JPanel createPreviewPane() { + return null; + } + + @Override + protected void init() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.addScrollPane(); + this.addStyleSelectPane(); + this.addConfigPane(); + } + + private void addScrollPane() { + scrollPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + BasicScrollPane basicScrollPane = new AttrScrollPane() { + @Override + protected JPanel createContentPane() { + return scrollPanel; + } + }; + this.add(basicScrollPane); + } + + private void addStyleSelectPane() { + UILabel buttonStyleLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Control_Style")); + custom = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-SimpleCombo_Style_Default"), Toolkit.i18nText("Fine-Plugin-SimpleCombo_Style_Custom")}); + custom.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); + custom.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + boolean isCustom = custom.getSelectedIndex() == 1; + centerPane.setVisible(isCustom); + + } + }); + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + JPanel stylePanel = DesignerUtils.createLeftRightComponentsPane(buttonStyleLabel, custom); + panel.add(stylePanel); + scrollPanel.add(panel, BorderLayout.NORTH); + } + + private void addConfigPane() { + centerPane = createCenterPane(); + centerPane.setVisible(false); + addLabelNamePane(); + addValuePane(); + addIconPane(); + addWidgetSettingPane(); + scrollPanel.add(centerPane, BorderLayout.CENTER); + } + + private JPanel createCenterPane() { + return FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); + } + + private void addLabelNamePane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Label_Name"))); + labelFontPane = new FontConfigPane(); + JPanel fontPanel = createFontPane(labelFontPane); + centerPane.add(fontPanel); + } + + private void addValuePane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Control_Value"))); + valueFontPane = new FontConfigPane(); + JPanel fontPanel = createFontPane(valueFontPane); + valueFontPane.setFontColor(new Color(153, 153, 153)); + centerPane.add(fontPanel); + } + + private JPanel createFontPane(FontConfigPane fontConfigPane) { + UILabel fontLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Character")); + JPanel fontPanel = DesignerUtils.createLeftRightComponentsPane(fontLabel, fontConfigPane); + return fontPanel; + } + + private void addIconPane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Arrow"))); + UILabel tipLabel = new UILabel(); + tipLabel.setFont(new Font(tipLabel.getName(), Font.PLAIN, 10)); + tipLabel.setSize(470, 40); + tipLabel.setText(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Tips")); + tipLabel.setForeground(Color.decode("#9B9B9B")); + centerPane.add(tipLabel); + + + UILabel expandLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Expand_Icon")); + UILabel unexpandLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Collapse_Icon")); + + expandIconPane = new IconConfigPane(); + unexpandIconPane = new IconConfigPane(); + + JPanel expandPane = DesignerUtils.createLeftRightComponentsPane(expandLabel, expandIconPane); + centerPane.add(expandPane); + + JPanel unexpandPane = DesignerUtils.createLeftRightComponentsPane(unexpandLabel, unexpandIconPane); + centerPane.add(unexpandPane); + } + + private void addWidgetSettingPane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Control_Region"))); + background = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + } + }); + borderType = new LineComboBox(DesignerUtils.BORDER_LINE_STYLE_ARRAY); + borderType.setSelectedLineStyle(Constants.LINE_THIN); + borderType.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); + borderColor = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + } + }); + borderRadius = new UISpinner(0, Integer.MAX_VALUE, 1, 2); + borderRadius.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); + + JComponent[] controlComponents = new JComponent[]{background, borderType, borderColor, borderRadius}; + String[] comboBoxNames = new String[]{ + Toolkit.i18nText("Fine-Plugin-SimpleCombo_Control_Background"), + Toolkit.i18nText("Fine-Plugin-SimpleCombo_Control_Border"), + Toolkit.i18nText("Fine-Plugin-SimpleCombo_Border_Color"), + Toolkit.i18nText("Fine-Plugin-SimpleCombo_Radius"), + }; + + Component[][] components = new Component[4][]; + + for (int i = 0; i < 4; i++) { + UILabel label = DesignerUtils.createConfigLabel(comboBoxNames[i]); + components[i] = new Component[]{label, controlComponents[i]}; + } + + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p, p, p, }; + double[] columnSize = {p, p}; + JPanel controlPanel = TableLayoutHelper.createCommonTableLayoutPane(components, rowSize, columnSize, 10); + centerPane.add(controlPanel); + + fillButton = new UIRadioButton(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Horizontal_Fill")); + fillButton.setSelected(true); + customButton = new UIRadioButton(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Custom_Width")); + ActionListener listener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + widthSpinner.setVisible(customButton.isSelected()); + } + }; + fillButton.addActionListener(listener); + customButton.addActionListener(listener); + ButtonGroup buttonGroup = new ButtonGroup(); + buttonGroup.add(fillButton); + buttonGroup.add(customButton); + widthSpinner = new UISpinner(1, Integer.MAX_VALUE, 1, 200); + widthSpinner.setPreferredSize(new Dimension(78, 20)); + widthSpinner.setVisible(false); + UILabel widthLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Width")); + JPanel buttonsPane = createButtonPane(); + buttonsPane.add(fillButton); + buttonsPane.add(customButton); + JPanel widthSetting = DesignerUtils.createLeftRightComponentsPane(widthLabel, buttonsPane, widthSpinner); + centerPane.add(widthSetting); + + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Floating_Layer"))); + UILabel floatLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Width")); + floatFillButton = new UIRadioButton(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Horizontal_Fill")); + floatFillButton.setSelected(true); + floatSameWidthButton = new UIRadioButton(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Follow_Control")); + ButtonGroup floatButtonGroup = new ButtonGroup(); + floatButtonGroup.add(floatFillButton); + floatButtonGroup.add(floatSameWidthButton); + JPanel floatButtonPane = createButtonPane(); + floatButtonPane.add(floatFillButton); + floatButtonPane.add(floatSameWidthButton); + JPanel floatSetting = DesignerUtils.createLeftRightComponentsPane(floatLabel, floatFillButton, floatSameWidthButton); + centerPane.add(floatSetting); + } + + private JPanel createButtonPane() { + JPanel buttonPane = new JPanel(); + buttonPane.setLayout(new GridLayout(0, 2, 14, 0)); + buttonPane.setPreferredSize(new Dimension(220, 20)); + return buttonPane; + } + + @Override + public void populateBean(MobileStyle ob) { + SimpleComboStyle mobileStyle = (SimpleComboStyle) ob; + custom.setSelectedIndex(mobileStyle.isCustom() ? 1 : 0); + expandIconPane.populate(mobileStyle.getExpandIcon()); + unexpandIconPane.populate(mobileStyle.getUnexpandIcon()); + if (mobileStyle.getLabelFont() != null) { + labelFontPane.populate(mobileStyle.getLabelFont()); + } + if (mobileStyle.getValueFont() != null) { + valueFontPane.populate(mobileStyle.getValueFont()); + } + if (mobileStyle.getBackgroundColor() != null) { + background.setSelectObject(mobileStyle.getBackgroundColor()); + } + if (mobileStyle.getBorderColor() != null) { + borderColor.setSelectObject(mobileStyle.getBorderColor()); + } + borderType.setSelectedLineStyle(mobileStyle.getBorderType()); + borderRadius.setValue(mobileStyle.getBorderRadius()); + if (mobileStyle.isCustomWidth()) { + fillButton.setSelected(false); + customButton.setSelected(true); + widthSpinner.setVisible(true); + widthSpinner.setValue(mobileStyle.getWidth()); + } else { + fillButton.setSelected(true); + customButton.setSelected(false); + widthSpinner.setVisible(false); + } + if (mobileStyle.isFloatWidthFollow()) { + floatFillButton.setSelected(false); + floatSameWidthButton.setSelected(true); + } else { + floatFillButton.setSelected(true); + floatSameWidthButton.setSelected(false); + } + } + + @Override + public MobileStyle updateBean() { + SimpleComboStyle mobileStyle = (SimpleComboStyle) this.widget.getMobileStyle(); + mobileStyle.setCustom(custom.getSelectedIndex() == 1); + mobileStyle.setExpandIcon(expandIconPane.update()); + mobileStyle.setUnexpandIcon(unexpandIconPane.update()); + mobileStyle.setLabelFont(labelFontPane.update()); + mobileStyle.setValueFont(valueFontPane.update()); + mobileStyle.setBackgroundColor(background.getSelectObject()); + mobileStyle.setBorderColor(borderColor.getSelectObject()); + mobileStyle.setBorderType(borderType.getSelectedLineStyle()); + mobileStyle.setBorderRadius(borderRadius.getValue()); + mobileStyle.setCustomWidth(customButton.isSelected()); + mobileStyle.setWidth(widthSpinner.getValue()); + mobileStyle.setFloatWidthFollow(floatSameWidthButton.isSelected()); + return mobileStyle; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/date/NavigationCustomDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/date/NavigationCustomDefinePane.java new file mode 100644 index 0000000000..e64ba926db --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/date/NavigationCustomDefinePane.java @@ -0,0 +1,272 @@ +package com.fr.design.mainframe.mobile.ui.date; + +import com.fr.design.dialog.AttrScrollPane; +import com.fr.design.dialog.BasicScrollPane; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.icheckbox.UICheckBox; +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.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; +import com.fr.design.mainframe.mobile.utils.DesignerUtils; +import com.fr.design.style.color.NewColorSelectBox; +import com.fr.form.ui.Widget; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.form.ui.mobile.date.NavigationMobileStyle; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +public class NavigationCustomDefinePane extends MobileStyleCustomDefinePane { + + private JPanel scrollPanel; + private UIComboBox custom; + private JPanel centerPane; + + private UIComboBox expand; + private UIComboBox dateFontSize; + private NewColorSelectBox buttonColorSelectBox; + private NewColorSelectBox titleSplitLineColorSelectBox; + private UICheckBox showTitleEditor; + private NewColorSelectBox arrowColorSelectBox; + private UIColorButton mainFontColor; + private UIColorButton specialFontColor; + + private Color titleSplitLineDisableColor = new Color(234, 234, 234); + private Color titleSplitLineColor; + + public NavigationCustomDefinePane(Widget widget) { + super(widget); + } + + @Override + protected JPanel createPreviewPane() { + return null; + } + + @Override + protected void init() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.addScrollPane(); + this.addStyleSelectPane(); + this.addConfigPane(); + } + + private void addScrollPane() { + scrollPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + BasicScrollPane basicScrollPane = new AttrScrollPane() { + @Override + protected JPanel createContentPane() { + return scrollPanel; + } + }; + this.add(basicScrollPane); + } + + private void addStyleSelectPane() { + JPanel stylePanel = new JPanel(); + stylePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + UILabel buttonStyleLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Style")); + custom = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-Date_Style_Default"), Toolkit.i18nText("Fine-Plugin-Date_Style_Custom")}); + custom.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); + custom.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + boolean isCustom = custom.getSelectedIndex() == 1; + centerPane.setVisible(isCustom); + + } + }); + stylePanel.add(buttonStyleLabel); + stylePanel.add(custom); + scrollPanel.add(stylePanel, BorderLayout.NORTH); + } + + private void addConfigPane() { + centerPane = createCenterPane(); + centerPane.setVisible(false); + addExpandPane(); + addHeaderLinePane(); + addButtonColorPane(); + addFontColorPane(); + addArrowPane(); + scrollPanel.add(centerPane, BorderLayout.CENTER); + custom.setSelectedIndex(1); + } + + private void addExpandPane() { + UILabel label = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Status")); + expand = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-Date_Status_Collapse"), Toolkit.i18nText("Fine-Plugin-Date_Status_Expand")}); + expand.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + panel.add(label); + panel.add(expand); + centerPane.add(panel); + } + + private void addButtonColorPane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-Date_Button"))); + UILabel label = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Button_Color")); + buttonColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + } + }); + buttonColorSelectBox.setSelectObject(new Color(31, 173, 229)); + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + panel.add(label); + panel.add(buttonColorSelectBox); + centerPane.add(panel); + } + + private void addHeaderLinePane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-Date_Title_Line"))); + + UILabel titleLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_SubTitle_Line")); + showTitleEditor = DesignerUtils.createCheckBox(Toolkit.i18nText("Fine-Plugin-Date_Show_Title_Line"), true); + JPanel headerPanel = new JPanel(); + headerPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + headerPanel.add(titleLabel); + headerPanel.add(showTitleEditor); + centerPane.add(headerPanel); + + final UILabel splitLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Title_Split_Line_Color")); + titleSplitLineColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if(showTitleEditor.isSelected()) { + titleSplitLineColor = titleSplitLineColorSelectBox.getSelectObject(); + } + } + }); + titleSplitLineColorSelectBox.setSelectObject(new Color(234, 234, 234)); + final JPanel splitLineColorPanel = new JPanel(); + splitLineColorPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + splitLineColorPanel.add(splitLabel); + splitLineColorPanel.add(titleSplitLineColorSelectBox); + + + showTitleEditor.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + if(showTitleEditor.isSelected()) { + titleSplitLineColorSelectBox.setSelectObject(titleSplitLineColor); + } else { + titleSplitLineColorSelectBox.setSelectObject(titleSplitLineDisableColor); + } + + titleSplitLineColorSelectBox.setEnabled(showTitleEditor.isSelected()); + splitLabel.setEnabled(showTitleEditor.isSelected()); + } + }); + centerPane.add(splitLineColorPanel); + } + + private void addFontColorPane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-Date_Font"))); + UILabel mainLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Font_Main")); + mainFontColor = new UIColorButton(); + mainFontColor.setColor(new Color(51, 51, 51)); + mainFontColor.setPreferredSize(new Dimension(20, 20)); + + UILabel specialLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Font_Special")); + specialFontColor = new UIColorButton(); + specialFontColor.setColor(new Color(255, 148, 84)); + specialFontColor.setPreferredSize(new Dimension(20, 20)); + + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p}; + double[] columnSize = {p, p}; + JPanel panel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][] { + {mainLabel, mainFontColor}, + {specialLabel, specialFontColor} + }, rowSize, columnSize, 10); + + centerPane.add(panel); + + + UILabel fontSizeLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Font_Size")); + dateFontSize = new UIComboBox(new Integer[]{12, 13, 14, 15, 16, 17, 18}); + dateFontSize.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); + dateFontSize.setSelectedItem(14); + JPanel fontPanel = new JPanel(); + fontPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + fontPanel.add(fontSizeLabel); + fontPanel.add(dateFontSize); + centerPane.add(fontPanel); + } + + private void addArrowPane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-Date_Arrow"))); + UILabel label = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Arrow_Color")); + arrowColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + } + }); + arrowColorSelectBox.setSelectObject(new Color(234, 234, 234)); + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + panel.add(label); + panel.add(arrowColorSelectBox ); + centerPane.add(panel); + } + + private JPanel createCenterPane() { + return FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); + } + + @Override + public void populateBean(MobileStyle ob) { + NavigationMobileStyle mobileStyle = (NavigationMobileStyle) ob; + custom.setSelectedIndex(mobileStyle.isCustom() ? 1 : 0); + expand.setSelectedIndex(mobileStyle.isExpand() ? 1 : 0); + buttonColorSelectBox.setSelectObject(mobileStyle.getButtonBackgroundColor()); + mainFontColor.setColor(mobileStyle.getMainFontColor()); + specialFontColor.setColor(mobileStyle.getSpecialFontColor()); + showTitleEditor.setSelected(mobileStyle.isShowTitleLine()); + if(mobileStyle.isShowTitleLine()) { + titleSplitLineColorSelectBox.setSelectObject(mobileStyle.getTitleSplitLineColor()); + } else { + titleSplitLineColorSelectBox.setSelectObject(titleSplitLineDisableColor); + titleSplitLineColor = mobileStyle.getTitleSplitLineColor(); + } + dateFontSize.setSelectedItem(mobileStyle.getDateFontSize()); + arrowColorSelectBox.setSelectObject(mobileStyle.getArrowColor()); + } + + @Override + public MobileStyle updateBean() { + NavigationMobileStyle mobileStyle = (NavigationMobileStyle)this.widget.getMobileStyle(); + + mobileStyle.setCustom(custom.getSelectedIndex() == 1); + mobileStyle.setExpand(expand.getSelectedIndex() == 1); + mobileStyle.setButtonBackgroundColor(buttonColorSelectBox.getSelectObject()); + mobileStyle.setMainFontColor(mainFontColor.getColor()); + mobileStyle.setSpecialFontColor(specialFontColor.getColor()); + mobileStyle.setShowTitleLine(showTitleEditor.isSelected()); + if(showTitleEditor.isSelected()) { + mobileStyle.setTitleSplitLineColor(titleSplitLineColorSelectBox.getSelectObject()); + } else { + mobileStyle.setTitleSplitLineColor(titleSplitLineColor); + } + mobileStyle.setDateFontSize(Integer.parseInt(dateFontSize.getSelectedItem().toString())); + mobileStyle.setArrowColor(arrowColorSelectBox.getSelectObject()); + return mobileStyle; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/date/SimpleCustomDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/date/SimpleCustomDefinePane.java new file mode 100644 index 0000000000..3a5cb5444a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/date/SimpleCustomDefinePane.java @@ -0,0 +1,230 @@ +package com.fr.design.mainframe.mobile.ui.date; + +import com.fr.design.dialog.AttrScrollPane; +import com.fr.design.dialog.BasicScrollPane; +import com.fr.design.gui.ibutton.UIColorButton; +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.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; +import com.fr.design.mainframe.mobile.utils.DesignerUtils; +import com.fr.design.style.color.NewColorSelectBox; +import com.fr.form.ui.Widget; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.form.ui.mobile.date.SimpleMobileStyle; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +public class SimpleCustomDefinePane extends MobileStyleCustomDefinePane { + + private JPanel scrollPanel; + private UIComboBox custom; + private JPanel centerPane; + + private UIComboBox expand; + private UIComboBox dateFontSize; + private NewColorSelectBox buttonColorSelectBox; + private NewColorSelectBox titleSplitLineColorSelectBox; + private NewColorSelectBox arrowColorSelectBox; + private UIColorButton mainFontColor; + private UIColorButton specialFontColor; + + public SimpleCustomDefinePane(Widget widget) { + super(widget); + } + + @Override + protected JPanel createPreviewPane() { + return null; + } + + @Override + protected void init() { + + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.addScrollPane(); + this.addStyleSelectPane(); + this.addConfigPane(); + + } + + private void addScrollPane() { + scrollPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + BasicScrollPane basicScrollPane = new AttrScrollPane() { + @Override + protected JPanel createContentPane() { + return scrollPanel; + } + }; + this.add(basicScrollPane); + } + + private void addStyleSelectPane() { + JPanel stylePanel = new JPanel(); + stylePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + UILabel buttonStyleLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Style")); + custom = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-Date_Style_Default"), + Toolkit.i18nText("Fine-Plugin-Date_Style_Custom")}); + custom.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); + custom.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + boolean isCustom = custom.getSelectedIndex() == 1; + centerPane.setVisible(isCustom); + + } + }); + stylePanel.add(buttonStyleLabel); + stylePanel.add(custom); + scrollPanel.add(stylePanel, BorderLayout.NORTH); + } + + private void addConfigPane() { + centerPane = createCenterPane(); + centerPane.setVisible(false); + addExpandPane(); + addHeaderLinePane(); + addButtonColorPane(); + addFontColorPane(); + addArrowPane(); + scrollPanel.add(centerPane, BorderLayout.CENTER); + custom.setSelectedIndex(1); + } + + private void addExpandPane() { + UILabel label = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Status")); + expand = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-Date_Status_Collapse"), Toolkit.i18nText("Fine-Plugin-Date_Status_Expand")}); + expand.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + panel.add(label); + panel.add(expand); + centerPane.add(panel); + } + + private void addHeaderLinePane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-Date_Title_Line"))); + UILabel label = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Title_Split_Line_Color")); + titleSplitLineColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + } + }); + titleSplitLineColorSelectBox.setSelectObject(new Color(234, 234, 234)); + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + panel.add(label); + panel.add(titleSplitLineColorSelectBox); + centerPane.add(panel); + } + + private void addButtonColorPane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-Date_Button"))); + UILabel label = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Button_Color")); + buttonColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + } + }); + buttonColorSelectBox.setSelectObject(new Color(31, 173, 229)); + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + panel.add(label); + panel.add(buttonColorSelectBox); + centerPane.add(panel); + } + + private void addFontColorPane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-Date_Font"))); + UILabel mainLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Font_Main")); + mainFontColor = new UIColorButton(); + mainFontColor.setColor(new Color(51, 51, 51)); + mainFontColor.setPreferredSize(new Dimension(20, 20)); + + UILabel specialLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Font_Special")); + specialFontColor = new UIColorButton(); + specialFontColor.setColor(new Color(255, 148, 84)); + specialFontColor.setPreferredSize(new Dimension(20, 20)); + + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p}; + double[] columnSize = {p, p}; + JPanel panel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][] { + {mainLabel, mainFontColor}, + {specialLabel, specialFontColor} + }, rowSize, columnSize, 10); + + centerPane.add(panel); + + UILabel fontSizeLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Font_Size")); + dateFontSize = new UIComboBox(new Integer[]{12, 13, 14, 15, 16, 17, 18}); + dateFontSize.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); + dateFontSize.setSelectedItem(14); + JPanel fontPanel = new JPanel(); + fontPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + fontPanel.add(fontSizeLabel); + fontPanel.add(dateFontSize); + centerPane.add(fontPanel); + } + + private void addArrowPane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-Date_Arrow"))); + UILabel label = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Arrow_Color")); + arrowColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + } + }); + arrowColorSelectBox.setSelectObject(new Color(234, 234, 234)); + JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + panel.add(label); + panel.add(arrowColorSelectBox ); + centerPane.add(panel); + } + + private JPanel createCenterPane() { + return FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); + } + + @Override + public void populateBean(MobileStyle ob) { + SimpleMobileStyle mobileStyle = (SimpleMobileStyle) ob; + custom.setSelectedIndex(mobileStyle.isCustom() ? 1 : 0); + expand.setSelectedIndex(mobileStyle.isExpand() ? 1 : 0); + buttonColorSelectBox.setSelectObject(mobileStyle.getButtonBackgroundColor()); + mainFontColor.setColor(mobileStyle.getMainFontColor()); + specialFontColor.setColor(mobileStyle.getSpecialFontColor()); + titleSplitLineColorSelectBox.setSelectObject(mobileStyle.getTitleSplitLineColor()); + dateFontSize.setSelectedItem(mobileStyle.getDateFontSize()); + arrowColorSelectBox.setSelectObject(mobileStyle.getArrowColor()); + } + + @Override + public MobileStyle updateBean() { + SimpleMobileStyle mobileStyle = (SimpleMobileStyle)this.widget.getMobileStyle(); + + mobileStyle.setCustom(custom.getSelectedIndex() == 1); + mobileStyle.setExpand(expand.getSelectedIndex() == 1); + mobileStyle.setButtonBackgroundColor(buttonColorSelectBox.getSelectObject()); + mobileStyle.setMainFontColor(mainFontColor.getColor()); + mobileStyle.setSpecialFontColor(specialFontColor.getColor()); + mobileStyle.setTitleSplitLineColor(titleSplitLineColorSelectBox.getSelectObject()); + mobileStyle.setDateFontSize(Integer.parseInt(dateFontSize.getSelectedItem().toString())); + mobileStyle.setArrowColor(arrowColorSelectBox.getSelectObject()); + return mobileStyle; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/date/SimpleDateCustomDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/date/SimpleDateCustomDefinePane.java new file mode 100644 index 0000000000..ad79f499e7 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/date/SimpleDateCustomDefinePane.java @@ -0,0 +1,267 @@ +package com.fr.design.mainframe.mobile.ui.date; + +import com.fr.design.dialog.AttrScrollPane; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.icombobox.LineComboBox; +import com.fr.design.gui.icombobox.UIComboBox; +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.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; +import com.fr.design.mainframe.mobile.utils.DesignerUtils; +import com.fr.design.mainframe.mobile.utils.FontConfigPane; +import com.fr.design.mainframe.mobile.utils.IconConfigPane; +import com.fr.design.style.color.NewColorSelectBox; +import com.fr.form.ui.Widget; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.form.ui.mobile.date.ControlStyle; +import com.fr.form.ui.mobile.date.SimpleDateMobileStyle; +import com.fr.stable.Constants; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +public class SimpleDateCustomDefinePane extends MobileStyleCustomDefinePane { + + private JPanel scrollPanel; + private UIComboBox custom; + private JPanel centerPane; + private FontConfigPane labelFontConfigPane; + private FontConfigPane controlValueConfigPane; + private NewColorSelectBox controlBackground; + private LineComboBox controlBorder; + private NewColorSelectBox controlBorderColor; + private UISpinner controlWidgetRadius; + private UISpinner widthSpinner; + private UIRadioButton fillButton; + private UIRadioButton customButton; + private IconConfigPane iconConfigPane; + + public SimpleDateCustomDefinePane(Widget widget) { + super(widget); + } + + @Override + protected JPanel createPreviewPane() { + return null; + } + + @Override + protected void init() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.addScrollPane(); + this.addStyleSelectPane(); + this.addConfigPane(); + } + + private void addScrollPane() { + scrollPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.add(new AttrScrollPane() { + @Override + protected JPanel createContentPane() { + return scrollPanel; + } + }); + } + + private void addStyleSelectPane() { + JPanel stylePanel = new JPanel(); + stylePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + UILabel buttonStyleLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-SimpleDate_Control_Style")); + custom = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-SimpleDate_Style_Default"), + Toolkit.i18nText("Fine-Plugin-SimpleDate_Style_Custom")}); + custom.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); + custom.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + boolean isCustom = custom.getSelectedIndex() == 1; + centerPane.setVisible(isCustom); + + } + }); + stylePanel.add(buttonStyleLabel); + stylePanel.add(custom); + scrollPanel.add(stylePanel, BorderLayout.NORTH); + } + + private void addConfigPane() { + centerPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); + centerPane.setVisible(false); + + addFontConfigPane(); + addIconConfigPane(); + addControlConfigPane(); + + scrollPanel.add(centerPane, BorderLayout.CENTER); + } + + private void addControlConfigPane() { + + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-SimpleDate_Control_Region"))); + controlBackground = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + } + }); + controlBorder = new LineComboBox(DesignerUtils.BORDER_LINE_STYLE_ARRAY); + controlBorder.setSelectedLineStyle(Constants.LINE_THIN); + controlBorder.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); + controlBorderColor = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + } + }); + controlWidgetRadius = new UISpinner(0, Integer.MAX_VALUE, 1, 2); + controlWidgetRadius.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); + + JComponent[] controlComponents = new JComponent[]{controlBackground, controlBorder, controlBorderColor, controlWidgetRadius}; + String[] comboBoxNames = new String[]{ + Toolkit.i18nText("Fine-Plugin-SimpleDate_Control_Background"), + Toolkit.i18nText("Fine-Plugin-SimpleDate_Control_Border"), + Toolkit.i18nText("Fine-Plugin-SimpleDate_Border_Color"), + Toolkit.i18nText("Fine-Plugin-SimpleDate_Radius") + }; + + Component[][] components = new Component[4][]; + + for (int i = 0; i < 4; i++) { + UILabel label = DesignerUtils.createConfigLabel(comboBoxNames[i]); + components[i] = new Component[]{label, controlComponents[i]}; + } + + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p, p, p}; + double[] columnSize = {p, p}; + JPanel controlPanel = TableLayoutHelper.createCommonTableLayoutPane(components, rowSize, columnSize, 10); + centerPane.add(controlPanel); + + this.fillButton = new UIRadioButton(Toolkit.i18nText("Fine-Plugin-SimpleDate_Horizontal_Fill")); + this.customButton = new UIRadioButton(Toolkit.i18nText("Fine-Plugin-SimpleDate_Width_Custom")); + + ButtonGroup buttonGroup = new ButtonGroup(); + buttonGroup.add(fillButton); + buttonGroup.add(customButton); + + JPanel panel = new JPanel(); + panel.add(fillButton); + panel.add(customButton); + panel.setLayout(new GridLayout(0, 2, 14, 0)); + panel.setPreferredSize(new Dimension(174, 20)); + fillButton.setSelected(true); + + ActionListener listener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + widthSpinner.setVisible(customButton.isSelected()); + } + }; + + fillButton.addActionListener(listener); + customButton.addActionListener(listener); + + UILabel label = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-SimpleDate_Width")); + widthSpinner = new UISpinner(1, Integer.MAX_VALUE, 1, 200); + widthSpinner.setPreferredSize(new Dimension(78, 20)); + widthSpinner.setVisible(false); + centerPane.add(DesignerUtils.createLeftRightComponentsPane(label, panel, widthSpinner)); + + } + + private void addFontConfigPane() { + + String[] titleSplitLineNames = new String[]{ + Toolkit.i18nText("Fine-Plugin-SimpleDate_Label_Name"), + Toolkit.i18nText("Fine-Plugin-SimpleDate_Control_Value") + }; + labelFontConfigPane = new FontConfigPane(); + controlValueConfigPane = new FontConfigPane(); + FontConfigPane[] fontConfigPanes = new FontConfigPane[]{labelFontConfigPane, controlValueConfigPane}; + for (int i = 0; i < 2; i++) { + centerPane.add(DesignerUtils.createTitleSplitLine(titleSplitLineNames[i])); + UILabel fontLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-SimpleDate_Character")); + JPanel fontPanel = DesignerUtils.createLeftRightComponentsPane(fontLabel, fontConfigPanes[i]); + centerPane.add(fontPanel); + } + } + + private void addIconConfigPane() { + + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-SimpleDate_Icon"))); + UILabel tipLabel = new UILabel(); + tipLabel.setFont(new Font(tipLabel.getName(), Font.PLAIN, 10)); + tipLabel.setSize(470, 40); + tipLabel.setText(Toolkit.i18nText("Fine-Plugin-SimpleDate_Tip")); + tipLabel.setForeground(Color.decode("#9B9B9B")); + centerPane.add(tipLabel); + + JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); + panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + + + iconConfigPane = new IconConfigPane(); + centerPane.add(iconConfigPane); + + } + + @Override + public void populateBean(MobileStyle mobileStyle) { + SimpleDateMobileStyle simpleDateMobileStyle = (SimpleDateMobileStyle) mobileStyle; + custom.setSelectedIndex(simpleDateMobileStyle.isCustom() ? 1 : 0); + iconConfigPane.populate(simpleDateMobileStyle.getIconValue()); + labelFontConfigPane.populate(simpleDateMobileStyle.getLabelFontStyle()); + controlValueConfigPane.populate(simpleDateMobileStyle.getValueFontStyle()); + + ControlStyle controlStyle = simpleDateMobileStyle.getControlStyle(); + + if (controlStyle != null) { + controlBackground.setSelectObject(controlStyle.getBackground()); + controlBorderColor.setSelectObject(controlStyle.getBorderColor()); + controlBorder.setSelectedLineStyle(controlStyle.getBorderType()); + controlWidgetRadius.setValue(controlStyle.getBorderRadius()); + if (controlStyle.isCustomWidth()) { + widthSpinner.setVisible(true); + widthSpinner.setValue(controlStyle.getWidth()); + customButton.setSelected(true); + fillButton.setSelected(false); + } else { + widthSpinner.setVisible(false); + customButton.setSelected(false); + fillButton.setSelected(true); + } + } + + } + + @Override + public MobileStyle updateBean() { + SimpleDateMobileStyle simpleDateMobileStyle = (SimpleDateMobileStyle) this.widget.getMobileStyle(); + simpleDateMobileStyle.setCustom(custom.getSelectedIndex() == 1); + simpleDateMobileStyle.setIconValue(iconConfigPane.update()); + simpleDateMobileStyle.setLabelFontStyle(labelFontConfigPane.update()); + simpleDateMobileStyle.setValueFontStyle(controlValueConfigPane.update()); + ControlStyle controlStyle = new ControlStyle(); + controlStyle.setBackground(controlBackground.getSelectObject()); + controlStyle.setBorderColor(controlBorderColor.getSelectObject()); + controlStyle.setBorderType(controlBorder.getSelectedLineStyle()); + controlStyle.setBorderRadius(controlWidgetRadius.getValue()); + controlStyle.setCustomWidth(customButton.isSelected()); + controlStyle.setWidth(widthSpinner.getValue()); + simpleDateMobileStyle.setControlStyle(controlStyle); + return simpleDateMobileStyle; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/CapsuleCustomDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/CapsuleCustomDefinePane.java new file mode 100644 index 0000000000..072a7a57a1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/CapsuleCustomDefinePane.java @@ -0,0 +1,310 @@ +package com.fr.design.mainframe.mobile.ui.radiogroup; + +import com.fr.design.constants.LayoutConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.dialog.AttrScrollPane; +import com.fr.design.dialog.BasicScrollPane; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.icombobox.LineComboBox; +import com.fr.design.gui.icombobox.UIComboBox; +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.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; +import com.fr.design.mainframe.mobile.utils.DesignerUtils; +import com.fr.design.mainframe.mobile.utils.FontConfigPane; +import com.fr.design.style.color.NewColorSelectBox; +import com.fr.form.ui.Widget; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.form.ui.mobile.radiogroup.CapsuleMobileStyle; +import com.fr.general.FRFont; +import com.fr.stable.Constants; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +public class CapsuleCustomDefinePane extends MobileStyleCustomDefinePane { + + private JPanel scrollPanel; + private UIComboBox custom; + private JPanel centerPane; + + private UISpinner leftSpinner; + private UISpinner rightSpinner; + private UISpinner topSpinner; + private UISpinner bottomSpinner; + + private JRadioButton leftAlignRadioButton; + private JRadioButton centerAlignRadioButton; + + private NewColorSelectBox initialColorSelectBox; + private NewColorSelectBox selectedColorSelectBox; + + private LineComboBox borderLineCombo; + private NewColorSelectBox initialBorderColor; + private NewColorSelectBox selectedBorderColor; + private UISpinner borderRadiusSpinner; + + private FontConfigPane initialFontConfPane; + private UIColorButton selectedFontColor; + + + public CapsuleCustomDefinePane(Widget widget) { + super(widget); + } + + @Override + protected JPanel createPreviewPane() { + return null; + } + + @Override + protected void init() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.addScrollPane(); + this.addStyleSelectPane(); + this.addConfigPane(); + } + + private void addScrollPane() { + scrollPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + BasicScrollPane basicScrollPane = new AttrScrollPane() { + @Override + protected JPanel createContentPane() { + return scrollPanel; + } + }; + this.add(basicScrollPane); + } + + private void addStyleSelectPane() { + JPanel stylePanel = new JPanel(); + stylePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + UILabel buttonStyleLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Style")); + custom = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-RadioGroup_Style_Default"), + Toolkit.i18nText("Fine-Plugin-RadioGroup_Style_Custom")}); + custom.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); + custom.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + boolean isCustom = custom.getSelectedIndex() == 1; + centerPane.setVisible(isCustom); + + } + }); + stylePanel.add(buttonStyleLabel); + stylePanel.add(custom); + scrollPanel.add(stylePanel, BorderLayout.NORTH); + } + + private void addConfigPane() { + centerPane = createCenterPane(); + centerPane.setVisible(false); + + addPaddingPane(); + addBackgroundPane(); + addBorderPane(); + addFontPane(); + + scrollPanel.add(centerPane, BorderLayout.CENTER); + custom.setSelectedIndex(1); + } + + private JPanel createCenterPane() { + return FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); + } + + private void addPaddingPane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Layout"))); + + UILabel paddingHintLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Button_Padding")); + UILabel emptyHintLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("")); + UILabel buttonAlignHintLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Alignment")); + + UILabel leftLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Left")); + leftSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultHorizontalPadding); + + UILabel rightLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Right")); + rightSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultHorizontalPadding); + + UILabel topLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Top")); + topSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultVerticalPadding); + + UILabel bottomLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Bottom")); + bottomSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultVerticalPadding); + + leftAlignRadioButton = new JRadioButton(Toolkit.i18nText("Fine-Plugin-RadioGroup_Alignment_Left"), true); + centerAlignRadioButton = new JRadioButton(Toolkit.i18nText("Fine-Plugin-RadioGroup_Alignment_Center"), false); + + JPanel leftSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{leftLabel, leftSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL); + JPanel rightSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{rightLabel, rightSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL); + JPanel topSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{topLabel, topSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL); + JPanel bottomSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{bottomLabel, bottomSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL); + + JPanel vPaddingSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{topSpinnerPanel, bottomSpinnerPanel}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, LayoutConstants.VGAP_SMALL); + + JPanel hPaddingSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{leftSpinnerPanel, rightSpinnerPanel}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, LayoutConstants.VGAP_SMALL); + + JPanel layoutPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{leftAlignRadioButton, centerAlignRadioButton}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, LayoutConstants.VGAP_SMALL); + + ButtonGroup layoutRadioButtonGroup = new ButtonGroup(); + layoutRadioButtonGroup.add(leftAlignRadioButton); + layoutRadioButtonGroup.add(centerAlignRadioButton); + + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p, p}; + double[] columnSize = {p, p}; + JPanel paddingPanel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{ + {paddingHintLabel, vPaddingSpinnerPanel}, + {emptyHintLabel, hPaddingSpinnerPanel}, + {buttonAlignHintLabel, layoutPanel}, + }, rowSize, columnSize, 10); + centerPane.add(paddingPanel); + } + + private void addBackgroundPane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Background"))); + + UILabel initialColorLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Background_Init")); + initialColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + } + }); + initialColorSelectBox.setSelectObject(new Color(244, 244, 244)); + JPanel initialColorSelectPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initialColorLabel, initialColorSelectBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); + centerPane.add(initialColorSelectPane); + + UILabel selectedColorLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Background_Select")); + selectedColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + + } + }); + selectedColorSelectBox.setSelectObject(new Color(31, 173, 229)); + JPanel selectedColorSelectPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectedColorLabel, selectedColorSelectBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); + centerPane.add(selectedColorSelectPane); + } + + private void addBorderPane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border"))); + + UILabel borderTypeLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border_Line")); + borderLineCombo = new LineComboBox(DesignerUtils.BORDER_LINE_STYLE_ARRAY); + borderLineCombo.setSelectedLineStyle(Constants.LINE_THIN); + + UILabel initialColorLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border_Init_Color")); + initialBorderColor = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + } + }); + initialBorderColor.setSelectObject(new Color(244, 244, 244)); + + UILabel selectedColorLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border_Select_Color")); + selectedBorderColor = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + } + }); + selectedBorderColor.setSelectObject(new Color(31, 173, 229)); + + UILabel radiusLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border_Radius")); + borderRadiusSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, 20); + borderRadiusSpinner.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); + + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p, p, p}; + double[] columnSize = {p, p}; + JPanel borderPanel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{ + {borderTypeLabel, borderLineCombo}, + {initialColorLabel, initialBorderColor}, + {selectedColorLabel, selectedBorderColor}, + {radiusLabel, borderRadiusSpinner} + }, rowSize, columnSize, 10); + + centerPane.add(borderPanel); + + } + + private void addFontPane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font"))); + + UILabel initialFontLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font_init")); + initialFontConfPane = new FontConfigPane(); + initialFontConfPane.setFontColor(new Color(204, 204, 204)); + JPanel fontPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initialFontLabel, initialFontConfPane}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); + centerPane.add(fontPanel); + UILabel selectedFontLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font_Select")); + selectedFontColor = new UIColorButton(); + selectedFontColor.setColor(Color.WHITE); + selectedFontColor.setPreferredSize(new Dimension(20, 20)); + JPanel selectFontColorPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectedFontLabel, selectedFontColor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); + centerPane.add(selectFontColorPanel); + + } + + @Override + public void populateBean(MobileStyle ob) { + CapsuleMobileStyle mobileStyle = (CapsuleMobileStyle) ob; + custom.setSelectedIndex(mobileStyle.isCustom() ? 1 : 0); + leftSpinner.setValue(mobileStyle.getLeftPadding()); + rightSpinner.setValue(mobileStyle.getRightPadding()); + topSpinner.setValue(mobileStyle.getTopPadding()); + bottomSpinner.setValue(mobileStyle.getBottomPadding()); + leftAlignRadioButton.setSelected(mobileStyle.getButtonAlign() == DesignerUtils.kAlignLeft); + centerAlignRadioButton.setSelected(mobileStyle.getButtonAlign() == DesignerUtils.kAlignCenter); + initialColorSelectBox.setSelectObject(mobileStyle.getInitialBackgroundColor()); + selectedColorSelectBox.setSelectObject(mobileStyle.getSelectedBackgroundColor()); + borderLineCombo.setSelectedLineStyle(mobileStyle.getBorderType()); + initialBorderColor.setSelectObject(mobileStyle.getInitialBorderColor()); + selectedBorderColor.setSelectObject(mobileStyle.getSelectedBorderColor()); + borderRadiusSpinner.setValue(mobileStyle.getBorderRadius()); + if (mobileStyle.getInitialFont() != null) { + initialFontConfPane.populate(mobileStyle.getInitialFont()); + } + if (mobileStyle.getSelectedFont() != null) { + selectedFontColor.setColor(mobileStyle.getSelectedFont().getForeground()); + } + } + + @Override + public MobileStyle updateBean() { + CapsuleMobileStyle mobileStyle = (CapsuleMobileStyle) this.widget.getMobileStyle(); + + mobileStyle.setCustom(custom.getSelectedIndex() == 1); + mobileStyle.setLeftPadding(leftSpinner.getValue()); + mobileStyle.setRightPadding(rightSpinner.getValue()); + mobileStyle.setTopPadding(topSpinner.getValue()); + mobileStyle.setBottomPadding(bottomSpinner.getValue()); + mobileStyle.setButtonAlign(leftAlignRadioButton.isSelected() ? DesignerUtils.kAlignLeft : DesignerUtils.kAlignCenter); + mobileStyle.setInitialBackgroundColor(initialColorSelectBox.getSelectObject()); + mobileStyle.setSelectedBackgroundColor(selectedColorSelectBox.getSelectObject()); + mobileStyle.setBorderType(borderLineCombo.getSelectedLineStyle()); + mobileStyle.setInitialBorderColor(initialBorderColor.getSelectObject()); + mobileStyle.setSelectedBorderColor(selectedBorderColor.getSelectObject()); + mobileStyle.setBorderRadius(borderRadiusSpinner.getValue()); + + FRFont initialFont = initialFontConfPane.updateFont(null, null, null); + FRFont selectedFont = initialFontConfPane.updateFont(selectedFontColor.getColor(), null, null); + + mobileStyle.setInitialFont(initialFont); + mobileStyle.setSelectedFont(selectedFont); + + return mobileStyle; + } + + @Override + protected String title4PopupWindow() { + return null; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/IconConfigPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/IconConfigPane.java new file mode 100644 index 0000000000..08e0ecd09a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/IconConfigPane.java @@ -0,0 +1,195 @@ +package com.fr.design.mainframe.mobile.ui.radiogroup; + +import com.fr.base.IconManager; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.utils.DrawRoutines; +import com.fr.design.web.CustomIconPane; +import com.fr.form.ui.WidgetInfoConfig; +import com.fr.general.ComparatorUtils; +import com.fr.general.FRFont; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.plaf.basic.BasicButtonUI; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; + +public class IconConfigPane extends JPanel { + private UIButton editIconButton; + private UIButton deleteIconButton; + private String curIconName; + private IconButton selectIconButton; + private ArrayList iconButtons = new ArrayList(); + + public IconConfigPane(int count) { + initComp(count); + } + + public void initComp(int count) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); + panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); + editIconButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Edit")); + editIconButton.setFont(FRFont.getInstance("Helvetica", Font.PLAIN, 12, Color.decode("#3A383A"))); + editIconButton.setPreferredSize(new Dimension(62, 20)); + panel.add(editIconButton); + editIconButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + final CustomIconPane cip = new CustomIconPane(){ + protected String createDescriptionText(){ + return Toolkit.i18nText("Fine-Design_Mobile_Custom_Icon_Message"); + } + }; + BasicDialog editDialog = cip.showWindow(DesignerContext.getDesignerFrame()); + editDialog.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + curIconName = cip.update(); + setShowIconImage(); + IconConfigPane.this.repaint(); + } + }); + editDialog.setVisible(true); + } + }); + editIconButton.setEnabled(false); + + deleteIconButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Delete")); + deleteIconButton.setFont(FRFont.getInstance("Helvetica", Font.PLAIN, 12, Color.decode("#3A383A"))); + deleteIconButton.setPreferredSize(new Dimension(62, 20)); + panel.add(deleteIconButton); + deleteIconButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + selectIconButton.setIconName(StringUtils.EMPTY); + IconConfigPane.this.repaint(); + } + }); + deleteIconButton.setEnabled(false); + + + this.add(panel, BorderLayout.CENTER); + + JPanel northPane = new JPanel(); + northPane.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + for (int i = 0; i < count; i++) { + IconButton iconButton = new IconButton(""); + northPane.add(iconButton); + iconButtons.add(iconButton); + } + this.add(northPane, BorderLayout.NORTH); + } + + public void setShowIconImage() { + selectIconButton.setIconName(curIconName); + } + + public void populate(ArrayList iconArr) { + for (int i = 0; i < iconButtons.size(); i++) { + iconButtons.get(i).setIconName(iconArr.get(i)); + } + } + + public ArrayList update() { + ArrayList iconNames = new ArrayList(); + for (int i = 0; i < iconButtons.size(); i++) { + iconNames.add(iconButtons.get(i).getIconName()); + } + return iconNames; + } + + + private class IconButton extends JToggleButton implements ActionListener { + private String iconName; + private Image iconImage = null; + private static final int ICON_BUTTON_SIZE = 20; + private static final int ICON_X = 2; + private static final int ICON_Y = 2; + + public IconButton(String name) { + this.iconName = name; + this.addActionListener(this); + this.setBackground(Color.WHITE); + this.setCursor(new Cursor(Cursor.HAND_CURSOR)); + this.iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(name); + } + + @Override + public void updateUI() { + setUI(new BasicButtonUI() { + public void paint(Graphics g, JComponent c) { + super.paint(g, c); + } + }); + } + + protected void paintBorder(Graphics g) { + super.paintBorder(g); + if (ComparatorUtils.equals(this, selectIconButton)) { + DrawRoutines.drawRoundedBorder( + g, Color.decode("#419BF9"), 0, 0, 20, 20); + } else { + DrawRoutines.drawRoundedBorder( + g, Color.decode("#D9DADD"), 0, 0, 20, 20); + } + + } + + public String getIconName() { + return iconName; + } + + public void setIconName(String iconName) { + this.iconName = iconName; + this.iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(iconName); + } + + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + Graphics2D g2d = (Graphics2D) g; + // carl:这里缩放显示 16 × 16 + if (iconImage != null) { + g2d.drawImage(iconImage, ICON_X, ICON_Y, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null); + } + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(ICON_BUTTON_SIZE, ICON_BUTTON_SIZE); + } + + public void actionPerformed(ActionEvent evt) { + selectIconButton = this; + editIconButton.setEnabled(true); + if(StringUtils.isNotEmpty(this.iconName)) { + deleteIconButton.setEnabled(true); + } else { + deleteIconButton.setEnabled(false); + } + IconConfigPane.this.repaint();// repaint + } + + @Override + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + private void fireChagneListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } + + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/ImageCustomDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/ImageCustomDefinePane.java new file mode 100644 index 0000000000..7288d3263c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/ImageCustomDefinePane.java @@ -0,0 +1,242 @@ +package com.fr.design.mainframe.mobile.ui.radiogroup; + +import com.fr.base.BaseUtils; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.dialog.AttrScrollPane; +import com.fr.design.dialog.BasicScrollPane; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.ibutton.UIToggleButton; +import com.fr.design.gui.icombobox.UIComboBox; +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.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; +import com.fr.design.mainframe.mobile.utils.DesignerUtils; +import com.fr.design.mainframe.mobile.utils.FontConfigPane; +import com.fr.form.ui.Widget; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.form.ui.mobile.radiogroup.ImageMobileStyle; +import com.fr.general.FRFont; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.Arrays; + +public class ImageCustomDefinePane extends MobileStyleCustomDefinePane { + + private static final Icon[] BOLD_ICONS = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold_white.png")}; + + private JPanel scrollPanel; + private UIComboBox custom; + private JPanel centerPane; + + private UISpinner leftSpinner; + private UISpinner rightSpinner; + private UISpinner topSpinner; + private UISpinner bottomSpinner; + + private IconConfigPane initialIconConfigPane; + private IconConfigPane selectedIconConfigPane; + + private FontConfigPane initialFontConfPane; + private UIColorButton selectedFontColor; + private UIToggleButton selectedFontBold; + + public ImageCustomDefinePane(Widget widget) { + super(widget); + } + + @Override + protected JPanel createPreviewPane() { + return null; + } + + @Override + protected void init() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.addScrollPane(); + this.addStyleSelectPane(); + this.addConfigPane(); + } + + private void addScrollPane() { + scrollPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + BasicScrollPane basicScrollPane = new AttrScrollPane() { + @Override + protected JPanel createContentPane() { + return scrollPanel; + } + }; + this.add(basicScrollPane); + } + + private void addStyleSelectPane() { + JPanel stylePanel = new JPanel(); + stylePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + UILabel buttonStyleLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Style")); + custom = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-RadioGroup_Style_Default"), + Toolkit.i18nText("Fine-Plugin-RadioGroup_Style_Custom")}); + custom.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); + custom.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + boolean isCustom = custom.getSelectedIndex() == 1; + centerPane.setVisible(isCustom); + + } + }); + stylePanel.add(buttonStyleLabel); + stylePanel.add(custom); + scrollPanel.add(stylePanel, BorderLayout.NORTH); + } + + private void addConfigPane() { + centerPane = createCenterPane(); + centerPane.setVisible(false); + + addPaddingPane(); + + addIconPane(); + + addFontPane(); + + scrollPanel.add(centerPane, BorderLayout.CENTER); + custom.setSelectedIndex(1); + } + + private JPanel createCenterPane() { + return FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); + } + + private void addPaddingPane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Layout"))); + + UILabel paddingHintLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Button_Padding")); + UILabel emptyHintLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("")); + + UILabel leftLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Left")); + leftSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultHorizontalPadding); + + UILabel rightLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Right")); + rightSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultHorizontalPadding); + + UILabel topLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Top")); + topSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultVerticalPadding); + + UILabel bottomLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Bottom")); + bottomSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultVerticalPadding); + + JPanel leftSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{leftLabel, leftSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL); + JPanel rightSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{rightLabel, rightSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL); + JPanel topSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{topLabel, topSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL); + JPanel bottomSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{bottomLabel, bottomSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL); + + JPanel vPaddingSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{topSpinnerPanel, bottomSpinnerPanel}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, LayoutConstants.VGAP_SMALL); + JPanel hPaddingSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{leftSpinnerPanel, rightSpinnerPanel}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, LayoutConstants.VGAP_SMALL); + + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p}; + double[] columnSize = {p, p}; + JPanel paddingPanel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{ + {paddingHintLabel, vPaddingSpinnerPanel}, + {emptyHintLabel, hPaddingSpinnerPanel}, + }, rowSize, columnSize, 10); + + centerPane.add(paddingPanel); + } + + private void addIconPane() { + + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Icon"))); + + UILabel initialLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Icon_Init")); + UILabel selectedLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Icon_Select")); + + initialIconConfigPane = new IconConfigPane(8); + selectedIconConfigPane = new IconConfigPane(8); + + JPanel container = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 5); + + JPanel initialPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + initialPane.add(initialLabel); + initialPane.add(initialIconConfigPane); + container.add(initialPane); + + JPanel selectedPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + selectedPane.add(selectedLabel); + selectedPane.add(selectedIconConfigPane); + container.add(selectedPane); + + centerPane.add(container); + + } + + private void addFontPane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font"))); + + UILabel initialFontLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font_init")); + initialFontConfPane = new FontConfigPane(); + initialFontConfPane.setFontColor(new Color(204, 204, 204)); + JPanel fontPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initialFontLabel, initialFontConfPane}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); + centerPane.add(fontPanel); + UILabel selectedFontLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font_Select")); + selectedFontColor = new UIColorButton(); + selectedFontColor.setColor(new Color(31, 173, 229)); + selectedFontColor.setPreferredSize(new Dimension(20, 20)); + selectedFontBold = new UIToggleButton(BOLD_ICONS, true); + selectedFontBold.setPreferredSize(new Dimension(20, 20)); + JPanel selectFontColorPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectedFontLabel, selectedFontColor, selectedFontBold}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); + centerPane.add(selectFontColorPanel); + + } + + @Override + public void populateBean(MobileStyle ob) { + ImageMobileStyle mobileStyle = (ImageMobileStyle) ob; + custom.setSelectedIndex(mobileStyle.isCustom() ? 1 : 0); + leftSpinner.setValue(mobileStyle.getLeftPadding()); + rightSpinner.setValue(mobileStyle.getRightPadding()); + topSpinner.setValue(mobileStyle.getTopPadding()); + bottomSpinner.setValue(mobileStyle.getBottomPadding()); + initialIconConfigPane.populate(new ArrayList<>(Arrays.asList(mobileStyle.getInitialIconNames()))); + selectedIconConfigPane.populate(new ArrayList<>(Arrays.asList(mobileStyle.getSelectedIconNames()))); + if(mobileStyle.getInitialFont() != null) { + initialFontConfPane.populate(mobileStyle.getInitialFont()); + } + if(mobileStyle.getSelectedFont() != null) { + selectedFontColor.setColor(mobileStyle.getSelectedFont().getForeground()); + selectedFontBold.setSelected(mobileStyle.getSelectedFont().isBold()); + } + } + + @Override + public MobileStyle updateBean() { + ImageMobileStyle mobileStyle = (ImageMobileStyle)this.widget.getMobileStyle(); + mobileStyle.setCustom(custom.getSelectedIndex() == 1); + mobileStyle.setLeftPadding(leftSpinner.getValue()); + mobileStyle.setRightPadding(rightSpinner.getValue()); + mobileStyle.setTopPadding(topSpinner.getValue()); + mobileStyle.setBottomPadding(bottomSpinner.getValue()); + ArrayList initialIconNamesList = initialIconConfigPane.update(); + ArrayList selectedIconNamesList = selectedIconConfigPane.update(); + mobileStyle.setInitialIconNames(initialIconNamesList.toArray(new String[initialIconNamesList.size()])); + mobileStyle.setSelectedIconNames(selectedIconNamesList.toArray(new String[selectedIconNamesList.size()])); + FRFont initialFont = initialFontConfPane.updateFont(null, null, null); + FRFont selectedFont = initialFontConfPane.updateFont(selectedFontColor.getColor(), selectedFontBold.isSelected(), null); + mobileStyle.setInitialFont(initialFont); + mobileStyle.setSelectedFont(selectedFont); + return mobileStyle; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/UnitedCustomDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/UnitedCustomDefinePane.java new file mode 100644 index 0000000000..8d9b425740 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/UnitedCustomDefinePane.java @@ -0,0 +1,279 @@ +package com.fr.design.mainframe.mobile.ui.radiogroup; + +import com.fr.design.constants.LayoutConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.dialog.AttrScrollPane; +import com.fr.design.dialog.BasicScrollPane; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.icombobox.LineComboBox; +import com.fr.design.gui.icombobox.UIComboBox; +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.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; +import com.fr.design.mainframe.mobile.utils.DesignerUtils; +import com.fr.design.mainframe.mobile.utils.FontConfigPane; +import com.fr.design.style.color.NewColorSelectBox; +import com.fr.form.ui.Widget; +import com.fr.form.ui.mobile.MobileStyle; +import com.fr.form.ui.mobile.radiogroup.UnitedMobileStyle; +import com.fr.general.FRFont; +import com.fr.stable.Constants; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +public class UnitedCustomDefinePane extends MobileStyleCustomDefinePane { + + private JPanel scrollPanel; + private UIComboBox custom; + private JPanel centerPane; + + private UISpinner leftSpinner; + private UISpinner rightSpinner; + private UISpinner topSpinner; + private UISpinner bottomSpinner; + + private NewColorSelectBox initialColorSelectBox; + private NewColorSelectBox selectedColorSelectBox; + + private LineComboBox borderLineCombo; + private NewColorSelectBox borderColor; + private UISpinner borderRadiusSpinner; + + private FontConfigPane initialFontConfPane; + private UIColorButton selectedFontColor; + + public UnitedCustomDefinePane(Widget widget) { + super(widget); + } + + @Override + protected JPanel createPreviewPane() { + return null; + } + + @Override + protected void init() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.addScrollPane(); + this.addStyleSelectPane(); + this.addConfigPane(); + } + + private void addScrollPane() { + scrollPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + BasicScrollPane basicScrollPane = new AttrScrollPane() { + @Override + protected JPanel createContentPane() { + return scrollPanel; + } + }; + this.add(basicScrollPane); + } + + private void addStyleSelectPane() { + JPanel stylePanel = new JPanel(); + stylePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + UILabel buttonStyleLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Style")); + custom = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-RadioGroup_Style_Default"), + Toolkit.i18nText("Fine-Plugin-RadioGroup_Style_Custom")}); + custom.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); + custom.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + boolean isCustom = custom.getSelectedIndex() == 1; + centerPane.setVisible(isCustom); + } + }); + stylePanel.add(buttonStyleLabel); + stylePanel.add(custom); + scrollPanel.add(stylePanel, BorderLayout.NORTH); + } + + private void addConfigPane() { + centerPane = createCenterPane(); + centerPane.setVisible(false); + + addPaddingPane(); + addBackgroundPane(); + addBorderPane(); + addFontPane(); + + scrollPanel.add(centerPane, BorderLayout.CENTER); + custom.setSelectedIndex(1); + } + + private JPanel createCenterPane() { + return FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); + } + + private void addPaddingPane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Layout"))); + + UILabel paddingHintLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Button_Padding")); + UILabel emptyHintLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("")); + + UILabel leftLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Left")); + leftSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultHorizontalPadding); + + UILabel rightLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Right")); + rightSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultHorizontalPadding); + + UILabel topLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Top")); + topSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultVerticalPadding); + + UILabel bottomLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Bottom")); + bottomSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultVerticalPadding); + + JPanel leftSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{leftLabel, leftSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL); + JPanel rightSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{rightLabel, rightSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL); + JPanel topSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{topLabel, topSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL); + JPanel bottomSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{bottomLabel, bottomSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL); + + JPanel vPaddingSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{topSpinnerPanel, bottomSpinnerPanel}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, LayoutConstants.VGAP_SMALL); + JPanel hPaddingSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{leftSpinnerPanel, rightSpinnerPanel}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, LayoutConstants.VGAP_SMALL); + + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p}; + double[] columnSize = {p, p}; + JPanel paddingPanel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{ + {paddingHintLabel, vPaddingSpinnerPanel}, + {emptyHintLabel, hPaddingSpinnerPanel}, + }, rowSize, columnSize, 10); + + centerPane.add(paddingPanel); + } + + private void addBackgroundPane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Background"))); + + UILabel initialColorLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Background_Init")); + initialColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + } + }); + initialColorSelectBox.setSelectObject(Color.WHITE); + JPanel initialColorSelectPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initialColorLabel, initialColorSelectBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); + centerPane.add(initialColorSelectPane); + + UILabel selectedColorLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Background_Select")); + selectedColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + + } + }); + selectedColorSelectBox.setSelectObject(new Color(31, 173, 229)); + JPanel selectedColorSelectPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectedColorLabel, selectedColorSelectBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); + centerPane.add(selectedColorSelectPane); + } + + private void addBorderPane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border"))); + + UILabel borderTypeLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border_Line")); + borderLineCombo = new LineComboBox(DesignerUtils.BORDER_LINE_STYLE_ARRAY); + borderLineCombo.setSelectedLineStyle(Constants.LINE_THIN); + + UILabel colorLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border_Color")); + borderColor = DesignerUtils.createNormalColorSelectBox(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + } + }); + borderColor.setSelectObject(new Color(31, 173, 229) ); + + UILabel radiusLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border_Radius")); + borderRadiusSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, 2); + borderRadiusSpinner.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20)); + + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p, p}; + double[] columnSize = {p, p}; + JPanel borderPanel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][] { + {borderTypeLabel, borderLineCombo}, + {colorLabel, borderColor}, + {radiusLabel, borderRadiusSpinner} + }, rowSize, columnSize, 10); + + centerPane.add(borderPanel); + + } + + private void addFontPane() { + centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font"))); + + UILabel initialFontLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font_init")); + initialFontConfPane = new FontConfigPane(); + initialFontConfPane.setFontColor(new Color(31, 173, 229)); + JPanel fontPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initialFontLabel, initialFontConfPane}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); + centerPane.add(fontPanel); + UILabel selectedFontLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font_Select")); + selectedFontColor = new UIColorButton(); + selectedFontColor.setPreferredSize(new Dimension(20, 20)); + selectedFontColor.setColor(Color.WHITE); + JPanel selectFontColorPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectedFontLabel, selectedFontColor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); + centerPane.add(selectFontColorPanel); + + } + + @Override + public void populateBean(MobileStyle ob) { + UnitedMobileStyle mobileStyle = (UnitedMobileStyle) ob; + custom.setSelectedIndex(mobileStyle.isCustom() ? 1 : 0); + leftSpinner.setValue(mobileStyle.getLeftPadding()); + rightSpinner.setValue(mobileStyle.getRightPadding()); + topSpinner.setValue(mobileStyle.getTopPadding()); + bottomSpinner.setValue(mobileStyle.getBottomPadding()); + initialColorSelectBox.setSelectObject(mobileStyle.getInitialBackgroundColor()); + selectedColorSelectBox.setSelectObject(mobileStyle.getSelectedBackgroundColor()); + borderLineCombo.setSelectedLineStyle(mobileStyle.getBorderType()); + borderColor.setSelectObject(mobileStyle.getBorderColor()); + borderRadiusSpinner.setValue(mobileStyle.getBorderRadius()); + if(mobileStyle.getInitialFont() != null) { + initialFontConfPane.populate(mobileStyle.getInitialFont()); + } + if(mobileStyle.getSelectedFont() != null) { + selectedFontColor.setColor(mobileStyle.getSelectedFont().getForeground()); + } + } + + @Override + public MobileStyle updateBean() { + UnitedMobileStyle mobileStyle = (UnitedMobileStyle)this.widget.getMobileStyle(); + + mobileStyle.setCustom(custom.getSelectedIndex() == 1); + mobileStyle.setLeftPadding(leftSpinner.getValue()); + mobileStyle.setRightPadding(rightSpinner.getValue()); + mobileStyle.setTopPadding(topSpinner.getValue()); + mobileStyle.setBottomPadding(bottomSpinner.getValue()); + mobileStyle.setInitialBackgroundColor(initialColorSelectBox.getSelectObject()); + mobileStyle.setSelectedBackgroundColor(selectedColorSelectBox.getSelectObject()); + mobileStyle.setBorderType(borderLineCombo.getSelectedLineStyle()); + mobileStyle.setBorderColor(borderColor.getSelectObject()); + mobileStyle.setBorderRadius(borderRadiusSpinner.getValue()); + + FRFont initialFont = initialFontConfPane.updateFont(null, null, null); + FRFont selectedFont = initialFontConfPane.updateFont(selectedFontColor.getColor(), null, null); + selectedFont.setForeground(selectedFontColor.getColor()); + + mobileStyle.setInitialFont(initialFont); + mobileStyle.setSelectedFont(selectedFont); + + return mobileStyle; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java new file mode 100644 index 0000000000..7f19bd3683 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java @@ -0,0 +1,44 @@ +package com.fr.design.mainframe.mobile.ui.topparam; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.form.ui.mobile.impl.MobileTopParamStyle; + +import javax.swing.*; +import java.awt.*; + +public class MobileTopParamPane extends BasicBeanPane { + private UICheckBox autoCommitCheckBox; + + public MobileTopParamPane() { + this.init(); + } + + private void init() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel panel = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Plugin-TopParam_Setting")); + panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + autoCommitCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Plugin-TopParam_AutoCommit"), true); + panel.add(autoCommitCheckBox); + this.add(panel, BorderLayout.CENTER); + } + + @Override + public void populateBean(MobileTopParamStyle topParamStyle) { + autoCommitCheckBox.setSelected(topParamStyle.isAutoCommit()); + } + + @Override + public MobileTopParamStyle updateBean() { + MobileTopParamStyle topParamStyle = new MobileTopParamStyle(); + topParamStyle.setAutoCommit(autoCommitCheckBox.isSelected()); + return topParamStyle; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/DesignerUtils.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/DesignerUtils.java new file mode 100644 index 0000000000..bcadac1c74 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/DesignerUtils.java @@ -0,0 +1,57 @@ +package com.fr.design.mainframe.mobile.utils; + +import com.fr.design.constants.LayoutConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.widget.UITitleSplitLine; +import com.fr.design.style.color.NewColorSelectBox; +import com.fr.stable.Constants; + +import javax.swing.*; +import javax.swing.event.ChangeListener; +import java.awt.*; + +public class DesignerUtils { + + public static final int NORMAL_COMBO_WIDTH = 152; + public static final int kDefaultHorizontalPadding = 0; + public static final int kDefaultVerticalPadding = 15; + public static final int kAlignLeft = 0; + public static final int kAlignCenter = 1; + public static final int[] BORDER_LINE_STYLE_ARRAY = new int[]{ + Constants.LINE_NONE, + Constants.LINE_THIN, + Constants.LINE_MEDIUM, + Constants.LINE_THICK, + }; + + public static UITitleSplitLine createTitleSplitLine(String title) { + UITitleSplitLine splitLine = new UITitleSplitLine(title, 520); + splitLine.setPreferredSize(new Dimension(520, 20)); + return splitLine; + } + + public static UILabel createConfigLabel(String title) { + UILabel label = new UILabel(title, UILabel.RIGHT); + label.setPreferredSize(new Dimension(100, 20)); + return label; + } + + public static NewColorSelectBox createNormalColorSelectBox(ChangeListener changeListener) { + NewColorSelectBox colorSelectBox = new NewColorSelectBox(NORMAL_COMBO_WIDTH); + colorSelectBox.addSelectChangeListener(changeListener); + return colorSelectBox; + } + + public static UICheckBox createCheckBox(String text, boolean selected) { + UICheckBox uiCheckBox = new UICheckBox(text, selected); + return uiCheckBox; + } + + public static JPanel createLeftRightComponentsPane(Component... components) { + return TableLayoutHelper.createGapTableLayoutPane(new Component[][]{components}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/FontConfigPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/FontConfigPane.java new file mode 100644 index 0000000000..6386e31e01 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/FontConfigPane.java @@ -0,0 +1,137 @@ +package com.fr.design.mainframe.mobile.utils; + +import com.fr.base.BaseUtils; +import com.fr.base.Utils; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.ibutton.UIToggleButton; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.general.FRFont; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.EventListenerList; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.Vector; + +public class FontConfigPane extends JPanel { + private static final Icon[] ITALIC_ICONS = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic_white.png")}; + private static final Icon[] BOLD_ICONS = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold_white.png")}; + + private EventListenerList fontChangeListener = new EventListenerList(); + private UIComboBox fontFamily; + private UIComboBox fontSize; + private UIToggleButton bold; + private UIColorButton color; + private UIToggleButton italic; + + + public FontConfigPane() { + super(); + init(); + } + + private void init() { + this.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + fontFamily = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); + Vector integerList = new Vector<>(); + for (int i = 1; i < 100; i++) { + integerList.add(i); + } + fontFamily.setPreferredSize(new Dimension(152, 20)); + fontSize = new UIComboBox(integerList); + fontSize.setSelectedIndex(14); + color = new UIColorButton(); + bold = new UIToggleButton(BOLD_ICONS, true); + italic = new UIToggleButton(ITALIC_ICONS, true); + fontFamily.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + fireFontStateChanged(); + } + }); + fontSize.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + fireFontStateChanged(); + } + }); + bold.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + fireFontStateChanged(); + } + }); + italic.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + fireFontStateChanged(); + } + }); + color.addColorChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + fireFontStateChanged(); + } + }); + this.add(fontFamily); + this.add(fontSize); + this.add(color); + this.add(bold); + this.add(italic); + + } + + public void setFontColor(Color fontColor) { + color.setColor(fontColor); + } + + public FRFont updateFont(Color fontColor, Boolean isBold, Boolean isItalic) { + String family = (String) fontFamily.getSelectedItem(); + int size = (int) fontSize.getSelectedItem(); + int style = Font.PLAIN; + boolean bold = (isBold == null) ? this.bold.isSelected() : isBold; + boolean italic = (isItalic == null) ? this.italic.isSelected() : isItalic; + style += bold ? Font.BOLD : Font.PLAIN; + style += italic ? Font.ITALIC : Font.PLAIN; + FRFont frFont = FRFont.getInstance(family, style, size, fontColor == null ? color.getColor() : fontColor); + return frFont; + } + + public FRFont update() { + String family = (String) fontFamily.getSelectedItem(); + int size = (int) fontSize.getSelectedItem(); + int style = Font.PLAIN; + style += this.bold.isSelected() ? Font.BOLD : Font.PLAIN; + style += this.italic.isSelected() ? Font.ITALIC : Font.PLAIN; + return FRFont.getInstance(family, style, size, color.getColor()); + } + + public void populate(FRFont frFont) { + fontFamily.setSelectedItem(frFont.getFamily()); + fontSize.setSelectedItem(frFont.getSize()); + color.setColor(frFont.getForeground()); + bold.setSelected(frFont.isBold()); + italic.setSelected(frFont.isItalic()); + + } + + /** + * 颜色状态改变 + */ + public void fireFontStateChanged() { + Object[] listeners = fontChangeListener.getListenerList(); + ChangeEvent e = null; + + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == ChangeListener.class) { + if (e == null) { + e = new ChangeEvent(this); + } + ((ChangeListener) listeners[i + 1]).stateChanged(e); + } + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/IconConfigPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/IconConfigPane.java new file mode 100644 index 0000000000..6f8e188e3f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/IconConfigPane.java @@ -0,0 +1,185 @@ +package com.fr.design.mainframe.mobile.utils; + +import com.fr.base.IconManager; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.utils.DrawRoutines; +import com.fr.design.web.CustomIconPane; +import com.fr.form.ui.WidgetInfoConfig; +import com.fr.general.FRFont; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.plaf.basic.BasicButtonUI; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class IconConfigPane extends JPanel { + private UIButton editIconButton; + private UIButton deleteIconButton; + private IconButton iconButton; + + public IconConfigPane() { + initComp(); + } + + public void initComp() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); + panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); + editIconButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Edit")); + editIconButton.setFont(FRFont.getInstance("Helvetica", Font.PLAIN, 12, Color.decode("#3A383A"))); + editIconButton.setPreferredSize(new Dimension(62, 20)); + panel.add(editIconButton); + editIconButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + final CustomIconPane cip = new CustomIconPane(){ + protected String createDescriptionText(){ + return Toolkit.i18nText("Fine-Design_Mobile_Custom_Icon_Message"); + } + }; + BasicDialog editDialog = cip.showWindow(new JFrame()); + editDialog.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + IconConfigPane.this.iconButton.setIconName(cip.update()); + IconConfigPane.this.deleteIconButton.setEnabled(true); + IconConfigPane.this.repaint(); + } + }); + editDialog.setVisible(true); + } + }); + editIconButton.setEnabled(true); + + deleteIconButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Delete")); + deleteIconButton.setFont(FRFont.getInstance("Helvetica", Font.PLAIN, 12, Color.decode("#3A383A"))); + deleteIconButton.setPreferredSize(new Dimension(62, 20)); + panel.add(deleteIconButton); + deleteIconButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + IconConfigPane.this.iconButton.setIconName(StringUtils.EMPTY); + IconConfigPane.this.deleteIconButton.setEnabled(false); + IconConfigPane.this.repaint(); + } + }); + deleteIconButton.setEnabled(false); + + + this.add(panel, BorderLayout.CENTER); + + JPanel westPane = new JPanel(); + iconButton = new IconButton(""); + westPane.add(iconButton); + this.add(westPane, BorderLayout.WEST); + } + + public void populate(String iconName) { + if(StringUtils.isNotEmpty(iconName)) { + deleteIconButton.setEnabled(true); + } else { + deleteIconButton.setEnabled(false); + } + iconButton.setIconName(iconName); + } + + public String update() { + return iconButton.getIconName(); + } + + + private class IconButton extends JToggleButton implements ActionListener { + private String iconName; + private Image iconImage = null; + private static final int ICON_BUTTON_SIZE = 20; + private static final int ICON_X = 2; + private static final int ICON_Y = 2; + + public IconButton(String name) { + this.iconName = name; + this.addActionListener(this); + this.setBackground(Color.WHITE); + this.setCursor(new Cursor(Cursor.HAND_CURSOR)); + this.iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(name); + } + + @Override + public void updateUI() { + setUI(new BasicButtonUI() { + public void paint(Graphics g, JComponent c) { + super.paint(g, c); + } + }); + } + + protected void paintBorder(Graphics g) { + super.paintBorder(g); + if (StringUtils.isNotEmpty(iconButton.getIconName())) { + DrawRoutines.drawRoundedBorder( + g, Color.decode("#419BF9"), 0, 0, 20, 20); + } else { + DrawRoutines.drawRoundedBorder( + g, Color.decode("#D9DADD"), 0, 0, 20, 20); + } + + } + + public String getIconName() { + return iconName; + } + + public void setIconName(String iconName) { + this.iconName = iconName; + this.iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(iconName); + this.repaint(); + } + + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + Graphics2D g2d = (Graphics2D) g; + // carl:这里缩放显示 16 × 16 + if (iconImage != null) { + g2d.drawImage(iconImage, ICON_X, ICON_Y, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null); + } + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(ICON_BUTTON_SIZE, ICON_BUTTON_SIZE); + } + + public void actionPerformed(ActionEvent evt) { + IconConfigPane.this.repaint();// repaint + } + + @Override + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + private void fireChagneListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } + + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/MobileStyleProviderManager.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/MobileStyleProviderManager.java new file mode 100644 index 0000000000..7c3194ba61 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/MobileStyleProviderManager.java @@ -0,0 +1,41 @@ +package com.fr.design.mainframe.mobile.utils; + +import com.fr.design.mainframe.mobile.provider.combo.SimpleComboCheckBoxStyleProvider; +import com.fr.design.mainframe.mobile.provider.combo.SimpleComboStyleProvider; +import com.fr.design.mainframe.mobile.provider.date.NavigationStyleProvider; +import com.fr.design.mainframe.mobile.provider.date.SimpleDateStyleProvider; +import com.fr.design.mainframe.mobile.provider.date.SimpleStyleProvider; +import com.fr.design.mainframe.mobile.provider.radiogroup.CapsuleRadioGroupStyleProvider; +import com.fr.design.mainframe.mobile.provider.radiogroup.ImageRadioGroupStyleProvider; +import com.fr.design.mainframe.mobile.provider.radiogroup.UnitedRadioGroupStyleProvider; +import com.fr.design.mainframe.mobile.provider.topparam.MobileTopParamStyleProvider; +import com.fr.stable.fun.mark.Mutable; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +public class MobileStyleProviderManager { + private static Set mobileWidgetStyleProviderSet = new HashSet() {{ + add(new SimpleStyleProvider()); + add(new NavigationStyleProvider()); + add(new SimpleDateStyleProvider()); + add(new SimpleComboStyleProvider()); + add(new SimpleComboCheckBoxStyleProvider()); + add(new CapsuleRadioGroupStyleProvider()); + add(new UnitedRadioGroupStyleProvider()); + add(new ImageRadioGroupStyleProvider()); + }}; + private static Set mobileParamUIProviderSet = new HashSet() {{ + add(new MobileTopParamStyleProvider()); + }}; + private static Map> map = new HashMap>() {{ + put("MobileWidgetStyleProvider", mobileWidgetStyleProviderSet); + put("MobileParamUIProvider", mobileParamUIProviderSet); + }}; + + public static Set getArray(String mark) { + return (Set) map.get(mark); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java index 9e2a0d5efd..823dd6ff3a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java @@ -15,7 +15,7 @@ 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.style.background.gradient.FixedGradientBar; +import com.fr.design.style.background.gradient.FixedGradientBarNoTheme; import com.fr.design.style.color.ColorAdjustPane; import com.fr.stable.StringUtils; @@ -40,7 +40,7 @@ public class ColorFillStylePane extends BasicBeanPane { private ColorSchemeComboBox styleSelectBox; private JPanel customPane; private JPanel changeColorSetPane; - private FixedGradientBar colorGradient; + private FixedGradientBarNoTheme colorGradient; private CardLayout cardLayout; @@ -69,8 +69,8 @@ public class ColorFillStylePane extends BasicBeanPane { }; changeColorSetPane = new JPanel(cardLayout = new CardLayout()); - changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 130), "gradient"); - gradientColors = new Color[]{Color.WHITE, FixedGradientBar.NEW_CHARACTER}; + changeColorSetPane.add(colorGradient = new FixedGradientBarNoTheme(4, 130), "gradient"); + gradientColors = new Color[]{Color.WHITE, FixedGradientBarNoTheme.NEW_CHARACTER}; changeColorSetPane.add(colorAdjustPane = new ColorAdjustPane(), "acc"); accColors = ColorAdjustPane.DEFAULT_COLORS; cardLayout.show(changeColorSetPane, "acc"); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java index b7034fd669..43d20d1bde 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java @@ -3,20 +3,10 @@ package com.fr.design.mainframe.predefined.ui.detail.background; import com.fr.base.background.ColorBackground; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.style.color.ColorSelectPane; +import com.fr.design.style.color.NewColorSelectPane; import com.fr.general.Background; - -import javax.swing.BorderFactory; -import javax.swing.JPanel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; /** * Created by kerry on 2020-08-31 @@ -50,48 +40,9 @@ public class ColorDetailPane extends AbstractBackgroundDetailPane chartPreStyleProviders = vanChart.getChartPreStyleProvider(); - for (ChartPreStyleProvider chartPreStyleProvider : chartPreStyleProviders) { - chartPreStyleProvider.updatePreDefinedStyle(style); + /*VanChart vanChart = chartCollection.getSelectedChartProvider(VanChart.class); + List chartThemeStyleProviders = vanChart.getChartPreStyleProvider(); + for (ChartThemeStyleProvider chartThemeStyleProvider : chartThemeStyleProviders) { + chartThemeStyleProvider.updateThemeStyle(style); } componentBackground = style.getComponentStyle().getBorderStyle().getBackground(); - vanChart.attrChange(); + vanChart.attrChange();*/ } @Override diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java new file mode 100644 index 0000000000..3df87ac658 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java @@ -0,0 +1,81 @@ +package com.fr.design.mainframe.theme; + +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeConfig; +import com.fr.concurrent.NamedThreadFactory; +import com.fr.module.ModuleContext; + +import javax.swing.SwingUtilities; +import java.util.concurrent.ExecutorService; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/24 + */ +public class AsyncThemeFetcher { + + private final ExecutorService executorService; + private final TemplateThemeConfig config; + + public AsyncThemeFetcher(int threads, TemplateThemeConfig config) { + this.executorService = ModuleContext.getExecutor().newFixedThreadPool( + threads, + new NamedThreadFactory(this.getClass().getName()) + ); + this.config = config; + } + + public void shutdown() { + executorService.shutdown(); + } + + public boolean isShutdown() { + return executorService.isShutdown(); + } + + public void submit(String themeName, AsyncThemeFetchCallback callback) { + if (callback != null) { + callback.beforeCachedFetch(); + } + executorService.submit(new Runnable() { + @Override + public void run() { + if (executorService.isShutdown()) { + return; + } + T theme = config.cachedFetch(themeName); + if (executorService.isShutdown()) { + return; + } + if (callback != null) { + // 后续任务不要在工作线程中执行,从而确保只在EDT线程操作UI + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + callback.afterCachedFetch(theme); + } + }); + } + } + }); + } + + public interface AsyncThemeFetchCallback { + void beforeCachedFetch(); + void afterCachedFetch(T theme); + } + + public static class AsyncThemeFetchCallbackAdapter implements AsyncThemeFetchCallback { + + @Override + public void beforeCachedFetch() { + + } + + @Override + public void afterCachedFetch(T theme) { + + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java new file mode 100644 index 0000000000..83179eddaf --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java @@ -0,0 +1,105 @@ +package com.fr.design.mainframe.theme; + +import com.fr.base.theme.FineColorManager; +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.TemplateThemeConfig; +import com.fr.base.theme.settings.ThemedComponentStyle; +import com.fr.base.theme.settings.ThemedFormBodyStyle; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.theme.edit.ChartStyleFormEditPane; +import com.fr.design.mainframe.theme.edit.ComponentStyleEditPane; +import com.fr.design.mainframe.theme.edit.FormBodyStyleEditPane; +import com.fr.design.mainframe.theme.preview.FormThemePreviewPane; + +import javax.swing.JPanel; +import java.util.List; +import java.awt.Color; + +import static com.fr.design.i18n.Toolkit.i18nText; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/13 + */ +public class FormThemeProfilePane extends TemplateThemeProfilePane { + public static final int LABEL_WIDTH = 60; + + private FormBodyStyleEditPane formBodyStyleSettingPane; + private ComponentStyleEditPane componentStyleSettingPane; + + public FormThemeProfilePane(TemplateThemeConfig config) { + super(config); + } + + @Override + public FormThemePreviewPane createThemePreviewPane() { + return new FormThemePreviewPane(); + } + + @Override + protected JPanel createCustomEditorsPane() { + JPanel container = super.createCustomEditorsPane(); + formBodyStyleSettingPane = new FormBodyStyleEditPane(); + addCustomEditorPane(i18nText("Fine-Design_Predefined_Template_Background"), formBodyStyleSettingPane); + + addCustomEditorPane(i18nText("Fine-Design_Predefined_Cell_Style"), createCellStyleSettingPane()); + addCustomEditorPane(i18nText("Fine-Design_Predefined_Chart_Style"), createChartStyleSettingPane()); + + + componentStyleSettingPane = new ComponentStyleEditPane(); + addCustomEditorPane(i18nText("Fine-Design_Predefined_Component_Style"), componentStyleSettingPane); + return container; + } + + @Override + protected JPanel createChartStyleSettingPane() { + JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + chartStyleSettingPane = new ChartStyleFormEditPane(); + container.add(chartStyleSettingPane); + return container; + } + + @Override + public void onColorSchemeChanged(List colors) { + super.onColorSchemeChanged(colors); + FineColorManager.FineColorReplaceByColorScheme replaceByColorScheme = new FineColorManager.FineColorReplaceByColorScheme(colors); + + ThemedFormBodyStyle formBodyStyle = formBodyStyleSettingPane.updateBean(); + FineColorManager.traverse(formBodyStyle, replaceByColorScheme); + formBodyStyleSettingPane.populateBean(formBodyStyle); + + ThemedComponentStyle componentStyle = componentStyleSettingPane.updateBean(); + FineColorManager.traverse(componentStyle, replaceByColorScheme); + componentStyleSettingPane.populateBean(componentStyle); + } + + @Override + public void populateBean(FormTheme theme) { + super.populateBean(theme); + + isPopulating = true; + + formBodyStyleSettingPane.populateBean(theme.getBodyStyle()); + componentStyleSettingPane.populateBean(theme.getComponentStyle()); + + themePreviewPane.refresh(theme); + + isPopulating = false; + } + + @Override + public void updateBean(FormTheme theme) { + ThemedFormBodyStyle formBodyStyle = formBodyStyleSettingPane.updateBean(); + theme.setBodyStyle(formBodyStyle); + + ThemedComponentStyle componentStyle = componentStyleSettingPane.updateBean(); + theme.setComponentStyle(componentStyle); + } + + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Basic_Form_Theme_Profile_Dialog_Title"); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/ReportThemeProfilePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/ReportThemeProfilePane.java new file mode 100644 index 0000000000..091262b589 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/ReportThemeProfilePane.java @@ -0,0 +1,74 @@ +package com.fr.design.mainframe.theme; + +import com.fr.base.theme.FineColorManager; +import com.fr.base.theme.ReportTheme; +import com.fr.base.theme.TemplateThemeConfig; +import com.fr.base.theme.settings.ThemedReportBodyStyle; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.theme.edit.ReportBodyStyleEditPane; +import com.fr.design.mainframe.theme.preview.ReportThemePreviewPane; + +import javax.swing.JPanel; +import java.awt.Color; +import java.util.List; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/13 + */ +public class ReportThemeProfilePane extends TemplateThemeProfilePane { + private ReportBodyStyleEditPane reportBodyStyleSettingPane; + + public ReportThemeProfilePane(TemplateThemeConfig config) { + super(config); + } + + @Override + public ReportThemePreviewPane createThemePreviewPane() { + return new ReportThemePreviewPane(); + } + + @Override + protected JPanel createCustomEditorsPane() { + JPanel container = super.createCustomEditorsPane(); + this.reportBodyStyleSettingPane = new ReportBodyStyleEditPane(); + addCustomEditorPane(Toolkit.i18nText("Fine-Design_Predefined_Template_Background"), reportBodyStyleSettingPane); + addCustomEditorPane(Toolkit.i18nText("Fine-Design_Predefined_Cell_Style"), createCellStyleSettingPane()); + addCustomEditorPane(Toolkit.i18nText("Fine-Design_Predefined_Chart_Style"), createChartStyleSettingPane()); + return container; + } + + @Override + public void onColorSchemeChanged(List colors) { + super.onColorSchemeChanged(colors); + + FineColorManager.FineColorReplaceByColorScheme replaceByColorScheme = new FineColorManager.FineColorReplaceByColorScheme(colors); + + ThemedReportBodyStyle bodyStyle = reportBodyStyleSettingPane.updateBean(); + FineColorManager.traverse(bodyStyle, replaceByColorScheme); + reportBodyStyleSettingPane.populateBean(bodyStyle); + } + + @Override + public void populateBean(ReportTheme theme) { + super.populateBean(theme); + + isPopulating = true; + reportBodyStyleSettingPane.populateBean(theme.getBodyStyle()); + + themePreviewPane.refresh(theme); + + isPopulating = false; + } + + @Override + public void updateBean(ReportTheme theme) { + theme.setBodyStyle(this.reportBodyStyleSettingPane.updateBean()); + } + + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Basic_Report_Theme_Profile_Dialog_Title"); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java new file mode 100644 index 0000000000..e00bc445c0 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeBlock.java @@ -0,0 +1,259 @@ +package com.fr.design.mainframe.theme; + +import com.fr.base.GraphHelper; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeConfig; +import com.fr.base.theme.settings.ThemeThumbnail; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.theme.dialog.TemplateThemeProfileDialog; +import com.fr.general.IOUtils; +import com.fr.stable.Constants; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Rectangle; +import java.awt.RenderingHints; +import java.awt.Toolkit; +import java.awt.Window; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/13 + */ +public class TemplateThemeBlock extends JPanel { + public static final int HEIGHT = 150; + public static final int THUMBNAIL_HEIGHT = 125; + private static final Color HOVERING_BORDER_COLOR = new Color(65, 155, 249); + + private final String name; + private final TemplateThemeConfig config; + private T theme; + private final TemplateThemeProfilePane profilePane; + private final Icon theme4currentTemplateMarkIcon = IOUtils.readIcon("/com/fr/design/form/images/theme4currentTemplate.png"); + private final Icon theme4NewTemplateMarkIcon= IOUtils.readIcon("/com/fr/design/form/images/theme4newTemplate.png"); + private final Icon profileIcon = IOUtils.readIcon("/com/fr/design/icon/icon_edit.png"); + private final boolean displayTheme4NewTemplateMarker; + + private final ThumbnailPane thumbnailPane; + // UIButton会影响Block的手势监听,这里使用UILabel代替,点击事件也有Block代为处理 + private UILabel profileButton; + private boolean selected = false; + private boolean hovering = false; + + private MouseAdapter clickListener; + + public TemplateThemeBlock(String name, + boolean displayTheme4NewTemplateMarker, + TemplateThemeConfig config, + TemplateThemeProfilePane profilePane) { + this.name = name; + this.displayTheme4NewTemplateMarker = displayTheme4NewTemplateMarker; + this.config = config; + this.profilePane = profilePane; + this.thumbnailPane = new ThumbnailPane(); + + initializePane(); + addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (clickListener != null) { + clickListener.mouseClicked(e); + } + + if (profileButton != null && profilePane != null) { + delegateProfileButtonClick(e); + } + } + + @Override + public void mouseEntered(MouseEvent e) { + hovering = true; + repaint(); + } + + @Override + public void mouseExited(MouseEvent e) { + hovering = false; + repaint(); + } + }); + } + + private void initializePane() { + setLayout(FRGUIPaneFactory.createBorderLayout()); + setPreferredSize(new Dimension(getPreferredSize().width, HEIGHT)); + setBackground(Color.WHITE); + + thumbnailPane.setBackground(Color.WHITE); + thumbnailPane.setPreferredSize(new Dimension(getPreferredSize().width, THUMBNAIL_HEIGHT)); + + JPanel infoPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + infoPane.setBackground(Color.WHITE); + infoPane.setBorder(BorderFactory.createEmptyBorder(0, IntervalConstants.INTERVAL_L7,0,IntervalConstants.INTERVAL_L7)); + + UILabel titleLabel = new UILabel(name); + titleLabel.setToolTipText(name); + infoPane.add(titleLabel, BorderLayout.CENTER); + + if (profilePane != null) { + addProfileButton(infoPane); + } + + add(thumbnailPane, BorderLayout.CENTER); + add(infoPane, BorderLayout.SOUTH); + } + + public void setTheme(T theme) { + this.theme = theme; + Image image = null; + if (theme != null) { + ThemeThumbnail thumbnail = theme.getThumbnail(); + if (thumbnail != null) { + image = thumbnail.getImage(); + } + } + thumbnailPane.setThumbnail(image); + } + + public T getTheme() { + return this.theme; + } + + public void setSelected(boolean selected) { + this.selected = selected; + repaint(); + } + + public void addClickListener(MouseAdapter clickListener) { + this.clickListener = clickListener; + } + + private void addProfileButton(JPanel panel) { + profileButton = new UILabel(profileIcon); + profileButton.setPreferredSize(new Dimension(24, 24)); + panel.add(profileButton, BorderLayout.EAST); + } + + private void delegateProfileButtonClick(MouseEvent e) { + int x = e.getX(); + int y = e.getY(); + + int profileButtonX = profileButton.getX(); + int profileButtonY = thumbnailPane.getHeight() + profileButton.getY(); + + boolean inX = profileButtonX <= x && x <= profileButtonX + profileButton.getWidth(); + boolean inY = profileButtonY <= y && y <= profileButtonY + profileButton.getHeight(); + if (inX && inY) { + openProfileDialog(); + } + } + + private void openProfileDialog() { + if (theme == null) { + return; + } + Window parent = SwingUtilities.getWindowAncestor(TemplateThemeBlock.this); + TemplateThemeProfileDialog profileDialog = new TemplateThemeProfileDialog<>(parent, profilePane); + try { + profilePane.populateBean((T) theme.clone()); + } catch (CloneNotSupportedException ex) { + ex.printStackTrace(); + } + profileDialog.setVisible(true); + } + + @Override + public void paint(Graphics g) { + super.paint(g); + Graphics2D g2d = (Graphics2D) g; + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + TemplateThemeConfig templateUsingConfig = template.getUsingTemplateThemeConfig(); + TemplateTheme templateTheme = template.getTemplateTheme(); + if (templateUsingConfig == this.config && StringUtils.equals(templateTheme.getName(), name)) { + theme4currentTemplateMarkIcon.paintIcon(this, g, getWidth() - 25, 0); + } + } + + if (displayTheme4NewTemplateMarker && StringUtils.equals(config.getThemeName4NewTemplate(), name)) { + theme4NewTemplateMarkIcon.paintIcon(this, g, 0, 0); + } + + if (selected || this.hovering) { + g.setColor(HOVERING_BORDER_COLOR); + Rectangle rectangle = new Rectangle(1, 1, this.getWidth() - 2, this.getHeight() - 2); + GraphHelper.draw(g, rectangle, Constants.LINE_MEDIUM); + } + } + + private static class ThumbnailPane extends JPanel { + private static final Image LOADING_IMAGE = Toolkit.getDefaultToolkit().createImage(ThumbnailPane.class.getResource("/com/fr/design/images/mainframe/loading.gif")); + private Image thumbnail = null; + + @Override + public void paint(Graphics g) { + super.paint(g); + Graphics2D g2d = (Graphics2D) g; + Color oldColor = g2d.getColor(); + g2d.setColor(Color.WHITE); + g2d.fillRect(0, 0, getWidth(), getHeight()); + g2d.setColor(oldColor); + + paintCenterImage(g2d, thumbnail != null ? thumbnail : LOADING_IMAGE); + } + + private void paintCenterImage(Graphics2D g2d, Image image) { + if (image == null) { + return; + } + + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + int width = getWidth(); + int height = getHeight(); + int imgWidth = image.getWidth(null); + int imgHeight = image.getHeight(null); + + if (width <= 0 || height <= 0 || imgWidth <= 0 || imgHeight <= 0) { + return; + } + + float imgAspect = 1.0F * imgWidth / imgHeight; + + if (1.0F * width / height > 1.0F * imgWidth / imgHeight) { + imgHeight = height; + imgWidth = (int) (1.0F * imgHeight * imgAspect); + } else { + imgWidth = width; + imgHeight = (int) (1.0F * imgWidth / imgAspect); + } + int x = (width - imgWidth) / 2; + int y = (height - imgHeight) / 2; + + g2d.drawImage(image, x, y, imgWidth, imgHeight, null); + } + + public void setThumbnail(Image thumbnail) { + this.thumbnail = thumbnail; + invalidate(); + repaint(); + } + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java new file mode 100644 index 0000000000..524c272ac9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java @@ -0,0 +1,242 @@ +package com.fr.design.mainframe.theme; + +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeConfig; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.dialog.BasicPane; +import com.fr.design.event.ChangeEvent; +import com.fr.design.event.ChangeListener; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/13 + */ +public class TemplateThemeListPane extends BasicPane { + public static final int BLOCK_COUNT_ROW_LINE = 3; + public static final int BLOCK_GAP = IntervalConstants.INTERVAL_L1; + public static final int CONTENT_WIDTH = 630; + public static final int ASYNC_FETCH_THEME_THREAD_COUNT = 10; + + private final AsyncThemeFetcher asyncThemeFetcher; + + private final boolean displayTheme4NewTemplateMarker; + protected final TemplateThemeConfig config; + private final TemplateThemeProfilePane profilePane; + private final JPanel contentListPane; + + private final Map> blockCache = new HashMap<>(); + + private TemplateThemeBlock selectedBlock; + private TemplateThemeBlock block4newTemplate; + + private TemplateThemeConfig.ThemeConfigChangeListener themeConfigChangeListener; + + private ChangeListener changeListener; + + public TemplateThemeListPane(boolean displayTheme4NewTemplateMarker, TemplateThemeConfig config, TemplateThemeProfilePane profilePane) { + this.displayTheme4NewTemplateMarker = displayTheme4NewTemplateMarker; + this.config = config; + this.profilePane = profilePane; + this.contentListPane = new JPanel(); + this.asyncThemeFetcher = new AsyncThemeFetcher<>(ASYNC_FETCH_THEME_THREAD_COUNT, config); + initializePane(); + } + + private void initializePane() { + setLayout(FRGUIPaneFactory.createBorderLayout()); + setPreferredSize(new Dimension(CONTENT_WIDTH, getPreferredSize().height)); + + contentListPane.setBorder(BorderFactory.createEmptyBorder(BLOCK_GAP, 0, BLOCK_GAP, 0)); + contentListPane.setLayout(new GridLayout(0, BLOCK_COUNT_ROW_LINE, BLOCK_GAP, BLOCK_GAP)); + fillContentListPane(); + + JPanel wrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); + wrapper.add(contentListPane, BorderLayout.NORTH); + + UIScrollPane scrollPane = new UIScrollPane(wrapper); + scrollPane.setBorder(BorderFactory.createEmptyBorder()); + add(scrollPane, BorderLayout.CENTER); + + } + + public void fillContentListPane() { + contentListPane.removeAll(); + List names = config.getThemeNames(); + for (String name: names) { + if (config.contains(name)) { + TemplateThemeBlock block = createCachedTemplateThemeBlock(name); + contentListPane.add(block); + if (StringUtils.equals(name, config.getThemeName4NewTemplate())) { + block4newTemplate = block; + } + } + } + } + private TemplateThemeBlock createCachedTemplateThemeBlock(String name) { + TemplateThemeBlock block = blockCache.get(name); + if (block == null) { + block = createNewTemplateThemeBlock(name); + blockCache.put(name, block); + } + return block; + } + + private TemplateThemeBlock createNewTemplateThemeBlock(String name) { + final TemplateThemeBlock block = new TemplateThemeBlock<>(name, displayTheme4NewTemplateMarker, config, profilePane); + block.addClickListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + super.mouseClicked(e); + setSelectedBlock(block); + } + }); + asyncThemeFetcher.submit(name, new AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter() { + @Override + public void beforeCachedFetch() { + super.beforeCachedFetch(); + block.setTheme(null); + } + + @Override + public void afterCachedFetch(T theme) { + super.afterCachedFetch(theme); + block.setTheme(theme); + } + }); + return block; + } + + public void setSelectedChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + private void setSelectedBlock(TemplateThemeBlock block) { + if (selectedBlock != null) { + selectedBlock.setSelected(false); + } + selectedBlock = block; + if (selectedBlock != null) { + selectedBlock.setSelected(true); + } + if (changeListener != null) { + changeListener.fireChanged(new ChangeEvent(this)); + } + } + + private void asyncFetchTheme(String themeName) { + asyncThemeFetcher.submit(themeName, new AsyncThemeListItemFetchCallback(themeName)); + } + + @Override + protected String title4PopupWindow() { + return null; + } + + public T getSelectedTheme() { + return selectedBlock != null ? selectedBlock.getTheme() : null; + } + + public void startListenThemeConfig() { + if (themeConfigChangeListener == null) { + themeConfigChangeListener = new TemplateThemeConfig.ThemeConfigChangeListener() { + @Override + public void onThemeConfigChanged(TemplateThemeConfig.ThemeConfigEvent event) { + String themeName = event.themName; + TemplateThemeBlock existingBlock = blockCache.get(event.themName); + switch (event.action) { + case DEFAULT_THEME_4_NEW_TEMPLATE_UPDATE: { + if (block4newTemplate != null) { + block4newTemplate.repaint(); + } + if (existingBlock != null) { + existingBlock.repaint(); + } + block4newTemplate = existingBlock; + break; + } + case UPDATE: { + if (existingBlock != null) { + asyncFetchTheme(themeName); + } + break; + } + case REMOVE: { + if (existingBlock != null) { + contentListPane.remove(existingBlock); + if (existingBlock == selectedBlock) { + setSelectedBlock(null); + } + validate(); + repaint(); + blockCache.remove(event.themName); + } + break; + } + case ADD: { + if (existingBlock == null) { + // TODO 这里是否还能继续优化? + fillContentListPane(); + asyncFetchTheme(themeName); + validate(); + repaint(); + } + break; + } + } + } + }; + config.addThemeConfigChangeListener(themeConfigChangeListener); + } + } + + public void stopListenThemeConfig() { + if (themeConfigChangeListener != null) { + config.removeThemeConfigChangeListener(themeConfigChangeListener); + themeConfigChangeListener = null; + } + } + + public void stopAsyncFetchTheme() { + asyncThemeFetcher.shutdown(); + } + + private class AsyncThemeListItemFetchCallback extends AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter { + private final String themeName; + public AsyncThemeListItemFetchCallback(String themeName) { + this.themeName = themeName; + } + + @Override + public void beforeCachedFetch() { + super.beforeCachedFetch(); + TemplateThemeBlock block = blockCache.get(themeName); + if (block != null) { + block.setTheme(null); + } + } + + @Override + public void afterCachedFetch(T theme) { + super.afterCachedFetch(theme); + TemplateThemeBlock block = blockCache.get(themeName); + if (block != null) { + block.setTheme(theme); + } + } + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java new file mode 100644 index 0000000000..bf93c6345a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java @@ -0,0 +1,325 @@ +package com.fr.design.mainframe.theme; + +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.FormThemeConfig; +import com.fr.base.theme.ReportTheme; +import com.fr.base.theme.ReportThemeConfig; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeConfig; +import com.fr.design.actions.UpdateAction; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.event.ChangeEvent; +import com.fr.design.event.ChangeListener; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.i18n.Toolkit; +import com.fr.design.icon.IconPathConstants; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.theme.dialog.TemplateThemeProfileDialog; +import com.fr.design.mainframe.theme.edit.CellStyleListEditPane; +import com.fr.design.menu.MenuDef; +import com.fr.design.menu.ToolBarDef; +import com.fr.general.IOUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; +import com.fr.transaction.CallBackAdaptor; +import com.fr.transaction.Configurations; +import com.fr.transaction.WorkerFacade; + +import javax.swing.BorderFactory; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JSeparator; +import javax.swing.SwingUtilities; +import javax.swing.border.LineBorder; +import java.awt.BasicStroke; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.Stroke; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import static com.fr.design.i18n.Toolkit.i18nText; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/13 + */ +public class TemplateThemeManagePane extends BasicPane { + private final RemoveThemeAction removeAction; + private final UIButton setTheme4NewTemplateButton; + + private final TemplateThemeConfig config; + private final TemplateThemeListPane themeListPane; + private final TemplateThemeProfilePane profilePane; + + private final AsyncThemeFetcher asyncThemeFetcher; + + public static TemplateThemeManagePane createFormThemesManagerPane() { + FormThemeConfig config = FormThemeConfig.getInstance(); + FormThemeProfilePane editPane = new FormThemeProfilePane(config); + return new TemplateThemeManagePane<>(config, editPane); + } + + public static TemplateThemeManagePane createReportThemesManagerPane() { + ReportThemeConfig config = ReportThemeConfig.getInstance(); + ReportThemeProfilePane editPane = new ReportThemeProfilePane(config); + return new TemplateThemeManagePane<>(config, editPane); + } + + public TemplateThemeManagePane(TemplateThemeConfig config, TemplateThemeProfilePane profilePane) { + this.config = config; + this.profilePane = profilePane; + this.themeListPane = new TemplateThemeListPane<>(true, config, profilePane); + this.removeAction = new RemoveThemeAction(false); + this.setTheme4NewTemplateButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Default_Setting")); + this.asyncThemeFetcher = new AsyncThemeFetcher<>(1, config); + + initializePane(); + } + + public TemplateThemeConfig getConfig() { + return config; + } + + private void initializePane() { + setLayout(FRGUIPaneFactory.createBorderLayout()); + setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); + + add(createActionsContainer(), BorderLayout.NORTH); + + JPanel nextContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); + add(nextContainer, BorderLayout.CENTER); + + nextContainer.add(new JSeparator(), BorderLayout.NORTH); + + themeListPane.setPreferredSize(new Dimension(themeListPane.getPreferredSize().width, 490)); + themeListPane.setSelectedChangeListener(new ChangeListener() { + @Override + public void fireChanged(ChangeEvent event) { + resetEnableRemoveAction(themeListPane.getSelectedTheme(), removeAction); + resetEnableSetTheme4NewTemplateButton(themeListPane.getSelectedTheme(), setTheme4NewTemplateButton); + } + }); + nextContainer.add(themeListPane, BorderLayout.CENTER); + + resetEnableRemoveAction(themeListPane.getSelectedTheme(), removeAction); + resetEnableSetTheme4NewTemplateButton(themeListPane.getSelectedTheme(), setTheme4NewTemplateButton); + + repaint(); + } + + private void resetEnableRemoveAction(T selectedTheme, RemoveThemeAction removeAction) { + if (selectedTheme == null) { + removeAction.setEnabled(false); + return; + } + String selectedThemeName = selectedTheme.getName(); + if (StringUtils.isEmpty(selectedThemeName)) { + removeAction.setEnabled(false); + return; + } + + removeAction.setEnabled(selectedTheme.isRemovable()); + } + + private void resetEnableSetTheme4NewTemplateButton(T selectedTheme, UIButton setTheme4NewTemplateButton) { + if (selectedTheme == null) { + setTheme4NewTemplateButton.setEnabled(false); + return; + } + String selectedThemeName = selectedTheme.getName(); + if (StringUtils.isEmpty(selectedThemeName)) { + setTheme4NewTemplateButton.setEnabled(false); + return; + } + + T currentTheme4NewTemplate = config.cachedFetchTheme4NewTemplate(); + if (currentTheme4NewTemplate == null) { + setTheme4NewTemplateButton.setEnabled(true); + return; + } + String currentThemeName4NewTemplate = currentTheme4NewTemplate.getName(); + if (StringUtils.isEmpty(currentThemeName4NewTemplate)) { + setTheme4NewTemplateButton.setEnabled(true); + return; + } + + setTheme4NewTemplateButton.setEnabled(!StringUtils.equals(currentThemeName4NewTemplate, selectedTheme.getName())); + } + + private JPanel createActionsContainer() { + JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane(); + content.setPreferredSize(new Dimension(content.getPreferredSize().width, 20)); + + UIToolbar toolBar = ToolBarDef.createJToolBar(); + toolBar.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + content.add(toolBar, BorderLayout.CENTER); + + MenuDef addMenuDef = createAddMenuDef(); + + ToolBarDef toolbarDef = new ToolBarDef(); + toolbarDef.addShortCut(addMenuDef, removeAction); + toolbarDef.updateToolBar(toolBar); + + setTheme4NewTemplateButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + T theme = themeListPane.getSelectedTheme(); + if (theme != null) { + config.setThemeName4NewTemplate(theme.getName(), new CallBackAdaptor() { + @Override + public void afterRollback() { + super.afterRollback(); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TemplateThemeManagePane.this), + i18nText("Fine-Design_Basic_Template_Theme_Operation_Failed_Tip"), + i18nText("Fine-Design_Basic_Alert"), + JOptionPane.WARNING_MESSAGE); + } + }); + } + } + }); + content.add(setTheme4NewTemplateButton, BorderLayout.EAST); + + JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + container.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); + container.add(content, BorderLayout.CENTER); + + container.setPreferredSize(new Dimension(container.getPreferredSize().width, 30)); + + return container; + } + + private MenuDef createAddMenuDef() { + MenuDef menuDef = new MenuDef(Toolkit.i18nText("Fine-Design_Basic_Action_Add")); + menuDef.setIconPath(IconPathConstants.ADD_POPMENU_ICON_PATH); + menuDef.setRePaint(true); + menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Light_Theme"), config.getDefaultLightThemeName())); + menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Dark_Theme"), config.getDefaultDarkThemeName())); + + return menuDef; + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Dialog_Title"); + } + + private class RemoveThemeAction extends UpdateAction { + + public RemoveThemeAction(boolean initialEnabled) { + setEnabled(initialEnabled); + setName(Toolkit.i18nText("Fine-Design_Basic_Remove")); + setMnemonic('R'); + setSmallIcon(IOUtils.readIcon(IconPathConstants.TD_REMOVE_ICON_PATH)); + } + + @Override + public void actionPerformed(ActionEvent e) { + T theme = TemplateThemeManagePane.this.themeListPane.getSelectedTheme(); + if (theme == null) { + return; + } + int result = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(TemplateThemeManagePane.this), + Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Delete_Tip", theme.getName()), + Toolkit.i18nText("Fine-Design_Basic_Delete"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); + if (result == JOptionPane.YES_OPTION) { + config.removeTheme(theme.getName(), new CallBackAdaptor() { + @Override + public void afterRollback() { + super.afterRollback(); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TemplateThemeManagePane.this), + i18nText("Fine-Design_Basic_Template_Theme_Operation_Failed_Tip"), + i18nText("Fine-Design_Basic_Alert"), + JOptionPane.WARNING_MESSAGE); + } + }); + } + } + } + + private class AddThemeAction extends UpdateAction { + private final String prototypeThemeName; + + public AddThemeAction(String name, String prototypeThemeName) { + setName(name); + setMnemonic('R'); + this.prototypeThemeName = prototypeThemeName; + asyncThemeFetcher.submit(prototypeThemeName, null); + } + + @Override + public void actionPerformed(ActionEvent e) { + asyncThemeFetcher.submit(prototypeThemeName, new AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter() { + @Override + public void afterCachedFetch(T theme) { + super.afterCachedFetch(theme); + createNewTheme(theme); + } + }); + } + + private void createNewTheme(T prototypeTheme) { + Window parent = SwingUtilities.getWindowAncestor(TemplateThemeManagePane.this); + TemplateThemeProfileDialog profileDialog = new TemplateThemeProfileDialog<>(parent, profilePane); + try { + T theme = (T) prototypeTheme.clone(); + theme.setName(StringUtils.EMPTY); + theme.setMutable(true); + theme.setRemovable(true); + profilePane.populateBean(theme); + profileDialog.setVisible(true); + } catch (CloneNotSupportedException ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + } + } + } + + public static class BottomLineBorder extends LineBorder { + + private BottomLineBorder(Color color, int thickness) { + super(color, thickness); + } + + @Override + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + Graphics2D g2d = (Graphics2D)g; + + Color oldColor = g2d.getColor(); + Stroke oldStroke = g2d.getStroke(); + + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + g2d.setColor(getLineColor()); + g2d.setStroke(new BasicStroke(getThickness() * 2)); + g2d.drawLine(0, height, width, height + getThickness() * 2); + + g2d.setStroke(oldStroke); + g2d.setColor(oldColor); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); + } + } + + public void startListenThemeConfig() { + themeListPane.startListenThemeConfig(); + } + + public void stopListenThemeConfig() { + themeListPane.stopListenThemeConfig(); + } + + public void stopAsyncFetchTheme() { + asyncThemeFetcher.shutdown(); + themeListPane.stopAsyncFetchTheme(); + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java new file mode 100644 index 0000000000..fab425fbe7 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java @@ -0,0 +1,93 @@ +package com.fr.design.mainframe.theme; + +import com.fr.base.chart.chartdata.CallbackEvent; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.settings.ThemeThumbnail; +import com.fr.design.mainframe.theme.preview.ThemePreviewed; +import com.fr.log.FineLoggerFactory; + +import javax.swing.JPanel; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.RenderingHints; +import java.awt.Transparency; +import java.awt.image.BufferedImage; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/13 + */ +public abstract class TemplateThemePreviewPane extends JPanel implements CallbackEvent, ThemePreviewed { + private JPanel parent; + + public void setParent(JPanel parent) { + this.parent = parent; + } + + @Override + public void callback() { + if (parent != null) { + parent.repaint(); + } else { + this.repaint(); + } + } + + protected Image createThumbnailImage() { + BufferedImage image = null; + + int thumbnailWidth = ThemeThumbnail.WIDTH; + int thumbnailHeight = ThemeThumbnail.HEIGHT; + float thumbnailAspect = 1.0F * thumbnailWidth / thumbnailHeight; + + int width = getWidth(); + int height = getHeight(); + float aspect = 1.0F * width / height; + + if (thumbnailAspect > aspect) { + height = (int) (width / thumbnailAspect); + } else { + width = (int) (height * thumbnailAspect); + } + + try { + // 使用TYPE_INT_RGB和new Color(255, 255, 255, 1)设置有透明背景buffer image, + // 使得创建出来的透明像素是(255, 255, 255, 1),而不是(0, 0, 0, 0) + // 这样不支持透明通道缩略图的旧设计器打开新设计器创建的模版时,就不会创建出拥有黑色背景的缩略图 + image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + Graphics2D g2d = image.createGraphics(); + // 创建一个支持透明背景的buffer image + image = g2d.getDeviceConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT); + g2d.dispose(); + g2d = image.createGraphics(); + + g2d.fillRect(0, 0, width, height); + + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.clipRect(0, 0, width, height); + + paint(g2d); + + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + + if (image != null) { + return image.getScaledInstance(thumbnailWidth, thumbnailHeight, BufferedImage.SCALE_SMOOTH); + } + + return null; + } + + @Override + public void paintComponent(Graphics g) { + g.clearRect(0, 0, 517, 532); + paintBackground((Graphics2D) g); + } + + protected abstract void paintBackground(Graphics2D g); +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java new file mode 100644 index 0000000000..0abd6a7bc9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java @@ -0,0 +1,609 @@ +package com.fr.design.mainframe.theme; + +import com.fr.base.theme.FineColorManager; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeConfig; +import com.fr.base.theme.settings.ThemeThumbnail; +import com.fr.base.theme.settings.ThemedCellStyleList; +import com.fr.base.theme.settings.ThemedChartStyle; +import com.fr.base.theme.settings.ThemedColorScheme; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.gui.frpane.UITabbedPane; +import com.fr.design.gui.ibutton.UIButton; +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.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.theme.dialog.TemplateThemeProfileDialog; +import com.fr.design.mainframe.theme.edit.CellStyleListEditPane; +import com.fr.design.mainframe.theme.edit.ChartStyleEditPane; +import com.fr.design.mainframe.theme.edit.ui.ColorListExtendedPane; +import com.fr.design.mainframe.theme.edit.ui.ColorListPane; +import com.fr.design.mainframe.theme.edit.ui.LabelUtils; +import com.fr.design.mainframe.theme.ui.BorderUtils; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; +import com.fr.transaction.CallBackAdaptor; +import com.fr.transaction.Configurations; +import com.fr.transaction.WorkerFacade; + +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Image; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.List; + +import static com.fr.design.i18n.Toolkit.i18nText; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/13 + */ +public abstract class TemplateThemeProfilePane extends AbstractAttrNoScrollPane { + public static final int TITLE_BORDER_FONT = 12; + public static final int LEFT_TITLE_PANE_WIDTH = 397; + public static final int LEFT_TITLE_PANE_HEIGHT = 532 + TITLE_BORDER_FONT / 2 + 10; + public static final int PREVIEW_PANE_WIDTH = LEFT_TITLE_PANE_WIDTH - 10; + public static final int PREVIEW_PANE_HEIGHT = LEFT_TITLE_PANE_HEIGHT - TITLE_BORDER_FONT - 16; + + public static final int RIGHT_PANE_WIDTH = 362; + public static final int RIGHT_PANE_HEIGHT = LEFT_TITLE_PANE_HEIGHT; + public static final int COLOR_SCHEME_TITLE_PANE_WIDTH = 298; + public static final int COLOR_SCHEME_TITLE_PANE_HEIGHT = 174 + TITLE_BORDER_FONT / 2; + + protected TemplateThemePreviewPane themePreviewPane; + + protected UITextField nameTextField; + private UILabel nameErrorLabel; + protected ColorListPane colorListPane; + private ColorListExtendedPane colorListExtendedPane; + protected CellStyleListEditPane cellStyleSettingPane; + protected ChartStyleEditPane chartStyleSettingPane; + + protected boolean isPopulating = false; + protected UITabbedPane uiTabbedPane; + + private final TemplateThemeConfig config; + + private UIButton saveButton = new UIButton(); + private UIButton saveAsButton = new UIButton(); + + private boolean currentIsNewTheme; + private T theme; + + public TemplateThemeProfilePane(TemplateThemeConfig config) { + this.config = config; + theme = config.createNewTheme(); + } + @Override + protected JPanel createContentPane() { + JPanel container = new JPanel(new BorderLayout(5, 0)); + container.add(createLeftPane(), BorderLayout.CENTER); + container.add(createRightPane(), BorderLayout.EAST); + addAttributeChangeListener(new AttributeChangeListener() { + @Override + public void attributeChange() { + if (!isPopulating) { + valueChangeAction(); + } + } + }); + return container; + } + + @Override + protected void initContentPane() { + super.initContentPane(); + if (leftContentPane != null) { + // 修正 AbstractAttrNoScrollPane 的默认行为 + leftContentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 6)); + } + } + + public void valueChangeAction() { + themePreviewPane.refresh(updateBean()); + } + + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Dialog_Title"); + } + + private JPanel createLeftPane() { + JPanel titleContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); + titleContainer.setPreferredSize(new Dimension(LEFT_TITLE_PANE_WIDTH, LEFT_TITLE_PANE_HEIGHT)); + titleContainer.setBorder(BorderUtils.createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Preview_Pane_Title"), TITLE_BORDER_FONT)); + + JPanel previewContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); + previewContainer.setBorder(BorderFactory.createEmptyBorder(5, 4, 10, 4)); + titleContainer.add(previewContainer, BorderLayout.CENTER); + + themePreviewPane = createThemePreviewPane(); + themePreviewPane.setPreferredSize(new Dimension(PREVIEW_PANE_WIDTH, PREVIEW_PANE_HEIGHT)); + themePreviewPane.setPreferredSize(new Dimension(PREVIEW_PANE_WIDTH, PREVIEW_PANE_HEIGHT)); + + previewContainer.add(themePreviewPane, BorderLayout.CENTER); + + return titleContainer; + } + private JPanel createRightPane() { + JPanel container = new JPanel(new BorderLayout(0, 12)); + container.setPreferredSize(new Dimension(RIGHT_PANE_WIDTH, RIGHT_PANE_HEIGHT)); + JPanel nameEditPane = createNameEditPane(); + container.add(nameEditPane, BorderLayout.NORTH); + + JPanel settingPane = new JPanel(new BorderLayout(0, 10)); + container.add(settingPane, BorderLayout.CENTER); + settingPane.add(createColorSchemeEditPane(), BorderLayout.NORTH); + settingPane.add(createCustomEditorsPane(), BorderLayout.CENTER); + + uiTabbedPane.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + valueChangeAction(); + } + }); + + return container; + } + + private JPanel createNameEditPane() { + JPanel container = new JPanel(new BorderLayout(30, 0)); + container.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); + container.add(LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Name")), BorderLayout.WEST); + + JPanel settingContainer = new JPanel(new BorderLayout(10, 0)); + container.add(settingContainer, BorderLayout.CENTER); + + nameErrorLabel = LabelUtils.createLabel(StringUtils.EMPTY, Color.RED); + nameErrorLabel.setVisible(false); + + nameTextField = new UITextField(); + nameTextField.setEnabled(false); + nameTextField.setPreferredSize(new Dimension(165, 20)); + nameTextField.getDocument().addDocumentListener(new DocumentListener() { + @Override + public void insertUpdate(DocumentEvent e) { + if (isEnabled()) { + checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, nameTextField, nameErrorLabel, saveButton); + } + } + + @Override + public void removeUpdate(DocumentEvent e) { + if (isEnabled()) { + checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, nameTextField, nameErrorLabel, saveButton); + } + } + + @Override + public void changedUpdate(DocumentEvent e) { + + } + }); + nameTextField.addFocusListener(new FocusAdapter() { + @Override + public void focusGained(FocusEvent e) { + if (isEnabled()) { + checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, nameTextField, nameErrorLabel, saveButton); + } + } + + @Override + public void focusLost(FocusEvent e) { + if (isEnabled()) { + checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, nameTextField, nameErrorLabel, saveButton); + } + } + }); + + settingContainer.add(nameTextField, BorderLayout.WEST); + + settingContainer.add(nameErrorLabel, BorderLayout.CENTER); + + return container; + } + private JPanel createColorSchemeEditPane() { + colorListPane = new ColorListPane(); + colorListExtendedPane = new ColorListExtendedPane(); + + JPanel extendedContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); + colorListExtendedPane.setBackground(null); + colorListExtendedPane.setOpaque(false); + extendedContainer.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + extendedContainer.setBackground(Color.WHITE); + extendedContainer.add(colorListExtendedPane); + + double p = TableLayout.PREFERRED; + double[] rowSize = new double[]{p, p, p}; + double[] columnSize = {p, p}; + + JPanel previewLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + previewLabelPane.add(LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Preview_Label")), BorderLayout.NORTH); + + UILabel tipLabel = LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Edit_Tip"), new Color(153, 153, 153)); + tipLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); + + JPanel content = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ + {LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Edit_Label")), colorListPane}, + {null, tipLabel}, + {previewLabelPane, extendedContainer}, + }, + rowSize, columnSize, 18, 7); + content.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + + JPanel borderContainer = new JPanel(new BorderLayout()); + borderContainer.setPreferredSize(new Dimension(COLOR_SCHEME_TITLE_PANE_WIDTH, COLOR_SCHEME_TITLE_PANE_HEIGHT)); + borderContainer.setBorder(BorderUtils.createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Title"))); + borderContainer.add(content); + + JPanel container = new JPanel(new BorderLayout()); + container.add(borderContainer, BorderLayout.WEST); + + colorListPane.addColorChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + List colors = colorListPane.update(); + onColorSchemeChanged(colors); + } + }); + + return container; + } + protected JPanel createCustomEditorsPane() { + JPanel container = new JPanel(new BorderLayout()); + container.setBorder(BorderUtils.createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Custom_Settings_Title"))); + + uiTabbedPane = new UITabbedPane(); + uiTabbedPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 1)); + container.add(uiTabbedPane, BorderLayout.NORTH); + + return container; + } + public void addCustomEditorPane(String title, JComponent component) { + component.setPreferredSize(new Dimension(360, 260)); + uiTabbedPane.addTab(title, component); + } + protected JPanel createCellStyleSettingPane() { + JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + cellStyleSettingPane = new CellStyleListEditPane(); + cellStyleSettingPane.registerAttrChangeListener(new AttributeChangeListener() { + @Override + public void attributeChange() { + valueChangeAction(); + } + }); + container.add(cellStyleSettingPane); + return container; + } + protected JPanel createChartStyleSettingPane() { + JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + chartStyleSettingPane = new ChartStyleEditPane(); + container.add(chartStyleSettingPane); + return container; + } + + public abstract TemplateThemePreviewPane createThemePreviewPane(); + + public void onColorSchemeChanged(List colors) { + colorListExtendedPane.populate(colors); + FineColorManager.FineColorReplaceByColorScheme replaceByColorScheme = new FineColorManager.FineColorReplaceByColorScheme(colors); + ThemedCellStyleList cellStyle = cellStyleSettingPane.updateBean(); + FineColorManager.traverse(cellStyle, replaceByColorScheme); + + ThemedChartStyle themedChartStyle = chartStyleSettingPane.updateBean(); + FineColorManager.traverse(themedChartStyle, replaceByColorScheme); + chartStyleSettingPane.populateBean(themedChartStyle); + chartStyleSettingPane.populateGradientBar(colors); + } + + public void populateBean(T theme) { + try { + this.theme = (T) theme.clone(); + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + isPopulating = true; + + String name = theme.getName(); + + currentIsNewTheme = config.cachedFetch(name) == null; + + nameTextField.setText(name); + nameTextField.setEnabled(StringUtils.isEmpty(name)); + if (saveButton != null) { + saveButton.setEnabled(theme.isMutable() && !currentIsNewTheme); + } + if (saveAsButton != null) { + saveAsButton.setEnabled(!currentIsNewTheme); + } + + cellStyleSettingPane.populateBean(theme.getCellStyleList()); + colorListPane.populate(theme.getColorScheme().getColors()); + colorListExtendedPane.populate(colorListPane.update()); + chartStyleSettingPane.populateBean(theme.getChartStyle()); + themePreviewPane.refresh(theme); + isPopulating = false; + } + + public T updateBean() { + if (theme == null) { + theme = config.createNewTheme(); + } + + theme.setName(this.nameTextField.getText()); + + Image thumbnailImage = themePreviewPane.createThumbnailImage(); + if (thumbnailImage != null) { + ThemeThumbnail thumbnail = new ThemeThumbnail(); + thumbnail.setImage(thumbnailImage); + theme.setThumbnail(thumbnail); + } + + ThemedCellStyleList cellStyleConfig = this.cellStyleSettingPane.updateBean(); + theme.setCellStyleList(cellStyleConfig); + + ThemedColorScheme colorScheme = theme.getColorScheme(); + colorScheme.setColors(this.colorListPane.update()); + theme.setColorScheme(colorScheme); + + theme.setChartStyle(this.chartStyleSettingPane.updateBean()); + + updateBean(theme); + return theme; + } + + public List getCurrentColorScheme() { + return colorListPane.update(); + } + + protected abstract void updateBean(T theme); + + public UIButton createSaveButton() { + saveButton = new UIButton(); + saveButton.setText(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Save")); + saveButton.setEnabled(false); + saveButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + T theme = updateBean(); + boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(currentIsNewTheme, nameTextField, nameErrorLabel, saveButton); + if (canBeSaved && theme != null) { + theme.setName(nameTextField.getText()); + config.addTheme(theme, true, new CallBackAdaptor() { + @Override + public void afterCommit() { + super.afterCommit(); + currentIsNewTheme = false; + nameTextField.setEnabled(false); + saveAsButton.setEnabled(true); + } + + @Override + public void afterRollback() { + super.afterRollback(); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TemplateThemeProfilePane.this), + i18nText("Fine-Design_Basic_Template_Theme_Operation_Failed_Tip"), + i18nText("Fine-Design_Basic_Alert"), + JOptionPane.WARNING_MESSAGE); + } + }); + } + } + }); + return saveButton; + } + public UIButton createSaveAsButton(final TemplateThemeProfileDialog profileDialog) { + saveAsButton = new UIButton(); + saveAsButton.removeAll(); + saveAsButton.setText(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Save_As")); + saveAsButton.setEnabled(false); + saveAsButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + new SaveAsDialog(profileDialog).setVisible(true); + } + }); + return saveAsButton; + } + private class SaveAsDialog extends JDialog { + private final TemplateThemeProfileDialog parent; + + private UITextField nameTextField; + private UILabel nameErrorLabel; + private UIButton confirmButton; + + public SaveAsDialog(TemplateThemeProfileDialog dialog) { + super(dialog, ModalityType.APPLICATION_MODAL); + + setTitle(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Save_As_Dialog_Title")); + setResizable(false); + setSize(new Dimension(300, 140)); + GUICoreUtils.centerWindow(this); + + parent = dialog; + + initializeComponents(); + add(createContentPane(), BorderLayout.CENTER); + add(createActionsContainer(), BorderLayout.SOUTH); + + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + exit(); + } + }); + } + + private void initializeComponents() { + nameErrorLabel = LabelUtils.createLabel(StringUtils.EMPTY, Color.RED); + nameErrorLabel.setBorder(BorderFactory.createEmptyBorder(10, 20, 0, 0)); + + confirmButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Confirm")); + confirmButton.setEnabled(false); + confirmButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + saveAsNew(nameTextField.getText()); + } + }); + + nameTextField = new UITextField(); + nameTextField.getDocument().addDocumentListener(new DocumentListener() { + @Override + public void insertUpdate(DocumentEvent e) { + if (isEnabled()) { + checkThemeCanBeSavedAndUpdateUI(true, nameTextField, nameErrorLabel, confirmButton); + } + } + + @Override + public void removeUpdate(DocumentEvent e) { + if (isEnabled()) { + checkThemeCanBeSavedAndUpdateUI(true, nameTextField, nameErrorLabel, confirmButton); + } + } + + @Override + public void changedUpdate(DocumentEvent e) { + + } + }); + nameTextField.addFocusListener(new FocusAdapter() { + @Override + public void focusGained(FocusEvent e) { + if (isEnabled()) { + checkThemeCanBeSavedAndUpdateUI(true, nameTextField, nameErrorLabel, confirmButton); + } + } + + @Override + public void focusLost(FocusEvent e) { + if (isEnabled()) { + checkThemeCanBeSavedAndUpdateUI(true, nameTextField, nameErrorLabel, confirmButton); + } + } + }); + nameTextField.setPreferredSize(new Dimension(180, 20)); + } + + private JPanel createActionsContainer() { + + UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel")); + cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + exit(); + } + }); + + JPanel container = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); + container.add(confirmButton); + container.add(cancelButton); + + return container; + } + + private JPanel createContentPane() { + JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + + JPanel nameTextPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(20, 5); + nameTextPane.setBorder(BorderFactory.createEmptyBorder(20, 0, 0, 0)); + nameTextPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Save_As_Pane_Name_Label"))); + nameTextPane.add(nameTextField); + + container.add(nameTextPane, BorderLayout.CENTER); + container.add(nameErrorLabel, BorderLayout.SOUTH); + + return container; + } + + private void saveAsNew(String name) { + T newThemeObject = null; + try { + newThemeObject = (T) updateBean().clone(); + } catch (CloneNotSupportedException ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + return; + } + boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(true, nameTextField, nameErrorLabel, confirmButton); + if (canBeSaved && newThemeObject != null) { + newThemeObject.setName(name); + newThemeObject.setRemovable(true); + newThemeObject.setMutable(true); + config.addTheme(newThemeObject, true, new CallBackAdaptor() { + @Override + public void afterCommit() { + super.afterCommit(); + exit(); + parent.exit(); + } + + @Override + public void afterRollback() { + super.afterRollback(); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TemplateThemeProfilePane.this), + i18nText("Fine-Design_Basic_Template_Theme_Operation_Failed_Tip"), + i18nText("Fine-Design_Basic_Alert"), + JOptionPane.WARNING_MESSAGE); + } + }); + } + } + + public void exit() { + this.dispose(); + } + } + + private boolean isThemeNameEmpty(String name) { + return StringUtils.isEmpty(name); + } + private boolean isThemeNameDuplicated(String name) { + return config.cachedFetch(name) != null; + } + private boolean checkThemeCanBeSavedAndUpdateUI(boolean checkDuplicated, UITextField textField, UILabel errorLabel, UIButton... actionButtons) { + String error = StringUtils.EMPTY; + String name = textField.getText(); + if (isThemeNameEmpty(name)) { + error = Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Empty_Name_Error_Tip"); + } else if (checkDuplicated && isThemeNameDuplicated(name)) { + error = Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Duplicated_Name_Error_Tip"); + } + errorLabel.setText(error); + + boolean valid = StringUtils.isEmpty(error); + + errorLabel.setVisible(!valid); + if (actionButtons != null && actionButtons.length > 0) { + for (UIButton button : actionButtons) { + if (button != null) { + button.setEnabled(valid); + } + } + } + + return valid; + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeDialog.java new file mode 100644 index 0000000000..69a057d65f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeDialog.java @@ -0,0 +1,101 @@ +package com.fr.design.mainframe.theme.dialog; + +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.BorderFactory; +import javax.swing.JDialog; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Window; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/16 + */ +public abstract class TemplateThemeDialog extends JDialog { + public static final int DIALOG_TITLE_HEIGHT = 28; + + public static final int DIALOG_BOTTOM_ACTION_BAR_HEIGHT = 30; + public static final int DIALOG_BOTTOM_ACTION_BUTTON_GAP = 10; + public static final int DIALOG_BOTTOM_ACTION_BUTTON_HEIGHT = 20; + + public TemplateThemeDialog(Window parent, String title, int contentWidth, int contentHeight) { + super(parent, ModalityType.APPLICATION_MODAL); + + setTitle(title); + setResizable(false); + setLayout(FRGUIPaneFactory.createBorderLayout()); + + int dialogContentHeight = contentHeight + DIALOG_BOTTOM_ACTION_BAR_HEIGHT; + int dialogWindowHeight = dialogContentHeight + DIALOG_TITLE_HEIGHT; + + setSize(new Dimension(contentWidth, dialogWindowHeight)); + + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + exit(); + } + }); + GUICoreUtils.centerWindow(this); + } + + protected final JPanel createDialogContentPane(JPanel contentPane, UIButton[] rightButtons) { + JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + container.add(contentPane, BorderLayout.CENTER); + container.add(createActionsContainer(rightButtons), BorderLayout.SOUTH); + return container; + } + + protected final JPanel createDialogContentPane(JPanel contentPane, UIButton[] leftButtons, UIButton[] rightButtons) { + JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + container.add(contentPane, BorderLayout.CENTER); + container.add(createActionsContainer(leftButtons, rightButtons), BorderLayout.SOUTH); + return container; + } + + + private JPanel createActionsContainer(UIButton... buttons) { + return this.createActionsContainer(FlowLayout.RIGHT, buttons); + } + + private JPanel createActionsContainer(int align, UIButton... buttons) { + JPanel container = new JPanel(new FlowLayout(align, DIALOG_BOTTOM_ACTION_BUTTON_GAP, 0)); + int paddingVertical = (DIALOG_BOTTOM_ACTION_BAR_HEIGHT - DIALOG_BOTTOM_ACTION_BUTTON_HEIGHT) / 2; + container.setBorder(BorderFactory.createEmptyBorder(paddingVertical, 0, paddingVertical, 0)); + + if (buttons == null || buttons.length == 0) { + return container; + } + + for (UIButton button: buttons) { + if (button != null) { + button.setPreferredSize(new Dimension(button.getPreferredSize().width, DIALOG_BOTTOM_ACTION_BUTTON_HEIGHT)); + container.add(button); + } + } + + return container; + } + + private JPanel createActionsContainer(UIButton[] leftButtons, UIButton[] rightButtons) { + JPanel leftPane = createActionsContainer(FlowLayout.LEFT, leftButtons); + JPanel rightPane = createActionsContainer(FlowLayout.RIGHT, rightButtons); + + JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + container.add(leftPane, BorderLayout.WEST); + container.add(rightPane, BorderLayout.EAST); + + return container; + } + + public void exit() { + this.dispose(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeManageDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeManageDialog.java new file mode 100644 index 0000000000..e7acb8d8ad --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeManageDialog.java @@ -0,0 +1,93 @@ +package com.fr.design.mainframe.theme.dialog; + +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.ReportTheme; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeConfig; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.frpane.UITabbedPane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.theme.TemplateThemeManagePane; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/13 + */ +public class TemplateThemeManageDialog extends TemplateThemeDialog { + public static final int CONTENT_WIDTH = 660; + public static final int CONTENT_HEIGHT = 570; + + private final TemplateThemeManageDialogContentPane contentPane; + + public TemplateThemeManageDialog(Window parent) { + super(parent, Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Dialog_Title"), CONTENT_WIDTH, CONTENT_HEIGHT); + contentPane = new TemplateThemeManageDialogContentPane(); + + setContentPane(createDialogContentPane(contentPane, new UIButton[]{ createCompleteButton() })); + } + + private UIButton createCompleteButton() { + UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Dialog_Complete")); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + exit(); + } + }); + return button; + } + + @Override + public void exit(){ + contentPane.exit(); + super.exit(); + } + + public static class TemplateThemeManageDialogContentPane extends JPanel { + private final TemplateThemeManagePane formThemesManagerPane; + private final TemplateThemeManagePane reportThemesManagerPane; + + public TemplateThemeManageDialogContentPane() { + setLayout(FRGUIPaneFactory.createBorderLayout()); + setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); + + UITabbedPane tabbedPane = new UITabbedPane(); + add(tabbedPane, BorderLayout.NORTH); + + formThemesManagerPane = TemplateThemeManagePane.createFormThemesManagerPane(); + formThemesManagerPane.startListenThemeConfig(); + reportThemesManagerPane = TemplateThemeManagePane.createReportThemesManagerPane(); + reportThemesManagerPane.startListenThemeConfig(); + + tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Dialog_FORM_TAB"), formThemesManagerPane); + tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Dialog_REPORT_TAB"), reportThemesManagerPane); + + tabbedPane.setSelectedIndex(0); + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + TemplateThemeConfig config = template.getUsingTemplateThemeConfig(); + if (config == reportThemesManagerPane.getConfig()) { + tabbedPane.setSelectedIndex(1); + } + } + } + + public void exit() { + formThemesManagerPane.stopListenThemeConfig(); + formThemesManagerPane.stopAsyncFetchTheme(); + reportThemesManagerPane.stopListenThemeConfig(); + reportThemesManagerPane.stopAsyncFetchTheme(); + } + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java new file mode 100644 index 0000000000..f0eeb2f48b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java @@ -0,0 +1,145 @@ +package com.fr.design.mainframe.theme.dialog; + +import com.fr.base.theme.TemplateTheme; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.theme.TemplateThemeProfilePane; +import com.fr.file.FILE; +import com.fr.file.FILEChooserPane; +import com.fr.file.FileFILE; +import com.fr.file.filter.ChooseFileFilter; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.ListSet; +import com.fr.stable.xml.XMLPrintWriter; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.List; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/13 + */ +public class TemplateThemeProfileDialog extends TemplateThemeDialog { + + public static TemplateThemeProfilePane currentVisibleProfilePane; + + public static final int CONTENT_WIDTH = 910; + public static final int CONTENT_HEIGHT = 570; + + public TemplateThemeProfileDialog(Window parent, TemplateThemeProfilePane profilePane) { + super(parent, profilePane.getTitle(), CONTENT_WIDTH, CONTENT_HEIGHT); + + JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane(); + content.setPreferredSize(new Dimension(CONTENT_WIDTH, CONTENT_HEIGHT)); + content.add(profilePane, BorderLayout.CENTER); + + setContentPane(createDialogContentPane(content, new UIButton[]{ + // 用于视觉设计师导出内置主题文件,发布前关闭 + // 后续由产品经理决定是否开启此功能 + createExportButton(profilePane), + profilePane.createSaveButton(), + profilePane.createSaveAsButton(this), + createCancelButton() + })); + + currentVisibleProfilePane = profilePane; + } + + private void exportTheme(T theme) { + FILEChooserPane fileChooser = FILEChooserPane.getInstance(true, true, new ChooseFileFilter() { + @Override + public boolean accept(FILE f) { + return f.isDirectory(); + } + + @Override + public String getDescription() { + return "export theme to xml"; + } + + @Override + public boolean containsExtension(String extension) { + return true; + } + + @Override + public String toString() { + return getDescription(); + } + }); + fileChooser.setCurrentDirectory(new FileFILE(new File("~/"))); + fileChooser.setFileNameTextField(theme.getName(), ".xml"); + FILE exportedFile = null; + + int result = fileChooser.showSaveDialog(DesignerContext.getDesignerFrame(), ".xml"); + if (result == FILEChooserPane.JOPTIONPANE_OK_OPTION || result == FILEChooserPane.OK_OPTION) { + exportedFile = fileChooser.getSelectedFILE(); + } + if (exportedFile == null) { + return; + } + + try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(exportedFile.getPath()))) { + XMLPrintWriter writer = XMLPrintWriter.create(bos); + theme.writeXML(writer); + writer.flush(); + writer.close(); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + public UIButton createExportButton(TemplateThemeProfilePane profilePane) { + UIButton exportButton = new UIButton(); + exportButton.setText(Toolkit.i18nText("Fine-Design_Basic_Export")); + exportButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + T theme = profilePane.updateBean(); + theme.getImageIdList().setIdList(new ListSet<>()); + exportTheme(theme); + } + }); + return exportButton; + } + + private UIButton createCancelButton() { + UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel")); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + exit(); + } + }); + return button; + } + + @Override + public void exit() { + currentVisibleProfilePane = null; + super.exit(); + } + + public static List getEditingColorScheme() { + if (currentVisibleProfilePane != null) { + return currentVisibleProfilePane.getCurrentColorScheme(); + } + return null; + } + + public static boolean isEditingTheme() { + return currentVisibleProfilePane != null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java new file mode 100644 index 0000000000..1d17bb4eb2 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java @@ -0,0 +1,162 @@ +package com.fr.design.mainframe.theme.dialog; + +import com.fr.base.theme.ThemedTemplate; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeConfig; +import com.fr.design.base.mode.DesignModeContext; +import com.fr.design.event.ChangeEvent; +import com.fr.design.event.ChangeListener; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.theme.TemplateThemeListPane; +import com.fr.design.mainframe.theme.ui.BorderUtils; +import com.fr.stable.StringUtils; +import com.fr.workspace.WorkContext; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.border.CompoundBorder; +import java.awt.BorderLayout; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/13 + */ +public class +TemplateThemeUsingDialog extends TemplateThemeDialog { + public static final int CONTENT_WIDTH = 660; + public static final int CONTENT_HEIGHT = 515; + + private final TemplateThemeListPane themeListPane; + private final ThemedTemplate currentTemplate; + + public TemplateThemeUsingDialog(Window parent, ThemedTemplate template, TemplateThemeConfig config) { + super(parent, Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Using_Dialog_Title"), CONTENT_WIDTH, CONTENT_HEIGHT); + + this.currentTemplate = template; + this.themeListPane = new TemplateThemeListPane<>(false, config, null); + + JPanel content = createContent(); + UIButton openThemeManagerButton = createOpenThemeManagerButton(); + UIButton usingCurrentThemeButton = createUsingCurrentThemeButton(); + UIButton completeButton = createCompleteButton(); + + setContentPane(createDialogContentPane(content, + new UIButton[]{ openThemeManagerButton }, + new UIButton[]{ usingCurrentThemeButton, completeButton } + )); + + themeListPane.startListenThemeConfig(); + + resetEnableCurrentThemeButton(themeListPane.getSelectedTheme(), usingCurrentThemeButton); + themeListPane.setSelectedChangeListener(new ChangeListener() { + @Override + public void fireChanged(ChangeEvent event) { + resetEnableCurrentThemeButton(themeListPane.getSelectedTheme(), usingCurrentThemeButton); + } + }); + } + + private void resetEnableCurrentThemeButton(T selectedTheme, UIButton usingCurrentThemeButton) { + if (selectedTheme == null) { + usingCurrentThemeButton.setEnabled(false); + return; + } + String selectedThemeName = selectedTheme.getName(); + if (StringUtils.isEmpty(selectedThemeName)) { + usingCurrentThemeButton.setEnabled(false); + return; + } + + if (currentTemplate == null) { + usingCurrentThemeButton.setEnabled(false); + return; + } + + TemplateTheme templateUsingTheme = currentTemplate.getTemplateTheme(); + if (templateUsingTheme == null) { + usingCurrentThemeButton.setEnabled(true); + return; + } + + String templateUsingThemeName = templateUsingTheme.getName(); + if (StringUtils.isEmpty(templateUsingThemeName)) { + usingCurrentThemeButton.setEnabled(true); + return; + } + + usingCurrentThemeButton.setEnabled(!StringUtils.equals(templateUsingThemeName, selectedTheme.getName())); + } + + private JPanel createContent() { + JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + container.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); + + JPanel themeListPaneContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); + themeListPaneContainer.setBorder(new CompoundBorder( + BorderUtils.createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Using_Dialog_Select"), 12), + BorderFactory.createEmptyBorder(0, 10, 0, 10) + )); + themeListPaneContainer.add(themeListPane, BorderLayout.CENTER); + container.add(themeListPaneContainer, BorderLayout.CENTER); + + return container; + } + + private UIButton createOpenThemeManagerButton() { + if (WorkContext.getCurrent().isRoot()) { + UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Dialog_Title")); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + TemplateThemeManageDialog dialog = new TemplateThemeManageDialog(TemplateThemeUsingDialog.this); + dialog.setVisible(true); + } + }); + return button; + } + return null; + } + + private UIButton createUsingCurrentThemeButton() { + UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Using_Dialog_Use")); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + apply2CurrentTemplate(button); + } + }); + return button; + } + + private UIButton createCompleteButton() { + UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Using_Dialog_Complete")); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + exit(); + } + }); + return button; + } + + public void exit() { + themeListPane.stopListenThemeConfig(); + themeListPane.stopAsyncFetchTheme(); + super.exit(); + } + + private void apply2CurrentTemplate(UIButton usingCurrentThemeButton) { + TemplateTheme theme = themeListPane.getSelectedTheme(); + if (theme != null) { + currentTemplate.setTemplateTheme(theme); + themeListPane.repaint(); + usingCurrentThemeButton.setEnabled(false); + } + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java new file mode 100644 index 0000000000..e0e42b8b48 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java @@ -0,0 +1,294 @@ +package com.fr.design.mainframe.theme.edit; + +import com.fr.base.Style; +import com.fr.base.theme.settings.ThemedCellStyle; +import com.fr.base.theme.settings.ThemedCellStyleList; +import com.fr.config.predefined.PredefinedCellStyle; +import com.fr.design.actions.UpdateAction; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.gui.NameInspector; +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.controlpane.UnrepeatedNameHelper; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.gui.ilist.DefaultListCellEditor; +import com.fr.design.gui.ilist.JNameEdList; +import com.fr.design.gui.ilist.ListModelElement; +import com.fr.design.gui.ilist.ModNameActionListener; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.icon.IconPathConstants; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.theme.edit.cell.CellStyleEditPane; +import com.fr.design.mainframe.theme.edit.cell.NoBorderPaneCellStyleEditPane; +import com.fr.design.menu.ShortCut; +import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; +import com.fr.general.NameObject; +import com.fr.stable.Nameable; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static com.fr.design.i18n.Toolkit.i18nText; + +/** + * Created by kerry on 2020-09-27 + */ +public class CellStyleListEditPane extends JListControlPane { + private boolean namePermitted = true; + private AttributeChangeListener attributeChangeListener; + + public CellStyleListEditPane() { + super(); + setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5)); + addModNameActionListener(new ModNameActionListener() { + public void nameModed(int index, String oldName, String newName) { + if (ComparatorUtils.equals(oldName, newName) || ComparatorUtils.equals(newName, NameInspector.ILLEGAL_NAME_HOLDER)) { + return; + } + namePermitted = true; + String[] allNames = nameableList.getAllNames(); + allNames[index] = StringUtils.EMPTY; + if (StringUtils.isEmpty(newName)) { + showTipDialogAndReset(i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Cell_Style_Empty_Name_Tip"), index); + nameableList.setNameAt(oldName, index); + return; + } + if (isNameRepeated(new List[]{Arrays.asList(allNames)}, newName)) { + showTipDialogAndReset(i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Cell_Style_Duplicated_Name_Tip", newName), index); + nameableList.setNameAt(oldName, index); + return; + } + populateSelectedValue(); + } + }); + } + + public void registerAttrChangeListener(AttributeChangeListener listener){ + this.attributeChangeListener = listener; + } + + + private void showTipDialogAndReset(String content, int index) { + nameableList.stopEditing(); + + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(CellStyleListEditPane.this), + content, + i18nText("Fine-Design_Basic_Alert"), + JOptionPane.WARNING_MESSAGE); + setIllegalIndex(index); + namePermitted = false; + } + + @Override + public NameableCreator[] createNameableCreators() { + return new NameableCreator[]{ new DefaultCellStyleNameObjectCreator(), new CellStyleNameObjectCreator() }; + } + + @Override + protected JNameEdList createJNameList() { + JNameEdList nameEdList = super.createJNameList(); + nameEdList.setCellEditor(new DefaultListCellEditor(new UITextField()) { + @Override + public Component getListCellEditorComponent(JList list, Object value, boolean isSelected, int index) { + ListModelElement element = (ListModelElement) getModel().getElementAt(index); + if (element != null) { + NameObject selectNameObject = (NameObject) element.wrapper; + ThemedCellStyle cellStyle = (ThemedCellStyle) (selectNameObject.getObject()); + if (!cellStyle.isRemovable()) { + return null; + } + } + return super.getListCellEditorComponent(list, value, isSelected, index); + } + }); + return nameEdList; + } + + @Override + public BasicBeanPane createPaneByCreators(NameableCreator creator) { + CellStyleEditPane stylePane = (CellStyleEditPane) super.createPaneByCreators(creator); + stylePane.registerAttrChangeListener(attributeChangeListener); + return stylePane; + } + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } + + protected void initComponentPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setCreators(this.createNameableCreators()); + initCardPane(); + JPanel leftPane = getLeftPane(); + leftPane.setPreferredSize(new Dimension(90, 0)); + cardPane.setPreferredSize(new Dimension(270, 0)); + JPanel mainSplitPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + mainSplitPane.add(leftPane, BorderLayout.WEST); + mainSplitPane.add(cardPane, BorderLayout.CENTER); + + this.add(mainSplitPane, BorderLayout.CENTER); + this.checkButtonEnabled(); + } + + @Override + protected void initToolBar() { + super.initToolBar(); + UIToolbar toolbar = getToolBar(); + toolbar.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + } + + @Override + protected ShortCut4JControlPane[] createShortcuts() { + return new ShortCut4JControlPane[]{ + createAddItemShortCut4JControlPane(), + new RemoveItemShortCut4JControlPane(new RemoveItemAction()) + }; + } + + private ShortCut4JControlPane createAddItemShortCut4JControlPane (){ + ShortCut shortCut = shortCutFactory.createAddItemUpdateAction(new NameableCreator[]{new CellStyleNameObjectCreator()}); + return new AddItemShortCut4JControlPane(shortCut); + } + + public void populateBean(ThemedCellStyleList ob) { + if (ob == null) { + return; + } + + List nameObjectList = new ArrayList<>(); + + List cellStyleList = ob.getCellStyleList(); + for (ThemedCellStyle cellStyle: cellStyleList) { + nameObjectList.add(new NameObject(cellStyle.getName(), cellStyle)); + } + + NameObject[] nameObjectArray = new NameObject[nameObjectList.size()]; + nameObjectList.toArray(nameObjectArray); + + populate(nameObjectArray); + + } + + public ThemedCellStyleList updateBean() { + Nameable[] nameables = this.update(); + ThemedCellStyleList styleConfig = new ThemedCellStyleList(); + for (Nameable nameable : nameables) { + ThemedCellStyle tmpStyle = (ThemedCellStyle) ((NameObject) nameable).getObject(); + tmpStyle.setName(nameable.getName()); + styleConfig.addThemedCellStyle(tmpStyle); + } + return styleConfig; + } + + private static class AddItemShortCut4JControlPane extends ShortCut4JControlPane{ + AddItemShortCut4JControlPane(ShortCut shortCut) { + this.shortCut = shortCut; + } + + @Override + public void checkEnable() { + this.shortCut.setEnabled(true); + } + } + + private class RemoveItemShortCut4JControlPane extends ShortCut4JControlPane { + RemoveItemShortCut4JControlPane(ShortCut shortCut) { + this.shortCut = shortCut; + } + + @Override + public void checkEnable() { + ListModelElement selectModel = CellStyleListEditPane.this.getSelectedValue(); + if (selectModel != null) { + NameObject selectNameObject = (NameObject) selectModel.wrapper; + ThemedCellStyle cellStyle = (ThemedCellStyle) (selectNameObject.getObject()); + this.shortCut.setEnabled(cellStyle.isRemovable() && !cellStyle.isDefault4New()); + } else { + this.shortCut.setEnabled(false); + } + + } + } + + private class RemoveItemAction extends UpdateAction { + RemoveItemAction() { + setName(i18nText(("Fine-Design_Basic_Action_Remove"))); + setMnemonic('R'); + setSmallIcon(IOUtils.readIcon(IconPathConstants.TD_REMOVE_ICON_PATH)); + } + + @Override + public void actionPerformed(ActionEvent evt) { + CellStyleListEditPane.this.onRemoveItem(); + } + } + + private static class CellStyleNameObjectCreator extends NameObjectCreator { + + public CellStyleNameObjectCreator() { + this(CellStyleEditPane.class); + } + + public CellStyleNameObjectCreator(Class updatePane) { + super(i18nText("Fine-Design_Predefined_Cell_New_Style"), ThemedCellStyle.class, updatePane); + } + + @Override + public Nameable createNameable(UnrepeatedNameHelper helper) { + ThemedCellStyle cellStyle = new ThemedCellStyle(); + cellStyle.setName(menuName); + cellStyle.setStyle(Style.getInstance()); + cellStyle.setRemovable(true); + cellStyle.setImmutable(true); + cellStyle.setDefault4Absent(false); + cellStyle.setDefault4New(false); + return new NameObject(helper.createUnrepeatedName(this.menuName()), cellStyle); + } + + @Override + public Object acceptObject2Populate(Object ob) { + if (ob instanceof NameObject) { + ob = ((NameObject) ob).getObject(); + } + if (clazzOfObject != null && clazzOfObject.isInstance(ob) && acceptNameObject(ob)) { + doSthChanged4Icon(ob); + return ob; + } + return null; + } + + public boolean acceptNameObject(Object ob) { + return !((ThemedCellStyle) ob).isDefault4New(); + } + } + + private static class DefaultCellStyleNameObjectCreator extends CellStyleNameObjectCreator { + + public DefaultCellStyleNameObjectCreator() { + super(NoBorderPaneCellStyleEditPane.class); + } + + @Override + public boolean acceptNameObject(Object ob) { + return ((ThemedCellStyle) ob).isDefault4New(); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ChartStyleEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ChartStyleEditPane.java new file mode 100644 index 0000000000..3830f02f15 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ChartStyleEditPane.java @@ -0,0 +1,104 @@ +package com.fr.design.mainframe.theme.edit; + +import com.fr.base.theme.settings.ThemedChartStyle; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.MultiTabPane; +import com.fr.design.mainframe.theme.edit.chart.ChartAxisStylePane; +import com.fr.design.mainframe.theme.edit.chart.ChartDataSheetStylePane; +import com.fr.design.mainframe.theme.edit.chart.ChartLabelStylePane; +import com.fr.design.mainframe.theme.edit.chart.ChartLegendStylePane; +import com.fr.design.mainframe.theme.edit.chart.ChartSeriesStylePane; +import com.fr.design.mainframe.theme.edit.chart.ChartTitleAndBackgroundStylePane; + +import javax.swing.BorderFactory; +import java.util.ArrayList; +import java.util.List; +import java.awt.Color; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-16 + */ +public class ChartStyleEditPane extends MultiTabPane { + + private ChartSeriesStylePane chartSeriesStylePane; + private ChartLegendStylePane chartLegendStylePane; + private ChartLabelStylePane chartLabelPane; + private ChartAxisStylePane chartAxisStylePane; + private ChartDataSheetStylePane chartDataSheetStylePane; + private ChartTitleAndBackgroundStylePane chartTitleAndBackgroundStylePane; + + public ChartStyleEditPane() { + } + + @Override + protected void initLayout() { + super.initLayout(); + setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + } + + @Override + protected List initPaneList() { + this.chartSeriesStylePane = new ChartSeriesStylePane(); + this.chartLegendStylePane = new ChartLegendStylePane(); + this.chartLabelPane = new ChartLabelStylePane(); + this.chartAxisStylePane = new ChartAxisStylePane(); + this.chartDataSheetStylePane = new ChartDataSheetStylePane(); + this.chartTitleAndBackgroundStylePane = createChartTitleAndBackgroundStylePane(); + paneList = new ArrayList<>(); + paneList.add(this.chartSeriesStylePane); + paneList.add(this.chartLegendStylePane); + paneList.add(this.chartLabelPane); + paneList.add(this.chartAxisStylePane); + paneList.add(this.chartDataSheetStylePane); + paneList.add(this.chartTitleAndBackgroundStylePane); + return paneList; + } + + protected ChartTitleAndBackgroundStylePane createChartTitleAndBackgroundStylePane() { + return new ChartTitleAndBackgroundStylePane(); + } + + @Override + public void populateBean(ThemedChartStyle ob) { + chartSeriesStylePane.populate(ob); + chartLegendStylePane.populate(ob); + chartLabelPane.populate(ob); + chartAxisStylePane.populate(ob); + chartDataSheetStylePane.populate(ob); + chartTitleAndBackgroundStylePane.populate(ob); + } + + @Override + public void updateBean(ThemedChartStyle ob) { + + } + + + @Override + public ThemedChartStyle updateBean() { + ThemedChartStyle chartStyle = new ThemedChartStyle(); + chartSeriesStylePane.update(chartStyle); + chartLegendStylePane.update(chartStyle); + chartLabelPane.update(chartStyle); + chartAxisStylePane.update(chartStyle); + chartDataSheetStylePane.update(chartStyle); + chartTitleAndBackgroundStylePane.update(chartStyle); + return chartStyle; + } + + public void populateGradientBar(List colors) { + chartSeriesStylePane.populateGradientBar(colors); + } + + @Override + public boolean accept(Object ob) { + return false; + } + + @Override + public void reset() { + + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ChartStyleFormEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ChartStyleFormEditPane.java new file mode 100644 index 0000000000..f0886804d3 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ChartStyleFormEditPane.java @@ -0,0 +1,16 @@ +package com.fr.design.mainframe.theme.edit; + +import com.fr.design.mainframe.theme.edit.chart.ChartTitleAndBackgroundStyleFormPane; +import com.fr.design.mainframe.theme.edit.chart.ChartTitleAndBackgroundStylePane; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2021-08-30 + */ +public class ChartStyleFormEditPane extends ChartStyleEditPane { + + protected ChartTitleAndBackgroundStylePane createChartTitleAndBackgroundStylePane() { + return new ChartTitleAndBackgroundStyleFormPane(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ComponentStyleEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ComponentStyleEditPane.java new file mode 100644 index 0000000000..87a12a9ddf --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ComponentStyleEditPane.java @@ -0,0 +1,136 @@ +package com.fr.design.mainframe.theme.edit; + +import com.fr.base.theme.settings.ThemedComponentStyle; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.style.ComponentBodyStylePane; +import com.fr.design.gui.style.ComponentIntegralStylePane; +import com.fr.design.gui.style.ComponentTitleStylePane; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.theme.edit.component.ComponentMarginStylePane; +import com.fr.design.mainframe.theme.edit.ui.LabelUtils; +import com.fr.design.mainframe.theme.edit.ui.TabbedPane; +import com.fr.form.ui.LayoutBorderStyle; +import com.fr.general.act.BorderPacker; + +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/12 + */ +public class ComponentStyleEditPane extends JPanel { + public static final int LABEL_WIDTH = 60; + public static final int SETTING_WIDTH = 193; + + private final ComponentTitleStylePane componentTitleStylePane; + private final ComponentBodyStylePane componentBodyStylePane; + private final ExtendedComponentIntegralStylePane componentIntegralStylePane; + + public ComponentStyleEditPane() { + setLayout(FRGUIPaneFactory.createBorderLayout()); + componentTitleStylePane = new ThemedComponentTitleStylePane(LABEL_WIDTH, SETTING_WIDTH); + componentBodyStylePane = new ComponentBodyStylePane(LABEL_WIDTH, SETTING_WIDTH); + componentIntegralStylePane = new ExtendedComponentIntegralStylePane(); + + JPanel content = new TabbedPane( + new String[] { + Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Component_Title"), + Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Component_Body"), + Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Component_Integral") + }, + new JComponent[] { createTabContainer(componentTitleStylePane), createTabContainer(componentBodyStylePane), createTabContainer(componentIntegralStylePane) } + ); + add(content, BorderLayout.NORTH); + } + + public void populateBean(ThemedComponentStyle style) { + componentTitleStylePane.populateBean(style.getStyle()); + componentBodyStylePane.populateBean(style.getStyle()); + componentIntegralStylePane.populateBean(style); + } + + public ThemedComponentStyle updateBean() { + ThemedComponentStyle style = new ThemedComponentStyle(); + + componentTitleStylePane.updateBean(style.getStyle()); + componentBodyStylePane.updateBean(style.getStyle()); + componentIntegralStylePane.updateBean(style); + return style; + } + + private static class ExtendedComponentIntegralStylePane extends JPanel { + private final ComponentIntegralStylePane integralStylePane; + private final ComponentMarginStylePane marginStylePane; + + public ExtendedComponentIntegralStylePane() { + setLayout(new BorderLayout(0, IntervalConstants.INTERVAL_L1)); + integralStylePane = new ComponentIntegralStylePane(LABEL_WIDTH, SETTING_WIDTH); + marginStylePane = new ComponentMarginStylePane(LABEL_WIDTH, SETTING_WIDTH); + + add(integralStylePane, BorderLayout.NORTH); + add(marginStylePane, BorderLayout.CENTER); + } + + public void populateBean(ThemedComponentStyle style) { + integralStylePane.populateBean(style.getStyle()); + marginStylePane.populate(style); + } + + public void updateBean(ThemedComponentStyle style) { + integralStylePane.updateBean(style.getStyle()); + marginStylePane.update(style); + } + } + + private static class ThemedComponentTitleStylePane extends ComponentTitleStylePane { + + public ThemedComponentTitleStylePane(int uiLabelWidth, int uiSettingWidth) { + super(uiLabelWidth, uiSettingWidth); + setSupportTitleVisible(false); + setSupportTitleContent(false); + setSupportOtherSetting(true); + } + + @Override + public void populateBean(BorderPacker style) { + style.setType(LayoutBorderStyle.TITLE); + super.populateBean(style); + } + + @Override + public void updateBean(BorderPacker style) { + super.updateBean(style); + style.setType(LayoutBorderStyle.TITLE); + } + } + + private JComponent createTabContainer(final JComponent component) { + JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + container.setPreferredSize(new Dimension(container.getPreferredSize().width, 220)); + + JPanel tipLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + tipLabelPane.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0)); + UILabel tipLabel = LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Component_Style_Tip"), new Color(153, 153, 153)); + tipLabelPane.add(tipLabel); + container.add(tipLabelPane, BorderLayout.NORTH); + + JScrollPane scrollPane = new JScrollPane(component); + scrollPane.setPreferredSize(new Dimension(container.getPreferredSize().width, 220)); + scrollPane.setBorder(BorderFactory.createEmptyBorder()); + scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + + container.add(scrollPane, BorderLayout.CENTER); + + return container; + + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/FormBodyStyleEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/FormBodyStyleEditPane.java new file mode 100644 index 0000000000..1f2089e69d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/FormBodyStyleEditPane.java @@ -0,0 +1,44 @@ +package com.fr.design.mainframe.theme.edit; + +import com.fr.base.theme.settings.ThemedFormBodyStyle; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.gui.style.ComponentBodyStylePane; + +import javax.swing.BorderFactory; +import javax.swing.JScrollPane; +import javax.swing.ScrollPaneConstants; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/12 + */ +public class FormBodyStyleEditPane extends JScrollPane { + public static final int LABEL_WIDTH = 60; + public static final int SETTING_WIDTH = 193; + + private final ComponentBodyStylePane bodyStylePane; + + public FormBodyStyleEditPane() { + bodyStylePane = new ComponentBodyStylePane(LABEL_WIDTH, SETTING_WIDTH); + bodyStylePane.setBorder(BorderFactory.createEmptyBorder( + IntervalConstants.INTERVAL_L1, + IntervalConstants.INTERVAL_L1, + IntervalConstants.INTERVAL_L1, + IntervalConstants.INTERVAL_L1 + )); + setViewportView(bodyStylePane); + setBorder(BorderFactory.createEmptyBorder()); + setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); + } + + public void populateBean(ThemedFormBodyStyle style) { + bodyStylePane.populateBean(style.getStyle()); + } + + public ThemedFormBodyStyle updateBean() { + ThemedFormBodyStyle formBodyStyle = new ThemedFormBodyStyle(); + bodyStylePane.updateBean(formBodyStyle.getStyle()); + return formBodyStyle; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ReportBodyStyleEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ReportBodyStyleEditPane.java new file mode 100644 index 0000000000..ec36c29703 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ReportBodyStyleEditPane.java @@ -0,0 +1,65 @@ +package com.fr.design.mainframe.theme.edit; + +import com.fr.base.theme.settings.ThemedReportBodyStyle; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.style.ReportBackgroundSpecialPane; +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.predefined.ui.detail.background.BackgroundSettingPane; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ScrollPaneConstants; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/12 + */ +public class ReportBodyStyleEditPane extends JScrollPane { + public static final int LABEL_WIDTH = 60; + public static final int SETTING_WIDTH = 193; + + private final ReportBackgroundSpecialPane backgroundPane; + + public ReportBodyStyleEditPane() { + backgroundPane = new ReportBackgroundSpecialPane(); + + double p = TableLayout.PREFERRED; + + JPanel uiLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + uiLabelPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_Background_Fill")), BorderLayout.NORTH); + uiLabelPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + JPanel backgroundLabeledPane = TableLayoutHelper.createCommonTableLayoutPane( + new Component[][]{ new Component[] { uiLabelPane, backgroundPane } }, + new double[] { p }, new double[] { LABEL_WIDTH, SETTING_WIDTH}, IntervalConstants.INTERVAL_L1 + ); + backgroundLabeledPane.setBorder(BorderFactory.createEmptyBorder( + IntervalConstants.INTERVAL_L1, + IntervalConstants.INTERVAL_L1, + IntervalConstants.INTERVAL_L1, + IntervalConstants.INTERVAL_L1 + )); + + setViewportView(backgroundLabeledPane); + setBorder(BorderFactory.createEmptyBorder()); + setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); + } + + public void populateBean(ThemedReportBodyStyle style) { + backgroundPane.populateBean(style.getBackground()); + } + + public ThemedReportBodyStyle updateBean() { + ThemedReportBodyStyle style = new ThemedReportBodyStyle(); + style.setBackground(backgroundPane.update()); + return style; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/AbstractBackgroundDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/AbstractBackgroundDetailPane.java new file mode 100644 index 0000000000..76f948ffdb --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/AbstractBackgroundDetailPane.java @@ -0,0 +1,51 @@ +package com.fr.design.mainframe.theme.edit.background; + +import com.fr.design.event.UIObserverListener; +import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; +import com.fr.general.Background; + +import javax.swing.event.ChangeListener; + +/** + * Created by kerry on 2020-09-14 + */ +public abstract class AbstractBackgroundDetailPane extends BackgroundQuickPane { + @Override + public boolean accept(Background background) { + return false; + } + + @Override + public void populateBean(Background background) { + this.populate((T) background); + } + + @Override + public Background updateBean() { + return this.update(); + } + + @Override + public String title4PopupWindow() { + return null; + } + + @Override + public void reset() { + + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + + } + + public abstract void populate(T background); + + public abstract T update(); + + public void addChangeListener(ChangeListener changeListener) { + + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/BackgroundSettingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/BackgroundSettingPane.java new file mode 100644 index 0000000000..667c601141 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/BackgroundSettingPane.java @@ -0,0 +1,136 @@ +package com.fr.design.mainframe.theme.edit.background; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.event.UIObserverListener; +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.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; +import com.fr.general.Background; +import com.fr.log.FineLoggerFactory; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +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; + +/** + * Created by kerry on 2020-09-02 + */ +public class BackgroundSettingPane extends BasicBeanPane { + private ChangeListener changeListener = null; + private UIComboBox headCombobox; + private BackgroundQuickPane[] paneList; + + public BackgroundSettingPane() { + init(); + } + + private void init() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.add(createComboHeadPane(), BorderLayout.NORTH); + CardLayout cardlayout = new CardLayout(); + paneList = supportKindsOfBackgroundUI(); + final JPanel centerPane = new JPanel(cardlayout) { + @Override + public Dimension getPreferredSize() {// AUGUST:使用当前面板的的高度 + int index = headCombobox.getSelectedIndex(); + return new Dimension(super.getPreferredSize().width, paneList[index].getPreferredSize().height); + } + }; + centerPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); + for (BackgroundQuickPane pane : paneList) { + headCombobox.addItem(pane.title4PopupWindow()); + centerPane.add(pane, pane.title4PopupWindow()); + } + headCombobox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + cardlayout.show(centerPane, (String) headCombobox.getSelectedItem()); + } + }); + this.add(centerPane, BorderLayout.CENTER); + } + + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + + private JPanel createComboHeadPane() { + headCombobox = new UIComboBox(); + + JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Fill")), headCombobox}}, + TableLayoutHelper.FILL_NONE, 33, 5); + headCombobox.setPreferredSize(new Dimension(160, 20)); + jPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); + return jPanel; + } + + protected BackgroundQuickPane[] supportKindsOfBackgroundUI() { + java.util.List kinds = new ArrayList<>(); + kinds.add(new EmptyBackgroundPane()); + kinds.add(new ColorDetailPane()); + kinds.add(new TextureDetailObservePane()); + kinds.add(new PatternDetailPane()); + kinds.add(createImageSelectPane()); + kinds.add(new GradientDetailPane()); + return kinds.toArray(new BackgroundQuickPane[kinds.size()]); + } + + protected ImageDetailPane createImageSelectPane() { + ImageDetailPane imageDetailPane = new ImageDetailPane(); + imageDetailPane.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + fireChangeListener(); + } + }); + return imageDetailPane; + } + + protected void fireChangeListener() { + if (changeListener != null) { + changeListener.stateChanged(null); + } + } + + + @Override + public void populateBean(Background background) { + for (int i = 0; i < paneList.length; i++) { + BackgroundQuickPane pane = paneList[i]; + if (pane.accept(background)) { + pane.populateBean(background); + headCombobox.setSelectedIndex(i); + return; + } + } + } + + @Override + public Background updateBean() { + int selectIndex = this.headCombobox.getSelectedIndex(); + try { + return paneList[selectIndex].updateBean(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return null; + } + + @Override + protected String title4PopupWindow() { + return null; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/ColorDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/ColorDetailPane.java new file mode 100644 index 0000000000..12eea2c520 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/ColorDetailPane.java @@ -0,0 +1,105 @@ +package com.fr.design.mainframe.theme.edit.background; + +import com.fr.base.background.ColorBackground; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.color.ColorSelectPane; +import com.fr.general.Background; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; + +/** + * Created by kerry on 2020-08-31 + */ +public class ColorDetailPane extends AbstractBackgroundDetailPane { + public static final String SPACE_4 = " "; + private ColorBackgroundSelectPane selectPane; + + + public ColorDetailPane() { + this.selectPane = new ColorBackgroundSelectPane(); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.add(this.selectPane, BorderLayout.CENTER); + } + + @Override + public void populate(ColorBackground background) { + this.selectPane.setColor(background.getColor()); + } + + @Override + public ColorBackground update() { + return ColorBackground.getInstance(selectPane.getColor()); + } + + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Basic_Color"); + } + + @Override + public boolean accept(Background background) { + return background instanceof ColorBackground; + } + + class ColorBackgroundSelectPane extends ColorSelectPane implements UIObserver { + protected UIObserverListener uiObserverListener; + + protected void initialCompents(boolean isSupportTransparent) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder()); + if (isSupportTransparent) { + this.add(createNorthPane(), BorderLayout.NORTH); + } + JPanel centerPane = createCenterPane(); + this.add(centerPane, BorderLayout.CENTER); + this.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (uiObserverListener != null) { + uiObserverListener.doChange(); + } + } + }); + } + + private JPanel createNorthPane() { + UIButton transpanrentBtn = new UIButton(); + transpanrentBtn.setPreferredSize(new Dimension(160, 20)); + JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Background_Color")), + transpanrentBtn}}, TableLayoutHelper.FILL_NONE, 33, 5); + jPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 10)); + return jPanel; + } + + protected JPanel createCenterPane() { + JPanel centerPane = new JPanel(); + + JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{new UILabel(SPACE_4), centerPane}}, TableLayoutHelper.FILL_NONE, 33, 5); + jPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 10)); + return jPanel; + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.uiObserverListener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/EmptyBackgroundPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/EmptyBackgroundPane.java new file mode 100644 index 0000000000..b7b345c63a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/EmptyBackgroundPane.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.theme.edit.background; + +import com.fr.design.i18n.Toolkit; +import com.fr.general.Background; + +/** + * Created by kerry on 2020-09-01 + */ +public class EmptyBackgroundPane extends AbstractBackgroundDetailPane { + + @Override + public void populate(Background background) { + + } + + @Override + public Background update() { + return null; + } + + /** + * 名称 + * + * @return 名称 + */ + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Basic_Background_Null"); + } + + public boolean accept(Background background) { + return background == null; + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/GradientDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/GradientDetailPane.java new file mode 100644 index 0000000000..042e8d4d32 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/GradientDetailPane.java @@ -0,0 +1,160 @@ +package com.fr.design.mainframe.theme.edit.background; + +import com.fr.base.background.GradientBackground; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.background.gradient.GradientBar; +import com.fr.general.Background; + +import javax.swing.ButtonGroup; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * 渐变色的面板,不是很pp,面板应用显得繁琐,有写可以写成控件类型,比如色彩选择的。。,可以做得花哨点 + * + * @author ben + */ +public class GradientDetailPane extends AbstractBackgroundDetailPane implements UIObserver { + private static final long serialVersionUID = -6854603990673031897L; + private UIObserverListener listener; + private UIRadioButton left2right, top2bottom; + private GradientBar gradientBar; + private ChangeListener changeListener = null; + + public GradientDetailPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + + JPanel gradientPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel blankJp = new JPanel(); + gradientBar = new GradientBar(4, 140); + blankJp.add(gradientBar); + + gradientPanel.add(gradientBar, BorderLayout.SOUTH); + + JPanel jp = new JPanel(new GridLayout(2, 1, 15, 10)); + + + left2right = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Page_Setup_Horizontal")); + jp.add(left2right); + left2right.setSelected(true); + left2right.addActionListener(reviewListener); + + top2bottom = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Page_Setup_Vertical")); + jp.add(top2bottom); + top2bottom.addActionListener(reviewListener); + + ButtonGroup toggle = new ButtonGroup(); + toggle.add(left2right); + toggle.add(top2bottom); + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Background_Gradient_Setting")), gradientPanel}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Background_Gradient_Color")), jp} + }; + JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, + IntervalConstants.INTERVAL_W4, IntervalConstants.INTERVAL_L1); + this.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (listener != null) { + listener.doChange(); + } + } + }); + + + this.add(contentPane); + } + + @Override + public boolean accept(Background background) { + return background instanceof GradientBackground; + } + + + + public void populate(GradientBackground bg) { + this.gradientBar.getSelectColorPointBtnP1().setColorInner(bg.getStartColor()); + this.gradientBar.getSelectColorPointBtnP2().setColorInner(bg.getEndColor()); + if (bg.getDirection() == GradientBackground.LEFT2RIGHT) { + left2right.setSelected(true); + } else { + top2bottom.setSelected(true); + } + if (bg.isUseCell()) { + return; + } + double startValue = (double) bg.getBeginPlace(); + double endValue = (double) bg.getFinishPlace(); + gradientBar.setStartValue(startValue); + gradientBar.setEndValue(endValue); + this.gradientBar.repaint(); + } + + public GradientBackground update() { + GradientBackground gb = new GradientBackground( + gradientBar.getSelectColorPointBtnP1().getColorInner(), + gradientBar.getSelectColorPointBtnP2().getColorInner()); + if (left2right.isSelected()) { + gb.setDirection(GradientBackground.LEFT2RIGHT); + } else { + gb.setDirection(GradientBackground.TOP2BOTTOM); + } + if (gradientBar.isOriginalPlace()) { + gb.setUseCell(true); + } else { + gb.setUseCell(false); + gb.setBeginPlace((float) gradientBar.getStartValue()); + gb.setFinishPlace((float) gradientBar.getEndValue()); + } + return gb; + } + + + ActionListener reviewListener = new ActionListener() { + public void actionPerformed(ActionEvent e) { + fireChagneListener(); + } + }; + + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + gradientBar.addChangeListener(changeListener); + } + + public void fireChagneListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.listener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Basic_Gradient_Color"); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/ImageDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/ImageDetailPane.java new file mode 100644 index 0000000000..208c210450 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/ImageDetailPane.java @@ -0,0 +1,216 @@ +package com.fr.design.mainframe.theme.edit.background; + +import com.fr.base.Style; +import com.fr.base.background.ImageBackground; +import com.fr.base.background.ImageFileBackground; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.frpane.ImgChooseWrapper; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.background.image.ImageFileChooser; +import com.fr.design.style.background.image.ImagePreviewPane; +import com.fr.general.Background; +import com.fr.stable.Constants; + +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * Image background pane. + */ +public class ImageDetailPane extends AbstractBackgroundDetailPane implements UIObserver { + private UIObserverListener listener; + protected ImagePreviewPane previewPane = null; + private Style imageStyle = null; + private ChangeListener changeListener = null; + private ImageFileChooser imageFileChooser = null; + + private UIRadioButton defaultRadioButton = null; + private UIRadioButton tiledRadioButton = null; + private UIRadioButton extendRadioButton = null; + private UIRadioButton adjustRadioButton = null; + + + public ImageDetailPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.add(initSelectFilePane(), BorderLayout.CENTER); + imageFileChooser = new ImageFileChooser(); + imageFileChooser.setMultiSelectionEnabled(false); + previewPane = new ImagePreviewPane(); + this.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (listener != null) { + listener.doChange(); + } + } + }); + } + + public JPanel initSelectFilePane() { + JPanel selectFilePane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + selectFilePane.setBorder(BorderFactory.createEmptyBorder()); + UIButton selectPictureButton = new UIButton( + Toolkit.i18nText("Fine-Design_Basic_Background_Image_Select")); + selectPictureButton.setMnemonic('S'); + selectPictureButton.addActionListener(selectPictureActionListener); + selectPictureButton.setPreferredSize(new Dimension(160, 20)); + //布局 + defaultRadioButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Layout_Default")); + tiledRadioButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Layout_Image_Titled")); + extendRadioButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Layout_Image_Extend")); + adjustRadioButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Layout_Image_Adjust")); + + defaultRadioButton.addActionListener(layoutActionListener); + tiledRadioButton.addActionListener(layoutActionListener); + extendRadioButton.addActionListener(layoutActionListener); + adjustRadioButton.addActionListener(layoutActionListener); + + JPanel jp = new JPanel(new GridLayout(4, 1, 15, 10)); + for (UIRadioButton button : imageLayoutButtons()) { + jp.add(button); + } + + ButtonGroup layoutBG = new ButtonGroup(); + layoutBG.add(defaultRadioButton); + layoutBG.add(tiledRadioButton); + layoutBG.add(extendRadioButton); + layoutBG.add(adjustRadioButton); + + defaultRadioButton.setSelected(true); + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Background_Image")), selectPictureButton}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Background_Fill_Mode")), jp} + }; + JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_NONE, + IntervalConstants.INTERVAL_L4, IntervalConstants.INTERVAL_L1); + selectFilePane.add(centerPane, BorderLayout.CENTER); + return selectFilePane; + } + + protected UIRadioButton[] imageLayoutButtons() { + return new UIRadioButton[]{ + defaultRadioButton, + tiledRadioButton, + extendRadioButton, + adjustRadioButton + }; + } + + @Override + public boolean accept(Background background) { + return background instanceof ImageBackground; + } + + + /** + * Select picture. + */ + ActionListener selectPictureActionListener = new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + int returnVal = imageFileChooser.showOpenDialog(ImageDetailPane.this); + setImageStyle(); + ImgChooseWrapper.getInstance(previewPane, imageFileChooser, imageStyle, changeListener).dealWithImageFile(returnVal); + } + }; + + protected void setImageStyle() { + if (tiledRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED); + } else if (adjustRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST); + } else if (extendRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_EXTEND); + } else { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER); + } + } + + ActionListener layoutActionListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent evt) { + setImageStyle(); + changeImageStyle(); + } + + private void changeImageStyle() { + previewPane.setImageStyle(ImageDetailPane.this.imageStyle); + previewPane.repaint(); + } + }; + + @Override + public void populate(ImageBackground imageBackground) { + if (imageBackground.getLayout() == Constants.IMAGE_CENTER) { + defaultRadioButton.setSelected(true); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER); + } else if (imageBackground.getLayout() == Constants.IMAGE_EXTEND) { + extendRadioButton.setSelected(true); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_EXTEND); + } else if (imageBackground.getLayout() == Constants.IMAGE_ADJUST) { + adjustRadioButton.setSelected(true); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST); + } else { + tiledRadioButton.setSelected(true); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED); + } + previewPane.setImageStyle(ImageDetailPane.this.imageStyle); + if (imageBackground.getImage() != null) { + previewPane.setImageWithSuffix(imageBackground.getImageWithSuffix()); + previewPane.setImage(imageBackground.getImage()); + } + + fireChagneListener(); + } + + @Override + public ImageBackground update() { + ImageBackground imageBackground = new ImageFileBackground(previewPane.getImageWithSuffix()); + setImageStyle(); + imageBackground.setLayout(imageStyle.getImageLayout()); + return imageBackground; + } + + @Override + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + private void fireChagneListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.listener = listener; + } + + + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Basic_Background_Image"); + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/PatternDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/PatternDetailPane.java new file mode 100644 index 0000000000..7d5ee66a73 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/PatternDetailPane.java @@ -0,0 +1,120 @@ +package com.fr.design.mainframe.theme.edit.background; + +import com.fr.base.background.PatternBackground; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.background.impl.PatternBackgroundPane; +import com.fr.design.style.color.ColorSelectBox; +import com.fr.general.Background; +import com.fr.log.FineLoggerFactory; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.GridLayout; +import java.awt.LayoutManager; + +/** + * Created by kerry on 2020-08-31 + */ +public class PatternDetailPane extends AbstractBackgroundDetailPane implements UIObserver { + + private UIObserverListener listener; + private PatternNewBackgroundPane patternNewBackgroundPane; + + public PatternDetailPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + patternNewBackgroundPane = new PatternNewBackgroundPane(6); + this.add(patternNewBackgroundPane, BorderLayout.CENTER); + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.listener = listener; + } + + @Override + public void populate(PatternBackground background) { + this.patternNewBackgroundPane.populate(background); + } + + @Override + public PatternBackground update() { + try { + return (PatternBackground) this.patternNewBackgroundPane.update(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return null; + } + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Basic_Background_Pattern"); + } + + + @Override + public boolean accept(Background background) { + return background instanceof PatternBackground; + } + + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + class PatternNewBackgroundPane extends PatternBackgroundPane { + private PatternNewBackgroundPane(int nColumn) { + super(nColumn); + } + + protected LayoutManager layoutOfTypePane(int nColumn) { + return new GridLayout(0, nColumn, 2, 2); + } + + protected void initComponents(int nColumn) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder()); + JPanel jPanel = new JPanel(); + jPanel.setLayout(layoutOfTypePane(nColumn)); + setChildrenOfTypePane(jPanel); + + foregroundColorPane = new ColorSelectBox(80); + backgroundColorPane = new ColorSelectBox(80); + foregroundColorPane.setSelectObject(Color.lightGray); + backgroundColorPane.setSelectObject(Color.black); + UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Background_Pattern")); + label.setVerticalAlignment(SwingConstants.TOP); + Component[][] components = new Component[][]{ + new Component[]{label, jPanel}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Background_ForeBackground_Color")), foregroundColorPane}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Background_Pattern_Color")), backgroundColorPane} + }; + JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, + IntervalConstants.INTERVAL_W4, IntervalConstants.INTERVAL_L1); + JPanel jPanel1 = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + jPanel1.add(centerPane); + jPanel1.setBorder(BorderFactory.createEmptyBorder()); + this.add(jPanel1, BorderLayout.NORTH); + this.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (listener != null) { + listener.doChange(); + } + } + }); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/TextureDetailObservePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/TextureDetailObservePane.java new file mode 100644 index 0000000000..a1d0fcb2cd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/background/TextureDetailObservePane.java @@ -0,0 +1,98 @@ +package com.fr.design.mainframe.theme.edit.background; + +import com.fr.base.background.TextureBackground; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.background.texture.TextureDetailPane; +import com.fr.general.Background; +import com.fr.log.FineLoggerFactory; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; + +/** + * Created by kerry on 2020-09-02 + */ +public class TextureDetailObservePane extends AbstractBackgroundDetailPane implements UIObserver { + private TextureDetailPane detailPane; + + private UIObserverListener listener; + + public TextureDetailObservePane() { + + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + detailPane = TextureDetailPane.createMiniTextureDetailPane(6); + + detailPane.setPreferredSize(new Dimension(160, 108)); + UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Background_Texture")); + label.setPreferredSize(new Dimension(24, 108)); + label.setVerticalAlignment(SwingConstants.TOP); + JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{label, detailPane}}, TableLayoutHelper.FILL_LASTCOLUMN, 33, 5); + jPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 10)); + + + detailPane.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (listener != null) { + listener.doChange(); + } + } + }); + this.add(jPanel, BorderLayout.CENTER); + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.listener = listener; + + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + @Override + public void populate(TextureBackground background) { + this.detailPane.populate(background); + } + + @Override + public TextureBackground update() { + try { + return (TextureBackground) this.detailPane.update(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return null; + } + + + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Basic_Background_Texture"); + } + + @Override + public boolean accept(Background background) { + return background instanceof TextureBackground; + } + + + @Override + public void addChangeListener(ChangeListener changeListener) { + + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java new file mode 100644 index 0000000000..a2991a89f2 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java @@ -0,0 +1,198 @@ +package com.fr.design.mainframe.theme.edit.cell; + +import com.fr.base.ScreenResolution; +import com.fr.base.Style; +import com.fr.base.theme.settings.ThemedCellStyle; +import com.fr.design.constants.UIConstants; +import com.fr.design.dialog.AttrScrollPane; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.BasicScrollPane; +import com.fr.design.dialog.MultiTabPane; +import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.gui.style.AbstractBasicStylePane; +import com.fr.design.gui.style.AlignmentPane; +import com.fr.design.gui.style.BorderPane; +import com.fr.design.gui.style.FormatPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.theme.ui.BorderUtils; + +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GridLayout; +import java.util.ArrayList; +import java.util.List; + +import static com.fr.design.i18n.Toolkit.i18nText; + + +/** + * 哎,复杂的原型图导致复杂的画法。非我所愿也 + * + * @author zhou + * @since 2012-5-24上午10:36:10 + */ +public class CellStyleEditPane extends MultiTabPane { + private ThemedCellStyle cellStyle; + private PreviewArea previewArea; + private boolean populating; + private AttributeChangeListener attributeChangeListener; + + public CellStyleEditPane() { + super(); + tabPane.setOneLineTab(true); + tabPane.setDrawLine(false); + tabPane.setBorder(BorderFactory.createLineBorder(UIConstants.SHADOW_GREY)); + tabPane.setLayout(new GridLayout(1, 3, 0, 0)); + } + + + + public void registerAttrChangeListener(AttributeChangeListener listener){ + this.attributeChangeListener = listener; + } + + private void fireAttrChangeListener() { + if (this.attributeChangeListener != null) { + this.attributeChangeListener.attributeChange(); + } + } + + public String title4PopupWindow() { + return i18nText("Fine-Design_Report_Custom_Style"); + } + + public void reset() { + populateBean(null); + } + + @Override + public void populateBean(ThemedCellStyle ob) { + this.populating = true; + this.cellStyle = ob; + + for (BasicPane basicPane : paneList) { + ((AbstractBasicStylePane) basicPane).populateBean(ob.getStyle()); + previewArea.preview(ob.getStyle()); + } + this.populating = false; + } + + @Override + public ThemedCellStyle updateBean() { + AbstractBasicStylePane basicStylePane = (AbstractBasicStylePane) paneList.get(tabPane.getSelectedIndex()); + this.cellStyle.setStyle(basicStylePane.update(this.cellStyle.getStyle())); + return this.cellStyle; + } + + @Override + public boolean accept(Object ob) { + return ob instanceof ThemedCellStyle; + } + + @Override + protected List initPaneList() { + paneList = new ArrayList<>(); + paneList.add(new FormatPane()); + paneList.add(new BorderPane()); + paneList.add(new AlignmentPane()); + return paneList; + } + + @Override + protected void initLayout() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + + JPanel jPanel = new JPanel(); + jPanel.setLayout(new BorderLayout(0, 4)); + + JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + previewArea = new PreviewArea(); + previewPane.setBorder(BorderUtils.createTitleBorder(i18nText("Fine-Design_Basic_Preview"))); + previewPane.add(previewArea, BorderLayout.CENTER); + + this.add(previewPane, BorderLayout.NORTH); + + this.add(jPanel, BorderLayout.CENTER); + jPanel.add(tabPane, BorderLayout.NORTH); + JPanel attrListenerPane = new AbstractAttrNoScrollPane() { + + @Override + protected void initContentPane() { + leftContentPane = createContentPane(); + this.add(leftContentPane, BorderLayout.CENTER); + } + + @Override + protected JPanel createContentPane() { + this.addAttributeChangeListener(new AttributeChangeListener() { + @Override + public void attributeChange() { + if (populating) { + return; + } + ThemedCellStyle cellStyle = updateBean(); + if (cellStyle != null) { + previewArea.preview(cellStyle.getStyle()); + } + fireAttrChangeListener(); + } + }); + BasicScrollPane basicScrollPane = new AttrScrollPane() { + @Override + protected JPanel createContentPane() { + return centerPane; + } + }; + return basicScrollPane; + } + }; + jPanel.add(attrListenerPane, BorderLayout.CENTER); + } + + @Override + public void updateBean(ThemedCellStyle ob) {} + + private static class PreviewArea extends JComponent { + + private static final String paintText = "Report"; + private Style style = Style.DEFAULT_STYLE; + + public PreviewArea() { + setPreferredSize(new Dimension(223, 30)); + } + + public void preview(Style style) { + this.style = style; + repaint(); + } + + @Override + public void paintComponent(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + int resolution = ScreenResolution.getScreenResolution(); + + if (style == Style.DEFAULT_STYLE) { + // 如果是默认的style,就只写"Report"上去 + Style.paintContent(g2d, paintText, style, getWidth() - 3, getHeight() - 3, resolution); + return; + } + + Style.paintBackground(g2d, style, getWidth() - 3, getHeight() - 3); + + Style.paintContent(g2d, paintText, style, getWidth() - 3, getHeight() - 3, resolution); + + Style.paintBorder(g2d, style, getWidth() - 3, getHeight() - 3); + } + + @Override + public Dimension getMinimumSize() { + return getPreferredSize(); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/NoBorderPaneCellStyleEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/NoBorderPaneCellStyleEditPane.java new file mode 100644 index 0000000000..7104572da6 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/NoBorderPaneCellStyleEditPane.java @@ -0,0 +1,19 @@ +package com.fr.design.mainframe.theme.edit.cell; + +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.style.AlignmentPane; +import com.fr.design.gui.style.FormatPane; + +import java.util.ArrayList; +import java.util.List; + +public class NoBorderPaneCellStyleEditPane extends CellStyleEditPane { + + @Override + protected List initPaneList() { + paneList = new ArrayList<>(); + paneList.add(new FormatPane()); + paneList.add(new AlignmentPane()); + return paneList; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/AbstractChartStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/AbstractChartStylePane.java new file mode 100644 index 0000000000..e96bcd7bb5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/AbstractChartStylePane.java @@ -0,0 +1,50 @@ +package com.fr.design.mainframe.theme.edit.chart; + +import com.fr.base.theme.settings.ThemedChartStyle; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-17 + */ +public abstract class AbstractChartStylePane extends BasicPane { + + public AbstractChartStylePane() { + initComponents(); + initPane(); + } + + protected abstract void initComponents(); + + protected void initPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + double e1 = 75; + double e = 155; + double p = TableLayout.PREFERRED; + double[] columnSize = {e1, e}; + JPanel gapTableLayoutPane = TableLayoutHelper.createGapTableLayoutPane(getComponent(), getRows(p), columnSize, 20, LayoutConstants.VGAP_LARGE); + gapTableLayoutPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); + UIScrollPane rightTopPane = new UIScrollPane(gapTableLayoutPane); + rightTopPane.setBorder(BorderFactory.createEmptyBorder()); + this.add(rightTopPane, BorderLayout.CENTER); + } + + protected abstract Component[][] getComponent(); + + protected abstract double[] getRows(double p); + + public abstract void populate(ThemedChartStyle chartStyle); + + public abstract void update(ThemedChartStyle chartStyle); +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartAxisStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartAxisStylePane.java new file mode 100644 index 0000000000..5a52bb28c4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartAxisStylePane.java @@ -0,0 +1,69 @@ +package com.fr.design.mainframe.theme.edit.chart; + +import com.fr.base.theme.settings.ThemedChartStyle; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.style.color.ColorSelectBox; + +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-16 + */ +public class ChartAxisStylePane extends AbstractChartStylePane { + + //轴标题字体样式 + private ChartFontPane titleFontPane; + + //轴标签字体样式 + private ChartFontPane labelFontPane; + + //轴线颜色 + private ColorSelectBox axisLineColor; + + protected void initComponents() { + titleFontPane = new ChartFontPane() { + public String getUILabelText() { + return Toolkit.i18nText("Fine-Design_Chart_Axis_Title_Character"); + } + }; + labelFontPane = new ChartFontPane() { + public String getUILabelText() { + return Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Character"); + } + }; + axisLineColor = new ColorSelectBox(100); + } + + protected Component[][] getComponent() { + return new Component[][]{ + new Component[]{titleFontPane, null}, + new Component[]{labelFontPane, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Axis_Line_Color")), axisLineColor} + }; + } + + protected double[] getRows(double p) { + return new double[]{p, p, p}; + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Axis"); + } + + public void populate(ThemedChartStyle chartStyle) { + titleFontPane.populate(chartStyle.getAxisTitleFont()); + labelFontPane.populate(chartStyle.getAxisLabelFont()); + axisLineColor.setSelectObject(chartStyle.getAxisLineColor()); + } + + + public void update(ThemedChartStyle chartStyle) { + chartStyle.setAxisTitleFont(titleFontPane.update()); + chartStyle.setAxisLabelFont(labelFontPane.update()); + chartStyle.setAxisLineColor(axisLineColor.getSelectObject()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartDataSheetStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartDataSheetStylePane.java new file mode 100644 index 0000000000..07ec893f7a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartDataSheetStylePane.java @@ -0,0 +1,58 @@ +package com.fr.design.mainframe.theme.edit.chart; + +import com.fr.base.theme.settings.ThemedChartStyle; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.style.color.ColorSelectBox; + +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-17 + */ +public class ChartDataSheetStylePane extends AbstractChartStylePane { + + //字体样式 + private ChartFontPane fontPane; + + //边框颜色 + private ColorSelectBox borderColor; + + protected void initComponents() { + fontPane = new ChartFontPane() { + public String getUILabelText() { + return Toolkit.i18nText("Fine-Design_Chart_DataSheet_Character"); + } + }; + borderColor = new ColorSelectBox(100); + } + + protected Component[][] getComponent() { + return new Component[][]{ + new Component[]{fontPane, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Border_Color")), borderColor} + }; + } + + protected double[] getRows(double p) { + return new double[]{p, p, p}; + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Data_Sheet"); + } + + public void populate(ThemedChartStyle chartStyle) { + fontPane.populate(chartStyle.getDataSheetFont()); + borderColor.setSelectObject(chartStyle.getDataSheetBorderColor()); + } + + + public void update(ThemedChartStyle chartStyle) { + chartStyle.setDataSheetFont(fontPane.update()); + chartStyle.setDataSheetBorderColor(borderColor.getSelectObject()); + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartFontPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartFontPane.java new file mode 100644 index 0000000000..ee04556c66 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartFontPane.java @@ -0,0 +1,161 @@ +package com.fr.design.mainframe.theme.edit.chart; + +import com.fr.base.BaseUtils; +import com.fr.base.FRContext; +import com.fr.base.Utils; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.dialog.BasicPane; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.ibutton.UIToggleButton; +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.utils.gui.GUICoreUtils; +import com.fr.general.FRFont; +import com.fr.general.GeneralUtils; + +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.Font; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-16 + */ +public class ChartFontPane extends BasicPane { + + public static final int FONT_START = 6; + public static final int FONT_END = 72; + private UIComboBox fontNameComboBox; + private UIComboBox fontSizeComboBox; + private UIToggleButton bold; + private UIToggleButton italic; + private UIColorButton fontColor; + private static Integer[] FONT_SIZES = new Integer[FONT_END - FONT_START + 1]; + + static { + for (int i = FONT_START; i <= FONT_END; i++) { + FONT_SIZES[i - FONT_START] = i; + } + } + + public ChartFontPane() { + initState(); + initComponents(); + } + + private void initState() { + fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); + fontSizeComboBox = new UIComboBox(FONT_SIZES); + bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); + italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); + fontColor = new UIColorButton(); + } + + protected void initComponents() { + Component[] components = new Component[]{ + fontColor, italic, bold + }; + JPanel buttonPane = new JPanel(new BorderLayout()); + buttonPane.add(fontSizeComboBox, BorderLayout.CENTER); + buttonPane.add(GUICoreUtils.createFlowPane(components, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE), BorderLayout.EAST); + + this.setLayout(new BorderLayout()); + this.add(getContentPane(buttonPane), BorderLayout.CENTER); + + populate(FRContext.getDefaultValues().getFRFont()); + } + + protected JPanel getContentPane(JPanel buttonPane) { + double e1 = 75; + double e = 155; + double p = TableLayout.PREFERRED; + double[] rows = {p, p, p}; + double[] columnSize = {e1, e}; + UILabel text = new UILabel(getUILabelText(), SwingConstants.LEFT); + Component[][] components = { + new Component[]{null, null}, + new Component[]{text, fontNameComboBox}, + new Component[]{null, buttonPane} + }; + + return TableLayoutHelper.createGapTableLayoutPane(components, rows, columnSize, 20, LayoutConstants.VGAP_LARGE); + } + + public String getUILabelText() { + return Toolkit.i18nText("Fine-Design_Chart_Character"); + } + + public String title4PopupWindow() { + return null; + } + + public void populate(FRFont frFont) { + UIObserverListener listener = fontNameComboBox == null ? null : fontNameComboBox.getUiObserverListener(); + removeAllComboBoxListener(); + + if (frFont != null) { + fontNameComboBox.setSelectedItem(frFont.getFamily()); + bold.setSelected(frFont.isBold()); + italic.setSelected(frFont.isItalic()); + populateFontSize(frFont); + if (fontColor != null) { + fontColor.setColor(frFont.getForeground()); + } + } + + //更新结束后,注册监听器 + registerAllComboBoxListener(listener); + } + + private void populateFontSize(FRFont frFont) { + if (fontSizeComboBox != null) { + fontSizeComboBox.setSelectedItem(frFont.getSize()); + } + } + + private void removeAllComboBoxListener() { + fontNameComboBox.removeChangeListener(); + fontSizeComboBox.removeChangeListener(); + } + + private void registerAllComboBoxListener(UIObserverListener listener) { + fontNameComboBox.registerChangeListener(listener); + fontSizeComboBox.registerChangeListener(listener); + } + + /** + * 更新字 + * + * @return 更新字 + */ + public FRFont update() { + String name = GeneralUtils.objectToString(fontNameComboBox.getSelectedItem()); + + return FRFont.getInstance(name, updateFontStyle(), updateFontSize(), fontColor.getColor()); + } + + private int updateFontStyle() { + int style = Font.PLAIN; + if (bold.isSelected() && !italic.isSelected()) { + style = Font.BOLD; + } else if (!bold.isSelected() && italic.isSelected()) { + style = Font.ITALIC; + } else if (bold.isSelected() && italic.isSelected()) { + style = 3; + } + + return style; + } + + private float updateFontSize() { + return Float.parseFloat(GeneralUtils.objectToString(fontSizeComboBox.getSelectedItem())); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartLabelStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartLabelStylePane.java new file mode 100644 index 0000000000..8eb736444f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartLabelStylePane.java @@ -0,0 +1,78 @@ +package com.fr.design.mainframe.theme.edit.chart; + +import com.fr.base.theme.settings.ThemedChartStyle; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-16 + */ +public class ChartLabelStylePane extends AbstractChartStylePane { + + private UIButtonGroup autoButton; + //字体样式 + private ChartFontPane chartFontPane; + + protected void initComponents() { + autoButton = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Auto"), + Toolkit.i18nText("Fine-Design_Chart_Custom")}); + chartFontPane = new ChartFontPane() { + public String getUILabelText() { + return Toolkit.i18nText("Fine-Design_Chart_Label_Character"); + } + }; + initListener(); + } + + protected Component[][] getComponent() { + return new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Style_Setting")), autoButton}, + new Component[]{chartFontPane, null} + }; + } + + protected double[] getRows(double p) { + return new double[]{p, p, p}; + } + + private void initListener() { + autoButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkPreButton(); + } + }); + } + + private void checkPreButton() { + chartFontPane.setVisible(autoButton.getSelectedIndex() == 1); + chartFontPane.setPreferredSize(autoButton.getSelectedIndex() == 1 ? new Dimension(0, 60) : new Dimension(0, 0)); + } + + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Label"); + } + + public void populate(ThemedChartStyle chartStyle) { + autoButton.setSelectedIndex(chartStyle.isAutoLabelFont() ? 0 : 1); + chartFontPane.populate(chartStyle.getLabelFont()); + checkPreButton(); + } + + + public void update(ThemedChartStyle chartStyle) { + chartStyle.setAutoLabelFont(autoButton.getSelectedIndex() == 0); + chartStyle.setLabelFont(chartFontPane.update()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartLegendStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartLegendStylePane.java new file mode 100644 index 0000000000..40f4652a0e --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartLegendStylePane.java @@ -0,0 +1,49 @@ +package com.fr.design.mainframe.theme.edit.chart; + +import com.fr.base.theme.settings.ThemedChartStyle; +import com.fr.design.i18n.Toolkit; + +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-16 + */ +public class ChartLegendStylePane extends AbstractChartStylePane { + + //字体样式 + private ChartFontPane chartFontPane; + + protected void initComponents() { + chartFontPane = new ChartFontPane() { + public String getUILabelText() { + return Toolkit.i18nText("Fine-Design_Chart_Legend_Character"); + } + }; + } + + protected Component[][] getComponent() { + return new Component[][]{ + new Component[]{chartFontPane, null} + }; + } + + protected double[] getRows(double p) { + return new double[]{p}; + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Legend"); + } + + public void populate(ThemedChartStyle chartStyle) { + chartFontPane.populate(chartStyle.getLegendFont()); + } + + + public void update(ThemedChartStyle chartStyle) { + chartStyle.setLegendFont(chartFontPane.update()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartSeriesStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartSeriesStylePane.java new file mode 100644 index 0000000000..fbb8f64895 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartSeriesStylePane.java @@ -0,0 +1,88 @@ +package com.fr.design.mainframe.theme.edit.chart; + +import com.fr.base.theme.settings.ThemedChartStyle; +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.theme.dialog.TemplateThemeProfileDialog; +import com.fr.design.style.background.gradient.FixedGradientBar; + +import java.util.List; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-17 + */ +public class ChartSeriesStylePane extends AbstractChartStylePane { + + private UIButtonGroup colorTypeButton; + private FixedGradientBar gradientBar; + + protected void initComponents() { + colorTypeButton = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Custom_Color"), + Toolkit.i18nText("Fine-Design_Chart_Legend_Gradual")}); + gradientBar = new FixedGradientBar(4, 130); + initListener(); + } + + protected Component[][] getComponent() { + return new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Match_Color_Scheme")), colorTypeButton}, + new Component[]{null, gradientBar} + }; + } + + protected double[] getRows(double p) { + return new double[]{p, p, p}; + } + + private void initListener() { + colorTypeButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkTypeButton(); + } + }); + } + + private void checkTypeButton() { + gradientBar.setVisible(colorTypeButton.getSelectedIndex() == 1); + gradientBar.setPreferredSize(colorTypeButton.getSelectedIndex() == 1 ? new Dimension(0, 60) : new Dimension(0, 0)); + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Series"); + } + + public void populate(ThemedChartStyle chartStyle) { + if (chartStyle.getThemedChartSeriesColor().isCombineColor()) { + List editingColorScheme = TemplateThemeProfileDialog.getEditingColorScheme(); + colorTypeButton.setSelectedIndex(0); + gradientBar.updateColor(editingColorScheme.get(0), editingColorScheme.get(1)); + } else { + colorTypeButton.setSelectedIndex(1); + gradientBar.updateColor(chartStyle.getThemedChartSeriesColor().getBeginColor(), chartStyle.getThemedChartSeriesColor().getEndColor()); + } + checkTypeButton(); + } + + + public void populateGradientBar(List colors) { + gradientBar.updateColor(colors.get(0), colors.get(1)); + this.repaint(); + } + + public void update(ThemedChartStyle chartStyle) { + chartStyle.getThemedChartSeriesColor().setCombineColor(colorTypeButton.getSelectedIndex() == 0); + chartStyle.getThemedChartSeriesColor().setBeginColor(gradientBar.getSelectColorPointBtnP1().getColorInner()); + chartStyle.getThemedChartSeriesColor().setEndColor(gradientBar.getSelectColorPointBtnP2().getColorInner()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartTitleAndBackgroundStyleFormPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartTitleAndBackgroundStyleFormPane.java new file mode 100644 index 0000000000..204bde0764 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartTitleAndBackgroundStyleFormPane.java @@ -0,0 +1,36 @@ +package com.fr.design.mainframe.theme.edit.chart; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; + +import java.awt.Color; +import java.awt.Component; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2021-08-30 + */ +public class ChartTitleAndBackgroundStyleFormPane extends ChartTitleAndBackgroundStylePane { + + private UILabel tooltipLabel; + + protected void initComponents() { + super.initComponents(); + tooltipLabel = new UILabel("" + Toolkit.i18nText("Fine-Design_Chart_Title_Background_Tooltip") + ""); + tooltipLabel.setForeground(new Color(153, 153, 153)); + } + + protected Component[][] getComponent() { + Component[][] component = super.getComponent(); + Component[][] newComponent = new Component[component.length + 2][]; + System.arraycopy(component, 0, newComponent, 2, component.length); + newComponent[0] = new Component[]{null, null}; + newComponent[1] = new Component[]{tooltipLabel, null}; + return newComponent; + } + + protected double[] getRows(double p) { + return new double[]{p, p, p, p, p, p, p}; + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartTitleAndBackgroundStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartTitleAndBackgroundStylePane.java new file mode 100644 index 0000000000..6bac518763 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/chart/ChartTitleAndBackgroundStylePane.java @@ -0,0 +1,127 @@ +package com.fr.design.mainframe.theme.edit.chart; + +import com.fr.base.background.ImageBackground; +import com.fr.base.theme.settings.ThemedChartStyle; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.ImageBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.NullBackgroundQuickPane; +import com.fr.design.mainframe.backgroundpane.VanChartGradientPane; +import com.fr.design.style.color.ColorSelectBox; +import com.fr.general.Background; +import com.fr.stable.Constants; + +import javax.swing.JPanel; +import java.util.ArrayList; +import java.util.List; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-09-16 + */ +public class ChartTitleAndBackgroundStylePane extends AbstractChartStylePane { + + //字体样式 + private ChartFontPane chartFontPane; + + private UIComboBox typeComboBox; + private List paneList; + private JPanel centerPane; + + //网格线颜色 + private ColorSelectBox mainGridColor; + + protected void initComponents() { + chartFontPane = new ChartFontPane() { + public String getUILabelText() { + return Toolkit.i18nText("Fine-Design_Chart_Title_Character"); + } + }; + + mainGridColor = new ColorSelectBox(100); + + typeComboBox = new UIComboBox(); + final CardLayout cardlayout = new CardLayout(); + initList(); + + centerPane = new JPanel(cardlayout) { + @Override + public Dimension getPreferredSize() {// AUGUST:使用当前面板的的高度 + int index = typeComboBox.getSelectedIndex(); + return new Dimension(super.getPreferredSize().width, paneList.get(index).getPreferredSize().height); + } + }; + for (int i = 0; i < paneList.size(); i++) { + BackgroundQuickPane pane = paneList.get(i); + typeComboBox.addItem(pane.title4PopupWindow()); + centerPane.add(pane, pane.title4PopupWindow()); + } + + typeComboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + cardlayout.show(centerPane, (String) typeComboBox.getSelectedItem()); + } + }); + } + + private void initList() { + paneList = new ArrayList<>(); + paneList.add(new NullBackgroundQuickPane()); + paneList.add(new ColorBackgroundQuickPane()); + paneList.add(new ImageBackgroundQuickPane(false)); + paneList.add(new VanChartGradientPane()); + } + + protected Component[][] getComponent() { + return new Component[][]{ + new Component[]{chartFontPane, null}, + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Area_Background_Color")), typeComboBox}, + new Component[]{null, centerPane}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Grid_Line_Color")), mainGridColor} + }; + } + + protected double[] getRows(double p) { + return new double[]{p, p, p, p, p}; + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Title_Background"); + } + + public void populate(ThemedChartStyle chartStyle) { + chartFontPane.populate(chartStyle.getTitleFont()); + Background background = chartStyle.getChartBackground(); + for (int i = 0; i < paneList.size(); i++) { + BackgroundQuickPane pane = paneList.get(i); + if (pane.accept(background)) { + pane.populateBean(background); + typeComboBox.setSelectedIndex(i); + break; + } + } + mainGridColor.setSelectObject(chartStyle.getGridMainLineColor()); + } + + + public void update(ThemedChartStyle chartStyle) { + chartStyle.setTitleFont(chartFontPane.update()); + chartStyle.setChartBackground(paneList.get(typeComboBox.getSelectedIndex()).updateBean()); + if (chartStyle.getChartBackground() instanceof ImageBackground) { + ((ImageBackground) chartStyle.getChartBackground()).setLayout(Constants.IMAGE_EXTEND); + } + chartStyle.setGridMainLineColor(mainGridColor.getSelectObject()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/component/ComponentMarginStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/component/ComponentMarginStylePane.java new file mode 100644 index 0000000000..643c1e9601 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/component/ComponentMarginStylePane.java @@ -0,0 +1,101 @@ +package com.fr.design.mainframe.theme.edit.component; + +import com.fr.base.theme.settings.ThemedComponentStyle; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.Component; + +import static com.fr.design.i18n.Toolkit.i18nText; + +/** + * Created by kerry on 2020-09-01 + */ +public class ComponentMarginStylePane extends JPanel { + private final int uiLabelWidth; + private final int uiSettingWidth; + + protected UISpinner top; + protected UISpinner bottom; + protected UISpinner left; + protected UISpinner right; + + public ComponentMarginStylePane(int uiLabelWidth, int uiSettingWidth) { + this.uiLabelWidth = uiLabelWidth; + this.uiSettingWidth = uiSettingWidth; + initBoundPane(0, 0, 0, 0); + } + + public void initBoundPane(int t, int b, int l, int r) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + + top = new UISpinner(0, Integer.MAX_VALUE, 1, t); + bottom = new UISpinner(0, Integer.MAX_VALUE, 1, b); + left = new UISpinner(0, Integer.MAX_VALUE, 1, l); + right = new UISpinner(0, Integer.MAX_VALUE, 1, r); + + top.setGlobalName(i18nText("Fine-Design_Form_Layout_Padding_Duplicate")); + bottom.setGlobalName(i18nText("Fine-Design_Form_Layout_Padding_Duplicate")); + left.setGlobalName(i18nText("Fine-Design_Form_Layout_Padding_Duplicate")); + right.setGlobalName(i18nText("Fine-Design_Form_Layout_Padding_Duplicate")); + + UILabel uiLabel = new UILabel(i18nText("Fine-Design_Form_Layout_Padding_Duplicate")); + uiLabel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0)); + uiLabel.setVerticalAlignment(SwingConstants.TOP); + + + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + double[] rowSize = { p }; + double[] columnSize = { this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f }; + + JPanel panel = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{uiLabel, createPaddingPane()}}, + rowSize, columnSize, + IntervalConstants.INTERVAL_L1, 0 + ); + this.add(panel); + } + + + public JPanel createPaddingPane() { + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p, p, p}; + double[] columnSize = {f, f}; + + Component[][] paddingPane = new Component[][]{ + new Component[]{top, bottom}, + new Component[]{createLabelByKey("Fine-Design_Report_Top"), createLabelByKey("Fine-Design_Report_Bottom")}, + new Component[]{left, right}, + new Component[]{createLabelByKey("Fine-Design_Report_Left"), createLabelByKey("Fine-Design_Basic_Right")} + }; + + return TableLayoutHelper.createGapTableLayoutPane(paddingPane, rowSize, columnSize, IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_L6); + } + + public void populate(ThemedComponentStyle componentStyle) { + this.top.setValue(componentStyle.getPaddingTop()); + this.bottom.setValue(componentStyle.getPaddingBottom()); + this.left.setValue(componentStyle.getPaddingLeft()); + this.right.setValue(componentStyle.getPaddingRight()); + } + + public void update(ThemedComponentStyle componentStyle) { + componentStyle.setPaddingTop((int) this.top.getValue()); + componentStyle.setPaddingBottom((int) this.bottom.getValue()); + componentStyle.setPaddingLeft((int) this.left.getValue()); + componentStyle.setPaddingRight((int) this.right.getValue()); + } + + private UILabel createLabelByKey(String key) { + return new UILabel(i18nText(key), SwingConstants.CENTER); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListExtendedPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListExtendedPane.java new file mode 100644 index 0000000000..4aac8562d1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListExtendedPane.java @@ -0,0 +1,147 @@ +package com.fr.design.mainframe.theme.edit.ui; + +import com.fr.base.theme.FineColorManager; +import com.fr.design.layout.FRGUIPaneFactory; + +import javax.swing.JPanel; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/7 + */ +public class ColorListExtendedPane extends JPanel implements MouseListener { + public static final int DEFAULT_COLOR_COUNT = 8; + public static final int DEFAULT_EXTENDED_COUNT = 5; + public static final int DEFAULT_COLOR_SIZE = 16; + public static final int DEFAULT_COLOR_GAP = 3; + + public static final ExtendedColorComputer DEFAULT_EXTENDED_COMPUTER = new ExtendedColorComputer() { + @Override + public Color computeExtendedColor(Color color, int index, int count) { + return FineColorManager.computeExtendedColor(color, index, count); + } + }; + + private final boolean selectable; + private final int colorCount; + private final int extendedCount; + private final int boxSize; + private final int boxGap; + + private final List colorList = new ArrayList<>(); + private ExtendedColorComputer extendedColorComputer = DEFAULT_EXTENDED_COMPUTER; + + private int selectedColorIndex = -1; + private int selectedExtendedIndex = -1; + + public ColorListExtendedPane() { + this(false, DEFAULT_COLOR_COUNT, DEFAULT_EXTENDED_COUNT, DEFAULT_COLOR_SIZE, DEFAULT_COLOR_GAP); + } + + public ColorListExtendedPane(boolean selectable, int colorCount, int extendedCount, int boxSize, int boxGap) { + setLayout(FRGUIPaneFactory.createBorderLayout()); + this.selectable = selectable; + this.colorCount = Math.max(1, colorCount); + this.extendedCount = extendedCount; + this.boxSize = boxSize; + this.boxGap = boxGap; + + for (int i = 0; i < colorCount; i++) { + colorList.add(Color.WHITE); + } + + int width = colorCount * boxSize + (colorCount - 1) * boxGap; + int height = extendedCount * boxSize + (extendedCount - 1) * boxGap; + setPreferredSize(new Dimension(width, height)); + } + + public void populate(List colors) { + if (colors.size() > 0) { + colorList.clear(); + for (int i = 0; i < colorCount; i++) { + Color color = colors.get(i % colorCount); + colorList.add(color); + } + repaint(); + } + } + + public List update() { + return new ArrayList<>(colorList); + } + + public void setExtendedColorComputer(ExtendedColorComputer extendedColorComputer) { + this.extendedColorComputer = extendedColorComputer; + } + + @Override + public void mouseClicked(MouseEvent e) { + int x = e.getX(); + int y = e.getY(); + + int colorIndex = x / (boxSize + boxGap); + int colorX = colorIndex * (boxSize + boxGap); + + int extendedIndex = y / boxSize; + int extendedY = extendedIndex * boxSize; + + if (colorX <= x && x <= colorX + boxSize && extendedY <= y && y <= extendedY + boxSize) { + selectedColorIndex = colorIndex; + selectedExtendedIndex = extendedIndex; + } else { + selectedColorIndex = -1; + selectedExtendedIndex = -1; + } + repaint(); + } + + @Override + public void mousePressed(MouseEvent e) { + + } + + @Override + public void mouseReleased(MouseEvent e) { + + } + + @Override + public void mouseEntered(MouseEvent e) { + + } + + @Override + public void mouseExited(MouseEvent e) { + + } + + public interface ExtendedColorComputer { + Color computeExtendedColor(Color color, int index, int count); + } + + @Override + public void paint(Graphics g) { + super.paint(g); + Color oldColor = g.getColor(); + + for (int i = 0; i < colorList.size(); i++) { + int x = i * (boxSize + boxGap); + for (int j = 0; j < extendedCount; j++) { + Color color = extendedColorComputer.computeExtendedColor(colorList.get(i), j, extendedCount); + g.setColor(color); + int y = j * (boxSize + boxGap); + g.fillRect(x, y, boxSize, boxSize); + } + } + + g.setColor(oldColor); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListPane.java new file mode 100644 index 0000000000..2bf1931f14 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListPane.java @@ -0,0 +1,203 @@ +package com.fr.design.mainframe.theme.edit.ui; + +import com.fr.base.FineColor; +import com.fr.base.background.ColorBackground; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.style.AbstractSelectBox; +import com.fr.design.style.color.NewColorSelectPane; + +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.EventListenerList; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GridLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.geom.Rectangle2D; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/7 + */ +public class ColorListPane extends JPanel implements UIObserver { + public static final int DEFAULT_COLOR_COUNT = 8; + public static final int DEFAULT_COLOR_SIZE = 16; + public static final int DEFAULT_COLOR_GAP = 3; + + private final int colorCount; + + private final List colorList = new ArrayList<>(); + private final List colorButtons = new ArrayList<>(); + + private final EventListenerList colorChangeListenerList = new EventListenerList(); + private UIObserverListener uiObserverListener; + + public ColorListPane() { + this(DEFAULT_COLOR_COUNT, DEFAULT_COLOR_SIZE, DEFAULT_COLOR_GAP); + } + + public ColorListPane(int colorCount, int boxSize, int boxGap) { + this.colorCount = Math.max(1, colorCount); + + for (int i = 0; i < colorCount; i++) { + colorList.add(Color.WHITE); + } + + setLayout(new GridLayout(1, 8, boxGap, 0)); + + for (int i = 0; i < colorCount; i++) { + ColorButton colorButton = new ColorButton(null); + colorButton.setPreferredSize(new Dimension(boxSize, boxSize)); + add(colorButton); + int index = i; + colorButton.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + colorList.set(index, colorButton.getSelectObject()); + fireColorStateChanged(); + } + }); + + colorButtons.add(colorButton); + } + + setPreferredSize(new Dimension(colorCount * boxSize + (colorCount - 1) * boxGap, boxSize)); + iniListener(); + } + + private void iniListener() { + if (shouldResponseChangeListener()) { + this.addColorChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (uiObserverListener == null) { + return; + } + uiObserverListener.doChange(); + } + }); + } + } + + public void populate(List colors) { + for (int i = 0; i < colors.size() && i < colorList.size(); i++) { + Color color = colors.get(i % colorCount); + colorList.set(i, color); + colorButtons.get(i).setSelectObject(color); + } + } + + public List update() { + return new ArrayList<>(colorList); + } + + public void addColorChangeListener(ChangeListener changeListener) { + colorChangeListenerList.add(ChangeListener.class, changeListener); + } + + public void removeColorChangeListener(ChangeListener changeListener) { + colorChangeListenerList.remove(ChangeListener.class, changeListener); + } + + public void fireColorStateChanged() { + Object[] listeners = colorChangeListenerList.getListenerList(); + ChangeEvent e = null; + + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == ChangeListener.class) { + if (e == null) { + e = new ChangeEvent(this); + } + ((ChangeListener) listeners[i + 1]).stateChanged(e); + } + } + } + + public void registerChangeListener(UIObserverListener listener) { + uiObserverListener = listener; + } + + public boolean shouldResponseChangeListener() { + return true; + } + + private static class ColorButton extends AbstractSelectBox { + private Color color; + private NewColorSelectPane colorPane; + private ChangeListener changeListener; + + public ColorButton(Color color) { + this.color = color; + addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + showPopupMenu(); + } + }); + } + + @Override + public JPanel initWindowPane(double preferredWidth) { + colorPane = new NewColorSelectPane(false) { + @Override + public void setVisible(boolean b) { + super.setVisible(b); + } + + @Override + protected boolean selectRealTime() { + return false; + } + }; + colorPane.setColor(this.getSelectObject()); + colorPane.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + hidePopupMenu(); + FineColor fineColor = ((NewColorSelectPane) e.getSource()).getColor(); + // 不要直接使用原始的FineColor对象,它的值会变化,这里实际需要的内部的真实颜色 + color = fineColor.getColor(); + fireDisplayComponent(ColorBackground.getInstance(color)); + ColorListPane.ColorButton.this.fireStateChanged(); + } + }); + return colorPane; + } + + @Override + public void paint(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + g2d.setPaint(color); + g2d.fill(new Rectangle2D.Double(0, 0, getWidth(), getHeight())); + } + + public void fireStateChanged() { + if (changeListener != null) { + changeListener.stateChanged(null); + } + } + + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + public Color getSelectObject() { + return this.color; + } + + public void setSelectObject(Color color) { + this.color = color; + if (this.colorPane != null) { + this.colorPane.setColor(color); + } + fireDisplayComponent(ColorBackground.getInstance(color)); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/LabelUtils.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/LabelUtils.java new file mode 100644 index 0000000000..2b099ed306 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/LabelUtils.java @@ -0,0 +1,29 @@ +package com.fr.design.mainframe.theme.edit.ui; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.general.FRFont; + +import java.awt.Color; +import java.awt.Font; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/15 + */ +public class LabelUtils { + public static UILabel createLabel(String title) { + return createLabel(title, new Color(51, 51, 52)); + } + + public static UILabel createLabel(String title, Color color) { + return createLabel(title, color, 12); + } + public static UILabel createLabel(String title, Color color, int size) { + UILabel uiLabel = new UILabel(title); + uiLabel.setForeground(color); + Font newFont = FRFont.getInstance(uiLabel.getFont().getFontName(), Font.PLAIN, size); + uiLabel.setFont(newFont); + return uiLabel; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/TabbedPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/TabbedPane.java new file mode 100644 index 0000000000..3f4667e111 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/TabbedPane.java @@ -0,0 +1,73 @@ +package com.fr.design.mainframe.theme.edit.ui; + +import com.fr.design.gui.ibutton.UITabGroup; +import com.fr.design.layout.FRGUIPaneFactory; + +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Dimension; +import java.util.Arrays; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/12 + */ +public class TabbedPane extends JPanel { + protected UITabGroup buttonGroup; + public JPanel tabContentPane; + public CardLayout cardLayout; + private String[] names = new String[]{}; + private JComponent[] panes = new JComponent[]{}; + + public TabbedPane(String[] names, JComponent[] panes) { + setLayout(FRGUIPaneFactory.createBorderLayout()); + setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + + for (JComponent pane :panes) { + pane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + } + + int count = Math.min(names.length, panes.length); + if (count > 0) { + this.names = names.length > count ? Arrays.copyOf(names, count) : names; + this.panes = panes.length > count ? Arrays.copyOf(panes, count) : panes; + initializeTabPane(); + } + } + + private void initializeTabPane() { + buttonGroup = new UITabGroup(this.names) { + @Override + public void tabChanged(int index) { + super.tabChanged(index); + cardLayout.show(tabContentPane, names[buttonGroup.getSelectedIndex()]); + } + }; + buttonGroup.setDrawLine(true); + + cardLayout = new CardLayout(); + tabContentPane = new JPanel(cardLayout) { + @Override + public Dimension getPreferredSize() { + int selectedIndex = buttonGroup.getSelectedIndex(); + if (selectedIndex < 0) { + return super.getPreferredSize(); + } else { + return panes[selectedIndex].getPreferredSize(); + } + } + }; + for (int i = 0; i < this.names.length; i++) { + tabContentPane.add(panes[i], names[i]); + } + buttonGroup.setSelectedIndex(0); + cardLayout.show(tabContentPane, names[0]); + + add(buttonGroup, BorderLayout.NORTH); + add(tabContentPane, BorderLayout.CENTER); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ChartComponentPreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ChartComponentPreviewPane.java new file mode 100644 index 0000000000..261804b4b5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ChartComponentPreviewPane.java @@ -0,0 +1,34 @@ +package com.fr.design.mainframe.theme.preview; + +import com.fr.base.theme.FormTheme; + +import java.awt.Component; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/13 + */ +public class ChartComponentPreviewPane extends ComponentPreviewPane implements ThemePreviewed { + private ChartPreviewPane contentPane; + + public ChartComponentPreviewPane(boolean showTitle) { + super(showTitle); + } + + @Override + protected Component createContentPane() { + contentPane = new ChartPreviewPane(); + return contentPane; + } + + @Override + public void refresh(FormTheme theme) { + super.refresh(theme); + contentPane.refresh(theme); + } + + public ChartPreviewPane getContentPane() { + return contentPane; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ChartPreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ChartPreviewPane.java new file mode 100644 index 0000000000..2029539aa8 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ChartPreviewPane.java @@ -0,0 +1,80 @@ +package com.fr.design.mainframe.theme.preview; + +import com.fr.base.chart.BaseChartCollection; +import com.fr.base.chart.BaseChartPainter; +import com.fr.base.chart.chartdata.CallbackEvent; +import com.fr.base.chart.result.WebChartIDInfo; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeCompatible; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.design.gui.chart.MiddleChartComponent; +import com.fr.script.Calculator; +import com.fr.stable.core.PropertyChangeListener; + +import javax.swing.BorderFactory; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/13 + */ +public class ChartPreviewPane extends MiddleChartComponent implements ThemePreviewed { + + private ChartCollection chartCollection; + + private CallbackEvent callbackEvent; + + public ChartPreviewPane() { + this.setBorder(BorderFactory.createEmptyBorder(0, 1, 2, 1)); + } + + public void setCallbackEvent(CallbackEvent callbackEvent) { + this.callbackEvent = callbackEvent; + } + + public void paintComponent(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + super.paintComponent(g); + if (chartCollection != null) { + drawChart(g2d); + } + drawChart(g2d); + } + + private void drawChart(Graphics2D g2d) { + Dimension d = getBounds().getSize(); + int chartWidth = d.width; + int chartHeight = d.height; + BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(), + WebChartIDInfo.createEmptyDesignerInfo(), chartWidth, chartHeight); + painter.paint(g2d, chartWidth, chartHeight, 0, null, callbackEvent); + } + + @Override + public void populate(BaseChartCollection cc) { + this.chartCollection = (ChartCollection) cc; + } + + @Override + public BaseChartCollection update() { + return this.chartCollection; + } + + @Override + public void reset() { + + } + + @Override + public void addStopEditingListener(PropertyChangeListener list) { + + } + + @Override + public void refresh(TemplateTheme style) { + chartCollection.onTemplateUsingThemeChange(style, TemplateThemeCompatible.NONE); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ComponentPreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ComponentPreviewPane.java new file mode 100644 index 0000000000..da7f7bac58 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ComponentPreviewPane.java @@ -0,0 +1,163 @@ +package com.fr.design.mainframe.theme.preview; + +import com.fr.base.BaseUtils; +import com.fr.base.Style; +import com.fr.base.background.ImageBackground; +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.settings.ThemedComponentStyle; +import com.fr.design.border.UIRoundedBorder; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.form.ui.Label; +import com.fr.form.ui.LayoutBorderStyle; +import com.fr.form.ui.WidgetValue; +import com.fr.general.Background; +import com.fr.general.act.BorderPacker; +import com.fr.general.act.TitlePacker; +import com.fr.stable.Constants; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.border.Border; +import java.awt.AlphaComposite; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Composite; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Shape; +import java.awt.geom.Rectangle2D; +import java.awt.geom.RoundRectangle2D; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/13 + */ +public abstract class ComponentPreviewPane extends UINoOpaquePanel implements ThemePreviewed { + public static final int TITLE_HEIGHT = 35; + + private final JPanel container; + private TitleDemoPane titlePane; + private BorderPacker style = new LayoutBorderStyle(); + + public ComponentPreviewPane(){ + this(false); + } + + public ComponentPreviewPane(boolean showTitle) { + container = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); + setLayout(new BorderLayout()); + if (showTitle) { + titlePane = new TitleDemoPane(); + titlePane.setPreferredSize(new Dimension(517, TITLE_HEIGHT)); + container.add(titlePane, BorderLayout.NORTH); + } + container.add(createContentPane(), BorderLayout.CENTER); + add(container, BorderLayout.CENTER); + } + + protected abstract Component createContentPane(); + + @Override + public void refresh(FormTheme theme) { + ThemedComponentStyle componentStyle = theme.getComponentStyle(); + + style = componentStyle.getStyle(); + setBorder(new UIRoundedBorder(style.getBorder(), style.getColor(), style.getBorderRadius())); + + int paddingTop = componentStyle.getPaddingTop(); + int paddingBottom = componentStyle.getPaddingBottom(); + int paddingLeft = componentStyle.getPaddingLeft(); + int paddingRight = componentStyle.getPaddingRight(); + container.setBorder(BorderFactory.createEmptyBorder(paddingTop, paddingLeft, paddingBottom, paddingRight)); + if (titlePane != null) { + titlePane.refresh(componentStyle); + } + + } + + @Override + public void paint(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + + Border border = getBorder(); + if (border instanceof UIRoundedBorder) { + UIRoundedBorder roundedBorder = (UIRoundedBorder) border; + Utils.clipByRoundBorder(g2d, getWidth(), getHeight(), roundedBorder.getRoundedCorner(), roundedBorder.getThickness()); + } + + int titleHeight = titlePane == null ? 0 : titlePane.getHeight(); + Utils.paintBackground(g2d, style.getBackground(), new Rectangle2D.Double(0, titleHeight, getWidth(), getHeight() - titleHeight), style.getAlpha()); + + Utils.paintBackground(g2d, style.getBorderImage(), new Rectangle2D.Double(0, 0, getWidth(), getHeight()), style.getBorderImageOpacity()); + + super.paint(g); + } + + private static class TitleDemoPane extends UINoOpaquePanel { + private final Label data = new Label(); + + public void refresh(ThemedComponentStyle componentStyle) { + BorderPacker borderPacker = componentStyle.getStyle(); + TitlePacker titlePacker = componentStyle.getStyle().getTitle(); + + data.setColor(borderPacker.getColor()); + data.setWidgetValue(new WidgetValue(String.valueOf(titlePacker.getTextObject()))); + data.setFont(titlePacker.getFrFont()); + data.setTextalign(titlePacker.getPosition()); + data.setBackground(titlePacker.getBackground()); + data.setBackgroundOpacity(titlePacker.getBackgroundOpacity()); + + data.setInsetImage(titlePacker.getInsetImage()); + data.setInsetImagePadding(titlePacker.getInsetImagePadding()); + data.setInsetRelativeTextLeft(titlePacker.isInsetRelativeTextLeft()); + data.setInsetRelativeTextRight(titlePacker.isInsetRelativeTextRight()); + } + + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + Dimension size = getSize(); + Background background = data.getBackground(); + float opacity = data.getBackgroundOpacity(); + if (background != null) { + Utils.paintBackground((Graphics2D) g, background, new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight()), opacity); + } + + Graphics2D g2d = (Graphics2D) g.create(); + Background inset = data.getInsetImage(); + Image insetImage = inset instanceof ImageBackground ? ((ImageBackground) inset).getImage() : null; + + BaseUtils.drawStringStyleInRotation(g2d, + getWidth(), getHeight(), + data.getWidgetValue().toString(), + Style.getInstance(data.getFont()) + .deriveHorizontalAlignment(data.getTextalign()) + .deriveVerticalAlignment(data.isVerticalCenter() ? SwingConstants.CENTER : SwingConstants.TOP) + .deriveTextStyle(data.isWrap() ? Style.TEXTSTYLE_WRAPTEXT : Style.TEXTSTYLE_SINGLELINE), + insetImage, data.getInsetImagePadding(), data.isInsetRelativeTextLeft(), data.isInsetRelativeTextRight(), + Constants.FR_PAINT_RESOLUTION); + } + + } + + private static class Utils { + private static void paintBackground(Graphics2D g2d, Background background, Shape shape, float opacity) { + if (background != null) { + Composite oldComposite = g2d.getComposite(); + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, opacity)); + background.paint(g2d, shape); + g2d.setComposite(oldComposite); + } + } + + private static void clipByRoundBorder(Graphics2D g2d, int width, int height, int radius, int borderThickness) { + int currentClipRadius = Math.max(radius - borderThickness, 0); + g2d.clip(new RoundRectangle2D.Double(0, 0, width, height, currentClipRadius, currentClipRadius)); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/FormThemePreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/FormThemePreviewPane.java new file mode 100644 index 0000000000..8b96eba4b9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/FormThemePreviewPane.java @@ -0,0 +1,199 @@ +package com.fr.design.mainframe.theme.preview; + +import com.fr.base.BaseFormula; +import com.fr.base.background.ColorBackground; +import com.fr.base.theme.FormTheme; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartattr.Title; +import com.fr.chart.chartdata.NormalChartData; +import com.fr.chart.charttypes.ChartTypeManager; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.theme.TemplateThemePreviewPane; +import com.fr.design.mainframe.theme.preview.ecpreview.ECComponentPreviewPane; +import com.fr.general.Background; +import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.PiePlot4VanChart; +import com.fr.plugin.chart.attr.axis.VanChartAxis; +import com.fr.plugin.chart.base.AttrLabel; +import com.fr.plugin.chart.base.VanChartTools; +import com.fr.plugin.chart.column.VanChartColumnPlot; +import com.fr.plugin.chart.type.GradientType; +import com.fr.plugin.chart.type.RadiusType; +import com.fr.plugin.chart.vanchart.VanChart; +import com.fr.stable.Constants; +import com.fr.stable.StringUtils; + +import javax.swing.JPanel; +import java.awt.AlphaComposite; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Composite; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/13 + */ +public class FormThemePreviewPane extends TemplateThemePreviewPane { + private ECComponentPreviewPane elementCasePane; + private Background background; + private ChartComponentPreviewPane columnChartPreviewPane; + private ChartComponentPreviewPane pieChartPreviewPane; + private float alpha = 1.0F; + + public FormThemePreviewPane() { + setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel content = new UINoOpaquePanel(); + content.setLayout(new BorderLayout()); + content.add(createChartContent(), BorderLayout.CENTER); + content.add(elementCasePane = new ECComponentPreviewPane(), BorderLayout.SOUTH); + add(content, BorderLayout.CENTER); + } + + private JPanel createChartContent() { + JPanel chartContent = new UINoOpaquePanel(); + chartContent.setLayout(new BorderLayout()); + JPanel columnChartPanel = new UINoOpaquePanel() { + public Dimension getPreferredSize() { + return new Dimension(300, 368); + } + }; + columnChartPanel.setLayout(new BorderLayout()); + columnChartPreviewPane = createChartPreviewPane(initColumnChart(), 300, 368); + columnChartPanel.add(columnChartPreviewPane, BorderLayout.CENTER); + + JPanel pieChartPanel = new UINoOpaquePanel() { + public Dimension getPreferredSize() { + return new Dimension(217, 368); + } + }; + pieChartPanel.setLayout(new BorderLayout()); + pieChartPreviewPane = createChartPreviewPane(initPieChart(), 217, 368); + pieChartPanel.add(pieChartPreviewPane, BorderLayout.CENTER); + chartContent.add(columnChartPanel, BorderLayout.CENTER); + chartContent.add(pieChartPanel, BorderLayout.EAST); + return chartContent; + } + + private ChartComponentPreviewPane createChartPreviewPane(ChartCollection chartCollection, int width, int height) { + ChartComponentPreviewPane chartComponentPreviewPane = new ChartComponentPreviewPane(true); + chartComponentPreviewPane.getContentPane().populate(chartCollection); + chartComponentPreviewPane.getContentPane().setCallbackEvent(this); + return chartComponentPreviewPane; + } + + @Override + public void refresh(FormTheme theme) { + background = theme.getBodyStyle().getStyle().getBackground(); + alpha = theme.getBodyStyle().getStyle().getAlpha(); + elementCasePane.refresh(theme); + columnChartPreviewPane.refresh(theme); + pieChartPreviewPane.refresh(theme); + repaint(); + } + + + protected void paintBackground(Graphics2D g2d) { + if (background == null) { + background = ColorBackground.getInstance(Color.WHITE); + } + Composite oldComposite = g2d.getComposite(); + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha)); + background.paint(g2d, new Rectangle2D.Double(0, 0, 517, 532)); + g2d.setComposite(oldComposite); + } + + //柱形图 + private ChartCollection initColumnChart() { + try { + VanChart chart = (VanChart) ChartTypeManager.getInstance().getCharts(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID)[0].clone(); + chart.getTitle().setTitleVisible(false); + VanChartTools vanChartTools = chart.getVanChartTools(); + vanChartTools.setSort(false); + vanChartTools.setExport(false); + vanChartTools.setFullScreen(false); + + VanChartColumnPlot plot = chart.getPlot(); + AttrLabel defaultAttrLabel = plot.getDefaultAttrLabel(); + defaultAttrLabel.setEnable(true); + defaultAttrLabel.getAttrLabelDetail().getBorder().setBorderStyle(0); + defaultAttrLabel.getAttrLabelDetail().getBackground().setBackground(null); + plot.getConditionCollection().getDefaultAttr().addDataSeriesCondition(defaultAttrLabel); + + plot.getLegend().setPosition(Constants.TOP); + plot.getGradientStyle().setGradientType(GradientType.NONE); + plot.setSeriesOverlapPercent(30); + plot.setCategoryIntervalPercent(30); + + VanChartAxis defaultYAxis = plot.getDefaultYAxis(); + Title title = new Title(); + title.setTextObject(Toolkit.i18nText("Fine-Design_Chart_Axis_Title")); + title.getTextAttr().setRotation(-90); + title.getTextAttr().setThemed(true); + defaultYAxis.setTitle(title); + defaultYAxis.setShowAxisTitle(true); + defaultYAxis.setCustomMaxValue(true); + defaultYAxis.setCustomMinValue(true); + defaultYAxis.setCustomMainUnit(true); + defaultYAxis.setMaxValue(BaseFormula.createFormulaBuilder().build("=600")); + defaultYAxis.setMinValue(BaseFormula.createFormulaBuilder().build("=0")); + defaultYAxis.setMainUnit(BaseFormula.createFormulaBuilder().build("=200")); + + Object[] category = { + Toolkit.i18nText("Fine-Design_Chart_Category") + "1", + Toolkit.i18nText("Fine-Design_Chart_Category") + "2", + Toolkit.i18nText("Fine-Design_Chart_Category") + "3", + Toolkit.i18nText("Fine-Design_Chart_Category") + "4" + }; + Object[] series = { + Toolkit.i18nText("Fine-Design_Chart_Series") + "1", + Toolkit.i18nText("Fine-Design_Chart_Series") + "2" + }; + Object[][] value = { + {"250", "540", "300", "410"}, + {"180", "190", "170", "100"}, + }; + NormalChartData normalChartData = new NormalChartData(category, series, value); + chart.setPreViewChartData(normalChartData); + ChartCollection chartCollection = new ChartCollection(chart); + return chartCollection; + } catch (Exception ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + } + return null; + } + + //饼图 + private ChartCollection initPieChart() { + try { + VanChart chart = (VanChart) ChartTypeManager.getInstance().getCharts(PiePlot4VanChart.VAN_CHART_PIE_PLOT)[0].clone(); + chart.getTitle().setTitleVisible(false); + VanChartTools vanChartTools = chart.getVanChartTools(); + vanChartTools.setSort(false); + vanChartTools.setExport(false); + vanChartTools.setFullScreen(false); + + PiePlot4VanChart plot = chart.getPlot(); + plot.getLegend().setPosition(Constants.BOTTOM); + plot.getGradientStyle().setGradientType(GradientType.NONE); + plot.setInnerRadiusPercent(75); + plot.getRadius().setRadiusType(RadiusType.FIXED); + plot.getRadius().setRadius(80); + + Object[] category = {StringUtils.EMPTY}; + Object[] series = {"A1", "B1", "C1", "D1", "E1", "F1", "G1", "H1"}; + Object[][] value = {{45}, {24}, {12}, {8}, {5}, {3}, {2}, {1},}; + NormalChartData normalChartData = new NormalChartData(category, series, value); + chart.setPreViewChartData(normalChartData); + ChartCollection chartCollection = new ChartCollection(chart); + return chartCollection; + } catch (Exception ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + } + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ReportThemePreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ReportThemePreviewPane.java new file mode 100644 index 0000000000..ce4f4f49be --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ReportThemePreviewPane.java @@ -0,0 +1,126 @@ +package com.fr.design.mainframe.theme.preview; + +import com.fr.base.BaseFormula; +import com.fr.base.background.ColorBackground; +import com.fr.base.theme.ReportTheme; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartattr.Title; +import com.fr.chart.chartdata.NormalChartData; +import com.fr.chart.charttypes.ChartTypeManager; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.theme.TemplateThemePreviewPane; +import com.fr.design.mainframe.theme.preview.ecpreview.ECReportPreviewPane; +import com.fr.general.Background; +import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.attr.axis.VanChartAxis; +import com.fr.plugin.chart.base.AttrLabel; +import com.fr.plugin.chart.base.VanChartTools; +import com.fr.plugin.chart.column.VanChartColumnPlot; +import com.fr.plugin.chart.type.GradientType; +import com.fr.plugin.chart.vanchart.VanChart; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/13 + */ +public class ReportThemePreviewPane extends TemplateThemePreviewPane { + private Background background; + + private final ECReportPreviewPane reportPreviewPane; + + private final ChartPreviewPane chartPreviewPane; + + public ReportThemePreviewPane() { + setLayout(FRGUIPaneFactory.createBorderLayout()); + chartPreviewPane = new ChartPreviewPane(); + chartPreviewPane.populate(initColumnChart()); + chartPreviewPane.setCallbackEvent(this); + reportPreviewPane = new ECReportPreviewPane(); + this.add(chartPreviewPane, BorderLayout.CENTER); + this.add(reportPreviewPane, BorderLayout.SOUTH); + } + + @Override + public void refresh(ReportTheme theme) { + background = theme.getBodyStyle().getBackground(); + reportPreviewPane.refresh(theme); + chartPreviewPane.refresh(theme); + repaint(); + } + + + protected void paintBackground(Graphics2D g2d) { + if (background == null) { + background = ColorBackground.getInstance(Color.WHITE); + } + background.paint(g2d, new Rectangle2D.Double(0, 0, 517, 532)); + } + + + //柱形图 + private ChartCollection initColumnChart() { + try { + VanChart chart = (VanChart) ChartTypeManager.getInstance().getCharts(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID)[0].clone(); + VanChartTools vanChartTools = chart.getVanChartTools(); + vanChartTools.setSort(false); + vanChartTools.setExport(false); + vanChartTools.setFullScreen(false); + + VanChartColumnPlot plot = chart.getPlot(); + AttrLabel defaultAttrLabel = plot.getDefaultAttrLabel(); + defaultAttrLabel.setEnable(true); + defaultAttrLabel.getAttrLabelDetail().getBorder().setBorderStyle(0); + defaultAttrLabel.getAttrLabelDetail().getBackground().setBackground(null); + plot.getConditionCollection().getDefaultAttr().addDataSeriesCondition(defaultAttrLabel); + + plot.getGradientStyle().setGradientType(GradientType.NONE); + plot.setSeriesOverlapPercent(30); + plot.setCategoryIntervalPercent(30); + + VanChartAxis defaultYAxis = plot.getDefaultYAxis(); + Title title = new Title(); + title.setTextObject(Toolkit.i18nText("Fine-Design_Chart_Axis_Title")); + title.getTextAttr().setRotation(-90); + title.getTextAttr().setThemed(true); + defaultYAxis.setTitle(title); + defaultYAxis.setShowAxisTitle(true); + defaultYAxis.setCustomMaxValue(true); + defaultYAxis.setCustomMinValue(true); + defaultYAxis.setCustomMainUnit(true); + defaultYAxis.setMaxValue(BaseFormula.createFormulaBuilder().build("=600")); + defaultYAxis.setMinValue(BaseFormula.createFormulaBuilder().build("=0")); + defaultYAxis.setMainUnit(BaseFormula.createFormulaBuilder().build("=200")); + + Object[] category = { + Toolkit.i18nText("Fine-Design_Chart_Category") + "1", + Toolkit.i18nText("Fine-Design_Chart_Category") + "2", + Toolkit.i18nText("Fine-Design_Chart_Category") + "3", + Toolkit.i18nText("Fine-Design_Chart_Category") + "4" + }; + Object[] series = { + Toolkit.i18nText("Fine-Design_Chart_Series") + "1", + Toolkit.i18nText("Fine-Design_Chart_Series") + "2", + Toolkit.i18nText("Fine-Design_Chart_Series") + "3" + }; + Object[][] value = { + {"340", "510", "300", "250"}, + {"180", "360", "170", "100"}, + {"210", "205", "405", "190"} + }; + NormalChartData normalChartData = new NormalChartData(category, series, value); + chart.setPreViewChartData(normalChartData); + ChartCollection chartCollection = new ChartCollection(chart); + return chartCollection; + } catch (Exception ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + } + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ThemePreviewed.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ThemePreviewed.java new file mode 100644 index 0000000000..bb2aa05c22 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ThemePreviewed.java @@ -0,0 +1,10 @@ +package com.fr.design.mainframe.theme.preview; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/13 + */ +public interface ThemePreviewed { + void refresh(T style); +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/UINoOpaquePanel.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/UINoOpaquePanel.java new file mode 100644 index 0000000000..16eb2d55e0 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/UINoOpaquePanel.java @@ -0,0 +1,19 @@ +package com.fr.design.mainframe.theme.preview; + +import javax.swing.JPanel; +import java.awt.LayoutManager; + +public class UINoOpaquePanel extends JPanel { + + public UINoOpaquePanel(){ + super(); + this.setOpaque(false); + this.setBackground(null); + } + + public UINoOpaquePanel(LayoutManager layout) { + super(layout, true); + this.setOpaque(false); + this.setBackground(null); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/AbstractECPreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/AbstractECPreviewPane.java new file mode 100644 index 0000000000..cf9822aba8 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/AbstractECPreviewPane.java @@ -0,0 +1,47 @@ +package com.fr.design.mainframe.theme.preview.ecpreview; + +import com.fr.base.Style; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.settings.ThemedCellStyle; +import com.fr.base.theme.settings.ThemedCellStyleList; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.theme.preview.ThemePreviewed; +import com.fr.design.mainframe.theme.preview.UINoOpaquePanel; +import com.fr.design.mainframe.theme.preview.ecpreview.cell.AbstractPreviewCell; +import com.fr.design.mainframe.theme.preview.ecpreview.cell.PreviewCell; + +import javax.swing.JPanel; +import java.util.List; + +public abstract class AbstractECPreviewPane extends UINoOpaquePanel implements ThemePreviewed { + protected Style getReportHeaderStyle(ThemedCellStyleList cellStyleList) { + return getCellStyle(cellStyleList, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Header")); + } + + protected Style getMainContentStyle(ThemedCellStyleList cellStyleList) { + return getCellStyle(cellStyleList, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Main_Text")); + } + + protected Style getHighLightStyle(ThemedCellStyleList cellStyleList) { + return getCellStyle(cellStyleList, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Highlight_Text")); + } + + protected Style getSmallTitleStyle(ThemedCellStyleList cellStyleList) { + return getCellStyle(cellStyleList, Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Small_Title")); + } + + private Style getCellStyle(ThemedCellStyleList cellStyleList, String styleName) { + ThemedCellStyle cellStyle = cellStyleList.find(styleName); + if (cellStyle == null) { + return Style.DEFAULT_STYLE; + } + return cellStyle.getStyle(); + } + + protected void refresh(List list, Style style) { + for (AbstractPreviewCell cell : list) { + cell.refresh(style); + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECComponentPreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECComponentPreviewPane.java new file mode 100644 index 0000000000..ff88607d45 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECComponentPreviewPane.java @@ -0,0 +1,27 @@ +package com.fr.design.mainframe.theme.preview.ecpreview; + +import com.fr.base.theme.FormTheme; +import com.fr.design.mainframe.theme.preview.ComponentPreviewPane; + +import java.awt.Component; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/13 + */ +public class ECComponentPreviewPane extends ComponentPreviewPane { + private ECPreviewPane contentPane; + + @Override + protected Component createContentPane() { + contentPane = new ECPreviewPane(); + return contentPane; + } + + @Override + public void refresh(FormTheme theme) { + super.refresh(theme); + contentPane.refresh(theme); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECPreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECPreviewPane.java new file mode 100644 index 0000000000..2497dadbee --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECPreviewPane.java @@ -0,0 +1,104 @@ +package com.fr.design.mainframe.theme.preview.ecpreview; + +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.settings.ThemedCellStyleList; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.theme.preview.UINoOpaquePanel; +import com.fr.design.mainframe.theme.preview.ecpreview.cell.AbstractPreviewCell; +import com.fr.design.mainframe.theme.preview.ecpreview.cell.PreviewCell; +import com.fr.log.FineLoggerFactory; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.io.BufferedReader; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/13 + */ +public class ECPreviewPane extends AbstractECPreviewPane { + private static String csv = + "城市 当月目标 当月实际完成 月度完成率 全年完成率\n" + + "南通市 324,646 324,646 100% 100%\n" + + "合肥市 248,938 348,938 140% 140%\n" + + "邵阳市 248,938 348,938 140% 140%\n" + + "合计 1,071,460 1,371,460 128% 128%"; + private final List DATA_LIST = createDataList(); + private static final String BLANK_CHAR = " "; + private List headerCellList = new ArrayList<>(); + private List contentCellList = new ArrayList<>(); + private List hightLightCellList = new ArrayList<>(); + + private List createDataList() { + List data = new ArrayList<>(); + try (BufferedReader reader = new BufferedReader(new StringReader(csv))) { + String textLine; + while ((textLine = reader.readLine()) != null) { + String[] texts = textLine.split(BLANK_CHAR); + data.add(texts); + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return data; + } + + + public ECPreviewPane() { + this.setPreferredSize(new Dimension(517, 170)); + this.setBorder(BorderFactory.createEmptyBorder(0, 1, 2, 1)); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + String[] titleArr = DATA_LIST.get(0); + String[] endArr = DATA_LIST.get(DATA_LIST.size() - 1); + JPanel titlePane = new UINoOpaquePanel(new GridLayout()); + this.add(titlePane, BorderLayout.NORTH); + for (String title : titleArr) { + PreviewCell cell = new PreviewCell(title); + cell.setPreferredSize(new Dimension(103, 36)); + titlePane.add(cell); + headerCellList.add(cell); + } + + JPanel contentPane = new UINoOpaquePanel(new GridLayout(3, 5, 0, 0)); + this.add(contentPane, BorderLayout.CENTER); + for (int i = 1; i < DATA_LIST.size() - 1; i++) { + String[] textLine = DATA_LIST.get(i); + for (int j = 0; j < textLine.length; j++) { + String text = textLine[j]; + PreviewCell cell = new PreviewCell(text); + cell.setPreferredSize(new Dimension(103, 33)); + contentPane.add(cell); + contentCellList.add(cell); + } + } + + JPanel endPane = new UINoOpaquePanel(new GridLayout()); + this.add(endPane, BorderLayout.SOUTH); + for (String text : endArr) { + PreviewCell cell = new PreviewCell(text); + cell.setPreferredSize(new Dimension(103, 33)); + endPane.add(cell); + hightLightCellList.add(cell); + } + + + } + + @Override + public void refresh(TemplateTheme theme) { + ThemedCellStyleList cellStyleConfig = theme.getCellStyleList(); + refresh(headerCellList, getReportHeaderStyle(cellStyleConfig)); + refresh(contentCellList, getMainContentStyle(cellStyleConfig)); + refresh(hightLightCellList, getHighLightStyle(cellStyleConfig)); + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECReportPreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECReportPreviewPane.java new file mode 100644 index 0000000000..4274950cff --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECReportPreviewPane.java @@ -0,0 +1,126 @@ +package com.fr.design.mainframe.theme.preview.ecpreview; + +import com.fr.base.theme.ReportTheme; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.settings.ThemedCellStyleList; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.theme.preview.ThemePreviewed; +import com.fr.design.mainframe.theme.preview.UINoOpaquePanel; +import com.fr.design.mainframe.theme.preview.ecpreview.cell.AbstractPreviewCell; +import com.fr.design.mainframe.theme.preview.ecpreview.cell.CornerPreviewCell; +import com.fr.design.mainframe.theme.preview.ecpreview.cell.PreviewCell; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.Point; +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.List; + +public class ECReportPreviewPane extends UINoOpaquePanel implements ThemePreviewed { + private List headerCellList = new ArrayList<>(); + private List titleCellList = new ArrayList<>(); + private List contentCellList = new ArrayList<>(); + private List highLightCellList = new ArrayList<>(); + + private PreviewPane previewPane; + + public ECReportPreviewPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + previewPane = new PreviewPane(); + this.add(previewPane, BorderLayout.CENTER); + } + + @Override + public void refresh(ReportTheme theme) { + previewPane.refresh(theme); + } + + + class PreviewPane extends AbstractECPreviewPane { + + + public PreviewPane() { + this.setPreferredSize(new Dimension(517, 270)); + this.setBorder(BorderFactory.createEmptyBorder(7, 10, 5, 10)); + + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel northPane = createNorthPane(); + JPanel centerPane = createCenterPane(); + this.add(northPane, BorderLayout.NORTH); + this.add(centerPane, BorderLayout.CENTER); + } + + private JPanel createNorthPane() { + JPanel northPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); + CornerPreviewCell cornerCell = new CornerPreviewCell(new String[]{"产品", "数据", "统计维度"}, new Point2D[]{new Point(132, 75), new Point(189, 53)}); + cornerCell.setPreferredSize(new Dimension(189, 75)); + headerCellList.add(cornerCell); + northPane.add(cornerCell, BorderLayout.WEST); + JPanel centerPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); + northPane.add(centerPane, BorderLayout.CENTER); + PreviewCell cell = new PreviewCell("按地区统计"); + titleCellList.add(cell); + cell.setPreferredSize(new Dimension(308, 38)); + centerPane.add(cell, BorderLayout.NORTH); + JPanel eastSouthPane = new UINoOpaquePanel(new GridLayout()); + PreviewCell cell1 = new PreviewCell("华东"); + PreviewCell cell2 = new PreviewCell("华南"); + PreviewCell cell3 = new PreviewCell("小计"); + headerCellList.add(cell1); + headerCellList.add(cell2); + headerCellList.add(cell3); + eastSouthPane.add(cell1); + eastSouthPane.add(cell2); + eastSouthPane.add(cell3); + centerPane.add(eastSouthPane, BorderLayout.CENTER); + return northPane; + } + + private JPanel createCenterPane() { + JPanel centerPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); + JPanel westPane = FRGUIPaneFactory.createBorderLayout_NO_Opaque_Pane(); + centerPane.add(westPane, BorderLayout.WEST); + PreviewCell cell1 = new PreviewCell("饮料"); + titleCellList.add(cell1); + cell1.setPreferredSize(new Dimension(94, 183)); + westPane.add(cell1, BorderLayout.WEST); + JPanel gridPane = new UINoOpaquePanel(new GridLayout(6, 1)); + for (int i = 0; i < 6; i++) { + PreviewCell cell = new PreviewCell("苹果汁"); + cell.setPreferredSize(new Dimension(95, 31)); + headerCellList.add(cell); + gridPane.add(cell); + } + westPane.add(gridPane, BorderLayout.CENTER); + + JPanel innerCenterPane = new UINoOpaquePanel(new GridLayout(6, 3)); + centerPane.add(innerCenterPane, BorderLayout.CENTER); + for (int i = 0; i < 18; i++) { + PreviewCell cell = new PreviewCell("35600"); + cell.setPreferredSize(new Dimension(102, 31)); + if ((i + 1) % 3 == 0) { + highLightCellList.add(cell); + } else { + contentCellList.add(cell); + } + innerCenterPane.add(cell); + } + + + return centerPane; + } + + @Override + public void refresh(TemplateTheme theme) { + ThemedCellStyleList cellStyleConfig = theme.getCellStyleList(); + refresh(headerCellList, getReportHeaderStyle(cellStyleConfig)); + refresh(contentCellList, getMainContentStyle(cellStyleConfig)); + refresh(titleCellList, getSmallTitleStyle(cellStyleConfig)); + refresh(highLightCellList, getHighLightStyle(cellStyleConfig)); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/cell/AbstractPreviewCell.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/cell/AbstractPreviewCell.java new file mode 100644 index 0000000000..9c7c335de6 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/cell/AbstractPreviewCell.java @@ -0,0 +1,32 @@ +package com.fr.design.mainframe.theme.preview.ecpreview.cell; + +import com.fr.base.ScreenResolution; +import com.fr.base.Style; + +import javax.swing.JComponent; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; + +public abstract class AbstractPreviewCell extends JComponent { + protected Style style = Style.DEFAULT_STYLE; + + public void refresh(Style style) { + this.style = style; + } + + public void paint(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + int resolution = ScreenResolution.getScreenResolution(); + Style.paintBackground(g2d, style, getWidth(), getHeight()); + paintContent(g2d, resolution); + Style.paintBorder(g2d, style, getWidth(), getHeight()); + } + + protected abstract void paintContent(Graphics2D g2d, int resolution); + + @Override + public Dimension getMinimumSize() { + return new Dimension(125, 30); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/cell/CornerPreviewCell.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/cell/CornerPreviewCell.java new file mode 100644 index 0000000000..00cb90774c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/cell/CornerPreviewCell.java @@ -0,0 +1,33 @@ +package com.fr.design.mainframe.theme.preview.ecpreview.cell; + +import com.fr.general.FRFont; +import com.fr.stable.GraphDrawHelper; + +import java.awt.Graphics2D; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; + +public class CornerPreviewCell extends AbstractPreviewCell { + private final String[] values; + private final Point2D[] point2DS; + + public CornerPreviewCell(String[] values, Point2D[] point2DS) { + this.values = values; + this.point2DS = point2DS; + } + + @Override + protected void paintContent(Graphics2D g2d, int resolution) { + FRFont frFont = style.getFRFont(); + g2d.setPaint(frFont.getForeground()); + g2d.drawString(values[0], 23, 53); + GraphDrawHelper.drawRotatedString(g2d, values[1], 104, 50, 30); + g2d.drawString(values[2], 128, 23); + //画分割线 + for (int i = 0; i < point2DS.length; i++) { + g2d.draw(new Line2D.Double(0, 0, point2DS[i].getX(), point2DS[i].getY())); //画线 + } + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/cell/PreviewCell.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/cell/PreviewCell.java new file mode 100644 index 0000000000..a6a5836dba --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/cell/PreviewCell.java @@ -0,0 +1,25 @@ +package com.fr.design.mainframe.theme.preview.ecpreview.cell; + +import com.fr.base.Style; + +import java.awt.Dimension; +import java.awt.Graphics2D; + +public class PreviewCell extends AbstractPreviewCell { + + private final String value; + + public PreviewCell(String value) { + this.value = value; + } + + @Override + protected void paintContent(Graphics2D g2d, int resolution) { + Style.paintContent(g2d, value, style, getWidth() - 3, getHeight() - 3, resolution); + } + + @Override + public Dimension getMinimumSize() { + return new Dimension(125, 30); + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/ui/BorderUtils.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/ui/BorderUtils.java new file mode 100644 index 0000000000..3b7a8b6c0e --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/ui/BorderUtils.java @@ -0,0 +1,30 @@ +package com.fr.design.mainframe.theme.ui; + +import com.fr.design.border.UIRoundedBorder; +import com.fr.general.FRFont; + +import javax.swing.border.Border; +import javax.swing.border.TitledBorder; +import java.awt.Color; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/15 + */ +public class BorderUtils { + public static Border createTitleBorder(String title) { + return createTitleBorder(title, 12); + } + public static Border createTitleBorder(String title, int size) { + return new NoEdgeTitleBorder( + new UIRoundedBorder(new Color(0XE0E0E1), 1, 1), + title, + TitledBorder.LEADING, + TitledBorder.TOP, + FRFont.getInstance().applySize(size), + new Color(47, 142, 241) + ); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/ui/NoEdgeTitleBorder.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/ui/NoEdgeTitleBorder.java new file mode 100644 index 0000000000..bf532b00f5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/ui/NoEdgeTitleBorder.java @@ -0,0 +1,320 @@ +package com.fr.design.mainframe.theme.ui; + +import javax.swing.JLabel; +import javax.swing.UIManager; +import javax.swing.border.AbstractBorder; +import javax.swing.border.Border; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.basic.BasicHTML; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Insets; +import java.awt.Rectangle; +import java.awt.geom.Path2D; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/16 + * 修正TitleBorder默认的行为,使得组件有多大,边框就有多大 + */ +public class NoEdgeTitleBorder extends TitledBorder { + + private final JLabel label; + + public NoEdgeTitleBorder(Border border, String title, int titleJustification, int titlePosition, Font titleFont, Color titleColor) { + super(border, title, titleJustification, titlePosition, titleFont, titleColor); + + this.label = new JLabel(); + this.label.setOpaque(false); + this.label.putClientProperty(BasicHTML.propertyKey, null); + } + + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + Border border = getBorder(); + String title = getTitle(); + if ((title != null) && !title.isEmpty()) { + int edge = 0; //(border instanceof TitledBorder) ? 0 : EDGE_SPACING; + JLabel label = getLabel(c); + Dimension size = label.getPreferredSize(); + Insets insets = getBorderInsets(border, c, new Insets(0, 0, 0, 0)); + + int borderX = x + edge; + int borderY = y + edge; + int borderW = width - edge - edge; + int borderH = height - edge - edge; + + int labelY = y; + int labelH = size.height; + int position = getPosition(); + switch (position) { + case ABOVE_TOP: + insets.left = 0; + insets.right = 0; + borderY += labelH - edge; + borderH -= labelH - edge; + break; + case TOP: + insets.top = edge + insets.top/2 - labelH/2; + if (insets.top < edge) { + borderY -= insets.top; + borderH += insets.top; + } + else { + labelY += insets.top; + } + break; + case BELOW_TOP: + labelY += insets.top + edge; + break; + case ABOVE_BOTTOM: + labelY += height - labelH - insets.bottom - edge; + break; + case BOTTOM: + labelY += height - labelH; + insets.bottom = edge + (insets.bottom - labelH) / 2; + if (insets.bottom < edge) { + borderH += insets.bottom; + } + else { + labelY -= insets.bottom; + } + break; + case BELOW_BOTTOM: + insets.left = 0; + insets.right = 0; + labelY += height - labelH; + borderH -= labelH - edge; + break; + } + insets.left += edge + TEXT_INSET_H; + insets.right += edge + TEXT_INSET_H; + + int labelX = x; + int labelW = width - insets.left - insets.right; + if (labelW > size.width) { + labelW = size.width; + } + switch (getJustification(c)) { + case LEFT: + labelX += insets.left; + break; + case RIGHT: + labelX += width - insets.right - labelW; + break; + case CENTER: + labelX += (width - labelW) / 2; + break; + } + + if (border != null) { + if ((position != TOP) && (position != BOTTOM)) { + border.paintBorder(c, g, borderX, borderY, borderW, borderH); + } + else { + Graphics g2 = g.create(); + if (g2 instanceof Graphics2D) { + Graphics2D g2d = (Graphics2D) g2; + Path2D path = new Path2D.Float(); + path.append(new Rectangle(borderX, borderY, borderW, labelY - borderY), false); + path.append(new Rectangle(borderX, labelY, labelX - borderX - TEXT_SPACING, labelH), false); + path.append(new Rectangle(labelX + labelW + TEXT_SPACING, labelY, borderX - labelX + borderW - labelW - TEXT_SPACING, labelH), false); + path.append(new Rectangle(borderX, labelY + labelH, borderW, borderY - labelY + borderH - labelH), false); + g2d.clip(path); + } + border.paintBorder(c, g2, borderX, borderY, borderW, borderH); + g2.dispose(); + } + } + g.translate(labelX, labelY); + label.setSize(labelW, labelH); + label.paint(g); + g.translate(-labelX, -labelY); + } + else if (border != null) { + border.paintBorder(c, g, x, y, width, height); + } + } + + /** + * Reinitialize the insets parameter with this Border's current Insets. + * @param c the component for which this border insets value applies + * @param insets the object to be reinitialized + */ + public Insets getBorderInsets(Component c, Insets insets) { + Border border = getBorder(); + insets = getBorderInsets(border, c, insets); + + String title = getTitle(); + if ((title != null) && !title.isEmpty()) { + int edge = 0; //(border instanceof TitledBorder) ? 0 : EDGE_SPACING; + JLabel label = getLabel(c); + Dimension size = label.getPreferredSize(); + + switch (getPosition()) { + case ABOVE_TOP: + insets.top += size.height - edge; + break; + case TOP: { + if (insets.top < size.height) { + insets.top = size.height - edge; + } + break; + } + case BELOW_TOP: + insets.top += size.height; + break; + case ABOVE_BOTTOM: + insets.bottom += size.height; + break; + case BOTTOM: { + if (insets.bottom < size.height) { + insets.bottom = size.height - edge; + } + break; + } + case BELOW_BOTTOM: + insets.bottom += size.height - edge; + break; + } + insets.top += edge; //TEXT_SPACING; + insets.left += edge; //TEXT_SPACING; + insets.right += edge; //TEXT_SPACING; + insets.bottom += edge; //TEXT_SPACING; + } + return insets; + } + + public int getBaseline(Component c, int width, int height) { + if (c == null) { + throw new NullPointerException("Must supply non-null component"); + } + if (width < 0) { + throw new IllegalArgumentException("Width must be >= 0"); + } + if (height < 0) { + throw new IllegalArgumentException("Height must be >= 0"); + } + Border border = getBorder(); + String title = getTitle(); + if ((title != null) && !title.isEmpty()) { + int edge = 0; //(border instanceof TitledBorder) ? 0 : EDGE_SPACING; + JLabel label = getLabel(c); + Dimension size = label.getPreferredSize(); + Insets insets = getBorderInsets(border, c, new Insets(0, 0, 0, 0)); + + int baseline = label.getBaseline(size.width, size.height); + switch (getPosition()) { + case ABOVE_TOP: + return baseline; + case TOP: + insets.top = edge + (insets.top - size.height) / 2; + return (insets.top < edge) + ? baseline + : baseline + insets.top; + case BELOW_TOP: + return baseline + insets.top + edge; + case ABOVE_BOTTOM: + return baseline + height - size.height - insets.bottom - edge; + case BOTTOM: + insets.bottom = edge + (insets.bottom - size.height) / 2; + return (insets.bottom < edge) + ? baseline + height - size.height + : baseline + height - size.height + insets.bottom; + case BELOW_BOTTOM: + return baseline + height - size.height; + } + } + return -1; + } + + private int getPosition() { + int position = getTitlePosition(); + if (position != DEFAULT_POSITION) { + return position; + } + Object value = UIManager.get("TitledBorder.position"); + if (value instanceof Integer) { + int i = (Integer) value; + if ((0 < i) && (i <= 6)) { + return i; + } + } + else if (value instanceof String) { + String s = (String) value; + if (s.equalsIgnoreCase("ABOVE_TOP")) { + return ABOVE_TOP; + } + if (s.equalsIgnoreCase("TOP")) { + return TOP; + } + if (s.equalsIgnoreCase("BELOW_TOP")) { + return BELOW_TOP; + } + if (s.equalsIgnoreCase("ABOVE_BOTTOM")) { + return ABOVE_BOTTOM; + } + if (s.equalsIgnoreCase("BOTTOM")) { + return BOTTOM; + } + if (s.equalsIgnoreCase("BELOW_BOTTOM")) { + return BELOW_BOTTOM; + } + } + return TOP; + } + + private int getJustification(Component c) { + int justification = getTitleJustification(); + if ((justification == LEADING) || (justification == DEFAULT_JUSTIFICATION)) { + return c.getComponentOrientation().isLeftToRight() ? LEFT : RIGHT; + } + if (justification == TRAILING) { + return c.getComponentOrientation().isLeftToRight() ? RIGHT : LEFT; + } + return justification; + } + + private Color getColor(Component c) { + Color color = getTitleColor(); + if (color != null) { + return color; + } + return (c != null) + ? c.getForeground() + : null; + } + + private JLabel getLabel(Component c) { + this.label.setText(getTitle()); + Font font = getFont(c); + this.label.setFont(font); + this.label.setForeground(getColor(c)); + this.label.setComponentOrientation(c.getComponentOrientation()); + this.label.setEnabled(c.isEnabled()); + Dimension dimension = this.label.getPreferredSize(); + dimension.height = font.getSize(); + this.label.setPreferredSize(dimension); + return this.label; + } + + private static Insets getBorderInsets(Border border, Component c, Insets insets) { + if (border == null) { + insets.set(0, 0, 0, 0); + } + else if (border instanceof AbstractBorder) { + AbstractBorder ab = (AbstractBorder) border; + insets = ab.getBorderInsets(c, insets); + } + else { + Insets i = border.getBorderInsets(c); + insets.set(i.top, i.left, i.bottom, i.right); + } + return insets; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/utils/DefaultThemedTemplateCellElementCase.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/utils/DefaultThemedTemplateCellElementCase.java new file mode 100644 index 0000000000..67d8c0b2a2 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/utils/DefaultThemedTemplateCellElementCase.java @@ -0,0 +1,45 @@ +package com.fr.design.mainframe.theme.utils; + +import com.fr.base.NameStyle; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.settings.ThemedCellStyle; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.mainframe.JTemplate; +import com.fr.report.cell.DefaultTemplateCellElement; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/31 + */ +public class DefaultThemedTemplateCellElementCase { + + public static DefaultTemplateCellElement createInstance() { + return themingCellElement(new DefaultTemplateCellElement()); + } + + public static DefaultTemplateCellElement createInstance(int column, int row) { + return themingCellElement(new DefaultTemplateCellElement(column, row)); + } + + public static DefaultTemplateCellElement createInstance(int column, int row, Object value) { + return themingCellElement(new DefaultTemplateCellElement(column, row, value)); + } + + public static DefaultTemplateCellElement createInstance(int column, int row, int columnSpan, int rowSpan, Object value) { + return themingCellElement(new DefaultTemplateCellElement(column, row, columnSpan, rowSpan, value)); + } + + private static DefaultTemplateCellElement themingCellElement(DefaultTemplateCellElement cellElement) { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + TemplateTheme theme = template.getTemplateTheme(); + ThemedCellStyle themedCellStyle = theme.getCellStyleList().getDefaultCellStyle4New(); + if (themedCellStyle != null) { + NameStyle nameStyle = NameStyle.getPassiveInstance(themedCellStyle.getName(), themedCellStyle.getStyle()); + cellElement.setStyle(nameStyle); + } + } + return cellElement; + } +} 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 a2d0ec83fa..d8e5b4a57e 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 @@ -9,7 +9,19 @@ import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; -import com.fr.design.actions.community.*; +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.TemplateStoreAction; +import com.fr.design.actions.community.VideoAction; +import com.fr.design.actions.community.WorkOrderCenterAction; import com.fr.design.actions.file.CloseCurrentTemplateAction; import com.fr.design.actions.file.ExitDesignerAction; import com.fr.design.actions.file.OpenRecentReportMenuDef; @@ -64,7 +76,6 @@ import com.fr.plugin.observer.PluginEventType; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; import com.fr.stable.bridge.ObjectHolder; -import com.fr.stable.os.support.OSBasedAction; import com.fr.stable.os.support.OSSupportCenter; import com.fr.start.OemHandler; import com.fr.workspace.WorkContext; @@ -141,16 +152,6 @@ public abstract class ToolBarMenuDock { return PANLE_HEIGNT; } - /** - * 导出菜单的子菜单 ,目前用于图表设计器 - * - * @return 子菜单 - */ - @Override - public ShortCut[] shortcut4ExportMenu() { - return new ShortCut[0]; - } - }; private static final int MENUBAR_HEIGHT = 22; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java index ada075aeb6..4de9018ace 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java @@ -1,11 +1,13 @@ package com.fr.design.mainframe.toolbar; -import javax.swing.*; - +import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.menu.MenuDef; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; +import javax.swing.JComponent; +import javax.swing.JPanel; + public interface ToolBarMenuDockPlus { /** * 模板的工具 @@ -54,10 +56,19 @@ public interface ToolBarMenuDockPlus { int getToolBarHeight(); /** - * 导出菜单的子菜单 ,目前用于图表设计器 + * 是否含有工具栏 包含:预览按钮 复制粘贴那一行 模板标签页那一行 字体颜色那一行 * - * @return 子菜单 + * @return 默认返回true */ - ShortCut[] shortcut4ExportMenu(); + default boolean hasToolBarPane() { + return true; + } + + /** + * 往 复制粘贴那一行工具栏 插入 工具栏按钮 + */ + default void insertToCombineUpToolbar(UIToolbar combineUp) { + } + } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/notification/SnapChatAllTypes.java b/designer-base/src/main/java/com/fr/design/notification/SnapChatAllTypes.java index d94da0c887..ae83a0bb91 100644 --- a/designer-base/src/main/java/com/fr/design/notification/SnapChatAllTypes.java +++ b/designer-base/src/main/java/com/fr/design/notification/SnapChatAllTypes.java @@ -12,7 +12,13 @@ public abstract class SnapChatAllTypes { /** * 社区按钮 */ - BBS("BBS"); + BBS("BBS"), + + /** + * 服务器按钮 + */ + SERVER("SERVER"); + private static final String SIGN = "0001"; @@ -35,4 +41,32 @@ public abstract class SnapChatAllTypes { } } + public enum UpdateAction implements SnapChatKey { + + /** + * 服务器模版主题管理 + */ + TEMPLATE_THEMES_MANAGER("TEMPLATE_THEMES_MANAGER"); + + private static final String SIGN = "0002"; + + private String key; + + UpdateAction(String key) { + this.key = key; + } + + public String getKey() { + return key; + } + + @Override + public String calc() { + + return CommonUtils.join( + new String[]{SIGN, getKey()}, "-" + ); + } + } + } diff --git a/designer-base/src/main/java/com/fr/design/preview/NewWritePreview.java b/designer-base/src/main/java/com/fr/design/preview/NewWritePreview.java deleted file mode 100644 index 8c7e408ff5..0000000000 --- a/designer-base/src/main/java/com/fr/design/preview/NewWritePreview.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.fr.design.preview; - -import com.fr.design.fun.impl.AbstractPreviewProvider; - -import java.util.HashMap; -import java.util.Map; - -/** - * 新前端填报预览 - * by abel 2021/07/08 - */ -public class NewWritePreview extends AbstractPreviewProvider { - @Override - public String nameForPopupItem() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_New_Preview"); - } - - @Override - public String iconPathForPopupItem() { - return "com/fr/design/images/buttonicon/writes.png"; - } - - @Override - public String iconPathForLarge() { - return "com/fr/design/images/buttonicon/writeb24.png"; - } - - @Override - public int previewTypeCode() { - return 99; - } - - @Override - public Map parametersForPreview() { - Map map = new HashMap(); - map.put("op", "write_new"); - return map; - } -} diff --git a/designer-base/src/main/java/com/fr/design/remote/ui/AuthorityEditorPane.java b/designer-base/src/main/java/com/fr/design/remote/ui/AuthorityEditorPane.java index 26fc0c28a2..da5817b853 100644 --- a/designer-base/src/main/java/com/fr/design/remote/ui/AuthorityEditorPane.java +++ b/designer-base/src/main/java/com/fr/design/remote/ui/AuthorityEditorPane.java @@ -38,7 +38,7 @@ public class AuthorityEditorPane extends BasicBeanPane { ) ) ); - IOFileNodeFilter filter = new IOFileNodeFilter(new String[]{".cpt", ".class", ".frm", ".form"}); + IOFileNodeFilter filter = new IOFileNodeFilter(new String[]{".cptx", ".cpt", ".class", ".frm", ".form"}); tree.setDigIn(true); tree.setFileNodeFilter(filter); UIScrollPane scrollPane = new UIScrollPane(tree); diff --git a/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java b/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java index 588e4601d0..48e988a826 100644 --- a/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java +++ b/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java @@ -163,7 +163,7 @@ public class WatermarkPane extends BasicPane { tipsJp.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical"), SwingConstants.CENTER)); watermarkGapTipsPane.add(tipsJp, BorderLayout.CENTER); - colorPane = new NewColorSelectPane(); + colorPane = new NewColorSelectPane(false); JPanel colorLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); colorLabelPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Text_Color")), BorderLayout.NORTH); diff --git a/designer-base/src/main/java/com/fr/design/style/CustomSelectBox.java b/designer-base/src/main/java/com/fr/design/style/CustomSelectBox.java index cffe363737..3b8e1daa23 100644 --- a/designer-base/src/main/java/com/fr/design/style/CustomSelectBox.java +++ b/designer-base/src/main/java/com/fr/design/style/CustomSelectBox.java @@ -11,7 +11,7 @@ import javax.swing.event.ChangeListener; import com.fr.base.background.ColorBackground; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.style.background.BackgroundCustomJComponent; -import com.fr.design.style.color.ColorSelectPane; +import com.fr.design.style.color.NewColorSelectPane; /** @@ -40,11 +40,11 @@ public class CustomSelectBox extends AbstractPopBox { @Override public JPanel initWindowPane(double preferredWidth) { - ColorSelectPane colorPane = new ColorSelectPane(); + NewColorSelectPane colorPane = new NewColorSelectPane(); colorPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { - ColorSelectPane source = (ColorSelectPane)e.getSource(); + NewColorSelectPane source = (NewColorSelectPane)e.getSource(); setSelectObject(source.getColor()); hidePopupMenu(); } diff --git a/designer-base/src/main/java/com/fr/design/style/background/BackgroundPane.java b/designer-base/src/main/java/com/fr/design/style/background/BackgroundPane.java index 593250ca8c..ebaf04e32a 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/BackgroundPane.java +++ b/designer-base/src/main/java/com/fr/design/style/background/BackgroundPane.java @@ -8,6 +8,7 @@ import java.awt.Dimension; import java.util.HashMap; import java.util.Map; +import com.fr.base.background.ColorBackground; import com.fr.design.gui.frpane.UITabbedPane; import javax.swing.event.ChangeEvent; @@ -16,6 +17,9 @@ import javax.swing.event.EventListenerList; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.dialog.BasicPane; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.style.background.impl.ColorBackgroundPane; +import com.fr.design.style.background.impl.ColorNoThemeBackgroundPane; import com.fr.general.Background; import com.fr.log.FineLoggerFactory; @@ -27,14 +31,15 @@ public class BackgroundPane extends BasicPane { private EventListenerList eventChangeList = new EventListenerList(); protected Map cacheMap = new HashMap<>(); - + //需求说: 如果是浏览器背景, 隐藏掉几个button public BackgroundPane() { + BackgroundFactory.getWrapper(ColorBackground.class).setType( + DesignerContext.getDesignerFrame().isServerConfig() ? ColorNoThemeBackgroundPane.class : ColorBackgroundPane.class); this.initComponents(); this.setPreferredSize(new Dimension(400, 300)); } - protected void initComponents() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/AbstractComponentPopBox.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/AbstractComponentPopBox.java new file mode 100644 index 0000000000..ef647f2bde --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/style/background/gradient/AbstractComponentPopBox.java @@ -0,0 +1,243 @@ +package com.fr.design.style.background.gradient; + +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.style.background.BackgroundJComponent; +import com.fr.general.Background; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JWindow; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.util.ArrayList; +import java.util.List; +import java.awt.AWTEvent; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.Window; +import java.awt.event.AWTEventListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2021-08-24 + */ +public abstract class AbstractComponentPopBox extends JComponent { + + protected BackgroundJComponent displayComponent; + + private JWindow selectPopupWindow; + private boolean isWindowEventInit = false; + private static int GAP = 2; + private static int GAP2 = 20; + + private List changeListenerList = new ArrayList(); + + MouseAdapter mouseListener = new MouseAdapter() { + public void mousePressed(MouseEvent evt) { + showPopupMenu(); + } + + + }; + + AWTEventListener awt = new AWTEventListener() { + public void eventDispatched(AWTEvent event) { + if (event instanceof MouseEvent) { + MouseEvent evt = (MouseEvent) event; + if (evt.getClickCount() > 0) { + mouseClick(evt); + } + } + } + }; + + protected void showPopupMenu() { + if (selectPopupWindow != null && selectPopupWindow.isVisible()) { + hidePopupMenu(); + return; + } + + if (!this.isEnabled()) { + return; + } + Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); + + selectPopupWindow = this.getControlWindow(); + + Point convertPoint = new Point(0, 0); + + // e: 将点(0,0)从ColorSelectionPane的坐标系统转换到屏幕坐标. + SwingUtilities.convertPointToScreen(convertPoint, this); + int y = convertPoint.y + this.getSize().height; + int x = convertPoint.x; + int h = y + selectPopupWindow.getHeight(); + int width = x + selectPopupWindow.getWidth(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + if (h > screenSize.height) { + y = y - selectPopupWindow.getHeight() - GAP2;// 超过屏幕高度了 + } + + if (width > screenSize.width) { + x = screenSize.width - selectPopupWindow.getWidth(); + } + selectPopupWindow.setLocation(x, y); + + selectPopupWindow.setVisible(true); + + //wei : 为了点击别的地方下拉颜色窗口消失 + MouseAdapter parentMouseListener = new MouseAdapter() { + public void mousePressed(MouseEvent evt) { + mouseClick(evt); + } + }; + if (!this.isWindowEventInit && SwingUtilities.getAncestorOfClass(GradientBackgroundPane.class, this) != null) { + SwingUtilities.getAncestorOfClass(GradientBackgroundPane.class, this).addMouseListener(parentMouseListener); + this.isWindowEventInit = true; + } + } + + private void mouseClick(MouseEvent evt) { + Point point = new Point((int) (evt.getLocationOnScreen().getX()), (int) evt.getLocationOnScreen().getY()); + Dimension popBoxD = AbstractComponentPopBox.this.getSize(); + try { + Point popBoxP = AbstractComponentPopBox.this.getLocationOnScreen(); + Dimension popMenuD = this.getControlWindow().getSize(); + Point popMenuP = this.getControlWindow().getLocation(); + Rectangle popBoxRect = new Rectangle(popBoxP, popBoxD); + Rectangle popMenuRect = new Rectangle(popMenuP, popMenuD); + if (!popBoxRect.contains(point) && !popMenuRect.contains(point)) { + this.hidePopupMenu(); + } + } catch (Exception ignore) { + this.hidePopupMenu(); + } + } + + protected void hidePopupMenu() { + if (selectPopupWindow != null) { + selectPopupWindow.setVisible(false); + } + + selectPopupWindow = null; + Toolkit.getDefaultToolkit().removeAWTEventListener(awt); + } + + protected JWindow getControlWindow() { + //find parent. + if (this.selectPopupWindow == null) { + Window parentWindow = SwingUtilities.windowForComponent(this); + if (parentWindow != null) { + this.selectPopupWindow = new AbstractComponentPopBox.SelectControlWindow(parentWindow); + } + + selectPopupWindow.addMouseListener(new MouseAdapter() { + public void mouseExited(MouseEvent evt) { + int x = evt.getLocationOnScreen().x; + int y = evt.getLocationOnScreen().y; + + if (selectPopupWindow != null) { + double desValue = 2; + Rectangle rectangle = selectPopupWindow.getBounds(); + boolean b1 = x < rectangle.x + desValue || x >= rectangle.x + rectangle.width - desValue; + boolean b2 = y > rectangle.y + rectangle.height - desValue;//避免了鼠标下移刚进入selectPopupWindow的过程中弹出框隐藏,上移移出后由AbstractPopBox的mouseListener处理 + if (b1 || b2) { + hidePopupMenu(); + } + } + } + }); + } + + return selectPopupWindow; + } + + /** + * 添加事件 + * + * @param changeListener 事件 + */ + public void addSelectChangeListener(ChangeListener changeListener) { + this.changeListenerList.add(changeListener); + } + + /** + * 删除事件 + * + * @param changeListener 事件 + */ + public void removeSelectChangeListener(ChangeListener changeListener) { + this.changeListenerList.remove(changeListener); + } + + /** + * 响应事件 + */ + public void fireChangeListener() { + if (!changeListenerList.isEmpty()) { + ChangeEvent evt = new ChangeEvent(this); + for (int i = 0; i < changeListenerList.size(); i++) { + this.changeListenerList.get(i).stateChanged(evt); + } + } + } + + /** + * 待说明 + * + * @param background 背景 + */ + public void fireDisplayComponent(Background background) { + if (displayComponent != null) { + displayComponent.setSelfBackground(background); + } + fireChangeListener(); + this.repaint(); + } + + /** + * 初始化弹出框的面板 + * + * @param preWidth 宽度 + * @return 弹出面板 + */ + public abstract JPanel initWindowPane(double preWidth); + + private class SelectControlWindow extends JWindow { + private static final long serialVersionUID = -5776589767069105911L; + + public SelectControlWindow(Window paranet) { + super(paranet); + this.initComponents(); + } + + public void initComponents() { + JPanel defaultPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.setContentPane(defaultPane); + +// defaultPane.setBorder(UIManager.getBorder("PopupMenu.border")); + + if (displayComponent != null) { + defaultPane.add(initWindowPane(displayComponent.getPreferredSize().getWidth())); + } else { + defaultPane.add(initWindowPane(20)); + } + this.pack(); + } + + @Override + public void setVisible(boolean b) { + super.setVisible(b); + AbstractComponentPopBox.this.repaint(); + } + } + + protected boolean isPopupVisible() { + return selectPopupWindow == null ? false : selectPopupWindow.isVisible(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarNoTheme.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarNoTheme.java new file mode 100644 index 0000000000..f3393366d2 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBarNoTheme.java @@ -0,0 +1,39 @@ +package com.fr.design.style.background.gradient; + +import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.style.color.ColorSelectDetailPane; +import com.fr.design.style.color.ColorSelectDialog; + +import javax.swing.JPanel; +import java.awt.Color; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2021-08-19 + */ +public class FixedGradientBarNoTheme extends FixedGradientBar { + + + public FixedGradientBarNoTheme(int minvalue, int maxvalue) { + super(minvalue, maxvalue); + } + + protected void clickButton(int select) { + ColorSelectDetailPane pane = new ColorSelectDetailPane(Color.WHITE); + Color selectColor = getList().get(select).getColorInner() == null ? Color.WHITE : getList().get(select).getColorInner(); + ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, selectColor, FixedGradientBarNoTheme.this); + Color color = FixedGradientBarNoTheme.this.getColor(); + if (color != null) { + DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color); + getList().get(select).setColorInner(color); + stateChanged(); + FixedGradientBarNoTheme.this.repaint(); + } + } + + public JPanel initWindowPane(double preWidth) { + return null; + } +} 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 b088864c0f..aac5c837a7 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 @@ -1,18 +1,16 @@ package com.fr.design.style.background.gradient; -import com.fr.design.DesignerEnvManager; +import com.fr.base.background.ColorBackground; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.itextfield.UINumberField; -import com.fr.design.mainframe.DesignerContext; import com.fr.design.style.color.ColorCell; -import com.fr.design.style.color.ColorSelectDetailPane; -import com.fr.design.style.color.ColorSelectDialog; import com.fr.design.style.color.ColorSelectable; +import com.fr.design.style.color.NewColorSelectPane; import com.fr.stable.AssistUtils; - import com.fr.stable.os.OperatingSystem; -import javax.swing.JComponent; + +import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; @@ -33,8 +31,8 @@ import java.awt.geom.Point2D; /** * TODO:面板缩放的功能没有考虑(就是尾值过大,导致超过界面显示的情况),原来的那个实现完全是个BUG。要缩放的情况也比较少,就干脆以后弄吧 */ -public class GradientBar extends JComponent implements UIObserver, ColorSelectable { - +public class GradientBar extends AbstractComponentPopBox implements UIObserver, ColorSelectable { + private NewColorSelectPane colorPane; /** * */ @@ -88,6 +86,22 @@ public class GradientBar extends JComponent implements UIObserver, ColorSelectab iniListener(); } + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + public int getIndex() { + return index; + } + + public void setIndex(int index) { + this.index = index; + } + public void updateColor(Color begin, Color end) { p1.setColorInner(begin); p2.setColorInner(end); @@ -106,15 +120,7 @@ public class GradientBar extends JComponent implements UIObserver, ColorSelectab } if (select >= 0) { - ColorSelectDetailPane pane = new ColorSelectDetailPane(Color.WHITE); - ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, GradientBar.this); - Color color = GradientBar.this.getColor(); - if (color != null) { - DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color); - list.get(select).setColorInner(color); - stateChanged(); - GradientBar.this.repaint(); - } + clickButton(select); } GradientBar.this.repaint(); } @@ -122,6 +128,36 @@ public class GradientBar extends JComponent implements UIObserver, ColorSelectab }); } + protected void clickButton(int select) { + setIndex(select); + showPopupMenu(); + } + + public JPanel initWindowPane(double preferredWidth) { + // 下拉的时候重新生成面板,刷新最近使用颜色 + colorPane = new NewColorSelectPane(false) { + @Override + public void setVisible(boolean b) { + super.setVisible(b); + } + + @Override + protected boolean selectRealTime() { + return false; + } + }; + colorPane.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + hidePopupMenu(); + setColor(((NewColorSelectPane) e.getSource()).getColor()); + getList().get(getIndex()).setColorInner(getColor()); + fireDisplayComponent(ColorBackground.getInstance(getColor())); + GradientBar.this.stateChanged(); + } + }); + return colorPane; + } + protected void addMouseDragListener() { this.addMouseMotionListener(new MouseAdapter() { public void mouseDragged(MouseEvent e) { @@ -132,10 +168,10 @@ public class GradientBar extends JComponent implements UIObserver, ColorSelectab break; } } - if(OperatingSystem.isLinux() && AssistUtils.equals(oldIndex,index)){ - if(Math.abs(p1.getX() - e.getX()) > Math.abs(p2.getX() - e.getX())){ + if (OperatingSystem.isLinux() && AssistUtils.equals(oldIndex, index)) { + if (Math.abs(p1.getX() - e.getX()) > Math.abs(p2.getX() - e.getX())) { index = 1; - }else{ + } else { index = 0; } } diff --git a/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java b/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java index 1e5e96ab1f..9c5b1af4d1 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java +++ b/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java @@ -3,266 +3,78 @@ */ package com.fr.design.style.background.image; -import com.fr.base.BaseUtils; import com.fr.design.DesignerEnvManager; -import com.fr.design.style.ChooseFileView; - - -import javax.swing.filechooser.FileFilter; -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; +import com.fr.design.gui.ifilechooser.FileSelectionMode; +import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.share.collect.ComponentCollector; +import com.fr.design.mainframe.toast.DesignerToastMsgUtil; +import javafx.stage.FileChooser; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.io.File; -import java.util.Enumeration; -import java.util.Hashtable; /** * This class used to choose image files. */ -public class ImageFileChooser extends ExpandFileChooser { +public class ImageFileChooser { + + JavaFxNativeFileChooser javaFxNativeFileChooser; public ImageFileChooser() { - super(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Image_Compress"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Open")); - ExampleFileFilter bothFilter = new ExampleFileFilter( - new String[]{"jpg", "gif", "png", "bmp"}, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Image_Image_Files")); - bothFilter.setExtensionListInDescription(true); - this.addChoosableFileFilter(bothFilter); - this.setAcceptAllFileFilterUsed(false); + javaFxNativeFileChooser = + new JavaFxNativeFileChooser.Builder(). + fileSelectionMode(FileSelectionMode.FILE). + title(Toolkit.i18nText("Fine-Design_Basic_Open")). + filter(Toolkit.i18nText("Fine-Design_Basic_Image_Image_Files"), "*.jpg", "*.gif", "*.png", "*.bmp"). + build(); + } - // Create Custom FileView - ChooseFileView fileView = new ChooseFileView(); - fileView.putIcon("jpg", BaseUtils.readIcon("/com/fr/base/images/dialog/file/jpgFile.gif")); - fileView.putIcon("gif", BaseUtils.readIcon("/com/fr/base/images/dialog/file/gifFile.gif")); - fileView.putIcon("png", BaseUtils.readIcon("/com/fr/base/images/dialog/file/pngFile.png")); - fileView.putIcon("bmp", BaseUtils.readIcon("/com/fr/base/images/dialog/file/bmpFile.gif")); - this.setFileView(fileView); + public int showOpenDialog(Component parent, String approveButtonText) { + return showOpenDialog(parent); } - public int showDialog(Component parent, String approveButtonText) { - return super.showDialog(parent, approveButtonText); + public int showOpenDialog(Component parent) { + showImageCompressMoveTip(); + return javaFxNativeFileChooser.showDialog(parent); } - @Override - public ActionListener checkAction() { - return new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - DesignerEnvManager.getEnvManager().setImageCompress(isCheckSelected()); - DesignerEnvManager.getEnvManager().saveXMLFile(); - } - }; - + public void setCurrentDirectory(File file) { + javaFxNativeFileChooser.setCurrentDirectory(file); } - /** - * A convenience implementation of FileFilter that filters out - * all files except for those type extensions that it knows about. - *

D:\finereport\develop\code\test\TestCase\WEB-INF\reportlets\TestCase\01903.cpt - *

- * Extensions are of the type ".foo", which is typically found on - * Windows and Unix boxes, but not on Macinthosh. Case is ignored. - *

- * Example - create a new filter that filerts out all files - * but gif and jpg image files: - *

- * JFileChooser chooser = new JFileChooser(); - * ExampleFileFilter filter = new ExampleFileFilter( - * new String{"gif", "jpg"}, "JPEG & GIF Images") - * chooser.addChoosableFileFilter(filter); - * chooser.showOpenDialog(this); - * - * @author Jeff Dinkins - * @version 1.12 12/03/01 - */ - class ExampleFileFilter extends FileFilter { - private Hashtable filters = null; - private String description = null; - private String fullDescription = null; - private boolean useExtensionsInDescription = true; - - /** - * Creates a file filter. If no filters are added, then all - * files are accepted. - * - * @see #addExtension - */ - public ExampleFileFilter() { - this.filters = new Hashtable(); - } - - /** - * Creates a file filter that accepts files with the given extension. - * Example: new ExampleFileFilter("jpg"); - * - * @see #addExtension - */ - public ExampleFileFilter(String extension) { - this(extension, null); - } - - /** - * Creates a file filter that accepts the given file type. - * Example: new ExampleFileFilter("jpg", "JPEG Image Images"); - *

- * Note that the "." before the extension is not needed. If - * provided, it will be ignored. - * - * @see #addExtension - */ - public ExampleFileFilter(String extension, String description) { - this(); - if (extension != null) addExtension(extension); - if (description != null) setDescription(description); - } - - /** - * Creates a file filter from the given string array. - * Example: new ExampleFileFilter(String {"gif", "jpg"}); - *

- * Note that the "." before the extension is not needed adn - * will be ignored. - * - * @see #addExtension - */ - public ExampleFileFilter(String[] filters) { - this(filters, null); - } - - /** - * Creates a file filter from the given string array and description. - * Example: new ExampleFileFilter(String {"gif", "jpg"}, "Gif and JPG Images"); - *

- * Note that the "." before the extension is not needed and will be ignored. - * - * @see #addExtension - */ - public ExampleFileFilter(String[] filters, String description) { - this(); - for (int i = 0; i < filters.length; i++) { - // add filters one by one - addExtension(filters[i]); - } - if (description != null) setDescription(description); - } - - /** - * Return true if this file should be shown in the directory pane, - * false if it shouldn't. - *

- * Files that begin with "." are ignored. - * - * @see #getExtension - */ - public boolean accept(File f) { - if (f != null) { - if (f.isDirectory()) { - return true; - } - String extension = getExtension(f); - if (extension != null && filters.get(getExtension(f)) != null) { - return true; - } - } - return false; - } - - /** - * Return the extension portion of the file's name . - * - * @see #getExtension - * @see javax.swing.filechooser.FileFilter#accept - */ - public String getExtension(File f) { - if (f != null) { - String filename = f.getName(); - int i = filename.lastIndexOf('.'); - if (i > 0 && i < filename.length() - 1) { - return filename.substring(i + 1).toLowerCase(); - } - } - return null; + public void setMultiSelectionEnabled(boolean multiple) { + if (multiple) { + javaFxNativeFileChooser.setSelectionMode(FileSelectionMode.MULTIPLE_FILE); + } else { + javaFxNativeFileChooser.setSelectionMode(FileSelectionMode.FILE); } + } - /** - * Adds a filetype "dot" extension to filter against. - *

- * For example: the following code will create a filter that filters - * out all files except those that end in ".jpg" and ".tif": - *

- * ExampleFileFilter filter = new ExampleFileFilter(); - * filter.addExtension("jpg"); - * filter.addExtension("tif"); - *

- * Note that the "." before the extension is not needed and will be ignored. - */ - public void addExtension(String extension) { - if (filters == null) { - filters = new Hashtable(5); - } - filters.put(extension.toLowerCase(), this); - fullDescription = null; - } + public File getSelectedFile() { + return javaFxNativeFileChooser.getSelectedFile(); + } + public boolean isCheckSelected() { + return DesignerEnvManager.getEnvManager().isImageCompress(); + } - /** - * Returns the human readable description of this filter. For - * example: "JPEG and GIF Image Files (*.jpg, *.gif)" - * - * @see javax.swing.filechooser.FileFilter#getDescription - */ - public String getDescription() { - if (fullDescription == null) { - if (description == null || isExtensionListInDescription()) { - fullDescription = description == null ? "(" : description + " ("; - // build the description from the extension list - Enumeration extensions = filters.keys(); - if (extensions != null) { - fullDescription += "." + extensions.nextElement(); - while (extensions.hasMoreElements()) { - fullDescription += ", ." + extensions.nextElement(); - } - } - fullDescription += ")"; - } else { - fullDescription = description; + private void showImageCompressMoveTip() { + if (DesignerEnvManager.getEnvManager().isShowImageCompressMoveTip()) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + DesignerToastMsgUtil.toastWarning(Toolkit.i18nText("Fine-Design_Image_Compress_Move_Tip")); + DesignerEnvManager.getEnvManager().setShowImageCompressMoveTip(false); } - } - return fullDescription; - } - - /** - * Sets the human readable description of this filter. For - * example: filter.setDescription("Gif and JPG Images"); - */ - public void setDescription(String description) { - this.description = description; - fullDescription = null; - } - - /** - * Determines whether the extension list (.jpg, .gif, etc) should - * show up in the human readable description. - *

- * Only relevent if a description was provided in the constructor - * or using setDescription(); - */ - public void setExtensionListInDescription(boolean b) { - useExtensionsInDescription = b; - fullDescription = null; - } - - /** - * Returns whether the extension list (.jpg, .gif, etc) should - * show up in the human readable description. - *

- * Only relevent if a description was provided in the constructor - * or using setDescription(); - */ - public boolean isExtensionListInDescription() { - return useExtensionsInDescription; + }); } } } diff --git a/designer-base/src/main/java/com/fr/design/style/background/impl/ColorBackgroundPane.java b/designer-base/src/main/java/com/fr/design/style/background/impl/ColorBackgroundPane.java index 62a08a948a..37fef6e613 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/impl/ColorBackgroundPane.java +++ b/designer-base/src/main/java/com/fr/design/style/background/impl/ColorBackgroundPane.java @@ -19,10 +19,14 @@ public class ColorBackgroundPane extends BackgroundDetailPane { public ColorBackgroundPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); - detailColorSelectPane = new DetailColorSelectPane(); + detailColorSelectPane = createColorSelectPane(); this.add(detailColorSelectPane, BorderLayout.CENTER); } + protected DetailColorSelectPane createColorSelectPane(){ + return new DetailColorSelectPane(); + } + public void populate(Background background) { if (background instanceof ColorBackground) { ColorBackground colorBackgroud = (ColorBackground) background; diff --git a/designer-base/src/main/java/com/fr/design/style/background/impl/ColorNoThemeBackgroundPane.java b/designer-base/src/main/java/com/fr/design/style/background/impl/ColorNoThemeBackgroundPane.java new file mode 100644 index 0000000000..01ee19a67e --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/style/background/impl/ColorNoThemeBackgroundPane.java @@ -0,0 +1,10 @@ +package com.fr.design.style.background.impl; + +import com.fr.design.style.color.DetailColorSelectPane; + +public class ColorNoThemeBackgroundPane extends ColorBackgroundPane{ + + protected DetailColorSelectPane createColorSelectPane(){ + return new DetailColorSelectPane(false); + } +} diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java b/designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java index fcdc594b5f..ad99b90835 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java @@ -1,13 +1,14 @@ package com.fr.design.style.color; import com.fr.base.BaseUtils; -import com.fr.base.background.ColorBackground; +import com.fr.design.DesignerEnvManager; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.VerticalFlowLayout; -import com.fr.design.style.AbstractSelectBox; +import com.fr.design.mainframe.DesignerContext; +import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -75,7 +76,7 @@ public class ColorAdjustPane extends JPanel implements UIObserver { int size = colorButtons.size(); Color[] colors = new Color[size]; for (int i = 0; i < size; i++) { - colors[i] = colorButtons.get(i).getSelectObject(); + colors[i] = colorButtons.get(i).getColor(); } return colors; } @@ -169,7 +170,7 @@ public class ColorAdjustPane extends JPanel implements UIObserver { } - private class AddColorButton extends AbstractSelectBox { + private class AddColorButton extends JComponent implements ColorSelectable { BufferedImage image = BaseUtils.readImageWithCache("/com/fr/design/images/buttonicon/add.png"); @@ -195,43 +196,38 @@ public class ColorAdjustPane extends JPanel implements UIObserver { return new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - showPopupMenu(); + //打开颜色选择面板 + showDialog(); } }; } - public JPanel initWindowPane(double preferredWidth) { - // 下拉的时候重新生成面板,刷新最近使用颜色 - ColorSelectPane colorPane = new ColorSelectPane(false) { - public void setVisible(boolean b) { - super.setVisible(b); - } + private void showDialog() { + ColorSelectDetailPane pane = new ColorSelectDetailPane(getColor()); + ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, getColor(), this, true); + Color color = this.getColor(); + if (color != null) { + DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color); + } + } - protected boolean selectRealTime() { - return false; - } - }; - colorPane.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - hidePopupMenu(); - Color color = ((ColorSelectPane) e.getSource()).getColor(); - fireDisplayComponent(ColorBackground.getInstance(color)); - if(colorButtons.size() < MAX_BUTTON) { - colorButtons.add(createColorButton(color)); - } - ColorAdjustPane.this.stateChanged(); - relayout(); - } - }); - return colorPane; + @Override + public void setColor(Color color) { + if (colorButtons.size() < MAX_BUTTON) { + colorButtons.add(createColorButton(color)); + } + ColorAdjustPane.this.stateChanged(); + relayout(); } - public Color getSelectObject() { - return null; + @Override + public Color getColor() { + return Color.WHITE; } - public void setSelectObject(Color color) { + @Override + public void colorSetted(ColorCell colorCell) { } } -} +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorButton.java b/designer-base/src/main/java/com/fr/design/style/color/ColorButton.java index a052f99f13..5ad794c79c 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorButton.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorButton.java @@ -1,11 +1,10 @@ package com.fr.design.style.color; import com.fr.base.BaseUtils; -import com.fr.base.background.ColorBackground; -import com.fr.design.style.AbstractSelectBox; +import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.DesignerContext; -import javax.swing.JPanel; -import javax.swing.event.ChangeEvent; +import javax.swing.JComponent; import javax.swing.event.ChangeListener; import java.awt.Color; import java.awt.Dimension; @@ -22,7 +21,7 @@ import java.awt.image.BufferedImage; * @version 10.0 * Created by Bjorn on 2020-03-06 */ -public class ColorButton extends AbstractSelectBox { +public class ColorButton extends JComponent implements ColorSelectable { private static final double DEL_WIDTH = 7; @@ -34,8 +33,6 @@ public class ColorButton extends AbstractSelectBox { private boolean isMoveOn = false; - private ColorSelectPane colorPane; - private boolean lastButton; private ChangeListener changeListener; @@ -111,40 +108,24 @@ public class ColorButton extends AbstractSelectBox { } if (e.getX() >= bounds.getWidth() - DEL_WIDTH && e.getY() <= DEL_WIDTH) { deleteButton(); - hidePopupMenu(); return; } } //打开颜色选择面板 - showPopupMenu(); + showDialog(); } - public JPanel initWindowPane(double preferredWidth) { - // 下拉的时候重新生成面板,刷新最近使用颜色 - colorPane = new ColorSelectPane(false) { - @Override - public void setVisible(boolean b) { - super.setVisible(b); - } - - @Override - protected boolean selectRealTime() { - return false; - } - }; - colorPane.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - hidePopupMenu(); - color = ((ColorSelectPane) e.getSource()).getColor(); - fireDisplayComponent(ColorBackground.getInstance(color)); - ColorButton.this.stateChanged(); - } - }); - return colorPane; + private void showDialog() { + ColorSelectDetailPane pane = new ColorSelectDetailPane(getColor()); + ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, getColor(), this, true); + Color color = this.getColor(); + if (color != null) { + DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color); + } } public void stateChanged() { - if (changeListener != null) { + if (changeListener != null) { changeListener.stateChanged(null); } } @@ -153,26 +134,18 @@ public class ColorButton extends AbstractSelectBox { this.changeListener = changeListener; } + @Override + public void setColor(Color color) { + this.color = color; + this.stateChanged(); + } - /** - * 获取当前选中的颜色 - * - * @return 当前选中的颜色 - */ - public Color getSelectObject() { + @Override + public Color getColor() { return this.color; } - /** - * 设置选中的颜色 - * - * @param color 颜色 - */ - public void setSelectObject(Color color) { - this.color = color; - colorPane.setColor(color); - - fireDisplayComponent(ColorBackground.getInstance(color)); + @Override + public void colorSetted(ColorCell colorCell) { } - -} +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorCell.java b/designer-base/src/main/java/com/fr/design/style/color/ColorCell.java index 06cca51d03..3e5636dc3e 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorCell.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorCell.java @@ -76,17 +76,21 @@ public class ColorCell extends JComponent implements ColorSelectable { g.fillRect(b.left, b.top, right, bottom); } - if (colorSelectable.getColor() != null - && ComparatorUtils.equals(colorSelectable.getColor(), this.getColor())) { + if (isColorSelected(colorSelectable)) { g.setColor(UIConstants.LINE_COLOR); g.drawRect(b.left, b.top, right - 1, bottom - 1); } } + protected boolean isColorSelected(ColorSelectable colorSelectable){ + return colorSelectable.getColor() != null + && ComparatorUtils.equals(colorSelectable.getColor(), this.getColor()); + } + /** * 鼠标事件处理 - * @param 鼠标事件 + * @param e 鼠标事件 */ public void processMouseEvent(MouseEvent e) { if (!isEnabled()) { diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java b/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java index 4ee3a119ea..43f994a65b 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java @@ -58,15 +58,19 @@ public abstract class ColorControlWindow extends JPopupMenu { } protected void initSelectionPopupPane(boolean isSupportTransparent) { - selectionPopupPane = new ColorSelectionPopupPane(isSupportTransparent); + selectionPopupPane = new ColorSelectionPopupPane(isSupportTransparent, supportThemeColor()); this.add(selectionPopupPane, BorderLayout.CENTER); } + protected boolean supportThemeColor(){ + return true; + } + class ColorSelectionPopupPane extends NewColorSelectPane { private static final long serialVersionUID = 7822856562329146354L; - public ColorSelectionPopupPane(boolean isSupportTransparent) { - super(isSupportTransparent); + public ColorSelectionPopupPane(boolean isSupportTransparent, boolean isSupportThemeColor) { + super(isSupportTransparent, isSupportThemeColor); this.addChangeListener(new ChangeListener() { @Override @@ -77,7 +81,7 @@ public abstract class ColorControlWindow extends JPopupMenu { } @Override - protected void doTransparent() { + public void doTransparent() { popupHider.hidePopupMenu(); super.doTransparent(); } diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindowWithAuto.java b/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindowWithAuto.java index cbb0e97eaa..dc4eb9571b 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindowWithAuto.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindowWithAuto.java @@ -61,7 +61,7 @@ public abstract class ColorControlWindowWithAuto extends ColorControlWindow { }); } - protected void doTransparent() { + public void doTransparent() { getPopupHider().hidePopupMenu(); setColor(null); } @@ -114,11 +114,10 @@ public abstract class ColorControlWindowWithAuto extends ColorControlWindow { } } + @Override public Dimension getPreferredSize() { - if (isSupportTransparent()) { - return new Dimension(super.getPreferredSize().width, TRANSPARENT_WINDOW_HEIGHT + BUTTON_HEIGHT); - } - return new Dimension(super.getPreferredSize().width, WINDOW_HEIGHT + BUTTON_HEIGHT); + Dimension dimension = super.getPreferredSize(); + return new Dimension(dimension.width, dimension.height + BUTTON_HEIGHT); } } diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorFactory.java b/designer-base/src/main/java/com/fr/design/style/color/ColorFactory.java index b22104f283..b643752b39 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorFactory.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorFactory.java @@ -71,5 +71,18 @@ public interface ColorFactory { new Color(0, 0, 255) }; + public static final Color STANDARD_COLORS[] = { + new Color(166, 89, 66), + new Color(166, 123, 66), + new Color(166, 66, 66), + new Color(103, 166, 66), + new Color(66, 121, 166), + new Color(68, 66, 166), + new Color(98, 66, 166), + new Color(146, 66, 166), + new Color(75, 18, 89), + new Color(89, 18, 51) + }; + } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectBox.java b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectBox.java index d2a8245445..3ec124b135 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectBox.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectBox.java @@ -17,7 +17,7 @@ public class ColorSelectBox extends AbstractSelectBox implements UIObserv private static final long serialVersionUID = 2782150678943960557L; private Color color; - private ColorSelectPane colorPane; + private NewColorSelectPane colorPane; private UIObserverListener uiObserverListener; public ColorSelectBox(int preferredWidth) { @@ -40,12 +40,8 @@ public class ColorSelectBox extends AbstractSelectBox implements UIObserv } } - protected ColorSelectPane getColorSelectPane(){ - return new ColorSelectPane() { - public void setVisible(boolean b) { - super.setVisible(b); - } - }; + protected NewColorSelectPane getColorSelectPane(){ + return new NewColorSelectPane(); } /** @@ -56,14 +52,14 @@ public class ColorSelectBox extends AbstractSelectBox implements UIObserv public JPanel initWindowPane(double preferredWidth) { // 下拉的时候重新生成面板,刷新最近使用颜色 colorPane = getColorSelectPane(); + colorPane.setColor(color); colorPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { hidePopupMenu(); - color = ((ColorSelectPane) e.getSource()).getColor(); + color = ((NewColorSelectPane) e.getSource()).getColor(); fireDisplayComponent(ColorBackground.getInstance(color)); } }); - colorPane.setColor(color); return colorPane; } diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDetailPane.java b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDetailPane.java index 13d8998222..3756fc627e 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDetailPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDetailPane.java @@ -36,6 +36,10 @@ public class ColorSelectDetailPane extends BasicPane { return selectedPanel; } + private SwatchChooserPanel swatchChooserPanel; + + private CustomChooserPanel customChooserPanel; + public void setSelectedPanel(JColorChooser selectedPanel) { this.selectedPanel = selectedPanel; } @@ -69,9 +73,9 @@ public class ColorSelectDetailPane extends BasicPane { selectedPanel.setPreferredSize(new Dimension(selectedPanel.getWidth(), SELECT_PANEL_HEIGHT)); selectedPanel.setPreviewPanel(new JPanel()); - AbstractColorChooserPanel swatchChooserPanel = new SwatchChooserPanel(); - AbstractColorChooserPanel customChooserPanel = new CustomChooserPanel(); - selectedPanel.setChooserPanels(new AbstractColorChooserPanel[]{swatchChooserPanel, customChooserPanel}); + swatchChooserPanel = new SwatchChooserPanel(); + customChooserPanel = new CustomChooserPanel(); + selectedPanel.setChooserPanels(new AbstractColorChooserPanel[]{customChooserPanel, swatchChooserPanel}); this.add(selectedPanel, BorderLayout.NORTH); // 最近使用面板 @@ -98,4 +102,8 @@ public class ColorSelectDetailPane extends BasicPane { previewPanel.add(colorChooserPreview); this.add(previewPanel, BorderLayout.SOUTH); } + + public void populate(Color color){ + customChooserPanel.setColor(color); + } } diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java index 33eb6dbf15..56bc9aa655 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java @@ -77,6 +77,7 @@ public class ColorSelectDialog extends MiddleChartDialog{ this.okListener = (ColorTracker) okListener; this.seletePane = seletePane; initComponent(); + this.pane.populate(initialColor); } private void initComponent() { diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java index 68c1b2b992..452c5fe30a 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java @@ -30,6 +30,7 @@ import java.awt.event.MouseEvent; /** * The pane used to select color */ +@Deprecated public class ColorSelectPane extends TransparentPane implements ColorSelectable { private static final long serialVersionUID = -8634152305687249392L; diff --git a/designer-base/src/main/java/com/fr/design/style/color/DetailColorSelectPane.java b/designer-base/src/main/java/com/fr/design/style/color/DetailColorSelectPane.java index 4245c1293b..5d7e81487e 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/DetailColorSelectPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/DetailColorSelectPane.java @@ -29,10 +29,14 @@ import com.fr.design.dialog.BasicPane; * Often used for foreground selection. */ public class DetailColorSelectPane extends BasicPane { - private ColorSelectPane colorSelectPane; + private NewColorSelectPane colorSelectPane; private UILabel colorPreviewLabel; - public DetailColorSelectPane() { + public DetailColorSelectPane(){ + this(true); + } + + public DetailColorSelectPane(boolean supportTheme) { this.setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 4)); this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -44,7 +48,7 @@ public class DetailColorSelectPane extends BasicPane { defaultPane.add(Box.createHorizontalStrut(4)); JPanel colorSelectContainPane =FRGUIPaneFactory.createBorderLayout_L_Pane(); defaultPane.add(colorSelectContainPane); - colorSelectPane = new ColorSelectPane(); + colorSelectPane = NewColorSelectPane.createColorSelectPaneWithTheme(supportTheme); colorSelectContainPane.add(colorSelectPane, BorderLayout.NORTH); defaultPane.add(Box.createHorizontalStrut(8)); diff --git a/designer-base/src/main/java/com/fr/design/style/color/FineColorCell.java b/designer-base/src/main/java/com/fr/design/style/color/FineColorCell.java new file mode 100644 index 0000000000..1007b3f849 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/style/color/FineColorCell.java @@ -0,0 +1,38 @@ +package com.fr.design.style.color; + +import com.fr.base.FineColor; +import com.fr.general.ComparatorUtils; + +import java.awt.Color; + +public class FineColorCell extends ColorCell { + private final int x; + private final int y; + + public FineColorCell(Color color, ColorSelectable colorSelectable) { + this(color, colorSelectable, -1, -1); + } + + public FineColorCell(Color color, ColorSelectable colorSelectable, int x, int y) { + super(color, colorSelectable); + this.x = x; + this.y = y; + } + + public Color getColor() { + Color color = super.getColor(); + FineColor fineColor = new FineColor(x, y, color); + return fineColor; + } + + + protected boolean isColorSelected(ColorSelectable colorSelectable) { + Color color = colorSelectable.getColor(); + if (color instanceof FineColor) { + return super.isColorSelected(colorSelectable) && (x == ((FineColor) color).getHor()) && (y == ((FineColor) color).getVer()); + } + return super.isColorSelected(colorSelectable); + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectBox.java b/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectBox.java index 4f291c6398..04d368e6bc 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectBox.java +++ b/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectBox.java @@ -20,7 +20,7 @@ public class NewColorSelectBox extends AbstractSelectBox implements UIObs private static final long serialVersionUID = 2782150678943960557L; private Color color; - private NewColorSelectPane colorPane = new NewColorSelectPane(); + private NewColorSelectPane colorPane = new NewColorSelectPane(false); private UIObserverListener uiObserverListener; private String newColorSelectBoxName = ""; private GlobalNameListener globalNameListener = null; @@ -58,7 +58,8 @@ public class NewColorSelectBox extends AbstractSelectBox implements UIObs */ public JPanel initWindowPane(double preferredWidth) { // 下拉的时候重新生成面板,以刷新最近使用颜色 - colorPane = new NewColorSelectPane(); + colorPane = new NewColorSelectPane(false); + colorPane.setColor(this.getSelectObject()); colorPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { hidePopupMenu(); diff --git a/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java b/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java index 6c21c10cba..8abab768ab 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java @@ -1,16 +1,22 @@ package com.fr.design.style.color; +import com.fr.base.FineColor; +import com.fr.base.theme.TemplateTheme; import com.fr.design.DesignerEnvManager; import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.theme.dialog.TemplateThemeProfileDialog; import javax.swing.BorderFactory; -import javax.swing.Box; +import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -19,11 +25,10 @@ import java.awt.Color; import java.awt.Cursor; import java.awt.Dimension; import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; +import java.util.List; /** @@ -32,57 +37,75 @@ import java.util.ArrayList; */ public class NewColorSelectPane extends BasicPane implements ColorSelectable { private static final long serialVersionUID = -8634152305687249392L; + private static final float BRIGHTNESS_VALUE = 0.15F; + private static final float PURITY_VALUE = 0.1F; - private Color color = null; // color + private FineColor color = null; // color // color setting action. - private ArrayList colorChangeListenerList = new ArrayList(); + private final ArrayList colorChangeListenerList = new ArrayList<>(); // 是否支持透明 private boolean isSupportTransparent; + private boolean isSupportThemeColor; + public final static int TRANSPARENT_WINDOW_HEIGHT = 165; public final static int WINDOW_HEIGHT = 150; // 最近使用颜色 - private UsedColorPane usedColorPane; + private final NewUsedColorPane usedColorPane; + private final JPanel menuColorPane; + private ColorCell[][] themeColorCellGrid; + + public static NewColorSelectPane createColorSelectPaneWithTheme(boolean supportTheme){ + return new NewColorSelectPane(true, supportTheme); + } /** * Constructor. */ public NewColorSelectPane() { - this(false); + this(true); + } + + public NewColorSelectPane(boolean isSupportTransparent) { + this(isSupportTransparent, true); } /** * Constructor. */ - NewColorSelectPane(boolean isSupportTransparent) { + public NewColorSelectPane(boolean isSupportTransparent, boolean isSupportThemeColor) { + this.isSupportThemeColor = isSupportThemeColor; initSelectButton(isSupportTransparent); - // center JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); + centerPane.setBorder(BorderFactory.createEmptyBorder(10, 4, 0 ,4)); this.add(centerPane, BorderLayout.CENTER); - // 第一行 - JPanel row1Pane = new JPanel(FRGUIPaneFactory.createBorderLayout()); - row1Pane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 0)); - row1Pane.setPreferredSize(new Dimension(135, 16)); // 宽度为 16 * 8 + 7 - centerPane.add(row1Pane); - // 最近使用 - usedColorPane = new UsedColorPane(1, 8, 1, this, true, false); - usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8)); - row1Pane.add(usedColorPane.getPane()); - - JPanel menuColorPane1 = new JPanel(); - centerPane.add(menuColorPane1); - - menuColorPane1.setLayout(new GridLayout(5, 8, 1, 1)); - menuColorPane1.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8)); - for (int i = 0; i < ColorFactory.MenuColors.length; i++) { - menuColorPane1.add(new ColorCell(ColorFactory.MenuColors[i], this)); + menuColorPane = getMenuColorPane(); + centerPane.add(menuColorPane); + if(isSupportThemeColor){ + initThemeColorPane(); + }else { + initMenuColorPane(); } - centerPane.add(Box.createVerticalStrut(1)); + JPanel standardColorPane = new JPanel(new BorderLayout(0, 5)); + standardColorPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + standardColorPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Standard_Color")), BorderLayout.CENTER); + centerPane.add(standardColorPane); + JPanel colorSelectPane = createStandardColorPane(); + standardColorPane.add(colorSelectPane, BorderLayout.SOUTH); + + // 增加最近使用 pane + JPanel row1Pane = new JPanel(new BorderLayout(0, 5)); + row1Pane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + row1Pane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Used")), BorderLayout.CENTER); + centerPane.add(row1Pane); + // 最近使用 + usedColorPane = new NewUsedColorPane(9, this, selectRealTime()); + row1Pane.add(usedColorPane.getPane(), BorderLayout.SOUTH); // mod by anchore 16/11/16 final UIButton customButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_More_Color")); @@ -99,12 +122,138 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { }); customButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); - JPanel centerPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane(); - centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 8)); - centerPane1.add(customButton, BorderLayout.NORTH); + JPanel centerPane1 = new JPanel(new BorderLayout(0, 0)); + centerPane1.setBorder(BorderFactory.createEmptyBorder(9, 0, 11, 0)); + centerPane1.add(customButton, BorderLayout.CENTER); + customButton.setPreferredSize(new Dimension(197, 20)); centerPane.add(centerPane1); } + private JPanel createStandardColorPane(){ + JPanel jPanel = new JPanel(new GridLayout(1, 10, 3, 0)); + Color[] colorArray = ColorFactory.STANDARD_COLORS; + for (int i = 0; i < colorArray.length; i++) { + jPanel.add(new ColorCell(colorArray[i], this)); + } + return jPanel; + } + + private void initThemeColorPane(){ + menuColorPane.removeAll(); + menuColorPane.setLayout(new BorderLayout(0, 10)); + JPanel northPane = new JPanel(new GridLayout(1, 8, 3, 0)); + JPanel centerPane = new JPanel(new GridLayout(1, 8, 3, 0)); + menuColorPane.add(northPane, BorderLayout.NORTH); + menuColorPane.add(centerPane, BorderLayout.CENTER); + + Color[] colorArray = new Color[] { + // 2列灰度色 + Color.decode("#B3B3B3"), + Color.decode("#808080"), + + // 8列主题色 + Color.decode("#FFFFFF"), + Color.decode("#CCCCCC"), + Color.decode("#FFFFFF"), + Color.decode("#CCCCCC"), + Color.decode("#FFFFFF"), + Color.decode("#CCCCCC"), + Color.decode("#FFFFFF"), + Color.decode("#CCCCCC"), + }; + + if (themeColorCellGrid == null) { + themeColorCellGrid = new ColorCell[colorArray.length][5]; + for (int i = 0; i < colorArray.length; i++) { + ColorCell[] colorCellColumn = new ColorCell[5]; + boolean isDefaultColor = (i == 0 || i == 1); + Color color = colorArray[i]; + colorCellColumn[0] = createFineColorCell(color, isDefaultColor, i, 2); + colorCellColumn[2] = createFineColorCell(color = saturationDown(color, isDefaultColor, true), isDefaultColor, i, 1); + colorCellColumn[1] = createFineColorCell(saturationDown(color, isDefaultColor, true), isDefaultColor, i, 0); + color = colorArray[i]; + colorCellColumn[3] = createFineColorCell(color = saturationDown(color, isDefaultColor, false), isDefaultColor, i, 3); + colorCellColumn[4] = createFineColorCell(saturationDown(color, isDefaultColor, false), isDefaultColor, i, 4); + themeColorCellGrid[i] = colorCellColumn; + } + } + + for (int i = 0; i < colorArray.length; i++) { + northPane.add(themeColorCellGrid[i][0]); + } + for (int i = 0; i < colorArray.length; i++) { + JPanel columnPane = new JPanel(new GridLayout(4, 1, 0, 3)); + columnPane.add(themeColorCellGrid[i][1]); + columnPane.add(themeColorCellGrid[i][2]); + columnPane.add(themeColorCellGrid[i][3]); + columnPane.add(themeColorCellGrid[i][4]); + centerPane.add(columnPane); + } + + refreshThemeMenuColorPane(); + } + + private void refreshThemeMenuColorPane() { + List standardColors = null; + if (TemplateThemeProfileDialog.isEditingTheme()) { + standardColors = TemplateThemeProfileDialog.getEditingColorScheme(); + } else { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + TemplateTheme theme = template.getTemplateTheme(); + if (theme != null) { + standardColors = theme.getColorScheme().getColors(); + } + } + } + if (standardColors == null || standardColors.size() != 8) { + return; + } + + for (int i = 2; i < themeColorCellGrid.length; i++) { + Color color = standardColors.get(i - 2); + + themeColorCellGrid[i][0].setColor(color); + themeColorCellGrid[i][2].setColor(color = saturationDown(color, false, true)); + themeColorCellGrid[i][1].setColor(saturationDown(color, false, true)); + + color = standardColors.get(i - 2); + themeColorCellGrid[i][3].setColor(color = saturationDown(color, false, false)); + themeColorCellGrid[i][4].setColor(saturationDown(color, false, false)); + } + } + + + private FineColorCell createFineColorCell(Color color, boolean isDefaultColor, int x, int y) { + return isDefaultColor ? new FineColorCell(color, this) : new FineColorCell(color, this, x - 2, y); + } + + /** + * 调整明度和纯度,默认色只调整明度 + * @param color + * @param isDefaultColor + * @return + */ + public static Color saturationDown(Color color, boolean isDefaultColor, boolean isLight) { + float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), new float[3]); + if (!isDefaultColor) { + hsb[1] = isLight ? Math.max(0, hsb[1] - PURITY_VALUE) : Math.min(1, hsb[1] + PURITY_VALUE); + } + hsb[2] = isLight ? Math.min(1, hsb[2] + BRIGHTNESS_VALUE) : Math.max(0, hsb[2] - BRIGHTNESS_VALUE); + Color color1 = Color.getHSBColor(hsb[0], hsb[1], hsb[2]); + return color1; + } + + private void initMenuColorPane() { + menuColorPane.setLayout(new GridLayout(5, 8, 3, 3)); + Color[] colorArray = this.getColorArray(); + for (int i = 0; i < colorArray.length; i++) { + Color color = colorArray[i] == null ? UsedColorPane.DEFAULT_COLOR : colorArray[i]; + menuColorPane.add(new ColorCell(color, this)); + } + + } + public boolean isSupportTransparent() { return isSupportTransparent; } @@ -113,6 +262,10 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { isSupportTransparent = supportTransparent; } + protected boolean selectRealTime() { + return true; + } + protected void initSelectButton(boolean isSupportTransparent){ this.isSupportTransparent = isSupportTransparent; this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -120,21 +273,14 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { if (isSupportTransparent) { UIButton transparentButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency")); this.add(transparentButton, BorderLayout.NORTH); - transparentButton.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - doTransparent(); - } - }); + transparentButton.addActionListener(e -> doTransparent()); } } /** * 添加监听 - * - * @param 监听列表 Add change listener. + * @param changeListener 监听 */ public void addChangeListener(ChangeListener changeListener) { this.colorChangeListenerList.add(changeListener); @@ -151,7 +297,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { * @return 颜色 * Return the color. */ - public Color getColor() { + public FineColor getColor() { return color; } @@ -163,7 +309,6 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { public Color getNotNoneColor() { if (color == null) { setColor(Color.WHITE); - return Color.WHITE; } return color; } @@ -175,27 +320,36 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { */ @Override public void setColor(Color color) { - this.color = color; + if (isSupportThemeColor) { + refreshThemeMenuColorPane(); + } + FineColor fineColor; + if (color == null) { + fineColor = null; + } else { + fineColor = color instanceof FineColor ? (FineColor) color : new FineColor(color); + } + setFineColor(fineColor); + } + + private void setFineColor(FineColor fineColor){ + this.color = fineColor; // fire color change. if (!colorChangeListenerList.isEmpty()) { ChangeEvent evt = new ChangeEvent(this); - for (int i = 0; i < colorChangeListenerList.size(); i++) { - this.colorChangeListenerList.get(i).stateChanged(evt); + for (ChangeListener changeListener : colorChangeListenerList) { + changeListener.stateChanged(evt); } } DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color); this.repaint(); } - /** - * 设置颜色 - * - * @param 颜色位置 - */ @Override public void colorSetted(ColorCell colorCell) { + this.updateUsedColor(); colorCell.repaint(); } @@ -203,18 +357,28 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { setColor(null); } + protected Color[] getColorArray() { + return ColorFactory.MenuColors; + } + + protected JPanel getMenuColorPane() { + return new JPanel(); + } + + protected void customButtonPressed() { // 颜色选择器 ColorSelectDetailPane pane = new ColorSelectDetailPane(Color.WHITE); - ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this); + Color color = getColor() == null ? Color.WHITE : getColor().getColor(); + ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, color, this); } @Override public Dimension getPreferredSize() { if (isSupportTransparent) { - return new Dimension(super.getPreferredSize().width, TRANSPARENT_WINDOW_HEIGHT); + return new Dimension(197, 265); } - return new Dimension(super.getPreferredSize().width, WINDOW_HEIGHT); + return new Dimension(197, 250); } /** @@ -224,5 +388,68 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { usedColorPane.updateUsedColor(); } + class NewUsedColorPane extends BasicPane { + + // 最近使用面板列数 + private int columns; + + // 最近使用面板 + private JPanel pane; + + private ColorSelectable selectable; + + private boolean setColorRealTime; + + public JPanel getPane(){ + return this.pane; + } + + + public NewUsedColorPane(int columns, ColorSelectable selectable, boolean setColorRealTime){ + this.columns = columns; + this.selectable = selectable; + this.setColorRealTime = setColorRealTime; + initialComponents(); + } + + + private void initialComponents() { + int total = columns; + JPanel panel = new JPanel(); + panel.setLayout(new GridLayout(1, columns + 1, 3, 3)); + panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + //最近使用颜色 + Color[] colors = DesignerEnvManager.getEnvManager().getColorConfigManager().getColors(); + int size = colors.length; + for (int i = 0; i < total; i++) { + Color color = i < size ? colors[size - i - 1] : + UsedColorPane.DEFAULT_COLOR; + panel.add(new ColorCell(color == null ? UsedColorPane.DEFAULT_COLOR : color, selectable)); + } + // 取色按钮 + JButton pickColorButton = PickColorButtonFactory.getPickColorButton(selectable, PickColorButtonFactory.IconType.ICON16, setColorRealTime); + panel.add(pickColorButton); + this.pane = panel; + } + + /** + * 更新最近使用颜色 + */ + public void updateUsedColor() { + int total = columns ; + Color[] colors = DesignerEnvManager.getEnvManager().getColorConfigManager().getColors(); + int size = colors.length; + for (int i = 0; i < total; i++) { + ColorCell cell = (ColorCell) this.pane.getComponent(i); + Color color = i < size ? colors[size - i - 1] : UsedColorPane.DEFAULT_COLOR; + cell.setColor(color == null ? UsedColorPane.DEFAULT_COLOR : color); + } + } + + @Override + protected String title4PopupWindow() { + return null; + } + } } diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java b/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java index 8616b647b4..5ae56627e9 100644 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java @@ -11,7 +11,14 @@ import com.fr.stable.os.OperatingSystem; public class ModernUIPaneFactory { public static ModernUIPane.Builder modernUIPaneBuilder() { - if (OperatingSystem.isWindows()) { + // 7.15的class不存在时 走老版本 + boolean hasJxBrowserV7_15 = true; + try { + Class.forName("com.teamdev.jxbrowser.net.Scheme"); + } catch (ClassNotFoundException e) { + hasJxBrowserV7_15 = false; + } + if (OperatingSystem.isWindows() && hasJxBrowserV7_15) { return new NewModernUIPane.Builder<>(); } else { return new ModernUIPane.Builder<>(); diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java b/designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java index ab883516cf..33747d3f15 100644 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java +++ b/designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java @@ -16,15 +16,14 @@ import com.teamdev.jxbrowser.engine.Engine; import com.teamdev.jxbrowser.engine.EngineOptions; import com.teamdev.jxbrowser.engine.RenderingMode; import com.teamdev.jxbrowser.js.JsObject; -import com.teamdev.jxbrowser.net.Network; -import com.teamdev.jxbrowser.net.callback.InterceptRequestCallback; +import com.teamdev.jxbrowser.net.Scheme; import com.teamdev.jxbrowser.view.swing.BrowserView; import java.awt.BorderLayout; import java.awt.Dimension; import java.util.Map; -import java.util.Optional; + import javax.swing.JDialog; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; @@ -43,6 +42,8 @@ public class NewModernUIPane extends ModernUIPane { private String namespace = "Pool"; private String variable = "data"; private String expression = "update()"; + private Scheme scheme; + private NxInterceptRequestCallback requestCallback; private NewModernUIPane() { super(); @@ -96,7 +97,13 @@ public class NewModernUIPane extends ModernUIPane { } private void initializeBrowser() { - Engine engine = Engine.newInstance(EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").build()); + EngineOptions options; + if (scheme != null && requestCallback != null) { + options = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").addScheme(scheme, requestCallback).build(); + } else { + options = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").build(); + } + Engine engine = Engine.newInstance(options); browser = engine.newBrowser(); // 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的 @@ -124,8 +131,9 @@ public class NewModernUIPane extends ModernUIPane { */ @Override public void redirect(String url, Map map) { - Network network = browser.engine().network(); - network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network, map)); + if (requestCallback != null) { + requestCallback.setMap(map); + } browser.navigation().loadUrl(url); } @@ -169,8 +177,8 @@ public class NewModernUIPane extends ModernUIPane { */ @Override public NewModernUIPane.Builder withEMB(final String path) { - Network network = pane.browser.engine().network(); - network.set(InterceptRequestCallback.class, new NxComplexInterceptRequestCallback(network, null)); + pane.scheme = Scheme.of("emb"); + pane.requestCallback = new NxComplexInterceptRequestCallback(null); pane.browser.navigation().loadUrl("emb:" + path); return this; } @@ -182,8 +190,8 @@ public class NewModernUIPane extends ModernUIPane { */ @Override public NewModernUIPane.Builder withURL(final String url) { - Network network = pane.browser.engine().network(); - network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network)); + pane.scheme = Scheme.of("file"); + pane.requestCallback = new NxComplexInterceptRequestCallback(null); pane.browser.navigation().loadUrl(url); return this; } @@ -195,8 +203,8 @@ public class NewModernUIPane extends ModernUIPane { */ @Override public NewModernUIPane.Builder withURL(final String url, Map map) { - Network network = pane.browser.engine().network(); - network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network, map)); + pane.scheme = Scheme.of("file"); + pane.requestCallback = new NxInterceptRequestCallback(map); pane.browser.navigation().loadUrl(url); return this; } @@ -208,8 +216,8 @@ public class NewModernUIPane extends ModernUIPane { */ @Override public NewModernUIPane.Builder withComponent(AssembleComponent component) { - Network network = pane.browser.engine().network(); - network.set(InterceptRequestCallback.class, new NxComplexInterceptRequestCallback(network, component)); + pane.scheme = Scheme.of("emb"); + pane.requestCallback = new NxComplexInterceptRequestCallback(component); pane.browser.navigation().loadUrl("emb:dynamic"); return this; } @@ -221,8 +229,8 @@ public class NewModernUIPane extends ModernUIPane { */ @Override public NewModernUIPane.Builder withComponent(AssembleComponent component, Map map) { - Network network = pane.browser.engine().network(); - network.set(InterceptRequestCallback.class, new NxComplexInterceptRequestCallback(network, component, map)); + pane.scheme = Scheme.of("emb"); + pane.requestCallback = new NxComplexInterceptRequestCallback(component, map); pane.browser.navigation().loadUrl("emb:dynamic"); return this; } @@ -235,8 +243,8 @@ public class NewModernUIPane extends ModernUIPane { */ @Override public NewModernUIPane.Builder withHTML(String html) { - Network network = pane.browser.engine().network(); - network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network)); + pane.scheme = Scheme.of("html"); + pane.requestCallback = new NxInterceptRequestCallback(); pane.browser.mainFrame().ifPresent(frame -> { frame.loadHtml(html); }); diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/NxComplexInterceptRequestCallback.java b/designer-base/src/main/java/com/fr/design/ui/compatible/NxComplexInterceptRequestCallback.java index f3147b6529..eb85495d40 100644 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/NxComplexInterceptRequestCallback.java +++ b/designer-base/src/main/java/com/fr/design/ui/compatible/NxComplexInterceptRequestCallback.java @@ -9,9 +9,6 @@ import com.fr.web.struct.AtomBuilder; import com.fr.web.struct.PathGroup; import com.fr.web.struct.category.ScriptPath; import com.fr.web.struct.category.StylePath; -import com.teamdev.jxbrowser.net.Network; -import com.teamdev.jxbrowser.net.UrlRequest; -import com.teamdev.jxbrowser.net.callback.InterceptRequestCallback; import java.io.InputStream; import java.nio.charset.StandardCharsets; @@ -26,21 +23,20 @@ public class NxComplexInterceptRequestCallback extends NxInterceptRequestCallbac private AssembleComponent component; - public NxComplexInterceptRequestCallback(Network network, AssembleComponent component) { - super(network); + public NxComplexInterceptRequestCallback(AssembleComponent component) { this.component = component; } - public NxComplexInterceptRequestCallback(Network network, AssembleComponent component, Map map) { - super(network, map); + public NxComplexInterceptRequestCallback(AssembleComponent component, Map map) { + super(map); this.component = component; } @Override - protected Response next(UrlRequest urlRequest, String path) { + protected Response next(Params params, String path) { if (path.startsWith("emb:dynamic")) { String text = htmlText(map); - return InterceptRequestCallback.Response.intercept(generateBasicUrlRequestJob(urlRequest, "text/html", text.getBytes(StandardCharsets.UTF_8))); + return Response.intercept(generateBasicUrlRequestJob(params, "text/html", text.getBytes(StandardCharsets.UTF_8))); } else { int index = path.indexOf("="); if (index > 0) { @@ -52,7 +48,7 @@ public class NxComplexInterceptRequestCallback extends NxInterceptRequestCallbac if (inputStream == null) { return Response.proceed(); } - return InterceptRequestCallback.Response.intercept(generateBasicUrlRequestJob(urlRequest, getMimeType(path), IOUtils.inputStream2Bytes(inputStream))); + return Response.intercept(generateBasicUrlRequestJob(params, getMimeType(path), IOUtils.inputStream2Bytes(inputStream))); } } diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/NxInterceptRequestCallback.java b/designer-base/src/main/java/com/fr/design/ui/compatible/NxInterceptRequestCallback.java index e2ab7ad93c..32a8f8b610 100644 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/NxInterceptRequestCallback.java +++ b/designer-base/src/main/java/com/fr/design/ui/compatible/NxInterceptRequestCallback.java @@ -9,11 +9,10 @@ import com.fr.stable.StringUtils; import com.fr.third.org.apache.commons.codec.net.URLCodec; import com.teamdev.jxbrowser.net.HttpHeader; import com.teamdev.jxbrowser.net.HttpStatus; -import com.teamdev.jxbrowser.net.Network; import com.teamdev.jxbrowser.net.UrlRequest; import com.teamdev.jxbrowser.net.UrlRequestJob; -import com.teamdev.jxbrowser.net.callback.InterceptRequestCallback; +import com.teamdev.jxbrowser.net.callback.InterceptUrlRequestCallback; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -29,17 +28,14 @@ import java.util.Optional; * @version 10.0 * Created by richie on 2020/3/25 */ -public class NxInterceptRequestCallback implements InterceptRequestCallback { +public class NxInterceptRequestCallback implements InterceptUrlRequestCallback { - Network network; Map map; - public NxInterceptRequestCallback(Network network) { - this.network = network; + public NxInterceptRequestCallback() { } - public NxInterceptRequestCallback(Network network, Map map) { - this.network = network; + public NxInterceptRequestCallback(Map map) { this.map = map; } @@ -48,21 +44,21 @@ public class NxInterceptRequestCallback implements InterceptRequestCallback { UrlRequest urlRequest = params.urlRequest(); String path = urlRequest.url(); if (path.startsWith("file:")) { - Optional optional = generateFileProtocolUrlRequestJob(urlRequest, path); + Optional optional = generateFileProtocolUrlRequestJob(params, path); if (optional.isPresent()) { - return InterceptRequestCallback.Response.intercept(optional.get()); + return Response.intercept(optional.get()); } } else { - return next(urlRequest, path); + return next(params, path); } return Response.proceed(); } - Response next(UrlRequest urlRequest, String path) { + Response next(Params params, String path) { return Response.proceed(); } - private Optional generateFileProtocolUrlRequestJob(UrlRequest urlRequest, String path) { + private Optional generateFileProtocolUrlRequestJob(Params params, String path) { try { String url = new URLCodec().decode(path); String filePath = TemplateUtils.renderParameter4Tpl(url, map); @@ -77,7 +73,7 @@ public class NxInterceptRequestCallback implements InterceptRequestCallback { } else { bytes = IOUtils.inputStream2Bytes(inputStream); } - return Optional.of(generateBasicUrlRequestJob(urlRequest, mimeType, bytes)); + return Optional.of(generateBasicUrlRequestJob(params, mimeType, bytes)); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } @@ -88,12 +84,12 @@ public class NxInterceptRequestCallback implements InterceptRequestCallback { return ArrayUtils.contains(new String[]{"text/html", "text/javascript", "text/css"}, mimeType); } - UrlRequestJob generateBasicUrlRequestJob(UrlRequest urlRequest, String mimeType, byte[] bytes) { + UrlRequestJob generateBasicUrlRequestJob(Params params, String mimeType, byte[] bytes) { UrlRequestJob.Options options = UrlRequestJob.Options - .newBuilder(urlRequest.id(), HttpStatus.OK) + .newBuilder(HttpStatus.OK) .addHttpHeader(HttpHeader.of("Content-Type", mimeType)) .build(); - UrlRequestJob urlRequestJob = network.newUrlRequestJob(options); + UrlRequestJob urlRequestJob = params.newUrlRequestJob(options); urlRequestJob.write(bytes); urlRequestJob.complete(); return urlRequestJob; @@ -145,4 +141,8 @@ public class NxInterceptRequestCallback implements InterceptRequestCallback { return "text/html"; } } + + public void setMap(Map map) { + this.map = map; + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java b/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java index fb40d54345..fee07ac467 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java @@ -14,6 +14,9 @@ import com.fr.design.extra.exe.GetPluginPrefixExecutor; import com.fr.design.extra.exe.PluginLoginExecutor; import com.fr.design.extra.exe.ReadUpdateOnlineExecutor; import com.fr.design.extra.exe.SearchOnlineExecutor; +import com.fr.design.gui.ifilechooser.FileChooserProvider; +import com.fr.design.gui.ifilechooser.FileSelectionMode; +import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser; import com.fr.design.i18n.Toolkit; import com.fr.design.locale.impl.BbsRegisterMark; import com.fr.design.locale.impl.BbsResetMark; @@ -36,6 +39,7 @@ import com.teamdev.jxbrowser.chromium.Browser; import com.teamdev.jxbrowser.chromium.JSArray; import com.teamdev.jxbrowser.chromium.JSFunction; import com.teamdev.jxbrowser.chromium.JSObject; +import javafx.stage.FileChooser; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; @@ -95,7 +99,7 @@ public class UpmBridge { @JSBridge public void startDownload(final JSFunction callback) { callback.invoke(window, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start")); - new SwingWorker(){ + new SwingWorker() { @Override protected Void doInBackground() throws Exception { UpmResourceLoader.INSTANCE.download(); @@ -308,16 +312,13 @@ public class UpmBridge { RunnableFuture future = new FutureTask<>(new Callable() { @Override public String call() { - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - - if (StringUtils.isNotEmpty(filter)) { - fileChooser.setFileFilter(new FileNameExtensionFilter(des, UpmUtils.findMatchedExtension(filter))); - } - - int result = fileChooser.showOpenDialog(UpmFinder.getDialog()); + FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder(). + fileSelectionMode(FileSelectionMode.FILE). + filter(des, filter). + build(); + int result = fileChooserProvider.showDialog(UpmFinder.getDialog()); if (result == JFileChooser.APPROVE_OPTION) { - return fileChooser.getSelectedFile().getAbsolutePath(); + return fileChooserProvider.getSelectedFile().getAbsolutePath(); } return null; } @@ -345,11 +346,11 @@ public class UpmBridge { public String call() { JFileChooser fileChooser = new JFileChooser(); List filterList = new ArrayList<>(); - if (args instanceof String) { + if (args instanceof String) { filterList.add(GeneralUtils.objectToString(args)); } else if (args instanceof JSArray) { - JSArray array = (JSArray)args; - for (int i = 0, len = array.length(); i < len; i ++) { + JSArray array = (JSArray) args; + for (int i = 0, len = array.length(); i < len; i++) { filterList.add(array.get(i).getStringValue()); } } diff --git a/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java b/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java index 24431cd957..e5624c4531 100644 --- a/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java +++ b/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java @@ -7,6 +7,7 @@ import com.fr.design.dialog.NotificationDialogAction; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.RemoteWorkspace; +import com.fr.design.i18n.DesignSizeI18nManager; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.env.CheckServiceDialog; @@ -107,7 +108,7 @@ public class VersionCheckUtils { CheckServiceDialog checkServiceDialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), GeneralUtils.readFullBuildNO(), getRemoteBranch(envName), getNoExistServiceDescription(envName)); checkServiceDialog.setVisible(true); } - }); + },DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.version.check.dialog")); notificationDialog.setVisible(true); } diff --git a/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java b/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java index ef66fc039a..9e03dcc9dc 100644 --- a/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java +++ b/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java @@ -10,6 +10,8 @@ import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ifilechooser.FileChooserProvider; +import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.itextarea.DescriptionTextArea; @@ -28,6 +30,7 @@ import com.fr.stable.ListMap; import com.fr.stable.StringUtils; import com.fr.transaction.Configurations; import com.fr.transaction.WorkerFacade; +import javafx.stage.FileChooser; import javax.swing.*; import javax.swing.event.ChangeEvent; @@ -108,7 +111,7 @@ public class CustomIconPane extends BasicPane { } - protected String createDescriptionText(){ + protected String createDescriptionText() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message1"); } @@ -447,13 +450,12 @@ public class CustomIconPane extends BasicPane { } private void onBrowseButtonClicked() { - JFileChooser jf = new JFileChooser(); // carl:不知道是否只要png格式,反正导出时全部都转成png了 - FileNameExtensionFilter fileFilter = new FileNameExtensionFilter("Icon Image File", "jpg", "jpeg", "png", "gif"); - jf.setFileFilter(fileFilter); - - if (JFileChooser.APPROVE_OPTION == jf.showOpenDialog(DesignerContext.getDesignerFrame())) { - String path = jf.getSelectedFile().getAbsolutePath(); + FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder(). + filter("Icon Image File", "*.jpg", "*.jpeg", "*.png", "*.gif"). + build(); + if (JFileChooser.APPROVE_OPTION == fileChooserProvider.showDialog(DesignerContext.getDesignerFrame())) { + String path = fileChooserProvider.getSelectedFile().getAbsolutePath(); // 图片存储有最大值48*48限制,没有超过最大值时,按原图大小存储,超过最大值后,压缩至最大值存储 Image image = BaseUtils.readImage(path); iconImage = ImageUtils.scale((BufferedImage) image, Math.min(image.getWidth(null), IconManager.MAXSTORAGE_ICONWIDTH), Math.min(image.getHeight(null), IconManager.MAXSTORAGE_ICONHEIGHT), true, Image.SCALE_SMOOTH); 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 a921a03229..032f16a769 100644 --- a/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java +++ b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java @@ -5,6 +5,7 @@ import com.fr.design.RestartHelper; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.DesignSizeI18nManager; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; @@ -113,10 +114,10 @@ public class CheckServiceDialog extends JDialog implements ActionListener { font = font.applySize(15).applyStyle(1); UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Sync_Branch_Inconsistency")); label.setFont(font); - label.setPreferredSize(new Dimension(650, 30)); + label.setPreferredSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.version.detail.label")); UILabel label2 = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Sync_Inconsistency_Risk")); - label2.setPreferredSize(new Dimension(600, 30)); + label2.setPreferredSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.version.detail.label")); verticalPanel.add(label); verticalPanel.add(label2); @@ -201,7 +202,7 @@ public class CheckServiceDialog extends JDialog implements ActionListener { this.add(topPanel, BorderLayout.NORTH); this.add(centerPanel, BorderLayout.CENTER); this.add(buttonPanel, BorderLayout.SOUTH); - this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US) ? 750 : 600, 500)); + this.setSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.version.detail.dialog")); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { diff --git a/designer-base/src/main/java/com/fr/env/HelpLink.java b/designer-base/src/main/java/com/fr/env/HelpLink.java new file mode 100644 index 0000000000..c717ce6ea6 --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/HelpLink.java @@ -0,0 +1,30 @@ +package com.fr.env; + +import com.fr.general.locale.LocaleCenter; +import com.fr.general.locale.LocaleMark; +import com.fr.locale.InterProviderFactory; +import com.fr.stable.StringUtils; +import java.util.HashMap; +import java.util.Map; + +/** + * 错误提示中的跳转链接管理 + * + * @author hades + * @version 10.0 + * Created by hades on 2021/8/9 + */ +public class HelpLink { + + public static String getLink(String solution) { + Map map = new HashMap<>(); + LocaleMark linkMark = LocaleCenter.getMark(RemoteDesignLocaleMark.class); + String link = linkMark.getValue(); + map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Change_PassWord"), StringUtils.EMPTY); + map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Cert_Error_Solution"), link); + map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Connection_Unknown_Error_Solution"), link); + map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_NetWork_Connection_Error_Solution"), link); + return map.get(solution); + } + +} diff --git a/designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java b/designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java new file mode 100644 index 0000000000..877a9224b2 --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java @@ -0,0 +1,36 @@ +package com.fr.env; + +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 hades + * @version 10.0 + * Created by hades on 2021/8/9 + */ +public class RemoteDesignLocaleMark implements LocaleMark { + + private Map map = new HashMap<>(); + private static final String REMOTE_DESIGN_CN = CloudCenter.getInstance().acquireUrlByKind("help.remote.design.zh_CN", "https://help.fanruan.com/finereport/doc-view-3925.html"); + private static final String REMOTE_DESIGN_EN = CloudCenter.getInstance().acquireUrlByKind("help.remote.design.en_US", "https://help.fanruan.com/finereport-en/doc-view-3862.html"); + + + public RemoteDesignLocaleMark() { + map.put(Locale.CHINA, REMOTE_DESIGN_CN); + map.put(Locale.KOREA, REMOTE_DESIGN_EN); + map.put(Locale.JAPAN, REMOTE_DESIGN_EN); + map.put(Locale.US, REMOTE_DESIGN_EN); + map.put(Locale.TAIWAN, REMOTE_DESIGN_CN); + } + + @Override + public String getValue() { + String result = map.get(GeneralContext.getLocale()); + return result == null ? REMOTE_DESIGN_CN : result; + } + +} 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 3635937783..56f90e804e 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -4,13 +4,14 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.beans.BasicBeanPane; import com.fr.design.border.UITitledBorder; -import com.fr.design.dialog.FineJOptionPane; -import com.fr.design.dialog.link.MessageWithLink; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.fun.DesignerEnvProcessor; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ifilechooser.FileChooserProvider; +import com.fr.design.gui.ifilechooser.FileSelectionMode; +import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ipasswordfield.UIPassWordField; import com.fr.design.gui.ipasswordfield.UIPasswordFieldWithFixedLength; @@ -19,17 +20,13 @@ import com.fr.design.i18n.DesignSizeI18nManager; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.DesignerContext; import com.fr.design.scrollruler.ModLineBorder; -import com.fr.license.exception.RegistEditionException; -import com.fr.log.FineLoggerFactory; +import com.fr.env.handler.WorkspaceExceptionHandler; import com.fr.stable.StringUtils; import com.fr.third.guava.base.Strings; import com.fr.workspace.WorkContext; import com.fr.workspace.connect.WorkspaceConnectionInfo; -import com.fr.workspace.engine.exception.WorkspaceAuthException; -import com.fr.workspace.engine.exception.WorkspaceCheckException; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JDialog; @@ -62,9 +59,7 @@ import java.io.File; import static com.fr.design.layout.TableLayout.FILL; import static com.fr.design.layout.TableLayout.PREFERRED; -import static com.fr.env.TestConnectionResult.AUTH_FAILED; import static com.fr.third.guava.base.Optional.fromNullable; -import static javax.swing.JOptionPane.ERROR_MESSAGE; /** * @author yaohwu @@ -569,11 +564,10 @@ public class RemoteEnvPane extends BasicBeanPane { fileChooserButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - int saveValue = fileChooser.showOpenDialog(SwingUtilities.getWindowAncestor(RemoteEnvPane.this)); + FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder().fileSelectionMode(FileSelectionMode.FILE).build(); + int saveValue = fileChooserProvider.showDialog(SwingUtilities.getWindowAncestor(RemoteEnvPane.this)); if (saveValue == JFileChooser.APPROVE_OPTION) { - File selectedFile = fileChooser.getSelectedFile(); + File selectedFile = fileChooserProvider.getSelectedFile(); certPathInput.setText(selectedFile.getAbsolutePath()); } } @@ -585,42 +579,24 @@ public class RemoteEnvPane extends BasicBeanPane { final RemoteDesignerWorkspaceInfo remoteEnv = updateBean(); final WorkspaceConnectionInfo connection = remoteEnv.getConnection(); - final SwingWorker worker = new SwingWorker() { + final SwingWorker worker = new SwingWorker() { @Override - protected TestConnectionResult doInBackground() throws Exception { - try { - return TestConnectionResult.parse(WorkContext.getConnector().testConnection(connection), connection); - } catch (WorkspaceAuthException ignored) { - return AUTH_FAILED; - } catch (RegistEditionException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - throw e; - } catch (WorkspaceCheckException e) { - return TestConnectionResult.parseByException(e); - } + protected Boolean doInBackground() throws Exception { + return WorkContext.getConnector().testConnection(connection); } @Override protected void done() { okButton.setEnabled(true); try { - TestConnectionResult result = get(); - if (result.isVerifyResult()) { - dialog.dispose(); - FineLoggerFactory.getLogger().error(result.getText().replaceAll(TestConnectionResult.WRAP, StringUtils.EMPTY) + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord")); - FineJOptionPane.showMessageDialog(RemoteEnvPane.this, - new MessageWithLink(result.getText(), Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"), connection.getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH), - Toolkit.i18nText("Fine-Design_Basic_Dialog_Message_Title"), - ERROR_MESSAGE, - UIManager.getIcon("OptionPane.errorIcon")); + if (get()) { + message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Successful")); + uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon")); } - message.setText(result.getText()); - uiLabel.setIcon(result.getIcon()); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e, e.getMessage()); - message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed")); - uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon")); + dialog.dispose(); + WorkspaceExceptionHandler.getInstance().handleInTest(e, remoteEnv); } dialogDownPane.remove(cancelButton); dialogDownPane.revalidate(); diff --git a/designer-base/src/main/java/com/fr/env/handler/Handler.java b/designer-base/src/main/java/com/fr/env/handler/Handler.java new file mode 100644 index 0000000000..ba2769d2da --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/handler/Handler.java @@ -0,0 +1,16 @@ +package com.fr.env.handler; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/8/5 + */ +public interface Handler { + + /** + * @param t + * @return 是否需要继续处理 + */ + R handle(T t); + +} diff --git a/designer-base/src/main/java/com/fr/env/handler/RefWrapper.java b/designer-base/src/main/java/com/fr/env/handler/RefWrapper.java new file mode 100644 index 0000000000..a2db84d239 --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/handler/RefWrapper.java @@ -0,0 +1,28 @@ +package com.fr.env.handler; + +/** + * + * @author hades + * @version 10.0 + * Created by hades on 2021/8/11 + */ +public class RefWrapper { + + private final Throwable throwable; + + private final String link; + + + public RefWrapper(Throwable throwable, String link) { + this.throwable = throwable; + this.link = link; + } + + public Throwable getThrowable() { + return throwable; + } + + public String getLink() { + return link; + } +} diff --git a/designer-base/src/main/java/com/fr/env/handler/ResultWrapper.java b/designer-base/src/main/java/com/fr/env/handler/ResultWrapper.java new file mode 100644 index 0000000000..2e9d705d39 --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/handler/ResultWrapper.java @@ -0,0 +1,30 @@ +package com.fr.env.handler; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/8/5 + */ +public class ResultWrapper { + + private final boolean next; + + private final Throwable throwable; + + public ResultWrapper(Throwable throwable) { + this(true, throwable); + } + + public ResultWrapper(boolean next, Throwable e) { + this.next = next; + this.throwable = e; + } + + public boolean isNext() { + return next; + } + + public Throwable getThrowable() { + return throwable; + } +} diff --git a/designer-base/src/main/java/com/fr/env/handler/WorkspaceExceptionHandler.java b/designer-base/src/main/java/com/fr/env/handler/WorkspaceExceptionHandler.java new file mode 100644 index 0000000000..367cd6bbb6 --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/handler/WorkspaceExceptionHandler.java @@ -0,0 +1,97 @@ +package com.fr.env.handler; + +import com.fr.base.exception.ExceptionDescriptor; +import com.fr.design.EnvChangeEntrance; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceType; +import com.fr.design.i18n.Toolkit; +import com.fr.env.RemoteWorkspaceURL; +import com.fr.env.handler.impl.CancelHandler; +import com.fr.env.handler.impl.CommonHandler; +import com.fr.env.handler.impl.ExecutionHandler; +import com.fr.env.handler.impl.UnexpectedHandler; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; +import java.util.ArrayList; +import java.util.List; +import javax.swing.UIManager; + + +import static javax.swing.JOptionPane.ERROR_MESSAGE; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/8/5 + */ +public class WorkspaceExceptionHandler { + + private static final WorkspaceExceptionHandler INSTANCE = new WorkspaceExceptionHandler(); + + public static WorkspaceExceptionHandler getInstance() { + return INSTANCE; + } + + private final List> testList = new ArrayList<>(); + + private final List> switchList = new ArrayList<>(); + + private WorkspaceExceptionHandler() { + // 要保证顺序 + testList.add(new CancelHandler()); + testList.add(new ExecutionHandler()); + testList.add(new UnexpectedHandler()); + testList.add(new CommonHandler(false)); + + switchList.add(new CancelHandler()); + switchList.add(new ExecutionHandler()); + switchList.add(new UnexpectedHandler()); + switchList.add(new CommonHandler(true)); + } + + public void handle(Throwable e, List> list, DesignerWorkspaceInfo workspaceInfo) { + Throwable throwable = e; + ResultWrapper wrapper; + String link = workspaceInfo.getConnection().getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH; + for (Handler handler : list) { + wrapper = handler.handle(new RefWrapper(throwable, link)); + throwable = wrapper.getThrowable(); + if (!wrapper.isNext()) { + break; + } + } + FineLoggerFactory.getLogger().error(throwable.getMessage(), throwable); + } + + public void handleInSwitch(Throwable e, DesignerWorkspaceInfo workspaceInfo) { + if (workspaceInfo == null || workspaceInfo.getType() == DesignerWorkspaceType.Local) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + if (e instanceof ExceptionDescriptor) { + new CommonHandler(true).handle(new RefWrapper(e, StringUtils.EMPTY)); + } else { + FineJOptionPane.showMessageDialog(EnvChangeEntrance.getInstance().getDialog(), + Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + ERROR_MESSAGE, + UIManager.getIcon("OptionPane.errorIcon")); + } + return; + } + handle(e, switchList, workspaceInfo); + } + + public void handleInStart(Throwable e, DesignerWorkspaceInfo workspaceInfo) { + if (workspaceInfo == null || workspaceInfo.getType() == DesignerWorkspaceType.Local) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + new CommonHandler(false).handle(new RefWrapper(e, StringUtils.EMPTY)); + return; + } + handle(e, testList, workspaceInfo); + } + + public void handleInTest(Throwable e, DesignerWorkspaceInfo workspaceInfo) { + handle(e, testList, workspaceInfo); + } + +} diff --git a/designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java b/designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java new file mode 100644 index 0000000000..140d0ec136 --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java @@ -0,0 +1,22 @@ +package com.fr.env.handler.impl; + +import com.fr.env.handler.Handler; +import com.fr.env.handler.RefWrapper; +import com.fr.env.handler.ResultWrapper; +import java.util.concurrent.CancellationException; + +/** + * 取消测试连接时的处理器 + * + * @author hades + * @version 10.0 + * Created by hades on 2021/8/5 + */ +public class CancelHandler implements Handler { + + @Override + public ResultWrapper handle(RefWrapper wrapper) { + Throwable e = wrapper.getThrowable(); + return new ResultWrapper(!(e instanceof CancellationException), e); + } +} diff --git a/designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java b/designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java new file mode 100644 index 0000000000..2fc8f9e156 --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java @@ -0,0 +1,52 @@ +package com.fr.env.handler.impl; + +import com.fr.base.exception.ExceptionDescriptor; +import com.fr.design.EnvChangeEntrance; +import com.fr.design.dialog.UIDetailErrorLinkDialog; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; +import com.fr.env.HelpLink; +import com.fr.env.handler.Handler; +import com.fr.env.handler.RefWrapper; +import com.fr.env.handler.ResultWrapper; +import com.fr.stable.StringUtils; +import javax.swing.SwingUtilities; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/8/5 + */ +public class CommonHandler implements Handler { + + private final boolean onSwitch; + + public CommonHandler(boolean onSwitch) { + this.onSwitch = onSwitch; + } + + @Override + public ResultWrapper handle(RefWrapper wrapper) { + Throwable e = wrapper.getThrowable(); + if (e instanceof ExceptionDescriptor) { + ExceptionDescriptor exceptionDescriptor = (ExceptionDescriptor) e; + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + String link = HelpLink.getLink(exceptionDescriptor.solution()); + UIDetailErrorLinkDialog detailErrorLinkDialog = UIDetailErrorLinkDialog.newBuilder(). + setWindow(onSwitch ? DesignerContext.getDesignerFrame() : EnvChangeEntrance.getInstance().getDialog()). + setErrorCode(exceptionDescriptor.errorCode()). + setReason(exceptionDescriptor.reason()). + setSolution(exceptionDescriptor.solution()). + setDetailReason(exceptionDescriptor.detailReason()). + setTitle(Toolkit.i18nText("Fine-Design_Basic_Connection_Failed")). + setLink(StringUtils.isEmpty(link) ? wrapper.getLink() : link). + setThrowable(e).build(); + detailErrorLinkDialog.setVisible(true); + } + }); + } + return new ResultWrapper(e); + } +} diff --git a/designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java b/designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java new file mode 100644 index 0000000000..5388935ea1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java @@ -0,0 +1,23 @@ +package com.fr.env.handler.impl; + +import com.fr.env.handler.Handler; +import com.fr.env.handler.RefWrapper; +import com.fr.env.handler.ResultWrapper; +import java.util.concurrent.ExecutionException; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/8/5 + */ +public class ExecutionHandler implements Handler { + + @Override + public ResultWrapper handle(RefWrapper wrapper) { + Throwable e = wrapper.getThrowable(); + if (e instanceof ExecutionException) { + return new ResultWrapper(e.getCause()); + } + return new ResultWrapper(e); + } +} diff --git a/designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java b/designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java new file mode 100644 index 0000000000..28a2b645df --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java @@ -0,0 +1,26 @@ +package com.fr.env.handler.impl; + +import com.fr.base.exception.ExceptionDescriptor; +import com.fr.env.handler.Handler; +import com.fr.env.handler.RefWrapper; +import com.fr.env.handler.ResultWrapper; +import com.fr.workspace.engine.convert.ExceptionConverter; + +/** + * 出现预料之外的情况异常处理器 + * + * @author hades + * @version 10.0 + * Created by hades on 2021/8/5 + */ +public class UnexpectedHandler implements Handler { + + @Override + public ResultWrapper handle(RefWrapper wrapper) { + Throwable e = wrapper.getThrowable(); + if (!(e instanceof ExceptionDescriptor)) { + return new ResultWrapper(ExceptionConverter.getInstance().convert(e)) ; + } + return new ResultWrapper(e); + } +} diff --git a/designer-base/src/main/java/com/fr/start/BaseDesigner.java b/designer-base/src/main/java/com/fr/start/BaseDesigner.java index b3945d0d7f..1c4c611264 100644 --- a/designer-base/src/main/java/com/fr/start/BaseDesigner.java +++ b/designer-base/src/main/java/com/fr/start/BaseDesigner.java @@ -11,6 +11,7 @@ import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerStartOpenFileProcessor; +import com.fr.design.fun.impl.DesignerStartWithEmptyFile; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; @@ -147,6 +148,10 @@ public abstract class BaseDesigner extends ToolBarMenuDock { //启动时打开指定文件的接口 DesignerStartOpenFileProcessor processor = ExtraDesignClassManager.getInstance().getSingle(DesignerStartOpenFileProcessor.XML_TAG); + // 如果插件没有,且又开启了启动时打开空文件,则使用启动时打开空文件 + if (processor == null && DesignerEnvManager.getEnvManager().isStartWithEmptyFile()) { + processor = DesignerStartWithEmptyFile.getInstance(); + } if (processor != null) { FILE f = processor.fileToShow(); if (f != null) { diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties index 6a227a996a..dd33c6a6a4 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties @@ -3,4 +3,7 @@ com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=630*185 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=630*31 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=630*280 com.fr.design.report.ReportColumnsPane=800*600 -com.fr.env.RemoteEnvPane.dialog=458*132 \ No newline at end of file +com.fr.env.RemoteEnvPane.dialog=458*132 +com.fr.design.version.check.dialog=490*95 +com.fr.design.version.detail.label=750*30 +com.fr.design.version.detail.dialog=900*500 \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties index db3632a293..b67a913e7a 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties @@ -2,4 +2,7 @@ com.fr.design.mainframe.check.CheckButton=280*118 com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=610*185 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=610*31 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=610*280 -com.fr.env.RemoteEnvPane.dialog=458*132 \ No newline at end of file +com.fr.env.RemoteEnvPane.dialog=458*132 +com.fr.design.version.check.dialog=430*95 +com.fr.design.version.detail.label=650*30 +com.fr.design.version.detail.dialog=800*500 \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties index b9d7ef15ab..862580eedc 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties @@ -2,4 +2,7 @@ com.fr.design.mainframe.check.CheckButton=230*118 com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=490*185 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=490*35 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=490*280 -com.fr.env.RemoteEnvPane.dialog=458*132 \ No newline at end of file +com.fr.env.RemoteEnvPane.dialog=458*132 +com.fr.design.version.check.dialog=450*95 +com.fr.design.version.detail.label=700*30 +com.fr.design.version.detail.dialog=850*500 \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties index 818a9d5d62..5a325b16bb 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties @@ -3,4 +3,7 @@ com.fr.design.mainframe.check.CheckButton=250*118 com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=385*185 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=385*31 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=385*280 -com.fr.env.RemoteEnvPane.dialog=308*132 \ No newline at end of file +com.fr.env.RemoteEnvPane.dialog=308*132 +com.fr.design.version.check.dialog=230*95 +com.fr.design.version.detail.label=450*30 +com.fr.design.version.detail.dialog=600*500 \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties index 87d117140e..1be37f9c7a 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties @@ -2,4 +2,7 @@ com.fr.design.mainframe.check.CheckButton=250*118 com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=385*185 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=385*31 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=385*280 -com.fr.env.RemoteEnvPane.dialog=308*132 \ No newline at end of file +com.fr.env.RemoteEnvPane.dialog=308*132 +com.fr.design.version.check.dialog=230*95 +com.fr.design.version.detail.label=450*30 +com.fr.design.version.detail.dialog=600*500 \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_auto_spacing_tip.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_auto_spacing_tip.png new file mode 100644 index 0000000000..74e79ee242 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_auto_spacing_tip.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_bottom_align.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_bottom_align.png new file mode 100755 index 0000000000..238e4735db Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_bottom_align.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_auto_spacing.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_auto_spacing.png new file mode 100755 index 0000000000..a1b89ab78b Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_auto_spacing.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_center_align.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_center_align.png new file mode 100755 index 0000000000..2f811f7bf8 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_center_align.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_spacing.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_spacing.png new file mode 100755 index 0000000000..d01dab47ec Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_spacing.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_left_align.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_left_align.png new file mode 100755 index 0000000000..2fe36d65e4 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_left_align.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_right_align.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_right_align.png new file mode 100755 index 0000000000..d402fb2bda Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_right_align.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_top_align.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_top_align.png new file mode 100755 index 0000000000..6865975a61 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_top_align.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_auto_spacing.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_auto_spacing.png new file mode 100755 index 0000000000..20988ce034 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_auto_spacing.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_center_align.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_center_align.png new file mode 100755 index 0000000000..432b2854e5 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_center_align.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_spacing.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_spacing.png new file mode 100755 index 0000000000..8b8019beba Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_spacing.png differ diff --git a/designer-base/src/main/resources/com/fr/env/jarVersion.properties b/designer-base/src/main/resources/com/fr/env/jarVersion.properties new file mode 100644 index 0000000000..7eff54deba --- /dev/null +++ b/designer-base/src/main/resources/com/fr/env/jarVersion.properties @@ -0,0 +1 @@ +report-engine-key=fine-report-engine-11.0.jar \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java b/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java index d6e89cd93f..e5fa7e3095 100644 --- a/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java +++ b/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java @@ -4,7 +4,10 @@ import com.fr.invoke.Reflect; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLReaderHelper; import com.fr.stable.xml.XMLableReader; +import com.fr.workspace.WorkContext; +import com.fr.workspace.connect.WorkspaceClient; import com.fr.workspace.connect.WorkspaceConnectionInfo; +import com.fr.workspace.connect.WorkspaceConnector; import junit.framework.TestCase; import org.junit.Assert; @@ -18,15 +21,31 @@ import java.io.ByteArrayOutputStream; */ public class RemoteDesignerWorkspaceInfoTest extends TestCase { - public void testCheckValid() { + public void testCheckValid() throws Exception { RemoteDesignerWorkspaceInfo workspaceInfo0 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("http://localhost:8075/webroot/decision", "admin", "123", "", "", true)); RemoteDesignerWorkspaceInfo workspaceInfo1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("http://127.0.0.1:8075/webroot/decision", "admin", "123", "", "", true)); RemoteDesignerWorkspaceInfo workspaceInfo2 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("https://127.0.0.1:8075/webroot/decision", "admin", "123", "", "", true)); RemoteDesignerWorkspaceInfo workspaceInfo3 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("https://localhost:8075/webroot/decision", "admin", "123", "", "", true)); + WorkspaceConnector connector = WorkContext.getConnector(); + + WorkspaceConnector workspaceConnector = new WorkspaceConnector() { + @Override + public boolean testConnection(WorkspaceConnectionInfo connection) throws Exception { + return false; + } + + @Override + public WorkspaceClient connect(WorkspaceConnectionInfo connection) throws Exception { + return null; + } + }; + WorkContext.setConnector(workspaceConnector); + Assert.assertFalse(workspaceInfo0.checkValid()); Assert.assertFalse(workspaceInfo1.checkValid()); Assert.assertFalse(workspaceInfo2.checkValid()); Assert.assertFalse(workspaceInfo3.checkValid()); + WorkContext.setConnector(connector); } public void testReadXml() { diff --git a/designer-base/src/test/java/com/fr/design/mainframe/JTemplateNameHelperTest.java b/designer-base/src/test/java/com/fr/design/mainframe/JTemplateNameHelperTest.java new file mode 100644 index 0000000000..032e715f60 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/mainframe/JTemplateNameHelperTest.java @@ -0,0 +1,23 @@ +package com.fr.design.mainframe; + +import junit.framework.TestCase; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/5/8 + */ +public class JTemplateNameHelperTest extends TestCase { + + public void testNewTemplateNameByIndex() { + + String name = JTemplateNameHelper.newTemplateNameByIndex("TEST"); + + assertEquals("TEST1", name); + + String name1 = JTemplateNameHelper.newTemplateNameByIndex("TEST"); + + assertEquals("TEST2", name1); + + } +} 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 a9dcca2a2c..8600a8c149 100644 --- a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java @@ -8,7 +8,6 @@ import com.fr.chart.fun.ChartTypeProvider; import com.fr.chartx.attr.ChartProvider; import com.fr.common.annotations.Compatible; import com.fr.design.beans.BasicBeanPane; -import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.chart.fun.ChartTypeUIProvider; import com.fr.design.chart.gui.ChartWidgetOption; import com.fr.design.condition.ConditionAttributesPane; @@ -46,7 +45,6 @@ import com.fr.general.GeneralContext; import com.fr.general.IOUtils; import com.fr.invoke.Reflect; 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; @@ -75,7 +73,6 @@ import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; import com.fr.plugin.solution.closeable.CloseableContainedMap; import com.fr.stable.ArrayUtils; -import com.fr.stable.AssistUtils; import com.fr.stable.StringUtils; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import com.fr.van.chart.area.AreaIndependentVanChartInterface; @@ -100,17 +97,7 @@ import com.fr.van.chart.treemap.TreeMapIndependentVanChartInterface; import com.fr.van.chart.wordcloud.designer.WordCloudIndependentVanChartInterface; import javax.swing.Icon; -import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.awt.event.ActionListener; - -import static com.fr.chart.charttypes.ChartTypeManager.DEFAULT_PRIORITY; -import static com.fr.chart.charttypes.ChartTypeManager.DEPRECATED_CHART_PRIORITY; -import static com.fr.chart.charttypes.ChartTypeManager.VAN_CHART_PRIORITY; /** * Created by eason on 14/12/29. @@ -120,10 +107,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr private static ChartTypeInterfaceManager classManager = new ChartTypeInterfaceManager(); - private static LinkedHashMap> chartTypeInterfaces = - new LinkedHashMap>(); - - private static Map idAndPriorityMap = new HashMap(); + private static CloseableContainedMap chartTypeUIs = new CloseableContainedMap<>(HashMap.class); public static final String TYPE_PANE_DEFAULT_TITLE = "DEFAULT_NAME"; @@ -186,127 +170,69 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr private static void readVanChart() { - addChartTypeInterface(VAN_CHART_PRIORITY, PiePlot4VanChart.VAN_CHART_PIE_PLOT, new PieIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID, new VanColumnChartTypeUI()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartColumnPlot.VAN_CHART_BAR_PLOT_ID, new BarIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartLinePlot.VAN_CHART_LINE_PLOT, new LineIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartAreaPlot.VAN_CHART_AREA_PLOT_ID, new AreaIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartGaugePlot.VAN_CHART_GAUGE_PLOT, new GaugeIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartRadarPlot.VAN_CHART_RADAR_PLOT, new RadarIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartScatterPlot.VAN_CHART_SCATTER_PLOT_ID, new ScatterIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartBubblePlot.VAN_CHART_BUBBLE_PLOT_ID, new BubbleIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartCustomPlot.VAN_CHART_CUSTOM_PLOT_ID, new CustomIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartMultiPiePlot.VAN_CHART_MULTILAYER_PLOT_ID, new MultiPieIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartMapPlot.VAN_CHART_MAP_ID, new VanMapChartTypeUI()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartDrillMapPlot.VAN_CHART_DRILL_MAP_ID, new VanDrillMapChartTypeUI()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartTreeMapPlot.VAN_CHART_TREE_MAP_PLOT_ID, new TreeMapIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartFunnelPlot.VAN_CHART_FUNNEL_PLOT_ID, new FunnelIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartHeatMapPlot.VAN_CHART_HEAT_MAP_ID, new VanHeatMapChartTypeUI()); - 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()); + addChartTypeInterface(PiePlot4VanChart.VAN_CHART_PIE_PLOT, new PieIndependentVanChartInterface()); + addChartTypeInterface(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID, new VanColumnChartTypeUI()); + addChartTypeInterface(VanChartColumnPlot.VAN_CHART_BAR_PLOT_ID, new BarIndependentVanChartInterface()); + addChartTypeInterface(VanChartLinePlot.VAN_CHART_LINE_PLOT, new LineIndependentVanChartInterface()); + addChartTypeInterface(VanChartAreaPlot.VAN_CHART_AREA_PLOT_ID, new AreaIndependentVanChartInterface()); + addChartTypeInterface(VanChartGaugePlot.VAN_CHART_GAUGE_PLOT, new GaugeIndependentVanChartInterface()); + addChartTypeInterface(VanChartRadarPlot.VAN_CHART_RADAR_PLOT, new RadarIndependentVanChartInterface()); + addChartTypeInterface(VanChartScatterPlot.VAN_CHART_SCATTER_PLOT_ID, new ScatterIndependentVanChartInterface()); + addChartTypeInterface(VanChartBubblePlot.VAN_CHART_BUBBLE_PLOT_ID, new BubbleIndependentVanChartInterface()); + addChartTypeInterface(VanChartCustomPlot.VAN_CHART_CUSTOM_PLOT_ID, new CustomIndependentVanChartInterface()); + addChartTypeInterface(VanChartMultiPiePlot.VAN_CHART_MULTILAYER_PLOT_ID, new MultiPieIndependentVanChartInterface()); + addChartTypeInterface(VanChartMapPlot.VAN_CHART_MAP_ID, new VanMapChartTypeUI()); + addChartTypeInterface(VanChartDrillMapPlot.VAN_CHART_DRILL_MAP_ID, new VanDrillMapChartTypeUI()); + addChartTypeInterface(VanChartTreeMapPlot.VAN_CHART_TREE_MAP_PLOT_ID, new TreeMapIndependentVanChartInterface()); + addChartTypeInterface(VanChartFunnelPlot.VAN_CHART_FUNNEL_PLOT_ID, new FunnelIndependentVanChartInterface()); + addChartTypeInterface(VanChartHeatMapPlot.VAN_CHART_HEAT_MAP_ID, new VanHeatMapChartTypeUI()); + addChartTypeInterface(VanChartWordCloudPlot.WORD_CLOUD_PLOT_ID, new WordCloudIndependentVanChartInterface()); + addChartTypeInterface(VanChartGanttPlot.VAN_CHART_GANTT_PLOT_ID, new GanttIndependentVanChartInterface()); + addChartTypeInterface(VanChartStructurePlot.STRUCTURE_PLOT_ID, new VanStructureChartTypeUI()); + addChartTypeInterface(VanChartBoxPlot.VAN_CHART_BOX_PLOT_ID, new BoxIndependentVanChartInterface()); } private static void readDefault() { - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.COLUMN_CHART, new ColumnChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.LINE_CHART, new LineChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.BAR_CHART, new BarChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.PIE_CHART, new PieChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.AREA_CHART, new AreaChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.SCATTER_CHART, new XYScatterChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.BUBBLE_CHART, new BubbleChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.RADAR_CHART, new RadarChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.STOCK_CHART, new StockChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.METER_CHART, new MeterChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.RANGE_CHART, new RangeChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.CUSTOM_CHART, new CustomChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.GANTT_CHART, new GanttChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.DONUT_CHART, new DonutChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.MAP_CHART, new MapChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.GIS_CHAER, new GisMapChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.FUNNEL_CHART, new FunnelChartTypeUI()); - } - - private static void addChartTypeInterface(String priority, String plotID, ChartTypeUIProvider provider) { - - if (chartTypeInterfaces != null) { - if (!chartTypeInterfaces.containsKey(priority)) { - //新建一个具体图表列表 - CloseableContainedMap chartUIList - = new CloseableContainedMap(LinkedHashMap.class); - chartUIList.put(plotID, provider); - chartTypeInterfaces.put(priority, chartUIList); - } else { - Map chartUIList = chartTypeInterfaces.get(priority); - if (!chartUIList.containsKey(plotID)) { - chartUIList.put(plotID, provider); - } - } - idAndPriorityMap.put(plotID, priority); + addChartTypeInterface(ChartConstants.COLUMN_CHART, new ColumnChartTypeUI()); + addChartTypeInterface(ChartConstants.LINE_CHART, new LineChartTypeUI()); + addChartTypeInterface(ChartConstants.BAR_CHART, new BarChartTypeUI()); + addChartTypeInterface(ChartConstants.PIE_CHART, new PieChartTypeUI()); + addChartTypeInterface(ChartConstants.AREA_CHART, new AreaChartTypeUI()); + addChartTypeInterface(ChartConstants.SCATTER_CHART, new XYScatterChartTypeUI()); + addChartTypeInterface(ChartConstants.BUBBLE_CHART, new BubbleChartTypeUI()); + addChartTypeInterface(ChartConstants.RADAR_CHART, new RadarChartTypeUI()); + addChartTypeInterface(ChartConstants.STOCK_CHART, new StockChartTypeUI()); + addChartTypeInterface(ChartConstants.METER_CHART, new MeterChartTypeUI()); + addChartTypeInterface(ChartConstants.RANGE_CHART, new RangeChartTypeUI()); + addChartTypeInterface(ChartConstants.CUSTOM_CHART, new CustomChartTypeUI()); + addChartTypeInterface(ChartConstants.GANTT_CHART, new GanttChartTypeUI()); + addChartTypeInterface(ChartConstants.DONUT_CHART, new DonutChartTypeUI()); + addChartTypeInterface(ChartConstants.MAP_CHART, new MapChartTypeUI()); + addChartTypeInterface(ChartConstants.GIS_CHAER, new GisMapChartTypeUI()); + addChartTypeInterface(ChartConstants.FUNNEL_CHART, new FunnelChartTypeUI()); + } + + private static void addChartTypeInterface(String id, ChartTypeUIProvider provider) { + + if (chartTypeUIs != null) { + chartTypeUIs.put(id, provider); } } - private ChartTypeUIProvider getChartTypeInterface(String plotID) { - if (idAndPriorityMap.containsKey(plotID)) { - String priority = idAndPriorityMap.get(plotID); - if (chartTypeInterfaces.containsKey(priority)) { - return chartTypeInterfaces.get(priority).get(plotID); - } + private ChartTypeUIProvider getChartTypeInterface(String id) { + if (chartTypeUIs.containsKey(id)) { + return chartTypeUIs.get(id); } return null; } - /** - * 把所有的pane加到list里 - * - * @param paneList pane容器 - */ - public void addPlotTypePaneList(List> paneList, - Map>> allChartTypePane, - ActionListener autoButtonListener) { - - List priorityList = getPriorityInOrder(); - for (Integer aPriorityList : priorityList) { - String priority = String.valueOf(aPriorityList); - addPlotTypePaneList(priority, paneList, allChartTypePane, autoButtonListener); - } - } - - - public void addPlotTypePaneList(String priority, List> paneList, - Map>> allChartTypePane, - ActionListener autoButtonListener) { - - if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority)) { - - Map chartUIList = chartTypeInterfaces.get(priority); - - Iterator> iterator = chartUIList.entrySet().iterator(); - while (iterator.hasNext()) { - try { - Map.Entry entry = iterator.next(); - String plotID = entry.getKey(); - - AbstractChartTypePane pane = entry.getValue().getPlotTypePane(); - if (AssistUtils.equals(pane.title4PopupWindow(), TYPE_PANE_DEFAULT_TITLE)) { - continue; - } - pane.reLayout(plotID); - pane.registerButtonListener(autoButtonListener); - paneList.add(pane); - - if (allChartTypePane.get(priority) == null) { - allChartTypePane.put(priority, new LinkedHashMap>()); - } - allChartTypePane.get(priority).put(plotID, pane); - } catch (Throwable e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } + public AbstractChartTypePane getPlotTypePane(String id) { + if (chartTypeUIs.containsKey(id)) { + return chartTypeUIs.get(id).getPlotTypePane(); } + return null; } @Compatible @@ -314,23 +240,9 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr return getName(plotID); } - private List getPriorityInOrder() { - - List priorityList = new ArrayList(); - if (chartTypeInterfaces != null) { - Iterator iterator = chartTypeInterfaces.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry entry = (Map.Entry) iterator.next(); - String priority = (String) entry.getKey(); - priorityList.add(Integer.valueOf(priority)); - } - } - return ChartTypeManager.orderInPriority(priorityList); - } - public String getIconPath(String plotID) { - if (chartTypeInterfaces != null) { + if (chartTypeUIs != null) { ChartTypeUIProvider provider = getChartTypeInterface(plotID); if (provider != null) { return provider.getIconPath(); @@ -341,7 +253,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr public String[] getDemoImagePath(String chartID) { - if (chartTypeInterfaces != null) { + if (chartTypeUIs != null) { ChartTypeUIProvider provider = getChartTypeInterface(chartID); if (provider != null) { String[] result = null; @@ -397,7 +309,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr } public String[] getSubName(String chartID) { - if (chartTypeInterfaces != null) { + if (chartTypeUIs != null) { ChartTypeUIProvider provider = getChartTypeInterface(chartID); if (provider != null) { String[] subNames = null; @@ -430,7 +342,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr } public String getName(String chartID) { - if (chartTypeInterfaces != null) { + if (chartTypeUIs != null) { ChartTypeUIProvider provider = getChartTypeInterface(chartID); if (provider != null) { String name = null; @@ -575,9 +487,8 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr if (StringUtils.isEmpty(id)) { id = injection.getAttribute("plotID"); } - String priority = injection.getAttribute("priority", DEFAULT_PRIORITY); ChartTypeUIProvider instance = (ChartTypeUIProvider) injection.getObject(); - addChartTypeInterface(priority, id, instance); + addChartTypeInterface(id, instance); } } @@ -586,22 +497,18 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr public void demount(PluginSingleInjection injection) { if (isChartTypeUIProvider(injection)) { - String priority = injection.getAttribute("priority", DEFAULT_PRIORITY); String id = injection.getAttribute("chartID"); if (StringUtils.isEmpty(id)) { id = injection.getAttribute("plotID"); } - removeChartTypeInterface(priority, id); + removeChartTypeInterface(id); } } - private void removeChartTypeInterface(String priority, String plotID) { + private void removeChartTypeInterface(String id) { - if (chartTypeInterfaces != null) { - if (chartTypeInterfaces.containsKey(priority)) { - Map chartUIList = chartTypeInterfaces.get(priority); - chartUIList.remove(plotID); - } + if (chartTypeUIs != null) { + chartTypeUIs.remove(id); } } diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java b/designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java index 4cd00e5772..bce90aaaeb 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java @@ -3,6 +3,7 @@ package com.fr.design.chart; import com.fr.base.chart.BaseChartCollection; import com.fr.chart.chartattr.ChartCollection; import com.fr.design.dialog.BasicDialog; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.chart.MiddleChartDialog; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.i18n.Toolkit; @@ -110,6 +111,7 @@ public class ChartDialog extends MiddleChartDialog { if (cc == null) { return; } + cc.setThemeStyle(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplateTheme()); this.cc = cc; } diff --git a/designer-chart/src/main/java/com/fr/design/chart/fun/ChartTypeUIProvider.java b/designer-chart/src/main/java/com/fr/design/chart/fun/ChartTypeUIProvider.java index 1843a18864..10ee1bc8ae 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/fun/ChartTypeUIProvider.java +++ b/designer-chart/src/main/java/com/fr/design/chart/fun/ChartTypeUIProvider.java @@ -90,7 +90,9 @@ public interface ChartTypeUIProvider extends Level { //todo:把下面这些接口删除 @Deprecated - boolean needChartChangePane(); + default boolean needChartChangePane() { + return false; + } /** * 数据集数据源的界面 @@ -98,7 +100,9 @@ public interface ChartTypeUIProvider extends Level { * @return 数据集数据源的界面 */ @Deprecated - AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent); + default AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { + return null; + } /** @@ -107,7 +111,9 @@ public interface ChartTypeUIProvider extends Level { * @return 单元格数据源的界面 */ @Deprecated - AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent); + default AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { + return null; + } /** * 条件属性界面 @@ -115,7 +121,9 @@ public interface ChartTypeUIProvider extends Level { * @return 条件属性界面 */ @Deprecated - ConditionAttributesPane getPlotConditionPane(Plot plot); + default ConditionAttributesPane getPlotConditionPane(Plot plot) { + return null; + } /** * 系列界面 @@ -123,7 +131,9 @@ public interface ChartTypeUIProvider extends Level { * @return 系列界面 */ @Deprecated - BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot); + default BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot) { + return null; + } /** * 是否使用默认的界面,为了避免界面来回切换 @@ -131,12 +141,18 @@ public interface ChartTypeUIProvider extends Level { * @return 是否使用默认的界面 */ @Deprecated - boolean isUseDefaultPane(); + default boolean isUseDefaultPane() { + return false; + } @Deprecated - ChartEditPane getChartEditPane(String plotID); + default ChartEditPane getChartEditPane(String plotID) { + return new ChartEditPane(); + } @Deprecated - ChartsConfigPane getChartConfigPane(String plotID); + default ChartsConfigPane getChartConfigPane(String plotID) { + return null; + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/chart/fun/IndependentChartUIProvider.java b/designer-chart/src/main/java/com/fr/design/chart/fun/IndependentChartUIProvider.java index 88a14c0906..d9005788fd 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/fun/IndependentChartUIProvider.java +++ b/designer-chart/src/main/java/com/fr/design/chart/fun/IndependentChartUIProvider.java @@ -6,6 +6,7 @@ import com.fr.common.annotations.Compatible; * Created by shine on 2019/09/05. */ @Compatible +@Deprecated public interface IndependentChartUIProvider extends ChartTypeUIProvider { } diff --git a/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractChartTypeUI.java b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractChartTypeUI.java index c37ff939dc..4453559281 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractChartTypeUI.java +++ b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractChartTypeUI.java @@ -1,19 +1,11 @@ package com.fr.design.chart.fun.impl; -import com.fr.chart.chartattr.Plot; -import com.fr.design.beans.BasicBeanPane; import com.fr.design.chart.fun.ChartTypeUIProvider; import com.fr.design.chartx.impl.AbstractDataPane; -import com.fr.design.chartx.impl.AbstractOtherPane; -import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; -import com.fr.design.mainframe.chart.ChartEditPane; -import com.fr.design.mainframe.chart.ChartsConfigPane; -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.AbstractChartAttrPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.stable.fun.impl.AbstractProvider; import com.fr.stable.fun.mark.API; @@ -24,13 +16,15 @@ import com.fr.stable.fun.mark.API; public abstract class AbstractChartTypeUI extends AbstractProvider implements ChartTypeUIProvider { @Override - public abstract AbstractChartTypePane getPlotTypePane(); + public AbstractChartTypePane getPlotTypePane() { + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new DefaultChartTypePane(); + } @Override public abstract AbstractDataPane getChartDataPane(AttributeChangeListener listener); @Override - public abstract AbstractOtherPane[] getAttrPaneArray(AttributeChangeListener listener); + public abstract AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener); @Override public String[] getSubName() { @@ -46,45 +40,4 @@ public abstract class AbstractChartTypeUI extends AbstractProvider implements Ch public String mark4Provider() { return getClass().getName(); } - - @Override - public boolean needChartChangePane() { - return false; - } - - @Override - public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { - return null; - } - - @Override - public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { - return null; - } - - @Override - public boolean isUseDefaultPane() { - return false; - } - - @Override - public ChartEditPane getChartEditPane(String plotID) { - return new ChartEditPane(); - } - - @Override - public ConditionAttributesPane getPlotConditionPane(Plot plot) { - return null; - } - - @Override - public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot) { - return null; - } - - @Override - public ChartsConfigPane getChartConfigPane(String plotID) { - return null; - } - } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java index f6a1b20fc7..8fa0f34dca 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java +++ b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java @@ -17,6 +17,7 @@ import com.fr.stable.StableUtils; /** * Created by Mitisky on 16/3/7. */ +@Deprecated public abstract class AbstractIndependentChartUIWithAPILevel implements ChartTypeUIProvider { //这个不能改,是做兼容用的 //2016.10.14-11.24号的8.0jar因为改了这个为3,不会提示5.26号之前的插件更新 diff --git a/designer-chart/src/main/java/com/fr/design/chart/fun/impl/DefaultChartTypePane.java b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/DefaultChartTypePane.java new file mode 100644 index 0000000000..9d6b6fdf7f --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/DefaultChartTypePane.java @@ -0,0 +1,38 @@ +package com.fr.design.chart.fun.impl; + +import com.fr.chart.charttypes.ChartTypeManager; +import com.fr.chartx.attr.ChartProvider; +import com.fr.design.ChartTypeInterfaceManager; +import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2020/7/8 + */ +public class DefaultChartTypePane extends AbstractChartTypePane { + + @Override + protected String[] getTypeIconPath() { + return ChartTypeInterfaceManager.getInstance().getDemoImagePath(this.getPlotID()); + } + + @Override + protected String[] getTypeTipName() { + return ChartTypeInterfaceManager.getInstance().getSubName(this.getPlotID()); + } + + public ChartProvider getDefaultChart() { + return ChartTypeManager.getInstance().getChartTypes(this.getPlotID())[0]; + } + + public String title4PopupWindow() { + return ChartTypeInterfaceManager.getInstance().getName(this.getPlotID()); + } + + @Override + public void populateBean(T ob) { + } + + +} diff --git a/designer-chart/src/main/java/com/fr/design/chart/fun/impl/InvisibleChartTypePane.java b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/InvisibleChartTypePane.java new file mode 100644 index 0000000000..6bc927b178 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/InvisibleChartTypePane.java @@ -0,0 +1,15 @@ +package com.fr.design.chart.fun.impl; + +import com.fr.design.ChartTypeInterfaceManager; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/6/25 + */ +public class InvisibleChartTypePane extends DefaultChartTypePane { + @Override + public String title4PopupWindow() { + return ChartTypeInterfaceManager.TYPE_PANE_DEFAULT_TITLE; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java index 1ce2fbffd9..b251abc6a8 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java @@ -146,7 +146,6 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene return; } - chartCollection4Design.setPredefinedStyleName(getGlobalPredefinedStyleName(), false); Graphics2D g2d = (Graphics2D) g; if (this.isOpaque()) { diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java index 7e64f3d209..30d01cb55d 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java @@ -2,6 +2,7 @@ package com.fr.design.chart.gui; import com.fr.base.chart.BaseChartGetter; import com.fr.chart.chartattr.ChartCollection; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.core.WidgetOption; import com.fr.form.ui.ChartEditor; import com.fr.form.ui.Widget; @@ -40,6 +41,7 @@ public class ChartWidgetOption extends WidgetOption { try { ChartEditor widget = clz.newInstance(); ChartCollection chartCollection = (ChartCollection) BaseChartGetter.createChartCollection(this.chartID); + chartCollection.setThemeStyle(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplateTheme()); VanChart vanChart = chartCollection.getSelectedChartProvider(VanChart.class); if (vanChart !=null) { vanChart.resetAttrInForm(); diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java b/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java index 8cd0743dab..133e2fef74 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java @@ -9,6 +9,8 @@ import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.FilterComboBox; +import com.fr.design.gui.ifilechooser.FileChooserProvider; +import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser; import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.DesignerContext; @@ -40,56 +42,56 @@ import java.awt.event.ItemListener; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-10-15 下午03:38:15 */ -public class MapCustomPane extends BasicBeanPane implements AbstrctMapAttrEditPane{ // 储存地图对应的字段. 名称, 类型. shape (点 用圆形代替) +public class MapCustomPane extends BasicBeanPane implements AbstrctMapAttrEditPane { // 储存地图对应的字段. 名称, 类型. shape (点 用圆形代替) - private FilterComboBox areaString;// 区域字段 - private DatabaseTableDataPane tableDataNameBox;// 数据集名称 + 后面跟随预览按钮 - private MapImageEditPane imageShowPane; // 图片展示编辑的界面 - private String lastSelectPath; - private boolean isNeedDataSource = true; + private FilterComboBox areaString;// 区域字段 + private DatabaseTableDataPane tableDataNameBox;// 数据集名称 + 后面跟随预览按钮 + private MapImageEditPane imageShowPane; // 图片展示编辑的界面 + private String lastSelectPath; + private boolean isNeedDataSource = true; - public MapCustomPane() { - initComp(); - } + public MapCustomPane() { + initComp(); + } - public MapCustomPane(boolean isNeedDataSource){ - this.isNeedDataSource = isNeedDataSource; - initComp(); - } + public MapCustomPane(boolean isNeedDataSource) { + this.isNeedDataSource = isNeedDataSource; + initComp(); + } - private void initComp() { - this.setLayout(new BorderLayout(0, 0)); + private void initComp() { + this.setLayout(new BorderLayout(0, 0)); - JPanel pane = new JPanel(); - this.add(pane, BorderLayout.NORTH); + JPanel pane = new JPanel(); + this.add(pane, BorderLayout.NORTH); - pane.setLayout(new BorderLayout()); + pane.setLayout(new BorderLayout()); - pane.add(northPaneCreate(), BorderLayout.NORTH); + pane.add(northPaneCreate(), BorderLayout.NORTH); - imageShowPane = new MapImageEditPane(); + imageShowPane = new MapImageEditPane(); - pane.add(imageShowPane, BorderLayout.CENTER); - } + pane.add(imageShowPane, BorderLayout.CENTER); + } - private JPanel northPaneCreate() { - JPanel northPane = new JPanel(); + private JPanel northPaneCreate() { + JPanel northPane = new JPanel(); - northPane.setLayout(new FlowLayout(FlowLayout.LEFT)); + northPane.setLayout(new FlowLayout(FlowLayout.LEFT)); - UIButton loadMap = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Import_Map")); - loadMap.setPreferredSize(new Dimension(160, 20)); - northPane.add(loadMap); + UIButton loadMap = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Import_Map")); + loadMap.setPreferredSize(new Dimension(160, 20)); + northPane.add(loadMap); - loadMap.addActionListener(selectPictureActionListener); + loadMap.addActionListener(selectPictureActionListener); - if(isNeedDataSource){ - UILabel label =new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":", SwingConstants.RIGHT) ; + if (isNeedDataSource) { + UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":", SwingConstants.RIGHT); tableDataNameBox = new DatabaseTableDataPane(label) { - protected void userEvent() { -refreshAreaNameBox(); -} + protected void userEvent() { + refreshAreaNameBox(); + } }; tableDataNameBox.setPreferredSize(new Dimension(200, 20)); northPane.add(tableDataNameBox); @@ -100,158 +102,156 @@ refreshAreaNameBox(); areaString.setPreferredSize(new Dimension(120, 20)); areaString.addItemListener(areaChange); northPane.add(areaString); - } - - - return northPane; - } - - private ActionListener selectPictureActionListener = new ActionListener() { - - public void actionPerformed(ActionEvent evt) { - JFileChooser svgFileChooser = new JFileChooser(); - svgFileChooser.addChoosableFileFilter(new SVGFileFilter()); - if (StringUtils.isNotBlank(lastSelectPath)) { - svgFileChooser.setSelectedFile(new File(lastSelectPath)); - } - int returnVal = svgFileChooser.showOpenDialog(DesignerContext.getDesignerFrame()); - if (returnVal != JFileChooser.CANCEL_OPTION) { - File selectedFile = svgFileChooser.getSelectedFile(); - try { - lastSelectPath = selectedFile.getCanonicalPath(); - } catch (Exception ex) { - FineLoggerFactory.getLogger().error(ex.getMessage(), ex); - } - if (selectedFile != null && selectedFile.isFile()) { + } + + + return northPane; + } + + private ActionListener selectPictureActionListener = new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder(). + filter(".svg, .svgz", "*.svg", "*.svgz"). + currentDirectory(lastSelectPath).build(); + int returnVal = fileChooserProvider.showDialog(DesignerContext.getDesignerFrame()); + if (returnVal != JFileChooser.CANCEL_OPTION) { + File selectedFile = fileChooserProvider.getSelectedFile(); + try { + lastSelectPath = selectedFile.getCanonicalPath(); + } catch (Exception ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + } + if (selectedFile != null && selectedFile.isFile()) { imageShowPane.setSvgMap(selectedFile.getPath()); imageShowPane.repaint(); - } - } - } - }; - - private ItemListener areaChange = new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Object select = areaString.getSelectedItem(); - if (select != null) { - String colName = Utils.objectToString(areaString.getSelectedItem()); - - TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper(); - - imageShowPane.refreshFromDataList(getColValuesInData(tableDataWrappe, colName)); - } - } - }; - - public static List getColValuesInData(TableDataWrapper tableDataWrappe, String colName) { - List colValues = new ArrayList<>(); - - EmbeddedTableData embeddedTableData = null; - try { - embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tableDataWrappe.getTableData(), TableData.RESULT_ALL, false); - } catch (Exception ee) { + } + } + } + }; + + private ItemListener areaChange = new ItemListener() { + public void itemStateChanged(ItemEvent e) { + Object select = areaString.getSelectedItem(); + if (select != null) { + String colName = Utils.objectToString(areaString.getSelectedItem()); + + TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper(); + + imageShowPane.refreshFromDataList(getColValuesInData(tableDataWrappe, colName)); + } + } + }; + + public static List getColValuesInData(TableDataWrapper tableDataWrappe, String colName) { + List colValues = new ArrayList<>(); + + EmbeddedTableData embeddedTableData = null; + try { + embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tableDataWrappe.getTableData(), TableData.RESULT_ALL, false); + } catch (Exception ee) { FineLoggerFactory.getLogger().error(ee.getMessage(), ee); - } - - if(embeddedTableData == null){ - return colValues; - } - - int columnIndex = getColumnIndex(embeddedTableData, colName); - - if(columnIndex == DataModel.COLUMN_NAME_NOT_FOUND){ - return colValues; - } - - for (int rowIndex = 0, rowCount = embeddedTableData.getRowCount(); rowIndex < rowCount; rowIndex++) { - String colValueName = GeneralUtils.objectToString(embeddedTableData.getValueAt(rowIndex, columnIndex)); - if (!colValues.contains(colValueName)) { - colValues.add(colValueName); - } - } - - return colValues; - } - - private static int getColumnIndex(EmbeddedTableData tableData, String colName) { - for (int columnIndex = 0, columnCount = tableData.getColumnCount(); columnIndex < columnCount; columnIndex++) { - if (ComparatorUtils.tableDataColumnNameEquals(tableData.getColumnName(columnIndex), colName)) { - return columnIndex; - } - } - return DataModel.COLUMN_NAME_NOT_FOUND; - } - - /** - * 选中方式: 区域或者点 - */ - public void setImageSelectType(int selectType) { - if (imageShowPane != null) { - imageShowPane.setEditType(selectType); - } - } - - private void refreshAreaNameBox() {// 刷新区域名称列表 - if(!isNeedDataSource){ - return; - } - TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper(); - if (tableDataWrappe == null) { - return; - } - List columnNameList = tableDataWrappe.calculateColumnNameList(); - - Object oldSelected = areaString.getSelectedItem(); - areaString.removeAllItems(); - - for(String item : columnNameList) { - areaString.addItem(item); - } - areaString.getModel().setSelectedItem(oldSelected); - } + } + + if (embeddedTableData == null) { + return colValues; + } + + int columnIndex = getColumnIndex(embeddedTableData, colName); + + if (columnIndex == DataModel.COLUMN_NAME_NOT_FOUND) { + return colValues; + } + + for (int rowIndex = 0, rowCount = embeddedTableData.getRowCount(); rowIndex < rowCount; rowIndex++) { + String colValueName = GeneralUtils.objectToString(embeddedTableData.getValueAt(rowIndex, columnIndex)); + if (!colValues.contains(colValueName)) { + colValues.add(colValueName); + } + } + + return colValues; + } + + private static int getColumnIndex(EmbeddedTableData tableData, String colName) { + for (int columnIndex = 0, columnCount = tableData.getColumnCount(); columnIndex < columnCount; columnIndex++) { + if (ComparatorUtils.tableDataColumnNameEquals(tableData.getColumnName(columnIndex), colName)) { + return columnIndex; + } + } + return DataModel.COLUMN_NAME_NOT_FOUND; + } + + /** + * 选中方式: 区域或者点 + */ + public void setImageSelectType(int selectType) { + if (imageShowPane != null) { + imageShowPane.setEditType(selectType); + } + } + + private void refreshAreaNameBox() {// 刷新区域名称列表 + if (!isNeedDataSource) { + return; + } + TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper(); + if (tableDataWrappe == null) { + return; + } + List columnNameList = tableDataWrappe.calculateColumnNameList(); + + Object oldSelected = areaString.getSelectedItem(); + areaString.removeAllItems(); + + for (String item : columnNameList) { + areaString.addItem(item); + } + areaString.getModel().setSelectedItem(oldSelected); + } /** * 当前正在编辑的条目的类别(国家,省市)名和地图名 * @param typeName 类别名 * @param mapName 地图名 */ - public void setTypeNameAndMapName(String typeName, String mapName){ + public void setTypeNameAndMapName(String typeName, String mapName) { imageShowPane.setTypeNameAndMapName(typeName, mapName); } - /** - * 根据地图名称 加载信息 - */ - public void populateBean(String list) { - imageShowPane.populateBean(list); - } - - /** - * 根据地图名称 保存信息 - */ - public String updateBean() { - // 地图类型等 加入Helper - return imageShowPane.updateBean(); - } - - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Map"); - } - - /** - * 更新界面 - * @param attr 地图属性 - */ - public void populateMapAttr(MapSvgAttr attr) { - imageShowPane.populateMapSvgAttr(attr); - } - - /** - * 更新MapSvgAttr - * @return 返回属性 - */ - public MapSvgAttr updateCurrentAttr() { - return imageShowPane.updateWithOutSave(); - } + /** + * 根据地图名称 加载信息 + */ + public void populateBean(String list) { + imageShowPane.populateBean(list); + } + + /** + * 根据地图名称 保存信息 + */ + public String updateBean() { + // 地图类型等 加入Helper + return imageShowPane.updateBean(); + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Map"); + } + + /** + * 更新界面 + * @param attr 地图属性 + */ + public void populateMapAttr(MapSvgAttr attr) { + imageShowPane.populateMapSvgAttr(attr); + } + + /** + * 更新MapSvgAttr + * @return 返回属性 + */ + public MapSvgAttr updateCurrentAttr() { + return imageShowPane.updateWithOutSave(); + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java index ae38672204..3372880dda 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java @@ -7,6 +7,7 @@ import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chart.web.ChartHyperPoplink; import com.fr.chartx.attr.ChartProvider; import com.fr.design.chart.gui.ChartComponent; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.hyperlink.AbstractHyperLinkPane; import com.fr.design.layout.FRGUIPaneFactory; @@ -14,9 +15,9 @@ import com.fr.design.mainframe.chart.ChartHyperEditPane; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.log.FineLoggerFactory; +import java.util.HashMap; import java.awt.BorderLayout; import java.awt.Dimension; -import java.util.HashMap; /** * 类说明: 图表超链 -- 弹出 悬浮窗. @@ -64,6 +65,7 @@ public class ChartHyperPoplinkPane extends AbstractHyperLinkPane extends protected abstract void update(T chart); + public String title4PopupWindow() { + return PaneTitleConstants.CHART_OTHER_TITLE; + } + @Override public void populate(ChartCollection collection) { if (collection == null) { diff --git a/designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java b/designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java index 5909437c70..8534ed4b72 100644 --- a/designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java +++ b/designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java @@ -8,110 +8,122 @@ import com.fr.base.GraphHelper; import com.fr.base.ScreenResolution; import com.fr.base.background.ColorBackground; import com.fr.chart.chartglyph.Marker; -import com.fr.general.ComparatorUtils; -import com.fr.plugin.chart.ConfigHelper; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.i18n.Toolkit; +import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; +import com.fr.plugin.chart.ConfigHelper; - -import javax.swing.*; -import java.awt.*; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JLabel; +import javax.swing.JList; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; /** * Combobox for selecting marker. */ public class MarkerComboBox extends UIComboBox { - private static final double TEXT_X_COORDINATES = 12d; - - /** - * Constructor. - * - * @param markerArray the array of marker. - */ - public MarkerComboBox(Marker[] markerArray) { - this.setModel(new DefaultComboBoxModel(markerArray)); - this.setRenderer(new MarkerCellRenderer()); - } - - /** - * Get selected marker. - */ - public Marker getSelectedMarkder() { - return (Marker) getSelectedItem(); - } - - /** - * Set the selected marker. - */ - public void setSelectedMarker(Marker marker) { - setSelectedItem(marker); - } - - /** - * CellRenderer. - */ - class MarkerCellRenderer extends UIComboBoxRenderer { - public Component getListCellRendererComponent(JList list, - Object value, int index, boolean isSelected, boolean cellHasFocus) { - this.marker = (Marker) value; - this.isSelected = isSelected; - - return this; - } - - public void paint(Graphics g) { - Graphics2D g2d = (Graphics2D) g; - - Dimension d = getSize(); - g2d.setColor(Color.black); - g2d.setFont(FRContext.getDefaultValues().getFRFont()); - - if (marker != null) { - boolean isAutoMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.AUTO_M); - boolean isNullMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.NULL_M); - - if (isAutoMarker || isNullMarker) { - String text = isNullMarker - ?Toolkit.i18nText("Fine-Design_Report_None") - :Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto"); - - paintTextMarker(g2d, d, text); - } else { - if (marker.getBackground() == null) { - marker.setBackground(ColorBackground.getInstance(Color.black)); - } - marker.paint(g2d, d.width / 2, d.height / 2); - } - } - - if (isSelected) { - g2d.setColor(Color.blue); - GraphHelper.drawRect(g2d, 0, 0, d.width - 1, d.height - 1); - } - } - - public Dimension getPreferredSize() { - return new Dimension(36, 16); - } - - public Dimension getMinimumSize() { - return getPreferredSize(); - } - - private Marker marker = null; - private boolean isSelected = false; - - private void paintTextMarker(Graphics2D g2d, Dimension d, String text) { - g2d.setColor(Color.black); - FRFont font = FRContext.getDefaultValues().getFRFont(); - int resolution = ScreenResolution.getScreenResolution(); - Font rfont = font.applyResolutionNP(resolution); - g2d.setFont(rfont); - FontMetrics fm = GraphHelper.getFontMetrics(rfont); - - GraphHelper.drawString(g2d, text, TEXT_X_COORDINATES, (d.height - fm.getHeight()) / 2 + fm.getAscent()); - } - } + private static final double TEXT_X_COORDINATES = 12d; + + /** + * Constructor. + * + * @param markerArray the array of marker. + */ + public MarkerComboBox(Marker[] markerArray) { + this.setModel(new DefaultComboBoxModel(markerArray)); + this.setRenderer(new MarkerCellRenderer()); + } + + /** + * Get selected marker. + */ + public Marker getSelectedMarkder() { + return (Marker) getSelectedItem(); + } + + /** + * Set the selected marker. + */ + public void setSelectedMarker(Marker marker) { + setSelectedItem(marker); + } + + /** + * CellRenderer. + */ + class MarkerCellRenderer extends UIComboBoxRenderer { + + private Marker marker = null; + private boolean isSelected = false; + + public Component getListCellRendererComponent(JList list, + Object value, int index, boolean isSelected, boolean cellHasFocus) { + this.marker = (Marker) value; + this.isSelected = isSelected; + + String text = null; + if (marker != null) { + boolean isAutoMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.AUTO_M); + boolean isNullMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.NULL_M); + if (isAutoMarker || isNullMarker) { + text = isNullMarker + ? Toolkit.i18nText("Fine-Design_Report_None") + : Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto"); + } + } + JLabel comp = (JLabel) super.getListCellRendererComponent(list, text, index, isSelected, cellHasFocus); + return comp; + } + + public void paint(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + Dimension d = getSize(); + if (marker != null) { + boolean isAutoMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.AUTO_M); + boolean isNullMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.NULL_M); + if (isAutoMarker || isNullMarker) { + super.paint(g); + } else { + g2d.setColor(Color.black); + if (marker.getBackground() == null) { + marker.setBackground(ColorBackground.getInstance(Color.black)); + } + marker.paint(g2d, d.width / 2, d.height / 2); + } + } + + if (isSelected) { + g2d.setColor(Color.blue); + GraphHelper.drawRect(g2d, 0, 0, d.width - 1, d.height - 1); + } + } + + public Dimension getPreferredSize() { + return new Dimension(36, 16); + } + + public Dimension getMinimumSize() { + return getPreferredSize(); + } + + + private void paintTextMarker(Graphics2D g2d, Dimension d, String text) { + g2d.setColor(Color.black); + FRFont font = FRContext.getDefaultValues().getFRFont(); + int resolution = ScreenResolution.getScreenResolution(); + Font rfont = font.applyResolutionNP(resolution); + g2d.setFont(rfont); + FontMetrics fm = GraphHelper.getFontMetrics(rfont); + + GraphHelper.drawString(g2d, text, TEXT_X_COORDINATES, (d.height - fm.getHeight()) / 2 + fm.getAscent()); + } + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java index 4efe977ff3..90b0e88054 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java @@ -16,6 +16,7 @@ import com.fr.design.gui.chart.ChartEditPaneProvider; import com.fr.design.gui.frpane.UITitlePanel; import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.stable.AssistUtils; import javax.swing.BorderFactory; import javax.swing.Icon; @@ -35,6 +36,9 @@ public class ChartPropertyPane extends BaseChartPropertyPane { protected ChartEditPane chartEditPane; + //ID一样的话 不用新建chartEditPane + private String currentID; + private ChartPropertyPane() { initComponent(); } @@ -46,9 +50,12 @@ public class ChartPropertyPane extends BaseChartPropertyPane { @Override public void updateChartEditPane(String plotID) { - chartEditPane = ChartTypeInterfaceManager.getInstance().getChartEditPane(plotID); - chartEditPane.setContainer(container); - resetChartEditPane(); + if (!AssistUtils.equals(currentID, plotID)) { + chartEditPane = ChartTypeInterfaceManager.getInstance().getChartEditPane(plotID); + chartEditPane.setContainer(container); + currentID = plotID; + resetChartEditPane(); + } } @Override diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/MapEditPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/MapEditPane.java deleted file mode 100644 index 307d457cfd..0000000000 --- a/designer-chart/src/main/java/com/fr/design/mainframe/MapEditPane.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.fr.design.mainframe; - -import com.fr.chart.base.MapSvgAttr; -import com.fr.chart.base.MapSvgXMLHelper; -import com.fr.chart.chartglyph.MapShapeValue; -import com.fr.design.beans.BasicBeanPane; -import com.fr.design.chart.series.PlotSeries.AbstrctMapAttrEditPane; -import com.fr.design.chart.series.PlotSeries.MapCustomPane; -import com.fr.design.chart.series.PlotSeries.MapDefiAreaNamePane; -import com.fr.design.gui.frpane.UITabbedPane; - -import com.fr.stable.CoreConstants; -import com.fr.stable.StringUtils; - -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.*; - -/** - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 7.1.1 - * Date: 14/12/2 - * Time: 下午7:17 - */ -public class MapEditPane extends BasicBeanPane{ - - private UITabbedPane tabbedPane; - private MapCustomPane areaPane ; -// private MapCustomPane pointPane; - private MapDefiAreaNamePane namedPane; - private String currentMapName; - private AbstrctMapAttrEditPane editingPane; - - private ChangeListener tabbedChangeListener = new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - switch ( tabbedPane.getSelectedIndex()){ - case 1: - namedPane.populateMapAttr(editingPane.updateCurrentAttr()); - editingPane = namedPane; - break; - default: - areaPane.populateMapAttr(editingPane.updateCurrentAttr()); - editingPane = areaPane; - } - } - } ; - - public MapEditPane(){ - initTabbedPane(); - this.setLayout(new BorderLayout()); - this.add(tabbedPane,BorderLayout.CENTER); - } - - private void initTabbedPane(){ - tabbedPane = new UITabbedPane(); - areaPane = new MapCustomPane(false); -// pointPane = new MapCustomPane(false); - namedPane= new MapDefiAreaNamePane(false); - areaPane.setImageSelectType(MapShapeValue.AREA); -// pointPane.setImageSelectType(MapShapeValue.POINT); - tabbedPane.add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Image_Area"),areaPane); -// tabbedPane.add(com.fr.design.i18n.Toolkit.i18nText("FR-Chart-Map_ImagePoint"),pointPane); - tabbedPane.add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Corresponding_Fields"),namedPane); - editingPane = areaPane; - } - - @Override - protected String title4PopupWindow() { - return null; - } - - @Override - public void populateBean(MapSvgAttr ob) { - if(!StringUtils.isEmpty(ob.getName()) && !MapSvgXMLHelper.getInstance().containsMapName(ob.getName())){ - MapSvgAttr mapSvgAttr = new MapSvgAttr(); - mapSvgAttr.setFilePath(MapSvgXMLHelper.customMapPath()+ CoreConstants.SEPARATOR+ob.getName()+".svg"); - MapSvgXMLHelper.getInstance().addNewSvgMaps(ob.getName(), mapSvgAttr); - } - - currentMapName = ob.getName(); - if(editingPane == null){ - editingPane = areaPane; - } - editingPane.populateMapAttr(ob); - tabbedPane.addChangeListener(tabbedChangeListener); - } - - public String getCurrentMapName(){ - return currentMapName; - } - - public void setCurrentMapName(String currentMapName){ - this.currentMapName = currentMapName; - - } - - @Override - public MapSvgAttr updateBean() { - MapSvgAttr currentAttr = editingPane.updateCurrentAttr(); - currentMapName =currentAttr != null ? currentAttr.getName() : currentMapName; - MapSvgAttr attr = MapSvgXMLHelper.getInstance().getMapAttr(currentMapName); - if(attr != null ){ - MapSvgXMLHelper.getInstance().removeNewMapAttr(currentMapName); - MapSvgXMLHelper.getInstance().pushMapAttr(currentMapName,currentAttr); - return currentAttr; - }else{ - return MapSvgXMLHelper.getInstance().getNewMapAttr(currentMapName); - } - } -} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java index 6cd8ae54a2..d6acb929a7 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java @@ -9,6 +9,7 @@ import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.chart.ChartEditPaneActionListener; import com.fr.design.gui.chart.ChartEditPaneProvider; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.ibutton.UIHeadGroup; @@ -19,6 +20,7 @@ import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartOtherPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartTypePane; +import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.form.main.Form; import com.fr.general.ComparatorUtils; @@ -28,11 +30,11 @@ import com.fr.plugin.chart.vanchart.VanChart; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.CardLayout; import java.util.ArrayList; import java.util.Calendar; import java.util.List; -import java.awt.BorderLayout; -import java.awt.CardLayout; public class ChartEditPane extends BasicPane implements AttributeChange, Prepare4DataSourceChange, ChartEditPaneProvider { @@ -102,6 +104,33 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare this.add(center, BorderLayout.CENTER); } + /** + * 增加面板Listener + */ + public void addChartEditPaneActionListener(ChartEditPaneActionListener l) { + this.listenerList.add(ChartEditPaneActionListener.class, l); + } + + /** + * 移除面板Listener + */ + public void removeChartEditPaneActionListener(ChartEditPaneActionListener l) { + this.listenerList.remove(ChartEditPaneActionListener.class, l); + } + + private void fireAttributeChange(ChartCollection chartCollection) { + // Guaranteed to return a non-null array + Object[] listeners = listenerList.getListenerList(); + + // Process the listeners last to first, notifying + // those that are interested in this event + for (int i = listeners.length - 1; i >= 0; i -= 1) { + if (listeners[i] == ChartEditPaneActionListener.class) { + ((ChartEditPaneActionListener) listeners[i + 1]).attributeChange(chartCollection); + } + } + } + AttributeChangeListener listener = new AttributeChangeListener() { @Override public void attributeChange() { @@ -131,6 +160,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare } fire(); + fireAttributeChange(collection); } } }; @@ -147,13 +177,13 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare */ public void reLayout(ChartProvider currentChart) { if (currentChart != null) { - int chartIndex = getSelectedChartIndex(currentChart); this.removeAll(); this.setLayout(new BorderLayout()); paneList = new ArrayList(); - addTypePane(); - String chartID = currentChart.getID(); + + addTypePane(currentChart); + boolean isDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartID); if (isDefault) { @@ -187,8 +217,17 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare return chartDataPane; } - protected void addTypePane() { - paneList.add(typePane); + protected void addTypePane(ChartProvider chart) { + if (visibleTypePane(chart)) { + paneList.add(typePane); + } + } + + private boolean visibleTypePane(ChartProvider chart) { + AbstractChartTypePane pane = ChartTypeInterfaceManager.getInstance().getPlotTypePane(chart.getID()); + return pane != null + && !ChartTypeInterfaceManager.TYPE_PANE_DEFAULT_TITLE.equals(pane.title4PopupWindow()) + && pane.visible(chart); } protected void setSelectedTab() { diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartHyperEditPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartHyperEditPane.java index bae6e20bce..fdfa6a3c3b 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartHyperEditPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartHyperEditPane.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe.chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.web.ChartHyperPoplink; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperPopAttrPane; @@ -48,7 +49,7 @@ public class ChartHyperEditPane extends ChartEditPane { return dataPane; } - protected void addTypePane() { + protected void addTypePane(ChartProvider chart) { paneList.add(attrPane); paneList.add(typePane); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index f2bea52278..1fdd6e9fd8 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -27,9 +27,6 @@ import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JPanel; import javax.swing.SwingUtilities; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FlowLayout; @@ -46,6 +43,9 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; /** * 图表 类型 增删 控制按钮界面. @@ -252,7 +252,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen public ChartProvider getChangeStateNewChart() { ChartProvider chart = editingCollection.getSelectedChartProvider(ChartProvider.class); String chartID = chart.getID(); - String priority = ChartTypeManager.getInstanceWithCheck().getPriority(chartID); + int priority = ChartTypeManager.getInstanceWithCheck().getPriority(chartID); ChartProvider firstChart = ChartTypeManager.getInstanceWithCheck().getFirstChart(priority); try { return (ChartProvider) firstChart.clone(); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java index 2318fc05f5..985ee28afa 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -17,9 +17,11 @@ import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.item.FlexibleComboBox; import com.fr.design.mainframe.chart.gui.item.ItemEventType; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.design.module.DesignModuleFactory; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; +import com.fr.stable.AssistUtils; import com.fr.stable.StringUtils; import javax.swing.JPanel; @@ -34,6 +36,8 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; /** * 图表 属性表, 类型选择 界面. @@ -61,7 +65,14 @@ public class ChartTypePane extends AbstractChartAttrPane { if (editingCollection != null) { relayoutChartTypePane(editingCollection); } else { - chartTypeComBox = new ComboBoxPane(); + chartTypeComBox = new ComboBoxPane() { + @Override + protected void initLayout() { + super.initLayout(); + jcb.setVisible(ChartEditContext.normalMode()); + } + }; + } BasicScrollPane scrollPane = new BasicScrollPane() { @@ -90,6 +101,19 @@ public class ChartTypePane extends AbstractChartAttrPane { buttonPane.setEditingChartPane(chartTypeComBox); + buttonPane.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + buttonPane.requestFocus(); + } + }); + + chartTypeComBox.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + content.requestFocus(); + } + }); return content; } @@ -140,14 +164,44 @@ public class ChartTypePane extends AbstractChartAttrPane { } } + /** + * 把所有的pane加到list里 + * + * @param paneList pane容器 + */ + private static void addPlotTypePaneList(List> paneList, + Map>> allChartTypePane, + ActionListener autoButtonListener) { + + String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDsIncludeDisabled(); + + for (String id : chartIDs) { + + AbstractChartTypePane pane = ChartTypeInterfaceManager.getInstance().getPlotTypePane(id); + if (pane == null || AssistUtils.equals(pane.title4PopupWindow(), ChartTypeInterfaceManager.TYPE_PANE_DEFAULT_TITLE)) { + continue; + } + pane.reLayout(id); + pane.registerButtonListener(autoButtonListener); + paneList.add(pane); + + Integer priority = ChartTypeManager.getInstance().getPriority(id); + if (allChartTypePane.get(priority) == null) { + allChartTypePane.put(priority, new LinkedHashMap>()); + } + allChartTypePane.get(priority).put(id, pane); + } + } + class ComboBoxPane extends UIComboBoxPane { - private Map>> allChartTypePane; + //todo:refactor 图表切换过滤不应该根据优先级priority,应该给旧版本图表和新特性图表的图表类型信息分别增加一个switchID之类的 + private Map>> allChartTypePane; @Override protected List> initPaneList() { List> paneList = new ArrayList>(); - allChartTypePane = new LinkedHashMap>>(); - ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(paneList, allChartTypePane, autoButtonListener); + allChartTypePane = new LinkedHashMap>>(); + addPlotTypePaneList(paneList, allChartTypePane, autoButtonListener); return paneList; } @@ -167,6 +221,7 @@ public class ChartTypePane extends AbstractChartAttrPane { String lastPlotID = chart.getID(); + boolean chartTypeChange = false; try { AbstractChartTypePane selectedPane = (AbstractChartTypePane) getSelectedPane(); ChartProvider newDefaultChart = (ChartProvider) ChartTypeManager.getInstanceWithCheck().getCharts(selectedPane.getPlotID())[0].clone(); @@ -176,13 +231,16 @@ public class ChartTypePane extends AbstractChartAttrPane { editingCollection.removeNameObject(editingCollection.getSelectedIndex()); editingCollection.addChart(newDefaultChart); chart = newDefaultChart; + chartTypeChange = true; } } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } //这一步会替换plot + String id = chart.getID(); ((AbstractChartTypePane) getSelectedPane()).updateBean(chart); - if (inForm) { + chartTypeChange = chartTypeChange || !ComparatorUtils.equals(id, chart.getID()); + if (inForm && chartTypeChange) { chart.resetAttrInForm(); } reLayoutEditPane(chart, lastPlotID); @@ -209,18 +267,18 @@ public class ChartTypePane extends AbstractChartAttrPane { } private void addAllCards() { - Iterator iterator = allChartTypePane.keySet().iterator(); + Iterator iterator = allChartTypePane.keySet().iterator(); while (iterator.hasNext()) { addOnePriorityCards(iterator.next(), false); } } - private void addOnePriorityCards(String priority) { + private void addOnePriorityCards(int priority) { addOnePriorityCards(priority, true); } - private void addOnePriorityCards(String priority, boolean ignore) { + private void addOnePriorityCards(int priority, boolean ignore) { Map> map = allChartTypePane.get(priority); @@ -236,7 +294,7 @@ public class ChartTypePane extends AbstractChartAttrPane { } - private void addOnePlotIDCards(String priority, String plotID) { + private void addOnePlotIDCards(int priority, String plotID) { cards.add(allChartTypePane.get(priority).get(plotID)); } @@ -246,7 +304,7 @@ public class ChartTypePane extends AbstractChartAttrPane { //重构需要重构下拉框选项和cardNames ChartProvider chart = collection.getSelectedChartProvider(ChartProvider.class); String chartID = chart.getID(); - String priority = ChartTypeManager.getInstanceWithCheck().getPriority(chartID); + int priority = ChartTypeManager.getInstanceWithCheck().getPriority(chartID); boolean enabledChart = ChartTypeManager.enabledChart(chartID); String item = ChartTypeInterfaceManager.getInstance().getName(chartID); @@ -360,7 +418,7 @@ public class ChartTypePane extends AbstractChartAttrPane { buttonPane.populateBean(collection); chartTypeComBox.populateBean(chart); - buttonPane.setVisible(ChartTypeInterfaceManager.getInstance().needChartChangePane(chart)); + buttonPane.setVisible(ChartTypeInterfaceManager.getInstance().needChartChangePane(chart) && ChartEditContext.normalMode()); this.initAllListeners(); } @@ -410,5 +468,6 @@ public class ChartTypePane extends AbstractChartAttrPane { public void registerChartEditPane(ChartEditPane currentEditPane) { this.editPane = currentEditPane; this.inForm = editPane.isInForm(); + buttonPane.refreshChartInForm(inForm); } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ColorSelectBoxWithOutTransparent.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ColorSelectBoxWithOutTransparent.java index ba0b032411..33498d39a0 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ColorSelectBoxWithOutTransparent.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ColorSelectBoxWithOutTransparent.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.chart.gui; import com.fr.design.style.color.ColorSelectBox; -import com.fr.design.style.color.ColorSelectPane; +import com.fr.design.style.color.NewColorSelectPane; /** * Created by Fangjie on 2016/4/8. @@ -14,7 +14,7 @@ public class ColorSelectBoxWithOutTransparent extends ColorSelectBox { @Override - protected ColorSelectPane getColorSelectPane(){ + protected NewColorSelectPane getColorSelectPane(){ return new ColorSelectPaneWithOutTransparent(); } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ColorSelectPaneWithOutTransparent.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ColorSelectPaneWithOutTransparent.java index beab8a7a5f..7acc164323 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ColorSelectPaneWithOutTransparent.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ColorSelectPaneWithOutTransparent.java @@ -1,43 +1,21 @@ package com.fr.design.mainframe.chart.gui; import com.fr.chart.base.ChartConstants; -import com.fr.design.style.color.ColorCell; -import com.fr.design.style.color.ColorSelectPane; +import com.fr.design.style.color.NewColorSelectPane; -import javax.swing.*; -import java.awt.*; +import java.awt.Color; /** * Created by Fangjie on 2016/4/8. */ -public class ColorSelectPaneWithOutTransparent extends ColorSelectPane { +public class ColorSelectPaneWithOutTransparent extends NewColorSelectPane { public ColorSelectPaneWithOutTransparent(){ super(false); } - public void initCenterPaneChildren(JPanel centerPane) { - JPanel menuColorPane1 = new JPanel(); - centerPane.add(menuColorPane1); - menuColorPane1.setLayout(new GridLayout(3, 8, 5, 5)); - for (int i = 0; i < ChartConstants.MAP_COLOR_ARRAY.length; i++) { - menuColorPane1.add(new ColorCell(ChartConstants.MAP_COLOR_ARRAY[i], this)); - } - centerPane.add(Box.createVerticalStrut(5)); - centerPane.add(new JSeparator()); - } - protected Color[] getColorArray(){ return ChartConstants.MAP_COLOR_ARRAY; } - protected JPanel getMenuColorPane() { - JPanel menuColorPane = new JPanel(); - menuColorPane.setLayout(new GridLayout(0, 8, 1, 1)); - menuColorPane.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8)); - - menuColorPane.setPreferredSize(new Dimension(205, 62)); - - return menuColorPane; - } } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java index 42cf782c35..86f7e4da87 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java @@ -7,16 +7,17 @@ import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.UIComboBoxPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.van.chart.designer.AbstractVanChartScrollPane; import javax.swing.BorderFactory; import javax.swing.JPanel; -import java.util.ArrayList; -import java.util.List; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; +import java.util.ArrayList; +import java.util.List; /** * 一般数据界面 @@ -67,7 +68,9 @@ public class NormalChartDataPane extends DataContentsPane { 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(0,5,0,8)); - this.add(northPane, BorderLayout.NORTH); + if (ChartEditContext.normalMode()) { + this.add(northPane, BorderLayout.NORTH); + } this.add(cardPane, BorderLayout.CENTER); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java index 9a906cc7c0..b23b63a18e 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java @@ -35,6 +35,7 @@ public class ChartTextAttrPane extends BasicPane { private UIToggleButton italic; private UIColorButton fontColor; public static Integer[] FONT_SIZES = new Integer[FONT_END - FONT_START + 1]; + static { for (int i = FONT_START; i <= FONT_END; i++) { FONT_SIZES[i - FONT_START] = i; @@ -88,6 +89,10 @@ public class ChartTextAttrPane extends BasicPane { populate(frFont); } + public void populate(TextAttr textAttr, boolean autoFont) { + populate(textAttr); + } + public void update(TextAttr textAttr) { if (textAttr == null) { textAttr = new TextAttr(); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithPreStyle.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithThemeStyle.java similarity index 71% rename from designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithPreStyle.java rename to designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithThemeStyle.java index e27ed43e1e..345d57de8a 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithPreStyle.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithThemeStyle.java @@ -7,10 +7,11 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.SwingConstants; +import java.awt.BorderLayout; import java.awt.Component; -import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -19,7 +20,7 @@ import java.awt.event.ActionListener; * @version 10.0 * Created by Bjorn on 2020-09-03 */ -public class ChartTextAttrPaneWithPreStyle extends ChartTextAttrPane { +public class ChartTextAttrPaneWithThemeStyle extends ChartTextAttrPane { private static final int PREDEFINED_STYLE = 0; private static final int CUSTOM = 1; @@ -27,27 +28,26 @@ public class ChartTextAttrPaneWithPreStyle extends ChartTextAttrPane { private UIButtonGroup preButton; private JPanel textFontPane; - public ChartTextAttrPaneWithPreStyle() { + public ChartTextAttrPaneWithThemeStyle() { initListener(); } protected JPanel getContentPane(JPanel buttonPane) { - preButton = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Predefined"), + JPanel panel = new JPanel(new BorderLayout(0, 10)); + + preButton = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Follow_Theme"), Toolkit.i18nText("Fine-Design_Chart_Custom")}); double f = TableLayout.FILL; double e = getEdithAreaWidth(); - double[] columnSize = {f, e}; double p = TableLayout.PREFERRED; - textFontPane = TableLayout4VanChartHelper.createGapTableLayoutPane(getComponents(buttonPane), getRowSize(), columnSize); - - double[] rowSize = {p, p, p}; + double[] columnSize = {f, e}; UILabel text = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); - Component[][] components = { - new Component[]{null, null}, - new Component[]{text, preButton}, - new Component[]{textFontPane, null}, - }; - return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); + JPanel preButtonPane = TableLayout4VanChartHelper.createGapTableLayoutPane(new Component[][]{new Component[]{text, preButton}}, new double[]{p}, columnSize); + textFontPane = TableLayout4VanChartHelper.createGapTableLayoutPane(getComponents(buttonPane), getRowSize(), columnSize); + panel.add(preButtonPane, BorderLayout.CENTER); + panel.add(textFontPane, BorderLayout.SOUTH); + panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + return panel; } protected double getEdithAreaWidth() { @@ -72,11 +72,19 @@ public class ChartTextAttrPaneWithPreStyle extends ChartTextAttrPane { private void checkPreButton() { textFontPane.setVisible(preButton.getSelectedIndex() == CUSTOM); - textFontPane.setPreferredSize(preButton.getSelectedIndex() == CUSTOM ? new Dimension(0, 60) : new Dimension(0, 0)); + } + + protected double[] getRowSize() { + double p = TableLayout.PREFERRED; + return new double[]{p, p}; } public void populate(TextAttr textAttr) { - if (textAttr.isPredefinedStyle()) { + populate(textAttr, false); + } + + public void populate(TextAttr textAttr, boolean autoFont) { + if (textAttr.isThemed() || autoFont) { preButton.setSelectedIndex(PREDEFINED_STYLE); } else { preButton.setSelectedIndex(CUSTOM); @@ -88,9 +96,9 @@ public class ChartTextAttrPaneWithPreStyle extends ChartTextAttrPane { public void update(TextAttr textAttr) { int selectedIndex = preButton.getSelectedIndex(); if (selectedIndex == PREDEFINED_STYLE) { - textAttr.setPredefinedStyle(true); + textAttr.setThemed(true); } else { - textAttr.setPredefinedStyle(false); + textAttr.setThemed(false); } super.update(textAttr); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ColorSelectBoxWithPreStyle.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ColorSelectBoxWithThemeStyle.java similarity index 81% rename from designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ColorSelectBoxWithPreStyle.java rename to designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ColorSelectBoxWithThemeStyle.java index a4a0344fa4..bee92e04c4 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ColorSelectBoxWithPreStyle.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ColorSelectBoxWithThemeStyle.java @@ -1,6 +1,6 @@ package com.fr.design.mainframe.chart.gui.style; -import com.fr.chart.base.ColorWithPreStyle; +import com.fr.chart.base.ColorWithThemeStyle; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; @@ -22,7 +22,7 @@ import java.awt.event.ActionListener; * @version 10.0 * Created by Bjorn on 2020-09-07 */ -public class ColorSelectBoxWithPreStyle extends BasicPane { +public class ColorSelectBoxWithThemeStyle extends BasicPane { private static final int PREDEFINED_STYLE = 0; private static final int CUSTOM = 1; @@ -30,8 +30,8 @@ public class ColorSelectBoxWithPreStyle extends BasicPane { private UIButtonGroup preButton; private ColorSelectBox colorSelectBox; - public ColorSelectBoxWithPreStyle(int preferredWidth) { - preButton = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Predefined"), + public ColorSelectBoxWithThemeStyle(int preferredWidth) { + preButton = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Follow_Theme"), Toolkit.i18nText("Fine-Design_Chart_Custom")}); colorSelectBox = new ColorSelectBox(preferredWidth); initContent(); @@ -73,15 +73,15 @@ public class ColorSelectBoxWithPreStyle extends BasicPane { return null; } - public void populate(ColorWithPreStyle colorWithPreStyle) { - preButton.setSelectedIndex(colorWithPreStyle.isPredefinedStyle() ? PREDEFINED_STYLE : CUSTOM); + public void populate(ColorWithThemeStyle colorWithPreStyle) { + preButton.setSelectedIndex(colorWithPreStyle.isThemed() ? PREDEFINED_STYLE : CUSTOM); colorSelectBox.setSelectObject(colorWithPreStyle.getColor()); checkPreButton(); } - public ColorWithPreStyle update() { - ColorWithPreStyle colorWithPreStyle = new ColorWithPreStyle(); - colorWithPreStyle.setPredefinedStyle(preButton.getSelectedIndex() == PREDEFINED_STYLE); + public ColorWithThemeStyle update() { + ColorWithThemeStyle colorWithPreStyle = new ColorWithThemeStyle(); + colorWithPreStyle.setThemed(preButton.getSelectedIndex() == PREDEFINED_STYLE); colorWithPreStyle.setColor(colorSelectBox.getSelectObject()); return colorWithPreStyle; } 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 fb2d1c31ad..6529efce05 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 @@ -277,11 +277,11 @@ public class UIColorPickerPane extends BasicPane implements UIObserver { */ public Dimension getPreferredSize() { if (designTypeButtonGroup.getSelectedIndex() == 0) { - return new Dimension(colorGroup.getPreferredSize().width + textGroup.getPreferredSize().width, upControlPane.getPreferredSize().height + getBoundY()); + return new Dimension(colorGroup.getPreferredSize().width + textGroup.getPreferredSize().width, upControlPane.getPreferredSize().height + getPreferredMarginY()); } else { - int extra = stagePanel == null ? 0 : stagePanel.getPreferredSize().height + getBoundY(); + int extra = stagePanel == null ? 0 : stagePanel.getPreferredSize().height + getPreferredMarginY(); return new Dimension(colorGroup.getPreferredSize().width + textGroup.getPreferredSize().width, - extra + textGroup.getPreferredSize().height + upControlPane.getPreferredSize().height + OFF_HEIGHT + getBoundY()); + extra + textGroup.getPreferredSize().height + upControlPane.getPreferredSize().height + OFF_HEIGHT + getPreferredMarginY()); } } @@ -662,6 +662,10 @@ public class UIColorPickerPane extends BasicPane implements UIObserver { return UPCONTROLPANE_WIDTH; } + protected int getPreferredMarginY() { + return MARGIN_TOP; + } + /** *刷新颜色选取器 * @param colorArray 颜色值 diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane4Map.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane4Map.java index 8606ffab9d..217b01d8b8 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane4Map.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane4Map.java @@ -2,15 +2,10 @@ package com.fr.design.mainframe.chart.gui.style.series; import com.fr.chart.base.ChartConstants; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; -import com.fr.design.style.color.ColorCell; import com.fr.design.style.color.ColorSelectBox; -import com.fr.design.style.color.ColorSelectPane; +import com.fr.design.style.color.NewColorSelectPane; -import javax.swing.Box; -import javax.swing.JPanel; -import javax.swing.JSeparator; import java.awt.Color; -import java.awt.GridLayout; /** * Created by IntelliJ IDEA. @@ -27,23 +22,12 @@ public class UIColorPickerPane4Map extends UIColorPickerPane { return new ColorSelectBox4Map(100); } - private class ColorSelectPane4Map extends ColorSelectPane { + private class ColorSelectPane4Map extends NewColorSelectPane { public ColorSelectPane4Map(){ super(false); } - public void initCenterPaneChildren(JPanel centerPane) { - JPanel menuColorPane1 = new JPanel(); - centerPane.add(menuColorPane1); - menuColorPane1.setLayout(new GridLayout(5, 8, 5, 5)); - for (int i = 0; i < ChartConstants.MAP_COLOR_ARRAY.length; i++) { - menuColorPane1.add(new ColorCell(ChartConstants.MAP_COLOR_ARRAY[i], this)); - } - centerPane.add(Box.createVerticalStrut(5)); - centerPane.add(new JSeparator()); - } - protected Color[] getColorArray(){ return ChartConstants.MAP_COLOR_ARRAY; } @@ -54,7 +38,7 @@ public class UIColorPickerPane4Map extends UIColorPickerPane { super(preferredWidth); } - protected ColorSelectPane getColorSelectPane(){ + protected NewColorSelectPane getColorSelectPane(){ return new ColorSelectPane4Map(); } } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java index 4f3f025105..cde6e8fd6e 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java @@ -217,6 +217,10 @@ public abstract class AbstractChartTypePane extends Fur return plotID; } + public boolean visible(ChartProvider chart) { + return true; + } + /** * @param ob 对象 * @return diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java index 584d7fd1d6..e8ef8714da 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java @@ -72,6 +72,7 @@ public class ChartImagePane extends ChartSelectDemoPane { }else{ this.isDoubleClicked = false; } + this.requestFocus(); super.mouseClicked(e); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/mode/ChartEditContext.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/mode/ChartEditContext.java new file mode 100644 index 0000000000..23616a482a --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/mode/ChartEditContext.java @@ -0,0 +1,26 @@ +package com.fr.design.mainframe.chart.mode; + +import com.fr.common.annotations.Open; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/6/4 + */ +@Open +public class ChartEditContext { + + private static ChartEditMode current = ChartEditMode.NORMAL; + + public static void switchTo(ChartEditMode mode) { + current = mode; + } + + public static boolean duchampMode() { + return current == ChartEditMode.DUCHAMP; + } + + public static boolean normalMode() { + return current == ChartEditMode.NORMAL; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/mode/ChartEditMode.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/mode/ChartEditMode.java new file mode 100644 index 0000000000..c5cc9da489 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/mode/ChartEditMode.java @@ -0,0 +1,12 @@ +package com.fr.design.mainframe.chart.mode; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/6/4 + */ +//todo:refactor 弹出框图表没有单元格数据源,就不用一层层传下去了 +public enum ChartEditMode { + NORMAL, + DUCHAMP +} diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java b/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java index 1c4d927523..378e6a0d79 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java @@ -3,6 +3,7 @@ package com.fr.design.module; import com.fr.chart.web.ChartHyperPoplink; import com.fr.chart.web.ChartHyperRelateCellLink; import com.fr.chart.web.ChartHyperRelateFloatLink; +import com.fr.design.base.mode.DesignModeContext; import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperPoplinkPane; import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperRelateCellLinkPane; import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperRelateFloatLinkPane; @@ -58,7 +59,7 @@ public class ChartHyperlinkGroup extends BaseHyperlinkGroup { return false; } - if (template.isJWorkBook()) { + if (template.isJWorkBook() || DesignModeContext.isDuchampMode()) { // 如果是普通报表单元格,那么没有 FormHyperlink 选项 FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); //返回true表示可用,返回false表示不可用 @@ -93,7 +94,7 @@ public class ChartHyperlinkGroup extends BaseHyperlinkGroup { if (template == null) { return false; } - if (template.isJWorkBook()) { + if (template.isJWorkBook() || DesignModeContext.isDuchampMode()) { // 如果是普通报表单元格,那么没有 FormHyperlink 选项 FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); //返回true表示可用,返回false表示不可用 @@ -117,4 +118,4 @@ public class ChartHyperlinkGroup extends BaseHyperlinkGroup { } }; } -} +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleAction.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleAction.java index 61b9a8c4f5..e989e1a364 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleAction.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleAction.java @@ -16,6 +16,8 @@ import com.fr.transaction.WorkerFacade; import com.fr.van.chart.designer.component.VanChartFillStylePane; import javax.swing.KeyStroke; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.util.concurrent.ExecutorService; import java.awt.event.ActionEvent; @@ -43,6 +45,7 @@ public class ChartPreStyleAction extends UpdateAction { */ public void actionPerformed(ActionEvent e) { DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); + DesignerContext.getDesignerFrame().setServerConfig(true); final ChartPreStyleManagerPane pane = new ChartPreStyleManagerPane(); BasicDialog dialog = pane.showWindow(designerFrame); dialog.addDialogActionListener(new DialogActionAdapter() { @@ -79,7 +82,13 @@ public class ChartPreStyleAction extends UpdateAction { })); } }); - + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosed(WindowEvent e) { + super.windowClosed(e); + DesignerContext.getDesignerFrame().setServerConfig(false); + } + }); pane.populateBean(); dialog.setVisible(true); 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 index f2f5c3cf6f..433c7dfd00 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java @@ -8,13 +8,10 @@ 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; @@ -25,14 +22,6 @@ import java.util.Iterator; */ public class ChartPreStyleListPane extends JListControlPane { - ChartPreStyleManagerPane chartPreStyleManagerPane; - - public ChartPreStyleListPane(ChartPreStyleManagerPane chartPreStyleManagerPane) { - super(); - this.chartPreStyleManagerPane = chartPreStyleManagerPane; - initListener(); - } - /** * 创建有名字的creator * @@ -53,13 +42,7 @@ public class ChartPreStyleListPane extends JListControlPane { @Override public BasicBeanPane createPaneByCreators(NameableCreator creator) { - return new ChartPreStylePane() { - @Override - protected void refreshWhenStyleChange(ChartColorMatching preStyle) { - super.refreshWhenStyleChange(preStyle); - chartPreStyleManagerPane.refreshDefaultColorBox(); - } - }; + return new ChartPreStylePane(); } @@ -82,21 +65,6 @@ public class ChartPreStyleListPane extends JListControlPane { 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(); @@ -111,15 +79,10 @@ public class ChartPreStyleListPane extends JListControlPane { 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(); 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 98f3862dcc..26ee8f20e2 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 @@ -1,24 +1,10 @@ package com.fr.design.module; -import com.fr.base.ChartColorMatching; -import com.fr.base.ChartPreStyleConfig; -import com.fr.design.gui.icombobox.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 javax.swing.JPanel; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; import java.awt.BorderLayout; -import java.awt.Dimension; /** * 图表预定义管理 界面, 在工具栏-服务器管理中. @@ -28,8 +14,6 @@ import java.awt.Dimension; */ public class ChartPreStyleManagerPane extends BasicPane { - private ColorSchemeComboBox defaultColorBox; - private ChartPreStyleListPane chartPreStyleListPane; public ChartPreStyleManagerPane() { @@ -38,78 +22,20 @@ public class ChartPreStyleManagerPane extends BasicPane { 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); + chartPreStyleListPane = new ChartPreStyleListPane(); 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/extended/chart/AbstractExtendedChartUIProvider.java b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartUIProvider.java index a1a088020f..64b4808535 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartUIProvider.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartUIProvider.java @@ -14,10 +14,14 @@ import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPa import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +import static com.fr.design.chart.fun.ChartTypeUIProvider.CURRENT_API_LEVEL; /** * Created by shine on 2018/3/2. */ +@API(level = CURRENT_API_LEVEL) public abstract class AbstractExtendedChartUIProvider extends AbstractProvider implements ChartTypeUIProvider { protected abstract AbstractExtendedChartTableDataPane getTableDataSourcePane(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/area/AreaIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/area/AreaIndependentVanChartInterface.java index 23bd47004c..4fe84a35e3 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/area/AreaIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/area/AreaIndependentVanChartInterface.java @@ -2,10 +2,12 @@ package com.fr.van.chart.area; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.vanchart.AbstractMultiCategoryVanChartUI; /** @@ -47,7 +49,7 @@ public class AreaIndependentVanChartInterface extends AbstractMultiCategoryVanCh @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartAreaPlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartAreaPlotPane(); } public ConditionAttributesPane getPlotConditionPane(Plot plot){ diff --git a/designer-chart/src/main/java/com/fr/van/chart/bar/BarIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/bar/BarIndependentVanChartInterface.java index 63a8e7640c..542be966c7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bar/BarIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bar/BarIndependentVanChartInterface.java @@ -3,12 +3,14 @@ package com.fr.van.chart.bar; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; 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.ChartStylePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.column.VanChartColumnConditionPane; import com.fr.van.chart.column.VanChartColumnSeriesPane; import com.fr.van.chart.designer.other.VanChartInteractivePane; @@ -57,7 +59,7 @@ public class BarIndependentVanChartInterface extends AbstractMultiCategoryVanCha @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartBarPlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartBarPlotPane(); } public ConditionAttributesPane getPlotConditionPane(Plot plot) { 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 index e4906b6254..6e1d3d9712 100644 --- 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 @@ -3,6 +3,7 @@ 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.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; @@ -12,6 +13,7 @@ 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.design.mainframe.chart.mode.ChartEditContext; 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; @@ -56,7 +58,7 @@ public class BoxIndependentVanChartInterface extends AbstractIndependentVanChart } public AbstractChartTypePane getPlotTypePane() { - return new VanChartBoxPlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartBoxPlotPane(); } public ConditionAttributesPane getPlotConditionPane(Plot plot) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/bubble/BubbleIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/bubble/BubbleIndependentVanChartInterface.java index 985e811ac2..cc344d4f43 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bubble/BubbleIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bubble/BubbleIndependentVanChartInterface.java @@ -3,6 +3,7 @@ package com.fr.van.chart.bubble; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; @@ -13,6 +14,7 @@ import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPa import com.fr.design.mainframe.chart.gui.data.report.BubblePlotReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.plugin.chart.base.VanChartConstants; import com.fr.plugin.chart.bubble.VanChartBubblePlot; import com.fr.van.chart.bubble.data.VanChartBubblePlotTableDataContentPane; @@ -54,7 +56,7 @@ public class BubbleIndependentVanChartInterface extends AbstractIndependentVanCh */ @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartBubblePlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartBubblePlotPane(); } /** diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java index b83a20f612..27c5882221 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java @@ -71,9 +71,7 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane { //边框(有圆角) protected VanChartBorderPane createDiffBorderPane() { - return new VanChartBorderWithRadiusPane(); - //TODO Bjorn 边框自动回退 - //return new VanChartBorderWithRadiusPane(true); + return new VanChartBorderWithRadiusPane(true); } private JPanel createSeriesStylePane(double[] row, double[] col) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanColumnChartTypeUI.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanColumnChartTypeUI.java index 0d491f9046..a971a98a9a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/column/VanColumnChartTypeUI.java +++ b/designer-chart/src/main/java/com/fr/van/chart/column/VanColumnChartTypeUI.java @@ -2,10 +2,12 @@ package com.fr.van.chart.column; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.vanchart.AbstractMultiCategoryVanChartUI; /** @@ -48,7 +50,7 @@ public class VanColumnChartTypeUI extends AbstractMultiCategoryVanChartUI { @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartColumnPlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartColumnPlotPane(); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java index 47e6488fd6..dc55527406 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java @@ -60,7 +60,9 @@ public class VanChartCustomDataPane extends ChartDataPane { */ public void addAttributeChangeListener(AttributeChangeListener listener) { super.addAttributeChangeListener(listener); - contentsTabPane.addAttributeChangeListener(listener); + if (contentsTabPane != null) { + contentsTabPane.addAttributeChangeListener(listener); + } } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java index ff0147652a..c3dcf73909 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java @@ -3,15 +3,19 @@ package com.fr.van.chart.custom; import com.fr.base.chart.chartdata.TopDefinitionProvider; import com.fr.chart.base.DataSeriesCondition; import com.fr.chart.chartattr.Chart; +import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionCollection; +import com.fr.chartx.attr.ChartProvider; import com.fr.chartx.data.AbstractDataDefinition; import com.fr.chartx.data.ChartDataDefinitionProvider; import com.fr.chartx.data.CustomChartDataDefinition; +import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.type.ChartImagePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.VanChartAttrLine; @@ -28,12 +32,12 @@ import com.fr.van.chart.designer.type.AbstractVanChartTypePane; import javax.swing.JPanel; import javax.swing.JSeparator; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; import java.awt.CardLayout; import java.awt.Component; import java.awt.Dimension; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; /** * Created by Mitisky on 16/2/16. @@ -54,11 +58,27 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { //自定义和自动版面的容器,cardLayOut布局 private JPanel contentPane; + @Override + public boolean visible(ChartProvider chart) { + if (ChartEditContext.duchampMode() && chart instanceof VanChart) { + Plot plot = ((VanChart) chart).getPlot(); + + if (plot instanceof VanChartCustomPlot) { + CustomStyle customStyle = ((VanChartCustomPlot) plot).getCustomStyle(); + return customStyle == CustomStyle.CUSTOM; + } + } + return super.visible(chart); + } + protected Component[][] getPaneComponents(JPanel typePane) { initContent(); - return new Component[][]{ + return ChartEditContext.duchampMode() ? new Component[][]{ + new Component[]{contentPane}, + new Component[]{buttonPane}, + }: new Component[][]{ new Component[]{typePane}, new Component[]{stylePane}, new Component[]{contentPane}, diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomInteractivePane.java index f399d90e81..8aab51b3f8 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomInteractivePane.java @@ -1,7 +1,6 @@ package com.fr.van.chart.custom.other; import com.fr.chart.chartattr.Plot; - import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.plugin.chart.custom.type.CustomStyle; @@ -37,6 +36,9 @@ public class VanChartCustomInteractivePane extends VanChartInteractivePane { @Override protected void populateHyperlink(Plot plot) { + if (hyperlinkPane == null) { + return; + } hyperlinkPane.populateBean(chart); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java index 8502888bd3..395d615926 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java @@ -1,12 +1,9 @@ package com.fr.van.chart.designer.component; -import com.fr.base.FRContext; import com.fr.base.GraphHelper; -import com.fr.base.ScreenResolution; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.i18n.Toolkit; -import com.fr.general.FRFont; import com.fr.plugin.chart.type.LineType; import com.fr.stable.Constants; @@ -14,8 +11,6 @@ import javax.swing.JLabel; import javax.swing.JList; import java.awt.Component; import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; @@ -37,9 +32,9 @@ public class LineTypeComboBox extends UIComboBox { public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); this.lineType = (LineType) value; - comp.setText(null); + value = lineType == LineType.NONE ? Toolkit.i18nText("Fine-Design_Report_None") : null; + JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); return comp; } @@ -51,14 +46,6 @@ public class LineTypeComboBox extends UIComboBox { g2d.setColor(getForeground()); switch (this.lineType) { - case NONE: - FRFont font = FRContext.getDefaultValues().getFRFont(); - int resolution = ScreenResolution.getScreenResolution(); - Font rfont = font.applyResolutionNP(resolution); - g2d.setFont(rfont); - FontMetrics fm = GraphHelper.getFontMetrics(rfont); - GraphHelper.drawString(g2d, Toolkit.i18nText("Fine-Design_Report_None"), 4, (d.height - fm.getHeight()) / 2 + fm.getAscent()); - break; case SOLID: GraphHelper.drawLine(g2d, 4, d.height / 2, d.width - 8, d.height / 2); break; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java index 057675a0a7..42e33b89ca 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java @@ -26,16 +26,8 @@ public class VanChartFillStylePane extends ColorFillStylePane implements Designe DesignerContext.setDesignerBean(name, this); } - protected void styleSelectBoxChange() { - //TODO Bjorn 配色预定义回退 - //getCustomPane().setVisible(getStyleSelectBox().getSelectedIndex() != 0); - super.styleSelectBoxChange(); - } - protected ColorSchemeComboBox createColorSchemeComboBox() { - return new ColorSchemeComboBox(); - //TODO Bjorn 配色预定义回退 - //return new ColorSchemeComboBox(null, true); + return new ColorSchemeComboBox(null, true); } protected void initLayout() { @@ -63,21 +55,19 @@ public class VanChartFillStylePane extends ColorFillStylePane implements Designe } public void populateBean(AttrFillStyle condition) { - /* if (condition.isPredefinedStyle()) { + if (condition.isThemed()) { getStyleSelectBox().setSelectType(ColorSchemeComboBox.SelectType.DEFAULT); return; - }*/ - //TODO Bjorn 配色预定义回退 + } populateBean(condition.getColorFillStyle()); } public void updateBean(AttrFillStyle attrFillStyle) { - /* if (getStyleSelectBox().getSelectedIndex() == 0) { - attrFillStyle.setPredefinedStyle(true); + if (getStyleSelectBox().getSelectedIndex() == 0) { + attrFillStyle.setThemed(true); return; } - attrFillStyle.setPredefinedStyle(false);*/ - //TODO Bjorn 配色预定义回退 + attrFillStyle.setThemed(false); attrFillStyle.setColorFillStyle(updateBean()); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPane.java index e3bd8248f3..8133771f94 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPane.java @@ -1,10 +1,12 @@ package com.fr.van.chart.designer.component; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithThemeStyle; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.type.TextAlign; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; +import java.awt.BorderLayout; public class VanChartLabelContentPane extends VanChartTooltipContentPane { @@ -22,12 +24,11 @@ public class VanChartLabelContentPane extends VanChartTooltipContentPane { return new AttrTooltipContent(TextAlign.CENTER); } - //TODO Bjorn 标签面板回退 - /* public JPanel createCommonStylePane() { + public JPanel createCommonStylePane() { if (isInCondition()) { return super.createCommonStylePane(); } - setTextAttrPane(new ChartTextAttrPaneWithPreStyle()); + setTextAttrPane(new ChartTextAttrPaneWithThemeStyle()); JPanel stylePanel = new JPanel(new BorderLayout()); stylePanel.add(getTextAttrPane(), BorderLayout.CENTER); @@ -42,9 +43,9 @@ public class VanChartLabelContentPane extends VanChartTooltipContentPane { } if (hasTextStylePane()) { this.getTextAttrPane().update(attrTooltipContent.getTextAttr()); - if (!attrTooltipContent.getTextAttr().isPredefinedStyle()) { + if (!attrTooltipContent.getTextAttr().isThemed()) { attrTooltipContent.setCustom(true); } } - }*/ + } } 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 d7c590e642..12e242b731 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 @@ -632,7 +632,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane { double[] rowSize = {p, p, p, p, p, p, p}; - Component[][] components = new Component[][]{ + Component[][] components = ChartEditContext.normalMode() ? new Component[][]{ new Component[]{createToolBarPane(getToolBarRowSize(), columnSize), null}, //大数据模式 恢复用注释。取消注释。 //new Component[]{createLargeDataModePane(), null}, @@ -141,6 +142,11 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { new Component[]{createZoomPane(plot), null}, new Component[]{createAutoRefreshPane(plot), null}, new Component[]{createHyperlinkPane(), null} + } : new Component[][]{ + new Component[]{createToolBarPane(getToolBarRowSize(), columnSize), null}, + new Component[]{createAnimationPane(), null}, + new Component[]{createAxisRotationPane(new double[]{p, p}, columnSize, plot), null}, + new Component[]{createZoomPane(plot), null} }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); @@ -595,6 +601,9 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { protected void populateHyperlink(Plot plot) { + if (superLink == null) { + return; + } superLink.populate(plot); } @@ -634,7 +643,9 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { } protected void populateAutoRefresh(VanChart chart) { - VanChartPlot plot = chart.getPlot(); + if (autoRefreshPane == null) { + return; + } RefreshMoreLabel refreshMoreLabel = chart.getRefreshMoreLabel(); if (refreshMoreLabel == null) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/MapRangeLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/MapRangeLegendPane.java index 7e68f99423..805913fe7c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/MapRangeLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/MapRangeLegendPane.java @@ -20,8 +20,6 @@ public class MapRangeLegendPane extends VanChartRangeLegendPane { @Override protected VanChartBackgroundPane creatBackgroundPane() { - //TODO Bjorn 地图图例背景自动逻辑 - return new VanChartBackgroundWithOutImagePane(); - //return new VanChartBackgroundWithOutImagePane(true); + return new VanChartBackgroundWithOutImagePane(true); } } 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 4ba1abb7dc..f51d1d689a 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 @@ -15,6 +15,7 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithThemeStyle; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.plugin.chart.attr.VanChartLegend; import com.fr.plugin.chart.type.LayoutType; @@ -287,9 +288,7 @@ public class VanChartPlotLegendPane extends BasicPane { } private JPanel createTitleStylePane() { - //TODO Bjorn 图例预定义逻辑 - //textAttrPane = new ChartTextAttrPaneWithPreStyle(); - textAttrPane = new ChartTextAttrPane(); + textAttrPane = new ChartTextAttrPaneWithThemeStyle(); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), textAttrPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java index 10a313af7e..fd5e37890b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java @@ -17,7 +17,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; -import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithThemeStyle; import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.plugin.chart.attr.VanChartTitle; @@ -57,7 +57,7 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { private JPanel titlePane; private TinyFormulaPane titleContent; - private ChartTextAttrPane textAttrPane; + private ChartTextAttrPaneWithThemeStyle textAttrPane; private UIButtonGroup alignmentPane; private VanChartBackgroundWithOutShadowWithRadiusPane backgroundPane; private UIToggleButton useHtml; @@ -188,9 +188,7 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { } private JPanel createTitleStylePane() { - //TODO Bjorn 标题预定义逻辑 - //textAttrPane = new ChartTextAttrPaneWithPreStyle(); - textAttrPane = new ChartTextAttrPane(); + textAttrPane = new ChartTextAttrPaneWithThemeStyle(); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), textAttrPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitleWithAutoBackground.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitleWithAutoBackground.java index e126c53598..eb87f4363a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitleWithAutoBackground.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitleWithAutoBackground.java @@ -14,8 +14,6 @@ public class VanChartTitleWithAutoBackground extends VanChartTitlePane { } protected VanChartBackgroundWithOutShadowWithRadiusPane createBackgroundPane() { - //TODO Bjorn 地图标题背景自动逻辑 - //return new VanChartBackgroundWithOutShadowWithRadiusPane(true); - return new VanChartBackgroundWithOutShadowWithRadiusPane(); + return new VanChartBackgroundWithOutShadowWithRadiusPane(true); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java index 9fb0c7e31e..f945a19699 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java @@ -20,7 +20,8 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; -import com.fr.design.style.color.ColorSelectBox; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithThemeStyle; +import com.fr.design.mainframe.chart.gui.style.ColorSelectBoxWithThemeStyle; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.plugin.chart.attr.axis.VanChartAxis; @@ -85,9 +86,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { protected LineComboBox axisLineStyle; - //TODO Bjorn 坐标轴面板回退 - protected ColorSelectBox axisLineColor; - //protected ColorSelectBoxWithPreStyle axisLineColor; + protected ColorSelectBoxWithThemeStyle axisLineColor; protected UIButtonGroup mainTick; protected UIButtonGroup secondTick; @@ -381,31 +380,16 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { } protected ChartTextAttrPane getChartTextAttrPane() { - //TODO Bjorn 坐标轴面板回退 - /* return new ChartTextAttrPaneWithPreStyle() { + return new ChartTextAttrPaneWithThemeStyle() { protected double getEdithAreaWidth() { return TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; } - };*/ - return new ChartTextAttrPane() { - @Override - protected JPanel getContentPane(JPanel buttonPane) { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; - double[] columnSize = {f, e}; - double[] rowSize = {p, p, p}; - - return TableLayout4VanChartHelper.createGapTableLayoutPane(getComponents(buttonPane), rowSize, columnSize); - } }; } protected JPanel createLineStylePane(double[] row, double[] col) { axisLineStyle = createLineComboBox(); - //TODO Bjorn 坐标轴面板回退 - //axisLineColor = new ColorSelectBoxWithPreStyle(100); - axisLineColor = new ColorSelectBox(100); + axisLineColor = new ColorSelectBoxWithThemeStyle(100); String[] strings = new String[]{Toolkit.i18nText("Fine-Design_Chart_Open"), Toolkit.i18nText("Fine-Design_Chart_Close")}; AxisTickLineType[] values = new AxisTickLineType[]{AxisTickLineType.TICK_LINE_OUTSIDE, AxisTickLineType.TICK_LINE_NONE}; mainTick = new UIButtonGroup(strings, values); @@ -423,9 +407,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { return new Component[][]{ new Component[]{null, null}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Type")), axisLineStyle}, - //TODO Bjorn 坐标轴面板回退 - //new Component[]{axisLineColor, null}, - new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), axisLineColor}, + new Component[]{axisLineColor, null}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Main_Graduation_Line")), mainTick}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Second_Graduation_Line")), secondTick}, }; @@ -735,9 +717,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { axisLineStyle.setSelectedLineStyle(axis.getAxisStyle()); } if (axisLineColor != null) { - axisLineColor.setSelectObject(axis.getAxisColor()); - //TODO Bjorn 坐标轴面板回退 - //axisLineColor.populate(axis.getLineColorWithPreStyle()); + axisLineColor.populate(axis.getLineColorWithPreStyle()); } if (mainTick != null) { mainTick.setSelectedItem(axis.getMainTickLine()); @@ -880,9 +860,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { axis.setAxisStyle(axisLineStyle.getSelectedLineStyle()); } if (axisLineColor != null) { - axis.setAxisColor(axisLineColor.getSelectObject()); - //TODO Bjorn 坐标轴面板回退 - //axis.setLineColorWithPreStyle(axisLineColor.update()); + axis.setLineColorWithPreStyle(axisLineColor.update()); } if (mainTick != null) { axis.setMainTickLine(mainTick.getSelectedItem()); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java index cd6c4fcf63..18fadeb985 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java @@ -8,6 +8,7 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithAuto; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithThemeStyle; import com.fr.design.style.color.ColorSelectBox; import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.axis.VanChartGaugeAxis; @@ -102,9 +103,7 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane { if (isMulti(gaugeStyle)) { return new ChartTextAttrPaneWithAuto(FontAutoType.SIZE_AND_COLOR); } else { - return new ChartTextAttrPane(); - //TODO Bjorn 坐标轴面板回退 - //return new ChartTextAttrPaneWithPreStyle(); + return new ChartTextAttrPaneWithThemeStyle(); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarXAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarXAxisPane.java index 309a7daa66..3558443c4f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarXAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarXAxisPane.java @@ -46,9 +46,7 @@ public class VanChartRadarXAxisPane extends VanChartBaseAxisPane { return new Component[][]{ new Component[]{null,null} , new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Type")), axisLineStyle}, - //TODO Bjorn 坐标轴面板回退 - //new Component[]{axisLineColor, null}, - new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), axisLineColor}, + new Component[]{axisLineColor, null}, }; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarYAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarYAxisPane.java index cf4ffb3864..0015676882 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarYAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/radar/VanChartRadarYAxisPane.java @@ -90,9 +90,7 @@ public class VanChartRadarYAxisPane extends VanChartValueAxisPane { return new Component[][]{ new Component[]{null, null}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Type")), axisLineStyle}, - //TODO Bjorn 坐标轴面板回退 - //new Component[]{axisLineColor, null}, - new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), axisLineColor}, + new Component[]{axisLineColor, null}, }; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java index 19f5d40510..6f65af6e15 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaBackgroundPane.java @@ -11,6 +11,7 @@ import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.van.chart.designer.AbstractVanChartScrollPane; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.background.VanChartBackgroundPane; +import com.fr.van.chart.designer.component.background.VanChartBackgroundPaneWithThemeStyle; import com.fr.van.chart.designer.component.border.VanChartBorderWithRadiusPane; import com.fr.van.chart.designer.style.background.radar.VanChartRadarAxisAreaPane; @@ -45,13 +46,11 @@ public class VanChartAreaBackgroundPane extends AbstractVanChartScrollPane { private LineTypeComboBox horizonLineType; private LineTypeComboBox verticalLineType; - private ColorSelectBox horizontalColorBox; - private ColorSelectBox verticalColorBox; - //TODO Bjorn 背景坐标轴面板回退 - /* private ColorSelectBoxWithPreStyle horizontalColorBox; - private ColorSelectBoxWithPreStyle verticalColorBox;*/ + private ColorSelectBoxWithThemeStyle horizontalColorBox; + private ColorSelectBoxWithThemeStyle verticalColorBox; private JPanel horizontalColorPane; private JPanel verticalColorPane; @@ -56,11 +54,8 @@ public class VanChartAxisAreaPane extends BasicBeanPane { } private void initComponents() { - horizontalColorBox = new ColorSelectBox(PREFERRED_WIDTH); - verticalColorBox = new ColorSelectBox(PREFERRED_WIDTH); - //TODO Bjorn 背景坐标轴面板回退 - /* horizontalColorBox = new ColorSelectBoxWithPreStyle(PREFERRED_WIDTH); - verticalColorBox = new ColorSelectBoxWithPreStyle(PREFERRED_WIDTH);*/ + horizontalColorBox = new ColorSelectBoxWithThemeStyle(PREFERRED_WIDTH); + verticalColorBox = new ColorSelectBoxWithThemeStyle(PREFERRED_WIDTH); horizonLineType = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.SOLID, LineType.DASHED}); verticalLineType = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.SOLID, LineType.DASHED}); @@ -93,18 +88,15 @@ public class VanChartAxisAreaPane extends BasicBeanPane { } protected void initGridLineComponents() { - //TODO Bjorn 背景坐标轴面板回退 Component[][] upComponent = new Component[][]{ new Component[]{null, null}, - new Component[]{null, horizontalColorBox} - //new Component[]{horizontalColorBox, null} + new Component[]{horizontalColorBox, null} }; horizontalColorPane = TableLayout4VanChartHelper.createGapTableLayoutPane(upComponent); Component[][] downComponent = new Component[][]{ new Component[]{null, null}, - new Component[]{null, verticalColorBox} - //new Component[]{verticalColorBox, null} + new Component[]{verticalColorBox, null} }; verticalColorPane = TableLayout4VanChartHelper.createGapTableLayoutPane(downComponent); @@ -228,16 +220,13 @@ public class VanChartAxisAreaPane extends BasicBeanPane { VanChartAxis defaultXAxis = rectanglePlot.getDefaultXAxis(); VanChartAxis defaultYAxis = rectanglePlot.getDefaultYAxis(); - //TODO Bjorn 背景坐标轴面板回退 if (defaultXAxis != null) { - //verticalColorBox.populate(defaultXAxis.getMainGridColorWithPreStyle()); - verticalColorBox.setSelectObject(defaultXAxis.getMainGridColor()); + verticalColorBox.populate(defaultXAxis.getMainGridColorWithPreStyle()); verticalLineType.setSelectedItem(defaultXAxis.getGridLineType()); } if (defaultYAxis != null) { - //horizontalColorBox.populate(defaultYAxis.getMainGridColorWithPreStyle()); - horizontalColorBox.setSelectObject(defaultYAxis.getMainGridColor()); + horizontalColorBox.populate(defaultYAxis.getMainGridColorWithPreStyle()); horizonLineType.setSelectedItem(defaultYAxis.getGridLineType()); } } @@ -264,16 +253,13 @@ public class VanChartAxisAreaPane extends BasicBeanPane { VanChartAxis defaultXAxis = rectanglePlot.getDefaultXAxis(); VanChartAxis defaultYAxis = rectanglePlot.getDefaultYAxis(); - //TODO Bjorn 背景坐标轴面板回退 if (defaultXAxis != null) { - //defaultXAxis.setMainGridColorWithPreStyle(verticalColorBox.update()); - defaultXAxis.setMainGridColor(verticalColorBox.getSelectObject()); + defaultXAxis.setMainGridColorWithPreStyle(verticalColorBox.update()); defaultXAxis.setGridLineType((LineType) verticalLineType.getSelectedItem()); } if (defaultYAxis != null) { - //defaultYAxis.setMainGridColorWithPreStyle(horizontalColorBox.update()); - defaultYAxis.setMainGridColor(horizontalColorBox.getSelectObject()); + defaultYAxis.setMainGridColorWithPreStyle(horizontalColorBox.update()); defaultYAxis.setGridLineType((LineType) horizonLineType.getSelectedItem()); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanChartDataSheetPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanChartDataSheetPane.java index d6fa66bfb5..83b65d01e9 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanChartDataSheetPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanChartDataSheetPane.java @@ -10,6 +10,7 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithThemeStyle; import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.VanChartAttrHelper; @@ -19,6 +20,7 @@ import com.fr.plugin.chart.type.AxisType; import com.fr.van.chart.designer.AbstractVanChartScrollPane; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.border.VanChartBorderPane; +import com.fr.van.chart.designer.component.border.VanChartBorderPaneWithPreStyle; import com.fr.van.chart.designer.component.format.FormatPaneWithNormalType; import javax.swing.JPanel; @@ -103,15 +105,12 @@ public class VanChartDataSheetPane extends AbstractVanChartScrollPane { return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); } - //TODO Bjorn 数据表面板回退 protected VanChartBorderPane createBorderPanePane() { - return new VanChartBorderPane(); - //return new VanChartBorderPaneWithPreStyle(); + return new VanChartBorderPaneWithPreStyle(); } protected ChartTextAttrPane createChartTextAttrPane() { - return new ChartTextAttrPane(); - //return new ChartTextAttrPaneWithPreStyle(); + return new ChartTextAttrPaneWithThemeStyle(); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java index 3d6ad86e88..d8c3217380 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java @@ -49,11 +49,6 @@ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabe return getGaugeStyle() == GaugeStyle.RING || getGaugeStyle() == GaugeStyle.SLOT; } - //TODO Bjorn 仪表盘自动逻辑 - protected boolean isFontColorAuto() { - return getGaugeStyle() == GaugeStyle.RING || getGaugeStyle() == GaugeStyle.SLOT; - } - protected boolean hasLabelPosition(Plot plot) { switch (getGaugeStyle()) { case RING: diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java index 8c672bab62..0f9e84729d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java @@ -79,10 +79,8 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { return false; } - //TODO Bjorn 仪表盘自动逻辑 protected boolean isFontColorAuto() { - return false; - //return true; + return true; } private FontAutoType getFontAutoType() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java index 849507e059..0a5f7b8feb 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java @@ -271,9 +271,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP } protected VanChartBorderPane createDiffBorderPane() { - return new VanChartBorderPane(); - //TODO Bjorn 边框自动回退 - //return new VanChartBorderPane(true); + return new VanChartBorderPane(true); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/other/VanChartDrillMapInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/other/VanChartDrillMapInteractivePane.java index c7386ed0a4..80962fd86b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/other/VanChartDrillMapInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/other/VanChartDrillMapInteractivePane.java @@ -6,7 +6,9 @@ import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.drillmap.VanChartDrillMapPlot; import com.fr.plugin.chart.vanchart.VanChart; @@ -39,13 +41,18 @@ public class VanChartDrillMapInteractivePane extends VanChartInteractivePaneWith double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double[] columnSize = {f, e}; double[] rowSize = {p, p, p, p, p, p, p, p, p, p, p}; - Component[][] components = new Component[][]{ + Component[][] components = ChartEditContext.normalMode() ? new Component[][]{ new Component[]{createToolBarPane(new double[]{p, p, p}, columnSize), null}, new Component[]{createAnimationPane(), null}, new Component[]{createZoomPane(plot), null}, new Component[]{createDrillToolsPane(), null}, new Component[]{createAutoRefreshPane(plot), null}, new Component[]{createHyperlinkPane(), null} + } : new Component[][]{ + new Component[]{createToolBarPane(new double[]{p, p, p}, columnSize), null}, + new Component[]{createAnimationPane(), null}, + new Component[]{createZoomPane(plot), null}, + new Component[]{createDrillToolsPane(), null} }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); @@ -75,15 +82,13 @@ public class VanChartDrillMapInteractivePane extends VanChartInteractivePaneWith } }; - //TODO Bjorn 钻取地图钻取目录背景自动逻辑 - /*backgroundPane = new VanChartBackgroundPaneWithOutImageAndShadow(true) { + backgroundPane = new VanChartBackgroundPaneWithOutImageAndShadow(true) { @Override protected void initList() { paneList.add(new ColorBackgroundQuickPane()); } - };*/ + }; - backgroundPane = new VanChartBackgroundPaneWithOutImageAndShadow(); selectBackgroundPane = new VanChartBackgroundPaneWithOutImageAndShadow() { protected String labelName() { return Toolkit.i18nText("Fine-Design_Chart_Select_Color"); diff --git a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/FunnelIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/FunnelIndependentVanChartInterface.java index 2899a9e117..b76f9047df 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/FunnelIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/FunnelIndependentVanChartInterface.java @@ -3,6 +3,7 @@ package com.fr.van.chart.funnel.designer; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; @@ -13,6 +14,7 @@ import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPa import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.PiePlotTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.designer.data.OneDimensionalPlotReportDataContentPane; import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.van.chart.designer.other.VanChartOtherPane; @@ -45,7 +47,7 @@ public class FunnelIndependentVanChartInterface extends AbstractIndependentVanCh */ @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartFunnelTypePane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartFunnelTypePane(); } public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent){ diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/GanttIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/GanttIndependentVanChartInterface.java index 9bc3ce1232..839e049dd1 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/GanttIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/GanttIndependentVanChartInterface.java @@ -3,6 +3,7 @@ package com.fr.van.chart.gantt.designer; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; @@ -12,6 +13,7 @@ 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.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.designer.other.VanChartOtherPane; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.gantt.designer.data.VanChartGanttDataPane; @@ -42,7 +44,7 @@ public class GanttIndependentVanChartInterface extends AbstractIndependentVanCha @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartGanttPlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartGanttPlotPane(); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/gauge/GaugeIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/gauge/GaugeIndependentVanChartInterface.java index 1e7a6fb322..7c424aa55b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gauge/GaugeIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gauge/GaugeIndependentVanChartInterface.java @@ -2,6 +2,7 @@ package com.fr.van.chart.gauge; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.AbstractChartAttrPane; @@ -14,6 +15,7 @@ import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane import com.fr.design.mainframe.chart.gui.data.table.CategoryPlotTableDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.MeterPlotTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.plugin.chart.gauge.VanChartGaugePlot; import com.fr.van.chart.custom.component.CategoryCustomPlotTableDataContentPane; import com.fr.van.chart.custom.component.MeterCustomPlotReportDataContentPane; @@ -61,7 +63,7 @@ public class GaugeIndependentVanChartInterface extends AbstractIndependentVanCha @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartGaugePlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartGaugePlotPane(); } public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java index afdd2d4ca9..49e4391b55 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java @@ -78,8 +78,7 @@ public class VanChartGaugeSeriesPane extends VanChartMultiColorSeriesPane { double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double[] columnSize = {f}; - //TODO Bjorn - double[] rowSize = {p, p, p, p, p, p, p}; + double[] rowSize = {p, p, p, p, p, p, p, p, p, p}; Component[][] components = new Component[][]{ new Component[]{createGaugeLayoutPane()}, new Component[]{createGaugeStylePane(rowSize, new double[]{f, e})}, @@ -132,6 +131,10 @@ public class VanChartGaugeSeriesPane extends VanChartMultiColorSeriesPane { return 10; } + protected int getPreferredMarginY() { + return 10; + } + protected double getDescriptionWidth() { double descriptionWidth = super.getDescriptionWidth(); if (valueFillStylePane == null) { @@ -221,14 +224,12 @@ public class VanChartGaugeSeriesPane extends VanChartMultiColorSeriesPane { private Component[][] getDiffComponentsWithGaugeStyle() { GaugeStyle style = getGaugeStyle(); switch (style) { - //TODO Bjorn 仪表盘样式自动逻辑 case RING: initRotate(); return new Component[][]{ new Component[]{null, null}, - getPaneBackgroundColor(), - /* getPaneBackgroundColorAuto(), - new Component[]{null, paneBackgroundColor},*/ + getPaneBackgroundColorAuto(), + new Component[]{null, paneBackgroundColor}, getInnerPaneBackgroundColor(), new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Radius_Set")), null}, getChutePercent() @@ -237,9 +238,8 @@ public class VanChartGaugeSeriesPane extends VanChartMultiColorSeriesPane { return new Component[][]{ new Component[]{null, null}, getNeedleColor(), - getSlotBackgroundColor(), - /* getSlotBackgroundColorAuto(), - new Component[]{null, slotBackgroundColor},*/ + getSlotBackgroundColorAuto(), + new Component[]{null, slotBackgroundColor}, new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Radius_Set")), null}, getChutePercent() }; @@ -247,33 +247,25 @@ public class VanChartGaugeSeriesPane extends VanChartMultiColorSeriesPane { return new Component[][]{ new Component[]{null, null}, getNeedleColor(), - getSlotBackgroundColor(), - /*getSlotBackgroundColorAuto(), - new Component[]{null, slotBackgroundColor},*/ + getSlotBackgroundColorAuto(), + new Component[]{null, slotBackgroundColor}, new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Length_Set")), null}, getThermometerWidth() }; default: return new Component[][]{ new Component[]{null, null}, - getHingeColor(), - /* getHingeColorAuto(), - new Component[]{null, hingeColor},*/ + getHingeColorAuto(), + new Component[]{null, hingeColor}, getHingeBackgroundColor(), getNeedleColor(), - getPaneBackgroundColor(), - /* getPaneBackgroundColorAuto(), - new Component[]{null, paneBackgroundColor},*/ + getPaneBackgroundColorAuto(), + new Component[]{null, paneBackgroundColor}, new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Radius_Set")), null} }; } } - private Component[] getHingeColor() { - hingeColor = new ColorSelectBox(120); - return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Hinge")), hingeColor}; - } - private Component[] getHingeColorAuto() { hingeColor = new ColorSelectBox(120); hingeColorAuto = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Auto"), diff --git a/designer-chart/src/main/java/com/fr/van/chart/line/LineIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/line/LineIndependentVanChartInterface.java index 739e87f14f..58252a74b0 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/line/LineIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/line/LineIndependentVanChartInterface.java @@ -2,10 +2,12 @@ package com.fr.van.chart.line; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.vanchart.AbstractMultiCategoryVanChartUI; /** @@ -42,7 +44,7 @@ public class LineIndependentVanChartInterface extends AbstractMultiCategoryVanCh @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartLinePlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartLinePlotPane(); } public ConditionAttributesPane getPlotConditionPane(Plot plot){ diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java index a2adff77a7..073002642b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java @@ -337,9 +337,7 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { } protected JPanel createAreaPane() { - //TODO Bjorn 地图背景自动 - //borderWithAlphaPane = new VanChartBorderWithAlphaPane(true); - borderWithAlphaPane = new VanChartBorderWithAlphaPane(); + borderWithAlphaPane = new VanChartBorderWithAlphaPane(true); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; @@ -355,8 +353,7 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { } protected JPanel createNullValueColorPane() { - //TODO Bjorn 地图空值背景自动 - /* nullValueAuto = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Auto"), + nullValueAuto = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Auto"), Toolkit.i18nText("Fine-Design_Chart_Custom")}); initNullValueListener(); nullValueColorBox = new ColorSelectBox(80); @@ -373,10 +370,7 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { new Component[]{text, nullValueAuto}, new Component[]{null, nullValueColorBox}, }; - return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize);*/ - - nullValueColorBox = new ColorSelectBox(80); - return TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_NULL_Value_Color"), nullValueColorBox); + return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); } @@ -593,15 +587,13 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { markerTypeCom.setSelectedItem(mapPlot.getMapMarkerType().toLocalString()); } if (nullValueColorBox != null) { - //TODO Bjorn 地图空值背景自动 - /* if (((VanChartMapPlot) plot).isAutoNullValue()) { + if (((VanChartMapPlot) plot).isAutoNullValue()) { nullValueAuto.setSelectedIndex(0); } else { nullValueAuto.setSelectedIndex(1); } nullValueColorBox.setSelectObject(((VanChartMapPlot) plot).getNullValueColor()); - checkNullValueButton();*/ - nullValueColorBox.setSelectObject(mapPlot.getNullValueColor()); + checkNullValueButton(); } //大数据模式 恢复用注释。下面3行删除。 if (lineMapLargeDataModelGroup != null) { @@ -623,8 +615,7 @@ public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { } } if (nullValueColorBox != null) { - //TODO Bjorn 地图空值背景自动 - //((VanChartMapPlot) plot).setAutoNullValue(nullValueAuto.getSelectedIndex() == 0); + ((VanChartMapPlot) plot).setAutoNullValue(nullValueAuto.getSelectedIndex() == 0); mapPlot.setNullValueColor(nullValueColorBox.getSelectObject()); } //大数据模式 恢复用注释。下面3行删除。 diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java index 0f89fed693..a6ede0df7e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java @@ -27,6 +27,9 @@ public class VanChartMapInteractivePane extends VanChartInteractivePaneWithMapZo @Override protected void populateHyperlink(Plot plot) { + if (hyperlinkPane == null) { + return; + } hyperlinkPane.populateBean(plot); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GisLayerPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GisLayerPane.java index 4a43d7619e..580144ce54 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GisLayerPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GisLayerPane.java @@ -73,12 +73,17 @@ public class GisLayerPane extends JPanel implements UIObserver { } private boolean isStandardGis() { + return gisButton.getSelectedIndex() == 1; + } + + private boolean isAuto() { return gisButton.getSelectedIndex() == 0; } private JPanel createGISLayerPane() { - gisButton = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Form_Widget_Style_Standard"), Toolkit.i18nText("Fine-Design_Chart_Custom")}); + gisButton = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Mode_Auto"), + Toolkit.i18nText("Fine-Design_Form_Widget_Style_Standard"), Toolkit.i18nText("Fine-Design_Chart_Custom")}); gisButton.setSelectedIndex(0); gisGaoDeLayer = new UIComboBox(MapLayerConfigManager.getGaoDeLayerItems()); gisButton.addActionListener(event -> { @@ -94,6 +99,9 @@ public class GisLayerPane extends JPanel implements UIObserver { layerPaneCheckPane = new JPanel(new CardLayout()) { @Override public Dimension getPreferredSize() { + if (isAuto()) { + return new Dimension(0, 0); + } if (isStandardGis()) { return gisGaoDeLayer.getPreferredSize(); } else { @@ -101,6 +109,7 @@ public class GisLayerPane extends JPanel implements UIObserver { } } }; + layerPaneCheckPane.add(new JPanel(), "auto"); layerPaneCheckPane.add(gisGaoDeLayer, "standard"); layerPaneCheckPane.add(gisLayer, "custom"); @@ -129,7 +138,7 @@ public class GisLayerPane extends JPanel implements UIObserver { layerCardPane = new JPanel(new CardLayout()) { @Override public Dimension getPreferredSize() { - if (isStandardGis()) { + if (isStandardGis() || isAuto()) { return new Dimension(0, 0); } String itemName = Utils.objectToString(gisLayer.getSelectedItem()); @@ -188,7 +197,9 @@ public class GisLayerPane extends JPanel implements UIObserver { private void refreshZoomLevel() { //gis图层不同,对应的缩放等级不同。 ZoomLevel[] levels; - if (isStandardGis()) { + if (isAuto()) { + levels = MapStatusPane.ZOOM_LEVELS; + } else if (isStandardGis()) { if (gisGaoDeLayer.getSelectedIndex() == gisGaoDeLayer.getItemCount() - 1) { levels = MapStatusPane.ZOOM_LEVELS; } else { @@ -209,7 +220,14 @@ public class GisLayerPane extends JPanel implements UIObserver { private void checkLayerCardPane() { CardLayout cardLayout = (CardLayout) layerPaneCheckPane.getLayout(); - cardLayout.show(layerPaneCheckPane, isStandardGis() ? "standard" : "custom"); + if (isAuto()) { + cardLayout.show(layerPaneCheckPane, "auto"); + } else if (isStandardGis()) { + cardLayout.show(layerPaneCheckPane, "standard"); + } else { + cardLayout.show(layerPaneCheckPane, "custom"); + } + } private void checkCustomLayerCardPane() { @@ -218,10 +236,6 @@ public class GisLayerPane extends JPanel implements UIObserver { } public void resetGisLayer(VanChartMapPlot mapPlot) { - //TODO Bjorn 地图gis图层自动逻辑 - /* mapPlot.getGisLayer().setGisLayerType(GISLayerType.AUTO); - mapPlot.getGisLayer().setLayerName(GISLayerType.getLocString(GISLayerType.AUTO));*/ - GisLayer defaultGisLayer = mapPlot.getDefaultGisLayer(); mapPlot.setGisLayer(defaultGisLayer); populate(defaultGisLayer); @@ -229,6 +243,9 @@ public class GisLayerPane extends JPanel implements UIObserver { public void populate(GisLayer layer) { switch (layer.getGisLayerType()) { + case AUTO: + gisButton.setSelectedIndex(0); + break; case GAO_DE_API: case LAYER_NULL: populateStandardGis(layer); @@ -243,7 +260,7 @@ public class GisLayerPane extends JPanel implements UIObserver { } private void populateStandardGis(GisLayer layer) { - gisButton.setSelectedIndex(0); + gisButton.setSelectedIndex(1); if (layer.getGisLayerType() == GISLayerType.LAYER_NULL) { gisGaoDeLayer.setSelectedIndex(gisGaoDeLayer.getItemCount() - 1); } else { @@ -252,7 +269,7 @@ public class GisLayerPane extends JPanel implements UIObserver { } private void populateCustomGis(GisLayer layer) { - gisButton.setSelectedIndex(1); + gisButton.setSelectedIndex(2); gisLayer.setSelectedItem(layer.getShowItemName()); switch (layer.getGisLayerType()) { @@ -266,7 +283,10 @@ public class GisLayerPane extends JPanel implements UIObserver { } public void update(GisLayer layer) { - if (isStandardGis()) { + if (isAuto()) { + layer.setGisLayerType(GISLayerType.AUTO); + layer.setLayerName(GISLayerType.getLocString(GISLayerType.AUTO)); + } else if (isStandardGis()) { updateStandardGis(layer); } else { updateCustomGis(layer); diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java index 9b5636e402..1bdb8d36ce 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java @@ -7,6 +7,7 @@ import com.fr.chartx.data.ChartDataDefinitionProvider; import com.fr.chartx.data.MapChartDataDefinition; import com.fr.design.mainframe.chart.gui.type.ChartImagePane; import com.fr.design.mainframe.chart.info.ChartInfoCollector; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.attr.plot.VanChartPlot; @@ -21,9 +22,9 @@ import com.fr.plugin.chart.vanchart.VanChart; import com.fr.van.chart.designer.type.AbstractVanChartTypePane; import javax.swing.JPanel; +import java.awt.Component; import java.util.HashSet; import java.util.Set; -import java.awt.Component; /** * Created by Mitisky on 16/5/4. @@ -55,7 +56,9 @@ public class VanChartMapPlotPane extends AbstractVanChartTypePane { } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } - return new Component[][]{ + return ChartEditContext.duchampMode() ? new Component[][]{ + new Component[]{sourceChoosePane} + } : new Component[][]{ new Component[]{typePane}, new Component[]{buttonPane}, new Component[]{sourceChoosePane} diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java index 1cc66a2bf5..a5da06312a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java @@ -2,6 +2,7 @@ package com.fr.van.chart.multilayer; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.ChartDataPane; @@ -9,6 +10,7 @@ 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.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.multilayer.data.MultiPiePlotReportDataContentPane; import com.fr.van.chart.multilayer.data.MultiPiePlotTableDataContentPane; import com.fr.van.chart.multilayer.other.VanChartMultiPieConditionPane; @@ -21,7 +23,7 @@ import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; public class MultiPieIndependentVanChartInterface extends AbstractIndependentVanChartUI { @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartMultiPiePlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartMultiPiePlotPane(); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/pie/PieIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/pie/PieIndependentVanChartInterface.java index 06841c0c92..7ede0ad462 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/pie/PieIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/pie/PieIndependentVanChartInterface.java @@ -2,6 +2,7 @@ package com.fr.van.chart.pie; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.ChartDataPane; @@ -9,6 +10,7 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.CategoryPlotTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.custom.component.CategoryCustomPlotTableDataContentPane; import com.fr.van.chart.custom.component.VanChartDataPane; import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; @@ -50,7 +52,7 @@ public class PieIndependentVanChartInterface extends AbstractIndependentVanChart @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartPiePlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartPiePlotPane(); } public ConditionAttributesPane getPlotConditionPane(Plot plot){ diff --git a/designer-chart/src/main/java/com/fr/van/chart/radar/RadarIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/radar/RadarIndependentVanChartInterface.java index 21784c522b..3f13cef0e8 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/radar/RadarIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/radar/RadarIndependentVanChartInterface.java @@ -2,10 +2,12 @@ package com.fr.van.chart.radar; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; /** @@ -40,7 +42,7 @@ public class RadarIndependentVanChartInterface extends AbstractIndependentVanCha @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartRadarPlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartRadarPlotPane(); } public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot){ diff --git a/designer-chart/src/main/java/com/fr/van/chart/range/component/LegendGradientBar.java b/designer-chart/src/main/java/com/fr/van/chart/range/component/LegendGradientBar.java index 8401f86a9c..6096056a4b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/range/component/LegendGradientBar.java +++ b/designer-chart/src/main/java/com/fr/van/chart/range/component/LegendGradientBar.java @@ -274,7 +274,8 @@ public class LegendGradientBar extends JComponent implements ColorSelectable, UI private void dealClick(SelectColorPointBtn selectColorPointBtn) { ColorSelectDetailPane pane = new ColorSelectDetailPane(Color.WHITE); this.setColor(selectColorPointBtn.getColorInner()); - ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, LegendGradientBar.this); + Color selectColor = selectColorPointBtn.getColorInner() == null ? Color.WHITE : selectColorPointBtn.getColorInner(); + ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, selectColor, LegendGradientBar.this); Color color = this.getColor(); if (color != null) { DesignerEnvManager.getEnvManager().getColorConfigManager().addToColorQueue(color); diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/ScatterIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/ScatterIndependentVanChartInterface.java index 1b7063af4d..444a36ae5a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/ScatterIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/ScatterIndependentVanChartInterface.java @@ -4,6 +4,7 @@ package com.fr.van.chart.scatter; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; @@ -14,6 +15,7 @@ import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPa import com.fr.design.mainframe.chart.gui.data.report.BubblePlotReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.van.chart.designer.other.VanChartOtherPane; import com.fr.van.chart.designer.other.zoom.ZoomPane; @@ -33,7 +35,7 @@ public class ScatterIndependentVanChartInterface extends AbstractIndependentVanC */ @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartScatterPlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartScatterPlotPane(); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterLabelContentPane.java index 9c79f9b8cd..364b3d1feb 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterLabelContentPane.java @@ -1,10 +1,13 @@ package com.fr.van.chart.scatter; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithThemeStyle; +import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.van.chart.designer.component.VanChartHtmlLabelPane; import com.fr.van.chart.designer.component.VanChartHtmlLabelPaneWithBackGroundLabel; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; +import java.awt.BorderLayout; /** * 散点图标签界面 @@ -21,12 +24,11 @@ public class VanChartScatterLabelContentPane extends VanChartScatterTooltipCont return new VanChartHtmlLabelPaneWithBackGroundLabel(); } - //TODO Bjorn 散点图标签预定义样式 - /* public JPanel createCommonStylePane() { + public JPanel createCommonStylePane() { if (isInCondition()) { return super.createCommonStylePane(); } - setTextAttrPane(new ChartTextAttrPaneWithPreStyle()); + setTextAttrPane(new ChartTextAttrPaneWithThemeStyle()); JPanel stylePanel = new JPanel(new BorderLayout()); stylePanel.add(getTextAttrPane(), BorderLayout.CENTER); @@ -41,9 +43,9 @@ public class VanChartScatterLabelContentPane extends VanChartScatterTooltipCont } if (hasTextStylePane()) { this.getTextAttrPane().update(attrTooltipContent.getTextAttr()); - if (!attrTooltipContent.getTextAttr().isPredefinedStyle()) { + if (!attrTooltipContent.getTextAttr().isThemed()) { attrTooltipContent.setCustom(true); } } - }*/ + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/VanStructureChartTypeUI.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/VanStructureChartTypeUI.java index 8109adeb0c..6733b8dbda 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/VanStructureChartTypeUI.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/VanStructureChartTypeUI.java @@ -3,6 +3,7 @@ package com.fr.van.chart.structure.desinger; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; @@ -12,6 +13,7 @@ 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.design.mainframe.chart.mode.ChartEditContext; import com.fr.plugin.chart.base.VanChartConstants; import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.van.chart.designer.other.VanChartOtherPane; @@ -31,7 +33,7 @@ import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; public class VanStructureChartTypeUI extends AbstractIndependentVanChartUI { @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartStructureTypePane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartStructureTypePane(); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/treemap/TreeMapIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/treemap/TreeMapIndependentVanChartInterface.java index 2b6589ed84..390a039197 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/treemap/TreeMapIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/treemap/TreeMapIndependentVanChartInterface.java @@ -3,11 +3,13 @@ package com.fr.van.chart.treemap; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; 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.ChartStylePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.van.chart.designer.other.VanChartOtherPane; import com.fr.van.chart.designer.style.VanChartStylePane; @@ -20,7 +22,7 @@ import com.fr.van.chart.treemap.style.VanChartTreeMapSeriesPane; public class TreeMapIndependentVanChartInterface extends MultiPieIndependentVanChartInterface { @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartTreeMapPlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartTreeMapPlotPane(); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java index 5ff077a4b6..290c6a43f0 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java @@ -3,6 +3,7 @@ package com.fr.van.chart.wordcloud.designer; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.AttributeChangeListener; @@ -13,6 +14,7 @@ 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.design.mainframe.chart.mode.ChartEditContext; import com.fr.plugin.chart.base.VanChartConstants; import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.van.chart.designer.other.VanChartOtherPane; @@ -39,7 +41,7 @@ public class WordCloudIndependentVanChartInterface extends AbstractIndependentVa */ @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartWordCloudTypePane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartWordCloudTypePane(); } @Override diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/CopyAction.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/CopyAction.java index c577a86939..b71def807b 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/actions/CopyAction.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/CopyAction.java @@ -1,8 +1,7 @@ package com.fr.design.designer.beans.actions; - import com.fr.design.base.mode.DesignModeContext; -import com.fr.design.designer.beans.actions.behavior.ComponentEnable; +import com.fr.design.designer.beans.actions.behavior.CopyableEnable; import com.fr.design.mainframe.FormDesigner; import javax.swing.KeyStroke; @@ -18,7 +17,7 @@ public class CopyAction extends FormWidgetEditAction { this.setMnemonic('C'); this.setSmallIcon("/com/fr/design/images/m_edit/copy"); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER)); - setUpdateBehavior(new ComponentEnable()); + setUpdateBehavior(new CopyableEnable()); this.setEnabled(!DesignModeContext.isBanCopyAndCut()); } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java index e93eebd729..94c84a87d4 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java @@ -3,6 +3,7 @@ package com.fr.design.designer.beans.actions; import com.fr.design.base.mode.DesignModeContext; import com.fr.design.designer.beans.actions.behavior.ComponentEnable; +import com.fr.design.designer.beans.actions.behavior.CutableEnable; import com.fr.design.mainframe.FormDesigner; import javax.swing.KeyStroke; @@ -18,7 +19,7 @@ public class CutAction extends FormWidgetEditAction { this.setMnemonic('T'); this.setSmallIcon("/com/fr/design/images/m_edit/cut"); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)); - this.setUpdateBehavior(new ComponentEnable()); + this.setUpdateBehavior(new CutableEnable()); this.setEnabled(!DesignModeContext.isBanCopyAndCut()); } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/FormDeleteAction.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/FormDeleteAction.java index 5f9a59de5f..c2fec8f392 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/actions/FormDeleteAction.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/FormDeleteAction.java @@ -7,9 +7,7 @@ import java.awt.event.KeyEvent; import javax.swing.*; - -import com.fr.design.designer.beans.actions.behavior.ComponentEnable; - +import com.fr.design.designer.beans.actions.behavior.DeletableEnable; import com.fr.design.mainframe.FormDesigner; /** @@ -26,7 +24,7 @@ public class FormDeleteAction extends FormWidgetEditAction { // Richie:删除菜单图标 this.setSmallIcon("/com/fr/design/images/m_report/delete"); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0)); - this.setUpdateBehavior(new ComponentEnable()); + this.setUpdateBehavior(new DeletableEnable()); } @Override diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/CopyableEnable.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/CopyableEnable.java new file mode 100644 index 0000000000..ce3254ea8c --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/CopyableEnable.java @@ -0,0 +1,16 @@ +package com.fr.design.designer.beans.actions.behavior; + +import com.fr.design.designer.beans.actions.FormWidgetEditAction; +import com.fr.design.mainframe.FormDesigner; + +public class CopyableEnable implements UpdateBehavior { + @Override + public void doUpdate(FormWidgetEditAction action) { + FormDesigner designer = action.getEditingComponent(); + if (designer == null) { + action.setEnabled(false); + return; + } + action.setEnabled(designer.isCurrentComponentCopyable()); + } +} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/CutableEnable.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/CutableEnable.java new file mode 100644 index 0000000000..7a6320227e --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/CutableEnable.java @@ -0,0 +1,16 @@ +package com.fr.design.designer.beans.actions.behavior; + +import com.fr.design.designer.beans.actions.FormWidgetEditAction; +import com.fr.design.mainframe.FormDesigner; + +public class CutableEnable implements UpdateBehavior { + @Override + public void doUpdate(FormWidgetEditAction action) { + FormDesigner designer = action.getEditingComponent(); + if (designer == null) { + action.setEnabled(false); + return; + } + action.setEnabled(designer.isCurrentComponentCutable()); + } +} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/DeletableEnable.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/DeletableEnable.java new file mode 100644 index 0000000000..6695826765 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/DeletableEnable.java @@ -0,0 +1,16 @@ +package com.fr.design.designer.beans.actions.behavior; + +import com.fr.design.designer.beans.actions.FormWidgetEditAction; +import com.fr.design.mainframe.FormDesigner; + +public class DeletableEnable implements UpdateBehavior { + @Override + public void doUpdate(FormWidgetEditAction action) { + FormDesigner designer = action.getEditingComponent(); + if (designer == null) { + action.setEnabled(false); + return; + } + action.setEnabled(designer.isCurrentComponentDeletable()); + } +} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/location/AccessDirection.java b/designer-form/src/main/java/com/fr/design/designer/beans/location/AccessDirection.java index eae04d9987..5650c45f12 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/location/AccessDirection.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/location/AccessDirection.java @@ -16,6 +16,7 @@ import com.fr.design.utils.ComponentUtils; import com.fr.env.utils.DesignerInteractionHistory; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; +import com.fr.form.ui.container.WBorderLayout; import java.awt.*; @@ -29,7 +30,7 @@ public abstract class AccessDirection implements Direction { private int ymin; private int xmin; - abstract int getCursor(); + abstract int getCursor(); protected abstract Rectangle getDraggedBounds(int dx, int dy, Rectangle currentBounds, FormDesigner designer, Rectangle oldBounds); @@ -56,14 +57,14 @@ public abstract class AccessDirection implements Direction { x = designer.getRootComponent().getWidth(); } //参数面板可以无下限拉长 - if (y < 0) { - y = 0; - } else if (y > designer.getRootComponent().getHeight() + designer.getParaHeight() && designer.getSelectionModel().hasSelectionComponent() + if (y < 0) { + y = 0; + } else if (y > designer.getRootComponent().getHeight() + designer.getParaHeight() && designer.getSelectionModel().hasSelectionComponent() && !designer.getSelectionModel().getSelection().getSelectedCreator().acceptType(XWParameterLayout.class)) { - y = designer.getRootComponent().getHeight() + designer.getParaHeight(); - } - return new Point(x, y); - } + y = designer.getRootComponent().getHeight() + designer.getParaHeight(); + } + return new Point(x, y); + } protected void sorptionPoint(Point point, Rectangle currentBounds, FormDesigner designer) { boolean findInX = currentBounds.getWidth() <= MoveUtils.SORPTION_UNIT; @@ -100,10 +101,10 @@ public abstract class AccessDirection implements Direction { findInY = true; } - } - if (findInX && findInY) { - break; - } + } + if (findInX && findInY) { + break; + } } setDesignerStateModelProperties(designer, findInX, findInY, currentBounds, point); @@ -129,11 +130,10 @@ public abstract class AccessDirection implements Direction { } - private WAbsoluteLayout getLayout(final FormDesigner designer){ - XLayoutContainer formLayoutContainer = (XLayoutContainer) XCreatorUtils.createXCreator( - designer.getTarget().getContainer()); + private WAbsoluteLayout getLayout(final FormDesigner designer) { WAbsoluteLayout layout; - if (formLayoutContainer.acceptType(XWBorderLayout.class)) {//看起来这边的作用应该是为了区别cpt(得到XWParameterLayout)还是frm(得到XWBorderLayout)的参数界面 + //看起来这边的作用应该是为了区别cpt(得到XWParameterLayout)还是frm(得到XWBorderLayout)的参数界面 + if (designer.getTarget().getContainer().acceptType(WBorderLayout.class)) { Container container = designer.getSelectionModel().getSelection().getSelectedCreator().getParent(); if (container instanceof XWAbsoluteLayout) { layout = ((XWAbsoluteLayout) container).toData(); @@ -161,49 +161,49 @@ public abstract class AccessDirection implements Direction { return; } //设定控件最小高度21,因每次拖曳至少移动1,防止控件高度等于21时,拖曳导致rec.y的变化使得控件不停的向上或向下移动。 - if(rec.height == MINHEIGHT){ + if (rec.height == MINHEIGHT) { ymin = rec.y; } - if(rec.height == MINHEIGHT - 1){ + if (rec.height == MINHEIGHT - 1) { ymin = ymin == rec.y ? rec.y : rec.y - 1; } - if(rec.height < MINHEIGHT){ + if (rec.height < MINHEIGHT) { rec.height = MINHEIGHT; rec.y = ymin; } // 增加下宽度也设最小为21 if (rec.width == MINWIDTH) { - xmin = rec.x; + xmin = rec.x; } - if(rec.width == MINWIDTH - 1){ - xmin = xmin == rec.x ? rec.x : rec.x - 1; + if (rec.width == MINWIDTH - 1) { + xmin = xmin == rec.x ? rec.x : rec.x - 1; } if (rec.width < MINWIDTH) { - rec.width = MINWIDTH; - rec.x = xmin; + rec.width = MINWIDTH; + rec.x = xmin; } } - /** - * 更新鼠标指针形状 - * @param formEditor 设计界面组件 - */ - public void updateCursor(FormDesigner formEditor) { + /** + * 更新鼠标指针形状 + * @param formEditor 设计界面组件 + */ + public void updateCursor(FormDesigner formEditor) { - // 调用位置枚举的多态方法getCursor获取鼠标形状 - int type = getCursor(); + // 调用位置枚举的多态方法getCursor获取鼠标形状 + int type = getCursor(); - if (type != formEditor.getCursor().getType()) { - // 设置当前形状 - formEditor.setCursor(Cursor.getPredefinedCursor(type)); + if (type != formEditor.getCursor().getType()) { + // 设置当前形状 + formEditor.setCursor(Cursor.getPredefinedCursor(type)); - // 显示/改变Tooltip + // 显示/改变Tooltip showTooltip(formEditor); - } - } + } + } - private void showTooltip(FormDesigner formEditor) { + private void showTooltip(FormDesigner formEditor) { // 显示拖拽改变组件尺寸相关的提示信息 int cursorType = formEditor.getCursor().getType(); if (Cursor.SW_RESIZE_CURSOR <= cursorType && cursorType <= Cursor.E_RESIZE_CURSOR) { @@ -217,15 +217,15 @@ public abstract class AccessDirection implements Direction { } } - public String getTooltip() { - return null; + public String getTooltip() { + return null; + } + + /** + * 生成组件备用的bound + * @param formEditor 设计界面组件 + */ + public void backupBounds(FormDesigner formEditor) { + formEditor.getSelectionModel().getSelection().backupBounds(); } - - /** - * 生成组件备用的bound - * @param formEditor 设计界面组件 - */ - public void backupBounds(FormDesigner formEditor) { - formEditor.getSelectionModel().getSelection().backupBounds(); - } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java index bf1c849906..df645e2dfe 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java @@ -85,13 +85,14 @@ public class SelectionModel { if (e.getButton() == MouseEvent.BUTTON3 || (!InputEventBaseOnOS.isControlDown(e) && !e.isShiftDown())) { // 如果Ctrl或者Shift键盘没有按下,则清除已经选择的组件 XCreator selectXCreator = selection.getSelectedCreator(); - if (selectXCreator != null && comp != null) { + boolean clickOnce = e.getClickCount() == 1; + boolean hasCom = selectXCreator != null && comp != null; + if (clickOnce && hasCom) { if (StringUtils.equals(selectXCreator.toData().getWidgetName(), comp.toData().getWidgetName())) { return; } } selection.reset(); - } else { //按下Ctrl或者shift键时鼠标可以进行多选,两次点击同一控件就取消选中 XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(comp).getTopLayout(); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java index 485c73b164..395647db3b 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java @@ -42,6 +42,9 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ public XBorderStyleWidgetCreator(Widget widget, Dimension initSize) { super(widget, initSize); + setOpaque(false); + setBackupBound(null); + ExtendSharableAttrMark sharableAttrMark = this.toData().getWidgetAttrMark(ExtendSharableAttrMark.XML_TAG); if (sharableAttrMark != null) { this.setShareId(sharableAttrMark.getShareId()); @@ -263,6 +266,11 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ } + @Override + public void setBackground(Color bg) { + super.setBackground(bg); + } + // 根据当前组件边框裁剪内容,如果当前组件存在圆角,则应当按圆角裁剪内容 private void clipByRoundedBorder(Graphics2D g2d) { Border currentBorder = getBorder(); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index 3b991d4a03..55b9c191f3 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java @@ -23,6 +23,7 @@ import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.NoSupportAuthorityEdit; import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.mainframe.loghandler.LogMessageBar; import com.fr.design.plugin.DesignerPluginContext; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.Widget; @@ -33,6 +34,7 @@ import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.JComponent; +import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.border.Border; @@ -776,6 +778,10 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo if (popup == null) { popup = new SelectedPopupDialog(this, designer); } + JFrame frame = LogMessageBar.getInstance().getLogFrame(); + if (frame!= null && frame.isActive()) { + return; + } int creatorRightX = (int) ((bounds.x + bounds.width + SelectedPopupDialog.OFFSET_X) * designer.getScale()); int creatorRightY = (int) (bounds.y * designer.getScale()); int formDesignerWidth = designer.getWidth(); @@ -783,14 +789,23 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo // 不超过可绘制区域 int extraX = Math.min(creatorRightX, formDesignerWidth); int extraY = creatorRightY < 0 ? 0 : Math.min(creatorRightY, formDesignerHeight); + + if (designer.isFormParaDesigner() && extraY + this.getHeight() >= formDesignerHeight) { + popup.setVisible(false); + return; + } + // 放到事件尾部执行 SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY); - popup.updatePane(designer); - popup.setVisible(selected && accept && popup.hasVisibleButtons() && popup.isCanVisible() && !isShowPluginDialog()); - popup.setRelativeBounds(bounds); + try { + popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY); + popup.updatePane(designer); + popup.setVisible(selected && accept && popup.hasVisibleButtons() && popup.isCanVisible() && !isShowPluginDialog()); + popup.setRelativeBounds(bounds); + } catch (Exception ignored) { + } } }); } @@ -862,4 +877,14 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo } } + public boolean isParentAbsolute() { + return ((XCreator) this.getParent()).acceptType(XWAbsoluteLayout.class); + } + + public int getLevel() { + if (this.getParent() == null) { + return 1; + } + return ((XCreator) this.getParent()).getLevel() + 1; + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java index 1d37024d98..fc01aefaa9 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java @@ -103,6 +103,11 @@ public class XWParameterLayout extends XWAbsoluteLayout { return false; } + @Override + public boolean canEnterIntoAbsolutePane() { + return false; + } + /** * 该组件是否可以拖拽(表单中参数面板和自适应布局不可以拖拽) * @return 是则返回true diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java index 71129bed46..1628b6cdd2 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java @@ -76,7 +76,7 @@ public class XWTitleLayout extends DedicateLayoutContainer { // 初始化后(如打开旧模版),需要重新调整组件/标题/边框的显示效果 XCreator xCreator = getBodyCreator(); if (xCreator instanceof XBorderStyleWidgetCreator) { - ((XBorderStyleWidgetCreator) xCreator).reshuffleBorderAndBackgroundPaintingEffectIfTitleExists(); + ((XBorderStyleWidgetCreator) xCreator).initStyle(); } } @@ -219,17 +219,26 @@ public class XWTitleLayout extends DedicateLayoutContainer { public void convert() { isRefreshing = true; WTitleLayout layout = this.toData(); + XBorderStyleWidgetCreator bodyCreator = null; this.removeAll(); for (int i = 0, num = layout.getWidgetCount(); i < num; i++) { BoundsWidget bw = (BoundsWidget) layout.getWidget(i); if (bw != null) { Rectangle bounds = bw.getBounds(); XWidgetCreator comp = (XWidgetCreator) XCreatorUtils.createXCreator(bw.getWidget()); - String constraint = bw.getWidget().acceptType(Label.class) ? WTitleLayout.TITLE : WTitleLayout.BODY; + boolean isTitleWidget = bw.getWidget().acceptType(Label.class); + String constraint = isTitleWidget ? WTitleLayout.TITLE : WTitleLayout.BODY; this.add(comp, constraint); comp.setBounds(bounds); + if (!isTitleWidget && comp instanceof XBorderStyleWidgetCreator) { + bodyCreator = (XBorderStyleWidgetCreator) comp; + } } } + // 刷新时重置下样式 + if (bodyCreator != null) { + bodyCreator.initStyle(); + } isRefreshing = false; } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java index 4fb422c0aa..1d564ec6c1 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java @@ -406,15 +406,10 @@ public class XWCardLayout extends XLayoutContainer { private void initBorderTitleStyle(BorderPacker style) { //初始化默认标题样式 - if (!initFlag) { - return; - } - style.setType(LayoutBorderStyle.TITLE); style.setBorder(Constants.LINE_THIN); TitlePacker widgetTitle = style.getTitle(); widgetTitle.setBackground(ColorBackground.getInstance(TITLE_COLOR)); - initFlag = false; } //隐藏或显示标题部分 diff --git a/designer-form/src/main/java/com/fr/design/fit/JFormType.java b/designer-form/src/main/java/com/fr/design/fit/JFormType.java index 7fe795c6fb..f2d1c4ad90 100644 --- a/designer-form/src/main/java/com/fr/design/fit/JFormType.java +++ b/designer-form/src/main/java/com/fr/design/fit/JFormType.java @@ -69,12 +69,12 @@ public enum JFormType { }; private int type; private boolean newType; - private PreviewProvider previewType; + private PreviewProvider defaultPreviewType; - JFormType(int type, PreviewProvider previewType) { + JFormType(int type, PreviewProvider defaultPreviewType) { this.type = type; this.newType = (type == 1); - this.previewType = previewType; + this.defaultPreviewType = defaultPreviewType; } public int getType() { @@ -85,8 +85,8 @@ public enum JFormType { return newType; } - public PreviewProvider getPreviewType() { - return previewType; + public PreviewProvider getDefaultPreviewType() { + return defaultPreviewType; } public abstract void switchUI(); @@ -128,6 +128,14 @@ public enum JFormType { * @date: 2020/12/17 16:17 */ public void updatePreviewType(JTemplate jTemplate) { - jTemplate.setPreviewType(this.getPreviewType()); + if (jTemplate.getPreviewType() != null) { + PreviewProvider[] previewProviders = jTemplate.supportPreview(); + for (PreviewProvider previewProvider : previewProviders) { + if (previewProvider.getClass() == jTemplate.getPreviewType().getClass()) { + return; + } + } + } + jTemplate.setPreviewType(this.getDefaultPreviewType()); } } diff --git a/designer-form/src/main/java/com/fr/design/fit/NewJForm.java b/designer-form/src/main/java/com/fr/design/fit/NewJForm.java index b8d429ca90..74737f8ce6 100644 --- a/designer-form/src/main/java/com/fr/design/fit/NewJForm.java +++ b/designer-form/src/main/java/com/fr/design/fit/NewJForm.java @@ -1,6 +1,7 @@ package com.fr.design.fit; import com.fr.base.DynamicUnitList; +import com.fr.base.Parameter; import com.fr.design.actions.TemplateParameterAction; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.LayoutAdapter; @@ -52,6 +53,10 @@ public class NewJForm extends JForm { changePaneSize(); } + public NewJForm(Form form, FILE file, Parameter[] parameters) { + this(form, file); + } + public NewJForm(Form form, FILE file) { super(form, file); if (DesignerUIModeConfig.getInstance().newUIMode()) { diff --git a/designer-form/src/main/java/com/fr/design/fit/attrpane/ElementEditorExtendDefinePane.java b/designer-form/src/main/java/com/fr/design/fit/attrpane/ElementEditorExtendDefinePane.java index 3d25590f48..20351165e0 100644 --- a/designer-form/src/main/java/com/fr/design/fit/attrpane/ElementEditorExtendDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/fit/attrpane/ElementEditorExtendDefinePane.java @@ -1,17 +1,23 @@ package com.fr.design.fit.attrpane; +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.settings.ThemedComponentStyle; import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.CRPropertyDescriptor; import com.fr.design.designer.creator.PropertyGroupPane; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XElementCase; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.style.FollowingThemePane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.widget.accessibles.AccessibleElementCaseToolBarEditor; import com.fr.design.widget.ui.designer.component.PaddingBoundPane; import com.fr.design.widget.ui.designer.layout.WTitleLayoutDefinePane; +import com.fr.form.main.Form; import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.ui.PaddingMargin; import com.fr.form.web.FormToolBarManager; import com.fr.general.ComparatorUtils; import com.fr.report.fit.ReportFitAttr; @@ -27,7 +33,7 @@ import java.util.List; * Created by kerry on 2020-04-09 */ public class ElementEditorExtendDefinePane extends WTitleLayoutDefinePane { - private PaddingBoundPane paddingBoundPane; + private final PaddingBoundPane paddingBoundPane; private AccessibleElementCaseToolBarEditor elementCaseToolBarEditor; private PropertyGroupPane extraPropertyGroupPane; private PcFitExpandablePane pcFitExpandablePane; @@ -36,14 +42,31 @@ public class ElementEditorExtendDefinePane extends WTitleLayoutDefinePane contentDisplayType = new HashMap<>(); + Map contentDisplayTip = new HashMap<>(); public PcFitExpandablePane(DataModify attrPane) { init(attrPane); } public void init(final DataModify attrPane) { + initComboBox(); this.setLayout(FRGUIPaneFactory.createBorderLayout()); JPanel pcFitPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); final JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); @@ -42,11 +52,11 @@ public class PcFitExpandablePane extends JPanel { comboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { - tipLabel.setText(ScaleTipType.getScaleTip(comboBox.getSelectedIndex()).getTip()); + tipLabel.setText(contentDisplayTip.get(comboBox.getSelectedItem())); } }); Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_Content_Display_Type")), comboBox}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Designer_Fit_Ec_Content_Display_Type")), comboBox}, new Component[]{tipLabel, null}, }; JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_W0); @@ -58,50 +68,61 @@ public class PcFitExpandablePane extends JPanel { this.add(pcFitPane, BorderLayout.CENTER); } + private void initComboBox() { + for (Item item : defaultItems) { + comboBox.addItem(item.value); + contentDisplayType.put(item.key, item.value); + contentDisplayTip.put(item.value, item.tip); + } + + Set pcFitProviders = ExtraDesignClassManager.getInstance().getArray(PcFitProvider.XML_TAG); + + for (PcFitProvider pcFitProvider : pcFitProviders) { + comboBox.addItem(pcFitProvider.getContentDisplayValue()); + contentDisplayType.put(pcFitProvider.getContentDisplayKey(), pcFitProvider.getContentDisplayValue()); + contentDisplayTip.put(pcFitProvider.getContentDisplayValue(), pcFitProvider.getContentDisplayTip()); + } + } + public ReportFitAttr update() { - ReportFitAttr fitAttr = getReportFitAttr(); - fitAttr.setFitStateInPC(FitStateCompatible.getOldTypeFromNew(comboBox.getSelectedIndex())); + ReportFitAttr fitAttr = getDefaultReportFitAttr(); + String selectType = (String) comboBox.getSelectedItem(); + for (Integer key : contentDisplayType.keySet()) { + if (CompareUtils.isEqual(contentDisplayType.get(key), selectType)) { + fitAttr.setFitStateInPC(key); + } + } return fitAttr; } public void populate(ReportFitAttr fitAttr) { - if (fitAttr == null) { - fitAttr = getReportFitAttr(); + if (fitAttr == null || !contentDisplayType.keySet().contains(fitAttr.fitStateInPC())) { + fitAttr = getDefaultReportFitAttr(); + } + String selectType = contentDisplayType.get(fitAttr.fitStateInPC()); + for (int i = 0; i < comboBox.getItemCount(); i++) { + if (CompareUtils.isEqual(selectType, comboBox.getItemAt(i))) { + comboBox.setSelectedIndex(i); + tipLabel.setText(contentDisplayTip.get(selectType)); + } } - int selectIndex = FitStateCompatible.getNewTypeFromOld(fitAttr.fitStateInPC()); - comboBox.setSelectedIndex(selectIndex); - tipLabel.setText(ScaleTipType.getScaleTip(selectIndex).getTip()); } - private ReportFitAttr getReportFitAttr() { + private ReportFitAttr getDefaultReportFitAttr() { ReportFitAttr fitAttr = new ReportFitAttr(); fitAttr.setFitStateInPC(FitAttrState.NOT_FIT.getState()); return fitAttr; } - private enum ScaleTipType { - EC_DOUBLE_FIT(0, com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_Double_Fit_Tip")), - EC_HOR_FIT(1, com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_Hor_Fit_Tip")), - EC_NO_FIT(2, com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Ec_No_Fit_Tip")); - private int index; - private String tip; + class Item { + public String value; + public int key; + public String tip; - ScaleTipType(int index, String tip) { - this.index = index; + Item(String value, int key, String tip) { + this.value = value; + this.key = key; this.tip = tip; } - - public String getTip() { - return tip; - } - - public static ScaleTipType getScaleTip(int selectIndex) { - for (ScaleTipType tipType : values()) { - if (selectIndex == tipType.index) { - return tipType; - } - } - return EC_NO_FIT; - } } } diff --git a/designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java b/designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java index 5d9c9463cd..8c55e8ab0a 100644 --- a/designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java +++ b/designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java @@ -11,7 +11,6 @@ import com.fr.design.fit.attrpane.RootDesignExtendDefinePane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JTemplate; -import com.fr.design.mainframe.JTemplateFactory; import com.fr.design.parameter.RootDesignDefinePane; import com.fr.design.preview.FormAdaptivePreview; import com.fr.design.preview.FormPreview; @@ -23,6 +22,8 @@ import com.fr.design.widget.ui.designer.layout.FRAbsoluteLayoutDefinePane; import com.fr.design.widget.ui.designer.layout.FRFitLayoutDefinePane; import com.fr.file.FILE; import com.fr.file.MemFILE; +import com.fr.form.main.Form; +import com.fr.form.main.WidgetGather; import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteBodyLayout; @@ -34,6 +35,7 @@ import com.fr.log.FineLoggerFactory; import com.fr.report.fit.ReportFitAttr; import javax.swing.SwingUtilities; +import java.util.Set; /** * Created by kerry on 2020-06-02 @@ -147,11 +149,34 @@ public class AdaptiveSwitchUtil { if (DesignerUIModeConfig.getInstance().newUIMode() && jForm.getTarget().getReportFitAttr() != null && isSwitchJFromIng()) { jForm.getTarget().setReportFitAttr(shiftReportFitAttr(old, jForm.getTarget().getReportFitAttr().isFitFont())); } + processAbsoluteLayoutCompatible(jForm.getTarget()); TemplateTool.saveForm(jForm); } return template; } + + private static void processAbsoluteLayoutCompatible(Form form){ + Form.traversalWidget(form.getContainer(), new WidgetGather() { + @Override + public void dealWith(Widget widget) { + if (widget.acceptType(WAbsoluteBodyLayout.class)) { + return; + } + WAbsoluteLayout absoluteLayout = (WAbsoluteLayout) widget; + //切换到新模板后,内部的绝对画布块都要设置成适应缩放的逻辑 + absoluteLayout.setCompState(0); + } + + @Override + public boolean dealWithAllCards() { + return true; + } + }, WAbsoluteLayout.class); + } + + + /** * @Description: 创建模板核心方法 * @param old 以前的方法 @@ -167,7 +192,16 @@ public class AdaptiveSwitchUtil { } TemplateTool.saveForm(old); } - return JTemplateFactory.createJTemplate(old.getEditingFILE()); + if (old.getTarget() instanceof Form) { + try { + return new NewJForm((Form) (old.getTarget()).clone(), old.getEditingFILE()); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + return null; + } + } else { + return null; + } } /** diff --git a/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java b/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java index c760d01dad..323a28ad04 100644 --- a/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java +++ b/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java @@ -12,6 +12,7 @@ import com.fr.design.fit.NewJForm; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.FormArea; import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JTemplate; import com.fr.event.Event; import com.fr.event.Listener; @@ -37,6 +38,10 @@ public class TemplateTool { private static Listener switchListener = new Listener() { @Override public void on(Event event, JTemplate jTemplate) { + if (!(jTemplate instanceof JForm)) { + JFormType.OLD_TYPE.switchUIMode(); + return; + } JFormType currentType = JFormType.OLD_TYPE; if (AdaptiveSwitchUtil.isSwitchJFromIng()) { currentType = DesignerUIModeConfig.getInstance().newUIMode() ? JFormType.NEW_TYPE : JFormType.OLD_TYPE; diff --git a/designer-form/src/main/java/com/fr/design/fit/menupane/BrowserFitAttrPane.java b/designer-form/src/main/java/com/fr/design/fit/menupane/BrowserFitAttrPane.java index fdc2f8332e..32fe81ded4 100644 --- a/designer-form/src/main/java/com/fr/design/fit/menupane/BrowserFitAttrPane.java +++ b/designer-form/src/main/java/com/fr/design/fit/menupane/BrowserFitAttrPane.java @@ -181,7 +181,7 @@ public class BrowserFitAttrPane extends BasicBeanPane { boolean isLocalConfig = !globalCheck.isSelected(); //勾选全局时,采用全局保存的自适应属性更新界面 if (!isLocalConfig) { - ReportFitAttr attr = globalFitAttr; + ReportFitAttr attr = jFormType.obtainFitAttr(); populateAttrPane(attr); remove(BrowserFitAttrPane.this.borderPane); initBorderPane(Toolkit.i18nText("Fine-Designer_Fit-Global")); diff --git a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java index 0ac74e5b58..20f8203ace 100644 --- a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java +++ b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java @@ -745,5 +745,13 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP return false; } + @Override + public boolean isCurrentComponentCutable() { + return !isRootSelected(); + } + @Override + public boolean isCurrentComponentCopyable() { + return !isRootSelected(); + } } diff --git a/designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java b/designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java index ded4e7c994..4c1f9304ba 100644 --- a/designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java +++ b/designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java @@ -36,6 +36,9 @@ public class FormDesignerUtils { * @return */ public static boolean isBodyAbsolute(FormDesigner designer) { + if (!designer.getRootComponent().acceptType(XWFitLayout.class)) { + return false; + } WFitLayout root = ((WFitLayout) designer.getRootComponent().toData()); return root.getBodyLayoutType() == com.fr.form.ui.container.WBodyLayoutType.ABSOLUTE; } diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java index 37db551027..98fe066e22 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java @@ -10,15 +10,14 @@ import javax.swing.JPanel; */ public class CardTagLayoutStylePane extends LayoutStylePane { + @Override - protected JPanel createTitleStylePane(){ - JPanel panel = super.createTitleStylePane(); - panel.setVisible(false); - return panel; + protected JPanel createNamedTitleStylePane(boolean isRootLayout) { + return null; } @Override - protected JPanel createBackgroundStylePane(boolean supportCornerRadius) { - return super.createBackgroundStylePane(false); + protected JPanel createNamedIntegralStylePane(boolean isRootLayout, boolean supportCornerRadius) { + return super.createNamedIntegralStylePane(isRootLayout, false); } } diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java index 453bd5e0da..09170b8c3b 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java @@ -1,40 +1,35 @@ package com.fr.design.gui.xpane; -import com.fr.base.Utils; -import com.fr.base.svg.IconUtils; import com.fr.design.beans.BasicBeanPane; import com.fr.design.designer.IntervalConstants; import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.formula.TinyFormulaPane; -import com.fr.design.gui.frpane.UIPercentDragPane; -import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.gui.ibutton.UIColorButton; -import com.fr.design.gui.ibutton.UIToggleButton; -import com.fr.design.gui.icheckbox.UICheckBox; -import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.style.BackgroundSpecialPane; -import com.fr.design.gui.style.FRFontPane; +import com.fr.design.gui.style.ComponentBodyStylePane; +import com.fr.design.gui.style.ComponentIntegralStylePane; +import com.fr.design.gui.style.ComponentTitleStylePane; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane; import com.fr.form.ui.LayoutBorderStyle; -import com.fr.form.ui.WidgetTitle; -import com.fr.general.Background; -import com.fr.general.FRFont; -import com.fr.general.IOUtils; -import com.fr.general.act.TitlePacker; -import com.fr.stable.Constants; - -import javax.swing.*; + +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; import javax.swing.border.LineBorder; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.*; +import java.awt.BasicStroke; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.Stroke; + +import static com.fr.design.i18n.Toolkit.i18nText; /** * @author Starryi @@ -44,51 +39,19 @@ import java.awt.*; * 可配置图片类型边框的样式设置面板 */ public class LayoutStylePane extends BasicBeanPane { - public static final String[] BORDER_STYLE = new String[]{ - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Common"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Shadow") - }; - private static final Dimension BUTTON_SIZE = new Dimension(20, 20); public static final int SETTING_LABEL_WIDTH = 60; protected LayoutBorderStyle style = new LayoutBorderStyle(); - //渲染风格:有无阴影 - protected UIComboBox borderStyleCombo; - // 含图片类型边框的边框配置面板(图片类型边框 + 阴影时存在默认的阴影颜色) - protected BorderLineAndImagePane borderLineAndImagePane; - //边框圆角或圆角裁剪 - protected UISpinner cornerSpinner; - //主体背景 - protected BackgroundSpecialPane backgroundPane; - //主体背景透明度 - protected UIPercentDragPane backgroundOpacityPane; - - // 标题可见 - protected UICheckBox titleVisibleCheckbox; - //标题文字内容 - protected TinyFormulaPane titleTextPane; - //标题字体格式 - protected UIComboBox titleFontFamilyComboBox; - //标题字体大小 - protected UIComboBox titleFontSizeComboBox; - //标题字体颜色 - protected UIColorButton titleFontColorSelectPane; - //标题字体特殊效果:粗体、斜体、下划线 - private UIToggleButton titleFontBoldButton; - private UIToggleButton titleFontItalicButton; - private UIToggleButton titleFontUnderlineButton; -// private LineComboBox titleFontUnderlineCombo; // 目前前端仅支持短横线类型的下划线,因此设计器端暂时就不展示线型选择框了,待后续优化 - // 标题图文混排 - protected TitleInsetImagePane titleInsetImagePane; - //对齐方式 - protected UIButtonGroup titleAlignPane; - //标题整体背景 - protected BackgroundSpecialPane titleBackgroundPane; - //标题背景透明度 - protected UIPercentDragPane titleBackgroundOpacityPane; - - private boolean supportBorderImage = false; + public JPanel namedTitleStylePane; + public JPanel namedBodyStylePane; + public JPanel namedIntegralStylePane; + + protected ComponentTitleStylePane titleStylePane; + protected ComponentBodyStylePane bodyStylePane; + protected ComponentIntegralStylePane integralStylePane; + + private final boolean supportBorderImage; public LayoutStylePane() { this(false); @@ -96,344 +59,92 @@ public class LayoutStylePane extends BasicBeanPane { public LayoutStylePane(boolean supportBorderImage) { this.supportBorderImage = supportBorderImage; - this.initLayout(); + this.initializePane(); } - protected void initLayout() { + protected void initializePane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); - JTemplate currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - boolean currentIsRootLayout = currentEditingTemplate != null && !currentEditingTemplate.isJWorkBook() && ((JForm)currentEditingTemplate).isSelectRootPane(); + boolean isRootLayout = currentEditingTemplate != null && !currentEditingTemplate.isJWorkBook() && ((JForm)currentEditingTemplate).isSelectRootPane(); - JPanel titlePane = createTitleStylePane(); - JPanel bodyContentPane = currentIsRootLayout ? createBodyContentPane4RootLayout() : createBodyContentPane(); - JPanel backgroundPane = createBackgroundStylePane(true); + namedTitleStylePane = createNamedTitleStylePane(isRootLayout); + namedBodyStylePane = createNamedBodyStylePane(isRootLayout); + namedIntegralStylePane = createNamedIntegralStylePane(isRootLayout, true); - if (titlePane != null) { - container.add(titlePane, BorderLayout.NORTH); - if (currentIsRootLayout) { - titlePane.setVisible(false); - } - } - JPanel nextContainerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - container.add(nextContainerPane, BorderLayout.CENTER); + addComponents(new JComponent[] { namedTitleStylePane, namedBodyStylePane, namedIntegralStylePane }); + } - if (bodyContentPane != null) { - //界面上表单主体只有背景和透明度可以设置 - nextContainerPane.add(bodyContentPane, BorderLayout.NORTH); + protected JPanel createNamedTitleStylePane(boolean isRootLayout) { + if (isRootLayout) { + return null; } - if (backgroundPane != null) { - nextContainerPane.add(backgroundPane, BorderLayout.CENTER); - if (currentIsRootLayout) { - backgroundPane.setVisible(false); - } - } - - this.add(container, BorderLayout.CENTER); + this.titleStylePane = new ComponentTitleStylePane(SETTING_LABEL_WIDTH); + return this.createNamedSubStylePane(i18nText("Fine-Design_Form_Widget_Style_Title"), this.titleStylePane); } - protected JPanel createBackgroundStylePane(boolean supportCornerRadius) { - borderStyleCombo = new UIComboBox(BORDER_STYLE); - borderLineAndImagePane = new BorderLineAndImagePane(this.supportBorderImage); - cornerSpinner = new UISpinner(0,1000,1,0); - - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] rowSize = supportCornerRadius ? new double[] {p, p, p, p} : new double[]{p, p, p}; - double[] columnSize = {SETTING_LABEL_WIDTH, f}; - - UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Background_Style")); - Font font = uiLabel.getFont().deriveFont(Font.BOLD); - uiLabel.setFont(font); - uiLabel.setForeground(new Color(143, 143, 146)); - - JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ - {uiLabel, null}, - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo}, - {this.borderLineAndImagePane, null}, - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner}, - }, - rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); - contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); - - JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); - container.setBorder(new BottomLineBorder()); - container.add(contentPane, BorderLayout.NORTH); - - return container; + protected JPanel createNamedBodyStylePane(boolean isRootLayout) { + this.bodyStylePane = new ComponentBodyStylePane(SETTING_LABEL_WIDTH); + if (isRootLayout) { + return this.bodyStylePane; + } + return this.createNamedSubStylePane(i18nText("Fine-Design_Form_Widget-Style_Body_Content"), this.bodyStylePane); } - protected JPanel createBodyContentPane() { - backgroundPane = new LayoutBackgroundSpecialPane(); - backgroundOpacityPane = new UIPercentDragPane(); - - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] rowSize = {p, p}; - double[] columnSize = {SETTING_LABEL_WIDTH, f}; - - JPanel bodyBackground = createBackgroundAndOpacityPane( - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Fill"), - this.backgroundPane, - this.backgroundOpacityPane); + protected JPanel createNamedIntegralStylePane(boolean isRootLayout, boolean supportCornerRadius) { + if (isRootLayout) { + return null; + } + this.integralStylePane = new ComponentIntegralStylePane(SETTING_LABEL_WIDTH, supportBorderImage, supportCornerRadius); + return this.createNamedSubStylePane(i18nText("Fine-Design_Form_Widget-Style_Integral_Style"), this.integralStylePane); + } - UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Content")); + protected JPanel createNamedSubStylePane(String name, JPanel stylePane) { + UILabel uiLabel = new UILabel(name); Font font = uiLabel.getFont().deriveFont(Font.BOLD); uiLabel.setFont(font); uiLabel.setForeground(new Color(143, 143, 146)); - JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ - {uiLabel, null}, - {bodyBackground, null}, - }, - rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); - contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); - - JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); - container.setBorder(new BottomLineBorder()); - container.add(contentPane, BorderLayout.NORTH); - - return container; - } - protected JPanel createBodyContentPane4RootLayout() { - backgroundPane = new LayoutBackgroundSpecialPane(); - backgroundOpacityPane = new UIPercentDragPane(); - - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] rowSize = {p}; - double[] columnSize = {SETTING_LABEL_WIDTH, f}; - - JPanel bodyBackground = createBackgroundAndOpacityPane( - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Fill"), - this.backgroundPane, - this.backgroundOpacityPane); - - JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ - {bodyBackground, null}, - }, - rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); - contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); + JPanel content = TableLayoutHelper.createGapTableLayoutPane( new JComponent[][] { + {uiLabel}, + {stylePane} + }, TableLayoutHelper.FILL_LASTCOLUMN, 0, IntervalConstants.INTERVAL_L1); + content.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0)); JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); + container.add(content, BorderLayout.NORTH); container.setBorder(new BottomLineBorder()); - container.add(contentPane, BorderLayout.NORTH); return container; } - protected void initTitleComponents() { - titleVisibleCheckbox = new UICheckBox(); - - titleTextPane = new TinyFormulaPane(); - - titleFontFamilyComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); - TitlePacker title = style.getTitle(); - if (title != null) { - FRFont frFont = title.getFrFont(); - if (frFont != null) { - String fontFamily = frFont.getFamily(); - // 使用style中默认的字体初始化titleFontFamilyComboBox,保证UI和数据的一致性 - this.titleFontFamilyComboBox.setSelectedItem(fontFamily); + private void addComponents(JComponent[] components) { + JPanel container = this; + for (JComponent component: components) { + if (component != null) { + container.add(component, BorderLayout.NORTH); + JPanel nextContainer = new JPanel(FRGUIPaneFactory.createBorderLayout()); + container.add(nextContainer, BorderLayout.CENTER); + container = nextContainer; } } - titleFontFamilyComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Family")); - - titleFontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); - titleFontSizeComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Size")); - - titleFontColorSelectPane = new UIColorButton(); - titleFontColorSelectPane.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Foreground")); - titleFontColorSelectPane.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Foreground")); - - titleFontBoldButton = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); - titleFontBoldButton.setPreferredSize(BUTTON_SIZE); - titleFontBoldButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Bold")); - titleFontBoldButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Bold")); - - titleFontItalicButton = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); - titleFontItalicButton.setPreferredSize(BUTTON_SIZE); - titleFontItalicButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Italic")); - titleFontItalicButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Italic")); - - titleFontUnderlineButton = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png")); - titleFontUnderlineButton.setPreferredSize(BUTTON_SIZE); - titleFontUnderlineButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Underline")); - titleFontUnderlineButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Underline")); - -// titleFontUnderlineCombo = new LineComboBox(UIConstants.BORDER_LINE_STYLE_ARRAY); -// titleFontUnderlineCombo.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Line_Style")); - - titleInsetImagePane = new TitleInsetImagePane(); - - titleAlignPane = new UIButtonGroup( - new Icon[] { - IconUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), - IconUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), - IconUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png") - }, - new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT}); - titleAlignPane.setAllToolTips( - new String[] { - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Left"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Center"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Right") - }); - - titleBackgroundPane = new LayoutBackgroundSpecialPane(); - - titleBackgroundOpacityPane = new UIPercentDragPane(); - } - - protected JPanel createTitleStylePane() { - initTitleComponents(); - - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] rowSize = {p,p,p,p,p,p}; - double[] columnSize = {SETTING_LABEL_WIDTH, f}; - - final JPanel bottomPane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][]{ - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Content")), titleTextPane}, - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Format")), titleFontFamilyComboBox}, - {null, createTitleFontButtonPane()}, - {titleInsetImagePane, null}, - {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Text_Align")), titleAlignPane}, - {this.createTitleBackgroundAndOpacityPane(), null}, - }, - rowSize, columnSize, IntervalConstants.INTERVAL_L1); - bottomPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - bottomPane.setVisible(false); - - JPanel visibleComposedPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - - titleVisibleCheckbox.setSelected(false); - visibleComposedPane.add(titleVisibleCheckbox, BorderLayout.WEST); - visibleComposedPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Visible")), BorderLayout.CENTER); - - UILabel uiLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title")); - Font font = uiLabel.getFont().deriveFont(Font.BOLD); - uiLabel.setFont(font); - uiLabel.setForeground(new Color(143, 143, 146)); - JPanel topPane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][] { - {uiLabel, null}, - {visibleComposedPane, null} - }, new double[]{p, p}, new double[]{SETTING_LABEL_WIDTH, p}, IntervalConstants.INTERVAL_L1); - topPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); - - JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); - container.setBorder(new BottomLineBorder()); - container.add(topPane, BorderLayout.NORTH); - container.add(bottomPane, BorderLayout.CENTER); - - titleVisibleCheckbox.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - bottomPane.setVisible(titleVisibleCheckbox.isSelected()); - } - }); - - return container; - } - - protected JPanel createTitleFontButtonPane(){ - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] rowSize = {p}; - double[] columnSize = {f, p, p, p, p}; - - JPanel buttonPane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][] { - {titleFontSizeComboBox, titleFontColorSelectPane, titleFontItalicButton, titleFontBoldButton, titleFontUnderlineButton}, - }, rowSize, columnSize, IntervalConstants.INTERVAL_W0); - - JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - containerPane.add(buttonPane, BorderLayout.NORTH); -// containerPane.add(titleFontUnderlineCombo, BorderLayout.CENTER); - -// titleFontUnderlineCombo.setVisible(false); -// titleFontUnderlineButton.addChangeListener(new ChangeListener() { -// @Override -// public void stateChanged(ChangeEvent e) { -// titleFontUnderlineCombo.setVisible(titleFontUnderlineButton.isSelected()); -// } -// }); - - return containerPane; - } - - protected JPanel createTitleBackgroundAndOpacityPane() { - return createBackgroundAndOpacityPane( - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Background"), - titleBackgroundPane, - titleBackgroundOpacityPane); } @Override public LayoutBorderStyle updateBean() { LayoutBorderStyle style = new LayoutBorderStyle(); - updateMain(style); - updateTitle(style); - return style; - } - protected void updateMain(LayoutBorderStyle style) { - if (borderStyleCombo != null) { - style.setBorderStyle(borderStyleCombo.getSelectedIndex()); - } - if (cornerSpinner != null) { - style.setBorderRadius((int) cornerSpinner.getValue()); + if (this.titleStylePane != null) { + this.titleStylePane.updateBean(style); } - if (borderLineAndImagePane != null) { - borderLineAndImagePane.updateBean(style); + if (this.bodyStylePane != null) { + this.bodyStylePane.updateBean(style); } - if (backgroundPane != null) { - style.setBackground(backgroundPane.update()); + if (this.integralStylePane != null) { + this.integralStylePane.updateBean(style); } - if (backgroundOpacityPane != null) { - style.setAlpha((float)backgroundOpacityPane.updateBean()); - } - } - - protected void updateTitle(LayoutBorderStyle style) { - style.setType(titleVisibleCheckbox != null && titleVisibleCheckbox.isSelected() ? LayoutBorderStyle.TITLE : LayoutBorderStyle.STANDARD); - TitlePacker title = style.getTitle() == null ? new WidgetTitle() : style.getTitle(); - title.setTextObject(titleTextPane.updateBean()); - FRFont frFont = title.getFrFont(); - frFont = frFont.applySize((Integer) titleFontSizeComboBox.getSelectedItem()); - frFont = frFont.applyName(titleFontFamilyComboBox.getSelectedItem().toString()); - frFont = frFont.applyForeground(titleFontColorSelectPane.getColor()); - frFont = updateTitleFontItalicBold(frFont); -// int line = titleFontUnderlineButton.isSelected() ? this.titleFontUnderlineCombo.getSelectedLineStyle() : Constants.LINE_NONE; - int line = titleFontUnderlineButton.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE; - frFont = frFont.applyUnderline(line); - title.setFrFont(frFont); - title.setPosition((Integer) titleAlignPane.getSelectedItem()); - titleInsetImagePane.updateBean(title); - title.setBackground(titleBackgroundPane.update()); - title.setBackgroundOpacity((float)titleBackgroundOpacityPane.updateBean()); - style.setTitle(title); - } - - private FRFont updateTitleFontItalicBold(FRFont frFont) { - int italic_bold = frFont.getStyle(); - boolean isItalic = italic_bold == Font.ITALIC || italic_bold == (Font.BOLD + Font.ITALIC); - boolean isBold = italic_bold == Font.BOLD || italic_bold == (Font.BOLD + Font.ITALIC); - if (titleFontItalicButton.isSelected() && !isItalic) { - italic_bold += Font.ITALIC; - } else if (!titleFontItalicButton.isSelected() && isItalic) { - italic_bold -= Font.ITALIC; - } - frFont = frFont.applyStyle(italic_bold); - if (titleFontBoldButton.isSelected() && !isBold) { - italic_bold += Font.BOLD; - } else if (!titleFontBoldButton.isSelected() && isBold) { - italic_bold -= Font.BOLD; - } - frFont = frFont.applyStyle(italic_bold); - return frFont; + return style; } @Override @@ -443,104 +154,20 @@ public class LayoutStylePane extends BasicBeanPane { } this.style.setStyle(style); - populateMain(); - populateTitle(); - } - - protected void populateMain() { - if (this.borderStyleCombo != null) { - this.borderStyleCombo.setSelectedIndex(style.getBorderStyle()); - } - if (this.borderLineAndImagePane != null) { - this.borderLineAndImagePane.populateBean(style); + if (this.titleStylePane != null) { + this.titleStylePane.populateBean(this.style); } - if (this.backgroundPane != null) { - this.backgroundPane.populateBean(style.getBackground()); - if (this.backgroundOpacityPane != null) { - this.backgroundOpacityPane.populateBean(style.getAlpha()); - } + if (this.bodyStylePane != null) { + this.bodyStylePane.populateBean(this.style); } - if (this.cornerSpinner != null) { - this.cornerSpinner.setValue(style.getBorderRadius()); + if (this.integralStylePane != null) { + this.integralStylePane.populateBean(this.style); } } - protected void populateTitle() { - TitlePacker widgetTitle = style == null ? new WidgetTitle() : style.getTitle(); - widgetTitle = widgetTitle == null ? new WidgetTitle() : widgetTitle; - titleVisibleCheckbox.setSelected(style.getType() != LayoutBorderStyle.STANDARD); - - this.titleTextPane.populateBean(widgetTitle.getTextObject().toString()); - - FRFont frFont = widgetTitle.getFrFont(); - this.titleFontSizeComboBox.setSelectedItem(frFont.getSize()); - this.titleFontFamilyComboBox.setSelectedItem(frFont.getFamily()); - this.titleFontColorSelectPane.setColor(frFont.getForeground()); - this.titleFontColorSelectPane.repaint(); - titleFontBoldButton.setSelected(frFont.isBold()); - titleFontItalicButton.setSelected(frFont.isItalic()); - - int line = frFont.getUnderline(); - if (line == Constants.LINE_NONE) { - titleFontUnderlineButton.setSelected(false); -// titleFontUnderlineCombo.setVisible(false); - } else { - titleFontUnderlineButton.setSelected(true); -// titleFontUnderlineCombo.setVisible(true); -// this.titleFontUnderlineCombo.setSelectedLineStyle(line); - } - - titleAlignPane.setSelectedItem(widgetTitle.getPosition()); - titleInsetImagePane.populateBean(widgetTitle); - titleBackgroundPane.populateBean(widgetTitle.getBackground()); - titleBackgroundOpacityPane.populateBean(widgetTitle.getBackgroundOpacity()); - } - @Override protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style"); - } - - private static JPanel createBackgroundAndOpacityPane(String name, BackgroundSpecialPane backgroundPane, UIPercentDragPane opacityPane) { - JPanel container = new JPanel(); - container.setLayout(new BorderLayout(0, 6)); - - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double[] columnSize = {SETTING_LABEL_WIDTH, f}; - - // 确保BackgroundSpecialPane高度变化时,Label依然保持与其顶部对齐 - JPanel backgroundLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - backgroundLabelPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0)); - backgroundLabelPane.add(new UILabel(name), BorderLayout.NORTH); - - JPanel backgroundComposedPane = TableLayoutHelper.createGapTableLayoutPane( - new JComponent[][]{ - {backgroundLabelPane, backgroundPane} - }, - new double[]{p}, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); - - JPanel opacityComposedPane = TableLayoutHelper.createGapTableLayoutPane( - new JComponent[][]{ - {new UILabel(""), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Alpha"))}, - {new UILabel(""), opacityPane} - }, - new double[]{p, p}, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); - - container.add(backgroundComposedPane, BorderLayout.NORTH, 0); - container.add(opacityComposedPane, BorderLayout.CENTER, 1); - - opacityComposedPane.setVisible(false); - - backgroundPane.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - Background background = backgroundPane.update(); - opacityComposedPane.setVisible(background != null); - } - }); - - return container; + return i18nText("Fine-Design_Form_Widget_Style"); } protected static class BottomLineBorder extends LineBorder { @@ -574,4 +201,23 @@ public class LayoutStylePane extends BasicBeanPane { return new GradientBackgroundQuickPane(140); } } + + public void supportTitleStyle(boolean supportTitleVisible, boolean supportTitleContent, boolean supportOtherSetting) { + if (titleStylePane != null) { + titleStylePane.setSupportTitleVisible(supportTitleVisible); + titleStylePane.setSupportTitleContent(supportTitleContent); + titleStylePane.setSupportOtherSetting(supportOtherSetting); + } + } + + public void supportBodyStyle(boolean supporting) { + if (namedBodyStylePane != null) { + namedBodyStylePane.setVisible(supporting); + } + } + public void supportIntegralStyle(boolean supporting) { + if (namedIntegralStylePane != null) { + namedIntegralStylePane.setVisible(supporting); + } + } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/AbstractFormParallelLine.java b/designer-form/src/main/java/com/fr/design/mainframe/AbstractFormParallelLine.java new file mode 100644 index 0000000000..3fe9fededb --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/AbstractFormParallelLine.java @@ -0,0 +1,70 @@ +package com.fr.design.mainframe; + +import java.awt.Point; + +public abstract class AbstractFormParallelLine { + protected int parallelValue; + protected int startPosition; + protected int endPosition; + + public AbstractFormParallelLine(int parallelValue, int startPosition, int endPosition) { + this.parallelValue = parallelValue; + this.startPosition = startPosition; + this.endPosition = endPosition; + } + + public int getCenterPosition() { + return (startPosition + endPosition) / 2; + } + + /** + * 获取当前直线的中垂线起点位置 + * @return 中垂线起点位置 + */ + abstract public Point getStartPointOnVerticalCenterLine(); + + /** + * 获取当前直线的中垂线的重点位置,重点位置即为重垂线与另一条平行线相交的点 + * @param parallelValue 平行线 + * @return 中垂线重点位置 + */ + abstract public Point getEndPointOnVerticalCenterLine(int parallelValue); + + public boolean isVerticalCenterLineBeforeTheParallelLine(AbstractFormParallelLine parallelLine) { + return this.getCenterPosition() < parallelLine.getStartPosition(); + } + + public boolean isVerticalCenterLineBehindTheParallelLine(AbstractFormParallelLine parallelLine) { + return this.getCenterPosition() > parallelLine.getEndPosition(); + } + + /** + * 传一个平行线,当 当前直线和平行线中心点位置无平行相交的部分的时候,需要绘制一条延长线,一直延长到平行线边界位置 + * @param parallelLine 平行线 + * @return 延长线的起点位置 + */ + abstract public Point getExtendedLineStartPoint(AbstractFormParallelLine parallelLine); + + /** + * 传一个平行线,当 当前直线和平行线中心点位置无平行相交的部分的时候,需要绘制一条延长线,一直延长到平行线边界位置 + * @param parallelLine 平行线 + * @return 延长线的重点位置 + */ + abstract public Point getExtendedLineEndPoint(AbstractFormParallelLine parallelLine); + + public int getDistanceWithLine(AbstractFormParallelLine parallelLine) { + return Math.abs(this.getParallelValue() - parallelLine.getParallelValue()); + } + + public int getParallelValue() { + return parallelValue; + } + + public int getStartPosition() { + return startPosition; + } + + public int getEndPosition() { + return endPosition; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java index 0f39f089f8..2d0bb383fc 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java @@ -425,6 +425,7 @@ public class ComponentTree extends JTree { Rectangle rectangle = getRelativeBounds(comp); comp.showSelectedPopup(designer, rectangle, comp.acceptType(XWTitleLayout.class, XWCardMainBorderLayout.class, XWAbsoluteLayout.class)); comp.setSelected(true); + designer.repaint(); } /** diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index 292bfdb076..a7244c0f2a 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -34,9 +34,9 @@ import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.LayoutUtils; import com.fr.general.ComparatorUtils; +import com.fr.stable.ArrayUtils; import com.fr.stable.Constants; -import java.util.LinkedList; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JPopupMenu; @@ -49,6 +49,7 @@ import java.awt.Cursor; import java.awt.Insets; import java.awt.Rectangle; import java.awt.event.MouseEvent; +import java.util.LinkedList; /** * 普通模式下的鼠标点击、位置处理器 @@ -217,6 +218,7 @@ public class EditingMouseListener extends MouseInputAdapter { int oldX = e.getX(); int oldY = e.getY(); offsetEventPoint(e); + designer.getSpacingLineDrawer().updateMouseEvent(e, false); if (e.isPopupTrigger()) { if (stateModel.isDragging()) { stateModel.draggingCancel(); @@ -318,6 +320,8 @@ public class EditingMouseListener extends MouseInputAdapter { offsetEventPoint(e); XCreator component = designer.getComponentAt(e); + designer.getSpacingLineDrawer().updateMouseEvent(e, true); + setCoverPaneNotDisplay(component, e, false); if (processTopLayoutMouseMove(component, e)) { @@ -642,16 +646,15 @@ public class EditingMouseListener extends MouseInputAdapter { selectionModel.selectACreatorAtMouseEvent(e); refreshTopXCreator(); XCreator[] xCreators = selectionModel.getSelection().getSelectedCreators(); - // 放到事件队尾执行 - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - for (XCreator xCreator : xCreators) { - xCreator.setSelected(!e.isShiftDown() && !e.isControlDown()); + if (ArrayUtils.getLength(xCreators) == 1) { + // 放到事件队尾执行 + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + xCreators[0].setSelected(!e.isShiftDown() && !e.isControlDown()); } - } - }); - + }); + } } else if (clickedNonCardButton && uneditedTab && responseTabLayout(oldCreator, e)) { // do nothing } else { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java b/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java index 05cc34dfb6..16dc8593ec 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java @@ -175,14 +175,12 @@ public class FormArea extends JComponent implements ScrollRulerComponent { double[] rowSize = {f}; double[] columnSize = {p, f, p, p, p, p, p, f, p}; UILabel tipsPane = new UILabel("form"); - tipsPane.setPreferredSize(new Dimension(265, 0)); widthPane = new UINumberField(); widthPane.setPreferredSize(new Dimension(60, 0)); heightPane = new UINumberField(); heightPane.setPreferredSize(new Dimension(60, 0)); slidePane = JFormSliderPane.getInstance(); - slidePane.setPreferredSize(new Dimension(326, 20)); JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][]{{tipsPane, new UILabel(), widthPane, diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java index 7a6a73f4ba..9731dd5081 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -2,8 +2,12 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.chart.BaseChartCollection; +import com.fr.base.theme.TemplateThemeAware; +import com.fr.base.theme.TemplateThemeCompatible; import com.fr.chart.chartattr.ChartCollection; import com.fr.chartx.attr.ChartProvider; +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.TemplateTheme; import com.fr.design.DesignModelAdapter; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataTreePane; @@ -18,6 +22,7 @@ import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWParameterLayout; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.icon.IconPathConstants; @@ -27,9 +32,14 @@ import com.fr.design.mod.bean.ContentChangeItem; import com.fr.design.mod.event.TableDataModifyEvent; import com.fr.design.utils.ComponentUtils; import com.fr.event.EventDispatcher; +import com.fr.form.main.Form; +import com.fr.form.main.WidgetGather; import com.fr.form.share.editor.SharableEditorProvider; import com.fr.form.share.SharableWidgetProvider; import com.fr.form.share.ShareLoader; +import com.fr.form.ui.AbstractBorderStyleWidget; +import com.fr.form.ui.ChartEditor; +import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.Widget; import com.fr.stable.Constants; import com.fr.stable.StringUtils; @@ -139,6 +149,10 @@ public class FormCreatorDropTarget extends DropTarget { } EventDispatcher.fire(TableDataModifyEvent.INSTANCE, new ContentChangeItem(tdNameMap, widget, ChangeItem.TABLE_DATA_NAME)); } + + // 新疆的图表块和报表块默认主题化 + addThemeToNewWidget(addingXCreator); + designer.getSelectionModel().setSelectedCreators( FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{widget})); designer.getEditListenerTable().fireCreatorModified(addingModel.getXCreator(), DesignerEvent.CREATOR_ADDED); @@ -349,4 +363,37 @@ public class FormCreatorDropTarget extends DropTarget { public TabDragInner getTabDragInner() { return this.tabDragInner; } + + private void addThemeToNewWidget(XCreator addingXCreator) { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template == null) { + return; + } + TemplateTheme theme = template.getTemplateTheme(); + if (!(theme instanceof FormTheme)) { + return; + } + FormTheme formTheme = (FormTheme) theme; + + Form.traversalWidget(addingXCreator.toData(), new WidgetGather() { + @Override + public void dealWith(Widget widget) { + if (widget instanceof AbstractBorderStyleWidget) { + AbstractBorderStyleWidget styleWidget = (AbstractBorderStyleWidget) widget; + if (!styleWidget.supportThemed()) { + return; + } + + boolean followingTheme = (!addingXCreator.isShared()) || styleWidget.isBorderStyleFollowingTheme(); + styleWidget.setBorderStyleFollowingTheme(followingTheme); + if (followingTheme) { + styleWidget.onTemplateUsingThemeChange(formTheme, TemplateThemeCompatible.NONE); + } + } + } + @Override + public boolean dealWithAllCards() { return true; } + }, AbstractBorderStyleWidget.class); + addingXCreator.rebuid(); + } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java index 8d579d6fcf..92127c5a86 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java @@ -38,7 +38,6 @@ import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; -import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.event.DesignerOpenedListener; @@ -111,6 +110,10 @@ public class FormDesigner extends TargetComponent

implements TreeSelection Arrays.asList(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Cut"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Copy"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_Edit_Delete")}) ); + protected static final ArrayList PARAMETER_TOOLAR_BAN_LIST = new ArrayList( + Arrays.asList(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Cut"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Copy")}) + ); + private double scale = 1.0D; //底层容器的默认大小 @@ -127,6 +130,7 @@ public class FormDesigner extends TargetComponent implements TreeSelection private ConnectorHelper connectorHelper; private boolean isReportBlockEditing = false; private TopXCreators topXCreators; + private FormSpacingLineDrawer spacingLineDrawer; //组件重叠 private boolean isWidgetsIntersect = false; @@ -195,6 +199,8 @@ public class FormDesigner extends TargetComponent implements TreeSelection // 必须刷新"参数/控件树"面板,否则,若最近一次打开模版为 cpt,重启设计器,打开 frm,控件树消失 populateParameterPropertyPane(); + + spacingLineDrawer = new FormSpacingLineDrawer(this); } @@ -834,6 +840,38 @@ public class FormDesigner extends TargetComponent implements TreeSelection return null; } + /** + * 从root里面查找层级为level的控件 + */ + private XCreator xCreatorAt(int x, int y, XCreator root, int level) { + if (root == null || !root.isVisible()) { + return null; + } + x -= root.getX(); + y -= root.getY(); + + if (root instanceof XLayoutContainer) { + XLayoutContainer rootContainer = (XLayoutContainer) root; + int count = rootContainer.getXCreatorCount(); + for (int i = 0; i < count; i++) { + XCreator child = rootContainer.getXCreator(i); + XCreator dest = xCreatorAt(x, y, child, level); + + if (dest != null && dest.getLevel() == level) { + return dest; + } + } + } + + Rectangle rect = ComponentUtils.computeVisibleRect(root); + if (isIntersectArea(x, y, rect)) { + // 判断是否处于交叉区域 + return root; + } + + return null; + } + /** * 从已选择的组件中找x,y所在的组件 */ @@ -1094,25 +1132,38 @@ public class FormDesigner extends TargetComponent implements TreeSelection * */ @Override public XCreator getComponentAt(int x, int y) { - XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent; - if (container == null) { - container = rootComponent; - } - int relativeX = x + (int) (formArea.getHorizontalValue() / scale) - container.getX(); - int relativeY = y + (int) (formArea.getVerticalValue() / scale) - container.getY(); - XCreator result = xCreatorAt(relativeX, relativeY, container); + XLayoutContainer container = getRootContainer(y); + XCreator result = xCreatorAt(getRelativeScaleX(x) - container.getX(), getRelativeScaleY(y) - container.getY(), container); return result == null ? getComponentAt(x, y, null) : result; } @Nullable public XCreator getComponentAt(int x, int y, XCreator[] except) { + XLayoutContainer container = getRootContainer(y); + XCreator comp = xCreatorAt(getRelativeScaleX(x), getRelativeScaleY(y), container, except); + return comp == null ? container : comp; + } + + public XCreator getComponentAt(int x, int y, int level) { + XLayoutContainer container = getRootContainer(y); + XCreator comp = xCreatorAt(getRelativeScaleX(x), getRelativeScaleY(y), container, level); + return comp == null ? container : comp; + } + + public XLayoutContainer getRootContainer(int y) { XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent; if (container == null) { container = rootComponent; } - XCreator comp = xCreatorAt(x + (int)(formArea.getHorizontalValue()/scale), (int)(y + formArea.getVerticalValue()/scale), container, - except); - return comp == null ? container : comp; + return container; + } + + private int getRelativeScaleX(int x) { + return x + (int)(formArea.getHorizontalValue() / scale); + } + + private int getRelativeScaleY(int y) { + return y + (int)(formArea.getVerticalValue() / scale); } public SelectionModel getSelectionModel() { @@ -1220,6 +1271,11 @@ public class FormDesigner extends TargetComponent implements TreeSelection return isForm || isRoot(getSelectionModel().getSelection().getSelectedCreator()); } + public boolean isParameterSelected() { + XCreator xCreator = getSelectionModel().getSelection().getSelectedCreator(); + return xCreator != null && xCreator.acceptType(XWParameterLayout.class); + } + /** * 显示权限编辑界面 */ @@ -1253,6 +1309,10 @@ public class FormDesigner extends TargetComponent implements TreeSelection protected void setToolbarButtons() { //自适应布局和底层都不能删除 DesignerContext.getDesignerFrame().checkCombineUp(!isRootSelected(), NAME_ARRAY_LIST); + + if (isParameterSelected()) { + DesignerContext.getDesignerFrame().checkCombineUp(false, PARAMETER_TOOLAR_BAN_LIST); + } } private void invalidateLayout() { @@ -1338,6 +1398,18 @@ public class FormDesigner extends TargetComponent implements TreeSelection } } + public boolean isCurrentComponentCutable() { + return !(isRootSelected() || isParameterSelected()); + } + + public boolean isCurrentComponentCopyable() { + return !(isRootSelected() || isParameterSelected()); + } + + public boolean isCurrentComponentDeletable() { + return !isRootSelected(); + } + // 当前选中控件可以上移一层吗? public boolean isCurrentComponentMovableUp() { XCreator creator = getSelectionModel().getSelection().getSelectedCreator(); @@ -1765,4 +1837,20 @@ public class FormDesigner extends TargetComponent implements TreeSelection } } + public boolean isMultiSelection() { + XCreator[] creators = this.getSelectionModel().getSelection().getSelectedCreators(); + if (creators != null && creators.length > 1) { + for (int i = 0; i < creators.length - 1; i++) { + if (creators[i].getParent() != creators[i + 1].getParent() || !creators[i].isParentAbsolute()) { + return false; + } + } + return creators[creators.length - 1].isParentAbsolute(); + } + return false; + } + + public FormSpacingLineDrawer getSpacingLineDrawer() { + return spacingLineDrawer; + } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java index a8ddce03c9..776925044b 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java @@ -17,15 +17,15 @@ import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.utils.ComponentUtils; - import com.fr.form.main.parameter.FormParameterUI; import com.fr.page.WatermarkPainter; import com.fr.report.core.ReportUtils; import com.fr.stable.ArrayUtils; import com.fr.stable.Constants; -import java.awt.dnd.DropTarget; -import javax.swing.*; +import javax.swing.JComponent; +import javax.swing.SwingUtilities; +import javax.swing.SwingWorker; import javax.swing.plaf.ComponentUI; import java.awt.AlphaComposite; import java.awt.Color; @@ -33,6 +33,7 @@ import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; +import java.awt.dnd.DropTarget; import java.awt.geom.AffineTransform; import java.awt.geom.Area; import java.awt.geom.Rectangle2D; @@ -128,6 +129,8 @@ public class FormDesignerUI extends ComponentUI { // 当前正在添加的组件 paintAddingBean(g, addingModel); } + + designer.getSpacingLineDrawer().draw(g); } // 绘制水印 @@ -518,4 +521,8 @@ public class FormDesignerUI extends ComponentUI { designer.paintTopCreators(g); } + private void paintSpacingLine() { + + } + } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormHorizontalParallelLine.java b/designer-form/src/main/java/com/fr/design/mainframe/FormHorizontalParallelLine.java new file mode 100644 index 0000000000..f9acfcc7b5 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormHorizontalParallelLine.java @@ -0,0 +1,45 @@ +package com.fr.design.mainframe; + +import java.awt.Point; + +public class FormHorizontalParallelLine extends AbstractFormParallelLine { + public FormHorizontalParallelLine(int parallelValue, int startPosition, int endPosition) { + super(parallelValue, startPosition, endPosition); + } + + @Override + public Point getStartPointOnVerticalCenterLine() { + Point point = new Point(); + point.setLocation(getCenterPosition(), parallelValue); + return point; + } + + @Override + public Point getEndPointOnVerticalCenterLine(int parallelValue) { + Point point = new Point(); + point.setLocation(getCenterPosition(), parallelValue); + return point; + } + + @Override + public Point getExtendedLineStartPoint(AbstractFormParallelLine parallelLine) { + Point point = new Point(); + if (parallelLine.isVerticalCenterLineBeforeTheParallelLine(this)) { + point.setLocation(getStartPosition(), getParallelValue()); + } else if (parallelLine.isVerticalCenterLineBehindTheParallelLine(this)) { + point.setLocation(getEndPosition(), getParallelValue()); + } + return point; + } + + @Override + public Point getExtendedLineEndPoint(AbstractFormParallelLine parallelLine) { + Point point = new Point(); + if (parallelLine.isVerticalCenterLineBeforeTheParallelLine(this)) { + point.setLocation(parallelLine.getStartPosition(), getParallelValue()); + } else if (parallelLine.isVerticalCenterLineBehindTheParallelLine(this)) { + point.setLocation(parallelLine.getEndPosition(), getParallelValue()); + } + return point; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java index c25d99b1ae..5a34339175 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java @@ -109,7 +109,7 @@ public class FormSelection { } /** - * 是否是可以增加的 + * 是否是可以增加组件到已选中的组件里面 * * @param creator 组件 * @return 是则返回true diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java index 2900650aa0..7d3b17f5b7 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java @@ -10,6 +10,7 @@ import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.XWScaleLayout; import com.fr.design.designer.creator.XWTitleLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; @@ -60,6 +61,11 @@ public class FormSelectionUtils { */ public static void paste2Container(FormDesigner designer, XLayoutContainer parent, FormSelection clipboard, int x, int y) { + clipboard = filterFormSelection(clipboard, parent); + if (clipboard.isEmpty()) { + Toolkit.getDefaultToolkit().beep(); + return; + } LayoutAdapter adapter = parent.getLayoutAdapter(); if (parent instanceof XWAbsoluteLayout) { //绝对布局 @@ -77,6 +83,25 @@ public class FormSelectionUtils { Toolkit.getDefaultToolkit().beep(); } + private static FormSelection filterFormSelection(FormSelection clipboard, XLayoutContainer parent) { + for (XCreator xCreator : clipboard.getSelectedCreators()) { + if (parent.acceptType(XWParameterLayout.class)) { + if (!xCreator.canEnterIntoParaPane()) { + clipboard.removeCreator(xCreator); + } + } else if (parent.acceptType(XWAbsoluteLayout.class)) { + if (!xCreator.canEnterIntoAbsolutePane()) { + clipboard.removeCreator(xCreator); + } + } else if (parent.acceptType(XWFitLayout.class)) { + if (!xCreator.canEnterIntoAdaptPane()) { + clipboard.removeCreator(xCreator); + } + } + } + return clipboard; + } + private static boolean isExtraContainer(XLayoutContainer parent) { if (parent != null) { Set set = ExtraDesignClassManager.getInstance().getArray(FormWidgetOptionProvider.XML_TAG); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java new file mode 100644 index 0000000000..540c707d49 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java @@ -0,0 +1,252 @@ +package com.fr.design.mainframe; + +import com.fr.design.designer.creator.XChartEditor; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.XElementCase; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWParameterLayout; +import com.fr.design.form.parameter.FormParaDesigner; +import com.fr.design.form.util.FormDesignerUtils; +import com.fr.design.utils.ComponentUtils; +import com.fr.stable.Constants; +import com.fr.stable.GraphDrawHelper; + +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.awt.geom.RoundRectangle2D; + +public class FormSpacingLineDrawer { + private static final Color LINE_COLOR = new Color(230, 82, 81); + private static final Color TEXT_COLOR = new Color(255, 255, 255); + private static final int TEXT_PADDING_HORIZONTAL = 8; + private static final int TEXT_PADDING_VERTICAL = 2; + private static final int MIN_SPACING = 10; + private static final float TIP_FONT_SIZE = 10F; + + private FormDesigner designer; + private XCreator hoverCreator = null; + private Rectangle selectedRec; + private Rectangle hoveredRec; + private boolean isMouseMoveEvent = false; + + public FormSpacingLineDrawer(FormDesigner designer) { + this.designer = designer; + } + + public void updateMouseEvent(MouseEvent e, boolean isMouseMoveEvent) { + XCreator creator = designer.getSelectionModel().getSelection().getSelectedCreator(); + if (creator != null) { + this.hoverCreator = getHoverComponentAt(e.getX(), e.getY()); + } + this.isMouseMoveEvent = isMouseMoveEvent; + } + + public void draw(Graphics g) { + if (!isDrawSpacingLine()) { + return; + } + + if (!hoverCreator.isParentAbsolute()) { + return; + } + + this.selectedRec = designer.getSelectionModel().getSelection().getRelativeBounds(); + this.hoveredRec = ComponentUtils.getRelativeBounds(hoverCreator); + + drawHorizontalSpacingLine(g); + drawVerticalSpacingLine(g); + } + + private void drawHorizontalSpacingLine(Graphics g) { + AbstractFormParallelLine[] lines = getNearestHorizontalSide(); + drawSpacingLine(g, lines); + } + + private void drawVerticalSpacingLine(Graphics g) { + AbstractFormParallelLine[] lines = getNearestVerticalSide(); + drawSpacingLine(g, lines); + } + + private void drawSpacingLine(Graphics g, int startX, int startY, int endX, int endY) { + Graphics2D g2d = (Graphics2D) g.create(); + g2d.setColor(LINE_COLOR); + GraphDrawHelper.drawLine(g2d, startX, startY, endX, endY, Constants.LINE_THIN); + } + + private void drawSpacingLine(Graphics g, AbstractFormParallelLine[] nearestSides) { + if (nearestSides.length != 2) { + return; + } + int gap = nearestSides[0].getDistanceWithLine(nearestSides[1]); + if (gap <= MIN_SPACING) { + return; + } + + int startX = (int) nearestSides[0].getStartPointOnVerticalCenterLine().getX() - designer.getHorizontalScaleValue(); + int startY = (int) nearestSides[0].getStartPointOnVerticalCenterLine().getY() - designer.getVerticalScaleValue(); + int endX = (int) nearestSides[0].getEndPointOnVerticalCenterLine(nearestSides[1].getParallelValue()).getX() - designer.getHorizontalScaleValue(); + int endY = (int) nearestSides[0].getEndPointOnVerticalCenterLine(nearestSides[1].getParallelValue()).getY() - designer.getVerticalScaleValue(); + + drawSpacingLine(g, startX, startY, endX, endY); + drawSpacingText(g, String.valueOf(gap), (startX + endX) / 2, (startY + endY) / 2); + drawExtendedLine(g, nearestSides); + } + + private void drawExtendedLine(Graphics g, int startX, int startY, int endX, int endY) { + Graphics2D g2d = (Graphics2D) g.create(); + g2d.setColor(LINE_COLOR); + GraphDrawHelper.drawLine(g2d, startX, startY, endX, endY, Constants.LINE_DASH); + } + + private void drawExtendedLine(Graphics g, AbstractFormParallelLine[] nearestSides) { + if (isNeedExtendedLine(nearestSides)) { + int startX = (int) nearestSides[1].getExtendedLineStartPoint(nearestSides[0]).getX() - designer.getHorizontalScaleValue(); + int startY = (int) nearestSides[1].getExtendedLineStartPoint(nearestSides[0]).getY() - designer.getVerticalScaleValue(); + int endX = (int) nearestSides[1].getExtendedLineEndPoint(nearestSides[0]).getX() - designer.getHorizontalScaleValue(); + int endY = (int) nearestSides[1].getExtendedLineEndPoint(nearestSides[0]).getY() - designer.getVerticalScaleValue(); + drawExtendedLine(g, startX, startY, endX, endY); + } + } + + private void drawSpacingText(Graphics g, String text, int x, int y) { + Graphics2D g2d = (Graphics2D) g.create(); + g2d.setColor(LINE_COLOR); + Font newFont = g2d.getFont().deriveFont(TIP_FONT_SIZE).deriveFont(Font.BOLD); + g2d.setFont(newFont); + FontMetrics metrics = g2d.getFontMetrics(); + int lineHeight = metrics.getAscent(); // 这里由于都是数字,要居中必须忽略掉leading和descent的高度 + int lineWidth = metrics.stringWidth(text); + + int labelPaneX = x - lineWidth / 2 - TEXT_PADDING_HORIZONTAL; + int labelPaneY = y - lineHeight / 2 - TEXT_PADDING_VERTICAL; + int labelPaneWidth = lineWidth + 2 * TEXT_PADDING_HORIZONTAL; + int labelPaneHeight = lineHeight + 2 * TEXT_PADDING_VERTICAL; + int labelPaneArc = Math.min(labelPaneWidth, labelPaneHeight); + GraphDrawHelper.fill(g2d, new RoundRectangle2D.Double(labelPaneX, labelPaneY, labelPaneWidth, labelPaneHeight, labelPaneArc, labelPaneArc)); + + g2d.setColor(TEXT_COLOR); + int labelX = x - lineWidth / 2; + int labelY = y + (lineHeight - 2) / 2; // 由于ascent里面包含了一小段空白,数字又没有大写的情况,相当于五线行第一行是空的,所以往上微调一点来居中 + GraphDrawHelper.drawString(g2d, text, labelX, labelY); + } + + private boolean isSelectedParaComponent() { + return designer.getParaComponent() == designer.getSelectionModel().getSelection().getSelectedCreator(); + } + + private boolean isSelectedRootComponent() { + return designer.isRoot(designer.getSelectionModel().getSelection().getSelectedCreator()); + } + + private boolean isSelectedForm() { + return designer.getSelectionModel().getSelection().getSelectedCreator().getParent() == null; + } + + private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) { + return nearestSides[0].isVerticalCenterLineBeforeTheParallelLine(nearestSides[1]) || nearestSides[0].isVerticalCenterLineBehindTheParallelLine(nearestSides[1]); + } + + private boolean isSelectedRootPane() { + // form、body、para这三个选中了,都不要画任何间距线 + return isSelectedForm() || isSelectedRootComponent() || isSelectedParaComponent(); + } + + // 当前组件是否在参数面板里面 + private boolean isCompInPara(XCreator creator) { + XLayoutContainer container = XCreatorUtils.getHotspotContainer(creator); + + boolean xCreatorAccept = creator.acceptType(XWParameterLayout.class); + boolean containerAccept = container != null && container.acceptType(XWParameterLayout.class); + + return xCreatorAccept || containerAccept; + } + + private boolean isBodyAbsoluteLayout() { + return !(designer instanceof FormParaDesigner) && FormDesignerUtils.isBodyAbsolute(designer); + } + + private boolean isSelectedCompInPara() { + return isCompInPara(designer.getSelectionModel().getSelection().getSelectedCreator()); + } + + private boolean isHoveredCompInPara() { + return isCompInPara(hoverCreator); + } + + private boolean isSelectedCompOrHoveredCompInPara() { + return isSelectedCompInPara() || isHoveredCompInPara(); + } + + private boolean isDrawSpacingLine() { + return isBodyAbsoluteLayout() && !isSelectedRootPane() && hoverCreator != null && !isSelectedCompOrHoveredCompInPara() && isMouseMoveEvent; + } + + private AbstractFormParallelLine[] getNearestHorizontalSide() { + AbstractFormParallelLine[] selectedRecSides = new AbstractFormParallelLine[] { + new FormHorizontalParallelLine(selectedRec.y, selectedRec.x, selectedRec.x + selectedRec.width), + new FormHorizontalParallelLine(selectedRec.y + selectedRec.height, selectedRec.x, selectedRec.x + selectedRec.width) + }; + + AbstractFormParallelLine[] hoveredCreatorSides = new AbstractFormParallelLine[] { + new FormHorizontalParallelLine(hoveredRec.y, hoveredRec.x, hoveredRec.x + hoveredRec.width), + new FormHorizontalParallelLine(hoveredRec.y + hoveredRec.height, hoveredRec.x, hoveredRec.x + hoveredRec.width) + }; + return getNearestSide(selectedRecSides, hoveredCreatorSides); + } + + private AbstractFormParallelLine[] getNearestVerticalSide() { + AbstractFormParallelLine[] selectedRecSides = new AbstractFormParallelLine[] { + new FormVerticalParallelLine(selectedRec.x, selectedRec.y, selectedRec.y + selectedRec.height), + new FormVerticalParallelLine(selectedRec.x + selectedRec.width, selectedRec.y, selectedRec.y + selectedRec.height) + }; + + AbstractFormParallelLine[] hoveredCreatorSides = new AbstractFormParallelLine[] { + new FormVerticalParallelLine(hoveredRec.x, hoveredRec.y, hoveredRec.y + hoveredRec.height), + new FormVerticalParallelLine(hoveredRec.x + hoveredRec.width, hoveredRec.y, hoveredRec.y + hoveredRec.height) + }; + return getNearestSide(selectedRecSides, hoveredCreatorSides); + } + + private AbstractFormParallelLine[] getNearestSide(AbstractFormParallelLine[] lines1, AbstractFormParallelLine[] lines2) { + AbstractFormParallelLine[] nearestSides = new AbstractFormParallelLine[] {lines1[0], lines2[0]}; + int minDistance = lines1[0].getDistanceWithLine(lines2[0]); + for (int i = 0; i < lines1.length; i++) { + for (int j = 0; j < lines2.length; j++) { + int distance = lines1[i].getDistanceWithLine(lines2[j]); + if (distance < minDistance) { + minDistance = distance; + nearestSides[0] = lines1[i]; + nearestSides[1] = lines2[j]; + } + } + } + return nearestSides; + } + + private XCreator getHoverComponentAt(int x, int y) { + XCreator component = designer.getComponentAt(x, y); + XLayoutContainer parent = XCreatorUtils.getHotspotContainer(component).getTopLayout(); + if (parent != null) { + if (!parent.isEditable()) { + return parent; + } else { + if (parent == component) { + return null; + } + + if (component instanceof XChartEditor || component instanceof XElementCase) { + return (XCreator) component.getParent(); + } + return component; + } + } else { + return component; + } + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormVerticalParallelLine.java b/designer-form/src/main/java/com/fr/design/mainframe/FormVerticalParallelLine.java new file mode 100644 index 0000000000..19028bc25e --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormVerticalParallelLine.java @@ -0,0 +1,45 @@ +package com.fr.design.mainframe; + +import java.awt.Point; + +public class FormVerticalParallelLine extends AbstractFormParallelLine { + public FormVerticalParallelLine(int parallelValue, int startPosition, int endPosition) { + super(parallelValue, startPosition, endPosition); + } + + @Override + public Point getStartPointOnVerticalCenterLine() { + Point point = new Point(); + point.setLocation(parallelValue, getCenterPosition()); + return point; + } + + @Override + public Point getEndPointOnVerticalCenterLine(int parallelValue) { + Point point = new Point(); + point.setLocation(parallelValue, getCenterPosition()); + return point; + } + + @Override + public Point getExtendedLineStartPoint(AbstractFormParallelLine parallelLine) { + Point point = new Point(); + if (parallelLine.isVerticalCenterLineBeforeTheParallelLine(this)) { + point.setLocation(getParallelValue(), getStartPosition()); + } else if (parallelLine.isVerticalCenterLineBehindTheParallelLine(this)) { + point.setLocation(getParallelValue(), getEndPosition()); + } + return point; + } + + @Override + public Point getExtendedLineEndPoint(AbstractFormParallelLine parallelLine) { + Point point = new Point(); + if (parallelLine.isVerticalCenterLineBeforeTheParallelLine(this)) { + point.setLocation(getParallelValue(), parallelLine.getStartPosition()); + } else if (parallelLine.isVerticalCenterLineBehindTheParallelLine(this)) { + point.setLocation(getParallelValue(), parallelLine.getEndPosition()); + } + return point; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index d98e0e8f7c..04dd922430 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -6,7 +6,12 @@ import com.fr.base.Parameter; import com.fr.base.Releasable; import com.fr.base.extension.FileExtension; import com.fr.base.iofile.attr.ExtendSharableAttrMark; +import com.fr.base.theme.TemplateThemeCompatible; import com.fr.base.vcs.DesignerMode; +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.FormThemeConfig; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeConfig; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; import com.fr.design.ExtraDesignClassManager; @@ -39,6 +44,7 @@ import com.fr.design.fun.PreviewProvider; import com.fr.design.fun.PropertyItemPaneProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; +import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.xpane.FormHyperlinkGroupPane; @@ -49,6 +55,7 @@ import com.fr.design.mainframe.form.FormECCompositeProvider; import com.fr.design.mainframe.form.FormECDesignerProvider; import com.fr.design.mainframe.template.info.JFormProcessInfo; import com.fr.design.mainframe.template.info.TemplateProcessInfo; +import com.fr.design.mainframe.theme.dialog.TemplateThemeUsingDialog; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.menu.KeySetUtils; @@ -94,6 +101,7 @@ import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.SwingConstants; +import javax.swing.tree.TreePath; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; @@ -107,7 +115,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; -import javax.swing.tree.TreePath; public class JForm extends JTemplate implements BaseJForm, Releasable { private static final String FORM_CARD = "FORM"; @@ -234,6 +241,20 @@ public class JForm extends JTemplate implements BaseJForm dialog = new TemplateThemeUsingDialog<>(designerFrame, JForm.this, FormThemeConfig.getInstance()); + dialog.setVisible(true); + } + }); + return button; + } + //表单返回 FORM_TAB or ELEMENTCASE_TAB public int getEditingReportIndex() { return this.index; @@ -1138,4 +1159,44 @@ public class JForm extends JTemplate implements BaseJForm getUsingTemplateThemeConfig() { + return getTarget().getUsingTemplateThemeConfig(); + } + + @Override + public FormTheme getTemplateTheme() { + return getTarget().getTemplateTheme(); + } + + @Override + public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) { + FormTheme oldTheme = getTarget().getTemplateTheme(); + boolean shouldCreateUndoState = compatible == TemplateThemeCompatible.NONE && !StringUtils.equals(oldTheme.getName(), newTheme.getName()); + + getTarget().setTemplateTheme(newTheme, compatible); + + fireTargetModified(shouldCreateUndoState); + formDesign.refreshRoot(); + FormHierarchyTreePane.getInstance().refreshRoot(); + if (this.index != FORM_TAB) { + refreshToolArea(); + } + + super.setTemplateTheme(newTheme, compatible); + } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java b/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java new file mode 100644 index 0000000000..49dbc8c974 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java @@ -0,0 +1,280 @@ +package com.fr.design.mainframe; + +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.XWParameterLayout; +import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; +import com.fr.form.ui.container.WLayout; + +import java.awt.Rectangle; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +public class MultiSelectionArrangement { + private FormDesigner designer; + private XLayoutContainer parent; // 当前选中的那些组件所在父容器 + private List selectedCreators; + private Rectangle rec; + + public MultiSelectionArrangement(FormDesigner designer) { + this.designer = designer; + update(); + } + + public void leftAlign() { + for (XCreator creator : selectedCreators) { + creator.setLocation(rec.x, creator.getY()); + } + update(); + } + + public void rightAlign() { + for (XCreator creator : selectedCreators) { + creator.setLocation(rec.x + rec.width - creator.getWidth(), creator.getY()); + } + update(); + } + + public void topAlign() { + for (XCreator creator : selectedCreators) { + creator.setLocation(creator.getX(), rec.y); + } + update(); + } + + public void bottomAlign() { + for (XCreator creator : selectedCreators) { + creator.setLocation(creator.getX(), rec.y + rec.height - creator.getHeight()); + } + update(); + } + + public void horizontalCenterAlign() { + for (XCreator creator : selectedCreators) { + creator.setLocation(rec.x + rec.width / 2 - creator.getWidth() / 2, creator.getY()); + } + update(); + } + + public void verticalCenterAlign() { + for (XCreator creator : selectedCreators) { + creator.setLocation(creator.getX(), rec.y + rec.height / 2 - creator.getHeight() / 2); + } + update(); + } + + // 水平分布,自动,间距由selectedCreators和border共同计算而来 + public void horizontalAutoDistribution() { + sortHorizontal(); + int[] gaps = calculateHorizontalGaps(); + horizontalDistribution(gaps); + } + + // 水平分布,手动,传入一个间距,排列selectedCreators + public void horizontalManualDistribution(int gap) { + sortHorizontal(); + reSizeRecByHorizontal(gap); + horizontalDistribution(fillGaps(gap, selectedCreators.size() - 1)); + } + + private void horizontalDistribution(int[] gaps) { + for (int i = 1; i < selectedCreators.size() - 1; i++) { + XCreator creator = selectedCreators.get(i); + XCreator preCreator = selectedCreators.get(i - 1); + creator.setLocation(preCreator.getX() + preCreator.getWidth() + gaps[i - 1], creator.getY()); + } + update(); + } + + private void reSizeRecByHorizontal(int gap) { + int width = 0; + for (XCreator creator : selectedCreators) { + width += creator.getWidth(); + } + width += (selectedCreators.size() - 1) * gap; + rec.x = rec.x + (rec.width - width) / 2; + rec.width = width; + XCreator first = selectedCreators.get(0); + first.setLocation(rec.x, first.getY()); + XCreator last = selectedCreators.get(selectedCreators.size() - 1); + last.setLocation(rec.x + rec.width - last.getWidth(), last.getY()); + } + + private void sortHorizontal() { + Collections.sort(selectedCreators, new Comparator() { + @Override + public int compare(XCreator o1, XCreator o2) { + int diffX = o1.getX() - o2.getX(); + if (diffX > 0) { + return 1; + } else if (diffX < 0) { + return -1; + } else { + int diffY = o1.getY() - o2.getY(); + if (diffY > 0) { + return 1; + } else if (diffY < 0) { + return -1; + } else { + int diffZOrder = o1.getParent().getComponentZOrder(o1) - o2.getParent().getComponentZOrder(o2); + if (diffZOrder > 0) { + return -1; + } else { + return 1; + } + } + } + } + }); + } + + // 计算selectedCreators的均分间距 + private int[] calculateHorizontalGaps() { + int sum = 0; + for (XCreator creator : selectedCreators) { + sum += creator.getWidth(); + } + int gapCount = selectedCreators.size() - 1; + XCreator head = selectedCreators.get(0); + XCreator tail = selectedCreators.get(gapCount); + int distanceBetweenHeadAndTailCreators = Math.abs(head.getX() - tail.getX()) + tail.getWidth(); + return calculateIntegerGaps(distanceBetweenHeadAndTailCreators - sum, gapCount); + } + + public void verticalAutoDistribution() { + sortVertical(); + int[] gaps = calculateVerticalGaps(); + verticalDistribution(gaps); + } + + public void verticalManualDistribution(int gap) { + sortVertical(); + reSizeRecByVertical(gap); + verticalDistribution(fillGaps(gap, selectedCreators.size() - 1)); + } + + private void verticalDistribution(int[] gaps) { + for (int i = 1; i < selectedCreators.size() - 1; i++) { + XCreator creator = selectedCreators.get(i); + XCreator preCreator = selectedCreators.get(i - 1); + creator.setLocation(creator.getX(), preCreator.getY() + preCreator.getHeight() + gaps[i - 1]); + } + update(); + } + + private void reSizeRecByVertical(int gap) { + int height = 0; + for (XCreator creator : selectedCreators) { + height += creator.getHeight(); + } + height += (selectedCreators.size() - 1) * gap; + rec.y = rec.y + (rec.height - height) / 2; + rec.height = height; + XCreator first = selectedCreators.get(0); + first.setLocation(first.getX(), rec.y); + XCreator last = selectedCreators.get(selectedCreators.size() - 1); + last.setLocation(last.getX(), rec.y + rec.height - last.getHeight()); + } + + private void sortVertical() { + Collections.sort(selectedCreators, new Comparator() { + @Override + public int compare(XCreator o1, XCreator o2) { + int diffY = o1.getY() - o2.getY(); + if (diffY > 0) { + return 1; + } else if (diffY < 0) { + return -1; + } else { + int diffX = o1.getX() - o2.getX(); + if (diffX > 0) { + return 1; + } else if (diffX < 0) { + return -1; + } else { + int diffZOrder = o1.getParent().getComponentZOrder(o1) - o2.getParent().getComponentZOrder(o2); + if (diffZOrder > 0) { + return -1; + } else { + return 1; + } + } + } + } + }); + } + + private int[] calculateVerticalGaps() { + int sum = 0; + for (XCreator creator : selectedCreators) { + sum += creator.getHeight(); + } + int gapCount = selectedCreators.size() - 1; + XCreator head = selectedCreators.get(0); + XCreator tail = selectedCreators.get(gapCount); + int distanceBetweenHeadAndTailCreators = Math.abs(head.getY() - tail.getY()) + tail.getHeight(); + return calculateIntegerGaps(distanceBetweenHeadAndTailCreators - sum, gapCount); + } + + private int[] calculateIntegerGaps(int gapTotalSize, int gapCount) { + int finalGap[] = new int[gapCount]; + // gapTotalSize: 原先的所有未取整的gap的总和,是一个整数 + int intGap = Math.round((float) gapTotalSize / gapCount); + // 把所有取整的gap求和,得到的整数gap + int intTotalSize = intGap * (gapCount); + // 求差,可以知道总误差 + int difference = intTotalSize - gapTotalSize; + // 遍历,由于取整是四舍五入得到的,取整后每个gap和取整前的gap最多相差0.5,故difference绝对值小于gapCount的 + for (int i = 0; i < gapCount; i++) { + if (i < Math.abs(difference)) { + if (difference < 0) { + // 说明取整后gap总误差小于取整前总gap,一个个加1补上 + finalGap[i] = intGap + 1; + } else { + // 说明取整后gap总误差大于取整前总gap,一个个减1去掉 + finalGap[i] = intGap - 1; + } + } else { + finalGap[i] = intGap; + } + } + return finalGap; + } + + // 创建用gap填满一个size大小的数组 + private int[] fillGaps(int gap, int size) { + int[] gaps = new int[size]; + Arrays.fill(gaps, gap); + return gaps; + } + + private void update() { + FormSelection selection = designer.getSelectionModel().getSelection(); + this.selectedCreators = Arrays.asList(selection.getSelectedCreators()); + this.rec = selection.getSelctionBounds(); + this.parent = getParent(selection.getSelectedCreator()); + + if (parent != null) { + // 这里要修改修改engine里面的对象才能成功保存,光修改设计器对象没用 + WLayout wabs = parent.toData(); + for (XCreator creator : selectedCreators) { + wabs.setBounds(creator.toData(), creator.getBounds()); + } + } + } + + private XLayoutContainer getParent(XCreator source) { + if(source.acceptType(XWCardTagLayout.class)){ + return (XLayoutContainer)source.getParent(); + } + XLayoutContainer container = XCreatorUtils.getParentXLayoutContainer(source); + if (source.acceptType(XWFitLayout.class) || source.acceptType(XWParameterLayout.class)) { + container = null; + } + return container; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java b/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java index fd64d3aabd..e61e8a600e 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java @@ -5,25 +5,37 @@ import com.fr.design.ExtraDesignClassManager; import com.fr.design.constants.UIConstants; import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEvent; -import com.fr.design.designer.creator.*; +import com.fr.design.designer.creator.XComponent; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWAbsoluteLayout; +import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; import com.fr.design.designer.properties.mobile.MobileBookMarkPropertyUI; import com.fr.design.designer.properties.mobile.MobileStylePropertyUI; import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.gui.controlpane.EventPropertyPane; +import com.fr.design.gui.ibutton.UIHead; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itable.AbstractPropertyTable; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.widget.ui.FormWidgetCardPane; +import com.fr.design.mainframe.widget.ui.FormWidgetCardPaneFactory; import com.fr.design.widget.ui.designer.mobile.MobileWidgetDefinePane; - import com.fr.stable.ArrayUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.CardLayout; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -130,7 +142,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper * 创建属性表table */ private void createPropertyTable() { - formWidgetCardPane = new FormWidgetCardPane(designer); + formWidgetCardPane = FormWidgetCardPaneFactory.create(designer); designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(formWidgetCardPane)); psp = new UIScrollPane(formWidgetCardPane); // 用来装载属性表table psp.setBorder(null); @@ -141,6 +153,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper */ private void createEventTable() { eventTable = new EventPropertyPane(designer); + eventTable.setEnabled(false); designer.addDesignerEditListener(new EventPropertyDesignerAdapter(eventTable)); } @@ -235,6 +248,15 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Event"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Mobile_Terminal") }; + List uiHeads = new ArrayList(){ + private static final long serialVersionUID = -2456634893793575347L; + { + add(new UIHead(tabTitles[0], 0)); + add(new UIHead(tabTitles[1], 1, !designer.isMultiSelection())); + add(new UIHead(tabTitles[2], 2, !designer.isMultiSelection())); + } + + }; final CardLayout tabbedPane = new CardLayout(); final JPanel center = new JPanel(tabbedPane); center.add(formWidgetCardPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Properties")); @@ -242,7 +264,9 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper center.add(wsp, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Mobile_Terminal")); this.add(center, BorderLayout.CENTER); - tabsHeaderIconPane = new UIHeadGroup(tabTitles) { + tabsHeaderIconPane = new UIHeadGroup(uiHeads) { + private static final long serialVersionUID = -6739508210752677967L; + @Override public void tabChanged(int index) { //切换的时候再populate @@ -388,20 +412,6 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper if (!isValid) { return; } - //fanglei:下面的注释不要删,只是暂时屏蔽 -// int value = downPanel.getVerticalScrollBar().getValue(); -// if (hasSelectParaPane(getEditingFormDesigner())) { -// cardLayout.show(centerPane, PARA); -// mobileParaWidgetTable.refreshData(); -// } else { -// cardLayout.show(centerPane, BODY); -// mobileWidgetTable.refreshData(); -// } -// //出现滚动条 -// downPanel.doLayout(); -// //控件列表选中某组件,触发表单中选中控件,选中事件又触发列表刷新,滚动条回到0 -// //此处设置滚动条值为刷新前 -// downPanel.getVerticalScrollBar().setValue(value); if (mobileExtraPropertyPanes != null) { for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) { extraPane.populate(designer); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/action/InstallComponentAction.java b/designer-form/src/main/java/com/fr/design/mainframe/share/action/InstallComponentAction.java index d3173e36bf..a845759f73 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/action/InstallComponentAction.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/action/InstallComponentAction.java @@ -4,7 +4,9 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; -import com.fr.design.gui.ifilechooser.UINativeFileChooser; +import com.fr.design.gui.ifilechooser.FileChooserProvider; +import com.fr.design.gui.ifilechooser.FileSelectionMode; +import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; @@ -17,6 +19,8 @@ import com.fr.design.os.impl.SupportOSImpl; import com.fr.form.share.record.ShareWidgetInfoManager; import com.fr.form.share.utils.ReuxUtils; import com.fr.log.FineLoggerFactory; +import com.sun.javafx.tk.FileChooserType; +import javafx.stage.FileChooser; import javax.swing.Action; import javax.swing.JFileChooser; @@ -42,23 +46,17 @@ public class InstallComponentAction extends UpdateAction { @Override public void actionPerformed(ActionEvent e) { - - if (SupportOSImpl.NATIVE_CHOOSER.support()) { - UINativeFileChooser nativeFileChooser = new UINativeFileChooser(); - nativeFileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); - nativeFileChooser.setMultiSelectionEnabled(true); - nativeFileChooser.setFileFilter(new FileNameExtensionFilter("reu reus", "reu", "reus")); - nativeFileChooser.setDialogTitle(Toolkit.i18nText("Fine-Design_Basic_Select")); - int returnValue = nativeFileChooser.showOpenDialog(new UILabel()); - installComponent(returnValue, nativeFileChooser.getSelectedFiles()); - } else { - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); - fileChooser.setMultiSelectionEnabled(true); - fileChooser.setFileFilter(new FileNameExtensionFilter("reu reus", "reu", "reus")); - int returnValue = fileChooser.showDialog(new UILabel(), Toolkit.i18nText("Fine-Design_Basic_Select")); - installComponent(returnValue, fileChooser.getSelectedFiles()); - } + FileChooserProvider fileChooserProvider = + new JavaFxNativeFileChooser.Builder(). + fileSelectionMode(FileSelectionMode.MULTIPLE_FILE). + title(Toolkit.i18nText("Fine-Design_Basic_Select")). + filters(new FileChooser.ExtensionFilter[]{ + new FileChooser.ExtensionFilter("reu", "*.reu"), + new FileChooser.ExtensionFilter("reus", "*.reus"), + new FileChooser.ExtensionFilter("zip", "*.zip")}). + build(); + int returnValue = fileChooserProvider.showDialog(null); + installComponent(returnValue, fileChooserProvider.getSelectedFiles()); } private void installComponent(int returnValue, File[] selectedFiles) { @@ -122,7 +120,7 @@ public class InstallComponentAction extends UpdateAction { private boolean containRues(File[] chosenFiles) { for (File file : chosenFiles) { - if (file.getName().endsWith(ReuxUtils.REUS_SUFFIX)) + if (ReuxUtils.isReusFile(file)) return true; } return false; @@ -144,8 +142,7 @@ public class InstallComponentAction extends UpdateAction { return false; } ShareComponentUtils.checkReadMe(); - boolean isReus = chosenFile.getName().endsWith(ReuxUtils.REUS_SUFFIX); - return isReus ? InstallUtils.installReusFile(chosenFile, installTime, failList) : InstallUtils.installReuFile(chosenFile, installTime, failList); + return ReuxUtils.isReusFile(chosenFile) ? InstallUtils.installReusFile(chosenFile, installTime, failList) : InstallUtils.installReuFile(chosenFile, installTime, failList); } private static class InstallBackInfo { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java index af329cde8b..c07485745d 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java @@ -14,6 +14,7 @@ import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.JPanel; +import javax.swing.JTextField; import javax.swing.SwingConstants; import javax.swing.SwingWorker; import java.awt.BorderLayout; @@ -164,9 +165,14 @@ public class OnlineWidgetRepoPane extends BasicPane { tipLabel1.setForeground(Color.decode("#8F8F92")); UILabel tipLabel2 = tipLabel(Toolkit.i18nText("Fine-Design_Share_Internet_Connect_Failed_Tip2")); tipLabel2.setForeground(Color.decode("#8F8F92")); - UILabel tipLabel3 = tipLabel(MARKET_URL); - tipLabel3.setForeground(Color.decode("#8F8F92")); + JTextField tipLabel3 = new JTextField(MARKET_URL); + tipLabel3.setHorizontalAlignment(JTextField.CENTER); + tipLabel3.setPreferredSize(new Dimension(240, 20)); + tipLabel3.setEditable(false); + tipLabel3.setForeground(Color.decode("#8F8F92")); + tipLabel3.setBackground(null); + tipLabel3.setBorder(null); UILabel emptyLabel = tipLabel(StringUtils.EMPTY); panel.add(uiLabel); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/widgetpackage/OnlineWidgetPackagesShowPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/widgetpackage/OnlineWidgetPackagesShowPane.java index d9697495b4..887b7c34a4 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/widgetpackage/OnlineWidgetPackagesShowPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/widgetpackage/OnlineWidgetPackagesShowPane.java @@ -1,10 +1,13 @@ package com.fr.design.mainframe.share.ui.online.widgetpackage; +import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.login.DesignerLoginHelper; +import com.fr.design.login.DesignerLoginSource; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.share.ui.base.MouseClickListener; import com.fr.design.mainframe.share.ui.online.AbstractOnlineWidgetShowPane; @@ -64,6 +67,11 @@ public class OnlineWidgetPackagesShowPane extends AbstractOnlineWidgetShowPane { downloadLabel = createLabel(Toolkit.i18nText("Fine-Design_Share_Download_All_Component"), new MouseClickListener() { @Override public void mouseClicked(MouseEvent e) { + String userName = DesignerEnvManager.getEnvManager().getDesignerLoginUsername(); + if (StringUtils.isEmpty(userName)) { + DesignerLoginHelper.showLoginDialog(DesignerLoginSource.NORMAL); + return; + } String message = Toolkit.i18nText("Fine-Design_Share_Download_All_Component_Message") + "\n" + Toolkit.i18nText("Fine-Design_Share_Total") diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/util/InstallUtils.java b/designer-form/src/main/java/com/fr/design/mainframe/share/util/InstallUtils.java index c25f53f515..610f688a46 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/util/InstallUtils.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/util/InstallUtils.java @@ -84,7 +84,7 @@ public class InstallUtils { @Nullable private static Group createComponentGroup(String fileName) { - String groupName = fileName.substring(0, fileName.indexOf(DOT + ReuxUtils.REUS_SUFFIX)); + String groupName = createGroupName(fileName); //有重名分组则加后缀 if (DefaultShareGroupManager.getInstance().getGroup(groupName) != null) { @@ -101,6 +101,15 @@ public class InstallUtils { return DefaultShareGroupManager.getInstance().getGroup(groupName); } + private static String createGroupName(String fileName) { + for (String suffix : ReuxUtils.SUPPORT_REUS_SUFFIX) { + if (fileName.endsWith(suffix)) { + return fileName.substring(0, fileName.indexOf(DOT + suffix)); + } + } + return fileName; + } + private static boolean installReuFile(Group group, File chosenFile, long installTime) { try { if (!group.installModule(chosenFile)) { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/AbstractMultiSelectionArrangementButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/AbstractMultiSelectionArrangementButton.java new file mode 100644 index 0000000000..dc268f4c5b --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/AbstractMultiSelectionArrangementButton.java @@ -0,0 +1,32 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.mainframe.MultiSelectionArrangement; + +public abstract class AbstractMultiSelectionArrangementButton extends UIButton implements MultiSelectionArrangementButton, UIObserver { + private static final long serialVersionUID = -2114423583742242771L; + protected MultiSelectionArrangement arrangement; + protected UIObserverListener uiObserverListener; + + public AbstractMultiSelectionArrangementButton(MultiSelectionArrangement arrangement) { + super(); + this.arrangement = arrangement; + this.setNormalPainted(false); + this.setBorderPaintedOnlyWhenPressed(true); + this.setIcon(getIcon()); + this.setToolTipText(getTipText()); + this.addActionListener(getActionListener()); + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + uiObserverListener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/BottomAlignButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/BottomAlignButton.java new file mode 100644 index 0000000000..99bf3a6c3a --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/BottomAlignButton.java @@ -0,0 +1,36 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.general.IOUtils; + +import javax.swing.Icon; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class BottomAlignButton extends AbstractMultiSelectionArrangementButton { + public BottomAlignButton(MultiSelectionArrangement arrangement) { + super(arrangement); + } + + @Override + public Icon getIcon() { + return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_bottom_align.png"); + } + + @Override + public String getTipText() { + return Toolkit.i18nText("Fine-Design_Multi_Selection_Bottom_Align"); + } + + @Override + public ActionListener getActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + arrangement.bottomAlign(); + uiObserverListener.doChange(); + } + }; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalCenterButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalCenterButton.java new file mode 100644 index 0000000000..6dc9c09b4a --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalCenterButton.java @@ -0,0 +1,36 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.general.IOUtils; + +import javax.swing.Icon; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class HorizontalCenterButton extends AbstractMultiSelectionArrangementButton { + public HorizontalCenterButton(MultiSelectionArrangement arrangement) { + super(arrangement); + } + + @Override + public Icon getIcon() { + return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_horizontal_center_align.png"); + } + + @Override + public String getTipText() { + return Toolkit.i18nText("Fine-Design_Multi_Selection_Horizontal_Center_Align"); + } + + @Override + public ActionListener getActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + arrangement.horizontalCenterAlign(); + uiObserverListener.doChange(); + } + }; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalDistributionButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalDistributionButton.java new file mode 100644 index 0000000000..0a0e225fc6 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalDistributionButton.java @@ -0,0 +1,36 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.general.IOUtils; + +import javax.swing.Icon; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class HorizontalDistributionButton extends AbstractMultiSelectionArrangementButton { + public HorizontalDistributionButton(MultiSelectionArrangement arrangement) { + super(arrangement); + } + + @Override + public Icon getIcon() { + return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_horizontal_auto_spacing.png"); + } + + @Override + public String getTipText() { + return Toolkit.i18nText("Fine-Design_Multi_Selection_Auto_Horizontal_Spacing"); + } + + @Override + public ActionListener getActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + arrangement.horizontalAutoDistribution(); + uiObserverListener.doChange(); + } + }; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/LeftAlignButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/LeftAlignButton.java new file mode 100644 index 0000000000..20a25a87cb --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/LeftAlignButton.java @@ -0,0 +1,36 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.general.IOUtils; + +import javax.swing.Icon; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class LeftAlignButton extends AbstractMultiSelectionArrangementButton { + public LeftAlignButton(MultiSelectionArrangement arrangement) { + super(arrangement); + } + + @Override + public Icon getIcon() { + return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_left_align.png"); + } + + @Override + public String getTipText() { + return Toolkit.i18nText("Fine-Design_Multi_Selection_Left_Align"); + } + + @Override + public ActionListener getActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + arrangement.leftAlign(); + uiObserverListener.doChange(); + } + }; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/MultiSelectionArrangementButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/MultiSelectionArrangementButton.java new file mode 100644 index 0000000000..99b7635708 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/MultiSelectionArrangementButton.java @@ -0,0 +1,12 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import javax.swing.Icon; +import java.awt.event.ActionListener; + +public interface MultiSelectionArrangementButton { + Icon getIcon(); + + String getTipText(); + + ActionListener getActionListener(); +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/RightAlignButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/RightAlignButton.java new file mode 100644 index 0000000000..5fac70bd7a --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/RightAlignButton.java @@ -0,0 +1,36 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.general.IOUtils; + +import javax.swing.Icon; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class RightAlignButton extends AbstractMultiSelectionArrangementButton { + public RightAlignButton(MultiSelectionArrangement arrangement) { + super(arrangement); + } + + @Override + public Icon getIcon() { + return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_right_align.png"); + } + + @Override + public String getTipText() { + return Toolkit.i18nText("Fine-Design_Multi_Selection_Right_Align"); + } + + @Override + public ActionListener getActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + arrangement.rightAlign(); + uiObserverListener.doChange(); + } + }; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/TopAlignButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/TopAlignButton.java new file mode 100644 index 0000000000..ebb2c4d21a --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/TopAlignButton.java @@ -0,0 +1,36 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.general.IOUtils; + +import javax.swing.Icon; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class TopAlignButton extends AbstractMultiSelectionArrangementButton { + public TopAlignButton(MultiSelectionArrangement arrangement) { + super(arrangement); + } + + @Override + public Icon getIcon() { + return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_top_align.png"); + } + + @Override + public String getTipText() { + return Toolkit.i18nText("Fine-Design_Multi_Selection_Top_Align"); + } + + @Override + public ActionListener getActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + arrangement.topAlign(); + uiObserverListener.doChange(); + } + }; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalCenterButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalCenterButton.java new file mode 100644 index 0000000000..9898f9002c --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalCenterButton.java @@ -0,0 +1,36 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.general.IOUtils; + +import javax.swing.Icon; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class VerticalCenterButton extends AbstractMultiSelectionArrangementButton { + public VerticalCenterButton(MultiSelectionArrangement arrangement) { + super(arrangement); + } + + @Override + public Icon getIcon() { + return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_vertical_center_align.png"); + } + + @Override + public String getTipText() { + return Toolkit.i18nText("Fine-Design_Multi_Selection_Vertical_Center_Align"); + } + + @Override + public ActionListener getActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + arrangement.verticalCenterAlign(); + uiObserverListener.doChange(); + } + }; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalDistributionButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalDistributionButton.java new file mode 100644 index 0000000000..50ec6ac894 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalDistributionButton.java @@ -0,0 +1,36 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.general.IOUtils; + +import javax.swing.Icon; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class VerticalDistributionButton extends AbstractMultiSelectionArrangementButton { + public VerticalDistributionButton(MultiSelectionArrangement arrangement) { + super(arrangement); + } + + @Override + public Icon getIcon() { + return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_vertical_auto_spacing.png"); + } + + @Override + public String getTipText() { + return Toolkit.i18nText("Fine-Design_Multi_Selection_Auto_Vertical_Spacing"); + } + + @Override + public ActionListener getActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + arrangement.verticalAutoDistribution(); + uiObserverListener.doChange(); + } + }; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java new file mode 100644 index 0000000000..ffd2a0f74e --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java @@ -0,0 +1,211 @@ +package com.fr.design.mainframe.widget.ui; + +import com.fr.design.designer.beans.events.DesignerEvent; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UINumberField; +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.FormDesigner; +import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.design.mainframe.widget.arrangement.buttons.BottomAlignButton; +import com.fr.design.mainframe.widget.arrangement.buttons.HorizontalCenterButton; +import com.fr.design.mainframe.widget.arrangement.buttons.HorizontalDistributionButton; +import com.fr.design.mainframe.widget.arrangement.buttons.LeftAlignButton; +import com.fr.design.mainframe.widget.arrangement.buttons.RightAlignButton; +import com.fr.design.mainframe.widget.arrangement.buttons.TopAlignButton; +import com.fr.design.mainframe.widget.arrangement.buttons.VerticalCenterButton; +import com.fr.design.mainframe.widget.arrangement.buttons.VerticalDistributionButton; +import com.fr.general.IOUtils; +import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; + +public class FormMultiWidgetCardPane extends FormWidgetCardPane { + private AttributeChangeListener listener; + private MultiSelectionArrangement arrangement; + + public FormMultiWidgetCardPane(FormDesigner designer) { + super(designer); + } + + public void initPropertyPane() { + arrangement = new MultiSelectionArrangement(designer); + content.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0)); + content.add(createArrangementLayoutPane(), BorderLayout.CENTER); + this.listener = new AttributeChangeListener() { + @Override + public void attributeChange() { + designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_RESIZED); + } + }; + } + + // 整个排列分布面板的layout,可以看成一个三行一列的表格,第一行是分布,第二行是自动间距,第三行是手动间距 + private JPanel createArrangementLayoutPane() { + double[] rowSize = {TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; + double[] columnSize = {TableLayout.PREFERRED}; + Component[][] components = new Component[][] { + new Component[] { + createAlignmentPane() + }, + new Component[] { + createAutoSpacingPane() + } + }; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 16); + } + + // 对齐 + private JPanel createAlignmentPane() { + double[] rowSize = {TableLayout.PREFERRED}; + double[] columnSize = { + TableLayout.PREFERRED, + TableLayout.PREFERRED, + TableLayout.PREFERRED, + TableLayout.PREFERRED, + TableLayout.PREFERRED, + TableLayout.PREFERRED + }; + Component[][] components = new Component[][] { + new Component[] { + new LeftAlignButton(arrangement), + new HorizontalCenterButton(arrangement), + new RightAlignButton(arrangement), + new TopAlignButton(arrangement), + new VerticalCenterButton(arrangement), + new BottomAlignButton(arrangement) + } + }; + JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 18, 0); + return createTitleLayout(Toolkit.i18nText("Fine-Design_Multi_Selection_Align"), centerPane); + } + + // 自动间距 + private JPanel createAutoSpacingPane() { + double[] rowSize = {TableLayout.PREFERRED}; + double[] columnSize = { + TableLayout.PREFERRED, + TableLayout.PREFERRED + }; + UIButton horizontalAutoSpacingBtn = new HorizontalDistributionButton(arrangement); + UIButton verticalAutoSpacingBtn = new VerticalDistributionButton(arrangement); + if (designer.getSelectionModel().getSelection().size() < 3) { + horizontalAutoSpacingBtn.setEnabled(false); + verticalAutoSpacingBtn.setEnabled(false); + } + Component[][] components = new Component[][] { + new Component[] { + horizontalAutoSpacingBtn, + verticalAutoSpacingBtn + } + }; + JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 18, 0); + + + UILabel tip = new UILabel(IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_auto_spacing_tip.png")); + tip.setToolTipText(Toolkit.i18nText("Fine-Design_Multi_Selection_Auto_Spacing_Tip")); + Component[][] titleComponents = new Component[][] { + new Component[] { + new UILabel(Toolkit.i18nText("Fine-Design_Multi_Selection_Auto_Spacing")), + tip + } + }; + JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(titleComponents, rowSize, columnSize, 5, 0); + + JPanel jPanel = new JPanel(); + jPanel.setLayout(new BorderLayout(0, 8)); + jPanel.add(northPane, BorderLayout.NORTH); + jPanel.add(centerPane, BorderLayout.CENTER); + return jPanel; + } + + // 手动间距 + private JPanel createManualSpacingPane() { + double[] rowSize = {TableLayout.PREFERRED, TableLayout.PREFERRED}; + double[] columnSize = { + TableLayout.PREFERRED, + TableLayout.FILL + }; + UITextField horizontalSpacingNumberField = createIntNumberField(false, Toolkit.i18nText("Fine-Design_Multi_Selection_Manual_Horizontal_Spacing_Tip")); + UITextField verticalSpacingNumberField = createIntNumberField(true, Toolkit.i18nText("Fine-Design_Multi_Selection_Manual_Vertical_Spacing_Tip")); + Component[][] components = new Component[][] { + new Component[] { + new UILabel(IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_horizontal_spacing.png")), + horizontalSpacingNumberField + }, + new Component[] { + new UILabel(IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_vertical_spacing.png")), + verticalSpacingNumberField + } + }; + JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 21, 9); + return createTitleLayout(Toolkit.i18nText("Fine-Design_Multi_Selection_Manual_Spacing"), centerPane); + } + + private UINumberField createIntNumberField(boolean isVertical, String tipText) { + final UINumberField numberField = new UINumberField() { + private static final long serialVersionUID = -448512934137620557L; + + public boolean shouldResponseChangeListener() { + return false; + } + }; + numberField.setPlaceholder(tipText); + numberField.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + distributionDoChange(numberField, isVertical); + } + }); + numberField.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + distributionDoChange(numberField, isVertical); + } + } + }); + return numberField; + } + + private void distributionDoChange(UINumberField numberField, boolean isVertical) { + String text = numberField.getText(); + if (StringUtils.isNotEmpty(text) && StableUtils.isNumber(text)) { + int gap = (int) Math.floor(Float.parseFloat(text)); + numberField.setValue(gap); + if (isVertical) { + arrangement.verticalManualDistribution(gap); + } else { + arrangement.horizontalManualDistribution(gap); + } + attributeChanged(); + } + } + + // 创建一个BorderLayout布局,上面是标题,例如“对齐”,下面是个容器 + private JPanel createTitleLayout(String title, JPanel centerPane) { + JPanel jPanel = new JPanel(); + jPanel.setLayout(new BorderLayout(0, 8)); + jPanel.add(new UILabel(title), BorderLayout.NORTH); + jPanel.add(centerPane, BorderLayout.CENTER); + return jPanel; + } + + @Override + public void populate() { + initListener(this); + this.addAttributeChangeListener(listener); + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormSingleWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormSingleWidgetCardPane.java new file mode 100644 index 0000000000..9f0c44ded3 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormSingleWidgetCardPane.java @@ -0,0 +1,298 @@ +package com.fr.design.mainframe.widget.ui; + +import com.fr.design.base.mode.DesignModeContext; +import com.fr.design.data.DataCreatorUI; +import com.fr.design.designer.beans.events.DesignerEvent; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWAbsoluteBodyLayout; +import com.fr.design.designer.creator.XWAbsoluteLayout; +import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.XWParameterLayout; +import com.fr.design.designer.creator.XWScaleLayout; +import com.fr.design.designer.creator.XWTitleLayout; +import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.foldablepane.UIExpandablePane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.EastRegionContainerPane; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.JForm; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.widget.DataModify; +import com.fr.design.widget.FormWidgetDefinePaneFactoryBase; +import com.fr.design.widget.Operator; +import com.fr.design.widget.ui.designer.component.WidgetAbsoluteBoundPane; +import com.fr.design.widget.ui.designer.component.WidgetBoundPane; +import com.fr.design.widget.ui.designer.component.WidgetCardTagBoundPane; +import com.fr.form.ui.ChartEditor; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WScaleLayout; +import com.fr.form.ui.container.WTitleLayout; +import com.fr.form.ui.widget.CRBoundsWidget; +import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import java.awt.BorderLayout; + +public class FormSingleWidgetCardPane extends FormWidgetCardPane { + private AttributeChangeListener listener; + + //当前的编辑器属性定义面板 + private DataModify currentEditorDefinePane; + private FormBasicPropertyPane widgetPropertyPane; + private JPanel attriCardPane; + + private XCreator xCreator; + private WidgetBoundPane widgetBoundPane; + + + public FormSingleWidgetCardPane(FormDesigner designer) { + super(designer); + } + + public void initPropertyPane() { + this.xCreator = findXcreator(designer); + initComponents(); + initDefinePane(); + } + + public XLayoutContainer getParent(XCreator source) { + XLayoutContainer container = XCreatorUtils.getParentXLayoutContainer(source); + if (source.acceptType(XWFitLayout.class) || source.acceptType(XWParameterLayout.class)) { + container = null; + } + return container; + } + + public WidgetBoundPane createWidgetBoundPane(XCreator xCreator) { + XLayoutContainer xLayoutContainer = getParent(xCreator); + if (xLayoutContainer == null || xCreator.acceptType(XWParameterLayout.class) || xCreator.acceptType(XWAbsoluteBodyLayout.class)) { + return null; + } else if (xLayoutContainer.acceptType(XWAbsoluteLayout.class)) { + return new WidgetAbsoluteBoundPane(xCreator); + } else if (xCreator.acceptType(XWCardTagLayout.class)) { + return new WidgetCardTagBoundPane(xCreator); + } + return new WidgetBoundPane(xCreator); + } + + public XCreator findXcreator(FormDesigner designer) { + XCreator creator = designer.getSelectionModel().getSelection().getSelectedCreator(); + return creator != null ? creator : designer.getRootComponent(); + } + + /** + * 后台初始化所有事件. + */ + @Override + public void initAllListeners() { + + } + + /** + * 后台初始化所有事件. + */ + public void reinitAllListeners() { + initListener(this); + } + + @Override + protected void initContentPane() { + + } + + private void initComponents() { + XCreator innerCreator = getXCreatorDedicated(); + + attriCardPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + content.add(attriCardPane, BorderLayout.CENTER); + content.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); + + final boolean isExtraWidget = FormWidgetDefinePaneFactoryBase.isExtraXWidget(innerCreator.toData()); + this.listener = new AttributeChangeListener() { + @Override + public void attributeChange() { + if (!isExtraWidget) { + updateCreator(); + } + updateWidgetBound(); + firePropertyEdit(); + } + }; + + freshPropertyMode(innerCreator); + if (isExtraWidget) { + // REPORT-55603: 仅对于插件控件,将尺寸*位置面板放置在definePane下方,其余控件将尺寸*位置面板放置在definePane上方 + widgetBoundPane = createWidgetBoundPane(xCreator); + if (widgetBoundPane != null) { + attriCardPane.add(widgetBoundPane, BorderLayout.CENTER); + } + return; + } + + widgetPropertyPane = WidgetBasicPropertyPaneFactory.createBasicPropertyPane(innerCreator); + + UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Basic"), 280, 20, widgetPropertyPane); + + content.add(uiExpandablePane, BorderLayout.NORTH); + + widgetBoundPane = createWidgetBoundPane(xCreator); + if (widgetBoundPane != null) { + attriCardPane.add(widgetBoundPane, BorderLayout.NORTH); + } + } + + private static void freshPropertyMode(XCreator xCreator) { + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (!(jTemplate instanceof JForm) && jTemplate.isUpMode() && !DesignModeContext.isAuthorityEditing()) { + if (xCreator instanceof XWParameterLayout) { + EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_PARA); + } else { + EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_PARA_WIDGET); + } + } + } + + private void initDefinePane() { + currentEditorDefinePane = null; + XCreator creator = getXCreatorDedicated(); + FormWidgetDefinePaneFactoryBase.RN rn = FormWidgetDefinePaneFactoryBase.createWidgetDefinePane(creator, designer, creator.toData(), new Operator() { + @Override + public void did(DataCreatorUI ui, String cardName) { + //todo + } + }); + DataModify definePane = rn.getDefinePane(); + + JComponent definePaneComponent = definePane.toSwingComponent(); + boolean isExtraWidget = FormWidgetDefinePaneFactoryBase.isExtraXWidget(creator.toData()); + + if (isExtraWidget) { + // REPORT-55603: 仅对于插件控件,将尺寸*位置面板放置在definePane下方,其余控件将尺寸*位置面板放置在definePane上方 + attriCardPane.add(definePaneComponent, BorderLayout.NORTH); + } else { + // 使用单独的JPane和BorderLayout.North进行包装,避免出现CENTER嵌套CENTER后,内容高度变大的情况 + JPanel definePaneWrapContent = FRGUIPaneFactory.createBorderLayout_S_Pane(); + definePaneWrapContent.add(definePaneComponent, BorderLayout.NORTH); + attriCardPane.add(definePaneWrapContent, BorderLayout.CENTER); + } + currentEditorDefinePane = definePane; + } + + private XCreator getXCreatorDedicated() { + boolean dedicateLayout = xCreator.acceptType(XWScaleLayout.class) && xCreator.getComponentCount() > 0 && ((XCreator) xCreator.getComponent(0)).shouldScaleCreator() || xCreator.acceptType(XWTitleLayout.class); + return dedicateLayout ? (XCreator) xCreator.getComponent(0) : xCreator; + } + + @Override + public String title4PopupWindow() { + return "Widget"; + } + + public void populate() { + //populate之前先移除所有的监听 + removeAttributeChangeListener(); + Widget cellWidget = xCreator.toData(); + if (widgetBoundPane != null) { + widgetBoundPane.populate(); + } + Widget innerWidget = cellWidget; + if (cellWidget.acceptType(WScaleLayout.class)) { + Widget crBoundsWidget = ((WScaleLayout) cellWidget).getBoundsWidget(); + innerWidget = ((CRBoundsWidget) crBoundsWidget).getWidget(); + } else if (cellWidget.acceptType(WTitleLayout.class)) { + CRBoundsWidget crBoundsWidget = ((WTitleLayout) cellWidget).getBodyBoundsWidget(); + innerWidget = crBoundsWidget.getWidget(); + } + if (currentEditorDefinePane != null) { + currentEditorDefinePane.populateBean(innerWidget); + } + if (widgetPropertyPane != null) { + widgetPropertyPane.populate(innerWidget); + } + reinitAllListeners(); + this.addAttributeChangeListener(listener); + } + + + public void updateCreator() { + currentEditorDefinePane.setGlobalName(getGlobalName()); + Widget widget = currentEditorDefinePane.updateBean(); + if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_Basic")) && widgetPropertyPane != null) { + UITextField widgetNameField = widgetPropertyPane.getWidgetNameField(); + String toSetWidgetName = widgetNameField.getText(); + String currentWidgetName = widget.getWidgetName(); + if (toSetWidgetName.isEmpty()) { + widgetNameField.setText(currentWidgetName); + return; + } + + boolean exist = designer.getTarget().isNameExist(toSetWidgetName, widget) && !ComparatorUtils.equals(toSetWidgetName, currentWidgetName); + if (exist) { + widgetNameField.setText(currentWidgetName); + showNameInvalidDialog(Toolkit.i18nText("Fine-Design_Form_Widget_Rename_Failure")); + return; + } + + //图表名称的合法性检查 + if (widget instanceof ChartEditor && toSetWidgetName.startsWith("Chart")) { + widgetNameField.setText(currentWidgetName); + showNameInvalidDialog(Toolkit.i18nText("Fine-Design_Form_Chart_Widget_Rename_Failure")); + return; + } + widgetPropertyPane.update(widget); + // 上面一行更新了组件 这里必须重新调用getWidgetName + xCreator.resetCreatorName(widget.getWidgetName()); + xCreator.resetVisible(widget.isVisible()); + designer.getEditListenerTable().fireCreatorModified(xCreator, DesignerEvent.CREATOR_RENAMED); + return; + } + fireValueChanged(); + } + + private void showNameInvalidDialog(String message) { + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), message, Toolkit.i18nText("Fine-Design_Form_Joption_News"), JOptionPane.ERROR_MESSAGE, IOUtils.readIcon("com/fr/design/form/images/joption_failure.png")); + } + + public void updateWidgetBound() { + if (widgetBoundPane != null && ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"))) { + widgetBoundPane.update(); + designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_RESIZED); + } + designer.refreshDesignerUI(); + } + + + @Override + /** + *检查 + */ + public void checkValid() throws Exception { + currentEditorDefinePane.checkValid(); + } + + public void fireValueChanged() { + XCreator creator = getXCreatorDedicated(); + creator.firePropertyChange(); + } + + @Override + public String getIconPath() { + return StringUtils.EMPTY; + } + + public void firePropertyEdit() { + designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java index a76c96902c..c2d145983a 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java @@ -1,49 +1,12 @@ package com.fr.design.mainframe.widget.ui; -import com.fr.design.data.DataCreatorUI; -import com.fr.design.designer.beans.events.DesignerEvent; -import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XCreatorUtils; -import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWAbsoluteBodyLayout; -import com.fr.design.designer.creator.XWAbsoluteLayout; -import com.fr.design.designer.creator.XWFitLayout; -import com.fr.design.designer.creator.XWParameterLayout; -import com.fr.design.designer.creator.XWScaleLayout; -import com.fr.design.designer.creator.XWTitleLayout; -import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; import com.fr.design.dialog.AttrScrollPane; import com.fr.design.dialog.BasicScrollPane; -import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; -import com.fr.design.gui.frpane.AttributeChangeListener; -import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.FormDesigner; -import com.fr.design.mainframe.JForm; -import com.fr.design.mainframe.JTemplate; -import com.fr.design.widget.DataModify; -import com.fr.design.widget.FormWidgetDefinePaneFactoryBase; -import com.fr.design.widget.Operator; -import com.fr.design.widget.ui.designer.component.WidgetAbsoluteBoundPane; -import com.fr.design.widget.ui.designer.component.WidgetBoundPane; -import com.fr.design.widget.ui.designer.component.WidgetCardTagBoundPane; -import com.fr.form.ui.ChartEditor; -import com.fr.form.ui.Widget; -import com.fr.form.ui.container.WScaleLayout; -import com.fr.form.ui.container.WTitleLayout; -import com.fr.form.ui.widget.CRBoundsWidget; -import com.fr.general.ComparatorUtils; -import com.fr.general.IOUtils; -import com.fr.stable.StringUtils; import javax.swing.BorderFactory; -import javax.swing.JComponent; -import javax.swing.JOptionPane; import javax.swing.JPanel; import java.awt.BorderLayout; @@ -51,43 +14,18 @@ import java.awt.BorderLayout; * Created by ibm on 2017/7/25. */ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { - private AttributeChangeListener listener; - private FormDesigner designer; - //当前的编辑器属性定义面板 - private DataModify currentEditorDefinePane; - private FormBasicPropertyPane widgetPropertyPane; - private JPanel attriCardPane; - - private XCreator xCreator; - private WidgetBoundPane widgetBoundPane; - + protected FormDesigner designer; + protected JPanel content; public FormWidgetCardPane(FormDesigner designer) { - super(); - this.xCreator = findXcreator(designer); this.designer = designer; - initComponents(); - initDefinePane(); + this.initLayout(); + this.initScrollPane(); + this.initPropertyPane(); } - public XLayoutContainer getParent(XCreator source) { - XLayoutContainer container = XCreatorUtils.getParentXLayoutContainer(source); - if (source.acceptType(XWFitLayout.class) || source.acceptType(XWParameterLayout.class)) { - container = null; - } - return container; - } + public void initPropertyPane() { - public WidgetBoundPane createWidgetBoundPane(XCreator xCreator) { - XLayoutContainer xLayoutContainer = getParent(xCreator); - if (xLayoutContainer == null || xCreator.acceptType(XWParameterLayout.class) || xCreator.acceptType(XWAbsoluteBodyLayout.class)) { - return null; - } else if (xLayoutContainer.acceptType(XWAbsoluteLayout.class)) { - return new WidgetAbsoluteBoundPane(xCreator); - } else if (xCreator.acceptType(XWCardTagLayout.class)) { - return new WidgetCardTagBoundPane(xCreator); - } - return new WidgetBoundPane(xCreator); } @Override @@ -95,219 +33,31 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { return null; } - public XCreator findXcreator(FormDesigner designer) { - XCreator creator = designer.getSelectionModel().getSelection().getSelectedCreator(); - return creator != null ? creator : designer.getRootComponent(); - } - - /** - * 后台初始化所有事件. - */ - @Override - public void initAllListeners() { - - } - - /** - * 后台初始化所有事件. - */ - public void reinitAllListeners() { - initListener(this); - } - - @Override - protected void initContentPane() { - } - - private void initComponents() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); - XCreator innerCreator = getXCreatorDedicated(); - - final JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + private void initScrollPane() { + final JPanel jPanel = this.createContentPaneInScrollPane(); BasicScrollPane basicScrollPane = new AttrScrollPane() { + private static final long serialVersionUID = 3117877968639659022L; + @Override protected JPanel createContentPane() { return jPanel; } }; this.add(basicScrollPane, BorderLayout.CENTER); - attriCardPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - jPanel.add(attriCardPane, BorderLayout.CENTER); - jPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); - - final boolean isExtraWidget = FormWidgetDefinePaneFactoryBase.isExtraXWidget(innerCreator.toData()); - this.listener = new AttributeChangeListener() { - @Override - public void attributeChange() { - if (!isExtraWidget) { - updateCreator(); - } - updateWidgetBound(); - firePropertyEdit(); - } - }; - - freshPropertyMode(innerCreator); - if (isExtraWidget) { - // REPORT-55603: 仅对于插件控件,将尺寸*位置面板放置在definePane下方,其余控件将尺寸*位置面板放置在definePane上方 - widgetBoundPane = createWidgetBoundPane(xCreator); - if (widgetBoundPane != null) { - attriCardPane.add(widgetBoundPane, BorderLayout.CENTER); - } - return; - } - - widgetPropertyPane = WidgetBasicPropertyPaneFactory.createBasicPropertyPane(innerCreator); - - UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Basic"), 280, 20, widgetPropertyPane); - - jPanel.add(uiExpandablePane, BorderLayout.NORTH); - - widgetBoundPane = createWidgetBoundPane(xCreator); - if (widgetBoundPane != null) { - attriCardPane.add(widgetBoundPane, BorderLayout.NORTH); - } - } - - private static void freshPropertyMode(XCreator xCreator) { - JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (!(jTemplate instanceof JForm) && jTemplate.isUpMode()) { - if (xCreator instanceof XWParameterLayout) { - EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_PARA); - } else { - EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_PARA_WIDGET); - } - } + this.content = jPanel; } - private void initDefinePane() { - currentEditorDefinePane = null; - XCreator creator = getXCreatorDedicated(); - FormWidgetDefinePaneFactoryBase.RN rn = FormWidgetDefinePaneFactoryBase.createWidgetDefinePane(creator, designer, creator.toData(), new Operator() { - @Override - public void did(DataCreatorUI ui, String cardName) { - //todo - } - }); - DataModify definePane = rn.getDefinePane(); - - JComponent definePaneComponent = definePane.toSwingComponent(); - boolean isExtraWidget = FormWidgetDefinePaneFactoryBase.isExtraXWidget(creator.toData()); - - if (isExtraWidget) { - // REPORT-55603: 仅对于插件控件,将尺寸*位置面板放置在definePane下方,其余控件将尺寸*位置面板放置在definePane上方 - attriCardPane.add(definePaneComponent, BorderLayout.NORTH); - } else { - // 使用单独的JPane和BorderLayout.North进行包装,避免出现CENTER嵌套CENTER后,内容高度变大的情况 - JPanel definePaneWrapContent = FRGUIPaneFactory.createBorderLayout_S_Pane(); - definePaneWrapContent.add(definePaneComponent, BorderLayout.NORTH); - attriCardPane.add(definePaneWrapContent, BorderLayout.CENTER); - } - currentEditorDefinePane = definePane; - } - - private XCreator getXCreatorDedicated() { - boolean dedicateLayout = xCreator.acceptType(XWScaleLayout.class) && xCreator.getComponentCount() > 0 && ((XCreator) xCreator.getComponent(0)).shouldScaleCreator() || xCreator.acceptType(XWTitleLayout.class); - return dedicateLayout ? (XCreator) xCreator.getComponent(0) : xCreator; + private void initLayout() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + // 跟上方tab标题“属性”那一栏间距10 + this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); } - @Override - public String title4PopupWindow() { - return "Widget"; + protected JPanel createContentPaneInScrollPane() { + return FRGUIPaneFactory.createBorderLayout_S_Pane(); } public void populate() { - //populate之前先移除所有的监听 - removeAttributeChangeListener(); - Widget cellWidget = xCreator.toData(); - if (widgetBoundPane != null) { - widgetBoundPane.populate(); - } - Widget innerWidget = cellWidget; - if (cellWidget.acceptType(WScaleLayout.class)) { - Widget crBoundsWidget = ((WScaleLayout) cellWidget).getBoundsWidget(); - innerWidget = ((CRBoundsWidget) crBoundsWidget).getWidget(); - } else if (cellWidget.acceptType(WTitleLayout.class)) { - CRBoundsWidget crBoundsWidget = ((WTitleLayout) cellWidget).getBodyBoundsWidget(); - innerWidget = crBoundsWidget.getWidget(); - } - currentEditorDefinePane.populateBean(innerWidget); - if (widgetPropertyPane != null) { - widgetPropertyPane.populate(innerWidget); - } - reinitAllListeners(); - this.addAttributeChangeListener(listener); - } - - - public void updateCreator() { - currentEditorDefinePane.setGlobalName(getGlobalName()); - Widget widget = currentEditorDefinePane.updateBean(); - if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_Basic")) && widgetPropertyPane != null) { - UITextField widgetNameField = widgetPropertyPane.getWidgetNameField(); - String toSetWidgetName = widgetNameField.getText(); - String currentWidgetName = widget.getWidgetName(); - if (toSetWidgetName.isEmpty()) { - widgetNameField.setText(currentWidgetName); - return; - } - - boolean exist = designer.getTarget().isNameExist(toSetWidgetName, widget) && !ComparatorUtils.equals(toSetWidgetName, currentWidgetName); - if (exist) { - widgetNameField.setText(currentWidgetName); - showNameInvalidDialog(Toolkit.i18nText("Fine-Design_Form_Widget_Rename_Failure")); - return; - } - - //图表名称的合法性检查 - if (widget instanceof ChartEditor && toSetWidgetName.startsWith("Chart")) { - widgetNameField.setText(currentWidgetName); - showNameInvalidDialog(Toolkit.i18nText("Fine-Design_Form_Chart_Widget_Rename_Failure")); - return; - } - widgetPropertyPane.update(widget); - // 上面一行更新了组件 这里必须重新调用getWidgetName - xCreator.resetCreatorName(widget.getWidgetName()); - xCreator.resetVisible(widget.isVisible()); - designer.getEditListenerTable().fireCreatorModified(xCreator, DesignerEvent.CREATOR_RENAMED); - return; - } - fireValueChanged(); - } - - private void showNameInvalidDialog(String message) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), message, Toolkit.i18nText("Fine-Design_Form_Joption_News"), JOptionPane.ERROR_MESSAGE, IOUtils.readIcon("com/fr/design/form/images/joption_failure.png")); - } - - public void updateWidgetBound() { - if (widgetBoundPane != null && ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"))) { - widgetBoundPane.update(); - designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_RESIZED); - } - designer.refreshDesignerUI(); - } - - - @Override - /** - *检查 - */ - public void checkValid() throws Exception { - currentEditorDefinePane.checkValid(); - } - - public void fireValueChanged() { - XCreator creator = getXCreatorDedicated(); - creator.firePropertyChange(); - } - - @Override - public String getIconPath() { - return StringUtils.EMPTY; - } - public void firePropertyEdit() { - designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPaneFactory.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPaneFactory.java new file mode 100644 index 0000000000..6c4874536e --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPaneFactory.java @@ -0,0 +1,13 @@ +package com.fr.design.mainframe.widget.ui; + +import com.fr.design.mainframe.FormDesigner; + +public class FormWidgetCardPaneFactory { + public static FormWidgetCardPane create(FormDesigner designer) { + if (designer.isMultiSelection()) { + return new FormMultiWidgetCardPane(designer); + } else { + return new FormSingleWidgetCardPane(designer); + } + } +} diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ChartEditorDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ChartEditorDefinePane.java index fdb3efc9d3..a4daf4acf2 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ChartEditorDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ChartEditorDefinePane.java @@ -1,49 +1,56 @@ package com.fr.design.widget.ui.designer.layout; -import com.fr.design.designer.IntervalConstants; -import com.fr.design.designer.creator.CRPropertyDescriptor; -import com.fr.design.designer.creator.PropertyGroupPane; +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.settings.ThemedComponentStyle; import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XElementCase; -import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.style.FollowingThemePane; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.widget.accessibles.AccessibleElementCaseToolBarEditor; import com.fr.design.widget.ui.designer.component.PaddingBoundPane; import com.fr.form.ui.ChartEditor; -import com.fr.form.ui.ElementCaseEditor; -import com.fr.form.web.FormToolBarManager; +import com.fr.form.ui.PaddingMargin; import com.fr.general.ComparatorUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.JPanel; /** * Created by ibm on 2017/8/7. */ public class ChartEditorDefinePane extends WTitleLayoutDefinePane { - private PaddingBoundPane paddingBoundPane; + private final PaddingBoundPane paddingBoundPane; public ChartEditorDefinePane(XCreator xCreator) { super(xCreator); + paddingBoundPane = new PaddingBoundPane(); + themePane.addFollowThemePane(paddingBoundPane, new FollowingThemePane.FollowingThemeActionChangeListener() { + @Override + public void onFollowingTheme(boolean following) { + paddingBoundPane.setVisible(!following); + + if (following) { + TemplateTheme theme = themePane.getUsingTheme(); + if (theme instanceof FormTheme) { + ThemedComponentStyle style = ((FormTheme) theme).getComponentStyle(); + int top = style.getPaddingTop(); + int bottom = style.getPaddingBottom(); + int left = style.getPaddingLeft(); + int right = style.getPaddingRight(); + paddingBoundPane.populateBean(new PaddingMargin(top, left, bottom, right)); + } + } + + } + }); } protected JPanel createCenterPane() { - JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - paddingBoundPane = new PaddingBoundPane(); - Component[][] components = new Component[][]{ - new Component[]{paddingBoundPane, null}, - }; - JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1); - panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0)); - centerPane.add(panel, BorderLayout.NORTH); - return centerPane; + return FRGUIPaneFactory.createBorderLayout_S_Pane(); } protected ChartEditor updateSubBean() { ChartEditor chartEditor = (ChartEditor) creator.toData(); - if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) { + if (themePane.isFollowingTheme() || ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) { paddingBoundPane.update(chartEditor); } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java index d8b0060e7a..87c89f3cb4 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java @@ -1,13 +1,18 @@ package com.fr.design.widget.ui.designer.layout; +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.settings.ThemedComponentStyle; import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.*; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.style.FollowingThemePane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.widget.accessibles.AccessibleElementCaseToolBarEditor; import com.fr.design.widget.ui.designer.component.PaddingBoundPane; import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.ui.PaddingMargin; import com.fr.form.web.FormToolBarManager; import com.fr.general.ComparatorUtils; @@ -21,21 +26,37 @@ import java.awt.Component; * Created by ibm on 2017/8/7. */ public class ElementEditorDefinePane extends WTitleLayoutDefinePane { - private PaddingBoundPane paddingBoundPane; + private final PaddingBoundPane paddingBoundPane; private AccessibleElementCaseToolBarEditor elementCaseToolBarEditor; private PropertyGroupPane extraPropertyGroupPane; public ElementEditorDefinePane(XCreator xCreator) { super(xCreator); + paddingBoundPane = new PaddingBoundPane(); + themePane.addFollowThemePane(paddingBoundPane, new FollowingThemePane.FollowingThemeActionChangeListener() { + @Override + public void onFollowingTheme(boolean following) { + paddingBoundPane.setVisible(!following); + if (following) { + TemplateTheme theme = themePane.getUsingTheme(); + if (theme instanceof FormTheme) { + ThemedComponentStyle style = ((FormTheme) theme).getComponentStyle(); + int top = style.getPaddingTop(); + int bottom = style.getPaddingBottom(); + int left = style.getPaddingLeft(); + int right = style.getPaddingRight(); + paddingBoundPane.populateBean(new PaddingMargin(top, left, bottom, right)); + } + } + } + }); } protected JPanel createCenterPane() { JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - paddingBoundPane = new PaddingBoundPane(); elementCaseToolBarEditor = new AccessibleElementCaseToolBarEditor(); Component[][] components = new Component[][]{ - new Component[]{paddingBoundPane, null}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_EC_Toolbar")), elementCaseToolBarEditor}, }; JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1); @@ -49,7 +70,7 @@ public class ElementEditorDefinePane extends WTitleLayoutDefinePane extends AbstractDataModify { + protected FollowingThemePane themePane; private LayoutStylePane stylePane; public WTitleLayoutDefinePane(XCreator xCreator) { @@ -27,8 +33,29 @@ public abstract class WTitleLayoutDefinePane").append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Properties_Mobile_Tip")) - .append("").append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Properties_Mobile_Install_Parameter_Pane_Plugin")) - .append("").append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Properties_Mobile_To_Get_More_Style")) - .append(""); - tipLabel.setText(text.toString()); - tipLabel.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - try { - Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind("plugin.mobile.style"))); - } catch (Exception exp) { - FineLoggerFactory.getLogger().error(exp.getMessage(), exp); - } - } - @Override - public void mouseEntered(MouseEvent e) { - Object source = e.getSource(); - if (source instanceof UILabel) { - ((UILabel) source).setCursor(new Cursor(Cursor.HAND_CURSOR)); - } - } - @Override - public void mouseExited(MouseEvent e) { - Object source = e.getSource(); - if (source instanceof UILabel) { - ((UILabel) source).setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); - } - } - @Override - public void mouseMoved(MouseEvent e) { - Object source = e.getSource(); - if (source instanceof UILabel) { - ((UILabel) source).setCursor(new Cursor(Cursor.HAND_CURSOR)); - } - } - }); - return tipLabel; - } - // 控件顺序 private UIExpandablePane getMobileWidgetListPane() { mobileWidgetListPane = new MobileWidgetListPane(designer, (WSortLayout) paraCreator.toData()); diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/TabMobileWidgetDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/TabMobileWidgetDefinePane.java index af591abddd..93e2ee1720 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/TabMobileWidgetDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/TabMobileWidgetDefinePane.java @@ -46,7 +46,7 @@ public class TabMobileWidgetDefinePane extends MobileWidgetDefinePane { public TabMobileWidgetDefinePane(XCreator xCreator) { this.xCreator = xCreator; - contentJPanel = FRGUIPaneFactory.createCenterFlowZeroGapBorderPane(); + contentJPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); scrollPane = new AttrScrollPane() { @Override protected JPanel createContentPane() { @@ -117,7 +117,7 @@ public class TabMobileWidgetDefinePane extends MobileWidgetDefinePane { //高级 holder.add(advancePane, BorderLayout.CENTER); - contentJPanel.add(holder, BorderLayout.CENTER); + contentJPanel.add(holder, BorderLayout.NORTH); this.add(scrollPane, BorderLayout.CENTER); } diff --git a/designer-form/src/main/resources/com/fr/design/form/images/theme4currentTemplate.png b/designer-form/src/main/resources/com/fr/design/form/images/theme4currentTemplate.png new file mode 100644 index 0000000000..e022f1cfb4 Binary files /dev/null and b/designer-form/src/main/resources/com/fr/design/form/images/theme4currentTemplate.png differ diff --git a/designer-form/src/main/resources/com/fr/design/form/images/theme4newTemplate.png b/designer-form/src/main/resources/com/fr/design/form/images/theme4newTemplate.png new file mode 100644 index 0000000000..43e7c8ff03 Binary files /dev/null and b/designer-form/src/main/resources/com/fr/design/form/images/theme4newTemplate.png differ diff --git a/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java b/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java index 04327d354b..be4c9cd7a3 100644 --- a/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java +++ b/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe.template.info; import com.fr.base.background.ColorBackground; import com.fr.chart.chartattr.ChartCollection; +import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.form.main.Form; import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.ChartEditor; @@ -41,11 +42,11 @@ public class JFormProcessInfoTest { boolean result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); Assert.assertTrue(result); - elementCase.addCellElement(new DefaultTemplateCellElement()); + elementCase.addCellElement(DefaultThemedTemplateCellElementCase.createInstance()); result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); Assert.assertTrue(result); - DefaultTemplateCellElement templateCellElement = new DefaultTemplateCellElement(); + DefaultTemplateCellElement templateCellElement = DefaultThemedTemplateCellElementCase.createInstance(); templateCellElement.setValue(123); elementCase.addCellElement(templateCellElement); diff --git a/designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java b/designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java index 87c423d999..e4108e6d2f 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java @@ -6,9 +6,9 @@ import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.grid.GridUtils; import com.fr.grid.selection.CellSelection; -import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.core.SheetUtils; import com.fr.report.elementcase.TemplateElementCase; @@ -35,7 +35,7 @@ public abstract class AbstractCellElementAction extends CellSelectionAction { final TemplateElementCase tplEC = ePane.getEditingElementCase(); TemplateCellElement editCellElement = tplEC.getTemplateCellElement(cs.getColumn(), cs.getRow()); if (editCellElement == null) { - editCellElement = new DefaultTemplateCellElement(cs.getColumn(), cs.getRow()); + editCellElement = DefaultThemedTemplateCellElementCase.createInstance(cs.getColumn(), cs.getRow()); tplEC.addCellElement(editCellElement); } SheetUtils.calculateDefaultParent(tplEC); @@ -52,7 +52,7 @@ public abstract class AbstractCellElementAction extends CellSelectionAction { int row = j + finalCS.getRow(); TemplateCellElement editCellElement = tplEC.getTemplateCellElement(column, row); if (editCellElement == null) { - editCellElement = new DefaultTemplateCellElement(column, row); + editCellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); tplEC.addCellElement(editCellElement); } // alex:不加这一句话会导致跨行跨列的格子被多次update diff --git a/designer-realize/src/main/java/com/fr/design/actions/cell/CellStyleAttrAction.java b/designer-realize/src/main/java/com/fr/design/actions/cell/CellStyleAttrAction.java new file mode 100644 index 0000000000..a257ea95d6 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/cell/CellStyleAttrAction.java @@ -0,0 +1,26 @@ +package com.fr.design.actions.cell; + +import com.fr.base.BaseUtils; +import com.fr.design.i18n.Toolkit; +import com.fr.design.menu.KeySetUtils; +import com.fr.general.IOUtils; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/26 + */ +public class CellStyleAttrAction extends CellAttributeTableAction { + + public CellStyleAttrAction() { + this.setMenuKeySet(KeySetUtils.GLOBAL_STYLE); + this.setName(getMenuKeySet().getMenuKeySetName()); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/m_format/cell.png")); + } + + @Override + protected String getID() { + return Toolkit.i18nText("Fine-Design_Form_Widget_Style"); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/cell/CustomCellStyleAction.java b/designer-realize/src/main/java/com/fr/design/actions/cell/CustomCellStyleAction.java new file mode 100644 index 0000000000..db34cea32c --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/cell/CustomCellStyleAction.java @@ -0,0 +1,22 @@ +package com.fr.design.actions.cell; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.CellElementPropertyPane; + +import java.awt.event.ActionEvent; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/26 + */ +public class CustomCellStyleAction extends CellStyleAttrAction { + + @Override + public void actionPerformed(ActionEvent e) { + CellElementPropertyPane.getInstance().GoToPane( + Toolkit.i18nText("Fine-Design_Report_Engine_Style"), + Toolkit.i18nText("Fine-Design_Report_Engine_Custom") + ); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/cell/GlobalStyleMenuDef.java b/designer-realize/src/main/java/com/fr/design/actions/cell/GlobalStyleMenuDef.java index 4699ab886e..f72e708d37 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/cell/GlobalStyleMenuDef.java +++ b/designer-realize/src/main/java/com/fr/design/actions/cell/GlobalStyleMenuDef.java @@ -6,24 +6,35 @@ package com.fr.design.actions.cell; import com.fr.base.BaseUtils; import com.fr.base.NameStyle; -import com.fr.config.ServerPreferenceConfig; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.settings.ThemedCellStyle; import com.fr.design.actions.SelectionListenerAction; import com.fr.design.actions.UpdateAction; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.imenu.UIMenu; import com.fr.design.mainframe.CellElementPropertyPane; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.MenuDef; import com.fr.design.selection.SelectionListener; import com.fr.design.style.StylePane; - import com.fr.stable.StringUtils; import com.fr.stable.pinyin.PinyinHelper; -import java.awt.*; -import java.awt.event.*; -import java.util.Iterator; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ContainerEvent; +import java.awt.event.ContainerListener; +import java.util.List; +/** + * 11.beta.1 + * REPORT-51919 主题切换 + * REPORT-58062 【主题切换】细节定制-单元格样式-样式数量较多,菜单栏中选择时没有滚动条 + * 模版主题化后,该菜单列表废弃,点击工具栏-单元格-样式菜单将直接跳转到右侧栏单元格样式面板 + * @deprecated + */ public class GlobalStyleMenuDef extends MenuDef { private static final int MAX_LENTH = 12; private ElementCasePane ePane; @@ -72,10 +83,12 @@ public class GlobalStyleMenuDef extends MenuDef { public void updateMenu() { UIMenu createdMenu = this.createJMenu(); createdMenu.removeAll(); - Iterator iterator = ServerPreferenceConfig.getInstance().getStyleNameIterator(); - while (iterator.hasNext()) { - String name = (String) iterator.next(); - NameStyle nameStyle = NameStyle.getInstance(name); + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + TemplateTheme theme = template.getTemplateTheme(); + List themedCellStyleList = theme.getCellStyleList().getCellStyleList(); + for (ThemedCellStyle themedCellStyle: themedCellStyleList) { + String name = themedCellStyle.getName(); + NameStyle nameStyle = NameStyle.getPassiveInstance(name, themedCellStyle.getStyle()); UpdateAction.UseMenuItem useMenuItem =new GlobalStyleSelection(ePane, nameStyle).createUseMenuItem(); useMenuItem.setNameStyle(nameStyle); createdMenu.add(useMenuItem); diff --git a/designer-realize/src/main/java/com/fr/design/actions/cell/NewPresentAction.java b/designer-realize/src/main/java/com/fr/design/actions/cell/NewPresentAction.java index 66870ff6fe..786910a02f 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/cell/NewPresentAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/cell/NewPresentAction.java @@ -4,12 +4,12 @@ import com.fr.base.present.Present; import com.fr.design.actions.PresentCheckBoxAction; import com.fr.design.mainframe.CellElementPropertyPane; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.Selection; -import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; import com.fr.stable.StableUtils; @@ -46,7 +46,7 @@ public class NewPresentAction extends PresentCheckBoxAction { int row = j + cellRectangle.y; TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(column, row); + cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); elementCase.addCellElement(cellElement); } else if (cellElement.getPresent() != null) { cellElement.setPresent(null); diff --git a/designer-realize/src/main/java/com/fr/design/actions/cell/StyleAction.java b/designer-realize/src/main/java/com/fr/design/actions/cell/StyleAction.java index 1f77f9b935..707779c824 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/cell/StyleAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/cell/StyleAction.java @@ -12,6 +12,11 @@ import com.fr.design.mainframe.CellElementPropertyPane; import com.fr.design.menu.KeySetUtils; +/** + * 11.beta.1 + * REPORT-51919 主题切换 + * @deprecated + */ public class StyleAction extends UpdateAction { public StyleAction() { diff --git a/designer-realize/src/main/java/com/fr/design/actions/columnrow/DSColumnBasicAction.java b/designer-realize/src/main/java/com/fr/design/actions/columnrow/DSColumnBasicAction.java index ddd10ad55b..dda5faa86a 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/columnrow/DSColumnBasicAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/columnrow/DSColumnBasicAction.java @@ -9,8 +9,8 @@ import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.grid.selection.CellSelection; -import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.core.SheetUtils; import com.fr.report.elementcase.TemplateElementCase; @@ -61,7 +61,7 @@ public class DSColumnBasicAction extends CellSelectionAction { editCellElement = report.getTemplateCellElement(column, row); if (editCellElement == null) { - editCellElement = new DefaultTemplateCellElement(column, row); + editCellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); report.addCellElement(editCellElement); } // update cell attributes diff --git a/designer-realize/src/main/java/com/fr/design/actions/report/ReportBackgroundAction.java b/designer-realize/src/main/java/com/fr/design/actions/report/ReportBackgroundAction.java index fa4055807c..481d2e0941 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/report/ReportBackgroundAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/report/ReportBackgroundAction.java @@ -4,14 +4,15 @@ package com.fr.design.actions.report; -import com.fr.base.svg.IconUtils; import com.fr.design.actions.ReportComponentAction; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ReportComponent; import com.fr.design.menu.KeySetUtils; -import com.fr.design.report.ReportBackgroundPane; -import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.report.NewReportBackgroundPane; import com.fr.report.core.ReportUtils; +import com.fr.report.report.Report; /** * Background action. @@ -35,16 +36,16 @@ public class ReportBackgroundAction extends ReportComponentAction> table = new ArrayList<>(); + int startRow = -1; + int currentRow = -1; + for (int i = 0; i < clips.length; i++) { + CellElement cellElement = clips[i]; + if (currentRow == -1) {// 初始化当前行. + currentRow = cellElement.getRow(); + startRow = currentRow; + table.add(new ArrayList<>()); + } - if (currentRow < cellElement.getRow()) { - for (int r = currentRow; r < cellElement.getRow(); r++) { - sbuf.append('\n'); - } - currentRow = cellElement.getRow(); - } + while (currentRow < cellElement.getRow()) { + table.add(new ArrayList<>()); + currentRow++; + } - // 添加分隔符号. - if (sbuf.length() > 0 && sbuf.charAt(sbuf.length() - 1) != '\n') { - sbuf.append('\t'); - } - //REPORT-5134:会复制出null - if (cellElement.getValue() == null) { - sbuf.append(StringUtils.EMPTY); - } else { - sbuf.append(cellElement.getValue()); - } - } + Object cellValue = cellElement.getValue() == null ? StringUtils.EMPTY : cellElement.getValue(); + table.get(currentRow - startRow).add(cellValue); + } - return sbuf.toString(); + return ClipboardHelper.formatExcelString(table); } + public CellSelection pasteAt(TemplateElementCase ec, int column, int row) { - Iterator cells = ec.intersect(column, row, columnSpan, rowSpan); - while (cells.hasNext()) { - TemplateCellElement cellElement = (TemplateCellElement)cells.next(); - ec.removeCellElement(cellElement); - } - for (int i = 0; i < clips.length; i++) { - TemplateCellElement cellElement; - try { - cellElement = (TemplateCellElement) clips[i].clone(); - } catch (CloneNotSupportedException e) { + Iterator cells = ec.intersect(column, row, columnSpan, rowSpan); + while (cells.hasNext()) { + TemplateCellElement cellElement = (TemplateCellElement) cells.next(); + ec.removeCellElement(cellElement); + } + for (int i = 0; i < clips.length; i++) { + TemplateCellElement cellElement; + try { + cellElement = (TemplateCellElement) clips[i].clone(); + } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); - return null; - } - - // peter:因为前面已经将这个位置的元素删除了,所以不需要override了. - ec.addCellElement((TemplateCellElement) cellElement.deriveCellElement( - column + cellElement.getColumn(), row + cellElement.getRow() - ), false); - } - //设置单元格的宽高 - if(this.columnWidth != null && this.rowHeight != null){ + return null; + } + + // peter:因为前面已经将这个位置的元素删除了,所以不需要override了. + ec.addCellElement((TemplateCellElement) cellElement.deriveCellElement( + column + cellElement.getColumn(), row + cellElement.getRow() + ), false); + } + //设置单元格的宽高 + if (this.columnWidth != null && this.rowHeight != null) { pasteWidthAndHeight(ec, column, row, columnSpan, rowSpan); } - return new CellSelection(column, row, columnSpan, rowSpan); + return new CellSelection(column, row, columnSpan, rowSpan); } - public void pasteWidthAndHeight(TemplateElementCase ec, int column, int row, int columnSpan, int rowSpan){ - for(int i = 0; i < columnSpan; i++){ - ec.setColumnWidth(column + i, columnWidth[i]); - } - for(int j = 0; j < rowSpan; j++){ - ec.setRowHeight(row + j, rowHeight[j]); - } - } + public void pasteWidthAndHeight(TemplateElementCase ec, int column, int row, int columnSpan, int rowSpan) { + for (int i = 0; i < columnSpan; i++) { + ec.setColumnWidth(column + i, columnWidth[i]); + } + for (int j = 0; j < rowSpan; j++) { + ec.setRowHeight(row + j, rowHeight[j]); + } + } public void pasteAtRegion(TemplateElementCase ec, - int startColumn, int startRow, - int column, int row, - int columnSpan, int rowSpan) { + int startColumn, int startRow, + int column, int row, + int columnSpan, int rowSpan) { for (int i = 0; i < clips.length; i++) { TemplateCellElement cellElement = clips[i]; @@ -173,14 +170,14 @@ public class CellElementsClip implements Cloneable, java.io.Serializable { * Clone. */ @Override - public Object clone() throws CloneNotSupportedException { + public Object clone() throws CloneNotSupportedException { CellElementsClip cloned = (CellElementsClip) super.clone(); if (this.clips != null) { - cloned.clips = new TemplateCellElement[this.clips.length]; - for (int i = 0; i < this.clips.length; i++) { - cloned.clips[i] = (TemplateCellElement)this.clips[i].clone(); - } + cloned.clips = new TemplateCellElement[this.clips.length]; + for (int i = 0; i < this.clips.length; i++) { + cloned.clips[i] = (TemplateCellElement) this.clips[i].clone(); + } } return cloned; diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java b/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java index 5f0fd27d2f..f95681be32 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java +++ b/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java @@ -58,14 +58,14 @@ import java.math.BigDecimal; * * @date: 2014-12-5-下午1:10:31 */ -public class RichTextToolBar extends BasicPane{ +public class RichTextToolBar extends BasicPane { private static final Dimension BUTTON_SIZE = new Dimension(24, 20); - /** - * 富文本字体下拉框默认首选字体 非设计器UI界面字体 - */ - private static final FRFont DEFAULT_FONT = FRContext.getDefaultValues().getFRFont().applySize(13); + /** + * 富文本字体下拉框默认首选字体 非设计器UI界面字体 + */ + private static final FRFont DEFAULT_FONT = FRContext.getDefaultValues().getFRFont().applySize(13); private UIComboBox fontNameComboBox; private UIComboBox fontSizeComboBox; @@ -86,9 +86,9 @@ public class RichTextToolBar extends BasicPane{ } public RichTextToolBar(RichTextEditingPane textPane) { - this.textPane = textPane; + this.textPane = textPane; - this.initComponents(); + this.initComponents(); } @Override @@ -97,18 +97,18 @@ public class RichTextToolBar extends BasicPane{ } protected void initComponents() { - //初始化并设置所有按钮样式 + //初始化并设置所有按钮样式 initAllButton(); //添加到工具栏 addToToolBar(); } - private void initAllButton(){ + private void initAllButton() { fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); fontNameComboBox.setPreferredSize(new Dimension(144, 20)); - fontSizeComboBox = new UIComboBox(FRFontPane.getFontSizes()); - colorSelectPane = new UIToolbarColorButton(BaseUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); - colorSelectPane.set4Toolbar(); + fontSizeComboBox = new UIComboBox(FRFontPane.getFontSizes()); + colorSelectPane = new UIToolbarColorButton(BaseUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); + colorSelectPane.set4Toolbar(); bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); @@ -123,28 +123,28 @@ public class RichTextToolBar extends BasicPane{ setToolTips(); //样式 setAllButtonStyle(); - //绑定监听器 + //绑定监听器 bindListener(); } - private void setAllButtonStyle(){ - setButtonStyle(bold); - setButtonStyle(italic); - setButtonStyle(underline); - setButtonStyle(subPane); - setButtonStyle(superPane); - setButtonStyle(formulaPane); + private void setAllButtonStyle() { + setButtonStyle(bold); + setButtonStyle(italic); + setButtonStyle(underline); + setButtonStyle(subPane); + setButtonStyle(superPane); + setButtonStyle(formulaPane); } - private void setButtonStyle(UIButton button){ - button.setNormalPainted(false); - button.setBackground(null); - button.setOpaque(false); - button.setPreferredSize(BUTTON_SIZE); - button.setBorderPaintedOnlyWhenPressed(true); + private void setButtonStyle(UIButton button) { + button.setNormalPainted(false); + button.setBackground(null); + button.setOpaque(false); + button.setPreferredSize(BUTTON_SIZE); + button.setBorderPaintedOnlyWhenPressed(true); } - private void addToToolBar(){ + private void addToToolBar() { this.setLayout(new FlowLayout(FlowLayout.LEFT)); this.add(fontNameComboBox); @@ -158,12 +158,12 @@ public class RichTextToolBar extends BasicPane{ this.add(formulaPane); } - private void bindListener(){ - // 这里下拉框默认选中字体 不由UI界面字体决定 两套不同体系 + private void bindListener() { + // 这里下拉框默认选中字体 不由UI界面字体决定 两套不同体系 fontNameComboBox.addItemListener(fontNameItemListener); - fontNameComboBox.setSelectedItem(DEFAULT_FONT.getFamily()); + fontNameComboBox.setSelectedItem(DEFAULT_FONT.getFamily()); fontSizeComboBox.addItemListener(fontSizeItemListener); - fontSizeComboBox.setSelectedItem(scaleDown(DEFAULT_FONT.getSize())); + fontSizeComboBox.setSelectedItem(scaleDown(DEFAULT_FONT.getSize())); bold.addActionListener(blodChangeAction); italic.addActionListener(itaChangeAction); @@ -200,466 +200,472 @@ public class RichTextToolBar extends BasicPane{ } /** - * 移除输入监听 - * 用于populate时, 插入字符串, 那时不需要插入监听 - * - * - * @date 2015-1-5-下午5:13:04 - * - */ - public void removeInputListener(){ - this.textPane.getDocument().removeDocumentListener(inputListener); + * 移除输入监听 + * 用于populate时, 插入字符串, 那时不需要插入监听 + * + * + * @date 2015-1-5-下午5:13:04 + * + */ + public void removeInputListener() { + this.textPane.getDocument().removeDocumentListener(inputListener); } /** - * 增加输入监听事件 - * - * - * @date 2015-1-5-下午5:13:26 - * - */ - public void addInputListener(){ - this.textPane.getDocument().addDocumentListener(inputListener); + * 增加输入监听事件 + * + * + * @date 2015-1-5-下午5:13:26 + * + */ + public void addInputListener() { + this.textPane.getDocument().addDocumentListener(inputListener); } private ActionListener blodChangeAction = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - boolean isBold = RichTextToolBar.this.bold.isSelected(); - // 调用setCharacterAttributes函数设置文本区选择文本的字体 - MutableAttributeSet attr = new SimpleAttributeSet(); - StyleConstants.setBold(attr, !isBold); - setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); - } - }; - - private ActionListener itaChangeAction = new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - boolean isIta = RichTextToolBar.this.italic.isSelected(); - // 调用setCharacterAttributes函数设置文本区选择文本的字体 - MutableAttributeSet attr = new SimpleAttributeSet(); - StyleConstants.setItalic(attr, !isIta); - setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); - } - }; - - private ActionListener underlineChangeAction = new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - boolean isUnder = RichTextToolBar.this.underline.isSelected(); - // 调用setCharacterAttributes函数设置文本区选择文本的字体 - MutableAttributeSet attr = new SimpleAttributeSet(); - StyleConstants.setUnderline(attr, !isUnder); - setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); - } - }; - private ActionListener subChangeAction = new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - boolean isSub = RichTextToolBar.this.subPane.isSelected(); - MutableAttributeSet attr = new SimpleAttributeSet(); - if (!isSub && RichTextToolBar.this.superPane.isSelected()) { - RichTextToolBar.this.superPane.setSelected(false); - StyleConstants.setSuperscript(attr, false); - } - // 调用setCharacterAttributes函数设置文本区选择文本的字体 - StyleConstants.setSubscript(attr, !isSub); - setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); - } - }; - private ActionListener superChangeAction = new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - boolean isSuper = RichTextToolBar.this.superPane.isSelected(); - // 调用setCharacterAttributes函数设置文本区选择文本的字体 - MutableAttributeSet attr = new SimpleAttributeSet(); - if (!isSuper && RichTextToolBar.this.subPane.isSelected()) { - RichTextToolBar.this.subPane.setSelected(false); - StyleConstants.setSubscript(attr, false); - } - StyleConstants.setSuperscript(attr, !isSuper); - setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); - } - }; - - private ChangeListener colorChangeAction = new ChangeListener() { + @Override + public void actionPerformed(ActionEvent e) { + boolean isBold = RichTextToolBar.this.bold.isSelected(); + // 调用setCharacterAttributes函数设置文本区选择文本的字体 + MutableAttributeSet attr = new SimpleAttributeSet(); + StyleConstants.setBold(attr, !isBold); + setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); + } + }; + + private ActionListener itaChangeAction = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + boolean isIta = RichTextToolBar.this.italic.isSelected(); + // 调用setCharacterAttributes函数设置文本区选择文本的字体 + MutableAttributeSet attr = new SimpleAttributeSet(); + StyleConstants.setItalic(attr, !isIta); + setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); + } + }; + + private ActionListener underlineChangeAction = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + boolean isUnder = RichTextToolBar.this.underline.isSelected(); + // 调用setCharacterAttributes函数设置文本区选择文本的字体 + MutableAttributeSet attr = new SimpleAttributeSet(); + StyleConstants.setUnderline(attr, !isUnder); + setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); + } + }; + private ActionListener subChangeAction = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + boolean isSub = RichTextToolBar.this.subPane.isSelected(); + MutableAttributeSet attr = new SimpleAttributeSet(); + if (!isSub && RichTextToolBar.this.superPane.isSelected()) { + RichTextToolBar.this.superPane.setSelected(false); + StyleConstants.setSuperscript(attr, false); + } + // 调用setCharacterAttributes函数设置文本区选择文本的字体 + StyleConstants.setSubscript(attr, !isSub); + setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); + } + }; + private ActionListener superChangeAction = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + boolean isSuper = RichTextToolBar.this.superPane.isSelected(); + // 调用setCharacterAttributes函数设置文本区选择文本的字体 + MutableAttributeSet attr = new SimpleAttributeSet(); + if (!isSuper && RichTextToolBar.this.subPane.isSelected()) { + RichTextToolBar.this.subPane.setSelected(false); + StyleConstants.setSubscript(attr, false); + } + StyleConstants.setSuperscript(attr, !isSuper); + setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); + } + }; + + private ChangeListener colorChangeAction = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - Color color = RichTextToolBar.this.colorSelectPane.getColor(); - color = color == null ? Color.BLACK : color; - // 调用setCharacterAttributes函数设置文本区选择文本的字体 - MutableAttributeSet attr = new SimpleAttributeSet(); - StyleConstants.setForeground(attr, color); - setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); + Color color = RichTextToolBar.this.colorSelectPane.getColor(); + color = color == null ? Color.BLACK : color; + // 调用setCharacterAttributes函数设置文本区选择文本的字体 + MutableAttributeSet attr = new SimpleAttributeSet(); + StyleConstants.setForeground(attr, color); + setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); } }; - // 设置文本区选择文本的样式 - private void setCharacterAttributes(JEditorPane editor, AttributeSet attr, - boolean replace) { - //注意不要失焦 - textPane.requestFocus(); - - // 取得选择文本的起始位置和结束位置 - int start = editor.getSelectionStart(); - int end = editor.getSelectionEnd(); - - // 如果选中文本,设置选中文本的样式 - if (start != end) { - StyledDocument doc = (StyledDocument) textPane.getDocument(); - // 将所选文本设置为新的样式,replace为false表示不覆盖原有的样式 - doc.setCharacterAttributes(start, end - start, attr, replace); - } - } - - private ItemListener fontSizeItemListener = new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - int fontSize = (Integer) RichTextToolBar.this.fontSizeComboBox.getSelectedItem(); - fontSize= scaleUp(fontSize); - // 调用setCharacterAttributes函数设置文本区选择文本的字体 - MutableAttributeSet attr = new SimpleAttributeSet(); - StyleConstants.setFontSize(attr, fontSize); - setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); - } + // 设置文本区选择文本的样式 + private void setCharacterAttributes(JEditorPane editor, AttributeSet attr, + boolean replace) { + //注意不要失焦 + textPane.requestFocus(); + + // 取得选择文本的起始位置和结束位置 + int start = editor.getSelectionStart(); + int end = editor.getSelectionEnd(); + + // 如果选中文本,设置选中文本的样式 + if (start != end) { + StyledDocument doc = (StyledDocument) textPane.getDocument(); + // 将所选文本设置为新的样式,replace为false表示不覆盖原有的样式 + doc.setCharacterAttributes(start, end - start, attr, replace); + } + } + + private ItemListener fontSizeItemListener = new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + int fontSize = (Integer) RichTextToolBar.this.fontSizeComboBox.getSelectedItem(); + fontSize = scaleUp(fontSize); + // 调用setCharacterAttributes函数设置文本区选择文本的字体 + MutableAttributeSet attr = new SimpleAttributeSet(); + StyleConstants.setFontSize(attr, fontSize); + setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); + } }; - private ItemListener fontNameItemListener = new ItemListener() { + private ItemListener fontNameItemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { - String fontName = (String) RichTextToolBar.this.fontNameComboBox.getSelectedItem(); - // 调用setCharacterAttributes函数设置文本区选择文本的字体 - MutableAttributeSet attr = new SimpleAttributeSet(); - StyleConstants.setFontFamily(attr, fontName); - setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); + String fontName = (String) RichTextToolBar.this.fontNameComboBox.getSelectedItem(); + if (fontName != null) { + // 调用setCharacterAttributes函数设置文本区选择文本的字体 + MutableAttributeSet attr = new SimpleAttributeSet(); + StyleConstants.setFontFamily(attr, fontName); + setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); + } } }; - private ActionListener formulaActionListener = new ActionListener() { - public void actionPerformed(ActionEvent evt) { - final UIFormula formulaPane = FormulaFactory.createFormulaPane(); - formulaPane.populate(BaseFormula.createFormulaBuilder().build()); - formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { - @Override - public void doOk() { - StyledDocument doc = (StyledDocument) textPane.getDocument(); - BaseFormula fm = formulaPane.update(); - String content = RichTextConverter.asFormula(fm.getContent()); - int start = textPane.getSelectionStart(); + private ActionListener formulaActionListener = new ActionListener() { + public void actionPerformed(ActionEvent evt) { + final UIFormula formulaPane = FormulaFactory.createFormulaPane(); + formulaPane.populate(BaseFormula.createFormulaBuilder().build()); + formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + StyledDocument doc = (StyledDocument) textPane.getDocument(); + BaseFormula fm = formulaPane.update(); + String content = RichTextConverter.asFormula(fm.getContent()); + int start = textPane.getSelectionStart(); AttributeSet attrs = start > 0 ? doc.getCharacterElement(start - 1).getAttributes() : new SimpleAttributeSet(); - try { - doc.insertString(start, content, attrs); - } catch (BadLocationException e) { + try { + doc.insertString(start, content, attrs); + } catch (BadLocationException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - }).setVisible(true); - } - }; - - private int roundUp(double num){ - String numStr = Double.toString(num); - numStr = new BigDecimal(numStr).setScale(0, BigDecimal.ROUND_HALF_UP).toString(); - return Integer.valueOf(numStr); - } - - private CaretListener textCareListener = new CaretListener() { - - //根据选中部分的文字样式, 来动态显示工具栏上按钮的状态 - private void setSelectedCharStyle(int start, int end, StyledDocument doc){ - boolean isBold = true; - boolean isItalic = true; - boolean isUnderline = true; - boolean isSubscript = true; - boolean isSuperscript = true; - String fontName_1st = null; - int fontSize_1st = 0; - Color fontColor_1st = null; - - for (int i = start; i < end; i++) { - Element ele = doc.getCharacterElement(i); - AttributeSet attrs = ele.getAttributes(); - - //粗体 - isBold = isBold && StyleConstants.isBold(attrs); - //斜体 - isItalic = isItalic && StyleConstants.isItalic(attrs); - //下划线 - isUnderline = isUnderline && StyleConstants.isUnderline(attrs); - //下标 - isSubscript = isSubscript && StyleConstants.isSubscript(attrs); - //上标 - isSuperscript = isSuperscript && StyleConstants.isSuperscript(attrs); - - if(i == start){ - fontName_1st = (String) attrs.getAttribute(StyleConstants.FontFamily); - fontSize_1st = (Integer) attrs.getAttribute(StyleConstants.FontSize); - fontColor_1st = (Color) attrs.getAttribute(StyleConstants.Foreground); - fontColor_1st = fontColor_1st == null ? Color.BLACK : fontColor_1st; - } - } - - setButtonSelected(isBold, isItalic, isUnderline, isSubscript, isSuperscript, - fontName_1st, fontSize_1st, fontColor_1st); - } - - //动态显示工具栏上按钮的状态 - private void setButtonSelected(boolean isBold, boolean isItalic, boolean isUnderline, - boolean isSubscript, boolean isSuperscript, String fontName_1st, - int fontSize_1st, Color fontColor_1st){ - bold.setSelected(isBold); - italic.setSelected(isItalic); - underline.setSelected(isUnderline); - subPane.setSelected(isSuperscript ? false : isSubscript); - superPane.setSelected(isSuperscript); - //为什么字体名称, 大小, 颜色, 不需要去判断是否全相同呢 - //因为如果全相同, 则设置为第一个字符的样式, 如果不全相同, 那么默认也设置成第一个字符的样式. - fontNameComboBox.setSelectedItem(fontName_1st); - fontSizeComboBox.removeItemListener(fontSizeItemListener); - fontSizeComboBox.setSelectedItem(scaleDown(fontSize_1st)); - fontSizeComboBox.addItemListener(fontSizeItemListener); - selectColorPane(fontColor_1st); - } - - private void selectColorPane(Color color){ - colorSelectPane.removeColorChangeListener(colorChangeAction); - colorSelectPane.setColor(color); - colorSelectPane.addColorChangeListener(colorChangeAction); - } - - @Override - public void caretUpdate(CaretEvent e) { - StyledDocument doc = (StyledDocument) textPane.getDocument(); - - // 取得选择文本的起始位置和结束位置 - int start = textPane.getSelectionStart(); - int end = textPane.getSelectionEnd(); - - //如果没有选定字符 - if(end == start){ - return; - } - - setSelectedCharStyle(start, end, doc); - } - }; - - //设置当前光标位样式 - private MouseListener setMouseCurrentStyle = new MouseAdapter() { - - @Override - public void mouseClicked(MouseEvent e) { - StyledDocument doc = (StyledDocument) textPane.getDocument(); - - // 取得选择文本的起始位置和结束位置 - int start = textPane.getSelectionStart(); - int end = textPane.getSelectionEnd(); - - if(start != end){ - return; - } - - setToLastCharStyle(end, doc); - } - - //如果默认不选字符, 那么设置为最后一个字符的样式 - private void setToLastCharStyle(int end, StyledDocument doc){ - if(textPane.isUpdating()){ - return; - } - - //取前一个字符的样式 - Element ele = doc.getCharacterElement(end - 1); - AttributeSet attrs = ele.getAttributes(); - populateToolBar(attrs); - } - }; - - /** - * 从样式中更新工具栏上的按钮状态 - * - * @param attrs 样式 - * - * - * @date 2015-1-5-下午5:12:33 - * - */ - public void populateToolBar(AttributeSet attrs){ - int size = scaleDown(StyleConstants.getFontSize(attrs)); - fontNameComboBox.setSelectedItem(StyleConstants.getFontFamily(attrs)); - fontSizeComboBox.setSelectedItem(size); - - bold.setSelected(StyleConstants.isBold(attrs)); - italic.setSelected(StyleConstants.isItalic(attrs)); - underline.setSelected(StyleConstants.isUnderline(attrs)); - subPane.setSelected(StyleConstants.isSubscript(attrs)); - superPane.setSelected(StyleConstants.isSuperscript(attrs)); - Color foreGround = StyleConstants.getForeground(attrs); - foreGround = foreGround == null ? Color.BLACK : foreGround; - colorSelectPane.setColor(foreGround); - colorSelectPane.repaint(); - } - - //pt转为px =*4/3 - private int scaleUp(int fontSize) { - return roundUp(FontTransformUtil.pt2px(fontSize)); - } - - //px转pt = *3/4 - private int scaleDown(int fontSize) { - return roundUp(FontTransformUtil.px2pt(fontSize)); - } - - - private DocumentListener inputListener = new DocumentListener() { - - @Override - public void removeUpdate(DocumentEvent e) { - } - - @Override - public void insertUpdate(DocumentEvent e) { - //标志正在更新内容 - textPane.startUpdating(); - final MutableAttributeSet attr = updateStyleFromToolBar(); - final int start = textPane.getSelectionStart(); - int end = textPane.getSelectionEnd(); - - if (start != end) { - textPane.finishUpdating(); - return; - } - - //放到SwingWorker里, 是因为在documentListener里不能动态改变doc内容 - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - changeContentStyle(start, attr); - } - }); - } - - //根据Style来显示populate按钮 - private void changeContentStyle(int start, MutableAttributeSet attr){ - changeContentStyle(start, attr, 1); - } - - private void changeContentStyle(int start, MutableAttributeSet attr, int contentLength){ - // 将所选文本设置为新的样式,replace为false表示不覆盖原有的样式 - StyledDocument doc = (StyledDocument) textPane.getDocument(); - doc.setCharacterAttributes(start, contentLength, attr, false); - textPane.finishUpdating(); - } - - //将界面上的设置赋值给输入的字符 - private MutableAttributeSet updateStyleFromToolBar(){ - final boolean isBold = bold.isSelected(); - final boolean isItalic = italic.isSelected(); - final boolean isSub = subPane.isSelected(); - final boolean isSuper = superPane.isSelected(); - final boolean isUnderLine = underline.isSelected(); - final String fontName = (String) fontNameComboBox.getSelectedItem(); - final int fontSize = scaleUp((Integer) fontSizeComboBox.getSelectedItem()); - final Color foreGround = colorSelectPane.getColor() == null ? Color.BLACK : colorSelectPane.getColor(); - - MutableAttributeSet attr = new SimpleAttributeSet(); - StyleConstants.setBold(attr, isBold); - StyleConstants.setItalic(attr, isItalic); - StyleConstants.setSubscript(attr, isSub); - StyleConstants.setSuperscript(attr, isSuper); - StyleConstants.setUnderline(attr, isUnderLine); - StyleConstants.setForeground(attr, foreGround); - StyleConstants.setFontFamily(attr, fontName); - StyleConstants.setFontSize(attr, fontSize); - - return attr; - } - - private static final int NOT_INITED = -1; - private static final int UPDATING = -2; - //记录上一次输入成功后光标点定位, 因为有可能文本是在中间插入的 - private int inputStart = NOT_INITED; - private static final int JDK_6 = 6; - private static final int JDK_7 = 7; - - @Override - public void changedUpdate(DocumentEvent e) { - //这边需要注意, jdk1.6和1.7对于输入法的处理逻辑不一样, jdk6时直接在输入法中输入一大段中文 - //他会一个个insert进去直接触发inserupdate事件, 而jdk7会直接把所有的塞进来. - //inserupdate那边绑定的是一个个插入的事件, 多个一起插入的放这 - //bug84777 8.0不走if逻辑,改成只有jdk7走if逻辑 - if(StableUtils.getMajorJavaVersion() == JDK_7){ - if(isUpdating()){ - return; - } - StyledDocument doc = (StyledDocument) textPane.getDocument(); - final String content; - initFlag(doc); - - final int start = textPane.getSelectionStart(); - final int inputLen = start - inputStart; - //检测输入内容 - try { - content = doc.getText(inputStart, inputLen); - } catch (BadLocationException e1) { - return; - } - - //中文输入法, 默认输入字符会被输入法的框截取住, jtextpane得到是一个空格, 此时不做处理 - if(StringUtils.isBlank(content) || inputLen <= 0){ - return; - } - //设置一次性输入多个文字的样式 - setContentStyle(inputLen); - } - } - - private void setContentStyle(final int inputLen){ - //缓存下Start, 下面要用来设置样式 - final int _start = inputStart; - final MutableAttributeSet attr = updateStyleFromToolBar(); - - //放到SwingWorker里, 是因为在documentListener里不能动态改变doc内容 - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - //防止触发死循环change事件 - startUpdating(); - //Start-1 是因为中文输入法会用空格占1位 - changeContentStyle(_start, attr, inputLen); - resetFlag(); - } - }); - } - - private boolean isUpdating(){ - return inputStart == UPDATING; - } - - private void startUpdating(){ - inputStart = UPDATING; - } - - //初始标记状态, 用于记录中文输入法多个字符同时输入的问题 - private void initFlag(StyledDocument doc){ - if(inputStart != NOT_INITED){ - return; - } - inputStart = textPane.getSelectionStart() - 1; - } - - //重置标记状态 - private void resetFlag(){ - inputStart = NOT_INITED; - } - }; + } + } + }).setVisible(true); + } + }; + + private int roundUp(double num) { + String numStr = Double.toString(num); + numStr = new BigDecimal(numStr).setScale(0, BigDecimal.ROUND_HALF_UP).toString(); + return Integer.valueOf(numStr); + } + + private CaretListener textCareListener = new CaretListener() { + + //根据选中部分的文字样式, 来动态显示工具栏上按钮的状态 + private void setSelectedCharStyle(int start, int end, StyledDocument doc) { + boolean isBold = true; + boolean isItalic = true; + boolean isUnderline = true; + boolean isSubscript = true; + boolean isSuperscript = true; + String fontName_1st = null; + int fontSize_1st = 0; + Color fontColor_1st = null; + + for (int i = start; i < end; i++) { + Element ele = doc.getCharacterElement(i); + AttributeSet attrs = ele.getAttributes(); + + //粗体 + isBold = isBold && StyleConstants.isBold(attrs); + //斜体 + isItalic = isItalic && StyleConstants.isItalic(attrs); + //下划线 + isUnderline = isUnderline && StyleConstants.isUnderline(attrs); + //下标 + isSubscript = isSubscript && StyleConstants.isSubscript(attrs); + //上标 + isSuperscript = isSuperscript && StyleConstants.isSuperscript(attrs); + + if (i == start) { + fontName_1st = (String) attrs.getAttribute(StyleConstants.FontFamily); + fontSize_1st = (Integer) attrs.getAttribute(StyleConstants.FontSize); + fontColor_1st = (Color) attrs.getAttribute(StyleConstants.Foreground); + fontColor_1st = fontColor_1st == null ? Color.BLACK : fontColor_1st; + } else { + if (!(attrs.getAttribute(StyleConstants.FontFamily)).equals(fontName_1st)) { + fontName_1st = null; + } + } + } + + setButtonSelected(isBold, isItalic, isUnderline, isSubscript, isSuperscript, + fontName_1st, fontSize_1st, fontColor_1st); + } + + //动态显示工具栏上按钮的状态 + private void setButtonSelected(boolean isBold, boolean isItalic, boolean isUnderline, + boolean isSubscript, boolean isSuperscript, String fontName_1st, + int fontSize_1st, Color fontColor_1st) { + bold.setSelected(isBold); + italic.setSelected(isItalic); + underline.setSelected(isUnderline); + subPane.setSelected(isSuperscript ? false : isSubscript); + superPane.setSelected(isSuperscript); + //为什么字体名称, 大小, 颜色, 不需要去判断是否全相同呢 + //因为如果全相同, 则设置为第一个字符的样式, 如果不全相同, 那么默认也设置成第一个字符的样式. + fontNameComboBox.setSelectedItem(fontName_1st); + fontSizeComboBox.removeItemListener(fontSizeItemListener); + fontSizeComboBox.setSelectedItem(scaleDown(fontSize_1st)); + fontSizeComboBox.addItemListener(fontSizeItemListener); + selectColorPane(fontColor_1st); + } + + private void selectColorPane(Color color) { + colorSelectPane.removeColorChangeListener(colorChangeAction); + colorSelectPane.setColor(color); + colorSelectPane.addColorChangeListener(colorChangeAction); + } + + @Override + public void caretUpdate(CaretEvent e) { + StyledDocument doc = (StyledDocument) textPane.getDocument(); + + // 取得选择文本的起始位置和结束位置 + int start = textPane.getSelectionStart(); + int end = textPane.getSelectionEnd(); + + //如果没有选定字符 + if (end == start) { + return; + } + + setSelectedCharStyle(start, end, doc); + } + }; + + //设置当前光标位样式 + private MouseListener setMouseCurrentStyle = new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent e) { + StyledDocument doc = (StyledDocument) textPane.getDocument(); + + // 取得选择文本的起始位置和结束位置 + int start = textPane.getSelectionStart(); + int end = textPane.getSelectionEnd(); + + if (start != end) { + return; + } + + setToLastCharStyle(end, doc); + } + + //如果默认不选字符, 那么设置为最后一个字符的样式 + private void setToLastCharStyle(int end, StyledDocument doc) { + if (textPane.isUpdating()) { + return; + } + + //取前一个字符的样式 + Element ele = doc.getCharacterElement(end - 1); + AttributeSet attrs = ele.getAttributes(); + populateToolBar(attrs); + } + }; + + /** + * 从样式中更新工具栏上的按钮状态 + * + * @param attrs 样式 + * + * + * @date 2015-1-5-下午5:12:33 + * + */ + public void populateToolBar(AttributeSet attrs) { + int size = scaleDown(StyleConstants.getFontSize(attrs)); + fontNameComboBox.setSelectedItem(StyleConstants.getFontFamily(attrs)); + fontSizeComboBox.setSelectedItem(size); + + bold.setSelected(StyleConstants.isBold(attrs)); + italic.setSelected(StyleConstants.isItalic(attrs)); + underline.setSelected(StyleConstants.isUnderline(attrs)); + subPane.setSelected(StyleConstants.isSubscript(attrs)); + superPane.setSelected(StyleConstants.isSuperscript(attrs)); + Color foreGround = StyleConstants.getForeground(attrs); + foreGround = foreGround == null ? Color.BLACK : foreGround; + colorSelectPane.setColor(foreGround); + colorSelectPane.repaint(); + } + + //pt转为px =*4/3 + private int scaleUp(int fontSize) { + return roundUp(FontTransformUtil.pt2px(fontSize)); + } + + //px转pt = *3/4 + private int scaleDown(int fontSize) { + return roundUp(FontTransformUtil.px2pt(fontSize)); + } + + + private DocumentListener inputListener = new DocumentListener() { + + @Override + public void removeUpdate(DocumentEvent e) { + } + + @Override + public void insertUpdate(DocumentEvent e) { + //标志正在更新内容 + textPane.startUpdating(); + final MutableAttributeSet attr = updateStyleFromToolBar(); + final int start = textPane.getSelectionStart(); + int end = textPane.getSelectionEnd(); + + if (start != end) { + textPane.finishUpdating(); + return; + } + + //放到SwingWorker里, 是因为在documentListener里不能动态改变doc内容 + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + changeContentStyle(start, attr); + } + }); + } + + //根据Style来显示populate按钮 + private void changeContentStyle(int start, MutableAttributeSet attr) { + changeContentStyle(start, attr, 1); + } + + private void changeContentStyle(int start, MutableAttributeSet attr, int contentLength) { + // 将所选文本设置为新的样式,replace为false表示不覆盖原有的样式 + StyledDocument doc = (StyledDocument) textPane.getDocument(); + doc.setCharacterAttributes(start, contentLength, attr, false); + textPane.finishUpdating(); + } + + //将界面上的设置赋值给输入的字符 + private MutableAttributeSet updateStyleFromToolBar() { + final boolean isBold = bold.isSelected(); + final boolean isItalic = italic.isSelected(); + final boolean isSub = subPane.isSelected(); + final boolean isSuper = superPane.isSelected(); + final boolean isUnderLine = underline.isSelected(); + final String fontName = (String) fontNameComboBox.getSelectedItem(); + final int fontSize = scaleUp((Integer) fontSizeComboBox.getSelectedItem()); + final Color foreGround = colorSelectPane.getColor() == null ? Color.BLACK : colorSelectPane.getColor(); + + MutableAttributeSet attr = new SimpleAttributeSet(); + StyleConstants.setBold(attr, isBold); + StyleConstants.setItalic(attr, isItalic); + StyleConstants.setSubscript(attr, isSub); + StyleConstants.setSuperscript(attr, isSuper); + StyleConstants.setUnderline(attr, isUnderLine); + StyleConstants.setForeground(attr, foreGround); + StyleConstants.setFontFamily(attr, fontName); + StyleConstants.setFontSize(attr, fontSize); + + return attr; + } + + private static final int NOT_INITED = -1; + private static final int UPDATING = -2; + //记录上一次输入成功后光标点定位, 因为有可能文本是在中间插入的 + private int inputStart = NOT_INITED; + private static final int JDK_6 = 6; + private static final int JDK_7 = 7; + + @Override + public void changedUpdate(DocumentEvent e) { + //这边需要注意, jdk1.6和1.7对于输入法的处理逻辑不一样, jdk6时直接在输入法中输入一大段中文 + //他会一个个insert进去直接触发inserupdate事件, 而jdk7会直接把所有的塞进来. + //inserupdate那边绑定的是一个个插入的事件, 多个一起插入的放这 + //bug84777 8.0不走if逻辑,改成只有jdk7走if逻辑 + if (StableUtils.getMajorJavaVersion() == JDK_7) { + if (isUpdating()) { + return; + } + StyledDocument doc = (StyledDocument) textPane.getDocument(); + final String content; + initFlag(doc); + + final int start = textPane.getSelectionStart(); + final int inputLen = start - inputStart; + //检测输入内容 + try { + content = doc.getText(inputStart, inputLen); + } catch (BadLocationException e1) { + return; + } + + //中文输入法, 默认输入字符会被输入法的框截取住, jtextpane得到是一个空格, 此时不做处理 + if (StringUtils.isBlank(content) || inputLen <= 0) { + return; + } + //设置一次性输入多个文字的样式 + setContentStyle(inputLen); + } + } + + private void setContentStyle(final int inputLen) { + //缓存下Start, 下面要用来设置样式 + final int _start = inputStart; + final MutableAttributeSet attr = updateStyleFromToolBar(); + + //放到SwingWorker里, 是因为在documentListener里不能动态改变doc内容 + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + //防止触发死循环change事件 + startUpdating(); + //Start-1 是因为中文输入法会用空格占1位 + changeContentStyle(_start, attr, inputLen); + resetFlag(); + } + }); + } + + private boolean isUpdating() { + return inputStart == UPDATING; + } + + private void startUpdating() { + inputStart = UPDATING; + } + + //初始标记状态, 用于记录中文输入法多个字符同时输入的问题 + private void initFlag(StyledDocument doc) { + if (inputStart != NOT_INITED) { + return; + } + inputStart = textPane.getSelectionStart() - 1; + } + + //重置标记状态 + private void resetFlag() { + inputStart = NOT_INITED; + } + }; } diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnPane.java index afade5626c..3f0add29ba 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnPane.java @@ -5,9 +5,9 @@ import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.log.FineLoggerFactory; import com.fr.report.cell.CellElement; -import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.TemplateCellElement; import javax.swing.JPanel; @@ -127,7 +127,7 @@ public class DSColumnPane extends BasicPane { if (tds == null || cellElement == null) { // _denny: 我不认为这种情况应该出现,以防万一 - this.cellElement = new DefaultTemplateCellElement(); + this.cellElement = DefaultThemedTemplateCellElementCase.createInstance(); return; } // _denny: 这边需要克隆一下,因为在设置时,可能改变字段cellElement,但改变真实值是不被期望的 diff --git a/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java b/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java index b89971f879..095d011f75 100644 --- a/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java +++ b/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java @@ -7,6 +7,7 @@ import com.fr.design.fun.JavaScriptActionProvider; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.hyperlink.popup.MobilePopupPane; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; @@ -15,6 +16,8 @@ import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.write.submit.DBManipulationPane; import com.fr.form.event.Listener; import com.fr.js.JavaScript; +import com.fr.report.web.util.ReportEngineEventMapping; +import com.fr.write.JavaScriptResourceInfo; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -25,6 +28,7 @@ import java.awt.FlowLayout; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Set; @@ -39,9 +43,13 @@ public class ListenerEditPane extends BasicBeanPane { private static final String DBCOMMIT = Toolkit.i18nText("Fine-Design_Basic_JavaScript_Commit_To_Database"); private static final String CUSTOMACTION = Toolkit.i18nText("Fine-Design_Report_Submit_Type_Custom"); private static final String EMAIL = Toolkit.i18nText("Fine-Design_Report_Email_Sent_Email"); + private static final String EXPORT = Toolkit.i18nText("Fine-Design_Basic_Export_JS_Event"); + private static final String MOBILEPOPUP = Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup"); private Listener listener; + JavaScriptActionPane javaScriptActionPane; + public ListenerEditPane() { this.initComponents(new String[0]); } @@ -62,8 +70,13 @@ public class ListenerEditPane extends BasicBeanPane { nameText = new UITextField(8); nameText.setEditable(false); namePane.add(nameText, BorderLayout.WEST); - final String[] style = {JS, DBCOMMIT, CUSTOMACTION, EMAIL}; - styleBox = new UIComboBox(style); + final List style = new ArrayList<>(Arrays.asList(JS, DBCOMMIT, CUSTOMACTION, EMAIL, MOBILEPOPUP)); + styleBox = new UIComboBox(style.toArray()); + boolean workbook = DesignerContext.getDesignerFrame().getSelectedJTemplate().isJWorkBook(); + if (workbook) { + style.add(EXPORT); + } + styleBox = new UIComboBox(style.toArray()); namePane.add(styleBox); namePane = GUICoreUtils.createFlowPane(new Component[]{ new UILabel(" " + Toolkit.i18nText("Fine-Design_Report_Event_Name") + ":"), @@ -81,7 +94,8 @@ public class ListenerEditPane extends BasicBeanPane { // 提交入库 List dbManiList = new ArrayList(); dbManiList.add(autoCreateDBManipulationPane()); - Commit2DBJavaScriptPane commit2DBJavaScriptPane = new Commit2DBJavaScriptPane(JavaScriptActionPane.createDefaultJavaScriptActionPane(), + javaScriptActionPane = JavaScriptActionPane.createDefaultJavaScriptActionPane(); + Commit2DBJavaScriptPane commit2DBJavaScriptPane = new Commit2DBJavaScriptPane(javaScriptActionPane, dbManiList); hyperlinkPane.add(DBCOMMIT, commit2DBJavaScriptPane); // 自定义事件 @@ -90,10 +104,20 @@ public class ListenerEditPane extends BasicBeanPane { // 发送邮件 EmailPane emailPane = new EmailPane(); hyperlinkPane.add(EMAIL, emailPane); + // 移动端弹窗 + MobilePopupPane mobilePopupPane = new MobilePopupPane(); + hyperlinkPane.add(MOBILEPOPUP, mobilePopupPane); cards.add(javaScriptPane); cards.add(commit2DBJavaScriptPane); cards.add(customActionPane); cards.add(emailPane); + cards.add(mobilePopupPane); + // 导出事件 这里要按顺序添加 + if (workbook) { + ExportJavaScriptPane exportJavaScriptPane = new ExportJavaScriptPane(); + hyperlinkPane.add(EXPORT, exportJavaScriptPane); + cards.add(exportJavaScriptPane); + } //其他事件 addOtherEvent(); hyperlinkPane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Report_JavaScript_Set"))); @@ -164,9 +188,15 @@ public class ListenerEditPane extends BasicBeanPane { @Override public Listener updateBean() { + String actionLocaleName = ReportEngineEventMapping.getLocaleName(listener.getEventName()); + + JavaScriptResourceInfo.PathNode pathNode = JavaScriptResourceInfo.PathNode.create(JavaScriptResourceInfo.Type.WEB_CONFIG, Toolkit.i18nText(actionLocaleName)); + JavaScriptResourceInfo javaScriptResourceInfo = new JavaScriptResourceInfo().addFirstPathNode(pathNode); + javaScriptActionPane.setResourceInfo(javaScriptResourceInfo); this.listener.setEventName(this.nameText.getText()); FurtherBasicBeanPane pane = this.cards.get(this.styleBox.getSelectedIndex()); this.listener.setAction(pane.updateBean()); + return this.listener; } } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java index 1fc891c8b3..5eb1de3664 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java @@ -185,7 +185,7 @@ public class AuthorityToolBarPane extends BasicBeanPane toolBarButtons = toolBarPane.getToolBarButtons(); - boolean isnotEnable = ComparatorUtils.equals(title.getText(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Server_Toolbar_Choose_Role"))&& !WorkContext.getCurrent().isRoot(); + boolean isnotEnable = ComparatorUtils.equals(title.getText(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Server_Toolbar_Choose_Role")) && !WorkContext.getCurrent().isRoot(); for (ToolBarButton button : toolBarButtons) { button.setEnabled(!isnotEnable); } @@ -296,9 +296,15 @@ public class AuthorityToolBarPane extends BasicBeanPane extends Tar DesignerContext.setFormatState(DesignerContext.FORMAT_STATE_ONCE); DesignerContext.setReferencedElementCasePane(ElementCasePane.this); DesignerContext.setReferencedIndex( - ((JWorkBook) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()).getEditingReportIndex()); + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getEditingReportIndex()); formatBrush.setSelected(true); formatBrushAction.executeActionReturnUndoRecordNeeded(); } else { @@ -569,7 +569,7 @@ public abstract class ElementCasePane extends Tar int row = j + cellRectangle.y; TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(column, row); + cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); elementCase.addCellElement(cellElement); } Style style = cellElement.getStyle(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java index 58b778065e..54ba90ea9f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneAuthorityEditPane.java @@ -11,6 +11,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.mainframe.toolbar.AuthorityEditToolBarComponent; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; @@ -291,7 +292,7 @@ public class ElementCasePaneAuthorityEditPane extends AuthorityEditPane { int row = j + cellRectangle.y; TemplateCellElement editCellElement = elementCase.getTemplateCellElement(column, row); if (editCellElement == null) { - editCellElement = new DefaultTemplateCellElement(column, row); + editCellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); elementCase.addCellElement(editCellElement); } else { // 对于合并的格子,我们不多次计算的权限. @@ -371,7 +372,7 @@ public class ElementCasePaneAuthorityEditPane extends AuthorityEditPane { Rectangle cellRectangle = cellSelection.getCellRectangle(0); DefaultTemplateCellElement cellElement = (DefaultTemplateCellElement) elementCase.getCellElement(cellRectangle.x, cellRectangle.y); if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(cellRectangle.x, cellRectangle.y); + cellElement = DefaultThemedTemplateCellElementCase.createInstance(cellRectangle.x, cellRectangle.y); } boolean firstCellDoneaAuthority = cellElement.isDoneAuthority( ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName()); @@ -507,7 +508,7 @@ public class ElementCasePaneAuthorityEditPane extends AuthorityEditPane { int row = j + cellRectangle.y; DefaultTemplateCellElement cellElement = (DefaultTemplateCellElement) elementCase.getCellElement(column, row); if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(cellSelection.getColumn(), cellSelection.getRow()); + cellElement = DefaultThemedTemplateCellElementCase.createInstance(cellSelection.getColumn(), cellSelection.getRow()); } if (cellElement.getCellWidgetAttr() == null) { isAllHasWidget = false; @@ -562,7 +563,7 @@ public class ElementCasePaneAuthorityEditPane extends AuthorityEditPane { final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); DefaultTemplateCellElement cellElement = (DefaultTemplateCellElement) elementCase.getCellElement(cellSelection.getColumn(), cellSelection.getRow()); if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(cellSelection.getColumn(), cellSelection.getRow()); + cellElement = DefaultThemedTemplateCellElementCase.createInstance(cellSelection.getColumn(), cellSelection.getRow()); } //单元格带控件 if (cellElement.getCellWidgetAttr() != null) { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java index 44992a84b2..5cc095cfac 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java @@ -5,9 +5,9 @@ import com.fr.design.DesignState; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.cell.CellAttributeAction; import com.fr.design.actions.cell.CellExpandAttrAction; +import com.fr.design.actions.cell.CellStyleAttrAction; import com.fr.design.actions.cell.CellWidgetAttrAction; import com.fr.design.actions.cell.ConditionAttributesAction; -import com.fr.design.actions.cell.GlobalStyleMenuDef; import com.fr.design.actions.columnrow.InsertColumnAction; import com.fr.design.actions.columnrow.InsertRowAction; import com.fr.design.actions.core.ActionFactory; @@ -15,6 +15,7 @@ import com.fr.design.actions.edit.HyperlinkAction; import com.fr.design.actions.edit.merge.MergeCellAction; import com.fr.design.actions.edit.merge.UnmergeCellAction; import com.fr.design.actions.utils.DeprecatedActionManager; +import com.fr.design.base.mode.DesignModeContext; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListPane; @@ -101,7 +102,9 @@ public class ElementCasePaneDelegate extends ElementCasePane { conditionAttributesGroupPane.populate(ElementCasePaneDelegate.this); EastRegionContainerPane.getInstance().replaceFloatElementPane(ReportFloatPane.getInstance()); - EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT); + EastRegionContainerPane.getInstance().switchMode(DesignModeContext.isDuchampMode() ? + EastRegionContainerPane.PropertyMode.DUCHAMP_REPORT : + EastRegionContainerPane.PropertyMode.REPORT); EastRegionContainerPane.getInstance().replaceCellAttrPane(CellElementPropertyPane.getInstance()); EastRegionContainerPane.getInstance().replaceCellElementPane(QuickEditorRegion.getInstance()); EastRegionContainerPane.getInstance().replaceConditionAttrPane(conditionAttributesGroupPane); @@ -198,10 +201,14 @@ public class ElementCasePaneDelegate extends ElementCasePane { MenuDef menuDef = new MenuDef(KeySetUtils.CELL.getMenuKeySetName(), KeySetUtils.CELL.getMnemonic()); menuDef.addShortCut(new CellExpandAttrAction()); - menuDef.addShortCut(new GlobalStyleMenuDef(this)); + menuDef.addShortCut(new CellStyleAttrAction()); // 单元格形态 menuDef.addShortCut(DeprecatedActionManager.getPresentMenu(this)); - menuDef.addShortCut(new CellWidgetAttrAction()); + + if (!DesignModeContext.isDuchampMode()) { + menuDef.addShortCut(new CellWidgetAttrAction()); + } + menuDef.addShortCut(new ConditionAttributesAction()); menuDef.addShortCut(new HyperlinkAction()); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/FormatBrushAction.java b/designer-realize/src/main/java/com/fr/design/mainframe/FormatBrushAction.java index 9b89864b67..1256c76644 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/FormatBrushAction.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/FormatBrushAction.java @@ -4,9 +4,9 @@ import com.fr.base.Style; import com.fr.design.actions.ElementCaseAction; +import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.Selection; -import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; @@ -129,7 +129,7 @@ public class FormatBrushAction extends ElementCaseAction { int row = j + cs.getRow(); TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(column, row); + cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); elementCase.addCellElement(cellElement); } cellElement.setStyle(referencedStyle[i % columnSpan][j % rowSpan]); @@ -152,7 +152,7 @@ public class FormatBrushAction extends ElementCaseAction { int row = j + cellRectangle.y; TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(column, row); + cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); elementCase.addCellElement(cellElement); } Style style = cellElement.getStyle(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 855201733a..0ba6c69913 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -5,7 +5,13 @@ import com.fr.base.DynamicUnitList; import com.fr.base.Parameter; import com.fr.base.ScreenResolution; import com.fr.base.extension.FileExtension; +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.TemplateThemeCompatible; import com.fr.base.vcs.DesignerMode; +import com.fr.base.theme.ReportTheme; +import com.fr.base.theme.ReportThemeConfig; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeConfig; import com.fr.design.DesignModelAdapter; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.AllowAuthorityEditAction; @@ -45,6 +51,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.cell.QuickEditorRegion; import com.fr.design.mainframe.template.info.JWorkBookProcessInfo; import com.fr.design.mainframe.template.info.TemplateProcessInfo; +import com.fr.design.mainframe.theme.dialog.TemplateThemeUsingDialog; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.MenuDef; @@ -55,7 +62,6 @@ import com.fr.design.module.DesignModuleFactory; import com.fr.design.parameter.ParameterDefinitePane; import com.fr.design.parameter.ParameterInputPane; import com.fr.design.preview.MobilePreview; -import com.fr.design.preview.NewWritePreview; import com.fr.design.preview.PagePreview; import com.fr.design.preview.ViewPreview; import com.fr.design.preview.WritePreview; @@ -148,6 +154,7 @@ public class JWorkBook extends JTemplate { super(workBook, fileName); populateReportParameterAttr(); } + public JWorkBook(WorkBook workBook, FILE file, Parameter[] parameters) { super(workBook, file, parameters); populateReportParameterAttr(); @@ -196,7 +203,7 @@ public class JWorkBook extends JTemplate { } @Override - protected UIModeControlContainer createCenterPane() { + protected JComponent createCenterPane() { parameterPane = ModuleContext.isModuleStarted(Module.FORM_MODULE) ? new ParameterDefinitePane() : null; centerPane = new UIModeControlContainer(parameterPane, reportComposite = new ReportComponentComposite(this)) { @Override @@ -217,7 +224,21 @@ public class JWorkBook extends JTemplate { reportComposite.addTargetModifiedListener(e -> JWorkBook.this.fireTargetModified()); reportComposite.setParentContainer(centerPane); - return centerPane; + return DesignModeContext.isDuchampMode() ? reportComposite : centerPane; + } + + @Override + protected UIButton createTemplateThemeButton() { + UIButton button = super.createTemplateThemeButton(); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); + TemplateThemeUsingDialog dialog = new TemplateThemeUsingDialog<>(designerFrame, JWorkBook.this, ReportThemeConfig.getInstance()); + dialog.setVisible(true); + } + }); + return button; } @Override @@ -316,7 +337,7 @@ public class JWorkBook extends JTemplate { } private boolean hasParameterPane() { - return parameterPane != null; + return parameterPane != null && !DesignModeContext.isDuchampMode(); } /** @@ -492,7 +513,7 @@ public class JWorkBook extends JTemplate { double creatorWidth = blockCreator.getEditorBounds().width; double areaHeight = polyDezi.polyArea.getHeight(); double areaWidth = polyDezi.polyArea.getWidth(); - if(AssistUtils.equals(creatorWidth,0) || AssistUtils.equals(creatorHeight,0)){ + if (AssistUtils.equals(creatorWidth, 0) || AssistUtils.equals(creatorHeight, 0)) { return resolution; } double time = (areaHeight / creatorHeight) < (areaWidth / creatorWidth) ? (areaHeight / creatorHeight) : (areaWidth / creatorWidth); @@ -509,7 +530,7 @@ public class JWorkBook extends JTemplate { int row = reportPane.getSelection().getSelectedRows()[0]; double rowLength = reportPane.getSelection().getSelectedRows().length; double rowExtent = reportPane.getGrid().getVerticalExtent(); - if(AssistUtils.equals(columnLength,0) || AssistUtils.equals(rowLength,0)){ + if (AssistUtils.equals(columnLength, 0) || AssistUtils.equals(rowLength, 0)) { return resolution; } double time = (columnExtent / columnLength) < (rowExtent / rowLength) ? (columnExtent / columnLength) : (rowExtent / rowLength); @@ -583,7 +604,8 @@ public class JWorkBook extends JTemplate { super.setTarget(book); } - private TargetComponent delegate4ToolbarMenuAdapter() { + + public ReportComponent delegate4ToolbarMenuAdapter() { return this.reportComposite.getEditingReportComponent(); } @@ -944,7 +966,7 @@ public class JWorkBook extends JTemplate { public PreviewProvider[] supportPreview() { PreviewProvider[] templatePreviews = super.supportPreview(); return ArrayUtils.addAll(new PreviewProvider[]{ - new PagePreview(), new WritePreview(), new ViewPreview(), new MobilePreview(), new NewWritePreview() + new PagePreview(), new WritePreview(), new ViewPreview(), new MobilePreview() }, templatePreviews); } @@ -1227,7 +1249,7 @@ public class JWorkBook extends JTemplate { addExtraChooseFILEFilter(fileChooser); } - protected void addExtraChooseFILEFilter(FILEChooserPane fileChooser){ + protected void addExtraChooseFILEFilter(FILEChooserPane fileChooser) { Set providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG); for (ReportSupportedFileUIProvider provider : providers) { provider.addChooseFileFilter(fileChooser, this.suffix()); @@ -1254,4 +1276,44 @@ public class JWorkBook extends JTemplate { designer.hidePopup(); } } + + @Override + public void refreshFormDesigner() { + FormDesigner designer = (FormDesigner) parameterPane.getParaDesigner(); + if (designer != null) { + designer.repaint(); + } + } + + @Override + protected void setUpTheme4NewTemplate() { + super.setUpTheme4NewTemplate(); + getTarget().setTemplateTheme(getTarget().getTemplateTheme()); + } + + + @Override + public TemplateThemeConfig getUsingTemplateThemeConfig() { + return getTarget().getUsingTemplateThemeConfig(); + } + + @Override + public ReportTheme getTemplateTheme() { + return getTarget().getTemplateTheme(); + } + + @Override + public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) { + ReportTheme oldTheme = getTarget().getTemplateTheme(); + boolean shouldCreateUndoState = compatible == TemplateThemeCompatible.NONE && !StringUtils.equals(oldTheme.getName(), newTheme.getName()); + + getTarget().setTemplateTheme(newTheme, compatible); + + fireTargetModified(shouldCreateUndoState); + reportComposite.setSelectedIndex(reportComposite.getSelectedIndex()); + TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).refreshDockingView(); + DesignerContext.getDesignerFrame().resetToolkitByPlus(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + + super.setTemplateTheme(newTheme, compatible); + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java index 9377c619a7..b412d724d0 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe; import com.fr.base.ScreenResolution; import com.fr.common.inputevent.InputEventBaseOnOS; +import com.fr.design.base.mode.DesignModeContext; import com.fr.design.designer.EditingState; import com.fr.design.event.RemoveListener; import com.fr.design.event.TargetModifiedListener; @@ -215,7 +216,9 @@ public class ReportComponentComposite extends JComponent implements RemoveListen jSliderContainer = JFormSliderPane.getInstance(); } southPane.add(hbarContainer, BorderLayout.NORTH); - southPane.add(sheetNameTab, BorderLayout.CENTER); + if (!DesignModeContext.isDuchampMode()) { + southPane.add(sheetNameTab, BorderLayout.CENTER); + } southPane.add(jSliderContainer, BorderLayout.EAST); return southPane; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java index 7b6fbff6f8..f2bf5e5854 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java @@ -26,6 +26,9 @@ import com.fr.base.BaseUtils; import com.fr.base.GraphHelper; import com.fr.base.svg.IconUtils; +import com.fr.base.theme.ReportTheme; +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeCompatible; import com.fr.base.vcs.DesignerMode; import com.fr.design.actions.UpdateAction; import com.fr.design.constants.UIConstants; @@ -807,7 +810,15 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse scrollIndex++; } - reportComposite.getEditingWorkBook().addReport(insertPos, newTemplateReport()); + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + TemplateTheme theme = template.getTemplateTheme(); + + TemplateReport templateReport = newTemplateReport(); + if (theme instanceof ReportTheme) { + templateReport.onTemplateUsingThemeChange((ReportTheme) theme, TemplateThemeCompatible.NONE); + } + + reportComposite.getEditingWorkBook().addReport(insertPos, templateReport); setSelectedIndex(insertPos); // sheet名字的公式也需要做相应的变化. diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java index c708960d7e..e7612c0010 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -57,8 +57,6 @@ import javax.swing.KeyStroke; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import javax.swing.Timer; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; import java.awt.AWTEvent; import java.awt.BorderLayout; import java.awt.Color; @@ -242,21 +240,28 @@ public class AlphaFineDialog extends UIDialog { if (hotData == null) { hotData = HotIssuesManager.getInstance().getHotIssues(); } - for (int i = 0; i < hotData.length; i++) { - panel.add(new HotIssueJpanel(hotData[i], i + 1)); - } } else { hotData = null; - for (int i = 0; i < AlphaFineConstants.HOT_ITEMS; i++) { - panel.add(new HotIssueJpanel(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Connection_Failed")}, i + 1)); - } } + initHotPane(panel, hotData); hotPane.add(uiLabel, BorderLayout.NORTH); hotPane.add(panel, BorderLayout.CENTER); add(hotPane, BorderLayout.SOUTH); setSize(AlphaFineConstants.FULL_SIZE); } + private void initHotPane(JPanel panel, String[][] hotData) { + if (hotData == null) { + for (int i = 0; i < AlphaFineConstants.HOT_ITEMS; i++) { + panel.add(new HotIssueJpanel(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Connection_Failed")}, i + 1)); + } + } else { + for (int i = 0; i < hotData.length; i++) { + panel.add(new HotIssueJpanel(hotData[i], i + 1)); + } + } + } + /** * 初始化输入框 */ diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java index 6897689b81..749a0a611f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java @@ -20,6 +20,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.jetbrains.annotations.Nullable; /** @@ -71,6 +72,7 @@ public class HotIssuesManager { * 从热门问题接口获取热门问题 * @return */ + @Nullable public String[][] getHotIssues() { try { @@ -84,7 +86,7 @@ public class HotIssuesManager { } } } catch (Exception e) { - FineLoggerFactory.getLogger().error("hotissues search error: " + e.getMessage()); + FineLoggerFactory.getLogger().error("hotissues search error: " + e.getMessage(), e); return null; } return data; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java index 431b401fc9..62134c1211 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java @@ -45,7 +45,12 @@ class CptApp extends AbstractWorkBookApp { @Override public WorkBook asIOFile(FILE file) { - return asIOFile(file, true); + // 11.beta.1 + // REPORT-51919 主题切换 + // REPORT-57943 【主题切换】10.0自定义的预定义样式,模板放11.0上,配置丢失 + // 11.beta.1 模版主题功能后,预定义单元格样式功能废弃,所有预定义单元格样式将被统一放置到"兼容主题"中, + // 对于本地不存在的预定义单元格样式,将会被设置为兼容主题中默认单元格样式,因此这里不需要再执行检查 + return asIOFile(file, false); } @Override diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/CellElementEditPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/CellElementEditPane.java index 487214a80e..e54d03443e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/CellElementEditPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/CellElementEditPane.java @@ -8,13 +8,12 @@ import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.itabpane.TitleChangeListener; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.cell.settingpane.*; +import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.utils.DesignUtils; import com.fr.general.ComparatorUtils; - import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.Selection; import com.fr.report.cell.CellElement; -import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; @@ -112,7 +111,7 @@ public class CellElementEditPane extends BasicPane { CellElement cellElement = elementCase.getCellElement(cs.getColumn(), cs.getRow()); if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(cs.getColumn(), cs.getRow()); + cellElement = DefaultThemedTemplateCellElementCase.createInstance(cs.getColumn(), cs.getRow()); //默认选中的是A1单元格,所以若是A1单元格没有加到列表时要加上,否则在聚合报表时会出错 if (cs.isSelectedOneCell(elementCasePane) && (cs.getColumn() + cs.getRow() == 0)) { elementCase.addCellElement((TemplateCellElement) cellElement); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/AbstractCellAttrPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/AbstractCellAttrPane.java index 83ef31eaa9..d9f8ed633f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/AbstractCellAttrPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/AbstractCellAttrPane.java @@ -2,9 +2,9 @@ package com.fr.design.mainframe.cell.settingpane; import com.fr.design.mainframe.AbstractAttrPane; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.FloatSelection; -import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; @@ -52,7 +52,7 @@ public abstract class AbstractCellAttrPane extends AbstractAttrPane { TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); TemplateCellElement cellElement = elementCase.getTemplateCellElement(cs.getColumn(), cs.getRow()); if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(cs.getColumn(), cs.getRow()); + cellElement = DefaultThemedTemplateCellElementCase.createInstance(cs.getColumn(), cs.getRow()); } this.cellElement = cellElement; elementCase.addCellElement(this.cellElement); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java index 0f7466af09..cd454660df 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java @@ -12,9 +12,9 @@ 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.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; -import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.cellattr.CellExpandAttr; import com.fr.report.elementcase.TemplateElementCase; @@ -239,7 +239,7 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { int row = j + cellRectangle.y; TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(column, row); + cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); elementCase.addCellElement(cellElement); } updateBean(cellElement); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java index cbe37764de..1d02fde9cb 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java @@ -17,10 +17,10 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.general.ComparatorUtils; -import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.cellattr.CellGUIAttr; import com.fr.report.cell.cellattr.CellInsertPolicyAttr; @@ -361,10 +361,11 @@ public class CellOtherSetPane extends AbstractCellAttrPane { cellGUIAttr = CellGUIAttr.DEFAULT_CELLGUIATTR; } - // 是否在编辑表单中的报表块 - boolean isInForm = EastRegionContainerPane.getInstance().getCurrentMode().equals(EastRegionContainerPane.PropertyMode.FORM_REPORT); + // 支持 跟随页面设置 选项 = 不在编辑表单中的报表块 && 不在大屏模板cpt组件中 + boolean supportFollowTplDefine = !EastRegionContainerPane.getInstance().getCurrentMode().equals(EastRegionContainerPane.PropertyMode.FORM_REPORT) + && !EastRegionContainerPane.getInstance().getCurrentMode().equals(EastRegionContainerPane.PropertyMode.DUCHAMP_REPORT); - defaultAutoRadioButton.setVisible(!isInForm); + defaultAutoRadioButton.setVisible(supportFollowTplDefine); switch (cellGUIAttr.getAdjustMode()) { case CellGUIAttr.ADJUST_MODE_NO_AUTO: noAutoRadioButton.setSelected(true); @@ -376,10 +377,10 @@ public class CellOtherSetPane extends AbstractCellAttrPane { autoWidthRadioButton.setSelected(true); break; case CellGUIAttr.ADJUST_MODE_DEFAULT: - if (isInForm) { - autoHeightRadioButton.setSelected(true); - } else { + if (supportFollowTplDefine) { defaultAutoRadioButton.setSelected(true); + } else { + autoHeightRadioButton.setSelected(true); } break; default: @@ -569,7 +570,7 @@ public class CellOtherSetPane extends AbstractCellAttrPane { int row = j + cellRectangle.y; TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(column, row); + cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); elementCase.addCellElement(cellElement); } updateBean(cellElement); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellPresentPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellPresentPane.java index 960e93eec5..881b8b0835 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellPresentPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellPresentPane.java @@ -2,9 +2,9 @@ package com.fr.design.mainframe.cell.settingpane; import com.fr.base.present.Present; import com.fr.design.constants.UIConstants; +import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.present.PresentPane; -import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; @@ -67,7 +67,7 @@ public class CellPresentPane extends AbstractCellAttrPane { int row = j + cellRectangle.y; TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(column, row); + cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); elementCase.addCellElement(cellElement); } cellElement.setPresent(present); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java index 049b0111ae..a678c501ac 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java @@ -4,10 +4,10 @@ import com.fr.base.Style; import com.fr.design.actions.utils.ReportActionUtils; import com.fr.design.constants.UIConstants; import com.fr.design.mainframe.cell.settingpane.style.StylePane; +import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.style.BorderUtils; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; @@ -70,7 +70,7 @@ public class CellStylePane extends AbstractCellAttrPane { @Override public void updateBeans() { Object[] selectionCellBorderObjects = BorderUtils.createCellBorderObject(elementCasePane); - if (stylePane.getSelectedIndex() == 1) { + if (stylePane.getSelectedIndex() == 0) { Style s = stylePane.updateBean(); TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); int cellRectangleCount = cs.getCellRectangleCount(); @@ -82,7 +82,7 @@ public class CellStylePane extends AbstractCellAttrPane { int row = j + cellRectangle.y; TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(column, row); + cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); elementCase.addCellElement(cellElement); } cellElement.setStyle(s); @@ -100,7 +100,7 @@ public class CellStylePane extends AbstractCellAttrPane { int row = j + cellRectangle.y; TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); if (cellElement == null) { - cellElement = new DefaultTemplateCellElement(column, row); + cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); elementCase.addCellElement(cellElement); } Style style = cellElement.getStyle(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java index e2d8247574..93bf523970 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java @@ -1,37 +1,164 @@ package com.fr.design.mainframe.cell.settingpane.style; +import com.fr.base.NameStyle; +import com.fr.base.Style; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.dialog.BasicPane; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.icontainer.UIScrollPane; +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.ElementCasePane; +import com.fr.general.ComparatorUtils; +import com.fr.log.FineLoggerFactory; + +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; +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.ActionEvent; +import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; -import javax.swing.event.ChangeListener; +public class StylePane extends BasicPane implements UIObserver { + public static final String[] FOLLOWING_THEME_STRING_ARRAYS = new String[]{ + Toolkit.i18nText("Fine-Design_Style_Follow_Theme"), + Toolkit.i18nText("Fine-Design_Style_Not_Follow_Theme"), + }; + public static final int DEFAULT_SELECTED_INDEX = 0; -import com.fr.base.Style; -import com.fr.design.beans.FurtherBasicBeanPane; -import com.fr.design.gui.frpane.UIComboBoxPane; -import com.fr.general.ComparatorUtils; + private final UIButtonGroup followingThemeButtonGroup; + private final CustomStylePane customStylePane; + private final ThemedCellStyleListPane themedCellStyleListPane; + private final CardLayout cardLayout; + private final JComponent[] panes = new JComponent[2]; -import com.fr.design.mainframe.ElementCasePane; + private JPanel contentPane; + + private final List observerListeners = new ArrayList<>(); + + public StylePane() { + followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); + customStylePane = new CustomStylePane(); + themedCellStyleListPane = new ThemedCellStyleListPane(); + panes[0] = createThemedStylePane(); + panes[1] = createCustomStylePane(); + cardLayout = new CardLayout(); + + initializePane(); + } + + private void initializePane() { + setLayout(new BorderLayout(0, IntervalConstants.INTERVAL_L1)); + + add(createFollowingThemePane(), BorderLayout.NORTH); + contentPane = createTabbedContentPane(); + add(contentPane, BorderLayout.CENTER); + } + + private JPanel createFollowingThemePane() { + followingThemeButtonGroup.setSelectedIndex(DEFAULT_SELECTED_INDEX); + followingThemeButtonGroup.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int selectedIndex = followingThemeButtonGroup.getSelectedIndex(); + cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[selectedIndex]); + if (selectedIndex == 1) { + // 对于同一个单元格,跟随主题切换到自定义,自定义中的配置与其保持一致 + NameStyle lastSelectedNameStyle = themedCellStyleListPane.updateBean(); + if (lastSelectedNameStyle != null) { + Style lastSelectedRealStyle = lastSelectedNameStyle.getRealStyle(); + try { + lastSelectedRealStyle = (Style) lastSelectedRealStyle.clone(); + if (lastSelectedRealStyle != null) { + customStylePane.populateBean(lastSelectedRealStyle); + } + } catch (CloneNotSupportedException ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + } + } + } else { + // 对于同一个单元格,自定义切换到跟随主题,跟随主题选中"默认"样式,并使用默认样式设置选中的单元格 + themedCellStyleListPane.reset(); + } + + fireStateChanged(); + } + }); + + UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Style_Setting")); + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + + return TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{ new Component[] { uiLabel, followingThemeButtonGroup} }, + new double[] { p }, new double[] { p, f}, + IntervalConstants.INTERVAL_L1, 0); + } + + protected JPanel createTabbedContentPane() { + JPanel contentPane = new JPanel(cardLayout) { + @Override + public Dimension getPreferredSize() { + int selectedIndex = followingThemeButtonGroup.getSelectedIndex(); + if (selectedIndex < 0) { + return super.getPreferredSize(); + } else { + return panes[selectedIndex].getPreferredSize(); + } + } + }; + for (int i = 0; i < FOLLOWING_THEME_STRING_ARRAYS.length; i++) { + contentPane.add(panes[i], FOLLOWING_THEME_STRING_ARRAYS[i]); + } + cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[DEFAULT_SELECTED_INDEX]); -public class StylePane extends UIComboBoxPane