diff --git a/designer-base/src/main/java/com/fr/common/detect/CommonPortDetector.java b/designer-base/src/main/java/com/fr/common/detect/CommonPortDetector.java new file mode 100644 index 0000000000..310e75dce0 --- /dev/null +++ b/designer-base/src/main/java/com/fr/common/detect/CommonPortDetector.java @@ -0,0 +1,59 @@ +package com.fr.common.detect; + +import com.fr.concurrent.NamedThreadFactory; +import com.fr.design.DesignerEnvManager; +import com.fr.log.FineLoggerFactory; +import com.fr.module.ModuleContext; +import com.fr.web.WebSocketConfig; + +import java.net.Socket; +import java.util.concurrent.ExecutorService; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/10 + */ +public class CommonPortDetector { + + private static final CommonPortDetector INSTANCE = new CommonPortDetector(); + private ExecutorService service = ModuleContext.getExecutor().newSingleThreadExecutor(new NamedThreadFactory("CommonPortDetector")); + + public static CommonPortDetector getInstance() { + return INSTANCE; + } + + public void execute() { + service.submit(new Runnable() { + @Override + public void run() { + detectTomcatPort(); + detectWebSocketPort(); + } + }); + } + + private void detectTomcatPort() { + int port = DesignerEnvManager.getEnvManager().getEmbedServerPort(); + if (checkPort(port)) { + FineLoggerFactory.getLogger().error("EmbedTomcat Port: {} is not available, maybe occupied by other programs, please check it!", port); + } + } + + private void detectWebSocketPort() { + Integer[] ports = WebSocketConfig.getInstance().getPort(); + for (int port : ports) { + if (checkPort(port)) { + FineLoggerFactory.getLogger().error("WebSocKet Port: {} is not available, maybe occupied by other programs, please check it!", port); + } + } + } + + private boolean checkPort(int port) { + try (Socket socket = new Socket("localhost", port)) { + return true; + } catch (Exception e) { + return false; + } + } +} diff --git a/designer-base/src/main/java/com/fr/common/report/ReportState.java b/designer-base/src/main/java/com/fr/common/report/ReportState.java new file mode 100644 index 0000000000..cc32e439cf --- /dev/null +++ b/designer-base/src/main/java/com/fr/common/report/ReportState.java @@ -0,0 +1,21 @@ +package com.fr.common.report; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/27 + */ +public enum ReportState { + + STOP("stop"), ACTIVE("active"); + + private String value; + + ReportState(String value) { + this.value = value; + } + + public String getValue() { + return this.value; + } +} \ No newline at end of file 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 6ebd349cbb..77c779ce3e 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -8,17 +8,21 @@ import com.fr.base.Utils; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; +import com.fr.design.dialog.ErrorDialog; import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.LocalDesignerWorkspaceInfo; 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.vcs.VcsConfigManager; import com.fr.design.update.push.DesignerPushUpdateConfigManager; import com.fr.design.style.color.ColorSelectConfigManager; import com.fr.design.utils.DesignUtils; +import com.fr.design.utils.DesignerPort; +import com.fr.exit.DesignerExiter; import com.fr.file.FILEFactory; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogFormatter; @@ -81,6 +85,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private static final String VERSION_80 = "80"; private static final int CACHINGTEMPLATE_LIMIT = 5; private static final String WEB_NAME = "webapps"; + /** + * 指定默认工作空间 + */ + public static final String DEFAULT_WORKSPACE_PATH = "fr.designer.workspace.default"; private static DesignerEnvManager designerEnvManager; // gui. private String activationKey = null; @@ -194,6 +202,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { XMLTools.readFileXML(designerEnvManager, designerEnvManager.getDesignerEnvFile()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); + XmlHandler.Self.handle(e); } // james:如果没有env定义,要设置一个默认的 @@ -340,6 +349,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } catch (IOException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); + XmlHandler.Self.handle(e); } finally { if (null != fileWriter) { try { @@ -554,6 +564,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private String getDefaultenvPath(String installHome) { + String defaultWorkspacePath = System.getProperty(DEFAULT_WORKSPACE_PATH); + if (defaultWorkspacePath != null) { + return defaultWorkspacePath; + } //这里需要转成反斜杠和生成默认路径一致 return new File(StableUtils.pathJoin(installHome, WEB_NAME, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME)).getPath(); } @@ -1396,6 +1410,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { /** * 对国际化进行校验 * 非简繁英日韩的默认环境 设计器全部默认为英文版本 + * * @param locale * @return */ @@ -1545,6 +1560,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { readDesignerPushUpdateAttr(reader); } else if (name.equals(vcsConfigManager.XML_TAG)) { readVcsAttr(reader); + } else if (DesignerPort.XML_TAG.equals(name)) { + readDesignerPort(reader); } else { readLayout(reader, name); } @@ -1736,6 +1753,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { reader.readXMLObject(vcsConfigManager); } + public void readDesignerPort(XMLableReader reader) { + reader.readXMLObject(DesignerPort.getInstance()); + } + /** * Write XML.
* The method will be invoked when save data to XML file.
@@ -1761,6 +1782,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { writeOpenDebug(writer); writeDesignerPushUpdateAttr(writer); writeVcsAttr(writer); + writeDesignerPort(writer); writer.end(); } @@ -2010,6 +2032,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.vcsConfigManager.writeXML(writer); } + private void writeDesignerPort(XMLPrintWriter writer) { + DesignerPort.getInstance().writeXML(writer); + } + public VcsConfigManager getVcsConfigManager() { return vcsConfigManager; @@ -2018,4 +2044,28 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { public void setVcsConfigManager(VcsConfigManager vcsConfigManager) { this.vcsConfigManager = vcsConfigManager; } + + enum XmlHandler { + Self; + public void handle(Throwable throwable) { + ErrorDialog dialog = new ErrorDialog(null, + Toolkit.i18nText("Fine-Design_Error_Start_Apology_Message"), + Toolkit.i18nText("Fine-Design_Error_Start_Report"), + throwable.getMessage()) { + @Override + protected void okEvent() { + dispose(); + DesignerExiter.getInstance().execute(); + } + + @Override + protected void restartEvent() { + dispose(); + RestartHelper.restart(); + } + }; + dialog.setVisible(true); + DesignerExiter.getInstance().execute(); + } + }; } 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 c1c11553f7..81e62239b4 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -1,37 +1,62 @@ package com.fr.design; +import com.fr.common.report.ReportState; 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.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceType; +import com.fr.design.env.RemoteWorkspace; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.TemplateTreePane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.utils.DesignUtils; +import com.fr.env.CheckServiceDialog; import com.fr.env.EnvListPane; +import com.fr.exit.DesignerExiter; import com.fr.general.GeneralContext; +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; +import com.fr.process.engine.core.CarryMessageEvent; +import com.fr.process.engine.core.FineProcessContext; +import com.fr.rpc.Result; import com.fr.stable.AssistUtils; import com.fr.stable.EnvChangedListener; +import com.fr.stable.StringUtils; import com.fr.start.server.ServerTray; import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContextCallback; import com.fr.workspace.Workspace; +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.WorkspaceConnectionException; +import com.fr.workspace.engine.rpc.WorkspaceProxyPool; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; +import java.lang.reflect.Method; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; import java.util.HashMap; 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; @@ -83,6 +108,7 @@ public class EnvChangeEntrance { private boolean switch2Env(final String envName, PopTipStrategy strategy) { DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); + WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); try { Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); @@ -91,18 +117,13 @@ public class EnvChangeEntrance { strategy.showTip(new PopTip() { @Override public void show() { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), - UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); } }); return false; } - // 如果版本不一致,且确认 不继续 连接,这里返回 false. - if (!versionCheckAndConfirm(selectedEnv)) { - return false; - } - WorkContext.switchTo(workspace, new WorkContextCallback() { @Override public void done() { @@ -115,20 +136,25 @@ public class EnvChangeEntrance { } } }); + // REPORT-25688如果是war包部署的服务器,给与提示 + if (WorkContext.getCurrent().isWarDeploy()) { + FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_War_Deploy_Tip"), + Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.INFORMATION_MESSAGE); + } //REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录 JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (template != null) { template.refreshToolArea(); } - + showServiceDialog(selectedEnv); } 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() { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), - UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); } }); return false; @@ -137,8 +163,8 @@ public class EnvChangeEntrance { strategy.showTip(new PopTip() { @Override public void show() { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), - UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); } }); @@ -153,6 +179,7 @@ public class EnvChangeEntrance { } /** + * 这个功能留着,可能会加回来,先做注释处理 * 切换远程环境之前,进行版本检测,当版本不一致的时候,提示。 * 当用户确认选择 ok 时,才继续。 * @@ -196,6 +223,148 @@ public class EnvChangeEntrance { return true; } + /** + * 对选择的环境做服务检测 + * @param selectedEnv 选择的工作环境 + */ + public void showServiceDialog(DesignerWorkspaceInfo selectedEnv) throws Exception { + //是否需要做服务校验 + if(needCheckBranch(selectedEnv)) { + String localBranch; + String remoteBranch; + WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); + localBranch = GeneralUtils.readFullBuildNO(); + try { + remoteBranch = new FunctionalHttpRequest(connectionInfo).getServerBranch(); + } catch (WorkspaceConnectionException e) { + remoteBranch = Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Is_Old") + formatBranch(localBranch); + } + //通过是否包含#来避免当前版本为非安装版本(主要是内部开发版本) + if (localBranch.contains("#") && localBranch.equals(remoteBranch)) { + //说明版本一致,仅做日志记录 + FineLoggerFactory.getLogger().info("Remote Designer version consistency"); + } else { + localBranch = formatBranch(localBranch); + remoteBranch = formatBranch(remoteBranch); + Set noExistServiceSet = getNoExistServiceSet(connectionInfo); + StringBuilder textBuilder = new StringBuilder(); + for (Class clazz : noExistServiceSet) { + WorkspaceAPI workspaceAPI = (WorkspaceAPI) clazz.getAnnotation(WorkspaceAPI.class); + if(workspaceAPI == null){ + FineLoggerFactory.getLogger().info("workspace service {} get annotation failed", clazz); + continue; + } + if(workspaceAPI.ignore()){ + continue; + } + String descriptionOfCN = InterProviderFactory.getProvider().getLocText(workspaceAPI.description()); + textBuilder.append(descriptionOfCN).append("\n"); + } + String areaText = textBuilder.toString(); + if(StringUtils.isEmpty(areaText)){ + return; + } + CheckServiceDialog dialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), areaText, localBranch, remoteBranch); + dialog.setVisible(true); + } + } + } + + /** + * 判断是否需要做版本验证,判断依据为 + * 1、选择的环境为远程环境 + * 2、一个月内不弹出是否勾选 + * @param selectedEnv 选择的环境 + * @return + */ + private boolean needCheckBranch(DesignerWorkspaceInfo selectedEnv){ + if(selectedEnv.getType() == DesignerWorkspaceType.Remote){ + try { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + Calendar calendar = Calendar.getInstance(); + if(StringUtils.isEmpty(selectedEnv.getRemindTime())){ + return true; + } + //获取记录的时间 + Date remindTime = format.parse(selectedEnv.getRemindTime()); + calendar.setTime(remindTime); + //获取一个月后的时间 + calendar.add(Calendar.MONTH,1); + //与当前时间作对比,然后判断是否提示 + if(new Date().after(calendar.getTime())){ + return true; + } + } catch (ParseException e) { + return true; + } + } + return false; + } + + /** + * 获取不存在的服务列表 + * @param info 环境连接信息 + * @return 以Set形式返回不存在的服务 + */ + public Set getNoExistServiceSet(WorkspaceConnectionInfo info){ + Set noExistServiceSet = new HashSet(); + Set remoteServiceSet = new HashSet(); + Set localServiceSet = FineObjectPool.getInstance().getServerPool().keySet(); + + try { + JSONArray serviceArray = new FunctionalHttpRequest(info).getServiceList(); + for(int i = 0; i < serviceArray.size(); i++){ + try{ + Class clazz = Class.forName((String) serviceArray.get(i)); + remoteServiceSet.add(clazz); + } catch (Exception e){ + continue; + } + } + noExistServiceSet.addAll(localServiceSet); + noExistServiceSet.removeAll(remoteServiceSet); + return noExistServiceSet; + } catch (WorkspaceConnectionException e) { + FineLoggerFactory.getLogger().info(e.getMessage()); + //根据本地的服务列表做逐一检测 + for(Class clazz : localServiceSet) { + Method testMethod = Reflect.on(Method.class).create(clazz, "connectTest", new Class[0], String.class, new Class[0], 1025, 8, null, null, null, null).get(); + WorkspaceProxyPool proxyPool = (WorkspaceProxyPool) (((RemoteWorkspace) WorkContext.getCurrent()).getClient()).getPool(); + Result result = proxyPool.testInvoker(testMethod); + Exception invokeException = (Exception) result.getException(); + if(invokeException != null){ + Exception cause = (Exception) invokeException.getCause(); + //获取被包装最底层的异常 + while (cause != null) { + invokeException = cause; + cause = (Exception) invokeException.getCause(); + } + //该异常表示服务不存在 + if(invokeException instanceof ClassNotFoundException){ + noExistServiceSet.add(clazz); + } + } + } + return noExistServiceSet; + } catch (Exception e){ + FineLoggerFactory.getLogger().error(e.getMessage(),e); + return noExistServiceSet; + } + } + + /** + * 格式化分支版本号 + * @param branch 初始的分支版本号 + * @return 格式化后的版本号 + */ + private String formatBranch(String branch){ + if(branch.contains("#")){ + return branch.substring(branch.lastIndexOf("#") + 1, branch.length() - 13); + } + return branch; + } + + /** * 编辑items * @@ -242,14 +411,18 @@ public class EnvChangeEntrance { @Override public void doOk() { + ProcessEventPipe pipe = FineProcessContext.getParentPipe(); + if (FineProcessContext.getParentPipe() != null) { + pipe.fire(new CarryMessageEvent(ReportState.ACTIVE.getValue())); + } if (!envListOkAction(envListPane, PopTipStrategy.NOW)) { - System.exit(0); + DesignerExiter.getInstance().execute(); } } @Override public void doCancel() { - System.exit(0); + DesignerExiter.getInstance().execute(); } }); envListDialog.setVisible(true); diff --git a/designer-base/src/main/java/com/fr/design/RestartHelper.java b/designer-base/src/main/java/com/fr/design/RestartHelper.java index cdb4fc532e..64fdda7baa 100644 --- a/designer-base/src/main/java/com/fr/design/RestartHelper.java +++ b/designer-base/src/main/java/com/fr/design/RestartHelper.java @@ -2,6 +2,7 @@ package com.fr.design; import com.fr.design.mainframe.DesignerContext; import com.fr.design.os.impl.RestartAction; +import com.fr.exit.DesignerExiter; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import com.fr.log.FineLoggerFactory; @@ -152,7 +153,14 @@ public class RestartHelper { } finally { WorkContext.getCurrent().close(); frame.dispose(); - System.exit(0); + try { + // 更新升级过渡用 供当前测试 后面可删除 + Class.forName("com.fr.exit.DesignerExiter"); + DesignerExiter.getInstance().execute(); + } catch (Exception ignore) { + } finally { + System.exit(0); + } } } @@ -194,7 +202,11 @@ public class RestartHelper { } catch (IOException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } - DesignerContext.getDesignerFrame().exit(); + if (DesignerContext.getDesignerFrame() != null) { + DesignerContext.getDesignerFrame().exit(); + } else { + DesignerExiter.getInstance().execute(); + } } } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/actions/community/UpAction.java b/designer-base/src/main/java/com/fr/design/actions/community/UpAction.java index 157f775b8c..9e550377f0 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/UpAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/UpAction.java @@ -2,6 +2,7 @@ package com.fr.design.actions.community; import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.menu.MenuKeySet; import com.fr.general.CloudCenter; import com.fr.log.FineLoggerFactory; @@ -38,7 +39,7 @@ public class UpAction extends UpdateAction try { Desktop.getDesktop().browse(new URI(url)); } catch (IOException exp) { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Default_Browser")); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Default_Browser")); FineLoggerFactory.getLogger().error(exp.getMessage(), exp); } catch (URISyntaxException exp) { FineLoggerFactory.getLogger().error(exp.getMessage(), exp); diff --git a/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java b/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java index 83aeaefe3d..574195470b 100644 --- a/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java +++ b/designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java @@ -260,6 +260,13 @@ public class ActionFactory { } } + public static void referCellInsertActionClass(Class[] cls) { + if (cls != null) { + actionClasses.clear(); + Collections.addAll(actionClasses, cls); + } + } + /** * 生成单元格插入相关的Action * 表单中报表块编辑需要屏蔽掉"插入子报表" @@ -318,6 +325,13 @@ public class ActionFactory { } } + public static void referFloatInsertActionClass(Class[] cls) { + if (cls != null) { + floatActionClasses.clear(); + Collections.addAll(floatActionClasses, cls); + } + } + /** * 生成悬浮元素插入相关的Action * 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 55ccfce636..3fc03f438f 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 @@ -38,6 +38,7 @@ import com.fr.general.log.Log4jConfig; import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; +import com.fr.stable.os.OperatingSystem; import com.fr.third.apache.log4j.Level; import com.fr.transaction.Configurations; import com.fr.transaction.Worker; @@ -218,22 +219,23 @@ public class PreferencePane extends BasicPane { oracleSpace = new UICheckBox(i18nText("Fine-Design_Basic_Show_All_Oracle_Tables")); oraclePane.add(oracleSpace); - JPanel upmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Update_Plugin_Manager")); - useOptimizedUPMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_New_Update_Plugin_Manager")); - upmSelectorPane.add(useOptimizedUPMCheckbox); - advancePane.add(upmSelectorPane); + if (!OperatingSystem.isLinux()) { + JPanel upmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Update_Plugin_Manager")); + useOptimizedUPMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_New_Update_Plugin_Manager")); + upmSelectorPane.add(useOptimizedUPMCheckbox); + advancePane.add(upmSelectorPane); + } - //REPORT-23578 先屏蔽掉 - //JPanel dbmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Database_Manager")); - //useUniverseDBMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_Universe_Database_Manager")); - //dbmSelectorPane.add(useUniverseDBMCheckbox); - //advancePane.add(dbmSelectorPane); + JPanel dbmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Database_Manager")); + useUniverseDBMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_Universe_Database_Manager")); + dbmSelectorPane.add(useUniverseDBMCheckbox); + advancePane.add(dbmSelectorPane); JPanel improvePane = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Basic_Product_Improve")); joinProductImproveCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Join_Product_Improve")); improvePane.add(joinProductImproveCheckBox); - if(SupportOSImpl.AUTOPUSHUPDATE.support()){ + if (SupportOSImpl.AUTOPUSHUPDATE.support()) { autoPushUpdateCheckBox = new UICheckBox(i18nText("Fine-Design_Automatic_Push_Update")); improvePane.add(autoPushUpdateCheckBox); } @@ -511,23 +513,8 @@ public class PreferencePane extends BasicPane { JPanel logLevelPane = FRGUIPaneFactory.createTitledBorderPane("log" + i18nText("Fine-Design_Basic_Level_Setting")); logPane.add(logLevelPane); logLevelComboBox = new UIComboBox(LOG); + logLevelComboBox.setEnabled(WorkContext.getCurrent().isLocal()); logLevelPane.add(logLevelComboBox); - logLevelComboBox.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - Configurations.update(new Worker() { - @Override - public void run() { - Log4jConfig.getInstance().setRootLevel((Level) logLevelComboBox.getSelectedItem()); - } - - @Override - public Class[] targets() { - return new Class[]{Log4jConfig.class}; - } - }); - } - }); } private void createLanPane(JPanel generalPane) { @@ -555,8 +542,8 @@ public class PreferencePane extends BasicPane { }); UILabel noticeLabel = new UILabel(i18nText("Fine-Design_Basic_Work_After_Restart_Designer"));//sail:提示重启后生效 double p = TableLayout.PREFERRED; - double rowSize[] = {p}; - double columnSize[] = {p, p, p}; + double[] rowSize = {p}; + double[] columnSize = {p, p, p}; Component[][] components = { {languageLabel, languageComboBox, noticeLabel}, }; @@ -596,7 +583,7 @@ public class PreferencePane extends BasicPane { private void createLengthPane(JPanel advancePane) { double p = TableLayout.PREFERRED; - double rowSize[] = {p}; + double[] rowSize = {p}; // 长度单位选择 JPanel lengthPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Setting_Ruler_Units")); @@ -618,8 +605,8 @@ public class PreferencePane extends BasicPane { private void createServerPane(JPanel advancePane) { double p = TableLayout.PREFERRED; - double rowSize[] = {p}; - double columnSize[] = {p, p, p}; + double[] rowSize = {p}; + double[] columnSize = {p, p, p}; JPanel serverPortPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Web_Preview_Port_Setting")); advancePane.add(serverPortPane); @@ -658,7 +645,7 @@ public class PreferencePane extends BasicPane { /** * The method of populate. * - * @param designerEnvManager + * @param designerEnvManager 设计器环境管理器 */ public void populate(DesignerEnvManager designerEnvManager) { if (designerEnvManager == null) { @@ -687,7 +674,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); } @@ -727,9 +714,11 @@ public class PreferencePane extends BasicPane { this.portEditor.setValue(new Integer(designerEnvManager.getEmbedServerPort())); - useOptimizedUPMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseOptimizedUPM()); + if (useOptimizedUPMCheckbox != null) { + useOptimizedUPMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseOptimizedUPM()); + } - //useUniverseDBMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseUniverseDBM()); + useUniverseDBMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseUniverseDBM()); this.oracleSpace.setSelected(designerEnvManager.isOracleSystemSpace()); this.cachingTemplateSpinner.setValue(designerEnvManager.getCachingTemplateLimit()); @@ -826,23 +815,32 @@ public class PreferencePane extends BasicPane { designerEnvManager.setUndoLimit(MAX_UNDO_LIMIT_50); } - Configurations.update(new Worker() { - @Override - public void run() { - Log4jConfig.getInstance().setRootLevel(((Level) logLevelComboBox.getSelectedItem())); - } + if (WorkContext.getCurrent().isLocal()) { + Configurations.update(new Worker() { + @Override + public void run() { + Level level = (Level) logLevelComboBox.getSelectedItem(); + if (level != null) { + Log4jConfig.getInstance().setRootLevel(level); + } + } - @Override - public Class[] targets() { - return new Class[]{Log4jConfig.class}; - } - }); + @Override + public Class[] targets() { + @SuppressWarnings("unchecked") + Class[] classes = new Class[]{Log4jConfig.class}; + return classes; + } + }); + } Configurations.update(new Worker() { @Override public void run() { - ServerPreferenceConfig.getInstance().setUseOptimizedUPM(useOptimizedUPMCheckbox.isSelected()); - //ServerPreferenceConfig.getInstance().setUseUniverseDBM(useUniverseDBMCheckbox.isSelected()); + if (useOptimizedUPMCheckbox != null) { + ServerPreferenceConfig.getInstance().setUseOptimizedUPM(useOptimizedUPMCheckbox.isSelected()); + } + ServerPreferenceConfig.getInstance().setUseUniverseDBM(useUniverseDBMCheckbox.isSelected()); } @Override diff --git a/designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java b/designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java index f3bfe5622e..f3c5236b52 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java @@ -21,7 +21,7 @@ import java.util.Map; import static javax.swing.JOptionPane.OK_CANCEL_OPTION; import static javax.swing.JOptionPane.OK_OPTION; import static javax.swing.JOptionPane.WARNING_MESSAGE; -import static javax.swing.JOptionPane.showConfirmDialog; +import static com.fr.design.dialog.FineJOptionPane.showConfirmDialog; public final class WebPreviewUtils { diff --git a/designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java b/designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java index 4f8424c41f..5277d2ebf1 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java @@ -2,6 +2,7 @@ package com.fr.design.actions.file.export; import com.fr.design.actions.JTemplateAction; import com.fr.design.base.mode.DesignModeContext; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.iprogressbar.FRProgressBar; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; @@ -132,10 +133,10 @@ public abstract class AbstractExportAction> extends JT E e = getEditingComponent(); if (!e.isALLSaved() && !DesignModeContext.isVcsMode()) { e.stopEditing(); - int returnVal = JOptionPane.showConfirmDialog( + int returnVal = FineJOptionPane.showConfirmDialog( DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + e.getEditingFILE() + "\" ?", - ProductConstants.PRODUCT_NAME, + Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE ); @@ -171,30 +172,30 @@ public abstract class AbstractExportAction> extends JT this.setProgress(100); FineLoggerFactory.getLogger().info("\"" + name + "\"" + Toolkit.i18nText("Fine-Design_Report_Finish_Export") + "!"); - JOptionPane.showMessageDialog( + FineJOptionPane.showMessageDialog( DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Report_Exported_Successfully") + "\n" + name); } catch (RemoteDesignPermissionDeniedException exp) { - FineLoggerFactory.getLogger().error(exp.getMessage(), exp); this.setProgress(100); target.closeTemplate(); - JOptionPane.showMessageDialog( + FineLoggerFactory.getLogger().error(exp.getMessage(), exp); + FineJOptionPane.showMessageDialog( DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Engine_Remote_Design_Permission_Denied"), - UIManager.getString("OptionPane.messageDialogTitle"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon") ); } catch (Exception exp) { - FineLoggerFactory.getLogger().error(exp.getMessage(), exp); this.setProgress(100); target.closeTemplate(); - JOptionPane.showMessageDialog( + FineLoggerFactory.getLogger().error(exp.getMessage(), exp); + FineJOptionPane.showMessageDialog( DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Report_Export_Failed") + "\n" + path, - UIManager.getString("OptionPane.messageDialogTitle"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon") ); diff --git a/designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java b/designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java index 4b09de8562..0839c14767 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java @@ -51,7 +51,7 @@ public class FineUIAction extends UpdateAction { BasicDialog dialog = pane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override public void doOk() { - + // Do nothing } }); dialog.setVisible(true); diff --git a/designer-base/src/main/java/com/fr/design/actions/help/ForumAction.java b/designer-base/src/main/java/com/fr/design/actions/help/ForumAction.java index 2d4814d2ed..0f3c5e9cc1 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/ForumAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/ForumAction.java @@ -6,6 +6,7 @@ package com.fr.design.actions.help; import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.menu.MenuKeySet; import com.fr.general.CloudCenter; import com.fr.log.FineLoggerFactory; @@ -47,7 +48,7 @@ public class ForumAction extends UpdateAction { try { Desktop.getDesktop().browse(new URI(url)); } catch (IOException exp) { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Default_Browser")); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Default_Browser")); FineLoggerFactory.getLogger().error(exp.getMessage(), exp); } catch (URISyntaxException exp) { FineLoggerFactory.getLogger().error(exp.getMessage(), exp); diff --git a/designer-base/src/main/java/com/fr/design/actions/help/SupportQQAction.java b/designer-base/src/main/java/com/fr/design/actions/help/SupportQQAction.java index a118f9d878..16b8b19eba 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/SupportQQAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/SupportQQAction.java @@ -6,6 +6,7 @@ package com.fr.design.actions.help; import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.menu.MenuKeySet; import com.fr.log.FineLoggerFactory; @@ -37,7 +38,7 @@ public class SupportQQAction extends UpdateAction { try { Desktop.getDesktop().browse(new URI(ProductConstants.SUPPORT_QQ)); } catch (IOException exp) { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Default_Browser")); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Default_Browser")); FineLoggerFactory.getLogger().error(exp.getMessage(), exp); } catch (URISyntaxException exp) { FineLoggerFactory.getLogger().error(exp.getMessage(), exp); diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/RemindDialog.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/RemindDialog.java index fe894437d7..e2d7b63c9f 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/RemindDialog.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/RemindDialog.java @@ -31,7 +31,7 @@ public class RemindDialog extends UIDialog { @Override public void checkValid() throws Exception { - + // Do nothing } public RemindPane getRemindPane() { diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/RemindPane.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/RemindPane.java index 7591c2af3d..1d8d99266e 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/RemindPane.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/RemindPane.java @@ -114,6 +114,7 @@ public class RemindPane extends JPanel { @Override public void removeLayoutComponent(Component comp) { + // Do nothing } @Override @@ -139,6 +140,7 @@ public class RemindPane extends JPanel { @Override public void addLayoutComponent(String name, Component comp) { + // Do nothing } }; } diff --git a/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java b/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java index 15c6cb705c..50ecd0ea6d 100644 --- a/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java @@ -57,49 +57,6 @@ public class ConnectionListAction extends UpdateAction { osBasedAction.execute(); } - /* private void openDesignDatabaseManager() { - DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); - final ConnectionConfig datasourceManager = ConnectionConfig.getInstance(); - final ConnectionManagerPane databaseManagerPane = new ConnectionManagerPane() { - public void complete() { - ConnectionConfig connectionConfig = datasourceManager.mirror(); - populate(connectionConfig); - } - - protected void renameConnection(String oldName, String newName) { - datasourceManager.renameConnection(oldName, newName); - } - }; - final BasicDialog databaseListDialog = databaseManagerPane.showLargeWindow(designerFrame, null); - databaseListDialog.addDialogActionListener(new DialogActionAdapter() { - public void doOk() { - if (!databaseManagerPane.isNamePermitted()) { - databaseListDialog.setDoOKSucceed(false); - return; - } - Configurations.modify(new WorkerFacade(ConnectionConfig.class) { - @Override - public void run() { - databaseManagerPane.update(datasourceManager); - } - }.addCallBack(new CallBackAdaptor() { - @Override - public boolean beforeCommit() { - //如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面 - return doWithDatasourceManager(datasourceManager, databaseManagerPane, databaseListDialog); - } - - @Override - public void afterCommit() { - DesignerContext.getDesignerBean("databasename").refreshBeanElement(); - } - })); - } - }); - databaseListDialog.setVisible(true); - } -*/ - /** * 更新datasourceManager * diff --git a/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java b/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java index deef91f0c7..84591579ec 100644 --- a/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java @@ -77,17 +77,7 @@ public class GlobalTableDataAction extends UpdateAction implements ResponseDataS } protected void renameConnection(final String oldName, final String newName) { - Configurations.update(new Worker() { - @Override - public void run() { - tableDataConfig.renameTableData(oldName, newName); - } - - @Override - public Class[] targets() { - return new Class[]{TableDataConfig.class, ProcedureConfig.class}; - } - }); + tableDataConfig.renameTableData(oldName, newName); } }; final BasicDialog globalTableDataDialog = globalTableDataPane.showLargeWindow(designerFrame, null); diff --git a/designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java b/designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java index 7b41f6fd81..d000dbbbb0 100644 --- a/designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java @@ -16,7 +16,6 @@ import java.awt.event.ActionEvent; * @since 8.0 */ public class PluginManagerAction extends UpdateAction { - private static String PLUGIN_MANAGER_ROUTE = "#management/plugin"; public PluginManagerAction() { this.setMenuKeySet(PLUGIN_MANAGER); this.setName(getMenuKeySet().getMenuKeySetName()); diff --git a/designer-base/src/main/java/com/fr/design/condition/ContinuousTreeSelectionModel.java b/designer-base/src/main/java/com/fr/design/condition/ContinuousTreeSelectionModel.java index 69d3a51aa8..8e83255cf3 100644 --- a/designer-base/src/main/java/com/fr/design/condition/ContinuousTreeSelectionModel.java +++ b/designer-base/src/main/java/com/fr/design/condition/ContinuousTreeSelectionModel.java @@ -16,8 +16,6 @@ import com.fr.design.utils.gui.GUICoreUtils; * 一个层次连续节点. */ public class ContinuousTreeSelectionModel extends DefaultTreeSelectionModel { - public ContinuousTreeSelectionModel() { - } public void addSelectionPaths(TreePath[] paths) { if (paths == null || paths.length == 0) { diff --git a/designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java b/designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java index 193c35775a..98f5f36530 100644 --- a/designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java +++ b/designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java @@ -10,6 +10,7 @@ import com.fr.data.condition.ListCondition; import com.fr.data.condition.ObjectCondition; import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.UIFormula; import com.fr.design.formula.VariableResolver; @@ -123,7 +124,7 @@ public abstract class LiteConditionPane extends BasicBeanPa ExpandMutableTreeNode parentTreeNode = getParentTreeNode(); boolean result = isExistedInParentTreeNode(parentTreeNode, liteCondition, false); if (result) { - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(LiteConditionPane.this), + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(LiteConditionPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_BindColumn_This_Condition_Has_Been_Existed")); return; } @@ -222,7 +223,7 @@ public abstract class LiteConditionPane extends BasicBeanPa return; } - int returnVal = JOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(LiteConditionPane.this), + int returnVal = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(LiteConditionPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove"), JOptionPane.OK_CANCEL_OPTION); if (returnVal == JOptionPane.OK_OPTION) { @@ -610,7 +611,7 @@ public abstract class LiteConditionPane extends BasicBeanPa //修改的时候加入判断条件重复 REPORT-13441 boolean result = isExistedInParentTreeNode(parentTreeNode, liteCondition, true); if (result) { - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(LiteConditionPane.this), + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(LiteConditionPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_BindColumn_This_Condition_Has_Been_Existed")); return; } diff --git a/designer-base/src/main/java/com/fr/design/constants/UIConstants.java b/designer-base/src/main/java/com/fr/design/constants/UIConstants.java index 1e119d27ed..15a7c87c08 100644 --- a/designer-base/src/main/java/com/fr/design/constants/UIConstants.java +++ b/designer-base/src/main/java/com/fr/design/constants/UIConstants.java @@ -145,7 +145,6 @@ public interface UIConstants { public static final Color LIST_ITEM_SPLIT_LINE = new Color(0xf0f0f3); - public static final BufferedImage DRAG_BAR = IOUtils.readImage("com/fr/design/images/control/bar.png"); public static final BufferedImage DRAG_BAR_LIGHT = IOUtils.readImage("com/fr/design/images/control/bar-light.png"); public static final BufferedImage ARROW_NORTH = IOUtils.readImage("com/fr/design/images/control/up_arrow.png"); @@ -196,6 +195,7 @@ public interface UIConstants { public static final Icon ANA_SMALL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/anas.png"); public static final Icon REFRESH_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/refresh.png"); public static final Icon FONT_ICON = IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"); + public static final Icon AUTO_FONT_ICON = IOUtils.readIcon("/com/fr/design/images/gui/color/autoForeground.png"); public static final Icon HISTORY_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/history.png"); public static final Icon DELETE_ICON = IOUtils.readIcon("com/fr/design/images/m_file/close.png"); public static final Icon EDIT_ICON = IOUtils.readIcon("com/fr/design/images/m_file/edit.png"); diff --git a/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java b/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java index 313ca0e2f7..45b3ac6a2a 100644 --- a/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java +++ b/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java @@ -272,10 +272,12 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp */ @Override public void editingCanceled(ChangeEvent e) { + // Do nothing } @Override public void editingStopped(ChangeEvent e) { + // Do nothing } } 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 44ec26127b..dc7002fa85 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 @@ -83,6 +83,7 @@ public abstract class DesignTableDataManager { //用于记录是否要弹出参数框 private static ThreadLocal threadLocal = new ThreadLocal(); + private static Map> columnCache = new HashMap<>(); /** * 清除全局 数据集缓存. @@ -113,11 +114,14 @@ public abstract class DesignTableDataManager { public static void closeTemplate(JTemplate template) { if (template != null) { + template.whenClose(); + columnCache.remove(getEditingTableDataSource()); dsListenersMap.remove(template.getPath()); } } public static void envChange() { + columnCache.clear(); dsListenersMap.clear(); dsNameChangedMap.clear(); clearGlobalDs(); @@ -197,7 +201,60 @@ public abstract class DesignTableDataManager { java.util.Map resMap = getAllEditingDataSet(source); java.util.Map dsMap = getAllDataSetIncludingProcedure(resMap); TableDataWrapper tabledataWrapper = dsMap.get(dsName); - return tabledataWrapper == null ? new String[0] : tabledataWrapper.calculateColumnNameList().toArray(new String[0]); + if (tabledataWrapper == null) { + return new String[0]; + } else { + return getSelectedColumnNamesFromCache(source, dsName, tabledataWrapper); + } + } + + private static String[] getSelectedColumnNamesFromCache(TableDataSource dataSource, String dsName, TableDataWrapper tableDataWrapper) { + Map map = columnCache.get(dataSource); + if (map == null) { + map = new HashMap<>(); + String[] columnNames = tableDataWrapper.calculateColumnNameList().toArray(new String[0]); + map.put(dsName, columnNames); + columnCache.put(dataSource, map); + return columnNames; + } else { + String[] columnNames = map.get(dsName); + if (columnNames == null) { + columnNames = tableDataWrapper.calculateColumnNameList().toArray(new String[0]); + map.put(dsName, columnNames); + return columnNames; + } else { + return columnNames; + } + } + } + + public static void removeSelectedColumnNames(String dsName) { + Map map = columnCache.get(getEditingTableDataSource()); + if (map == null) { + return; + } + map.remove(dsName); + } + + public static void addDsColumnNames(String dsName, String[] columnNames) { + TableDataSource dataSource = getEditingTableDataSource(); + Map map = columnCache.get(dataSource); + if (map == null) { + map = new HashMap<>(); + map.put(dsName, columnNames); + columnCache.put(dataSource, map); + } else { + map.put(dsName, columnNames); + } + } + + public static String[] getDsColumnNames(String dsName) { + TableDataSource dataSource = getEditingTableDataSource(); + Map map = columnCache.get(dataSource); + if (map == null) { + return new String[0]; + } + return map.get(dsName); } /** diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java index 028f71363b..eda6414671 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java @@ -17,6 +17,7 @@ import com.fr.design.data.datapane.preview.PreviewLabel; import com.fr.design.data.datapane.preview.PreviewLabel.Previewable; import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.tabledata.Prepare4DataSourceChange; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.icombobox.FRTreeComboBox; import com.fr.design.gui.icombobox.FilterableComboBoxModel; import com.fr.design.gui.icombobox.UIComboBox; @@ -103,10 +104,12 @@ public class ChoosePane extends BasicBeanPane implements Refresha @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { + // Do nothing } @Override public void popupMenuCanceled(PopupMenuEvent e) { + // Do nothing } }; @@ -114,10 +117,12 @@ public class ChoosePane extends BasicBeanPane implements Refresha private PopupMenuListener listener = new PopupMenuListener() { @Override public void popupMenuCanceled(PopupMenuEvent e) { + // Do nothing } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { + // Do nothing } @Override @@ -199,6 +204,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha } protected void addFocusListener() { + // Do nothing } @SuppressWarnings("unchecked") @@ -332,7 +338,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha DBUtils.refreshDatabase(); String schema = StringUtils.isEmpty(schemaBox.getSelectedItem()) ? null : schemaBox.getSelectedItem(); DataCoreUtils.refreshTables(getConnection(), TableProcedure.TABLE, schema); - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh_Successfully") + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh_Database"), + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh_Successfully") + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh_Database"), JOptionPane.INFORMATION_MESSAGE); } @@ -438,7 +444,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha } } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"), + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Failed"), JOptionPane.ERROR_MESSAGE); } } @@ -462,7 +468,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha } if (!connect) { DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); - JOptionPane.showMessageDialog(designerFrame, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"), + FineJOptionPane.showMessageDialog(designerFrame, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Failed"), JOptionPane.ERROR_MESSAGE); failedToFindTable(); return null; @@ -492,6 +498,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha } protected void failedToFindTable() { + // Do nothing } protected String getTableName() { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java index 0ca42c0f92..14d0431e25 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java @@ -75,6 +75,7 @@ public class ChoosePaneSupportFormula extends ChoosePane { } protected void addFocusListener() { + // Do nothing } /** diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java index 59880cc4ef..d2fdc32291 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java @@ -5,6 +5,7 @@ import com.fr.data.TableDataSource; import com.fr.data.api.StoreProcedureAssist; import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.design.data.DesignTableDataManager; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.ilist.ListModelElement; @@ -49,7 +50,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData if (StringUtils.isEmpty(tempName)) { isNamePermitted = false; nameableList.stopEditing(); - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Toolkit.i18nText("Fine-Design_Basic_Table_Data_Empty_Name_Tips")); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Toolkit.i18nText("Fine-Design_Basic_Table_Data_Empty_Name_Tips")); setIllegalIndex(editingIndex); return; } @@ -58,17 +59,17 @@ public class TableDataPaneListPane extends JListControlPane implements TableData && isNameRepeated(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName)) { isNamePermitted = false; nameableList.stopEditing(); - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Toolkit.i18nText("Fine-Design_Basic_Table_Data_Duplicate_Name_Tips", tempName)); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Toolkit.i18nText("Fine-Design_Basic_Table_Data_Duplicate_Name_Tips", tempName)); setIllegalIndex(editingIndex); } else if (editingType instanceof StoreProcedure && isIncludeUnderline(tempName)) { isNamePermitted = false; nameableList.stopEditing(); - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Toolkit.i18nText("Fine-Design_Basic_Stored_Procedure_Name_Tips")); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Toolkit.i18nText("Fine-Design_Basic_Stored_Procedure_Name_Tips")); setIllegalIndex(editingIndex); } if (nameableList.getSelectedValue() instanceof ListModelElement) { Nameable selected = ((ListModelElement) nameableList.getSelectedValue()).wrapper; - if (!ComparatorUtils.equals(tempName, selected.getName())) { + if (!ComparatorUtils.equals(tempName, selected.getName()) && !isNameRepeated(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName)) { rename(selected.getName(), tempName); } @@ -255,6 +256,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData } protected void checkRepeatedDSName(List exsitTableDataNameList) { + // Do nothing } /** 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 56f81e9a5b..531e128484 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 @@ -16,6 +16,9 @@ import com.fr.design.data.tabledata.wrapper.AbstractTableDataWrapper; 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.fun.TableDataDefineProvider; import com.fr.design.fun.TableDataPaneProcessor; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icontainer.UIScrollPane; @@ -24,12 +27,12 @@ import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.icon.IconPathConstants; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.MenuDef; import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.ToolBarDef; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; - import com.fr.general.NameObject; import com.fr.plugin.context.PluginContext; import com.fr.plugin.injectable.PluginModule; @@ -38,8 +41,13 @@ import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; import com.fr.stable.core.PropertyChangeAdapter; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.ToolTipManager; +import java.awt.BorderLayout; +import java.awt.GridLayout; import java.awt.dnd.DnDConstants; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; @@ -89,23 +97,9 @@ public class TableDataTreePane extends BasicTableDataTreePane { createAddMenuDef(); - GeneralContext.listenPluginRunningChanged(new PluginEventListener(PLUGIN_LISTENER_PRIORITY) { - - @Override - public void on(PluginEvent event) { - - addMenuDef.clearShortCuts(); - createAddMenuDef(); - } - }, new PluginFilter() { - - @Override - public boolean accept(PluginContext context) { + // 创建插件监听 + createPluginListener(); - return context.contain(PluginModule.ExtraDesign); - } - }); - editAction = new EditAction(); removeAction = new RemoveAction(); previewTableDataAction = new PreviewTableDataAction(dataTree); @@ -145,8 +139,57 @@ public class TableDataTreePane extends BasicTableDataTreePane { new TableDataTreeDragSource(dataTree, DnDConstants.ACTION_COPY); checkButtonEnabled(); } + + private void createPluginListener() { + + //菜单栏监听 + GeneralContext.listenPluginRunningChanged(new PluginEventListener(PLUGIN_LISTENER_PRIORITY) { + + @Override + public void on(PluginEvent event) { + + addMenuDef.clearShortCuts(); + createAddMenuDef(); + } + }, new PluginFilter() { + + @Override + public boolean accept(PluginContext context) { + + return context.contain(PluginModule.ExtraDesign); + } + }); + + //监听数据集插件 + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + @Override + public void on(PluginEvent event) { + //REPORT-25577 + //如果数据集插件禁用或启用。需要清空当前模板中的缓存 + reloadCurrTemplate(); + } + private void reloadCurrTemplate() { + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (accept(jt)) { + jt.refreshResource(); + } + } + + private boolean accept(JTemplate jt) { + + return jt != null && jt.getEditingFILE() != null && jt.getEditingFILE().exists(); + } + }, new PluginFilter() { + @Override + public boolean accept(PluginContext pluginContext) { + return pluginContext.contain(TableDataDefineProvider.XML_TAG); + } + }); + } + + protected void checkButtonEnabled() { super.checkButtonEnabled(editAction, previewTableDataAction, removeAction, op, dataTree); } @@ -243,6 +286,7 @@ public class TableDataTreePane extends BasicTableDataTreePane { if (selectedNO == null) { return; } + DesignTableDataManager.removeSelectedColumnNames(selectedNO.getName()); dgEdit(((AbstractTableDataWrapper) selectedNO.getObject()).creatTableDataPane(), selectedNO.getName(), false); } } @@ -263,7 +307,7 @@ public class TableDataTreePane extends BasicTableDataTreePane { return; } - int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + ":" + selectedNO.getName() + "?", + int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + ":" + selectedNO.getName() + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (returnVal == JOptionPane.OK_OPTION) { // richer:这个地方为什么要在DataSourceTree里面去remove呢?多此一举吧 @@ -274,6 +318,7 @@ public class TableDataTreePane extends BasicTableDataTreePane { dataTree.setSelectionRow(dataTree.getRowCount() - 1); fireDSChanged(); checkButtonEnabled(); + DesignTableDataManager.removeSelectedColumnNames(selectedNO.getName()); } } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java index a14944d5e6..1e3f96a986 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java @@ -4,6 +4,7 @@ import com.fr.data.impl.Connection; import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.impl.JNDIDatabaseConnection; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.fun.ConnectionProvider; import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameObjectCreator; @@ -43,7 +44,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh String tempName = getEditingName(); if (StringUtils.isEmpty(tempName)) { nameableList.stopEditing(); - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ConnectionListPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connection_Empty_Name")); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ConnectionListPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connection_Empty_Name")); setIllegalIndex(editingIndex); isNamePermitted = false; return; @@ -53,7 +54,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh isNamePermitted = false; nameableList.stopEditing(); String message = Toolkit.i18nText("Fine-Design_Basic_Connection_Duplicate_Name", tempName); - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ConnectionListPane.this), message); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ConnectionListPane.this), message); setIllegalIndex(editingIndex); } if (isNamePermitted && !ComparatorUtils.equals(tempName, selectedName)) { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionTableProcedurePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionTableProcedurePane.java index f6f258285d..4b4d668666 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionTableProcedurePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionTableProcedurePane.java @@ -98,7 +98,7 @@ public class ConnectionTableProcedurePane extends BasicPane { } protected void addKeyMonitor() { - + //do nothing } protected JPanel createCheckBoxgroupPane() { @@ -137,7 +137,7 @@ public class ConnectionTableProcedurePane extends BasicPane { /** * 给 itemComboBox 加上 itemListener - * + * * @param itemListener */ public void addItemListener(ItemListener itemListener) { @@ -214,7 +214,7 @@ public class ConnectionTableProcedurePane extends BasicPane { public static interface DoubleClickSelectedNodeOnTreeListener { /** * 处理双击事件 - * + * * @param target */ public void actionPerformed(TableProcedure target); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java index 6be5657bbd..575ba43f5b 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java @@ -140,8 +140,6 @@ public class PreviewTableModel extends AbstractTableModel { * 就是由于预览的JTable在不停的getRowCount来显示数据. */ private static class ErrorResultSet extends AbstractDataModel { - public ErrorResultSet() { - } public int getRowCount() { return 0; @@ -160,6 +158,7 @@ public class PreviewTableModel extends AbstractTableModel { } public void release() throws Exception { + // Do nothing } } 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 01d7c9a6ff..2cd16b4940 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 @@ -14,6 +14,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.ilable.UILabel; @@ -303,7 +304,7 @@ public class PreviewTablePane extends BasicPane { return; } FineLoggerFactory.getLogger().error(exp.getMessage(), exp); - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), columnErrMessage, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), columnErrMessage, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE); } private void populate(TableData tableData) throws Exception { @@ -394,8 +395,8 @@ public class PreviewTablePane extends BasicPane { } catch (Exception e) { if (!(e instanceof CancellationException)) { FineLoggerFactory.getLogger().error(e.getMessage(), e); - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), - null, 0, UIManager.getIcon("OptionPane.errorIcon")); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); } dialog.setVisible(false); } finally { diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/AutoStoreProcedureTableModel.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/AutoStoreProcedureTableModel.java index a3248ba1d8..3336596591 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/AutoStoreProcedureTableModel.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/AutoStoreProcedureTableModel.java @@ -38,6 +38,7 @@ public class AutoStoreProcedureTableModel extends StoreProcedureTableModel { this.setDefaultEditor(ParameterTableModel.ParameterEditor.class, new ParameterTableModel().new ParameterEditor()); this.setDefaultRenderer(StoreProcedureParameterValueEditor.class, new ProcedureParameterValueRenderer()); } + @Override public boolean isCellEditable(int row, int col) { if (ComparatorUtils.equals(getValueAt(row, col -1), "OUT")) { return false; @@ -48,6 +49,7 @@ public class AutoStoreProcedureTableModel extends StoreProcedureTableModel { return false; } + @Override public boolean shouldResponseDoubleClickAction () { return false; } @@ -60,7 +62,7 @@ public class AutoStoreProcedureTableModel extends StoreProcedureTableModel { editor = ValueEditorPaneFactory.createStoreProcedValueEditorPane(); editor.getMenu().addPopupMenuListener(new PopupMenuListener() { public void popupMenuWillBecomeVisible(PopupMenuEvent e) { - + // Do nothing } public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { @@ -77,15 +79,16 @@ public class AutoStoreProcedureTableModel extends StoreProcedureTableModel { }, 100); } + @Override public void popupMenuCanceled(PopupMenuEvent e) { - + //do nothing } }); this.addCellEditorListener(new CellEditorListener() { @Override public void editingCanceled(ChangeEvent e) { - + //do nothing } @Override @@ -147,6 +150,7 @@ public class AutoStoreProcedureTableModel extends StoreProcedureTableModel { editor = ValueEditorPaneFactory.createStoreProcedValueEditorPane(); } + @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { editor.setCurrentEditor(0); editor.populate(value); diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ClassTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ClassTableDataPane.java index 7cd8dec3e8..b454ddd89f 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ClassTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ClassTableDataPane.java @@ -57,8 +57,10 @@ public class ClassTableDataPane extends AbstractTableDataPane { (Dialog) SwingUtilities.getWindowAncestor(ClassTableDataPane.this), new DialogActionAdapter() { public void doOk() { - classNameTextField.setText(bPane.getClassPath()); - } + String classPath = bPane.getClassPath(); + ClassTableData tableData = new ClassTableData(classPath); + populateBean(tableData); + } }); dlg.setVisible(true); } @@ -124,6 +126,7 @@ public class ClassTableDataPane extends AbstractTableDataPane { this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); } + @Override public void actionPerformed(ActionEvent e) { java.util.List oldParas = editorPane.update(); oldParas.add(new Parameter()); @@ -132,6 +135,7 @@ public class ClassTableDataPane extends AbstractTableDataPane { @Override public void checkEnabled() { + //do nothing } } private class RemoveParaAction extends UITableEditAction { @@ -149,6 +153,7 @@ public class ClassTableDataPane extends AbstractTableDataPane { @Override public void checkEnabled() { + //do nothing } } diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/CustomDictModel.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/CustomDictModel.java index fdf44df23e..3d9fbad2ad 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/CustomDictModel.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/CustomDictModel.java @@ -1,22 +1,21 @@ package com.fr.design.data.tabledata.tabledatapane; -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.List; +import com.fr.design.gui.itableeditorpane.ActionStyle; +import com.fr.design.gui.itableeditorpane.UIArrayTableModel; +import com.fr.design.gui.itableeditorpane.UITableEditAction; +import com.fr.design.gui.itableeditorpane.UITableModelAdapter; +import com.fr.design.gui.itextfield.UITextField; import javax.swing.AbstractCellEditor; import javax.swing.JTable; import javax.swing.event.CellEditorListener; import javax.swing.event.ChangeEvent; import javax.swing.table.TableCellEditor; - -import com.fr.design.gui.itableeditorpane.ActionStyle; -import com.fr.design.gui.itableeditorpane.UIArrayTableModel; -import com.fr.design.gui.itableeditorpane.UITableEditAction; -import com.fr.design.gui.itableeditorpane.UITableModelAdapter; -import com.fr.design.gui.itextfield.UITextField; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; public class CustomDictModel extends UITableModelAdapter implements ActionStyle { /** @@ -34,11 +33,13 @@ public class CustomDictModel extends UITableModelAdapter implements Ac this.setDefaultEditor(ParameterEditor.class, new ParameterEditor()); } + @Override public Object getValueAt(int row, int column) { Object[] os = this.getList().get(row); return os[column]; } + @Override public void setValueAt(Object value, int row, int column) { Object[] os = this.getList().get(row); os[column] = value; @@ -104,7 +105,7 @@ public class CustomDictModel extends UITableModelAdapter implements Ac @Override public void editingCanceled(ChangeEvent e) { - + //do nothing } @Override 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 44b87cad60..8b5a4e77f9 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 @@ -101,10 +101,10 @@ public class DBTableDataPane extends AbstractTableDataPane { @Override protected void addKeyMonitor() { searchField.addKeyListener(new KeyListener() { - + @Override public void keyTyped(KeyEvent e) { - + //do nothing } @Override @@ -117,7 +117,7 @@ public class DBTableDataPane extends AbstractTableDataPane { @Override public void keyReleased(KeyEvent e) { - + //do nothing } }); } @@ -240,7 +240,7 @@ public class DBTableDataPane extends AbstractTableDataPane { maxPanel.setBorder(null); JPanel wrapMaxPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); wrapMaxPanel.add(maxPanel); - wrapMaxPanel.setPreferredSize(new Dimension(250, 20)); + wrapMaxPanel.setPreferredSize(new Dimension(350, 20)); UIToolbar editToolBar = ToolBarDef.createJToolBar(); toolBarDef.updateToolBar(editToolBar); editToolBar.add(isShareCheckBox); diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java index f55195d3b3..6eb802619f 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java @@ -14,6 +14,7 @@ import com.fr.data.impl.XMLTableData; import com.fr.design.actions.UpdateAction; import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.icheckbox.UICheckBox; @@ -222,7 +223,7 @@ public class FileTableDataPane extends AbstractTableDataPane { public void actionPerformed(ActionEvent arg0) { String uri = ParameterHelper.analyze4Templatee(urlText.getText(), params); if (!checkURL(uri)) { - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(FileTableDataPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Add_JS_warning")); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(FileTableDataPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Add_JS_warning")); return; } params = getEditorPaneParameter(); @@ -234,10 +235,10 @@ public class FileTableDataPane extends AbstractTableDataPane { FineLoggerFactory.getLogger().error(e.getMessage(), e); } if (in == null) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"), - null, 0, UIManager.getIcon("OptionPane.errorIcon")); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); } else { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Connection_Successfully")); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Connection_Successfully")); try { in.close(); } catch (IOException e) { @@ -521,6 +522,7 @@ public class FileTableDataPane extends AbstractTableDataPane { @Override public void checkEnabled() { + //do nothing } } @@ -832,7 +834,7 @@ public class FileTableDataPane extends AbstractTableDataPane { } private class XMLNodeTree extends JTree { - private DefaultTreeModel treeModel; + private DefaultTreeModel xmlTreeModel; private DefaultTreeModel waitTreeModel = null; @@ -854,7 +856,7 @@ public class FileTableDataPane extends AbstractTableDataPane { private MouseListener treeMouseListener = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { - if (XMLNodeTree.this.getModel() != treeModel) { + if (XMLNodeTree.this.getModel() != xmlTreeModel) { return; } int selRow = XMLNodeTree.this.getRowForLocation(e.getX(), e.getY()); @@ -891,7 +893,7 @@ public class FileTableDataPane extends AbstractTableDataPane { } public DefaultTreeModel getTreeModel() { - return treeModel; + return xmlTreeModel; } //防止界面卡死。 @@ -908,7 +910,7 @@ public class FileTableDataPane extends AbstractTableDataPane { //wikky:为满足706设计时对不合法的xml文件(有多个根节点)的处理,把拿到的InputStream强制在最外层添加作为唯一根节点而将文件转换为合法的xml。 private void initData() { params = getEditorPaneParameter(); // 生成tree结构放哪儿呢?放这里感觉不对撒 - treeModel = null; + xmlTreeModel = null; selectedNode = null; xmlColumnsList.clear(); DataSource dataSource = null; @@ -949,17 +951,17 @@ public class FileTableDataPane extends AbstractTableDataPane { FineLoggerFactory.getLogger().error(e.getMessage(), e); loadedTreeModel(); } - if (treeModel == null) { + if (xmlTreeModel == null) { FineLoggerFactory.getLogger().info("The file is wrong or bad, can not create the XMLReader."); return; } - if (treeModel.getChildCount(treeModel.getRoot()) == 1) { - treeModel = new DefaultTreeModel((ExpandMutableTreeNode) treeModel.getChild(treeModel.getRoot(), 0)); + if (xmlTreeModel.getChildCount(xmlTreeModel.getRoot()) == 1) { + xmlTreeModel = new DefaultTreeModel((ExpandMutableTreeNode) xmlTreeModel.getChild(xmlTreeModel.getRoot(), 0)); } else { - ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); + ExpandMutableTreeNode root = (ExpandMutableTreeNode) xmlTreeModel.getRoot(); root.setUserObject(StringUtils.EMPTY); } - this.setModel(treeModel); + this.setModel(xmlTreeModel); } private void loadedTreeModel() { @@ -1011,7 +1013,7 @@ public class FileTableDataPane extends AbstractTableDataPane { } currentNode = new ExpandMutableTreeNode(nodeName); if (layer == 0) { - treeModel = new DefaultTreeModel(currentNode); + xmlTreeModel = new DefaultTreeModel(currentNode); } else { boolean conflict = false; for (int i = 0; i < parentNode.getChildCount(); i++) { diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java index 4a5b33033a..2cf170c55e 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java @@ -144,12 +144,14 @@ public class MultiTDTableDataPane extends AbstractTableDataPane imp } populateWorker = new SwingWorker() { + @Override protected Void doInBackground() throws Exception { try { storeProcedureContext.setText(StringUtils.EMPTY); @@ -204,6 +206,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp return null; } + @Override public void done() { editorPane.populate(storeprocedure.getParameters()); } @@ -218,6 +221,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp * * @param listener 监听器 */ + @Override public void addStoreProcedureWorkerListener(StoreProcedureWorkerListener listener) { this.storeProcedureWorkerListener = listener; @@ -227,6 +231,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp /** * 去除存储过程监听器 */ + @Override public void removeStoreProcedureWorkerListener() { this.storeProcedureWorkerListener = null; @@ -239,7 +244,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp try { throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + "."); } catch (Exception e) { - JOptionPane.showMessageDialog(ProcedureDataPane.this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + "."); + FineJOptionPane.showMessageDialog(ProcedureDataPane.this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + "."); } } @@ -264,6 +269,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp } updateWorker = new SwingWorker() { + @Override protected Void doInBackground() throws Exception { DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER); sp.setCalculating(true); @@ -271,6 +277,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp return null; } + @Override public void done() { DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER); sp.setCalculating(false); @@ -328,6 +335,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp /** * 响应数据集改变 */ + @Override public void fireDSChanged() { fireDSChanged(new HashMap()); } @@ -337,6 +345,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp * * @param map 改变的map */ + @Override public void fireDSChanged(Map map) { DesignTableDataManager.fireDSChanged(map); } @@ -348,6 +357,7 @@ public class ProcedureDataPane extends AbstractTableDataPane imp this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png")); } + @Override public void actionPerformed(ActionEvent evt) { StoreProcedure sp = updateBeanWithOutExecute(); StoreProcedureDataWrapper storeProcedureDataWrappe = new StoreProcedureDataWrapper(sp, StringUtils.EMPTY, queryText.getText()); @@ -361,12 +371,14 @@ public class ProcedureDataPane extends AbstractTableDataPane imp this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png")); } + @Override public void actionPerformed(ActionEvent e) { refresh(); } @Override public void checkEnabled() { + //do nothing } } } diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java index 7c484c7b29..c55e5871ee 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java @@ -33,9 +33,16 @@ public class TableDataManagerPane extends LoadingBasicPane { ); } tableDataPane = pane == null ? new TableDataPaneListPane() { - public void rename(String oldName, String newName) { + @Override + public void rename(final String oldName, final String newName) { super.rename(oldName, newName); - renameConnection(oldName, newName); + new SwingWorker() { + @Override + protected Void doInBackground() { + renameConnection(oldName, newName); + return null; + } + }.execute(); } } : pane; container.add(tableDataPane.getPanel(), BorderLayout.CENTER); diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java index fc94a0618e..82022bea60 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java @@ -50,10 +50,11 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper { DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter(); TableDataSource tds = adapter == null ? null : adapter.getBook(); String[] colNames = tabledata.getColumnNames(tds); + String[] colNamesInCache = DesignTableDataManager.getDsColumnNames(name); if(ArrayUtils.isNotEmpty(colNames)){ - columnNameList = new ArrayList(); - columnNameList.addAll(Arrays.asList(colNames)); - return columnNameList; + return toColumnNameList(colNames); + } else if (ArrayUtils.isNotEmpty(colNamesInCache)) { + return toColumnNameList(colNamesInCache); } EmbeddedTableData embeddedTableData = null; @@ -65,6 +66,13 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper { } } columnNameList = DesignTableDataManager.getColumnNamesByTableData(embeddedTableData); + DesignTableDataManager.addDsColumnNames(name, columnNameList.toArray(new String[0])); + return columnNameList; + } + + private List toColumnNameList(String[] colNames) { + columnNameList = new ArrayList<>(); + columnNameList.addAll(Arrays.asList(colNames)); return columnNameList; } diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java index 49c7dcd119..cefc0e1128 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java @@ -9,6 +9,7 @@ import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.iprogressbar.AutoProgressBar; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.mainframe.DesignerContext; @@ -102,7 +103,7 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper { return columnNameList; } if (!createStore(false)) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Engine_No_TableData")); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Engine_No_TableData")); return new ArrayList(); } columnNameList = Arrays.asList(procedureDataModel.getColumnName()); @@ -219,7 +220,7 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper { } catch (Exception e) { if (!(e instanceof CancellationException)) { FineLoggerFactory.getLogger().error(e.getMessage(), e); - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage()); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage()); } loadingBar.close(); } diff --git a/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseDialog.java b/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseDialog.java index 1a01a8641b..f035d7e418 100644 --- a/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseDialog.java +++ b/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseDialog.java @@ -27,6 +27,6 @@ public class UniversalDatabaseDialog extends UIDialog { @Override public void checkValid() throws Exception { - + //do nothing } } diff --git a/designer-base/src/main/java/com/fr/design/designer/EditingState.java b/designer-base/src/main/java/com/fr/design/designer/EditingState.java index 3f4fdf6f05..8bd46d4bdb 100644 --- a/designer-base/src/main/java/com/fr/design/designer/EditingState.java +++ b/designer-base/src/main/java/com/fr/design/designer/EditingState.java @@ -7,6 +7,7 @@ public interface EditingState { @Override public void revert() { + //do nothing } }; diff --git a/designer-base/src/main/java/com/fr/design/dialog/BasicScrollPane.java b/designer-base/src/main/java/com/fr/design/dialog/BasicScrollPane.java index d67b05d268..0255748979 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/BasicScrollPane.java +++ b/designer-base/src/main/java/com/fr/design/dialog/BasicScrollPane.java @@ -121,12 +121,12 @@ public abstract class BasicScrollPane extends BasicBeanPane{ @Override public void addLayoutComponent(String name, Component comp) { - + //do nothing } @Override public void removeLayoutComponent(Component comp) { - + //do nothing } @Override diff --git a/designer-base/src/main/java/com/fr/design/dialog/ErrorDialog.java b/designer-base/src/main/java/com/fr/design/dialog/ErrorDialog.java new file mode 100644 index 0000000000..21042a57a9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/dialog/ErrorDialog.java @@ -0,0 +1,94 @@ +package com.fr.design.dialog; + +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.utils.gui.GUICoreUtils; +import com.fr.general.FRFont; + +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/1/8 + */ +public abstract class ErrorDialog extends JDialog implements ActionListener { + + private UIButton okButton; + private UIButton restartButton; + + + public ErrorDialog(Frame parent, String message, String title, String detail) { + super(parent, true); + JPanel northPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + JPanel messagePane = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); + UILabel boldFontLabel = new UILabel(message); + UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Send_Report_To_Us")); + Font font = FRFont.getInstance("Dialog", Font.BOLD, 20); + boldFontLabel.setFont(font); + messagePane.add(boldFontLabel); + messagePane.add(label); + northPane.add(messagePane); + + JTextArea area = new JTextArea(detail); + area.setPreferredSize(new Dimension(400, 100)); + area.setEnabled(true); + area.setEditable(false); + JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + UILabel detailLabel = new UILabel(Toolkit.i18nText("Fine-Design_Problem_Detail_Message")); + centerPane.add(detailLabel, BorderLayout.NORTH); + centerPane.add(area, BorderLayout.CENTER); + + JPanel southPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + JPanel controlPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel buttonPane = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 0)); + okButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Ok")); + okButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + okEvent(); + } + }); + buttonPane.add(okButton); + restartButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Restart")); + restartButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + restartEvent(); + } + }); + buttonPane.add(restartButton); + controlPane.add(buttonPane, BorderLayout.EAST); + southPane.add(controlPane); + + this.setTitle(title); + this.setResizable(false); + this.add(northPane, BorderLayout.NORTH); + this.add(centerPane, BorderLayout.CENTER); + this.add(southPane, BorderLayout.SOUTH); + this.setSize(new Dimension(600, 500)); + GUICoreUtils.centerWindow(this); + + } + + @Override + public void actionPerformed(ActionEvent e) { + dispose(); + } + + protected abstract void okEvent(); + + protected abstract void restartEvent(); + +} diff --git a/designer-base/src/main/java/com/fr/design/dialog/FineJOptionPane.java b/designer-base/src/main/java/com/fr/design/dialog/FineJOptionPane.java new file mode 100644 index 0000000000..4a4424d9f5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/dialog/FineJOptionPane.java @@ -0,0 +1,290 @@ +package com.fr.design.dialog; + +import com.fr.invoke.Reflect; + +import javax.swing.Icon; +import javax.swing.JDialog; +import javax.swing.JOptionPane; +import java.awt.Component; +import java.awt.HeadlessException; +import java.util.HashMap; +import java.util.Map; + +/** + * @author Joe + * @version 10.0 + * Created by Joe on 12/5/2019 + */ +public class FineJOptionPane extends JOptionPane { + + public final static String[] OPTION_DEFAULT = { com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Button_OK") }; + public final static String[] OPTION_YES_NO = { com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Yes"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No") }; + public final static String[] OPTION_YES_NO_CANCEL = { com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Yes"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Button_Cancel") }; + public final static String[] OPTION_OK_CANCEL = { com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Button_OK"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Button_Cancel") }; + + //选项类型optionType 和 选项字符串数组 一一对应 + private final static Map OPTION_MAP = new HashMap<>(); + + static { + OPTION_MAP.put(DEFAULT_OPTION, OPTION_DEFAULT); + OPTION_MAP.put(YES_NO_OPTION, OPTION_YES_NO); + OPTION_MAP.put(YES_NO_CANCEL_OPTION, OPTION_YES_NO_CANCEL); + OPTION_MAP.put(OK_CANCEL_OPTION, OPTION_OK_CANCEL); + } + + private final static String MESSAGE_DIALOG_TITLE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Message"); + private final static String CONFIRM_DIALOG_TITLE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"); + private final static String INPUT_DIALOG_TITLE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"); + + /** + * 使用默认 标题 和 消息类型 的消息提示弹出框 + * @param parentComponent 父容器 + * @param message 具体的提示消息 + * @throws HeadlessException + */ + public static void showMessageDialog(Component parentComponent, Object message) + throws HeadlessException { + showMessageDialog(parentComponent, message, MESSAGE_DIALOG_TITLE, + INFORMATION_MESSAGE); + } + + /** + * 使用默认 Icon 的消息提示弹出框 + * @param parentComponent 父容器 + * @param message 具体的提示消息 + * @param title 标题 + * @param messageType 消息类型 + * @throws HeadlessException + */ + public static void showMessageDialog(Component parentComponent, Object message, + String title, int messageType) + throws HeadlessException { + showMessageDialog(parentComponent, message, title, messageType, null); + } + + /** + * 使用默认 选项类型、选项 和 初始选项 的消息提示弹出框 + * @param parentComponent 父容器 + * @param message 具体的提示消息 + * @param title 标题 + * @param messageType 消息类型 + * @param icon 图标 + * @throws HeadlessException + */ + public static void showMessageDialog(Component parentComponent, Object message, + String title, int messageType, Icon icon) + throws HeadlessException { + showMessageDialog(parentComponent, message, title, DEFAULT_OPTION, + messageType, icon, OPTION_DEFAULT, null); + } + + /** + * 自定义的消息提示弹出框 + * @param parentComponent 父容器 + * @param message 具体的提示消息 + * @param title 标题 + * @param optionType 选项类型 + * @param messageType 消息类型 + * @param icon 图标 + * @param options 选项 + * @param initialValue 初始选项 + * @throws HeadlessException + */ + public static void showMessageDialog(Component parentComponent, Object message, + String title, int optionType, int messageType, + Icon icon, Object[] options, Object initialValue) + throws HeadlessException { + showOptionDialog(parentComponent, message, title, optionType, + messageType, icon, options, initialValue); + } + + /** + * 使用默认 标题 和 选项类型 的确认弹出框 + * @param parentComponent 父容器 + * @param message 具体的提示消息 + * @throws HeadlessException + */ + public static int showConfirmDialog(Component parentComponent, Object message) + throws HeadlessException { + return showConfirmDialog(parentComponent, message, + CONFIRM_DIALOG_TITLE, + YES_NO_CANCEL_OPTION); + } + + /** + * 使用默认 消息类型 的确认弹出框 + * @param parentComponent 父容器 + * @param message 具体的提示消息 + * @param title 标题 + * @param optionType 选项类型 + * @throws HeadlessException + */ + public static int showConfirmDialog(Component parentComponent, Object message, + String title, int optionType) throws HeadlessException { + return showConfirmDialog(parentComponent, message, title, optionType, + QUESTION_MESSAGE); + } + + /** + * 使用默认 Icon 的确认弹出框 + * @param parentComponent 父容器 + * @param message 具体的提示消息 + * @param title 标题 + * @param optionType 选项类型 + * @param messageType 消息类型 + * @throws HeadlessException + */ + public static int showConfirmDialog(Component parentComponent, Object message, + String title, int optionType, int messageType) + throws HeadlessException { + return showConfirmDialog(parentComponent, message, title, optionType, + messageType, null); + } + + /** + * 根据 选项类型 获取对应 选项 ,且使用默认 初始选项 的确认弹出框 + * @param parentComponent 父容器 + * @param message 具体的提示消息 + * @param title 标题 + * @param optionType 选项类型 + * @param messageType 消息类型 + * @param icon 图标 + * @throws HeadlessException + */ + public static int showConfirmDialog(Component parentComponent, Object message, + String title, int optionType, int messageType, Icon icon) + throws HeadlessException { + String[] options = OPTION_MAP.get(optionType); + return showConfirmDialog(parentComponent, message, title, optionType, + messageType, icon, options, options[0]); + } + + /** + * 自定义的确认弹出框 + * @param parentComponent 父容器 + * @param message 具体的提示消息 + * @param title 标题 + * @param optionType 选项类型 + * @param messageType 消息类型 + * @param icon 图标 + * @param options 选项 + * @param initialValue 初始选项 + * @throws HeadlessException + */ + public static int showConfirmDialog(Component parentComponent, Object message, + String title, int optionType, int messageType, Icon icon, + Object[] options, Object initialValue) + throws HeadlessException { + return showOptionDialog(parentComponent, message, title, optionType, + messageType, icon, options, initialValue); + } + + /** + * 指定消息内容的输入弹出框 + * @param message 消息内容 + * @return + * @throws HeadlessException + */ + public static String showInputDialog(Object message) + throws HeadlessException { + return showInputDialog(null, message); + } + + /** + * 使用默认 标题 和 消息类型 的输入弹出框 + * @param parentComponent 父容器 + * @param message 消息内容 + * @return + * @throws HeadlessException + */ + public static String showInputDialog(Component parentComponent, + Object message) throws HeadlessException { + return showInputDialog(parentComponent, message, INPUT_DIALOG_TITLE, QUESTION_MESSAGE); + } + + /** + * 使用默认 标题、消息类型、Icon 和 选项 的输入弹出框 + * @param parentComponent 父容器 + * @param message 消息类型 + * @param initialSelectionValue 初始选项 + * @return + */ + public static String showInputDialog(Component parentComponent, Object message, + Object initialSelectionValue) { + return (String)showInputDialog(parentComponent, message, + INPUT_DIALOG_TITLE, QUESTION_MESSAGE, null, null, + initialSelectionValue); + } + + /** + * 使用默认 父容器、消息内容 和 初始选项 的输入弹出框 + * @param message 消息内容 + * @param initialSelectionValue 初始选项 + * @return + */ + public static String showInputDialog(Object message, Object initialSelectionValue) { + return showInputDialog(null, message, initialSelectionValue); + } + + /** + * 使用默认 Icon、选项 和 初始选项 的输入弹出框 + * @param parentComponent 父容器 + * @param message 消息内容 + * @param title 标题 + * @param messageType 消息类型 + * @return + * @throws HeadlessException + */ + public static String showInputDialog(Component parentComponent, + Object message, String title, int messageType) + throws HeadlessException { + return (String)showInputDialog(parentComponent, message, title, + messageType, null, null, null); + } + + /** + * 自定义的输入弹出框 + * @param parentComponent 父容器 + * @param message 消息内容 + * @param title 标题 + * @param messageType 消息类型 + * @param icon 图标 + * @param selectionValues 选项 + * @param initialSelectionValue 初始选项 + * @return + * @throws HeadlessException + */ + public static Object showInputDialog(Component parentComponent, + Object message, String title, int messageType, Icon icon, + Object[] selectionValues, Object initialSelectionValue) + throws HeadlessException { + JOptionPane pane = new JOptionPane(message, messageType, + OK_CANCEL_OPTION, icon, + OPTION_OK_CANCEL, null); + + pane.setWantsInput(true); + pane.setSelectionValues(selectionValues); + pane.setInitialSelectionValue(initialSelectionValue); + pane.setComponentOrientation(((parentComponent == null) ? + getRootFrame() : parentComponent).getComponentOrientation()); + + int style = Reflect.on(JOptionPane.class).call("styleFromMessageType", messageType).get(); + JDialog dialog = Reflect.on(pane).call("createDialog", parentComponent, title, style).get(); + + pane.selectInitialValue(); + dialog.show(); + dialog.dispose(); + + Object value = pane.getInputValue(); + + if (value == UNINITIALIZED_VALUE) { + return null; + } + return value; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/dialog/JWizardDialog.java b/designer-base/src/main/java/com/fr/design/dialog/JWizardDialog.java index 95894bd014..891e1bf757 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/JWizardDialog.java +++ b/designer-base/src/main/java/com/fr/design/dialog/JWizardDialog.java @@ -363,5 +363,6 @@ public class JWizardDialog extends BasicDialog { @Override public void checkValid() throws Exception { + //do nothing } } diff --git a/designer-base/src/main/java/com/fr/design/dialog/JWizardPanel.java b/designer-base/src/main/java/com/fr/design/dialog/JWizardPanel.java index ce3a2f9da6..c4762f2557 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/JWizardPanel.java +++ b/designer-base/src/main/java/com/fr/design/dialog/JWizardPanel.java @@ -168,7 +168,7 @@ public class JWizardPanel extends BasicPane { public void addNotify() { if (firstNotify) { Font font = stepTitleLabel.getFont(); - font = font.deriveFont(Font.BOLD, font.getSize() * 14 / 10.0F); + font = font.deriveFont(Font.BOLD, (float) (font.getSize() * 14 / 10.0D)); stepTitleLabel.setFont(font); firstNotify = false; } diff --git a/designer-base/src/main/java/com/fr/design/dialog/TipDialog.java b/designer-base/src/main/java/com/fr/design/dialog/TipDialog.java new file mode 100644 index 0000000000..35f9c3c0fb --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/dialog/TipDialog.java @@ -0,0 +1,98 @@ +package com.fr.design.dialog; + +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.utils.gui.GUICoreUtils; +import com.fr.general.IOUtils; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/1/8 + */ +public abstract class TipDialog extends JDialog implements ActionListener { + + private UIButton endButton; + private UIButton cancelButton; + + public TipDialog(Frame parent, String type, String tip, String endText, String cancelText) { + super(parent, true); + JPanel northPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + JPanel iconPane = new JPanel(); + UILabel iconLabel = new UILabel(); + iconLabel.setIcon(IOUtils.readIcon("com/fr/design/images/error/error2.png")); + iconPane.add(iconLabel); + iconPane.setPreferredSize(new Dimension(50, 50)); + JPanel tipPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + UILabel tipLabel = new UILabel(tip); + tipPane.add(tipLabel); + northPane.add(iconPane, BorderLayout.WEST); + northPane.add(tipPane, BorderLayout.CENTER); + + JTextPane area = new JTextPane(); + UILabel typeLabel = new UILabel(type); + area.insertComponent(typeLabel); + if (StringUtils.isNotEmpty(type)) { + UILabel logoIconLabel = new UILabel(); + logoIconLabel.setIcon(IOUtils.readIcon("com/fr/base/images/oem/logo.png")); + area.insertComponent(logoIconLabel); + } + area.setPreferredSize(new Dimension(400, 100)); + area.setEnabled(true); + area.setEditable(false); + JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + centerPane.add(area); + + JPanel southPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + JPanel controlPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel buttonPane = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 0)); + endButton = new UIButton(endText); + endButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + endEvent(); + } + }); + buttonPane.add(endButton); + cancelButton = new UIButton(cancelText); + cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + cancelEvent(); + } + }); + buttonPane.add(cancelButton); + controlPane.add(buttonPane, BorderLayout.EAST); + southPane.add(controlPane); + + this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Error_Tittle")); + this.setResizable(false); + this.add(northPane, BorderLayout.NORTH); + this.add(centerPane, BorderLayout.CENTER); + this.add(southPane, BorderLayout.SOUTH); + this.setSize(new Dimension(600, 500)); + GUICoreUtils.centerWindow(this); + + } + + protected abstract void endEvent(); + + protected abstract void cancelEvent(); + + @Override + public void actionPerformed(ActionEvent e) { + dispose(); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java b/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java index c4e07e9676..a885c51883 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java +++ b/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java @@ -167,7 +167,7 @@ public abstract class UIDialog extends JDialog { try { checkValid(); } catch (Exception exp) { - JOptionPane.showMessageDialog(this, exp.getMessage()); + FineJOptionPane.showMessageDialog(this, exp.getMessage()); return; } diff --git a/designer-base/src/main/java/com/fr/design/editor/DoubleDeckValueEditorPane.java b/designer-base/src/main/java/com/fr/design/editor/DoubleDeckValueEditorPane.java index de8df9a718..6e6c3d8b9b 100644 --- a/designer-base/src/main/java/com/fr/design/editor/DoubleDeckValueEditorPane.java +++ b/designer-base/src/main/java/com/fr/design/editor/DoubleDeckValueEditorPane.java @@ -3,6 +3,7 @@ package com.fr.design.editor; import com.fr.base.BaseFormula; import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.editor.editor.ColumnIndexEditor; import com.fr.design.editor.editor.ColumnNameEditor; import com.fr.design.editor.editor.Editor; @@ -302,8 +303,8 @@ public class DoubleDeckValueEditorPane extends BasicPane implements UIObserver, DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager(); if (designerEnvManager.isSupportStringToFormula()) { if (!designerEnvManager.isDefaultStringToFormula()) { - int returnValue = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit_String_To_Formula") - + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.YES_NO_OPTION); + int returnValue = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit_String_To_Formula") + + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION); if (returnValue == JOptionPane.OK_OPTION) { setCurrentEditor(j); diff --git a/designer-base/src/main/java/com/fr/design/editor/ValueEditorPane.java b/designer-base/src/main/java/com/fr/design/editor/ValueEditorPane.java index 588fc1218a..503929e228 100644 --- a/designer-base/src/main/java/com/fr/design/editor/ValueEditorPane.java +++ b/designer-base/src/main/java/com/fr/design/editor/ValueEditorPane.java @@ -3,6 +3,7 @@ package com.fr.design.editor; import com.fr.base.BaseFormula; import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.editor.editor.ColumnNameEditor; import com.fr.design.editor.editor.Editor; import com.fr.design.editor.editor.FormulaEditor; @@ -283,8 +284,8 @@ public class ValueEditorPane extends BasicPane implements UIObserver, GlobalName DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager(); if (designerEnvManager.isSupportStringToFormula()) { if (!designerEnvManager.isDefaultStringToFormula()) { - int returnValue = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit_String_To_Formula") - + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.YES_NO_OPTION); + int returnValue = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit_String_To_Formula") + + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION); if (returnValue == JOptionPane.OK_OPTION) { setCurrentEditor(j); diff --git a/designer-base/src/main/java/com/fr/design/editor/editor/WidgetNameEditor.java b/designer-base/src/main/java/com/fr/design/editor/editor/WidgetNameEditor.java index 9258ce589c..80c545e922 100644 --- a/designer-base/src/main/java/com/fr/design/editor/editor/WidgetNameEditor.java +++ b/designer-base/src/main/java/com/fr/design/editor/editor/WidgetNameEditor.java @@ -1,18 +1,17 @@ package com.fr.design.editor.editor; -import java.awt.BorderLayout; -import java.awt.Component; - -import javax.swing.JList; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; - import com.fr.design.DesignModelAdapter; -import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.icombobox.FilterComboBox; +import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.stable.js.WidgetName; +import javax.swing.JList; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; +import java.awt.BorderLayout; +import java.awt.Component; + /** * the editor to edit WidgetName * @@ -43,12 +42,12 @@ public class WidgetNameEditor extends Editor { @Override public void popupMenuCanceled(PopupMenuEvent e) { - + //do nothing } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { - + //do nothing } @Override diff --git a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java index 1174a8a73b..288f6baa30 100644 --- a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java +++ b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java @@ -1,15 +1,40 @@ package com.fr.design.env; +import com.fr.common.report.ReportState; +import com.fr.concurrent.NamedThreadFactory; +import com.fr.design.EnvChangeEntrance; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.messagecollect.StartErrorMessageCollector; +import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage; +import com.fr.general.IOUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.process.ProcessEventPipe; +import com.fr.process.engine.core.CarryMessageEvent; +import com.fr.process.engine.core.FineProcessContext; +import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.connect.WorkspaceClient; +import javax.swing.*; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + /** * 根据配置生成运行环境 */ public class DesignerWorkspaceGenerator { - public static Workspace generate(DesignerWorkspaceInfo config) throws Exception { + private static final int WAIT_FREQ = 60; + private static ExecutorService service = Executors.newCachedThreadPool( + new NamedThreadFactory("DesignerWorkspaceGenerator")); + + public static Workspace generate(final DesignerWorkspaceInfo config) throws Exception { if (config == null || config.getType() == null) { return null; @@ -22,7 +47,19 @@ public class DesignerWorkspaceGenerator { break; } case Remote: { - WorkspaceClient client = WorkContext.getConnector().connect(config.getConnection()); + Future future = service.submit(new Callable() { + @Override + public WorkspaceClient call() throws Exception { + return WorkContext.getConnector().connect(config.getConnection()); + } + }); + WorkspaceClient client = null; + try { + client = future.get(WAIT_FREQ, TimeUnit.SECONDS); + } catch (TimeoutException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + RemoteHandler.handle(config); + } if (client != null) { workspace = new RemoteWorkspace(client, config.getConnection()); } @@ -31,4 +68,36 @@ public class DesignerWorkspaceGenerator { } return workspace; } + + enum RemoteHandler { + SELF; + public static void handle(DesignerWorkspaceInfo config) { + ProcessEventPipe eventPipe = FineProcessContext.getParentPipe(); + if (eventPipe != null) { + eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue())); + } + StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.REMOTE_DESIGN_NO_RESPONSE.getId(), + DesignerErrorMessage.REMOTE_DESIGN_NO_RESPONSE.getMessage(), + StringUtils.EMPTY); + int result = FineJOptionPane.showOptionDialog(null, + Toolkit.i18nText("Fine-Design_Error_Remote_No_Response_Tip"), + Toolkit.i18nText("Fine-Design_Basic_Error_Tittle"), + JOptionPane.YES_NO_OPTION, + JOptionPane.ERROR_MESSAGE, + IOUtils.readIcon("com/fr/design/images/error/error2.png"), + new Object[] {Toolkit.i18nText("Fine-Design_Error_Remote_No_Response_Wait"), Toolkit.i18nText("Fine-Design_Error_Remote_No_Response_Switch")}, + null); + if (result == JOptionPane.YES_OPTION) { + try { + generate(config); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + } + } + + public static void stop() { + service.shutdown(); + } } 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 2e5cc9f8c0..ccc98bfe37 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 @@ -10,6 +10,9 @@ public interface DesignerWorkspaceInfo extends XMLable { String getPath(); + //获取提醒时间,用于判断是否做服务检测 + String getRemindTime(); + WorkspaceConnectionInfo getConnection(); boolean checkValid(); 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 efba8a2dfa..ef1f420d62 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 @@ -43,6 +43,11 @@ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { return path; } + @Override + public String getRemindTime() { + return null; + } + @Override public WorkspaceConnectionInfo getConnection() { return null; @@ -64,7 +69,9 @@ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { writer.attr("path", path); } + @Override + @SuppressWarnings("squid:S2975") public Object clone() throws CloneNotSupportedException { LocalDesignerWorkspaceInfo object = (LocalDesignerWorkspaceInfo)super.clone(); 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 ffc80cb089..af0b8a01c0 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 @@ -1,16 +1,20 @@ package com.fr.design.env; +import com.fr.log.FineLoggerFactory; import com.fr.security.SecurityToolbox; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; +import com.fr.workspace.WorkContext; import com.fr.workspace.connect.WorkspaceConnectionInfo; public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { private String name; + private String remindTime; + private WorkspaceConnectionInfo connection; public static RemoteDesignerWorkspaceInfo create(WorkspaceConnectionInfo connection) { @@ -43,11 +47,21 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { return connection; } + public void setRemindTime(String remindTime){ + this.remindTime = remindTime; + } + + @Override + public String getRemindTime(){ + return remindTime; + } + @Override public void readXML(XMLableReader reader) { if (reader.isAttr()) { this.name = reader.getAttrAsString("name", StringUtils.EMPTY); + this.remindTime = reader.getAttrAsString("remindTime", StringUtils.EMPTY); } if (reader.isChildNode()) { String tagName = reader.getTagName(); @@ -67,6 +81,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { public void writeXML(XMLPrintWriter writer) { writer.attr("name", name); + writer.attr("remindTime", remindTime); if (this.connection != null) { writer.startTAG("Connection"); writer.attr("url", connection.getUrl()); @@ -79,6 +94,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { } @Override + @SuppressWarnings("squid:S2975") public Object clone() throws CloneNotSupportedException { RemoteDesignerWorkspaceInfo object = (RemoteDesignerWorkspaceInfo) super.clone(); @@ -89,8 +105,14 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { @Override - public boolean checkValid(){ - - return true; + public boolean checkValid() { + boolean result = false; + try { + result = WorkContext.getConnector().testConnection(connection); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + return result; + } + return result; } } diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java index c0319f9357..3d96ea1efc 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java @@ -1,7 +1,10 @@ package com.fr.design.env; -import com.fr.cluster.engine.base.FineClusterConfig; +import com.fr.cluster.engine.remote.ClusterOperator; import com.fr.design.i18n.Toolkit; +import com.fr.base.operator.common.CommonOperator; +import com.fr.rpc.ExceptionHandler; +import com.fr.rpc.RPCInvokerExceptionInfo; import com.fr.stable.AssistUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; @@ -9,6 +12,8 @@ import com.fr.workspace.connect.WorkspaceClient; import com.fr.workspace.connect.WorkspaceConnection; import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.server.authority.decision.DecisionOperator; +import com.fr.workspace.engine.rpc.WorkspaceProxyPool; +import com.fr.workspace.pool.WorkObjectPool; /** * Created by juhaoyu on 2018/6/14. @@ -45,8 +50,12 @@ public class RemoteWorkspace implements Workspace { @Override public boolean isWarDeploy() { - - return false; + return WorkContext.getCurrent().get(CommonOperator.class, new ExceptionHandler() { + @Override + public Boolean callHandler(RPCInvokerExceptionInfo rpcInvokerExceptionInfo) { + return false; + } + }).isWarDeploy(); } @Override @@ -70,7 +79,12 @@ public class RemoteWorkspace implements Workspace { @Override public boolean isCluster() { - return FineClusterConfig.getInstance().isCluster(); + return WorkContext.getCurrent().get(ClusterOperator.class, new ExceptionHandler() { + @Override + public Boolean callHandler(RPCInvokerExceptionInfo rpcInvokerExceptionInfo) { + return false; + } + }).isCluster(); } @Override @@ -84,6 +98,19 @@ public class RemoteWorkspace implements Workspace { return client.getPool().get(type); } + + @Override + public T get(Class type, ExceptionHandler exceptionHandler){ + if(exceptionHandler != null) { + WorkObjectPool objectPool = client.getPool(); + if (objectPool instanceof WorkspaceProxyPool) { + return ((WorkspaceProxyPool) objectPool).get(type, exceptionHandler); + }else { + return client.getPool().get(type); + } + } + return client.getPool().get(type); + } @Override public void close() { @@ -102,4 +129,8 @@ public class RemoteWorkspace implements Workspace { return obj instanceof RemoteWorkspace && AssistUtils.equals(((RemoteWorkspace) obj).connection, this.connection); } + + public WorkspaceClient getClient(){ + return client; + } } diff --git a/designer-base/src/main/java/com/fr/design/event/RemoveListener.java b/designer-base/src/main/java/com/fr/design/event/RemoveListener.java new file mode 100644 index 0000000000..ff3eae3055 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/event/RemoveListener.java @@ -0,0 +1,11 @@ +package com.fr.design.event; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/19 + */ +public interface RemoveListener { + + void doRemoveAction(); +} diff --git a/designer-base/src/main/java/com/fr/design/extra/AppStoreBuilder.java b/designer-base/src/main/java/com/fr/design/extra/AppStoreBuilder.java index ba8950ec2b..5599c75535 100644 --- a/designer-base/src/main/java/com/fr/design/extra/AppStoreBuilder.java +++ b/designer-base/src/main/java/com/fr/design/extra/AppStoreBuilder.java @@ -10,10 +10,10 @@ package com.fr.design.extra; public class AppStoreBuilder { public void checkStoreJavaSciptVersion() { - + //do nothing } public void updateStoreJavaScript() { - + //do nothing } } diff --git a/designer-base/src/main/java/com/fr/design/extra/LoginDialog.java b/designer-base/src/main/java/com/fr/design/extra/LoginDialog.java index 33983baf21..42791ad522 100644 --- a/designer-base/src/main/java/com/fr/design/extra/LoginDialog.java +++ b/designer-base/src/main/java/com/fr/design/extra/LoginDialog.java @@ -4,12 +4,8 @@ import com.fr.design.dialog.UIDialog; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.StableUtils; -import javax.swing.JPanel; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dialog; -import java.awt.Dimension; -import java.awt.Frame; +import javax.swing.*; +import java.awt.*; /** * Created by vito on 2017/5/5. @@ -41,5 +37,6 @@ public class LoginDialog extends UIDialog { @Override public void checkValid() throws Exception { + // do nothing } } diff --git a/designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java b/designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java index 50add423f4..471e25109a 100644 --- a/designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java +++ b/designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java @@ -14,10 +14,8 @@ import javafx.concurrent.Task; import javafx.scene.web.WebEngine; import netscape.javascript.JSObject; -import javax.swing.JDialog; -import javax.swing.SwingUtilities; -import java.awt.Color; -import java.awt.Desktop; +import javax.swing.*; +import java.awt.*; import java.net.URI; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -221,5 +219,6 @@ public class LoginWebBridge { } public void openUrlAtLocalWebBrowser(WebEngine eng, String url) { + // do nothing } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/extra/LoginWebPane.java b/designer-base/src/main/java/com/fr/design/extra/LoginWebPane.java index a6b60b605e..d0a155a582 100644 --- a/designer-base/src/main/java/com/fr/design/extra/LoginWebPane.java +++ b/designer-base/src/main/java/com/fr/design/extra/LoginWebPane.java @@ -1,5 +1,6 @@ package com.fr.design.extra; +import com.fr.design.dialog.FineJOptionPane; import javafx.application.Platform; import javafx.embed.swing.JFXPanel; import javafx.event.EventHandler; @@ -46,7 +47,7 @@ public class LoginWebPane extends JFXPanel { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - JOptionPane.showMessageDialog(LoginWebPane.this, message); + FineJOptionPane.showMessageDialog(LoginWebPane.this, message); } }); } diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginAbstractLoadingViewPane.java b/designer-base/src/main/java/com/fr/design/extra/PluginAbstractLoadingViewPane.java index 0eb1144665..3f06ffb9cf 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginAbstractLoadingViewPane.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginAbstractLoadingViewPane.java @@ -4,7 +4,6 @@ import com.fr.base.BaseUtils; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.ilable.UILabel; - import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; @@ -88,7 +87,7 @@ public abstract class PluginAbstractLoadingViewPane extends PluginAbstract @Override public void pressInstallButton() { - + // do nothing } @Override diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginControlPane.java b/designer-base/src/main/java/com/fr/design/extra/PluginControlPane.java index e5b4feba28..312d833471 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginControlPane.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginControlPane.java @@ -7,7 +7,6 @@ import com.fr.design.gui.ilist.UIList; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.IOUtils; - import com.fr.plugin.context.PluginMarker; import com.fr.plugin.license.Licensed; import com.fr.plugin.manage.PluginManager; @@ -23,7 +22,7 @@ import javax.swing.event.DocumentListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.*; -import java.util.*; +import java.util.ArrayList; import java.util.List; /** @@ -155,7 +154,7 @@ public class PluginControlPane extends BasicPane { PluginManager.getController().uninstall(PluginMarker.create(id, version), true, new PluginTaskCallback() { @Override public void done(PluginTaskResult result) { - + // do nothing } }); } diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginFromStorePane.java b/designer-base/src/main/java/com/fr/design/extra/PluginFromStorePane.java index 115cc87dc1..5f76dbafca 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginFromStorePane.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginFromStorePane.java @@ -1,6 +1,7 @@ package com.fr.design.extra; import com.fr.config.MarketConfig; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.tradition.callback.UpdateOnlineCallback; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.ilable.UILabel; @@ -13,11 +14,7 @@ import com.fr.plugin.manage.control.ProgressCallback; import com.fr.plugin.view.PluginView; import com.fr.stable.StringUtils; -import javax.swing.JComponent; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.SwingConstants; +import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.File; import java.util.List; @@ -98,7 +95,7 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane config; private WebEngine webEngine; @@ -94,10 +94,10 @@ public class PluginWebBridge { * @return 配置信息 */ public String getRunConfig() { - if (action != null) { + if (actions != null) { JSONObject jsonObject = new JSONObject(); try { - jsonObject.put(ACTION, action.getContext()); + jsonObject.put(ACTION, actions.getContext()); Set keySet = config.keySet(); for (String key : keySet) { jsonObject.put(key, config.get(key).toString()); @@ -117,7 +117,7 @@ public class PluginWebBridge { * @param config 参数 */ public void setRunConfig(ACTIONS action, Map config) { - this.action = action; + this.actions = action; this.config = config; } @@ -125,7 +125,7 @@ public class PluginWebBridge { * 清楚打开动作 */ public void clearRunConfig() { - this.action = null; + this.actions = null; this.config = null; } diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginWebPane.java b/designer-base/src/main/java/com/fr/design/extra/PluginWebPane.java index 627d16855e..002ac88bf1 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginWebPane.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginWebPane.java @@ -1,6 +1,7 @@ package com.fr.design.extra; import com.fr.base.TemplateUtils; +import com.fr.design.dialog.FineJOptionPane; import com.fr.general.GeneralContext; import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; @@ -104,7 +105,7 @@ public class PluginWebPane extends JFXPanel { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - JOptionPane.showMessageDialog(PluginWebPane.this, message); + FineJOptionPane.showMessageDialog(PluginWebPane.this, message); } }); } diff --git a/designer-base/src/main/java/com/fr/design/extra/QQLoginDialog.java b/designer-base/src/main/java/com/fr/design/extra/QQLoginDialog.java index 4773aff689..3ba60054f2 100644 --- a/designer-base/src/main/java/com/fr/design/extra/QQLoginDialog.java +++ b/designer-base/src/main/java/com/fr/design/extra/QQLoginDialog.java @@ -3,7 +3,6 @@ package com.fr.design.extra; import com.fr.design.dialog.UIDialog; import com.fr.design.utils.gui.GUICoreUtils; - import javax.swing.*; import java.awt.*; @@ -27,6 +26,7 @@ public class QQLoginDialog extends UIDialog { @Override public void checkValid() throws Exception { + // do nothing } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/extra/QQLoginWebPane.java b/designer-base/src/main/java/com/fr/design/extra/QQLoginWebPane.java index 9928d9ae0e..9c56738b49 100644 --- a/designer-base/src/main/java/com/fr/design/extra/QQLoginWebPane.java +++ b/designer-base/src/main/java/com/fr/design/extra/QQLoginWebPane.java @@ -1,5 +1,6 @@ package com.fr.design.extra; +import com.fr.design.dialog.FineJOptionPane; import com.fr.general.CloudCenter; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; @@ -138,7 +139,7 @@ public class QQLoginWebPane extends JFXPanel { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - JOptionPane.showMessageDialog(QQLoginWebPane.this, message); + FineJOptionPane.showMessageDialog(QQLoginWebPane.this, message); } }); } diff --git a/designer-base/src/main/java/com/fr/design/extra/ShopDialog.java b/designer-base/src/main/java/com/fr/design/extra/ShopDialog.java index e2fb97b627..72fa6149b6 100644 --- a/designer-base/src/main/java/com/fr/design/extra/ShopDialog.java +++ b/designer-base/src/main/java/com/fr/design/extra/ShopDialog.java @@ -29,5 +29,6 @@ public class ShopDialog extends UIDialog { @Override public void checkValid() throws Exception { + // do nothing } } diff --git a/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java b/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java index bbb10c6d65..3abcfc0a4f 100644 --- a/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java +++ b/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java @@ -2,6 +2,7 @@ package com.fr.design.extra; import com.fr.base.FRContext; import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.UIDialog; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.mainframe.DesignerContext; @@ -62,7 +63,7 @@ public class WebViewDlgHelper { String mainJsPath = StableUtils.pathJoin(installHome, MAIN_JS_PATH); File file = new File(mainJsPath); if (!file.exists()) { - int rv = JOptionPane.showConfirmDialog( + int rv = FineJOptionPane.showConfirmDialog( null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Need_Install"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), @@ -79,7 +80,7 @@ public class WebViewDlgHelper { updateShopScripts(SHOP_SCRIPTS); showPluginDlg(); } else { - int rv = JOptionPane.showConfirmDialog( + int rv = FineJOptionPane.showConfirmDialog( null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Need_Install_Version"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), @@ -199,7 +200,7 @@ public class WebViewDlgHelper { private static void confirmDownLoadShopJS() { - int rv = JOptionPane.showConfirmDialog( + int rv = FineJOptionPane.showConfirmDialog( null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Need_Install"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), @@ -277,7 +278,7 @@ public class WebViewDlgHelper { CommonUtils.deleteFile(scriptZip); } PluginStoreConstants.refreshProps(); // 下载完刷新一下版本号等 - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Installed"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Installed"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE); } } catch (InterruptedException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); @@ -300,7 +301,7 @@ public class WebViewDlgHelper { JSONObject resultJSONObject = new JSONObject(text); String isLatest = resultJSONObject.optString("result"); if (!ComparatorUtils.equals(isLatest, LATEST)) { - int rv = JOptionPane.showConfirmDialog( + int rv = FineJOptionPane.showConfirmDialog( null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Need_Update"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java index 4cbd063284..19bd89ef10 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java @@ -1,6 +1,7 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginOperateUtils; import com.fr.design.extra.PluginUtils; @@ -41,7 +42,7 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { String switchedInfo = PluginOperateUtils.getSwitchedInfo(result); jsCallback.execute("success"); FineLoggerFactory.getLogger().info(pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo); - JOptionPane.showMessageDialog(null, pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo); + FineJOptionPane.showMessageDialog(null, pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo); } else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) { int rv = JOptionPane.showOptionDialog( null, @@ -50,7 +51,7 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, - null, + FineJOptionPane.OPTION_YES_NO_CANCEL, null ); if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { @@ -70,7 +71,7 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, - null, + FineJOptionPane.OPTION_YES_NO_CANCEL, null ); if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { @@ -80,7 +81,7 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { }else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); - JOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed"), JOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java index 6e72c0478d..f597180e87 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java @@ -1,6 +1,7 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginOperateUtils; import com.fr.log.FineLoggerFactory; @@ -38,7 +39,7 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { String switchedInfo = PluginOperateUtils.getSwitchedInfo(result); jsCallback.execute("success"); FineLoggerFactory.getLogger().info(pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo); - JOptionPane.showMessageDialog(null, pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo); + FineJOptionPane.showMessageDialog(null, pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo); } else if(result.errorCode() == PluginErrorCode.HasLowerPluginWhenInstall){ int rv = JOptionPane.showOptionDialog( null, @@ -47,7 +48,7 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, - null, + FineJOptionPane.OPTION_YES_NO_CANCEL, null ); if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { @@ -58,7 +59,7 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { }else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); - JOptionPane.showMessageDialog(null, pluginInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, pluginInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java index b7b817ef4c..c48a47faeb 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java @@ -1,6 +1,7 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginUtils; import com.fr.plugin.manage.control.PluginTaskCallback; @@ -24,9 +25,9 @@ public class ModifyStatusCallback implements PluginTaskCallback{ if (result.isSuccess()) { jsCallback.execute("success"); String modifyMessage = isActive ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Disabled_Duplicate") : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Plugin_Has_Been_Actived_Duplicate"); - JOptionPane.showMessageDialog(null, modifyMessage); + FineJOptionPane.showMessageDialog(null, modifyMessage); } else { - JOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java index db8a69188a..b3773ef6f9 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java @@ -1,6 +1,7 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginUtils; import com.fr.log.FineLoggerFactory; @@ -27,7 +28,7 @@ public class UninstallPluginCallback extends AbstractPluginTaskCallback { if (result.isSuccess()) { jsCallback.execute("success"); FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Success")); - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Success")); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Success")); }else if (result.errorCode() == PluginErrorCode.NeedUninstallDependingPluginFirst) { int rv = JOptionPane.showOptionDialog( null, @@ -36,7 +37,7 @@ public class UninstallPluginCallback extends AbstractPluginTaskCallback { JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, - null, + FineJOptionPane.OPTION_YES_NO_CANCEL, null ); if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { @@ -46,7 +47,7 @@ public class UninstallPluginCallback extends AbstractPluginTaskCallback { } else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Failed")); - JOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java index 392d8074e9..7cced40f0b 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java @@ -1,6 +1,7 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginOperateUtils; import com.fr.design.extra.PluginUtils; @@ -39,7 +40,7 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { if (result.isSuccess()) { jsCallback.execute("success"); FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success")); - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success")); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success")); } else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) { int rv = JOptionPane.showOptionDialog( null, @@ -48,7 +49,7 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, - null, + FineJOptionPane.OPTION_YES_NO_CANCEL, null ); if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { @@ -68,7 +69,7 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, - null, + FineJOptionPane.OPTION_YES_NO_CANCEL, null ); if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { @@ -78,7 +79,7 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { }else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed")); - JOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java index 28f4f6a31f..69998a3169 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java @@ -1,6 +1,7 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginOperateUtils; import com.fr.log.FineLoggerFactory; @@ -33,11 +34,11 @@ public class UpdateOnlineCallback extends AbstractDealPreTaskCallback { if (result.isSuccess()) { jsCallback.execute("success"); FineLoggerFactory.getLogger().info(pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success")); - JOptionPane.showMessageDialog(null,pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success")); + FineJOptionPane.showMessageDialog(null,pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Success")); } else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed")); - JOptionPane.showMessageDialog(null, pluginInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, pluginInfo, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/tradition/callback/UpdateOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/tradition/callback/UpdateOnlineCallback.java index 468e923166..97a2ae0063 100644 --- a/designer-base/src/main/java/com/fr/design/extra/tradition/callback/UpdateOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/tradition/callback/UpdateOnlineCallback.java @@ -1,5 +1,6 @@ package com.fr.design.extra.tradition.callback; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginStatusCheckCompletePane; import com.fr.design.extra.PluginUtils; @@ -32,7 +33,7 @@ public class UpdateOnlineCallback implements ProgressCallback { public void done(PluginTaskResult result){ if (result.isSuccess()) { FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("FR-Designer-Plugin_Update_Success")); - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Successful")); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Successful")); } else if (result.errorCode() == PluginErrorCode.OperationNotSupport) { int rv = JOptionPane.showOptionDialog( null, @@ -41,7 +42,7 @@ public class UpdateOnlineCallback implements ProgressCallback { JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, - null, + FineJOptionPane.OPTION_YES_NO_CANCEL, null ); if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { @@ -50,7 +51,7 @@ public class UpdateOnlineCallback implements ProgressCallback { PluginManager.getController().update(pluginMarker, toPluginMarker, new UpdateOnlineCallback(pluginMarker, toPluginMarker, pane)); } else { FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("FR-Designer-Plugin_Delete_Failed")); - JOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(null, PluginUtils.getMessageByErrorCode(result.errorCode()), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java index 8e75fae0bc..f8b089fe6a 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java @@ -178,15 +178,28 @@ public class HistoryTemplateListCache implements CallbackEvent { * @return 位置 */ public int contains(JTemplate jt) { + return contains(jt, null); + } + + public int contains(FILE file) { + return contains(null, file); + } + + private int contains(JTemplate jt, FILE file) { + FILE item = null; + if (jt != null) { + item = jt.getEditingFILE(); + } else { + item = file; + } for (int i = 0; i < historyList.size(); i++) { - if (ComparatorUtils.equals(historyList.get(i).getEditingFILE(), jt.getEditingFILE())) { + if (ComparatorUtils.equals(historyList.get(i).getEditingFILE(), item)) { return i; } } return -1; } - /** * 判断是否打开过该模板 * 由于切换环境不会关闭模板,可能存在同名的模板,所以该方法不能准确找到所选的模板, @@ -386,4 +399,16 @@ public class HistoryTemplateListCache implements CallbackEvent { } FineLoggerFactory.getLogger().info("Env Change Template Loaded."); } + + /** + * 重新载入当前模板,刷新数据/对象 + */ + public void reloadCurrentTemplate() { + JTemplate jt = getCurrentEditingTemplate(); + boolean access = jt != null && jt.getEditingFILE() != null && jt.getEditingFILE().exists(); + if (access) { + jt.refreshResource(); + } + } + } diff --git a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java index 5a722239c6..e4ab990337 100644 --- a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java @@ -5,6 +5,7 @@ import com.fr.base.BaseUtils; import com.fr.base.GraphHelper; import com.fr.base.vcs.DesignerMode; import com.fr.design.constants.UIConstants; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIScrollPopUpMenu; import com.fr.design.i18n.Toolkit; @@ -21,26 +22,9 @@ import com.fr.third.javax.annotation.Nonnull; import com.fr.workspace.WorkContext; import com.fr.workspace.server.lock.TplOperator; -import javax.swing.BorderFactory; -import javax.swing.ButtonModel; -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JSeparator; +import javax.swing.*; import javax.swing.plaf.basic.BasicMenuItemUI; -import java.awt.AWTEvent; -import java.awt.AlphaComposite; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.GradientPaint; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.RenderingHints; +import java.awt.*; import java.awt.event.AWTEventListener; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -257,7 +241,7 @@ public class MutilTempalteTabPane extends JComponent { private String tempalteShowName(JTemplate template) { - String name = template.getEditingFILE().getName(); + String name = template.getTemplateName(); if (!template.isSaved() && !name.endsWith(" *")) { name += " *"; } @@ -398,8 +382,8 @@ public class MutilTempalteTabPane extends JComponent { //画下面的那条线 if (templateStartX < maxWidth) { GeneralPath generalPath = new GeneralPath(Path2D.WIND_EVEN_ODD, 2); - generalPath.moveTo((float) templateStartX, getHeight() - 1.0F); - generalPath.lineTo((float) maxWidth, getHeight() - 1.0F); + generalPath.moveTo((float) templateStartX, (float) (getHeight() - 1.0D)); + generalPath.lineTo((float) maxWidth, (float) (getHeight() - 1.0D)); g2d.fill(generalPath); //TODO hzzz delete // g2d.setPaint(UIConstants.LINE_COLOR); @@ -409,7 +393,7 @@ public class MutilTempalteTabPane extends JComponent { private void paintDefaultBackground(Graphics2D g2d) { //画默认背景 - g2d.setPaint(new GradientPaint(1, 1, UIConstants.TEMPLATE_TAB_PANE_BACKGROUND, 1, getHeight() - 1.0F, UIConstants.TEMPLATE_TAB_PANE_BACKGROUND)); + g2d.setPaint(new GradientPaint(1, 1, UIConstants.TEMPLATE_TAB_PANE_BACKGROUND, 1, (float) (getHeight() - 1.0D), UIConstants.TEMPLATE_TAB_PANE_BACKGROUND)); g2d.fillRect(0, 0, getWidth(), getHeight()); } @@ -535,7 +519,7 @@ public class MutilTempalteTabPane extends JComponent { double[] x = {templateStartX, templateStartX, templateStartX + realWidth, templateStartX + realWidth, templateStartX}; double[] y = {1, getHeight() + 1, getHeight() + 1, 1, 1}; RoundRectangle2D.Double rect1 = new RoundRectangle2D.Double(templateStartX, 1, this.getWidth(), this.getHeight(), 7, 7); - g2d.setPaint(new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, getHeight() - 1.0F, UIConstants.SELECT_TAB)); + g2d.setPaint(new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, (float) (getHeight() - 1.0D), UIConstants.SELECT_TAB)); //选了30度和60度的特殊角度的x,y作为经过的两个点的坐标 double specialLocation1 = 2.5; double specialLocation2 = 4.330127; @@ -590,9 +574,9 @@ public class MutilTempalteTabPane extends JComponent { double[] x = {templateStartX, templateStartX, templateStartX + realWidth, templateStartX + realWidth, templateStartX}; double[] y = {-1, getHeight() - 1, getHeight() - 1, -1, -1}; if (selfIndex == mouseOveredIndex) { - g2d.setPaint(new GradientPaint(1, 1, UIConstants.HOVER_BLUE, 1, getHeight() - 1.0F, UIConstants.HOVER_BLUE)); + g2d.setPaint(new GradientPaint(1, 1, UIConstants.HOVER_BLUE, 1, (float) (getHeight() - 1.0D), UIConstants.HOVER_BLUE)); } else { - g2d.setPaint(new GradientPaint(1, 1, UIConstants.SHADOW_GREY, 1, getHeight() - 1.0F, UIConstants.SHADOW_GREY)); + g2d.setPaint(new GradientPaint(1, 1, UIConstants.SHADOW_GREY, 1, (float) (getHeight() - 1.0D), UIConstants.SHADOW_GREY)); } @@ -678,8 +662,8 @@ public class MutilTempalteTabPane extends JComponent { if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) { specifiedTemplate.stopEditing(); - int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", - ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); + int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", + Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (returnVal == JOptionPane.YES_OPTION) { specifiedTemplate.saveTemplate(); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); @@ -854,7 +838,7 @@ public class MutilTempalteTabPane extends JComponent { */ @Override public void mouseEntered(MouseEvent e) { - + // do nothing } /** @@ -877,6 +861,7 @@ public class MutilTempalteTabPane extends JComponent { */ @Override public void mouseReleased(MouseEvent e) { + // do nothing } /** @@ -886,6 +871,7 @@ public class MutilTempalteTabPane extends JComponent { */ @Override public void mouseClicked(MouseEvent e) { + // do nothing } /** @@ -931,7 +917,7 @@ public class MutilTempalteTabPane extends JComponent { //如果在权限编辑情况下,不允许切换到表单类型的工作簿 if (DesignerMode.isAuthorityEditing() && !openedTemplate.get(selectedIndex).isJWorkBook()) { DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(tempSelectedIndex)); - JOptionPane.showMessageDialog(MutilTempalteTabPane.this, Toolkit.i18nText("Fine-Design_Basic_Form_Authority_Edited_Cannot_Be_Supported") + FineJOptionPane.showMessageDialog(MutilTempalteTabPane.this, Toolkit.i18nText("Fine-Design_Basic_Form_Authority_Edited_Cannot_Be_Supported") + "!", Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); MutilTempalteTabPane.this.repaint(); return; @@ -957,6 +943,7 @@ public class MutilTempalteTabPane extends JComponent { */ @Override public void mouseDragged(MouseEvent e) { + // do nothing } /** diff --git a/designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java b/designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java index a1082b62f9..c3b8d3e4d5 100644 --- a/designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java +++ b/designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java @@ -135,7 +135,7 @@ public class NodeAuthProcessor { * @param fileNode file nodes * @return 带权限信息的文件节点 */ - public boolean fixFileNodeAuth(FileNode fileNode) { + public boolean checkFileNodeAuth(FileNode fileNode) { boolean isLocal = WorkContext.getCurrent().isLocal(); boolean isRoot = WorkContext.getCurrent().isRoot(); diff --git a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java index 295b63385b..f271f23c0e 100644 --- a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java @@ -1 +1 @@ -package com.fr.design.file; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilist.UIList; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.ProductConstants; import javax.swing.*; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; /** * Author : daisy * Date: 13-8-9 * Time: 下午3:41 */ public class SaveSomeTemplatePane extends BasicPane { private UICheckBox[] templateCheckBoxes = null; private BasicDialog dialog; private JPanel templatesChoosePane; private UIScrollPane scrollPane; private java.util.List> unSavedTemplate = new ArrayList>(); private boolean isAllSaved = false; //该变量用来判断是在关闭其他模板或是关闭设计器的时候,是否需要判断当前模板有没有保存 private boolean isJudgeCurrentEditingTemplate = true; public SaveSomeTemplatePane(boolean isNeedTojudgeCurrent) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); if (this.dialog == null) { this.dialog = this.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override public void doOk() { for (int i = 0; i < templateCheckBoxes.length; i++) { if (templateCheckBoxes[i].isSelected()) { saveSelectedTemplate(unSavedTemplate.get(i)); } } isAllSaved = true; } public void doCancel() { isAllSaved = false; } }); } UILabel tip = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_The_Source_To_Save")); this.add(tip, BorderLayout.NORTH); templatesChoosePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); UIScrollPane scrollPane = new UIScrollPane(templatesChoosePane); this.add(scrollPane, BorderLayout.CENTER); this.isJudgeCurrentEditingTemplate = isNeedTojudgeCurrent; } private void initTemplatesChoosePane() { templatesChoosePane.setBorder(BorderFactory.createTitledBorder("")); for (int i = 0; i < unSavedTemplate.size(); i++) { templateCheckBoxes[i] = new UICheckBox(unSavedTemplate.get(i).getEditingFILE().getName()); templateCheckBoxes[i].setSelected(true); } final UIList templatesList = new UIList(templateCheckBoxes); templatesList.setModel(new UnSeletedTemplateListDataMode()); templatesList.setCellRenderer(new UnSelectedListCellRender()); templatesList.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { super.mousePressed(e); int index = templatesList.getSelectedIndex(); if (index < 0) { return; } UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(index); checkBox.setSelected(!checkBox.isSelected()); templatesList.repaint(); } }); final UICheckBox filenameCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_All")); filenameCheckBox.setSelected(true); filenameCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean isSelected = filenameCheckBox.isSelected(); for (int i = 0; i < templatesList.getModel().getSize(); i++) { UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(i); checkBox.setSelected(isSelected); } templatesList.repaint(); } }); templatesChoosePane.add(filenameCheckBox, BorderLayout.NORTH); templatesChoosePane.add(templatesList, BorderLayout.CENTER); } public boolean showSavePane() { populate(); //如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目 if (!unSavedTemplate.isEmpty()) { dialog.setVisible(true); } else { isAllSaved = true; } return isAllSaved; } public void populate() { java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); for (int i = 0; i < opendedTemplate.size(); i++) { if (isneedToAdd(opendedTemplate.get(i), currentTemplate)) { unSavedTemplate.add(opendedTemplate.get(i)); } } templateCheckBoxes = new UICheckBox[unSavedTemplate.size()]; initTemplatesChoosePane(); } private boolean isneedToAdd(JTemplate template, JTemplate currentTemplate) { //所有模板都判断是不是保存 if (isJudgeCurrentEditingTemplate) { return !template.isALLSaved(); } //当前编辑的模板不判断是否已经保存 if (ComparatorUtils.equals(template, currentTemplate)) { return false; } else { return !template.isALLSaved(); } } private void saveSelectedTemplate(JTemplate specifiedTemplate) { if (!specifiedTemplate.isSaved()) { specifiedTemplate.stopEditing(); specifiedTemplate.saveTemplate(); } FineLoggerFactory.getLogger().info( com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); } public int saveLastOneTemplate() { JTemplate specifiedTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (!specifiedTemplate.isALLSaved()) { specifiedTemplate.stopEditing(); int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (returnVal == JOptionPane.YES_OPTION && specifiedTemplate.saveTemplate()) { specifiedTemplate.saveTemplate(); FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); } return returnVal; } return JOptionPane.YES_OPTION; } protected String title4PopupWindow() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save"); } private class UnSelectedListCellRender extends DefaultListCellRenderer { @Override public Component getListCellRendererComponent(JList list, Object value, int index, final boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); templateCheckBoxes[index] = (UICheckBox) value; templateCheckBoxes[index].setBackground(list.getBackground()); return templateCheckBoxes[index]; } } private class UnSeletedTemplateListDataMode extends AbstractListModel { @Override public int getSize() { return templateCheckBoxes.length; } @Override public UICheckBox getElementAt(int index) { if (index > getSize() - 1 || index < 0) { return null; } return templateCheckBoxes[index]; } } } \ No newline at end of file +package com.fr.design.file; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilist.UIList; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.ProductConstants; import javax.swing.*; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; /** * Author : daisy * Date: 13-8-9 * Time: 下午3:41 */ public class SaveSomeTemplatePane extends BasicPane { private UICheckBox[] templateCheckBoxes = null; private BasicDialog dialog; private JPanel templatesChoosePane; private UIScrollPane scrollPane; private java.util.List> unSavedTemplate = new ArrayList>(); private boolean isAllSaved = false; //该变量用来判断是在关闭其他模板或是关闭设计器的时候,是否需要判断当前模板有没有保存 private boolean isJudgeCurrentEditingTemplate = true; public SaveSomeTemplatePane(boolean isNeedTojudgeCurrent) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); if (this.dialog == null) { this.dialog = this.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override public void doOk() { for (int i = 0; i < templateCheckBoxes.length; i++) { if (templateCheckBoxes[i].isSelected()) { saveSelectedTemplate(unSavedTemplate.get(i)); } } isAllSaved = true; } public void doCancel() { isAllSaved = false; } }); } UILabel tip = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_The_Source_To_Save")); this.add(tip, BorderLayout.NORTH); templatesChoosePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); UIScrollPane scrollPane = new UIScrollPane(templatesChoosePane); this.add(scrollPane, BorderLayout.CENTER); this.isJudgeCurrentEditingTemplate = isNeedTojudgeCurrent; } private void initTemplatesChoosePane() { templatesChoosePane.setBorder(BorderFactory.createTitledBorder("")); for (int i = 0; i < unSavedTemplate.size(); i++) { templateCheckBoxes[i] = new UICheckBox(unSavedTemplate.get(i).getEditingFILE().getName()); templateCheckBoxes[i].setSelected(true); } final UIList templatesList = new UIList(templateCheckBoxes); templatesList.setModel(new UnSeletedTemplateListDataMode()); templatesList.setCellRenderer(new UnSelectedListCellRender()); templatesList.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { super.mousePressed(e); int index = templatesList.getSelectedIndex(); if (index < 0) { return; } UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(index); checkBox.setSelected(!checkBox.isSelected()); templatesList.repaint(); } }); final UICheckBox filenameCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_All")); filenameCheckBox.setSelected(true); filenameCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean isSelected = filenameCheckBox.isSelected(); for (int i = 0; i < templatesList.getModel().getSize(); i++) { UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(i); checkBox.setSelected(isSelected); } templatesList.repaint(); } }); templatesChoosePane.add(filenameCheckBox, BorderLayout.NORTH); templatesChoosePane.add(templatesList, BorderLayout.CENTER); } public boolean showSavePane() { populate(); //如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目 if (!unSavedTemplate.isEmpty()) { dialog.setVisible(true); } else { isAllSaved = true; } return isAllSaved; } public void populate() { java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); for (int i = 0; i < opendedTemplate.size(); i++) { if (isneedToAdd(opendedTemplate.get(i), currentTemplate)) { unSavedTemplate.add(opendedTemplate.get(i)); } } templateCheckBoxes = new UICheckBox[unSavedTemplate.size()]; initTemplatesChoosePane(); } private boolean isneedToAdd(JTemplate template, JTemplate currentTemplate) { //所有模板都判断是不是保存 if (isJudgeCurrentEditingTemplate) { return !template.isALLSaved(); } //当前编辑的模板不判断是否已经保存 if (ComparatorUtils.equals(template, currentTemplate)) { return false; } else { return !template.isALLSaved(); } } private void saveSelectedTemplate(JTemplate specifiedTemplate) { if (!specifiedTemplate.isSaved()) { specifiedTemplate.stopEditing(); specifiedTemplate.saveTemplate(); } FineLoggerFactory.getLogger().info( com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); } public int saveLastOneTemplate() { JTemplate specifiedTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (!specifiedTemplate.isALLSaved()) { specifiedTemplate.stopEditing(); int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (returnVal == JOptionPane.YES_OPTION && specifiedTemplate.saveTemplate()) { specifiedTemplate.saveTemplate(); FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); } return returnVal; } return JOptionPane.YES_OPTION; } protected String title4PopupWindow() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save"); } private class UnSelectedListCellRender extends DefaultListCellRenderer { @Override public Component getListCellRendererComponent(JList list, Object value, int index, final boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); templateCheckBoxes[index] = (UICheckBox) value; templateCheckBoxes[index].setBackground(list.getBackground()); return templateCheckBoxes[index]; } } private class UnSeletedTemplateListDataMode extends AbstractListModel { @Override public int getSize() { return templateCheckBoxes.length; } @Override public UICheckBox getElementAt(int index) { if (index > getSize() - 1 || index < 0) { return null; } return templateCheckBoxes[index]; } } } \ No newline at end of file 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 1708c07533..93001bde44 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 @@ -4,6 +4,7 @@ package com.fr.design.file; import com.fr.base.FRContext; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; @@ -254,16 +255,16 @@ public class TemplateTreePane extends JPanel implements FileOperations { ? Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Folder") : Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_File"); - if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), + if (FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), tipContent, - UIManager.getString("OptionPane.messageDialogTitle"), + Toolkit.i18nText("Fine-Design_Basic_Confirm"), YES_NO_OPTION) == JOptionPane.YES_OPTION) { // 删除所有选中的即可 if (!deleteNodes(Arrays.asList(treeNodes))) { - JOptionPane.showConfirmDialog(null, + FineJOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Basic_Delete_Failure"), - UIManager.getString("OptionPane.messageDialogTitle"), + Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } @@ -277,24 +278,24 @@ public class TemplateTreePane extends JPanel implements FileOperations { if (deletableNodes.isEmpty()) { // 提醒被锁定模板无法删除 - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Unable_Delete_Locked_File"), - Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + Toolkit.i18nText("Fine-Design_Basic_Alert"), WARNING_MESSAGE); return; } - if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), + if (FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), tipContent, - UIManager.getString("OptionPane.messageDialogTitle"), + Toolkit.i18nText("Fine-Design_Basic_Confirm"), YES_NO_OPTION) == JOptionPane.YES_OPTION) { // 删除其他 if (!deleteNodes(deletableNodes)) { - JOptionPane.showConfirmDialog(null, + FineJOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Basic_Delete_Failure"), - UIManager.getString("OptionPane.messageDialogTitle"), + Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } @@ -415,9 +416,9 @@ public class TemplateTreePane extends JPanel implements FileOperations { } if (!lockedNodes.isEmpty()) { - JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), + FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Warn_Rename_Lock_File"), - UIManager.getString("OptionPane.messageDialogTitle"), + Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE); return true; } 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 a8c8c34779..32e7030bb6 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 @@ -8,6 +8,7 @@ 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.FineJOptionPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; @@ -28,17 +29,7 @@ import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.script.Expression; -import javax.swing.BorderFactory; -import javax.swing.DefaultListCellRenderer; -import javax.swing.DefaultListModel; -import javax.swing.Icon; -import javax.swing.JComponent; -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.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.event.TreeSelectionEvent; @@ -48,10 +39,7 @@ import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.MutableTreeNode; import javax.swing.tree.TreePath; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; @@ -149,10 +137,12 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { keyWordTextField.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { + //do nothing } @Override public void keyReleased(KeyEvent e) { + //do nothing } @Override @@ -237,7 +227,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { protected void extendCheckBoxPane(JPanel checkBoxPane) { - + // do nothing } private void configFormulaArea() { @@ -413,6 +403,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { @Override public void keyTyped(KeyEvent e) { + // do nothing } protected void search(String keyWord, boolean findDescription) { @@ -583,14 +574,15 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { // alex:继续往下面走,expression为null时告知不合法公式 } - JOptionPane.showMessageDialog( + 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")) + ".", ProductConstants.PRODUCT_NAME, + (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_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE); } } diff --git a/designer-base/src/main/java/com/fr/design/formula/FunctionManagerPane.java b/designer-base/src/main/java/com/fr/design/formula/FunctionManagerPane.java index 3d56dd925e..c40a917e39 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FunctionManagerPane.java +++ b/designer-base/src/main/java/com/fr/design/formula/FunctionManagerPane.java @@ -142,8 +142,10 @@ public class FunctionManagerPane extends BasicPane { editorButton.setPreferredSize(new Dimension(editorButton.getPreferredSize().width, classNameTextField.getPreferredSize().height)); reportletNamePane.add(editorButton); editorButton.addActionListener(createEditorButtonActionListener()); - northPane.add(GUICoreUtils.createFlowPane(new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Class_Name") + ":"), - reportletNamePane}, FlowLayout.LEFT)); + JPanel classNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + classNamePane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Class_Name") + ":"), BorderLayout.NORTH); + classNamePane.add(reportletNamePane, BorderLayout.CENTER); + northPane.add(classNamePane); DescriptionTextArea descriptionArea = new DescriptionTextArea(); descriptionArea.setWrapStyleWord(true); descriptionArea.setLineWrap(true); diff --git a/designer-base/src/main/java/com/fr/design/formula/JavaEditorPane.java b/designer-base/src/main/java/com/fr/design/formula/JavaEditorPane.java index a3bdbae216..9b5a95a431 100644 --- a/designer-base/src/main/java/com/fr/design/formula/JavaEditorPane.java +++ b/designer-base/src/main/java/com/fr/design/formula/JavaEditorPane.java @@ -2,6 +2,7 @@ package com.fr.design.formula; import com.fr.base.FRContext; import com.fr.design.dialog.BasicPane; +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.ilable.UILabel; @@ -161,11 +162,11 @@ public class JavaEditorPane extends BasicPane { } try { WorkContext.getWorkResource().write(StableUtils.pathJoin(ProjectConstants.CLASSES_NAME, getJavaPath()), text.getBytes(EncodeConstants.ENCODING_UTF_8)); - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Common_Save_Successfully") + "!"); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Common_Save_Successfully") + "!"); fireSaveActionListener(); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Common_Save_Failed") + "!"); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Common_Save_Failed") + "!"); } } @@ -191,7 +192,7 @@ public class JavaEditorPane extends BasicPane { if (StringUtils.isEmpty(message)) { message = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Compile_Success") + "!"; } - JOptionPane.showMessageDialog(null, message); + FineJOptionPane.showMessageDialog(null, message); } catch (InterruptedException e1) { FineLoggerFactory.getLogger().error(e1.getMessage(), e1); Thread.currentThread().interrupt(); diff --git a/designer-base/src/main/java/com/fr/design/fun/MobileBookMarkStyleProvider.java b/designer-base/src/main/java/com/fr/design/fun/MobileBookMarkStyleProvider.java new file mode 100644 index 0000000000..d376dd9ac7 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/MobileBookMarkStyleProvider.java @@ -0,0 +1,34 @@ +package com.fr.design.fun; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.form.ui.mobile.MobileBookMarkStyle; +import com.fr.stable.fun.mark.Mutable; + +/** + * 移动端书签样式扩展接口 + * + * @author hades + * @version 10.0 + * Created by hades on 2019/12/23 + */ +public interface MobileBookMarkStyleProvider extends Mutable { + + String XML_TAG = "MobileBookMarkStyleProvider"; + + int CURRENT_LEVEL = 1; + + /** + * 书签样式 + * @return + */ + Class classForMobileBookMarkStyle(); + + /** + * 书签样式面板 + * @return + */ + Class> classForMobileBookMarkStyleAppearance(); + + String displayName(); + +} diff --git a/designer-base/src/main/java/com/fr/design/fun/MultiStyleUIConfigProvider.java b/designer-base/src/main/java/com/fr/design/fun/MultiStyleUIConfigProvider.java new file mode 100644 index 0000000000..d00138effb --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/MultiStyleUIConfigProvider.java @@ -0,0 +1,23 @@ +package com.fr.design.fun; + +import com.fr.common.annotations.Open; +import com.fr.stable.fun.mark.Mutable; + +import java.util.List; + +/** + * Created by kerry on 2019-11-11 + */ +@Open +public interface MultiStyleUIConfigProvider extends Mutable { + String XML_TAG = "MultiStyleUIConfigProvider"; + + int CURRENT_LEVEL = 1; + + /** + * 获取配置项list + * + * @return 配置项list + */ + List getConfigList(); +} diff --git a/designer-base/src/main/java/com/fr/design/fun/StyleUIConfigProvider.java b/designer-base/src/main/java/com/fr/design/fun/StyleUIConfigProvider.java new file mode 100644 index 0000000000..a28d276df2 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/StyleUIConfigProvider.java @@ -0,0 +1,39 @@ +package com.fr.design.fun; + +import com.fr.base.Style; +import com.fr.common.annotations.Open; +import com.fr.stable.fun.mark.Mutable; + +import javax.swing.JComponent; +import javax.swing.event.ChangeListener; + +/** + * Created by kerry on 2019-11-11 + */ +@Open +public interface StyleUIConfigProvider extends Mutable { + String XML_TAG = "CustomStyleUIConfigProvider"; + + int CURRENT_LEVEL = 1; + + /** + * @return 配置名 + */ + String configName(); + + /** + * @param changeListener 需要添加的listener + * @return 对应的component + */ + JComponent uiComponent(ChangeListener changeListener); + + /** + * @return 更新后的样式 + */ + Style updateConfig(); + + /** + * @param style 待渲染的样式 + */ + void populateConfig(Style style); +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileBookMarkStyleProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileBookMarkStyleProvider.java new file mode 100644 index 0000000000..21ed6722b6 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileBookMarkStyleProvider.java @@ -0,0 +1,24 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.MobileBookMarkStyleProvider; +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/24 + */ +@API(level = MobileBookMarkStyleProvider.CURRENT_LEVEL) +public abstract class AbstractMobileBookMarkStyleProvider extends AbstractProvider implements MobileBookMarkStyleProvider { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMultiStyleUIConfigProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMultiStyleUIConfigProvider.java new file mode 100644 index 0000000000..260d4099bf --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMultiStyleUIConfigProvider.java @@ -0,0 +1,26 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.StyleUIConfigProvider; +import com.fr.design.fun.MultiStyleUIConfigProvider; +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by kerry on 2019-11-11 + */ +@API(level = MultiStyleUIConfigProvider.CURRENT_LEVEL) +public abstract class AbstractMultiStyleUIConfigProvider extends AbstractProvider implements MultiStyleUIConfigProvider { + @Override + public List getConfigList() { + return new ArrayList(); + } + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractStyleUIConfigProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractStyleUIConfigProvider.java new file mode 100644 index 0000000000..e3388feaf7 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractStyleUIConfigProvider.java @@ -0,0 +1,41 @@ +package com.fr.design.fun.impl; + +import com.fr.base.Style; +import com.fr.design.fun.StyleUIConfigProvider; +import com.fr.stable.StringUtils; +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +import javax.swing.JComponent; +import javax.swing.event.ChangeListener; + +/** + * Created by kerry on 2019-11-11 + */ +@API(level = StyleUIConfigProvider.CURRENT_LEVEL) +public class AbstractStyleUIConfigProvider extends AbstractProvider implements StyleUIConfigProvider { + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String configName() { + return StringUtils.EMPTY; + } + + @Override + public JComponent uiComponent(ChangeListener changeListener) { + return null; + } + + @Override + public Style updateConfig() { + return null; + } + + @Override + public void populateConfig(Style style) { + + } +} 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 4bb286dbc0..ebe41b2bc7 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 @@ -1,10 +1,13 @@ package com.fr.design.gui.controlpane; +import com.fr.design.DesignerEnvManager; import com.fr.design.beans.BasicBeanPane; import com.fr.design.data.tabledata.tabledatapane.GlobalMultiTDTableDataPane; import com.fr.design.data.tabledata.tabledatapane.GlobalTreeTableDataPane; import com.fr.design.data.tabledata.tabledatapane.MultiTDTableDataPane; import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane; +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.general.ComparatorUtils; @@ -99,6 +102,15 @@ class JControlUpdatePane extends JPanel { if (pane != null && pane.isVisible()) { Object bean = pane.updateBean(); + try { + if (bean instanceof RemoteDesignerWorkspaceInfo) { + DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(elEditing.wrapper.getName()); + String remindTime = info.getRemindTime(); + ((RemoteDesignerWorkspaceInfo) bean).setRemindTime(remindTime); + } + }catch (Exception e){ + FineLoggerFactory.getLogger().info("remindTime is not exist"); + } if (i < creators.length) { creators[i].saveUpdatedBean(elEditing, bean); } diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneHelper.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneHelper.java index 5618c407c0..0d12772d33 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneHelper.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneHelper.java @@ -1,6 +1,7 @@ package com.fr.design.gui.controlpane; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.ListModelElement; import com.fr.stable.Nameable; @@ -32,7 +33,7 @@ class ListControlPaneHelper { try { listControlPane.checkValid(); } catch (Exception exp) { - JOptionPane.showMessageDialog((Component) listControlPane, exp.getMessage()); + FineJOptionPane.showMessageDialog((Component) listControlPane, exp.getMessage()); listControlPane.setSelectedIndex(idx); return true; } 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 6ab6bce56f..747dbe32f0 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 @@ -1,6 +1,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.ilable.UILabel; import com.fr.design.gui.itoolbar.UIToolBarUI; @@ -10,15 +11,25 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.menu.ShortCut; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.widget.FRWidgetFactory; +import com.fr.invoke.Reflect; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; import com.fr.stable.os.OperatingSystem; + +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JSplitPane; +import javax.swing.SwingUtilities; +import javax.swing.border.EmptyBorder; 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.Frame; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsEnvironment; @@ -26,14 +37,6 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.Window; -import javax.swing.BorderFactory; -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JSplitPane; -import javax.swing.border.EmptyBorder; - import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; @@ -243,6 +246,20 @@ abstract class UIControlPane extends JControlPane { return; } } + + try { + //没有指定owner的弹出框用的是SwingUtilities.getSharedOwnerFrame() + Frame sharedOwnerFrame = Reflect.on(SwingUtilities.class).call("getSharedOwnerFrame").get(); + for (Window window : sharedOwnerFrame.getOwnedWindows()) { + if (window instanceof JDialog && window.isVisible() && ((JDialog) window).isModal()) { + // 如果有可见模态对话框,则不隐藏 + return; + } + } + } catch (Exception ignore) { + //do nothing + } + // 要隐藏 先检查有没有非法输入 // 非法输入检查放在最后,因为可能出现面板弹出新弹框而失去焦点的情况,比如 输入公式时,弹出公式编辑对话框 try { @@ -250,7 +267,7 @@ abstract class UIControlPane extends JControlPane { } catch (Exception exp) { // 存在非法输入 拒绝隐藏 this.setAlwaysOnTop(true); - JOptionPane.showMessageDialog(this, exp.getMessage()); + FineJOptionPane.showMessageDialog(this, exp.getMessage()); this.requestFocus(); return; } diff --git a/designer-base/src/main/java/com/fr/design/gui/date/UICalendarPanel.java b/designer-base/src/main/java/com/fr/design/gui/date/UICalendarPanel.java index c97b671dec..c21b740c43 100644 --- a/designer-base/src/main/java/com/fr/design/gui/date/UICalendarPanel.java +++ b/designer-base/src/main/java/com/fr/design/gui/date/UICalendarPanel.java @@ -437,18 +437,18 @@ public class UICalendarPanel extends JPanel { }; } - protected EventListenerList listenerList = new EventListenerList(); + protected EventListenerList eventlistenerList = new EventListenerList(); public void addDateChangeListener(ChangeListener l) { - listenerList.add(ChangeListener.class, l); + eventlistenerList.add(ChangeListener.class, l); } public void removeDateChangeListener(ChangeListener l) { - listenerList.remove(ChangeListener.class, l); + eventlistenerList.remove(ChangeListener.class, l); } protected void fireDateChanged(ChangeEvent e) { - Object[] listeners = listenerList.getListenerList(); + Object[] listeners = eventlistenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ChangeListener.class) { ((ChangeListener) listeners[i + 1]).stateChanged(e); diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/CommitTabbedPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/CommitTabbedPane.java index afbf43c305..66b057d0ca 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/CommitTabbedPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/CommitTabbedPane.java @@ -3,6 +3,7 @@ package com.fr.design.gui.frpane; import com.fr.base.BaseUtils; import com.fr.design.constants.UIConstants; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.write.submit.DBManipulationPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.javascript.Commit2DBJavaScriptPane; @@ -408,7 +409,7 @@ public class CommitTabbedPane extends JComponent implements MouseListener, Mous selectedIndex = dbManipulationPaneList.size()-1; commit2DBJavaScriptPane.updateCardPane(); } else if (isOverCloseIcon(x)){ - int re = JOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_CommitTab_Sure_To_Delete")+ "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_CommitTab_Remove") + int re = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_CommitTab_Sure_To_Delete")+ "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_CommitTab_Remove") , JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (re == JOptionPane.OK_OPTION) { dbManipulationPaneList.remove(getTabIndex(x)); diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/EditingStringListPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/EditingStringListPane.java index d3370a7c07..068e9cc9db 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/EditingStringListPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/EditingStringListPane.java @@ -1,6 +1,7 @@ package com.fr.design.gui.frpane; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; @@ -127,7 +128,7 @@ public abstract class EditingStringListPane extends BasicBeanPane> setAddEnabled(false); } } else { - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(EditingStringListPane.this), newvalue + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Already_Exists_Not_Add_Repeat")+"!"); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(EditingStringListPane.this), newvalue + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Already_Exists_Not_Add_Repeat")+"!"); } } }); @@ -149,7 +150,7 @@ public abstract class EditingStringListPane extends BasicBeanPane> public void actionPerformed(ActionEvent e) { Object selected = jlist.getSelectedValue(); if (selected != null) { - int re = JOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(EditingStringListPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Sure_To_Delete") + selected.toString() + "?"); + int re = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(EditingStringListPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Sure_To_Delete") + selected.toString() + "?"); if (re == JOptionPane.OK_OPTION) { JListUtils.removeSelectedListItems(jlist); } diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupPane.java index 3f4ae9b2a5..8405ce09ea 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupPane.java @@ -2,6 +2,7 @@ package com.fr.design.gui.frpane; import com.fr.design.ExtraDesignClassManager; import com.fr.design.designer.TargetComponent; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.fun.HyperlinkProvider; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.UIListControlPane; @@ -45,6 +46,7 @@ public abstract class HyperlinkGroupPane extends UIListControlPane { @Override public void on(PluginEvent event) { refreshNameableCreator(createNameableCreators()); + HistoryTemplateListCache.getInstance().reloadCurrentTemplate(); } }, new PluginFilter() { diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/JTreeControlPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/JTreeControlPane.java index 0c266b81ac..04e3626a4a 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/JTreeControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/JTreeControlPane.java @@ -5,6 +5,7 @@ import com.fr.data.impl.TreeNodeAttr; import com.fr.data.impl.TreeNodeWrapper; import com.fr.design.actions.UpdateAction; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.controlpane.ControlPane; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.UnrepeatedNameHelper; @@ -231,7 +232,7 @@ public class JTreeControlPane extends ControlPane { public void actionPerformed(ActionEvent e) { // TODO remove tree node - int val = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + "?", + int val = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (val != JOptionPane.OK_OPTION) { return; diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/UITabbedPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/UITabbedPane.java index 92ad39559e..c1021321b9 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/UITabbedPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/UITabbedPane.java @@ -1,5 +1,6 @@ package com.fr.design.gui.frpane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.general.ComparatorUtils; @@ -113,7 +114,7 @@ public class UITabbedPane extends JTabbedPane{ * @param i tab索引 */ public void doRemoveTab(int i){ - int re = JOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(UITabbedPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Sure_To_Delete")+ "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove") + int re = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(UITabbedPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Sure_To_Delete")+ "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove") , JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (re == JOptionPane.OK_OPTION) { super.removeTabAt(i); diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/UITabbedPaneUI.java b/designer-base/src/main/java/com/fr/design/gui/frpane/UITabbedPaneUI.java index d95740798b..5798a864b0 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/UITabbedPaneUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/UITabbedPaneUI.java @@ -330,7 +330,9 @@ public class UITabbedPaneUI extends BasicTabbedPaneUI { g.drawLine(x + 1, y + h - 2, x + w - 3, y + h - 2); // bottom } + @Override protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex) { + // do nothing } /** 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 798b79af08..bab3e8851c 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 @@ -133,14 +133,17 @@ public abstract class UnitInputPane extends BasicPane { @Override public void keyTyped(KeyEvent arg0) { + // 敲击键盘,发生在按键按下后,按键放开前 } @Override public void keyReleased(KeyEvent arg0) { + // 松开按键时 } @Override public void keyPressed(KeyEvent arg0) { + // 按下按键时 changed = true; } }; @@ -149,23 +152,28 @@ public abstract class UnitInputPane extends BasicPane { @Override public void mouseReleased(MouseEvent arg0) { + // 鼠标按键在组件上释放时 } @Override public void mousePressed(MouseEvent arg0) { + // 鼠标按键在组件上按下时 changed = true; } @Override public void mouseExited(MouseEvent arg0) { + // 鼠标离开组件时 } @Override public void mouseEntered(MouseEvent arg0) { + // 鼠标进入到组件时 } @Override public void mouseClicked(MouseEvent arg0) { + // 鼠标按键在组件上单击时 } }; } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/tree/layer/config/LayerDataControlPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/tree/layer/config/LayerDataControlPane.java index 128adca1f1..6d74e48015 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/tree/layer/config/LayerDataControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/tree/layer/config/LayerDataControlPane.java @@ -2,6 +2,7 @@ package com.fr.design.gui.frpane.tree.layer.config; import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.controlpane.ControlPane; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itoolbar.UIToolbar; @@ -177,7 +178,7 @@ public class LayerDataControlPane extends ControlPane { public void actionPerformed(ActionEvent e) { // TODO remove tree node - int val = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + "?", + int val = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (val != JOptionPane.OK_OPTION) { return; diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/SpecialUIButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/SpecialUIButton.java index 338cbac7ef..c423ac582b 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/SpecialUIButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/SpecialUIButton.java @@ -25,6 +25,8 @@ public class SpecialUIButton extends JButton { * * @see javax.swing.AbstractButton#setUI(ButtonUI) */ + @Override public void setUI(ButtonUI ui) { + // do nothing } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIBasicButtonUI.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIBasicButtonUI.java index 64db1e91da..87aae662bd 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIBasicButtonUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIBasicButtonUI.java @@ -43,6 +43,7 @@ public class UIBasicButtonUI extends MetalButtonUI { private boolean isDefault; public UIBasicButtonUI() { + // do nothing } /** 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 c1dc9b0581..28f5830619 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 @@ -1,19 +1,5 @@ package com.fr.design.gui.ibutton; -import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -import javax.swing.AbstractButton; -import javax.swing.ButtonModel; -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.event.EventListenerList; - import com.fr.base.Utils; import com.fr.design.constants.UIConstants; import com.fr.design.event.GlobalNameListener; @@ -21,231 +7,235 @@ import com.fr.design.event.GlobalNameObserver; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ipoppane.PopupHider; -import com.fr.general.ComparatorUtils; import com.fr.design.style.color.ColorControlWindow; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.ComparatorUtils; + +import javax.swing.AbstractButton; +import javax.swing.ButtonModel; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.EventListenerList; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; public class UIColorButton extends UIButton implements PopupHider, UIObserver, GlobalNameObserver { - private static final int SIZE = 16; - private static final int SIZE_2 = 2; - private static final int SIZE_4 = 4; - private static final int SIZE_6 = 6; - private static final int POPUP_MENU_SHIFT = -70; - private Color color = Color.BLACK; - private ColorControlWindow popupWin; - private EventListenerList colorChangeListenerList = new EventListenerList(); - private boolean isEventBanned = false; - private String colorButtonName = ""; - private UIObserverListener uiObserverListener; - private GlobalNameListener globalNameListener = null; - - public UIColorButton() { - this(UIConstants.FONT_ICON); - } - - public UIColorButton(Icon icon) { - super(icon); - setUI(getButtonUI()); - addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - showPopupMenu(); - } - }); - iniListener(); - } - - private void iniListener() { - if (shouldResponseChangeListener()) { - this.addColorChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - if (uiObserverListener == null) { - return; - } - if (globalNameListener != null && shouldResponseNameListener()) { - globalNameListener.setGlobalName(colorButtonName); - } - uiObserverListener.doChange(); - } - }); - } - } - - private UIButtonUI getButtonUI() { - return new UIButtonUI() { - @Override - protected void paintIcon(Graphics g, JComponent c) { - super.paintIcon(g, c); - AbstractButton b = (AbstractButton) c; - ButtonModel model = b.getModel(); - if (model.isEnabled()) { - g.setColor(UIColorButton.this.getColor()); - } else { - g.setColor(new Color(Utils.filterRGB(UIColorButton.this.getColor().getRGB(), 50))); - } - g.fillRect((b.getWidth() - SIZE) / SIZE_2, b.getHeight() - SIZE_6, SIZE, SIZE_4); - } - }; - } - - public void setEventBanned(boolean isEventBanned) { - this.isEventBanned = isEventBanned; - } - - public void setGlobalName(String name) { - colorButtonName = name; - } - - public Color getColor() { - return color; - } - - public void setColor(Color color) { - if (ComparatorUtils.equals(this.color, color)) { - return; - } - - this.color = color; - hidePopupMenu(); - fireColorStateChanged(); - } - - private void showPopupMenu() { - if (isEventBanned) { - return; - } - - if (popupWin != null && popupWin.isVisible()) { - hidePopupMenu(); - return; - } - - if (!this.isEnabled()) { - return; - } - - popupWin = this.getColorControlWindow(); - - GUICoreUtils.showPopupMenu(popupWin, this, POPUP_MENU_SHIFT, this.getSize().height); - } - - /** - * 隐藏popupmenu - */ - public void hidePopupMenu() { - if (popupWin != null) { - popupWin.setVisible(false); - repaint(); - } - - popupWin = null; - } - - private ColorControlWindow getColorControlWindow() { - //find parant. - if (this.popupWin == null) { - this.popupWin = new ColorControlWindow(UIColorButton.this) { - @Override - protected void colorChanged() { - UIColorButton.this.setColor(this.getColor()); - } - - }; - } - - return popupWin; - } - - /** - * 添加监听 - * - * @param changeListener 监听列表 - */ - public void addColorChangeListener(ChangeListener changeListener) { - colorChangeListenerList.add(ChangeListener.class, changeListener); - } - - /** - * 移除监听 - * Removes an old ColorChangeListener. - * @param 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); - } - } - } - - - /** - * 注册状态改变监听 - * - * @param listener 观察者监听事件 - */ - public void registerChangeListener(UIObserverListener listener) { - uiObserverListener = listener; - } - - /** - * 是否需要响应监听 - * - * @return 是否响应 - */ - public boolean shouldResponseChangeListener() { - return true; - } - - /** - * 注册监听 - * - * @param listener 观察者监听事件 - */ - public void registerNameListener(GlobalNameListener listener) { - globalNameListener = listener; - } - - /** - * 是否需要相应 - * - * @return 是否响应 - */ - public boolean shouldResponseNameListener() { - return true; - } - - /** - * 主函数 - * - * @param args 参数 - */ - public static void main(String... args) { - LayoutManager layoutManager = null; - JFrame jf = new JFrame("test"); - jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - JPanel content = (JPanel) jf.getContentPane(); - content.setLayout(layoutManager); - - UIColorButton bb = new UIColorButton(UIConstants.FONT_ICON); - bb.setBounds(20, 20, bb.getPreferredSize().width, bb.getPreferredSize().height); - content.add(bb); - GUICoreUtils.centerWindow(jf); - jf.setSize(400, 400); - jf.setVisible(true); - } + public static final int SIZE = 16; + public static final int SIZE_2 = 2; + public static final int SIZE_4 = 4; + public static final int SIZE_6 = 6; + private static final int POPUP_MENU_SHIFT = -70; + private Color color = Color.BLACK; + private ColorControlWindow popupWin; + private EventListenerList colorChangeListenerList = new EventListenerList(); + private boolean isEventBanned = false; + private String colorButtonName = ""; + private UIObserverListener uiObserverListener; + private GlobalNameListener globalNameListener = null; + + public UIColorButton() { + this(UIConstants.FONT_ICON); + } + + public UIColorButton(Icon icon) { + super(icon); + setUI(getButtonUI()); + addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + showPopupMenu(); + } + }); + iniListener(); + } + + public ColorControlWindow getPopupWin() { + return popupWin; + } + + public void setPopupWin(ColorControlWindow popupWin) { + this.popupWin = popupWin; + } + + private void iniListener() { + if (shouldResponseChangeListener()) { + this.addColorChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (uiObserverListener == null) { + return; + } + if (globalNameListener != null && shouldResponseNameListener()) { + globalNameListener.setGlobalName(colorButtonName); + } + uiObserverListener.doChange(); + } + }); + } + } + + private UIButtonUI getButtonUI() { + return new UIButtonUI() { + @Override + protected void paintIcon(Graphics g, JComponent c) { + super.paintIcon(g, c); + AbstractButton b = (AbstractButton) c; + ButtonModel model = b.getModel(); + if (model.isEnabled()) { + g.setColor(UIColorButton.this.getColor()); + } else { + g.setColor(new Color(Utils.filterRGB(UIColorButton.this.getColor().getRGB(), 50))); + } + g.fillRect((b.getWidth() - SIZE) / SIZE_2, b.getHeight() - SIZE_6, SIZE, SIZE_4); + } + }; + } + + public void setEventBanned(boolean isEventBanned) { + this.isEventBanned = isEventBanned; + } + + public void setGlobalName(String name) { + colorButtonName = name; + } + + public Color getColor() { + return color; + } + + public void setColor(Color color) { + if (ComparatorUtils.equals(this.color, color)) { + return; + } + Color oldColor = this.color; + this.color = color; + checkColorChange(oldColor, this.color); + } + + protected void checkColorChange(Color oldColor, Color newColor) { + hidePopupMenu(); + fireColorStateChanged(); + } + + private void showPopupMenu() { + if (isEventBanned) { + return; + } + + if (popupWin != null && popupWin.isVisible()) { + hidePopupMenu(); + return; + } + + if (!this.isEnabled()) { + return; + } + + popupWin = this.getColorControlWindow(); + + GUICoreUtils.showPopupMenu(popupWin, this, POPUP_MENU_SHIFT, this.getSize().height); + } + + /** + * 隐藏popupmenu + */ + public void hidePopupMenu() { + if (popupWin != null) { + popupWin.setVisible(false); + } + popupWin = null; + repaint(); + } + + protected ColorControlWindow getColorControlWindow() { + //find parant. + if (this.popupWin == null) { + this.popupWin = new ColorControlWindow(UIColorButton.this) { + @Override + protected void colorChanged() { + UIColorButton.this.setColor(this.getColor()); + } + + }; + } + + return popupWin; + } + + /** + * 添加监听 + * + * @param changeListener 监听列表 + */ + public void addColorChangeListener(ChangeListener changeListener) { + colorChangeListenerList.add(ChangeListener.class, changeListener); + } + + /** + * 移除监听 + * Removes an old ColorChangeListener. + * + * @param 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); + } + } + } + + + /** + * 注册状态改变监听 + * + * @param listener 观察者监听事件 + */ + public void registerChangeListener(UIObserverListener listener) { + uiObserverListener = listener; + } + + /** + * 是否需要响应监听 + * + * @return 是否响应 + */ + public boolean shouldResponseChangeListener() { + return true; + } + + /** + * 注册监听 + * + * @param listener 观察者监听事件 + */ + public void registerNameListener(GlobalNameListener listener) { + globalNameListener = listener; + } + + /** + * 是否需要相应 + * + * @return 是否响应 + */ + public boolean shouldResponseNameListener() { + return true; + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButtonWithAuto.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButtonWithAuto.java new file mode 100644 index 0000000000..a7dcad008a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButtonWithAuto.java @@ -0,0 +1,38 @@ +package com.fr.design.gui.ibutton; + +import com.fr.chart.base.ChartConstants; +import com.fr.design.constants.UIConstants; +import com.fr.design.style.color.ColorControlWindow; +import com.fr.design.style.color.ColorControlWindowWithAuto; +import com.fr.general.ComparatorUtils; + +import java.awt.Color; + +public class UIColorButtonWithAuto extends UIColorButton { + + protected void checkColorChange(Color oldColor, Color newColor) { + if (ComparatorUtils.equals(oldColor, ChartConstants.AUTO_FONT_COLOR) && !ComparatorUtils.equals(newColor, ChartConstants.AUTO_FONT_COLOR)) { + setIcon(UIConstants.FONT_ICON); + } + + if (!ComparatorUtils.equals(oldColor, ChartConstants.AUTO_FONT_COLOR) && ComparatorUtils.equals(newColor, ChartConstants.AUTO_FONT_COLOR)) { + setIcon(UIConstants.AUTO_FONT_ICON); + } + + super.checkColorChange(oldColor, newColor); + } + + protected ColorControlWindow getColorControlWindow() { + if (getPopupWin() == null) { + ColorControlWindowWithAuto colorControlWindowWithAuto = new ColorControlWindowWithAuto(UIColorButtonWithAuto.this) { + protected void colorChanged() { + UIColorButtonWithAuto.this.setColor(this.getColor()); + } + }; + + setPopupWin(colorControlWindowWithAuto); + } + + return getPopupWin(); + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java index 4efd505890..4a24c8de25 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java @@ -18,11 +18,11 @@ public class UICombinationButton extends JPanel{ protected UIButton rightButton; protected void leftButtonClickEvent() { - + // 左边按钮点击事件 } protected void rightButtonClickEvent() { - + // 右边按钮点击事件 } public UICombinationButton() { 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 edbc013405..e21f4c2170 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 @@ -25,7 +25,7 @@ public class UIHeadGroup extends JPanel { protected int selectedIndex = -1; protected void tabChanged(int newSelectedIndex) { - + // do nothing } public UIHeadGroup(String[] textArray) { diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIPasswordField.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIPasswordField.java index 8d26b5e875..8963119a04 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIPasswordField.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIPasswordField.java @@ -1 +1 @@ -package com.fr.design.gui.ibutton; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import javax.swing.*; /** * Author : Shockway * Date: 13-10-21 * Time: 下午3:23 */ public class UIPasswordField extends JPasswordField implements UIObserver { public void registerChangeListener(UIObserverListener listener) { } public boolean shouldResponseChangeListener() { return false; } } \ No newline at end of file +package com.fr.design.gui.ibutton; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import javax.swing.*; /** * Author : Shockway * Date: 13-10-21 * Time: 下午3:23 */ public class UIPasswordField extends JPasswordField implements UIObserver { public void registerChangeListener(UIObserverListener listener) { // do nothing } public boolean shouldResponseChangeListener() { return false; } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIPreviewButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIPreviewButton.java index a5f9de9b70..50bbc1440d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIPreviewButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIPreviewButton.java @@ -1 +1 @@ -package com.fr.design.gui.ibutton; import com.fr.design.constants.UIConstants; import com.fr.stable.Constants; import com.fr.design.utils.gui.GUICoreUtils; import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; /** * Author : daisy * Date: 13-8-1 * Time: 下午3:41 */ public class UIPreviewButton extends JPanel { private static final int START_X = -7; protected UIButton upButton; protected UIButton downButton; protected void upButtonClickEvent() { } protected void downButtonClickEvent() { } public UIPreviewButton() { this(new UIButton(), new UIButton()); } public UIPreviewButton(UIButton up, UIButton down) { upButton = up; downButton = down; upButton.setRoundBorder(true, Constants.CENTER); downButton.setRoundBorder(true, Constants.CENTER); upButton.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { downButton.getModel().setPressed(true); downButton.getModel().setSelected(true); downButton.repaint(); } @Override public void mouseReleased(MouseEvent e) { downButton.getModel().setPressed(false); downButton.getModel().setSelected(false); downButton.repaint(); } @Override public void mouseClicked(MouseEvent e) { upButtonClickEvent(); } }); downButton.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { upButton.getModel().setPressed(true); upButton.getModel().setSelected(true); upButton.repaint(); } @Override public void mouseReleased(MouseEvent e) { upButton.getModel().setPressed(false); upButton.getModel().setSelected(false); upButton.repaint(); } @Override public void mouseClicked(MouseEvent e) { downButtonClickEvent(); } }); this.setLayout(new FlowLayout(FlowLayout.CENTER,5,0)); this.add(upButton); this.add(downButton); } public UIPreviewButton(Icon left, Icon right) { this(); upButton.setIcon(left); downButton.setIcon(right); } public UIButton getUpButton() { return upButton; } public void setExtraPainted(boolean isExtraPainted) { if (!isExtraPainted) { upButton.setBackground(null); downButton.setBackground(null); upButton.setOpaque(false); downButton.setOpaque(false); } } public UIButton getDownButton() { return downButton; } public void set4Toolbar() { upButton.setNormalPainted(false); downButton.setNormalPainted(false); upButton.setBorderPaintedOnlyWhenPressed(true); downButton.setBorderPaintedOnlyWhenPressed(true); } protected void showPopWindow(JPopupMenu menu) { GUICoreUtils.showPopupMenu(menu, this, START_X, getY() + getHeight() - 3); } public static void main(String... args) { JFrame jf = new JFrame("test"); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel content = (JPanel) jf.getContentPane(); content.setLayout(null); UIPreviewButton bb = new UIPreviewButton(UIConstants.PAGE_BIG_ICON, UIConstants.PREVIEW_DOWN); bb.setBounds(20, 20, bb.getPreferredSize().width, bb.getPreferredSize().height); content.add(bb); GUICoreUtils.centerWindow(jf); jf.setSize(100, 100); jf.setVisible(true); } } \ No newline at end of file +package com.fr.design.gui.ibutton; import com.fr.design.constants.UIConstants; import com.fr.stable.Constants; import com.fr.design.utils.gui.GUICoreUtils; import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; /** * Author : daisy * Date: 13-8-1 * Time: 下午3:41 */ public class UIPreviewButton extends JPanel { private static final int START_X = -7; protected UIButton upButton; protected UIButton downButton; protected void upButtonClickEvent() { // do nothing } protected void downButtonClickEvent() { // do nothing } public UIPreviewButton() { this(new UIButton(), new UIButton()); } public UIPreviewButton(UIButton up, UIButton down) { upButton = up; downButton = down; upButton.setRoundBorder(true, Constants.CENTER); downButton.setRoundBorder(true, Constants.CENTER); upButton.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { downButton.getModel().setPressed(true); downButton.getModel().setSelected(true); downButton.repaint(); } @Override public void mouseReleased(MouseEvent e) { downButton.getModel().setPressed(false); downButton.getModel().setSelected(false); downButton.repaint(); } @Override public void mouseClicked(MouseEvent e) { upButtonClickEvent(); } }); downButton.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { upButton.getModel().setPressed(true); upButton.getModel().setSelected(true); upButton.repaint(); } @Override public void mouseReleased(MouseEvent e) { upButton.getModel().setPressed(false); upButton.getModel().setSelected(false); upButton.repaint(); } @Override public void mouseClicked(MouseEvent e) { downButtonClickEvent(); } }); this.setLayout(new FlowLayout(FlowLayout.CENTER,5,0)); this.add(upButton); this.add(downButton); } public UIPreviewButton(Icon left, Icon right) { this(); upButton.setIcon(left); downButton.setIcon(right); } public UIButton getUpButton() { return upButton; } public void setExtraPainted(boolean isExtraPainted) { if (!isExtraPainted) { upButton.setBackground(null); downButton.setBackground(null); upButton.setOpaque(false); downButton.setOpaque(false); } } public UIButton getDownButton() { return downButton; } public void set4Toolbar() { upButton.setNormalPainted(false); downButton.setNormalPainted(false); upButton.setBorderPaintedOnlyWhenPressed(true); downButton.setBorderPaintedOnlyWhenPressed(true); } protected void showPopWindow(JPopupMenu menu) { GUICoreUtils.showPopupMenu(menu, this, START_X, getY() + getHeight() - 3); } public static void main(String... args) { JFrame jf = new JFrame("test"); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel content = (JPanel) jf.getContentPane(); content.setLayout(null); UIPreviewButton bb = new UIPreviewButton(UIConstants.PAGE_BIG_ICON, UIConstants.PREVIEW_DOWN); bb.setBounds(20, 20, bb.getPreferredSize().width, bb.getPreferredSize().height); content.add(bb); GUICoreUtils.centerWindow(jf); jf.setSize(100, 100); jf.setVisible(true); } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIRadioButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIRadioButton.java index 0752eef4d2..1c2aef38a7 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIRadioButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIRadioButton.java @@ -25,36 +25,43 @@ public class UIRadioButton extends JRadioButton implements UIObserver, GlobalNam public UIRadioButton() { super(); initListener(); + initComponent(); } public UIRadioButton(Icon icon) { super(icon); initListener(); + initComponent(); } public UIRadioButton(Action a) { super(a); initListener(); + initComponent(); } public UIRadioButton(Icon icon, boolean selected) { super(icon, selected); initListener(); + initComponent(); } public UIRadioButton(String text) { super(text); initListener(); + initComponent(); } public UIRadioButton(String text, boolean selected) { super(text, selected); initListener(); + initComponent(); } public UIRadioButton(String text, Icon icon) { super(text, icon); initListener(); + initComponent(); } @@ -81,6 +88,10 @@ public class UIRadioButton extends JRadioButton implements UIObserver, GlobalNam } } + private void initComponent() { + this.setFocusPainted(false); + } + /** * 给组件登记一个观察者监听事件 * diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButtonUI.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButtonUI.java index 6a92f5057b..6b406588b6 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButtonUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButtonUI.java @@ -176,11 +176,11 @@ public class UISliderButtonUI extends BasicButtonUI { private void fillNormal(Graphics2D g2d, int x, int y, int width, int height, boolean isRound, int rectDirection, boolean isAuthorityEdited, boolean isPressedPainted) { GradientPaint gp; if (DesignerMode.isAuthorityEditing() && isAuthorityEdited) { - gp = new GradientPaint(1, 1, UIConstants.AUTHORITY_BLUE, 1, height - 1f, UIConstants.AUTHORITY_DARK_BLUE); + gp = new GradientPaint(1, 1, UIConstants.AUTHORITY_BLUE, 1, height - 1F, UIConstants.AUTHORITY_DARK_BLUE); } else if (isPressedPainted) { - gp = new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, height - 1, UIConstants.SELECT_TAB); + gp = new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, height - 1F, UIConstants.SELECT_TAB); }else{ - gp = new GradientPaint(1, 1, UIConstants.POP_DIALOG_BORDER, 1, height - 1, UIConstants.POP_DIALOG_BORDER); + gp = new GradientPaint(1, 1, UIConstants.POP_DIALOG_BORDER, 1, height - 1F, UIConstants.POP_DIALOG_BORDER); } fillPaint(g2d, x, y, width, height, isRound, rectDirection, gp, UIConstants.ARC); @@ -189,11 +189,11 @@ public class UISliderButtonUI extends BasicButtonUI { private void fillRollOver(Graphics2D g2d, int x, int y, int width, int height, boolean isRound, int rectDirection, boolean isAuthorityEdited, boolean isPressedPainted) { GradientPaint gp; if (DesignerMode.isAuthorityEditing() && isAuthorityEdited) { - gp = new GradientPaint(1, 1, UIConstants.AUTHORITY_BLUE, 1, height - 1, UIConstants.HOVER_BLUE); + gp = new GradientPaint(1, 1, UIConstants.AUTHORITY_BLUE, 1, height - 1F, UIConstants.HOVER_BLUE); } else if (isPressedPainted) { - gp = new GradientPaint(1, 1, UIConstants.POP_DIALOG_BORDER, 1, height - 1, UIConstants.POP_DIALOG_BORDER); + gp = new GradientPaint(1, 1, UIConstants.POP_DIALOG_BORDER, 1, height - 1F, UIConstants.POP_DIALOG_BORDER); }else { - gp = new GradientPaint(1, 1, UIConstants.POP_DIALOG_BORDER, 1, height - 1, UIConstants.POP_DIALOG_BORDER); + gp = new GradientPaint(1, 1, UIConstants.POP_DIALOG_BORDER, 1, height - 1F, UIConstants.POP_DIALOG_BORDER); } fillPaint(g2d, x, y, width, height, isRound, rectDirection, gp, UIConstants.ARC); } @@ -225,4 +225,4 @@ public class UISliderButtonUI extends BasicButtonUI { g2d.setColor(oldColor); } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UITabButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UITabButton.java index 4e50dd9942..aa5c34f60b 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UITabButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UITabButton.java @@ -162,12 +162,12 @@ public class UITabButton extends UILabel implements UISelectedComponent { Color blue = UIConstants.LIGHT_BLUE; g2d.setColor(blue); g2d.fillRect(0, 1, w - 1, h / 2); - GradientPaint gp = new GradientPaint(1, 1, UIConstants.OCEAN_BLUE, 1, h - 1, blue); + GradientPaint gp = new GradientPaint(1, 1, UIConstants.OCEAN_BLUE, 1, h - 1F, blue); g2d.setPaint(gp); g2d.fillRect(0, h / 2, w - 1, h / 2); this.setForeground(UIConstants.FONT_COLOR); } else if (!isSelected() && !isRollover) { - GradientPaint gp = new GradientPaint(1, 1, TOP, 1, h - 1, DOWN); + GradientPaint gp = new GradientPaint(1, 1, TOP, 1, h - 1F, DOWN); g2d.setPaint(gp); g2d.fillRect(0, h / 2, w - 1, h / 2); this.setForeground(UIConstants.FONT_COLOR); @@ -175,7 +175,7 @@ public class UITabButton extends UILabel implements UISelectedComponent { } protected void paintOther(Graphics2D g2d, int w, int h) { - + // do nothing } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java index 45c878419e..dc380c0c94 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java @@ -187,7 +187,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{ @Override protected void fireStateChanged() { - + // do nothing } @@ -220,7 +220,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{ protected void paintOtherBorder(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setStroke(UIConstants.BS); - Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1, getHeight() - 1, UIConstants.ARC, UIConstants.ARC); + Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1F, getHeight() - 1F, UIConstants.ARC, UIConstants.ARC); g2d.setColor(UIConstants.LINE_COLOR); g2d.draw(shape); } @@ -252,4 +252,4 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{ return true; } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java index 10ea06a8ce..379274b90b 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java @@ -59,24 +59,28 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser initListener(); } - private void initListener() { + protected void initListener() { if (shouldResponseChangeListener()) { this.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { - if (uiObserverListener == null) { - return; - } - if (globalNameListener != null && shouldResponseNameListener()) { - globalNameListener.setGlobalName(checkboxName); - } - uiObserverListener.doChange(); + attributeChange(); } }); } } + protected void attributeChange() { + if (uiObserverListener == null) { + return; + } + if (globalNameListener != null && shouldResponseNameListener()) { + globalNameListener.setGlobalName(checkboxName); + } + uiObserverListener.doChange(); + } + /** * 给组件登记一个观察者监听事件 * diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/ComboCheckBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/ComboCheckBox.java index 31290d6b05..3a0be4a8ff 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/ComboCheckBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/ComboCheckBox.java @@ -77,8 +77,8 @@ public class ComboCheckBox extends UIComboBox { protected ComboCheckBox comboBox; protected JScrollPane scrollPane; - protected MouseListener mouseListener; - protected MouseMotionListener mouseMotionListener; + protected MouseListener checkListMouseListener; + protected MouseMotionListener checkListMouseMotionListener; public CheckListPopup(JComboBox comboBox) { this.comboBox = (ComboCheckBox) comboBox; @@ -157,22 +157,22 @@ public class ComboCheckBox extends UIComboBox { @Override public MouseListener getMouseListener() { - if (mouseListener == null) { - mouseListener = new InvocationMouseHandler(); + if (checkListMouseListener == null) { + checkListMouseListener = new InvocationMouseHandler(); } - return mouseListener; + return checkListMouseListener; } public MouseMotionListener getMouseMotionListener() { - if (mouseMotionListener == null) { - mouseMotionListener = new MouseMotionAdapter() { + if (checkListMouseMotionListener == null) { + checkListMouseMotionListener = new MouseMotionAdapter() { }; } - return mouseMotionListener; + return checkListMouseMotionListener; } public void uninstallingUI() { - + // do nothing } protected class InvocationMouseHandler extends MouseAdapter { diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java index ae2e6b52d8..a7a9133351 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java @@ -1,22 +1,14 @@ package com.fr.design.gui.icombobox; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.IllegalComponentStateException; -import java.awt.RenderingHints; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionAdapter; -import java.awt.event.MouseMotionListener; -import java.util.Enumeration; +import com.fr.design.constants.UIConstants; +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.layout.FRGUIPaneFactory; +import com.fr.general.ComparatorUtils; +import com.fr.general.NameObject; +import com.fr.stable.Constants; +import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.DefaultListCellRenderer; @@ -38,16 +30,23 @@ import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; - -import com.fr.design.constants.UIConstants; -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.layout.FRGUIPaneFactory; -import com.fr.general.ComparatorUtils; -import com.fr.general.NameObject; -import com.fr.stable.Constants; -import com.fr.stable.StringUtils; +import java.util.Enumeration; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.IllegalComponentStateException; +import java.awt.RenderingHints; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionAdapter; +import java.awt.event.MouseMotionListener; public class FRTreeComboBox extends UIComboBox { @@ -79,7 +78,7 @@ public class FRTreeComboBox extends UIComboBox { boolean showRoot, boolean editable) { this.setTree(tree); this.tree.setCellRenderer(renderer); - this.setEditor(new FrTreeSearchComboBoxEditor(this)); + this.setEditor(createEditor()); if (!showRoot) { tree.expandPath(new TreePath(tree.getModel().getRoot())); tree.setRootVisible(false); @@ -101,6 +100,10 @@ public class FRTreeComboBox extends UIComboBox { return true; } + protected UIComboBoxEditor createEditor() { + return new FrTreeSearchComboBoxEditor(this); + } + public void setTree(JTree tree) { this.tree = tree; if (tree != null) { @@ -318,6 +321,7 @@ public class FRTreeComboBox extends UIComboBox { @Override public void mouseClicked(MouseEvent e) { + // do nothing } @Override @@ -528,7 +532,7 @@ public class FRTreeComboBox extends UIComboBox { } } - class FrTreeSearchComboBoxEditor extends UIComboBoxEditor implements DocumentListener { + public class FrTreeSearchComboBoxEditor extends UIComboBoxEditor implements DocumentListener { private volatile boolean setting = false; private FRTreeComboBox comboBox; private Object item; diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/LineComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/LineComboBox.java index 74cd42a7ef..ca4eddfe3e 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/LineComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/LineComboBox.java @@ -3,6 +3,11 @@ */ package com.fr.design.gui.icombobox; +import com.fr.base.FRContext; +import com.fr.base.GraphHelper; +import com.fr.base.ScreenResolution; +import com.fr.general.FRFont; +import com.fr.stable.Constants; import java.awt.Component; import java.awt.Dimension; import java.awt.Font; @@ -11,18 +16,10 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.GeneralPath; import java.awt.geom.Point2D; - import javax.swing.DefaultComboBoxModel; import javax.swing.JLabel; import javax.swing.JList; -import com.fr.base.FRContext; -import com.fr.base.GraphHelper; -import com.fr.base.ScreenResolution; -import com.fr.general.FRFont; - -import com.fr.stable.Constants; - /** * Combobox for selecting line styles. @@ -88,13 +85,13 @@ public class LineComboBox extends UIComboBox { FontMetrics fm = GraphHelper.getFontMetrics(rfont); if (style == Constants.LINE_NONE) { //draw "none" string - GraphHelper.drawString(g2d, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_None"), 4, (d.height - fm.getHeight()) / 2 + fm.getAscent()); + GraphHelper.drawString(g2d, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_None"), 4, (d.height - fm.getHeight()) / 2D + fm.getAscent()); } else { - GraphHelper.drawLine(g2d, 4, d.height / 2, d.width - 8, d.height / 2, style); + GraphHelper.drawLine(g2d, 4, d.height / 2D, d.width - 8D, d.height / 2D, style); } if(isShowAxisWithLineStyle()) { // 带有坐标轴箭头的样式. - drawArrow(g2d, new Point2D.Double(4, d.height / 2), new Point2D.Double(d.width - 8, d.height/2)); + drawArrow(g2d, new Point2D.Double(4, d.height / 2D), new Point2D.Double(d.width - 8D, d.height / 2D)); } } @@ -142,4 +139,4 @@ public class LineComboBox extends UIComboBox { private int style = Constants.LINE_NONE; } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxButton.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxButton.java index 9f96f655eb..6130050dc2 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxButton.java @@ -172,11 +172,9 @@ public class UIComboBoxButton extends JButton { } c.setBackground(UIManager.getColor("ComboBox.focusBackground")); if (c instanceof JComponent) { - mustResetOpaque = true; JComponent jc = (JComponent) c; - savedOpaque = jc.isOpaque(); + jc.isOpaque(); jc.setOpaque(true); - paintFocus = true; } } else { c.setForeground(comboBox.getForeground()); diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java index 1513eb6e95..2a5c29d8c8 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java @@ -1,12 +1,11 @@ package com.fr.design.gui.icontainer; -import com.fr.base.BaseUtils; -import com.fr.base.vcs.DesignerMode; + +import com.fr.design.base.mode.DesignModeContext; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.stable.Constants; import javax.swing.*; import java.awt.*; @@ -174,6 +173,7 @@ public class UIEastResizableContainer extends JPanel { @Override public void addLayoutComponent(String name, Component comp) { + // do nothing } }; @@ -238,6 +238,7 @@ public class UIEastResizableContainer extends JPanel { * 伸缩右子面板时,触发此方法 */ public void onResize() { + // do nothing here } private class TopToolPane extends JPanel { @@ -261,6 +262,7 @@ public class UIEastResizableContainer extends JPanel { @Override public void mouseDragged(MouseEvent e) { + // do nothing } }); addMouseListener(new MouseAdapter() { @@ -282,7 +284,7 @@ public class UIEastResizableContainer extends JPanel { } onResize(); refreshContainer(); - if (DesignerMode.isAuthorityEditing()) { + if (DesignModeContext.isAuthorityEditing()) { DesignerContext.getDesignerFrame().doResize(); } } diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIModeControlContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIModeControlContainer.java index eadb94109f..a589b0c878 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIModeControlContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIModeControlContainer.java @@ -1,6 +1,7 @@ package com.fr.design.gui.icontainer; import com.fr.base.vcs.DesignerMode; +import com.fr.design.base.mode.DesignModeContext; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; @@ -46,7 +47,7 @@ public class UIModeControlContainer extends JLayeredPane { private boolean isHideMode = false; private boolean isSheeetCovered = false; - private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 30 / 100.0F); + private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f); public UIModeControlContainer() { this(new JPanel(), new JPanel()); @@ -85,7 +86,7 @@ public class UIModeControlContainer extends JLayeredPane { public void needToShowCoverAndHidPane() { - if (DesignerMode.isAuthorityEditing()) { + if (DesignModeContext.isAuthorityEditing()) { this.remove(coverPane); this.remove(hidePane); } else { @@ -128,7 +129,7 @@ public class UIModeControlContainer extends JLayeredPane { if (isHideMode || !upEditMode) { return; } - if (DesignerMode.isAuthorityEditing()) { + if (DesignModeContext.isAuthorityEditing()) { return; } setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR)); @@ -151,11 +152,12 @@ public class UIModeControlContainer extends JLayeredPane { MouseMotionListener mouseMotionListener = new MouseMotionListener() { @Override public void mouseMoved(MouseEvent e) { + //do nothing } @Override public void mouseDragged(MouseEvent e) { - if (DesignerMode.isAuthorityEditing()) { + if (DesignModeContext.isAuthorityEditing()) { return; } boolean notUpEditMode = isHideMode || !upEditMode; @@ -174,7 +176,7 @@ public class UIModeControlContainer extends JLayeredPane { @Override public void removeLayoutComponent(Component comp) { - + //do nothing } @Override @@ -234,11 +236,12 @@ public class UIModeControlContainer extends JLayeredPane { @Override public void addLayoutComponent(String name, Component comp) { + // do nothing } }; protected void onModeChanged() { - + //do nothing here } /** @@ -309,7 +312,7 @@ public class UIModeControlContainer extends JLayeredPane { addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - + // do nothing } }); } @@ -319,6 +322,7 @@ public class UIModeControlContainer extends JLayeredPane { @Override public void removeLayoutComponent(Component comp) { + // do nothing } @Override @@ -333,10 +337,12 @@ public class UIModeControlContainer extends JLayeredPane { @Override public void layoutContainer(Container parent) { + // do nothing } @Override public void addLayoutComponent(String name, Component comp) { + // do nothing } }; @@ -366,7 +372,7 @@ public class UIModeControlContainer extends JLayeredPane { addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - + // do nothing } }); @@ -407,6 +413,7 @@ public class UIModeControlContainer extends JLayeredPane { @Override public void removeLayoutComponent(Component comp) { + // do nothing } @Override @@ -437,6 +444,7 @@ public class UIModeControlContainer extends JLayeredPane { @Override public void addLayoutComponent(String name, Component comp) { + // do nothing } }; diff --git a/designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java b/designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java index 432628f0fa..ebccd24f45 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java +++ b/designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java @@ -1,5 +1,6 @@ package com.fr.design.gui.ilable; +import javax.swing.event.MouseInputAdapter; import java.awt.Color; import java.awt.Cursor; import java.awt.Graphics; @@ -7,9 +8,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; -import com.fr.design.gui.ilable.UILabel; -import javax.swing.event.MouseInputAdapter; - /** * Action label */ @@ -31,6 +29,7 @@ public class ActionLabel extends UILabel { /** * Repaints the text. */ + @Override public void paintComponent(Graphics _gfx) { super.paintComponent(_gfx); @@ -39,12 +38,17 @@ public class ActionLabel extends UILabel { } private MouseInputAdapter mouseInputAdapter = new MouseInputAdapter() { + @Override public void mouseClicked(MouseEvent e) { + //do nothing } + @Override public void mousePressed(MouseEvent e) { + //do nothing } + @Override public void mouseReleased(MouseEvent evt) { Object source = evt.getSource(); @@ -65,6 +69,7 @@ public class ActionLabel extends UILabel { } } + @Override public void mouseExited(MouseEvent evt) { Object source = evt.getSource(); @@ -73,6 +78,7 @@ public class ActionLabel extends UILabel { } } + @Override public void mouseDragged(MouseEvent e) { } diff --git a/designer-base/src/main/java/com/fr/design/gui/imenu/UIBasicMenuItemUI.java b/designer-base/src/main/java/com/fr/design/gui/imenu/UIBasicMenuItemUI.java index 844120c51b..a14de81c55 100644 --- a/designer-base/src/main/java/com/fr/design/gui/imenu/UIBasicMenuItemUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/imenu/UIBasicMenuItemUI.java @@ -287,7 +287,7 @@ public class UIBasicMenuItemUI extends MenuItemUI { View v = (View) c.getClientProperty(BasicHTML.propertyKey); if (v != null) { d = getPreferredSize(c); - d.width -= v.getPreferredSpan(View.X_AXIS) - v.getMinimumSpan(View.X_AXIS); + d.width -= (double) v.getPreferredSpan(View.X_AXIS) - (double) v.getMinimumSpan(View.X_AXIS); } return d; } @@ -345,7 +345,7 @@ public class UIBasicMenuItemUI extends MenuItemUI { View v = (View) c.getClientProperty(BasicHTML.propertyKey); if (v != null) { d = getPreferredSize(c); - d.width += v.getMaximumSpan(View.X_AXIS) - v.getPreferredSpan(View.X_AXIS); + d.width += (double) v.getMaximumSpan(View.X_AXIS) - (double) v.getPreferredSpan(View.X_AXIS); } return d; } @@ -816,7 +816,6 @@ public class UIBasicMenuItemUI extends MenuItemUI { // get Accelerator text KeyStroke accelerator = b.getAccelerator(); String acceleratorText = ""; - drawMenu(acceleratorText, accelerator, c, ic, maxValue, offset, paintIcon, b); String text = layoutMenuItem(fm, b.getText(), fmAccel, acceleratorText, ic, null, arrowIcon, b.getVerticalAlignment(), b.getHorizontalAlignment(), b.getVerticalTextPosition(), b.getHorizontalTextPosition(), viewRect, @@ -834,43 +833,6 @@ public class UIBasicMenuItemUI extends MenuItemUI { g.setFont(holdf); } - private void drawMenu(String acceleratorText, KeyStroke accelerator, JComponent c, - Icon ic, int maxValue, int offset, Icon paintIcon, JMenuItem b) { - if (accelerator != null) { - int modifiers = accelerator.getModifiers(); - if (modifiers > 0) { - acceleratorText = KeyEvent.getKeyModifiersText(modifiers); - //acceleratorText += "-"; - acceleratorText += acceleratorDelimiter; - } - - int keyCode = accelerator.getKeyCode(); - if (keyCode != 0) { - acceleratorText += KeyEvent.getKeyText(keyCode); - } else { - acceleratorText += accelerator.getKeyChar(); - } - } - if (!isTopLevelMenu()) { - if (c instanceof JCheckBoxMenuItem || c instanceof JRadioButtonMenuItem) { - ic = checkIcon; - if (checkIcon.getIconWidth() < maxValue) { - ic = new EmptyIcon(maxValue, checkIcon.getIconHeight()); - offset = (maxValue - checkIcon.getIconWidth()) / 2; - } - paintIcon = null; - } else if (c instanceof JMenuItem) { - if (ic == null || ic.getIconWidth() < maxValue) { - int height = (ic == null) ? 2 : b.getIcon().getIconHeight(); - int width = (ic == null) ? 2 : b.getIcon().getIconWidth(); - offset = (maxValue - width) / 2; - ic = new EmptyIcon(maxValue, height); - } - } - } - } - - private void drawAccText(String acceleratorText, Graphics g, JComponent p, ButtonModel model, FontMetrics fmAccel, JComponent c) { if (acceleratorText != null && !ComparatorUtils.equals(acceleratorText, "")) { //Get the maxAccWidth from the parent to calculate the offset. diff --git a/designer-base/src/main/java/com/fr/design/gui/imenutable/UIMenuTable.java b/designer-base/src/main/java/com/fr/design/gui/imenutable/UIMenuTable.java index d950e91ed7..938e0caccc 100644 --- a/designer-base/src/main/java/com/fr/design/gui/imenutable/UIMenuTable.java +++ b/designer-base/src/main/java/com/fr/design/gui/imenutable/UIMenuTable.java @@ -157,8 +157,7 @@ public class UIMenuTable extends JTable { @Override public TableCellRenderer getDefaultRenderer(Class columnClass) { - columnClass = UITable.class; - return super.getDefaultRenderer(columnClass); + return super.getDefaultRenderer(UITable.class); } private class UITableRender implements TableCellRenderer { diff --git a/designer-base/src/main/java/com/fr/design/gui/imenutable/UIMenuTableUI.java b/designer-base/src/main/java/com/fr/design/gui/imenutable/UIMenuTableUI.java index 8dc90f10bb..32b33cbab2 100644 --- a/designer-base/src/main/java/com/fr/design/gui/imenutable/UIMenuTableUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/imenutable/UIMenuTableUI.java @@ -10,6 +10,7 @@ import javax.swing.event.MouseInputListener; import com.fr.base.GraphHelper; import com.fr.design.constants.UIConstants; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.itable.UITableUI; import com.fr.design.mainframe.DesignerContext; @@ -74,7 +75,7 @@ public class UIMenuTableUI extends UITableUI{ @Override public void mousePressed(MouseEvent e) { if (e.getX() >= table.getWidth() - 20) { - int val = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + "?", + int val = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (val == JOptionPane.OK_OPTION) { uiTable.removeLine(table.rowAtPoint(e.getPoint())); diff --git a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/UIProgressBorder.java b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/UIProgressBorder.java index c4df50e82a..30074f5638 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/UIProgressBorder.java +++ b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/UIProgressBorder.java @@ -72,6 +72,7 @@ public class UIProgressBorder extends UIRoundedBorder { g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } + @SuppressWarnings("squid:S2164") private void paintBorderShadow(Graphics2D g2, int shadowWidth, int x, int y, int width, int height) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); shadowWidth = Math.max(shadowWidth, 2); @@ -85,6 +86,7 @@ public class UIProgressBorder extends UIRoundedBorder { } } + @SuppressWarnings("squid:S2164") private static Color getMixedColor(Color c1, float pct1, Color c2, float pct2) { float[] clr1 = c1.getComponents(null); float[] clr2 = c2.getComponents(null); diff --git a/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIBasicScrollBarUI.java b/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIBasicScrollBarUI.java index 851f907977..821ebbc335 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIBasicScrollBarUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIBasicScrollBarUI.java @@ -165,50 +165,6 @@ public class UIBasicScrollBarUI extends BasicScrollBarUI { // drawColorAndLength(g, t, x2, y2, color); } - private void drawColorAndLength(Graphics g, Rectangle t, int x2, int y2, Color color) { - - if (scrollbar.getOrientation() == JScrollBar.VERTICAL) { - int y1 = t.y + (t.height) / 2 - 4; - y2 = Math.min(y1 + 8, t.y + t.height - 5); - - int y = y1; - // we take only saturation & brightness and apply them - // to the background color (normal/rollover/pressed) - g.setColor(UISBChooser.getAdjustedColor(color, 0, 71)); - while (y < y2) { - g.drawLine(5, y, 11, y); - y += 2; - } - - y = y1 + 1; - g.setColor(UISBChooser.getAdjustedColor(color, 0, -13)); - while (y < y2) { - g.drawLine(6, y, 12, y); - y += 2; - } - } else { - int x1 = t.x + (t.width) / 2 - 4; - x2 = Math.min(x1 + 8, t.x + t.width - 5); - - int x = x1 + 1; - // we take only saturation & brightness and apply them - // to the background color (normal/rollover/pressed) - g.setColor(UISBChooser.getAdjustedColor(color, 0, 71)); - while (x < x2) { - g.drawLine(x, 5, x, 11); - x += 2; - } - - x = x1; - g.setColor(UISBChooser.getAdjustedColor(color, 0, -13)); - while (x < x2) { - g.drawLine(x, 6, x, 12); - x += 2; - } - } - } - - private void drawVertical(Graphics g, Rectangle t, int xs, int ys, int x2, Color pressedColor, Color rolloverColor, Color normalColor) { diff --git a/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UISBChooser.java b/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UISBChooser.java index a6ba742830..c780eeb2d7 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UISBChooser.java +++ b/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UISBChooser.java @@ -90,6 +90,7 @@ public class UISBChooser extends JDialog { (frame.getHeight() - getSize().height) / 2); } + @SuppressWarnings("squid:S1226") private void initP3(JPanel p3, JPanel p1) { p3 = new JPanel(new FlowLayout(FlowLayout.LEFT, 3, 8)); p3.add(new JLabel("R:")); @@ -198,6 +199,7 @@ public class UISBChooser extends JDialog { twoColorField.setUpperColor(outColor); } + @SuppressWarnings("squid:S2164") public static Color getAdjustedColor(Color inColor, int sat, int bri) { Color briColor = inColor; @@ -219,9 +221,9 @@ public class UISBChooser extends JDialog { int dg = briColor.getGreen() - satColor.getGreen(); int db = briColor.getBlue() - satColor.getBlue(); - r = briColor.getRed() - (int) Math.round(dr * sat / VALUE * 1.0); - g = briColor.getGreen() - (int) Math.round(dg * sat / VALUE * 1.0); - b = briColor.getBlue() - (int) Math.round(db * sat / VALUE * 1.0); + r = briColor.getRed() - (int) Math.round(dr * sat / (VALUE * 1.0)); + g = briColor.getGreen() - (int) Math.round(dg * sat / (VALUE * 1.0)); + b = briColor.getBlue() - (int) Math.round(db * sat / (VALUE * 1.0)); } else { float d = ColorRoutines.getGreyValue(briColor); float dr = briColor.getRed() - d; diff --git a/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java b/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java index d3393054ae..949b3958ae 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java @@ -2,6 +2,25 @@ package com.fr.design.gui.iscrollbar; import com.fr.design.constants.UIConstants; import com.fr.stable.StringUtils; +import sun.swing.DefaultLookup; + +import javax.swing.BoundedRangeModel; +import javax.swing.InputMap; +import javax.swing.JComponent; +import javax.swing.JList; +import javax.swing.JScrollBar; +import javax.swing.JScrollPane; +import javax.swing.JViewport; +import javax.swing.LookAndFeel; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; +import javax.swing.Timer; +import javax.swing.UIManager; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.ScrollBarUI; +import javax.swing.plaf.UIResource; import java.awt.Color; import java.awt.Component; import java.awt.Container; @@ -22,24 +41,6 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import javax.swing.BoundedRangeModel; -import javax.swing.InputMap; -import javax.swing.JComponent; -import javax.swing.JList; -import javax.swing.JScrollBar; -import javax.swing.JScrollPane; -import javax.swing.JViewport; -import javax.swing.LookAndFeel; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; -import javax.swing.Timer; -import javax.swing.UIManager; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.ScrollBarUI; -import javax.swing.plaf.UIResource; -import sun.swing.DefaultLookup; /** * Like BasicScrollBarUI,but without two buttons @@ -590,6 +591,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo * will cause a repaint. */ + @SuppressWarnings("squid:S2164") protected void layoutVScrollbar(JScrollBar sb) { Dimension sbSize = sb.getSize(); Insets sbInsets = sb.getInsets(); @@ -672,6 +674,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo * Make sure the thumb fits between the buttons. Note that setting the * thumbs bounds causes a repaint. */ + @SuppressWarnings("squid:S2164") protected void layoutHScrollbar(JScrollBar sb) { Dimension sbSize = sb.getSize(); Insets sbInsets = sb.getInsets(); @@ -1080,7 +1083,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo scrollbar.repaint(); } - + @SuppressWarnings("squid:S2164") private void setValueFrom(MouseEvent e) { boolean active = isThumbRollover(); BoundedRangeModel model = scrollbar.getModel(); diff --git a/designer-base/src/main/java/com/fr/design/gui/itable/UITable.java b/designer-base/src/main/java/com/fr/design/gui/itable/UITable.java index ca214c4241..e5dcd7fd14 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itable/UITable.java +++ b/designer-base/src/main/java/com/fr/design/gui/itable/UITable.java @@ -291,8 +291,7 @@ public class UITable extends JTable implements UIObserver { * */ public TableCellEditor getDefaultEditor(Class columnClass) { - columnClass = UITable.class; - return super.getDefaultEditor(columnClass); + return super.getDefaultEditor(UITable.class); } @Override @@ -300,8 +299,7 @@ public class UITable extends JTable implements UIObserver { * */ public TableCellRenderer getDefaultRenderer(Class columnClass) { - columnClass = UITable.class; - return super.getDefaultRenderer(columnClass); + return super.getDefaultRenderer(UITable.class); } /** diff --git a/designer-base/src/main/java/com/fr/design/gui/itable/UITableUI.java b/designer-base/src/main/java/com/fr/design/gui/itable/UITableUI.java index 370ceacb8f..71e80027c3 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itable/UITableUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/itable/UITableUI.java @@ -19,6 +19,7 @@ import javax.swing.table.TableModel; import com.fr.base.BaseUtils; import com.fr.design.constants.UIConstants; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.mainframe.DesignerContext; import com.fr.stable.Constants; @@ -132,7 +133,7 @@ public class UITableUI extends BasicTableUI { return; } if (!table.isEditing()) { - int val = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + "?", + int val = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (val == JOptionPane.OK_OPTION) { ((UITable) table).removeLine(table.rowAtPoint(e.getPoint())); diff --git a/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java b/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java index 0ec8fe90c6..fc219a30bc 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java +++ b/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java @@ -1,6 +1,7 @@ package com.fr.design.gui.itableeditorpane; import com.fr.base.BaseUtils; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.mainframe.DesignerContext; import com.fr.log.FineLoggerFactory; @@ -207,7 +208,7 @@ public abstract class UITableModelAdapter extends AbstractTabl public void actionPerformed(ActionEvent e) { final int selectedRow = table.getSelectedRow(); if (selectedRow > table.getRowCount() - 1 || selectedRow < 0) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No-Alternatives")); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No-Alternatives")); return; } stopCellEditing(); @@ -251,7 +252,7 @@ public abstract class UITableModelAdapter extends AbstractTabl if(component == null){ component = DesignerContext.getDesignerFrame(); } - int val = JOptionPane.showConfirmDialog(component, + int val = FineJOptionPane.showConfirmDialog(component, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (val != JOptionPane.OK_OPTION) { diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/TextFieldUI.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/TextFieldUI.java deleted file mode 100644 index 2d0891181e..0000000000 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/TextFieldUI.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.fr.design.gui.itextfield; - -import java.awt.Graphics; - -import javax.swing.plaf.metal.MetalTextFieldUI; -import javax.swing.text.JTextComponent; - -import de.muntjak.tinylookandfeel.Theme; - -public class TextFieldUI extends MetalTextFieldUI { - - - protected void paintBackground(Graphics g) { - JTextComponent editor = getComponent(); - // We will only be here if editor is opaque, so we don't have to test - - if(editor.isEnabled()) { - if(editor.isEditable()) { - g.setColor(editor.getBackground()); - } - else { - // not editable - if(editor.getBackground().equals(Theme.textBgColor[Theme.style].getColor())) { - // set default panel background - g.setColor(Theme.backColor[Theme.style].getColor()); - } - else { - // color changed by user - set textfield background - g.setColor(editor.getBackground()); - } - } - - g.fillRect(0, 0, editor.getWidth(), editor.getHeight()); - } - else { - if(editor.getBackground().equals(Theme.textBgColor[Theme.style].getColor())) { - g.setColor(Theme.textDisabledBgColor[Theme.style].getColor()); - } - else { - // color changed by user - set textfield background - g.setColor(editor.getBackground()); - } - - g.fillRect(0, 0, editor.getWidth(), editor.getHeight()); - - if(Theme.style != Theme.YQ_STYLE) return; - - g.setColor(Theme.backColor[Theme.style].getColor()); - g.drawRect(1, 1, editor.getWidth() - 3, editor.getHeight() - 3); - g.drawRect(2, 2, editor.getWidth() - 5, editor.getHeight() - 5); - } - } -} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java b/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java index 9bbca6d2bc..b188cb5aa8 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java @@ -102,7 +102,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO {IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal_white.png")}, {IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment_white.png")}}; Integer[] hAlignment = new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT, Integer.valueOf(Constants.DISTRIBUTED), Constants.NULL}; - hAlignmentPane = new UIButtonGroup(hAlignmentIconArray, hAlignment); + hAlignmentPane = new UIButtonGroup<>(hAlignmentIconArray, hAlignment); hAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Left"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Right"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Distributed"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_DEFAULT")}); hPaneContainer = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); @@ -112,7 +112,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO {IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal_white.png")}, {IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal_white.png")}}; Integer[] vAlignment = new Integer[]{Constants.TOP, Constants.CENTER, Constants.BOTTOM}; - vAlignmentPane = new UIButtonGroup(vAlignmentIconArray, vAlignment); + vAlignmentPane = new UIButtonGroup<>(vAlignmentIconArray, vAlignment); vAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Top"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Bottom")}); initOtherComponent(); initAllNames(); @@ -174,7 +174,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO } private void initTextRotationCombox() { - ArrayList selectOption = new ArrayList(); + ArrayList selectOption = new ArrayList<>(); selectOption.add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Angle")); VerticalTextProcessor processor = ExtraClassManager.getInstance().getSingle(VerticalTextProcessor.XML_TAG, DefaultVerticalTextProcessor.class); selectOption.addAll(Arrays.asList(processor.getComboxOption())); @@ -343,8 +343,8 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO int rightPadding = indentationUnitProcessor.paddingUnitProcessor(style.getPaddingRight()); // alex:indent - this.leftIndentSpinner.setValue(new Integer(leftPadding)); - this.rightIndentSpinner.setValue(new Integer(rightPadding)); + this.leftIndentSpinner.setValue(leftPadding); + this.rightIndentSpinner.setValue(rightPadding); this.spaceBeforeSpinner.setValue(style.getSpacingBefore()); this.spaceAfterSpinner.setValue(style.getSpacingAfter()); @@ -360,7 +360,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO public Style update(Style style) { // peter:需要判断传递进来的值是否为null. if (style == null) { - return style; + return null; } if (ComparatorUtils.equals(globalNameListener.getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Pane_Horizontal"))) { @@ -463,7 +463,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO } /** - * @param name + * @param name 全局名 */ public void setGlobalName(String name) { } diff --git a/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java b/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java index 795c6d455a..cf362f7f5e 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java @@ -6,6 +6,7 @@ import com.fr.base.Style; import com.fr.base.TextFormat; import com.fr.data.core.FormatField; import com.fr.data.core.FormatField.FormatContents; +import com.fr.design.i18n.Toolkit; import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; @@ -36,20 +37,23 @@ import java.text.SimpleDateFormat; * @author zhou * @since 2012-5-24上午10:57:00 */ -public class FormatPane extends AbstractBasicStylePane implements GlobalNameObserver { +public class FormatPane extends AbstractBasicStylePane implements GlobalNameObserver { private static final long serialVersionUID = 724330854437726751L; - private static final int LABLE_X = 4; - private static final int LABLE_Y = 18; - private static final int LABLE_DELTA_WIDTH = 8; - private static final int LABLE_HEIGHT = 15; //标签背景的范围 + private static final int LABEL_X = 4; + private static final int LABEL_Y = 18; + private static final int LABEL_DELTA_WIDTH = 8; + private static final int LABEL_HEIGHT = 15; //标签背景的范围 private static final int CURRENCY_FLAG_POINT = 6; - private static final Border LEFT_BORDER = BorderFactory.createEmptyBorder(0,30,0,0); + private static final Border LEFT_BORDER = BorderFactory.createEmptyBorder(0, 30, 0, 0); - private static final Integer[] TYPES = new Integer[]{FormatContents.NULL, FormatContents.NUMBER, FormatContents.CURRENCY, FormatContents.PERCENT, FormatContents.SCIENTIFIC, - FormatContents.DATE, FormatContents.TIME, FormatContents.TEXT}; + private static final Integer[] TYPES = new Integer[]{ + FormatContents.NULL, FormatContents.NUMBER, + FormatContents.CURRENCY, FormatContents.PERCENT, + FormatContents.SCIENTIFIC, FormatContents.DATE, + FormatContents.TIME, FormatContents.TEXT}; - private static final Integer[] DATETYPES = new Integer[]{FormatContents.NULL, FormatContents.DATE, FormatContents.TIME,}; + private static final Integer[] DATE_TYPES = new Integer[]{FormatContents.NULL, FormatContents.DATE, FormatContents.TIME}; private Format format; @@ -61,7 +65,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs private JPanel centerPane; private JPanel formatFontPane; private FRFontPane frFontPane; - private boolean isRightFormate; + private boolean isRightFormat; private boolean isDate = false; private GlobalNameListener globalNameListener = null; @@ -78,7 +82,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs protected void initComponents(Integer[] types) { this.setLayout(new BorderLayout(0, 4)); - iniSampleLable(); + initSampleLabel(); contentPane = new JPanel(new BorderLayout(0, 4)) { @Override public Dimension getPreferredSize() { @@ -108,7 +112,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs frFontPane = new FRFontPane(); - UILabel font = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FR_Font"), SwingConstants.LEFT); + UILabel font = new UILabel(Toolkit.i18nText("Fine-Design_Form_FR_Font"), SwingConstants.LEFT); JPanel fontPane = new JPanel(new BorderLayout()); fontPane.add(font, BorderLayout.NORTH); @@ -136,7 +140,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane) { return new Component[][]{ new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format"), SwingConstants.LEFT), typePane}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Format"), SwingConstants.LEFT), typePane}, new Component[]{centerPane, null}, new Component[]{fontPane, frFontPane}, }; @@ -155,24 +159,24 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs }; } - private void iniSampleLable() { - Border innterborder = new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 4); - Font tmpFont = null; - Border border = BorderFactory.createTitledBorder(innterborder, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_StyleFormat_Sample"), TitledBorder.LEFT, 0, tmpFont, UIConstants.LINE_COLOR); + private void initSampleLabel() { + Border interBorder = new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 4); + String title = Toolkit.i18nText("Fine-Design_Report_Base_StyleFormat_Sample"); + Border border = BorderFactory.createTitledBorder(interBorder, title, TitledBorder.LEFT, 0, null, UIConstants.LINE_COLOR); sampleLabel = new UILabel(FormatField.getInstance().getFormatValue()) { @Override public void paint(Graphics g) { super.paint(g); int width = getWidth(); - Color orignal = g.getColor(); + Color original = g.getColor(); g.setColor(getBackground()); - g.fillRect(LABLE_X, LABLE_Y, width - LABLE_DELTA_WIDTH, LABLE_HEIGHT); + g.fillRect(LABEL_X, LABEL_Y, width - LABEL_DELTA_WIDTH, LABEL_HEIGHT); g.setColor(UIConstants.LINE_COLOR); FontMetrics cellFM = g.getFontMetrics(); int textWidth = cellFM.stringWidth(getText()); GraphHelper.drawString(g, getText(), (width - textWidth) / 2, 26); - g.setColor(orignal); + g.setColor(original); } }; sampleLabel.setHorizontalAlignment(UILabel.CENTER); @@ -197,7 +201,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs * @return 标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Text"); + return Toolkit.i18nText("Fine-Design_Report_Text"); } /** @@ -212,13 +216,9 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs if (format instanceof CoreDecimalFormat) { // check all value String pattern = ((CoreDecimalFormat) format).toPattern(); - boolean isCurrency1 = (pattern.length() > 0 && pattern.charAt(0) == '¤'); - boolean isCurrency2 = (pattern.length() > 0 && pattern.charAt(0) == '$'); - boolean isCurrency = isCurrency1 || isCurrency2; - boolean isCurrency4 = (pattern.length() > CURRENCY_FLAG_POINT && ComparatorUtils.equals(pattern.substring(0, CURRENCY_FLAG_POINT), "#,##0;")); - if (isCurrency || isCurrency4) { + if (isCurrencyFormatStyle(pattern)) { setPatternComboBoxAndList(FormatContents.CURRENCY, pattern); - } else if (pattern.endsWith("%")) { + } else if (pattern.indexOf("%") > 0) { setPatternComboBoxAndList(FormatContents.PERCENT, pattern); } else if (pattern.indexOf("E") > 0) { setPatternComboBoxAndList(FormatContents.SCIENTIFIC, pattern); @@ -238,6 +238,17 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs } } + private boolean isCurrencyFormatStyle(String pattern) { + if (pattern.length() == 0) { + return false; + } + + if (pattern.charAt(0) == '¤' || pattern.charAt(0) == '$') { + return true; + } + + return pattern.length() > CURRENCY_FLAG_POINT && pattern.startsWith("#,##0;"); + } /** * 判断是否是数组有模式 @@ -273,7 +284,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs if (getFormatContents() == FormatContents.TEXT) { return FormatField.getInstance().getFormat(getFormatContents(), patternString); } - if (isRightFormate) { + if (isRightFormat) { if (StringUtils.isNotEmpty(patternString)) { return FormatField.getInstance().getFormat(getFormatContents(), patternString); } @@ -292,7 +303,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs this.sampleLabel.setText(FormatField.getInstance().getFormatValue()); this.sampleLabel.setForeground(UIManager.getColor("Label.foreground")); try { - isRightFormate = true; + isRightFormat = true; if (StringUtils.isEmpty(String.valueOf(textField.getSelectedItem()))) { return; } @@ -300,7 +311,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs } catch (Exception e) { this.sampleLabel.setForeground(Color.red); this.sampleLabel.setText(e.getMessage()); - isRightFormate = false; + isRightFormat = false; } } @@ -401,8 +412,8 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs this.isDate = isDate; this.typeComboBox.setSelectedIndex(0); if (isDate) { - for (int i = 0; i < DATETYPES.length; i++) { - this.typeComboBox.addItem(DATETYPES[i]); + for (int i = 0; i < DATE_TYPES.length; i++) { + this.typeComboBox.addItem(DATE_TYPES[i]); } for (int i = 0; i < TYPES.length; i++) { this.typeComboBox.removeItemAt(1); @@ -411,7 +422,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs for (int i = 0; i < TYPES.length; i++) { this.typeComboBox.addItem(TYPES[i]); } - for (int i = 0; i < DATETYPES.length; i++) { + for (int i = 0; i < DATE_TYPES.length; i++) { this.typeComboBox.removeItemAt(1); } } diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/print/RPrintUtilities.java b/designer-base/src/main/java/com/fr/design/gui/syntax/print/RPrintUtilities.java index 352676010c..749bf45408 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/print/RPrintUtilities.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/print/RPrintUtilities.java @@ -9,6 +9,8 @@ */ package com.fr.design.gui.syntax.print; +import com.fr.log.FineLoggerFactory; + import javax.swing.text.BadLocationException; import javax.swing.text.Document; import javax.swing.text.Element; @@ -62,8 +64,8 @@ public abstract class RPrintUtilities { private static int getLineBreakPoint(String line, final int maxCharsPerLine) { int breakPoint = -1; - for (int i=0; i breakPoint) breakPoint = breakCharPos; } @@ -147,11 +149,11 @@ public abstract class RPrintUtilities { int tabIndex = curLineString.indexOf('\t'); while (tabIndex > -1) { int spacesNeeded = tabSizeInSpaces - (tabIndex % tabSizeInSpaces); - String replacementString = ""; + StringBuilder replacementString = new StringBuilder(); for (int i=0; i-1 && pos>currentPos) // currentPos = pos; - if (pos>0 && pos>currentPos & pos!=currentLineString.length()) + if (pos > 0 && pos > currentPos & pos != currentLineString.length()) currentPos = pos; } @@ -440,7 +442,7 @@ public abstract class RPrintUtilities { try { doc.getText(currentLineStart+startingOffset, currentPos, currentLineSeg); } catch (BadLocationException ble) { - System.err.println(ble); + FineLoggerFactory.getLogger().error(ble.getMessage()); return Printable.NO_SUCH_PAGE; } currentLineLengthInPixels = Utilities. @@ -453,12 +455,11 @@ public abstract class RPrintUtilities { try { doc.getText((currentLineStart+startingOffset), currentPos, currentLineSeg); } catch (BadLocationException ble) { - System.err.println("BadLocationException in print (a):"); - System.err.println("==> currentLineStart: " + currentLineStart + - "; startingOffset: " + startingOffset + "; currentPos: " + currentPos); - System.err.println("==> Range: " + (currentLineStart+startingOffset) + " - " + - (currentLineStart+startingOffset+currentPos)); - ble.printStackTrace(); + FineLoggerFactory.getLogger().error("BadLocationException in print (a):" + "==> currentLineStart: " + currentLineStart + + "; startingOffset: " + startingOffset + "; currentPos: " + currentPos + + "==> Range: " + (currentLineStart+startingOffset) + " - " + + (currentLineStart+startingOffset+currentPos)); + FineLoggerFactory.getLogger().error(ble.getMessage()); return Printable.NO_SUCH_PAGE; } @@ -521,7 +522,8 @@ public abstract class RPrintUtilities { return x; int tabSizeInPixels = tabSizeInSpaces * fm.charWidth(' '); int ntabs = (((int) x) - xOffset) / tabSizeInPixels; - return xOffset + ((ntabs + 1) * tabSizeInPixels); + double reFloat = (double) xOffset + (double) ((ntabs + 1) * tabSizeInPixels); + return (float) reFloat; } } diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxUtilities.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxUtilities.java index ddb3ddfa3c..596c5d9bd9 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxUtilities.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxUtilities.java @@ -518,6 +518,8 @@ public class RSyntaxUtilities implements SwingConstants { } numEmbedded--; } + } else { + //do nothing } } // End of for (int i=segOffset; i { token = null; } } + else { + throw new NoSuchElementException(); + } return t; } diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java index e99208afc0..97e367ef0c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java @@ -268,7 +268,7 @@ public class WrappedSyntaxView extends BoxView implements TabExpander, if (host.getEOLMarkersVisible()) { g.setColor(host.getForegroundForTokenType(Token.WHITESPACE)); g.setFont(host.getFontForTokenType(Token.WHITESPACE)); - g.drawString("\u00B6", x, y-fontHeight); + g.drawString("\u00B6", x, (float) (y-fontHeight)); } } @@ -458,7 +458,7 @@ public class WrappedSyntaxView extends BoxView implements TabExpander, if (host.getEOLMarkersVisible()) { g.setColor(host.getForegroundForTokenType(Token.WHITESPACE)); g.setFont(host.getFontForTokenType(Token.WHITESPACE)); - g.drawString("\u00B6", x, y-fontHeight); + g.drawString("\u00B6", x, (float) (y-fontHeight)); } } @@ -841,10 +841,11 @@ public class WrappedSyntaxView extends BoxView implements TabExpander, * @return the tab stop, measured in points >= 0 */ public float nextTabStop(float x, int tabOffset) { - if (tabSize == 0) + if (tabSize == 0) { return x; + } int ntabs = ((int) x - tabBase) / tabSize; - return tabBase + ((ntabs + 1) * tabSize); + return (float) (tabBase + ((ntabs + 1) * tabSize)); } diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/folding/HtmlFoldParser.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/folding/HtmlFoldParser.java index 79d8da0a30..41f51215c7 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/folding/HtmlFoldParser.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/folding/HtmlFoldParser.java @@ -172,7 +172,7 @@ public class HtmlFoldParser implements FoldParser { // Continuing an MLC from a previous line if (inMLC) { // Found the end of the MLC starting on a previous line... - if (t.endsWith(MLC_END)) { + if (currentFold != null && t.endsWith(MLC_END)) { int mlcEnd = t.getEndOffset() - 1; currentFold.setEndOffset(mlcEnd); Fold parentFold = currentFold.getParent(); diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/FormulaTokenMaker.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/FormulaTokenMaker.java index aae7216734..98b5265c39 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/FormulaTokenMaker.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/FormulaTokenMaker.java @@ -18,6 +18,7 @@ import java.io.IOException; * on 9/18/19 6:12 PM from the specification file * /Users/3dot141/Downloads/FolxDownload/App/jflex-1.4.1/bin/FormulaTokenMaker.flex */ +@SuppressWarnings("squid:S1192") public class FormulaTokenMaker extends AbstractJFlexCTokenMaker { /** This character denotes the end of file */ diff --git a/designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperlinkPane.java b/designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperlinkPane.java index 532fe467c3..7147ef90e2 100644 --- a/designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperlinkPane.java +++ b/designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperlinkPane.java @@ -2,6 +2,7 @@ package com.fr.design.hyperlink; import com.fr.base.BaseUtils; import com.fr.base.Parameter; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.frpane.ReportletParameterViewPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.itableeditorpane.ParameterTableModel; @@ -122,7 +123,7 @@ public class ReportletHyperlinkPane extends AbstractHyperLinkPane j ? i : j; + double x = Math.max(i,j); if (AssistUtils.equals(x, i)) { w = (int) (Math.round(m) * WIDTH_PARA_INT - WIDTH_OFFSET_M); } else if (AssistUtils.equals(x, j)) { diff --git a/designer-base/src/main/java/com/fr/design/layout/TableLayout.java b/designer-base/src/main/java/com/fr/design/layout/TableLayout.java index f8134be1fd..2cf288da63 100644 --- a/designer-base/src/main/java/com/fr/design/layout/TableLayout.java +++ b/designer-base/src/main/java/com/fr/design/layout/TableLayout.java @@ -1747,7 +1747,7 @@ public class TableLayout implements LayoutManager2, Serializable { for (counter = 0; counter < numCr; counter++) if ((crSpec[z][counter] > 0.0) && (crSpec[z][counter] < 1.0)) fillSizeRatio -= crSpec[z][counter]; - else if (crSpec[z][counter] == FILL) + else if (AssistUtils.equals(crSpec[z][counter], FILL)) numFillSize++; // Adjust fill ratios to reflect number of fill rows/columns @@ -1773,8 +1773,8 @@ public class TableLayout implements LayoutManager2, Serializable { int crPrefMin[] = new int[numCr]; for (counter = 0; counter < numCr; counter++) - if ((crSpec[z][counter] == PREFERRED) || - (crSpec[z][counter] == MINIMUM)) { + if ((AssistUtils.equals(crSpec[z][counter], PREFERRED)) || + (AssistUtils.equals(crSpec[z][counter], MINIMUM))) { crPrefMin[counter] = crSize[z][counter]; } diff --git a/designer-base/src/main/java/com/fr/design/layout/TableLayoutHelper.java b/designer-base/src/main/java/com/fr/design/layout/TableLayoutHelper.java index 1be77c8492..d394f43ee7 100644 --- a/designer-base/src/main/java/com/fr/design/layout/TableLayoutHelper.java +++ b/designer-base/src/main/java/com/fr/design/layout/TableLayoutHelper.java @@ -372,7 +372,8 @@ public class TableLayoutHelper { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; JPanel jp1 = TableLayoutHelper.createTableLayoutPane(createTestComponents("jp1"), TableLayoutHelper.FILL_NONE); - JPanel jp2 = TableLayoutHelper.createGapTableLayoutPane(createTestComponents("jp2"), TableLayoutHelper.FILL_LASTCOL_AND_ROW, (double)2 * TEN, (double)2 * TEN); + JPanel jp2 = TableLayoutHelper.createGapTableLayoutPane(createTestComponents("jp2"), + TableLayoutHelper.FILL_LASTCOL_AND_ROW, (double)2 * TEN, (double)2 * TEN); JPanel jp3 = TableLayoutHelper.createGapTableLayoutPane(createTestComponents("jp3"), new double[]{f, p, f, p}, new double[]{f, f}, 4, 4); JPanel jp4 = TableLayoutHelper.createGapTableLayoutPane(createTestComponents("jp4"), diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/SplashMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/SplashMark.java index 790108978f..8cf75c0587 100644 --- a/designer-base/src/main/java/com/fr/design/locale/impl/SplashMark.java +++ b/designer-base/src/main/java/com/fr/design/locale/impl/SplashMark.java @@ -15,14 +15,13 @@ import java.util.Map; public class SplashMark implements LocaleMark { private Map map = new HashMap(); - private static final String SPLASH_PATH = "/com/fr/design/images/splash_10.gif"; - private static final String SPLASH_EN_PATH = "/com/fr/design/images/splash_10_en.gif"; - private static final String SPLASH_JP_PATH = "/com/fr/design/images/splash_10_jp.gif"; + private static final String SPLASH_PATH = "/com/fr/design/images/splash_10.png"; + private static final String SPLASH_EN_PATH = "/com/fr/design/images/splash_10_en.png"; public SplashMark() { map.put(Locale.CHINA, SPLASH_PATH); map.put(Locale.KOREA, SPLASH_EN_PATH); - map.put(Locale.JAPAN, SPLASH_JP_PATH); + map.put(Locale.JAPAN, SPLASH_EN_PATH); map.put(Locale.US, SPLASH_EN_PATH); map.put(Locale.TAIWAN, SPLASH_EN_PATH); } 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 082775a62d..2cf8d8c350 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 @@ -13,6 +13,7 @@ import com.fr.design.base.mode.DesignModeContext; import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataTreePane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.event.DesignerOpenedListener; import com.fr.design.event.TargetModifiedEvent; @@ -39,25 +40,29 @@ 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; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.event.EventDispatcher; import com.fr.exception.DecryptTemplateException; +import com.fr.exit.DesignerExiter; 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.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.OperatingSystem; 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; @@ -180,7 +185,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta @Override public void windowClosing(WindowEvent e) { - + //关闭前当前模板 停止编辑 + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().stopEditing(); SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true); // 只有一个文件未保存时 if (HistoryTemplateListCache.getInstance().getHistoryCount() == 1) { @@ -311,6 +317,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta // window close listener. this.addWindowListeners(getFrameListeners()); + addMacOsListener(); + this.addComponentListener(new ComponentAdapter() { @Override @@ -463,7 +471,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta OSSupportCenter.buildAction(new OSBasedAction() { @Override public void execute(Object... objects) { - bbsLoginPane[0] = ad.createBBSLoginPane(); + bbsLoginPane[0] = ad.createBBSLoginPane(); } }, SupportOSImpl.USERINFOPANE); processor.hold(northEastPane, LogMessageBar.getInstance(), bbsLoginPane[0]); @@ -475,7 +483,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta OSSupportCenter.buildAction(new OSBasedAction() { @Override public void execute(Object... objects) { - northEastPane.add(ad.createBBSLoginPane()); + northEastPane.add(ad.createBBSLoginPane()); } }, SupportOSImpl.USERINFOPANE); @@ -498,8 +506,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta image = ICODecoder.read(DesignerFrame.class .getResourceAsStream("/com/fr/base/images/oem/logo.ico")); } - this.setIconImages(image); - } catch (IOException e) { + if (OperatingSystem.isMacos()) { + Class clazz = Class.forName("com.apple.eawt.Application"); + BufferedImage icon = image.isEmpty() ? IOUtils.readImage("/com/fr/base/images/oem/logo.png") : image.get(image.size() - 1); + Reflect.on(Reflect.on(clazz).call("getApplication").get()).call("setDockIconImage", icon); + } else { + this.setIconImages(image); + } + } catch (IOException | ClassNotFoundException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png")); } @@ -512,6 +526,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } } + private void addMacOsListener() { + OSSupportCenter.buildAction(new MacOsAddListenerAction(), SupportOSImpl.DOCK_QUIT); + } + protected ArrayList getFrameListeners() { ArrayList arrayList = new ArrayList<>(); @@ -828,7 +846,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } defaultTitleSB.append(username).append("@").append(envName).append("[").append(workspace.getDescription()).append("]"); if (editingTemplate != null) { - String path = editingTemplate.getEditingFILE().getPath(); + String path = editingTemplate.getPath(); if (!editingTemplate.getEditingFILE().exists()) { path = FILEFactory.MEM_PREFIX + path; } else if (path.startsWith(ProjectConstants.REPORTLETS_NAME)) { @@ -919,9 +937,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } else { editingTemplate.stopEditing(); if (!editingTemplate.getEditingFILE().exists()) { - int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), + int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + editingTemplate.getEditingFILE() - + "\" ?", ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION, + + "\" ?", Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (returnVal == JOptionPane.YES_OPTION && editingTemplate.saveTemplate()) { editingTemplate.saveTemplate(); @@ -1033,10 +1051,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta // p:判断一下,如何文件为空或者文件不存在,直接返回. if (tplFile == null || !tplFile.exists()) { - JOptionPane.showMessageDialog( + FineJOptionPane.showMessageDialog( this, Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"), - ProductConstants.PRODUCT_NAME, + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE ); DesignerFrameFileDealerPane.getInstance().refresh(); @@ -1046,10 +1064,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta try { openFile(tplFile); } catch (DecryptTemplateException e) { - JOptionPane.showMessageDialog( + FineJOptionPane.showMessageDialog( this, Toolkit.i18nText("Fine-Design_Encrypt_Decrypt_Exception"), - UIManager.getString("OptionPane.messageDialogTitle"), + Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE, UIManager.getIcon("OptionPane.errorIcon") ); @@ -1083,6 +1101,17 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ private void openFile(FILE tplFile) { + if (tplFile != null) { + int index = HistoryTemplateListCache.getInstance().contains(tplFile); + if (index != -1) { + JTemplate jt = HistoryTemplateListCache.getInstance().getHistoryList().get(index); + if (!(jt instanceof JVirtualTemplate)) { + jt.activeOldJTemplate(); + return; + } + } + } + JTemplate jt = JTemplateFactory.createJTemplate(tplFile); if (jt == null) { return; @@ -1092,23 +1121,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta this.addAndActivateJTemplate(); MutilTempalteTabPane.getInstance().setTemTemplate( HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); - } else { - activeTemplate(jt); - } - } - - /** - * 激活指定的模板 - * - * @param jt 当前报表 - * @date 2014-10-14-下午6:31:23 - */ - private void activeTemplate(JTemplate jt) { - // 如果该模板已经打开,则进行激活就可以了 - int index = HistoryTemplateListCache.getInstance().contains(jt); - List> historyList = HistoryTemplateListCache.getInstance().getHistoryList(); - if (index != -1) { - historyList.get(index).activeJTemplate(index, jt); } else { this.addAndActivateJTemplate(jt); } @@ -1132,8 +1144,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta Thread.currentThread().interrupt(); } - DesignerEnvManager.getEnvManager().setLastOpenFile( - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath()); + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jt != null) { + DesignerEnvManager.getEnvManager().setLastOpenFile(jt.getEditingFILE().getPath()); + } DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY( WestRegionContainerPane.getInstance().getToolPaneY()); @@ -1159,8 +1173,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta this.dispose(); this.ad.shutDown(); - - System.exit(0); + DesignerExiter.getInstance().execute(); } // harry:添加程序外拖拽文件进来打开的功能 @@ -1267,4 +1280,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta progressDialog.dispose(); } + + /** + * 设计器是否已经打开 + * + * @return 设计器是否已经打开 + */ + public boolean isDesignerOpened() { + return designerOpened; + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index f24375da1f..bcac7f946c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -11,6 +11,7 @@ import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.tabledata.ResponseDataSourceChange; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.file.FileOperations; import com.fr.design.file.FileToolbarStateChangeListener; import com.fr.design.file.HistoryTemplateListCache; @@ -217,7 +218,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt if (VcsHelper.getInstance().needInit()) { vcsAction = new VcsAction(); - if (WorkContext.getCurrent().isLocal()) { + if (!WorkContext.getCurrent().isCluster()) { vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_Title")); } else { vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_NotSupportRemote")); @@ -324,9 +325,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt public void actionPerformed(ActionEvent evt) { if (!selectedOperation.access()) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied"), - Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + Toolkit.i18nText("Fine-Design_Basic_Alert"), WARNING_MESSAGE); return; } @@ -466,9 +467,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt @Override public void actionPerformed(ActionEvent evt) { if (!selectedOperation.access()) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied"), - Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + Toolkit.i18nText("Fine-Design_Basic_Alert"), WARNING_MESSAGE); return; } @@ -477,9 +478,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt String lock = node.getLock(); if (lock != null && !lock.equals(node.getUserID())) { // 提醒被锁定模板无法重命名 - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Unable_Rename_Locked_File"), - Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + Toolkit.i18nText("Fine-Design_Basic_Alert"), WARNING_MESSAGE); return; } @@ -506,9 +507,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt public void actionPerformed(ActionEvent evt) { if (!selectedOperation.access()) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied"), - Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + Toolkit.i18nText("Fine-Design_Basic_Alert"), WARNING_MESSAGE); return; } @@ -683,21 +684,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt this.dispose(); //模版重命名 - boolean success = false; - - // 提醒保存文件 - SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true); - // 只有一个文件未保存时 - if (HistoryTemplateListCache.getInstance().getHistoryCount() == 1) { - int choose = saveSomeTempaltePane.saveLastOneTemplate(); - if (choose != JOptionPane.CANCEL_OPTION) { - success = selectedOperation.rename(fnf, path, newPath); - } - } else { - if (saveSomeTempaltePane.showSavePane()) { - success = selectedOperation.rename(fnf, path, newPath); - } - } + boolean success = selectedOperation.rename(fnf, path, newPath); if (success) { HistoryTemplateListCache.getInstance().rename(fnf, path, newPath); @@ -705,9 +692,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt selectedOperation.refresh(); DesignerContext.getDesignerFrame().setTitle(); } else { - JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), + FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Rename_Failure"), - UIManager.getString("OptionPane.messageDialogTitle"), + Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } @@ -896,9 +883,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt selectedOperation.refresh(); this.dispose(); if (!success) { - JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), + FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Make_Failure"), - UIManager.getString("OptionPane.messageDialogTitle"), + Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } 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 4ac0200696..29c1dcb539 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 @@ -21,6 +21,7 @@ import com.fr.design.actions.file.WebPreviewUtils; import com.fr.design.base.mode.DesignModeContext; import com.fr.design.designer.DesignerProxy; import com.fr.design.designer.TargetComponent; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.InformationWarnPane; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.TemplateTreePane; @@ -35,6 +36,7 @@ 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; import com.fr.design.mainframe.template.info.TemplateInfoCollector; import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.design.mainframe.template.info.TimeConsumeTimer; @@ -69,11 +71,11 @@ import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.undo.UndoManager; -import java.awt.BorderLayout; import java.util.ArrayList; import java.util.Arrays; import java.util.Set; import java.util.regex.Pattern; +import java.awt.BorderLayout; /** * 报表设计和表单设计的编辑区域(设计器编辑的IO文件) @@ -91,6 +93,7 @@ public abstract class JTemplate> protected U authorityUndoState = null; protected T template; // 当前模板 protected TemplateProcessInfo processInfo; // 模板过程的相关信息 + private JComponent centerPane; private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复 private DesignModelAdapter designModel; private PreviewProvider previewType; @@ -121,13 +124,13 @@ public abstract class JTemplate> this.editingFILE = file; this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder()); - this.add(createCenterPane(), BorderLayout.CENTER); + addCenterPane(); this.undoState = createUndoState(); designModel = createDesignModel(); consumeTimer.setEnabled(shouldInitForCollectInfo(isNewFile)); } - + void onGetFocus() { consumeTimer.start(); } @@ -163,6 +166,7 @@ public abstract class JTemplate> } private void collectInfo(String originID) { // 执行收集操作 + ChartInfoCollector.getInstance().collectInfo(template.getTemplateID(), originID, getProcessInfo(), 0); if (!consumeTimer.isEnabled()) { return; } @@ -243,6 +247,47 @@ public abstract class JTemplate> } + /** + * 模板关闭时 + */ + public void whenClose() { + // do nothing + } + + /** + * 刷新内部资源 + * + * 刷新资源的同时。 + * CenterPane 负责监听改动。 + * 所以需要同步处理 + */ + public void refreshResource() { + + try { + this.template = JTemplateFactory.asIOFile(this.editingFILE); + setTarget(this.template); + + // 先移除旧的。 + removeCenterPane(); + // 加入新的 + addCenterPane(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + private void addCenterPane() { + + this.centerPane = createCenterPane(); + this.add(centerPane, BorderLayout.CENTER); + } + + private void removeCenterPane() { + + JComponent centerPane = this.centerPane; + this.remove(centerPane); + } + /** * 刷新容器 */ @@ -540,7 +585,7 @@ public abstract class JTemplate> FineLoggerFactory.getLogger().error(e.getMessage(), e); } if (!access) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.WARNING_MESSAGE); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); return false; } collectInfo(); @@ -594,10 +639,10 @@ public abstract class JTemplate> FineLoggerFactory.getLogger().error(e.getMessage(), e); } if (!access) { - JOptionPane.showMessageDialog( + FineJOptionPane.showMessageDialog( DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + "!", - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Message"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); return false; } @@ -618,10 +663,10 @@ public abstract class JTemplate> } return saved; } else { - JOptionPane.showMessageDialog( + FineJOptionPane.showMessageDialog( DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design-Basic_Save_Failure"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Message"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); return false; } @@ -1218,4 +1263,9 @@ public abstract class JTemplate> } public abstract String route(); + + public String getTemplateName() { + return getEditingFILE().getName(); + } + } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java index c6a6f4a0de..8019cc178a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe; +import com.fr.base.io.BaseBook; import com.fr.file.FILE; import com.fr.stable.CoreConstants; import com.fr.third.javax.annotation.Nonnull; @@ -42,6 +43,28 @@ public final class JTemplateFactory { } return null; } + + public static T asIOFile(@Nonnull FILE file) { + + String fileName = file.getName(); + int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT); + if (indexOfLastDot < 0) { + return null; + } + String fileExtension = fileName.substring(indexOfLastDot + 1); + for (App app : ALL_APP) { + String[] defaultAppExtensions = app.defaultExtensions(); + for (String defaultAppExtension : defaultAppExtensions) { + if (defaultAppExtension.equalsIgnoreCase(fileExtension)) { + BaseBook bb = app.asIOFile(file); + if (bb != null) { + return (T) bb; + } + } + } + } + return null; + } /** diff --git a/designer-base/src/main/java/com/fr/design/mainframe/UndoStateEdit.java b/designer-base/src/main/java/com/fr/design/mainframe/UndoStateEdit.java index 92de00dbcb..a70795d409 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/UndoStateEdit.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/UndoStateEdit.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe; import com.fr.base.vcs.DesignerMode; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; @@ -43,7 +44,7 @@ public class UndoStateEdit extends AbstractUndoableEdit { public void undo() throws CannotUndoException { super.undo(); if (cur.getAuthorityType() == BaseUndoState.AUTHORITY_STATE) { - int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Undo_All_Authority_Operations") + "?", + int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Undo_All_Authority_Operations") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Undo"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (returnVal == JOptionPane.NO_OPTION) { return; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java new file mode 100644 index 0000000000..a3665b77bd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java @@ -0,0 +1,130 @@ +package com.fr.design.mainframe.burying.point; + +import com.fr.base.FRContext; +import com.fr.base.io.XMLReadHelper; +import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.template.info.SendHelper; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLTools; +import com.fr.stable.xml.XMLableReader; +import com.fr.third.javax.xml.stream.XMLStreamException; +import com.fr.third.org.apache.commons.io.FileUtils; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-02-21 + */ +public abstract class AbstractPointCollector implements BasePointCollector { + + protected Map pointInfoMap; + + private static final int MAX_SIZE = 512 * 1024 * 1024; + + public AbstractPointCollector() { + pointInfoMap = new ConcurrentHashMap<>(); + loadFromFile(); + } + + /** + * 获取是否满足触发埋点的要求 + */ + protected boolean shouldCollectInfo() { + return FileUtils.sizeOf(getInfoFile()) <= MAX_SIZE && DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); + } + + @Override + public void sendPointInfo() { + + addIdleDayCount(); + + List removeList = new ArrayList<>(); + List sendList = new ArrayList<>(); + + for (String key : pointInfoMap.keySet()) { + AbstractPointInfo pointInfo = pointInfoMap.get(key); + pointInfo.selectPoint(removeList, sendList); + } + + // 发送记录 + for (String key : sendList) { + if(SendHelper.sendPointInfo(pointInfoMap.get(key))){ + removeList.add(key); + } + } + + // 清空记录 + for (String key : removeList) { + pointInfoMap.remove(key); + } + + saveInfo(); + } + + /** + * 从文件中读取埋点信息 + */ + protected void loadFromFile() { + if (!getInfoFile().exists()) { + return; + } + + XMLableReader reader = null; + try (InputStream in = new FileInputStream(getInfoFile())) { + // XMLableReader 还是应该考虑实现 Closable 接口的,这样就能使用 try-with 语句了 + reader = XMLReadHelper.createXMLableReader(in, XMLPrintWriter.XML_ENCODER); + if (reader == null) { + return; + } + reader.readXMLObject(this); + } catch (FileNotFoundException e) { + // do nothing + } catch (XMLStreamException | IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } finally { + try { + if (reader != null) { + reader.close(); + } + } catch (XMLStreamException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + } + + /** + * 保存埋点信息到文件中 + */ + protected void saveInfo() { + try { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + XMLTools.writeOutputStreamXML(this, out); + out.flush(); + out.close(); + String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8); + FileUtils.writeStringToFile(getInfoFile(), fileContent, StandardCharsets.UTF_8); + } catch (Exception ex) { + FineLoggerFactory.getLogger().error(ex.getMessage()); + } + } + + /** + * 获取缓存文件存放路径 + */ + protected abstract File getInfoFile(); + + protected abstract void addIdleDayCount(); +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointInfo.java b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointInfo.java new file mode 100644 index 0000000000..6646bfd09a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointInfo.java @@ -0,0 +1,55 @@ +package com.fr.design.mainframe.burying.point; + +import java.util.List; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-02-21 + */ +public abstract class AbstractPointInfo implements BasePointInfo { + + protected int idleDayCount; // 到现在为止,埋点闲置的天数 + + @Override + public void resetIdleDayCount() { + this.idleDayCount = 0; + } + + @Override + public void addIdleDayCountByOne() { + this.idleDayCount += 1; + } + + /** + * 上传前判断该埋点,是否需要被上传,或者删除,或者什么都不做。 + */ + @Override + public void selectPoint(List removeList, List sendList) { + //埋点还未完成,直接返回 + if (!isComplete()) { + return; + } + //属于测试模板,直接删除,否则发送信息 + if (isTestTemplate()) { + removeList.add(key()); + } else { + sendList.add(key()); + } + } + + /** + * 是否为测试模板 + */ + protected abstract boolean isTestTemplate(); + + /** + * 是否已经制作完成 + */ + protected abstract boolean isComplete(); + + /** + * 埋点记录的主键 + */ + protected abstract String key(); +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointCollector.java new file mode 100644 index 0000000000..f10f1682e0 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointCollector.java @@ -0,0 +1,23 @@ +package com.fr.design.mainframe.burying.point; + +import com.fr.design.mainframe.template.info.TemplateProcessInfo; +import com.fr.stable.xml.XMLReadable; +import com.fr.stable.xml.XMLWriter; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-02-21 + */ +public interface BasePointCollector extends XMLReadable, XMLWriter { + + /** + * 发送埋点信息到服务器 + */ + public void sendPointInfo(); + + /** + * 保存埋点的信息到本地 + */ + public void collectInfo(String templateID, String originID, TemplateProcessInfo processInfo, int timeConsume); +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointInfo.java b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointInfo.java new file mode 100644 index 0000000000..b45f1cb6a7 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointInfo.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.burying.point; + +import com.fr.stable.xml.XMLReadable; +import com.fr.stable.xml.XMLWriter; + +import java.util.List; +import java.util.Map; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-02-21 + */ +public interface BasePointInfo extends XMLReadable, XMLWriter { + + /** + * 重置埋点的未编辑天数 + */ + void resetIdleDayCount(); + + /** + * 增加一天埋点的未编辑天数 + */ + void addIdleDayCountByOne(); + + /** + * 上传前判断该埋点,是否需要被上传,或者删除,或者什么都不做。 + */ + void selectPoint(List removeList, List sendList); + + /** + * 获取要上传的内容,key→上传路径,value→上传内容 + */ + Map getSendInfo(); +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java new file mode 100644 index 0000000000..9d305ef1da --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java @@ -0,0 +1,250 @@ +package com.fr.design.mainframe.chart.info; + +import com.fr.base.io.BaseBook; +import com.fr.config.MarketConfig; +import com.fr.design.DesignModelAdapter; +import com.fr.design.DesignerEnvManager; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.mainframe.burying.point.AbstractPointInfo; +import com.fr.general.CloudCenter; +import com.fr.general.GeneralUtils; +import com.fr.json.JSONObject; +import com.fr.stable.ProductConstants; +import com.fr.stable.StringUtils; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLableReader; +import com.fr.third.joda.time.DateTime; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-02-17 + */ +public class ChartInfo extends AbstractPointInfo { + public static final String XML_TAG = "ChartInfo"; + private static final String CHART_CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("chartinfo.consuming") + "/single"; + + + private static final String XML_CHART_CONSUMING_MAP = "chartConsumingMap"; + private static final String ATTR_TEST_TEMPLATE = "testTemplate"; + private static final String ATTR_DAY_COUNT = "day_count"; + private static final String ATTR_USERNAME = "username"; + private static final String ATTR_UUID = "uuid"; + private static final String ATTR_ACTIVITYKEY = "activityKey"; + private static final String ATTR_TEMPLATE_ID = "templateID"; + private static final String ATTR_REPORT_TYPE = "type"; + private static final String ATTR_CHART_ID = "chartId"; + private static final String ATTR_CHART_TYPE = "chartType"; + private static final String ATTR_CHART_CREATE_TIME = "chartCreateTime"; + private static final String ATTR_CHART_TYPE_TIME = "chartTypeTime"; + private static final String ATTR_CHART_PROPERTY_FIRST_TIME = "chartPropertyFirstTime"; + private static final String ATTR_CHART_PROPERTY_END_TIME = "chartPropertyEndTime"; + private static final String ATTR_JAR_TIME = "jarTime"; + private static final String ATTR_VERSION = "version"; + + private static final int COMPLETE_DAY_COUNT = 3; // 判断图表是否可以上传的天数 + + private String chartId = StringUtils.EMPTY; + + private String templateId = StringUtils.EMPTY; + + private Map chartConsumingMap = new HashMap<>(); + + private BaseBook book; + + private boolean testTemplate; + + private ChartInfo() { + } + + private ChartInfo(String chartId, String templateId, BaseBook book) { + this.chartId = chartId; + this.templateId = templateId; + this.book = book; + } + + public String getChartId() { + return chartId; + } + + @Override + protected String key() { + return chartId; + } + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + this.chartConsumingMap.put(ATTR_TEMPLATE_ID, templateId); + } + + + public BaseBook getBook() { + return book; + } + + @Override + public boolean isTestTemplate() { + return testTemplate; + } + + public void setTestTemplate(boolean testTemplate) { + this.testTemplate = testTemplate; + } + + static ChartInfo newInstanceByRead(XMLableReader reader) { + ChartInfo chartInfo = new ChartInfo(); + reader.readXMLObject(chartInfo); + return chartInfo; + } + + public static ChartInfo newInstance(String chartId, String chartType) { + return newInstance(chartId, chartType, null); + } + + public static ChartInfo newInstance(String chartId, String chartType, String createTime) { + HashMap chartConsumingMap = new HashMap<>(); + + String username = MarketConfig.getInstance().getBbsUsername(); + String uuid = DesignerEnvManager.getEnvManager().getUUID(); + String activityKey = DesignerEnvManager.getEnvManager().getActivationKey(); + + BaseBook book = DesignModelAdapter.getCurrentModelAdapter().getBook(); + String templateId = book.getTemplateID(); + int reportType = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getProcessInfo().getReportType(); + + String typeTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); + + createTime = createTime == null ? typeTime : createTime; + + String jarTime = GeneralUtils.readBuildNO(); + String version = ProductConstants.VERSION; + chartConsumingMap.put(ATTR_USERNAME, username); + chartConsumingMap.put(ATTR_UUID, uuid); + chartConsumingMap.put(ATTR_ACTIVITYKEY, activityKey); + chartConsumingMap.put(ATTR_TEMPLATE_ID, templateId); + chartConsumingMap.put(ATTR_REPORT_TYPE, String.valueOf(reportType)); + chartConsumingMap.put(ATTR_CHART_ID, chartId); + chartConsumingMap.put(ATTR_CHART_TYPE, chartType); + chartConsumingMap.put(ATTR_CHART_CREATE_TIME, createTime); + chartConsumingMap.put(ATTR_CHART_TYPE_TIME, typeTime); + chartConsumingMap.put(ATTR_CHART_PROPERTY_FIRST_TIME, ""); + chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, ""); + chartConsumingMap.put(ATTR_JAR_TIME, jarTime); + chartConsumingMap.put(ATTR_VERSION, version); + + ChartInfo chartInfo = new ChartInfo(chartId, templateId, book); + chartInfo.chartConsumingMap = chartConsumingMap; + + return chartInfo; + } + + @Override + public void writeXML(XMLPrintWriter writer) { + writer.startTAG(XML_TAG); + if (StringUtils.isNotEmpty(chartId)) { + writer.attr(ATTR_CHART_ID, this.chartId); + } + if (StringUtils.isNotEmpty(templateId)) { + writer.attr(ATTR_TEMPLATE_ID, this.templateId); + } + if (idleDayCount >= 0) { + writer.attr(ATTR_DAY_COUNT, this.idleDayCount); + } + writer.attr(ATTR_TEST_TEMPLATE, this.testTemplate); + writer.startTAG(XML_CHART_CONSUMING_MAP); + writer.attr(ATTR_USERNAME, chartConsumingMap.get(ATTR_USERNAME)); + writer.attr(ATTR_UUID, chartConsumingMap.get(ATTR_UUID)); + writer.attr(ATTR_ACTIVITYKEY, chartConsumingMap.get(ATTR_ACTIVITYKEY)); + writer.attr(ATTR_REPORT_TYPE, chartConsumingMap.get(ATTR_REPORT_TYPE)); + writer.attr(ATTR_CHART_TYPE, chartConsumingMap.get(ATTR_CHART_TYPE)); + writer.attr(ATTR_CHART_CREATE_TIME, chartConsumingMap.get(ATTR_CHART_CREATE_TIME)); + writer.attr(ATTR_CHART_TYPE_TIME, chartConsumingMap.get(ATTR_CHART_TYPE_TIME)); + writer.attr(ATTR_CHART_PROPERTY_FIRST_TIME, chartConsumingMap.get(ATTR_CHART_PROPERTY_FIRST_TIME)); + writer.attr(ATTR_CHART_PROPERTY_END_TIME, chartConsumingMap.get(ATTR_CHART_PROPERTY_END_TIME)); + writer.attr(ATTR_JAR_TIME, chartConsumingMap.get(ATTR_JAR_TIME)); + writer.attr(ATTR_VERSION, chartConsumingMap.get(ATTR_VERSION)); + writer.end(); + writer.end(); + } + + @Override + public void readXML(XMLableReader reader) { + + if (!reader.isChildNode()) { + idleDayCount = reader.getAttrAsInt(ATTR_DAY_COUNT, 0); + chartId = reader.getAttrAsString(ATTR_CHART_ID, StringUtils.EMPTY); + templateId = reader.getAttrAsString(ATTR_TEMPLATE_ID, StringUtils.EMPTY); + testTemplate = reader.getAttrAsBoolean(ATTR_TEST_TEMPLATE, true); + } else { + String name = reader.getTagName(); + if (XML_CHART_CONSUMING_MAP.equals(name)) { + chartConsumingMap.put(ATTR_USERNAME, reader.getAttrAsString(ATTR_USERNAME, StringUtils.EMPTY)); + chartConsumingMap.put(ATTR_UUID, reader.getAttrAsString(ATTR_UUID, StringUtils.EMPTY)); + chartConsumingMap.put(ATTR_ACTIVITYKEY, reader.getAttrAsString(ATTR_ACTIVITYKEY, StringUtils.EMPTY)); + chartConsumingMap.put(ATTR_TEMPLATE_ID, templateId); + chartConsumingMap.put(ATTR_REPORT_TYPE, reader.getAttrAsString(ATTR_REPORT_TYPE, "0")); + chartConsumingMap.put(ATTR_CHART_ID, chartId); + chartConsumingMap.put(ATTR_CHART_TYPE, reader.getAttrAsString(ATTR_CHART_TYPE, StringUtils.EMPTY)); + chartConsumingMap.put(ATTR_CHART_CREATE_TIME, reader.getAttrAsString(ATTR_CHART_CREATE_TIME, StringUtils.EMPTY)); + chartConsumingMap.put(ATTR_CHART_TYPE_TIME, reader.getAttrAsString(ATTR_CHART_TYPE_TIME, StringUtils.EMPTY)); + chartConsumingMap.put(ATTR_CHART_PROPERTY_FIRST_TIME, reader.getAttrAsString(ATTR_CHART_PROPERTY_FIRST_TIME, StringUtils.EMPTY)); + chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, reader.getAttrAsString(ATTR_CHART_PROPERTY_END_TIME, StringUtils.EMPTY)); + chartConsumingMap.put(ATTR_JAR_TIME, reader.getAttrAsString(ATTR_JAR_TIME, StringUtils.EMPTY)); + chartConsumingMap.put(ATTR_VERSION, reader.getAttrAsString(ATTR_VERSION, "8.0")); + } + } + } + + @Override + public boolean isComplete() { + // 连续3天打开了设计器但是没有编辑 + return idleDayCount > COMPLETE_DAY_COUNT; + } + + @Override + public Map getSendInfo() { + Map sendMap = new HashMap<>(); + sendMap.put(CHART_CONSUMING_URL, new JSONObject(chartConsumingMap).toString()); + return sendMap; + } + + public void updatePropertyTime() { + String propertyTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); + + if (StringUtils.isEmpty(chartConsumingMap.get(ATTR_CHART_PROPERTY_FIRST_TIME))) { + chartConsumingMap.put(ATTR_CHART_PROPERTY_FIRST_TIME, propertyTime); + } + chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, propertyTime); + } + + public void updateChartType(String chartType) { + String typeTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); + + chartConsumingMap.put(ATTR_CHART_TYPE_TIME, typeTime); + chartConsumingMap.put(ATTR_CHART_TYPE, chartType); + chartConsumingMap.put(ATTR_CHART_PROPERTY_FIRST_TIME, ""); + chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, ""); + } + + @Override + public ChartInfo clone() { + ChartInfo chartInfo = new ChartInfo(); + chartInfo.chartId = this.chartId; + chartInfo.idleDayCount = this.idleDayCount; + chartInfo.templateId = this.templateId; + chartInfo.testTemplate = this.testTemplate; + Map chartConsumingMap = new HashMap<>(); + for (Map.Entry entry : this.chartConsumingMap.entrySet()) { + chartConsumingMap.put(entry.getKey(), entry.getValue()); + } + chartInfo.chartConsumingMap = chartConsumingMap; + return chartInfo; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java new file mode 100644 index 0000000000..d622c688a5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java @@ -0,0 +1,248 @@ +package com.fr.design.mainframe.chart.info; + +import com.fr.base.io.BaseBook; +import com.fr.chartx.attr.ChartProvider; +import com.fr.design.mainframe.burying.point.AbstractPointCollector; +import com.fr.design.mainframe.template.info.TemplateInfo; +import com.fr.design.mainframe.template.info.TemplateProcessInfo; +import com.fr.general.ComparatorUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.vanchart.VanChart; +import com.fr.stable.ProductConstants; +import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLableReader; +import com.fr.third.joda.time.DateTime; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-02-18 + */ +public class ChartInfoCollector extends AbstractPointCollector { + private static final String XML_TAG = "ChartInfoCollector"; + private static final String XML_LAST_EDIT_DAY = "lastEditDay"; + + private static final String XML_CHART_INFO_LIST = "ChartInfoList"; + private static final String XML_FILE_NAME = "chart.info"; + + private static ChartInfoCollector instance; + + private Map chartInfoCacheMap; + + private String lastEditDay; + + private ChartInfoCollector() { + init(); + } + + private void init() { + chartInfoCacheMap = new HashMap<>(); + } + + public static ChartInfoCollector getInstance() { + if (instance == null) { + instance = new ChartInfoCollector(); + } + return instance; + } + + public void collection(ChartProvider chartProvider, String createTime) { + if (chartProvider instanceof VanChart) { + VanChart vanChart = (VanChart) chartProvider; + collection(vanChart.getUuid(), vanChart.getID(), createTime); + } + } + + /** + * 新建图表,保存状态 + */ + public void collection(String chartId, String chartType, String createTime) { + if (!shouldCollectInfo()) { + return; + } + + ChartInfo chartInfo = ChartInfo.newInstance(chartId, chartType, createTime); + chartInfoCacheMap.put(chartId, chartInfo); + } + + public void updateChartPropertyTime(ChartProvider chartProvider) { + if (chartProvider instanceof VanChart) { + VanChart vanChart = (VanChart) chartProvider; + updateChartPropertyTime(vanChart.getUuid(), vanChart.getID()); + } + } + + /** + * 图表编辑,更新编辑时间 + */ + public void updateChartPropertyTime(String chartId, String chartType) { + if (!shouldCollectInfo()) { + return; + } + ChartInfo chartInfo = getOrCreateChartInfo(chartId, chartType); + + //更新编辑时间 + chartInfo.updatePropertyTime(); + + //重置计数 + chartInfo.resetIdleDayCount(); + } + + public void updateChartTypeTime(ChartProvider chartProvider) { + if (chartProvider instanceof VanChart) { + VanChart vanChart = (VanChart) chartProvider; + updateChartTypeTime(vanChart.getUuid(), vanChart.getID()); + } + } + + /** + * 图表类型变化,更新类型和类型确认时间 + */ + public void updateChartTypeTime(String chartId, String chartType) { + if (!shouldCollectInfo()) { + return; + } + + ChartInfo chartInfo = getOrCreateChartInfo(chartId, chartType); + + //更新类型确认时间和类型 + chartInfo.updateChartType(chartType); + + //重置计数 + chartInfo.resetIdleDayCount(); + } + + private ChartInfo getOrCreateChartInfo(String chartId, String chartType) { + //缓存中有从缓存中拿 + if (chartInfoCacheMap.containsKey(chartId)) { + return chartInfoCacheMap.get(chartId); + } + //缓存中没有从文件中读取的信息中拷贝到缓存 + if (pointInfoMap.containsKey(chartId)) { + ChartInfo chartInfo = pointInfoMap.get(chartId).clone(); + chartInfoCacheMap.put(chartId, chartInfo); + return chartInfo; + } + //都有的话创建一个并加入到缓存中 + ChartInfo chartInfo = ChartInfo.newInstance(chartId, chartType); + chartInfoCacheMap.put(chartId, chartInfo); + return chartInfo; + } + + /** + * 保存模板的时候将该模板中的图表埋点信息保存 + */ + @Override + public void collectInfo(String templateId, String originID, TemplateProcessInfo processInfo, int timeConsume) { + if (!shouldCollectInfo()) { + return; + } + if (StringUtils.isEmpty(originID)) { + originID = templateId; + } + boolean testTemplate = isTestTemplate(processInfo); + + for (ChartInfo chartInfo : pointInfoMap.values()) { + if (originID.equals(chartInfo.getTemplateId())) { + chartInfo.setTemplateId(templateId); + chartInfo.setTestTemplate(testTemplate); + } + } + + for (ChartInfo chartInfo : chartInfoCacheMap.values()) { + BaseBook book = chartInfo.getBook(); + if ((book != null && templateId.equals(book.getTemplateID())) || + originID.equals(chartInfo.getTemplateId())) { + chartInfo.setTemplateId(templateId); + chartInfo.setTestTemplate(testTemplate); + pointInfoMap.put(chartInfo.getChartId(), chartInfo); + } + } + + // 每次更新之后,都同步到暂存文件中 + saveInfo(); + } + + private boolean isTestTemplate(TemplateProcessInfo processInfo) { + int reportType = processInfo.getReportType(); + int cellCount = processInfo.getCellCount(); + int floatCount = processInfo.getFloatCount(); + int blockCount = processInfo.getBlockCount(); + int widgetCount = processInfo.getWidgetCount(); + + return TemplateInfo.isTestTemplate(reportType, cellCount, floatCount, blockCount, widgetCount); + } + + /** + * 更新 day_count:打开设计器却未编辑图表的连续日子 + */ + @Override + protected void addIdleDayCount() { + // 判断今天是否第一次打开设计器,为了防止同一天内,多次 addIdleDayCount + String today = DateTime.now().toString("yyyy-MM-dd"); + if (ComparatorUtils.equals(today, lastEditDay)) { + return; + } + for (ChartInfo chartInfo : pointInfoMap.values()) { + chartInfo.addIdleDayCountByOne(); + } + lastEditDay = today; + } + + + /** + * 获取缓存文件存放路径 + */ + @Override + protected File getInfoFile() { + File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), XML_FILE_NAME)); + try { + if (!file.exists()) { + file.createNewFile(); + } + } catch (Exception ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + } + return file; + } + + @Override + public void readXML(XMLableReader reader) { + if (reader.isChildNode()) { + try { + String name = reader.getTagName(); + if (ChartInfo.XML_TAG.equals(name)) { + ChartInfo chartInfo = ChartInfo.newInstanceByRead(reader); + pointInfoMap.put(chartInfo.getChartId(), chartInfo); + } else if (XML_LAST_EDIT_DAY.equals(name)) { + lastEditDay = reader.getElementValue(); + } + } catch (Exception ex) { + // 什么也不做,使用默认值 + } + } + } + + @Override + public void writeXML(XMLPrintWriter writer) { + writer.startTAG(XML_TAG); + + writer.startTAG(XML_LAST_EDIT_DAY); + writer.textNode(lastEditDay); + writer.end(); + + writer.startTAG(XML_CHART_INFO_LIST); + for (ChartInfo chartInfo : pointInfoMap.values()) { + chartInfo.writeXML(writer); + } + writer.end(); + + writer.end(); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java b/designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java similarity index 94% rename from designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java rename to designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java index 9bfd729dd4..99950edae7 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java @@ -21,6 +21,9 @@ import java.util.Date; */ public class ErrorInfo { + private static final String SUFFIX = ".json"; + private static final String FOLDER_NAME = "errorInfo"; + private String username; private String uuid; private String activekey; @@ -128,8 +131,8 @@ public class ErrorInfo { public void saveFileToCache(JSONObject jo) { String content = jo.toString(); - String fileName = UUID.randomUUID() + ErrorInfoUploader.SUFFIX; - File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), ErrorInfoUploader.FOLDER_NAME, fileName)); + String fileName = UUID.randomUUID() + SUFFIX; + File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FOLDER_NAME, fileName)); FileOutputStream out = null; try (InputStream in = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))) { StableUtils.makesureFileExist(file); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java index 57d1d457f6..5937770c4e 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java @@ -53,6 +53,12 @@ public class DesignerLogHandler { private static final int SERVER_GAP_Y = -20; + private static final String ERROR_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + ":"; + + private static final String WARN_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Seriously") + ":"; + + private static final String NORMAL_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Normal") + ":"; + public static DesignerLogHandler getInstance() { return HOLDER.singleton; @@ -310,11 +316,11 @@ public class DesignerLogHandler { private String appendLocaleMark(String str, int style) { if (style == DesignerLogger.ERROR_INT) { - str = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + ":" + str + "\n"; + str = ERROR_MARK + str + "\n"; } else if (style == DesignerLogger.WARN_INT) { - str = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Seriously") + ":" + str + "\n"; + str = WARN_MARK + str + "\n"; } else { - str = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Normal") + ":" + str + "\n"; + str = NORMAL_MARK + str + "\n"; } return str; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogDetailPane.java index 5ea260f469..0ed6386168 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogDetailPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogDetailPane.java @@ -6,6 +6,7 @@ import javax.swing.JFrame; import javax.swing.JPanel; import com.fr.base.BaseUtils; +import com.fr.design.i18n.Toolkit; import com.fr.design.utils.gui.GUICoreUtils; public class LogDetailPane extends JPanel{ @@ -20,7 +21,7 @@ public class LogDetailPane extends JPanel{ fr.setSize(600, 400); GUICoreUtils.centerWindow(fr); fr.setResizable(false); - fr.setTitle("日志"); + fr.setTitle(Toolkit.i18nText("Fine-Design_Basic_Log")); fr.setIconImage(BaseUtils.readImageWithCache("com/fr/design/images/buttonicon/history.png")); fr.getContentPane().setLayout(new BorderLayout()); fr.getContentPane().add(this, BorderLayout.CENTER); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java index 5a4ba1edaf..bbb9eed346 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java @@ -69,7 +69,7 @@ public class LogHandlerBarUI extends ComponentUI implements MouseListener, Focus int w = button.getWidth(); int h = button.getHeight(); Graphics2D g2d = (Graphics2D) g; - GradientPaint gp = new GradientPaint(1, 1, darkColor, 1, h - 1, darkColor); + GradientPaint gp = new GradientPaint(1, 1, darkColor, 1, (float)(h - 1), darkColor); g2d.setPaint(gp); g2d.fillRect(0, 0, w, h); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java new file mode 100644 index 0000000000..ca3fd13ccc --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java @@ -0,0 +1,44 @@ +package com.fr.design.mainframe.messagecollect; + +import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.errorinfo.ErrorInfo; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; + +/** + * + * @author hades + * @version 10.0 + * Created by hades on 2020/1/8 + */ +public class StartErrorMessageCollector { + + private static final StartErrorMessageCollector INSTANCE = new StartErrorMessageCollector(); + + private String uuid; + private String activeKey; + + + public static StartErrorMessageCollector getInstance() { + return INSTANCE; + } + + private StartErrorMessageCollector() { + DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); + this.uuid = envManager.getUUID(); + this.activeKey = envManager.getActivationKey(); + } + + public void record(String id, String msg, String detail) { + FineLoggerFactory.getLogger().error(id + ": " + msg + ", detail: " + detail); + ErrorInfo errorInfo = new ErrorInfo(StringUtils.EMPTY, uuid, activeKey); + errorInfo.setLogid(id); + errorInfo.setLog(msg); + errorInfo.setStackTrace(detail); + errorInfo.saveAsJSON(); + } + + public void record(String id, String msg) { + record(id, msg, StringUtils.EMPTY); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java b/designer-base/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java new file mode 100644 index 0000000000..d2047336ec --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java @@ -0,0 +1,37 @@ +package com.fr.design.mainframe.messagecollect.entity; + +import com.fr.design.i18n.Toolkit; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/1/8 + */ +public enum DesignerErrorMessage { + + DESIGNER_PROCESS_OCCUPIED("11300201", Toolkit.i18nText("Fine-Design_Error_Process_Occupied_Message")), + PORT_OCCUPIED("11300202", Toolkit.i18nText("Fine-Design_Error_Port_Occupied_Message")), + FINEDB_PROBLEM("11300203", Toolkit.i18nText("Fine-Design_Error_Finedb_Problem_Message")), + DESIGNER_OUT_OF_MEMORY("11300204", Toolkit.i18nText("Fine-Design_Error_Out_Of_Memory_Message")), + REMOTE_DESIGN_NO_RESPONSE("11300205", Toolkit.i18nText("Fine-Design_Error_Remote_No_Response_Message")), + UNEXCEPTED_START_FAILED("11300200", Toolkit.i18nText("Fine-Design_Error_UnExcepted_Start_Failed")), + UNEXCEPTED_FALL_BACK("11300400 ", Toolkit.i18nText("Fine-Design_Error_UnExcepted_Fall_Back")); + + + + private String id; + private String message; + + public String getId() { + return id; + } + + public String getMessage() { + return message; + } + + DesignerErrorMessage(String id, String message) { + this.id = id; + this.message = message; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileBookMarkStyleCustomDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileBookMarkStyleCustomDefinePane.java new file mode 100644 index 0000000000..20a14ea222 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileBookMarkStyleCustomDefinePane.java @@ -0,0 +1,27 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.form.ui.mobile.MobileBookMarkStyle; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/24 + */ +public class DefaultMobileBookMarkStyleCustomDefinePane extends BasicBeanPane { + + @Override + public void populateBean(MobileBookMarkStyle ob) { + + } + + @Override + public MobileBookMarkStyle updateBean() { + return null; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileBookMarkStyleProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileBookMarkStyleProvider.java new file mode 100644 index 0000000000..709afefe47 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileBookMarkStyleProvider.java @@ -0,0 +1,29 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.fun.impl.AbstractMobileBookMarkStyleProvider; +import com.fr.form.ui.mobile.impl.DefaultMobileBookMarkStyle; +import com.fr.form.ui.mobile.MobileBookMarkStyle; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/24 + */ +public class DefaultMobileBookMarkStyleProvider extends AbstractMobileBookMarkStyleProvider { + + @Override + public Class classForMobileBookMarkStyle() { + return DefaultMobileBookMarkStyle.class; + } + + @Override + public Class> classForMobileBookMarkStyleAppearance() { + return DefaultMobileBookMarkStyleCustomDefinePane.class; + } + + @Override + public String displayName() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_None_BookMark_Style"); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleDefinePane.java new file mode 100644 index 0000000000..7812e8f32a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleDefinePane.java @@ -0,0 +1,61 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.fun.MobileBookMarkStyleProvider; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.form.ui.mobile.MobileBookMarkStyle; +import com.fr.general.ComparatorUtils; +import com.fr.invoke.Reflect; + +import javax.swing.*; +import java.awt.*; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/23 + */ +public class MobileBookMarkStyleDefinePane extends BasicBeanPane { + + private BasicBeanPane customDefinePane; + private String displayName; + + MobileBookMarkStyleDefinePane(MobileBookMarkStyleProvider bookMarkStyleProvider) { + this.customDefinePane = Reflect.on( + bookMarkStyleProvider.classForMobileBookMarkStyleAppearance()).create().get(); + this.displayName = bookMarkStyleProvider.displayName(); + initComponent(); + } + + private void initComponent() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + JPanel settingPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + if (!ComparatorUtils.equals(displayName, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_None_BookMark_Style"))) { + JPanel hintLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + hintLabelPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); + UILabel hintLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Hint")); + hintLabel.setForeground(Color.GRAY); + hintLabelPane.add(hintLabel); + settingPane.add(hintLabelPane, BorderLayout.NORTH); + } + settingPane.add(this.customDefinePane, BorderLayout.CENTER); + this.add(settingPane, BorderLayout.CENTER); + } + + @Override + public void populateBean(MobileBookMarkStyle ob) { + this.customDefinePane.populateBean(ob); + } + + @Override + public MobileBookMarkStyle updateBean() { + return this.customDefinePane.updateBean(); + } + + @Override + protected String title4PopupWindow() { + return "MobileBookMarkStyleDefinePane"; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStylePane.java new file mode 100644 index 0000000000..4828b2bc82 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStylePane.java @@ -0,0 +1,148 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.fun.MobileBookMarkStyleProvider; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.form.ui.mobile.MobileBookMarkStyle; + +import javax.swing.*; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/23 + */ +public class MobileBookMarkStylePane extends BasicBeanPane { + public static final int LEFT_PANEL_WIDTH = 140; + public static final int LEFT_PANEL_HEIGHT = 565; + public static final int RIGHT_PANEL_WIDTH = 510; + public static final int RIGHT_PANEL_HEIGHT = 565; + + + public static ListCellRenderer renderer = new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, + boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof MobileBookMarkStyle) { + this.setText((value.toString())); + } + return this; + } + }; + + private DefaultListModel listModel; + private JList bookMarkList; + private JPanel rightPane; + private CardLayout card; + private Map> map = new HashMap<>(); + + public MobileBookMarkStylePane() { + initComponent(); + } + + private void initComponent() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + this.listModel = new DefaultListModel<>(); + this.card = new CardLayout(); + this.rightPane = FRGUIPaneFactory.createCardLayout_S_Pane(); + this.rightPane.setLayout(card); + initDefaultAndExtraPanel(); + initLeftListPanel(); + initRightPanel(); + } + + private void initDefaultAndExtraPanel() { + List list = getMobileBookMarkStyleProvider(); + for (MobileBookMarkStyleProvider bookMarkStyleProvider : list) { + String displayName = bookMarkStyleProvider.displayName(); + MobileBookMarkStyleDefinePane mobileBookMarkStyleDefinePane = new MobileBookMarkStyleDefinePane( + bookMarkStyleProvider); + listModel.addElement(displayName); + rightPane.add(displayName, mobileBookMarkStyleDefinePane); + map.put(displayName, mobileBookMarkStyleDefinePane); + } + } + + private void initLeftListPanel() { + bookMarkList = new JList<>(listModel); + bookMarkList.setCellRenderer(renderer); + bookMarkList.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + card.show(rightPane, (String) bookMarkList.getSelectedValue()); + } + }); + JPanel leftPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); + leftPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + leftPanel.add(bookMarkList, BorderLayout.CENTER); + leftPanel.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, LEFT_PANEL_HEIGHT)); + this.add(leftPanel, BorderLayout.WEST); + } + + private void initRightPanel() { + JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + centerPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + centerPane.setPreferredSize(new Dimension(RIGHT_PANEL_WIDTH, RIGHT_PANEL_HEIGHT)); + centerPane.add(rightPane, BorderLayout.CENTER); + this.add(centerPane, BorderLayout.CENTER); + } + + + private List getMobileBookMarkStyleProvider() { + DefaultMobileBookMarkStyleProvider defaultMobileBookMarkStyleProvider = new DefaultMobileBookMarkStyleProvider(); + SidebarMobileBookMarkStyleProvider sidebarMobileBookMarkStyleProvider = new SidebarMobileBookMarkStyleProvider(); + Set mobileBookMarkStyleProviders = ExtraDesignClassManager.getInstance().getArray( + MobileBookMarkStyleProvider.XML_TAG); + List list = new ArrayList<>(); + list.add(defaultMobileBookMarkStyleProvider); + list.add(sidebarMobileBookMarkStyleProvider); + list.addAll(mobileBookMarkStyleProviders); + return Collections.unmodifiableList(list); + } + + @Override + protected String title4PopupWindow() { + return null; + } + + + @Override + public void populateBean(MobileBookMarkStyle mobileBookMarkStyle) { + if (mobileBookMarkStyle != null) { + List bookMarkStyleProviders = getMobileBookMarkStyleProvider(); + int i = 0; + for (MobileBookMarkStyleProvider bookMarkStyleProvider : bookMarkStyleProviders) { + if (mobileBookMarkStyle.getClass() == bookMarkStyleProvider.classForMobileBookMarkStyle()) { + String displayName = bookMarkStyleProvider.displayName(); + bookMarkList.setSelectedIndex(i); + map.get(displayName).populateBean(mobileBookMarkStyle); + card.show(rightPane, displayName); + return; + } + i++; + } + } + bookMarkList.setSelectedIndex(0); + } + + @Override + public MobileBookMarkStyle updateBean() { + return map.get(bookMarkList.getSelectedValue()).updateBean(); + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java new file mode 100644 index 0000000000..766f06d511 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java @@ -0,0 +1,72 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.gui.itextfield.UIIntNumberField; +import com.fr.design.gui.itextfield.UINumberField; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.widget.UITitleSplitLine; +import com.fr.form.ui.mobile.MobileCollapsedStyle; +import com.fr.form.ui.mobile.MobileFormCollapsedStyle; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/2/13 + */ +public class MobileCollapsedStyleExpandPane extends MobileCollapsedStylePane { + + private static final Dimension DEFAULT_SPINNER_SIZE = new Dimension(60, 24); + + private UISpinner rowSpinner; + + public MobileCollapsedStyleExpandPane() { + } + + + @Override + protected JPanel createLinePane() { + UITitleSplitLine splitLine = new UITitleSplitLine(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Line_Number"), 520); + splitLine.setPreferredSize(new Dimension(520, 20)); + this.rowSpinner = new UISpinner(1, Integer.MAX_VALUE, 1, 1) { + @Override + protected UINumberField initNumberField(){ + return new UIIntNumberField(); + } + }; + rowSpinner.setPreferredSize(DEFAULT_SPINNER_SIZE); + JPanel panel = new JPanel(); + panel.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); + panel.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Start_From"))); + panel.add(rowSpinner); + panel.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Row_To_Fold"))); + JPanel linePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + linePane.add(splitLine, BorderLayout.NORTH); + linePane.add(panel, BorderLayout.CENTER); + return linePane; + } + + @Override + public void populateBean(MobileCollapsedStyle ob) { + super.populateBean(ob); + rowSpinner.setValue(((MobileFormCollapsedStyle) ob).getLineAttr().getNumber()); + } + + @Override + public MobileCollapsedStyle updateBean() { + MobileCollapsedStyle style = super.updateBean(); + ((MobileFormCollapsedStyle) style).getLineAttr().setNumber((int) rowSpinner.getValue()); + return style; + } + + @Override + protected MobileCollapsedStyle updateDiffBean() { + return new MobileFormCollapsedStyle(); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStylePane.java new file mode 100644 index 0000000000..74538e77c5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStylePane.java @@ -0,0 +1,145 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.gui.ibutton.ModeButtonGroup; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.layout.VerticalFlowLayout; +import com.fr.design.mainframe.widget.UITitleSplitLine; +import com.fr.design.style.color.NewColorSelectBox; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.form.ui.mobile.CollapseState; +import com.fr.form.ui.mobile.MobileChartCollapsedStyle; +import com.fr.form.ui.mobile.MobileCollapsedStyle; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +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.FlowLayout; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/2/13 + */ +public class MobileCollapsedStylePane extends BasicBeanPane { + + private UICheckBox showButtonCheck; + private NewColorSelectBox buttonColorBox; + private UITextField foldedTextFiled; + private UITextField unfoldedTextFiled; + private ModeButtonGroup buttonGroup; + + + public MobileCollapsedStylePane() { + TitledBorder titledBorder = GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"), null); + VerticalFlowLayout layout = new VerticalFlowLayout(FlowLayout.LEADING, 0, 10); + layout.setAlignLeft(true); + this.setBorder(titledBorder); + this.setLayout(layout); + this.add(createLinePane()); + this.add(createSettingPane()); + } + + private JPanel createSettingPane() { + JPanel settingPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 0); + UITitleSplitLine splitLine = new UITitleSplitLine(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Button"), 520); + splitLine.setPreferredSize(new Dimension(520, 20)); + UILabel showButtonLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Show_Button")); + showButtonCheck = new UICheckBox(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Show_Button_On_Right")); + showButtonCheck.setPreferredSize(new Dimension(140, 24)); + UILabel buttonColorLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Button_Color")); + buttonColorBox = new NewColorSelectBox(137); + UILabel foldedLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Folded_Hint")); + foldedTextFiled = new UITextField(); + UILabel unfoldedLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_UnFolded_Hint")); + unfoldedTextFiled = new UITextField(); + UILabel defaultStateLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Default_State")); + buttonGroup = new ModeButtonGroup<>(); + UIRadioButton foldedButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Fold")); + foldedButton.setSelected(true); + UIRadioButton unfoldedButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Unfold")); + buttonGroup.put(CollapseState.FOLDED, foldedButton); + buttonGroup.put(CollapseState.UNFOLDED, unfoldedButton); + JPanel flowLeftPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); + flowLeftPane.add(foldedButton); + flowLeftPane.add(unfoldedButton); + Component[][] northComponents = new Component[][] { + new Component[] {showButtonLabel, showButtonCheck} + }; + Component[][] southComponents = new Component[][] { + new Component[] {defaultStateLabel, flowLeftPane} + }; + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p, p, p, p}; + double[] colSize = {p, f}; + int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}}; + Component[][] centerComponents = new Component[][] { + new Component[] {buttonColorLabel, buttonColorBox}, + new Component[] {foldedLabel, foldedTextFiled}, + new Component[] {unfoldedLabel, unfoldedTextFiled}, + }; + JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(northComponents, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W2, IntervalConstants.INTERVAL_L1); + JPanel southPane = TableLayoutHelper.createGapTableLayoutPane(southComponents, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); + final JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(centerComponents, rowSize, colSize, rowCount, LayoutConstants.HGAP_LARGE, LayoutConstants.VGAP_SMALL); + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + panel.add(northPane, BorderLayout.NORTH); + panel.add(centerPane, BorderLayout.CENTER); + panel.add(southPane, BorderLayout.SOUTH); + settingPane.add(splitLine); + settingPane.add(panel); + showButtonCheck.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + centerPane.setVisible(showButtonCheck.isSelected()); + } + }); + return settingPane; + } + + protected JPanel createLinePane() { + return FRGUIPaneFactory.createBorderLayout_S_Pane(); + } + + @Override + public void populateBean(MobileCollapsedStyle ob) { + showButtonCheck.setSelected(ob.getCollapseButton().isShowButton()); + buttonColorBox.setSelectObject(ob.getCollapseButton().getButtonColor()); + foldedTextFiled.setText(ob.getCollapseButton().getFoldedHint()); + unfoldedTextFiled.setText(ob.getCollapseButton().getUnfoldedHint()); + buttonGroup.setSelectButton(ob.getCollapseButton().getDefaultState()); + } + + @Override + public MobileCollapsedStyle updateBean() { + MobileCollapsedStyle style = updateDiffBean(); + style.getCollapseButton().setShowButton(showButtonCheck.isSelected()); + style.getCollapseButton().setButtonColor(buttonColorBox.getSelectObject()); + style.getCollapseButton().setFoldedHint(foldedTextFiled.getText()); + style.getCollapseButton().setUnfoldedHint(unfoldedTextFiled.getText()); + style.getCollapseButton().setDefaultState(buttonGroup.getCurrentSelected()); + return style; + } + + protected MobileCollapsedStyle updateDiffBean() { + return new MobileChartCollapsedStyle(); + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Mobile_Collapse_Expand"); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileComboBoxDialogEditor.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileComboBoxDialogEditor.java new file mode 100644 index 0000000000..6e9b74a1dd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileComboBoxDialogEditor.java @@ -0,0 +1,100 @@ +package com.fr.design.mainframe.mobile.ui; + +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.gui.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; +import com.fr.form.ui.mobile.MobileCollapsedStyle; +import com.fr.general.ComparatorUtils; + +import javax.swing.SwingUtilities; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/2/13 + */ +public class MobileComboBoxDialogEditor extends BasicPane { + + private static final Dimension DEFAULT_DIMENSION = new Dimension(600, 400); + private static final Dimension COMBOX_DIMENSION = new Dimension(135,20); + private static final String NONE = Toolkit.i18nText("Fine-Design_Mobile_Collapse_None"); + private static final String CUSTOM = Toolkit.i18nText("Fine-Design_Mobile_Collapse_Custom"); + + + private MobileCollapsedStyle style; + private MobileCollapsedStylePane stylePane; + private UIComboBox comboBox; + private ActionListener listener; + + public MobileComboBoxDialogEditor(MobileCollapsedStylePane stylePane) { + this.stylePane = stylePane; + this.comboBox = new UIComboBox(new Object[] {NONE, CUSTOM}); + this.comboBox.setPreferredSize(COMBOX_DIMENSION); + this.comboBox.setSelectedItem(NONE); + listener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (ComparatorUtils.equals(MobileComboBoxDialogEditor.this.comboBox.getSelectedItem(), CUSTOM)) { + showEditorPane(); + } + } + }; + this.comboBox.addActionListener(listener); + this.add(comboBox); + + } + + public boolean isSelectedCustom() { + return ComparatorUtils.equals(CUSTOM, this.comboBox.getSelectedItem()); + } + + public void setSelected(boolean selectedCustom) { + this.comboBox.removeActionListener(listener); + this.comboBox.setSelectedItem(selectedCustom ? CUSTOM : NONE); + this.comboBox.addActionListener(listener); + } + + private void showEditorPane() { + stylePane.setPreferredSize(DEFAULT_DIMENSION); + BasicDialog dialog = stylePane.showWindow(SwingUtilities.getWindowAncestor(this)); + dialog.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + MobileCollapsedStyle style = stylePane.updateBean(); + style.setCollapsedWork(true); + setStyle(style); + MobileComboBoxDialogEditor.this.firePropertyChanged(); + } + }); + stylePane.populateBean(getStyle()); + dialog.setVisible(true); + } + + + protected void firePropertyChanged() { + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(); + } + + public MobileCollapsedStyle getStyle() { + return style; + } + + public void setStyle(MobileCollapsedStyle style) { + this.style = style; + } + + @Override + protected String title4PopupWindow() { + return null; + } + + + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStylePane.java index d0e949fa9c..3573427ca9 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStylePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStylePane.java @@ -13,9 +13,9 @@ import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; import javax.swing.*; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; import java.util.HashMap; import java.util.Map; @@ -79,8 +79,8 @@ public class MobileStylePane extends BasicPane { private void addWestList() { styleList = new JList<>(listModel); styleList.setCellRenderer(render); - styleList.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { + styleList.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent e) { String selectedValue = (String)styleList.getSelectedValue(); card.show(right, selectedValue); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleCustomDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleCustomDefinePane.java new file mode 100644 index 0000000000..79bab33dfc --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleCustomDefinePane.java @@ -0,0 +1,387 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.base.BaseUtils; +import com.fr.base.Utils; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.ibutton.UIToggleButton; +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.UnsignedIntUISpinner; +import com.fr.design.gui.style.FRFontPane; +import com.fr.design.gui.style.NumberDragBar; +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.color.ColorSelectBox; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.form.ui.mobile.MobileBookMarkStyle; +import com.fr.form.ui.mobile.impl.SidebarMobileBookMarkStyle; +import com.fr.stable.CoreConstants; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; + +/** + * @author Starryi + * @version 10.0 + * Created by Starryi on 2020/02/28 + */ +public class SidebarMobileBookMarkStyleCustomDefinePane extends BasicBeanPane { + private static final long serialVersionUID = 1L; + + private static final int COLUMN_WIDTH = 160; + + private UnsignedIntUISpinner buttonWidthSpinner; + private UnsignedIntUISpinner buttonHeightSpinner; + private UnsignedIntUISpinner buttonGapSpinner; + private UnsignedIntUISpinner buttonBorderRadiusSpinner; + + private ColorSelectBox normalBackgroundColorBox; + private NumberDragBar normalOpacityDragBar; + private UnsignedIntUISpinner normalOpacitySpinner; + private LineComboBox normalBorderWidthComBox; + private ColorSelectBox normalBorderColorBox; + private UIComboBox normalFontNameComboBox; + private UIComboBox normalFontSizeComboBox; + private UIColorButton normalFontColorButton; + private UIToggleButton normalFontItalicButton; + private UIToggleButton normalFontBoldButton; + + private ColorSelectBox selectedBackgroundColorBox; + private NumberDragBar selectedOpacityDragBar; + private UnsignedIntUISpinner selectedOpacitySpinner; + private LineComboBox selectedBorderWidthComBox; + private ColorSelectBox selectedBorderColorBox; + private UIComboBox selectedFontNameComboBox; + private UIComboBox selectedFontSizeComboBox; + private UIColorButton selectedFontColorButton; + private UIToggleButton selectedFontItalicButton; + private UIToggleButton selectedFontBoldButton; + + private SidebarMobileBookMarkStyle DEFAULT_STYLE = new SidebarMobileBookMarkStyle(); + + public SidebarMobileBookMarkStyleCustomDefinePane() { + this.initComponent(); + } + + private void initComponent() { + this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + this.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + + this.add(this.createNavButtonStylePanel()); + this.add(this.createNormalStateStylePanel()); + this.add(this.createSelectedStateStylePanel()); + } + + private JPanel createNavButtonStylePanel() { + + buttonWidthSpinner = new UnsignedIntUISpinner(20, 150, 1, DEFAULT_STYLE.getWidth()); + buttonHeightSpinner = new UnsignedIntUISpinner(20, 100, 1, DEFAULT_STYLE.getHeight()); + buttonGapSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, DEFAULT_STYLE.getGap()); + buttonBorderRadiusSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, DEFAULT_STYLE.getBorderRadius()); + + UILabel sizeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Size") + ":", + SwingConstants.RIGHT); + JPanel sizePane = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(2, 5, 0); + sizePane.add(buttonWidthSpinner); + sizePane.add(buttonHeightSpinner); + + JPanel sizeTipsPane = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(2, 5, 0); + sizeTipsPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Width"), + SwingConstants.CENTER)); + sizeTipsPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Height"), + SwingConstants.CENTER)); + + UILabel gapLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Gap") + ":", + SwingConstants.RIGHT); + UILabel borderRadiusLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Border_Radius") + ":", + SwingConstants.RIGHT); + + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p, p, p}; + double[] columnSize = {p, COLUMN_WIDTH}; + double[] verticalGaps = {0, 10, 10}; + + JPanel navButtonSettingsPanel = TableLayoutHelper.createDiffVGapTableLayoutPane(new JComponent[][]{ + {sizeLabel, sizePane}, + {null, sizeTipsPane}, + {gapLabel, buttonGapSpinner}, + {borderRadiusLabel, buttonBorderRadiusSpinner}, + }, rowSize, columnSize, 5, verticalGaps); + + navButtonSettingsPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); + + JPanel containerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + containerPane.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Style"), + Color.decode("#2F8EF1"))); + containerPane.add(navButtonSettingsPanel); + + return containerPane; + } + + private JPanel createNormalStateStylePanel() { + double p = TableLayout.PREFERRED; + + normalBackgroundColorBox = new ColorSelectBox(COLUMN_WIDTH); + normalBackgroundColorBox.setSelectObject(DEFAULT_STYLE.getBackgroundColor()); + normalOpacityDragBar = new NumberDragBar(0, 100); + normalOpacityDragBar.setValue(DEFAULT_STYLE.getOpacity()); + normalOpacityDragBar.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + normalOpacitySpinner.setValue(normalOpacityDragBar.getValue()); + } + }); + normalOpacitySpinner = new UnsignedIntUISpinner(0, 100, 1, DEFAULT_STYLE.getOpacity()); + normalOpacitySpinner.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + normalOpacityDragBar.setValue((int) normalOpacitySpinner.getValue()); + } + }); + normalBorderWidthComBox = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY); + normalBorderWidthComBox.setSelectedLineStyle(DEFAULT_STYLE.getBorderWidth()); + normalBorderColorBox = new ColorSelectBox(COLUMN_WIDTH); + normalBorderColorBox.setSelectObject(DEFAULT_STYLE.getBorderColor()); + normalFontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); + normalFontNameComboBox.setSelectedItem(DEFAULT_STYLE.getSelectedFontFamily()); + normalFontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); + normalFontSizeComboBox.setSelectedItem(DEFAULT_STYLE.getFontSize()); + normalFontColorButton = new UIColorButton(); + normalFontColorButton.setColor(DEFAULT_STYLE.getFontColor()); + normalFontItalicButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); + normalFontItalicButton.setSelected(DEFAULT_STYLE.isFontItalic()); + normalFontBoldButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); + normalFontBoldButton.setSelected(DEFAULT_STYLE.isFontBold()); + + JPanel opacityPane = new JPanel(new BorderLayout(0, 0)); + JPanel jp = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(2, 5, 0); + jp.add(normalOpacityDragBar); + jp.add(normalOpacitySpinner); + opacityPane.add(jp, BorderLayout.CENTER); + + JPanel fontExtraPane = TableLayoutHelper.createGapTableLayoutPane( + new JComponent[][]{{normalFontSizeComboBox, normalFontColorButton, normalFontItalicButton, normalFontBoldButton}}, + new double[]{p}, + new double[]{p, p, p, p}, + 0, 5 + ); + + double[] rowSize = {p, p, p, p, p}; + double[] columnSize = {p, COLUMN_WIDTH, p}; + + JPanel normalStateStyleSettingsPanel = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Background_Color") + ":", SwingConstants.RIGHT), + normalBackgroundColorBox + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Opacity") + ":", SwingConstants.RIGHT), + opacityPane, + new UILabel("%") + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Border_Width") + ":", SwingConstants.RIGHT), + normalBorderWidthComBox + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Border_Color") + ":", SwingConstants.RIGHT), + normalBorderColorBox + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Font") + ":", SwingConstants.RIGHT), + normalFontNameComboBox, + fontExtraPane + } + }, rowSize, columnSize, 5, 10); + normalStateStyleSettingsPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); + + JPanel containerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + containerPane.setBorder( + GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Normal_Style"), + Color.decode("#2F8EF1")) + ); + containerPane.add(normalStateStyleSettingsPanel); + + return containerPane; + } + + private JPanel createSelectedStateStylePanel() { + double p = TableLayout.PREFERRED; + + selectedBackgroundColorBox = new ColorSelectBox(COLUMN_WIDTH); + selectedBackgroundColorBox.setSelectObject(DEFAULT_STYLE.getSelectedBackgroundColor()); + selectedOpacityDragBar = new NumberDragBar(0, 100); + selectedOpacityDragBar.setValue(DEFAULT_STYLE.getSelectedOpacity()); + selectedOpacityDragBar.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + selectedOpacitySpinner.setValue(selectedOpacityDragBar.getValue()); + } + }); + selectedOpacitySpinner = new UnsignedIntUISpinner(0, 100, 1, DEFAULT_STYLE.getSelectedOpacity()); + selectedOpacitySpinner.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + selectedOpacityDragBar.setValue((int) selectedOpacitySpinner.getValue()); + } + }); + selectedBorderWidthComBox = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY); + selectedBorderWidthComBox.setSelectedLineStyle(DEFAULT_STYLE.getSelectedBorderWidth()); + selectedBorderColorBox = new ColorSelectBox(COLUMN_WIDTH); + selectedBorderColorBox.setSelectObject(DEFAULT_STYLE.getSelectedBorderColor()); + selectedFontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); + selectedFontNameComboBox.setSelectedItem(DEFAULT_STYLE.getSelectedFontFamily()); + selectedFontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); + selectedFontSizeComboBox.setSelectedItem(DEFAULT_STYLE.getSelectedFontSize()); + selectedFontColorButton = new UIColorButton(); + selectedFontColorButton.setColor(DEFAULT_STYLE.getSelectedFontColor()); + selectedFontItalicButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); + selectedFontItalicButton.setSelected(DEFAULT_STYLE.isSelectedFontItalic()); + selectedFontBoldButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); + selectedFontBoldButton.setSelected(DEFAULT_STYLE.isSelectedFontBold()); + + JPanel opacityPane = new JPanel(new BorderLayout(0, 0)); + JPanel jp = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(2, 5, 0); + jp.add(selectedOpacityDragBar); + jp.add(selectedOpacitySpinner); + opacityPane.add(jp, BorderLayout.CENTER); + + JPanel fontExtraPane = TableLayoutHelper.createGapTableLayoutPane( + new JComponent[][]{{selectedFontSizeComboBox, selectedFontColorButton, selectedFontItalicButton, selectedFontBoldButton}}, + new double[]{p}, + new double[]{p, p, p, p}, + 0, 5 + ); + + double[] rowSize = {p, p, p, p, p}; + double[] columnSize = {p, COLUMN_WIDTH, p}; + + JPanel selectedStateStyleSettingsPanel = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Background_Color") + ":", SwingConstants.RIGHT), + selectedBackgroundColorBox + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Opacity") + ":", SwingConstants.RIGHT), + opacityPane, + new UILabel("%") + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Border_Width") + ":", SwingConstants.RIGHT), + selectedBorderWidthComBox + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Border_Color") + ":", SwingConstants.RIGHT), + selectedBorderColorBox + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Font") + ":", SwingConstants.RIGHT), + selectedFontNameComboBox, + fontExtraPane + } + }, rowSize, columnSize, 5, 10); + selectedStateStyleSettingsPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); + + JPanel containerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + containerPane.setBorder( + GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Selected_Style"), + Color.decode("#2F8EF1")) + ); + containerPane.add(selectedStateStyleSettingsPanel); + + return containerPane; + } + + @Override + public void populateBean(MobileBookMarkStyle ob) { + SidebarMobileBookMarkStyle style = null; + if (ob instanceof SidebarMobileBookMarkStyle) { + style = (SidebarMobileBookMarkStyle) ob; + } + if (style == null) { + return; + } + + buttonWidthSpinner.setValue(style.getWidth()); + buttonHeightSpinner.setValue(style.getHeight()); + buttonGapSpinner.setValue(style.getGap()); + buttonBorderRadiusSpinner.setValue(style.getBorderRadius()); + + normalBackgroundColorBox.setSelectObject(style.getBackgroundColor()); + normalOpacityDragBar.setValue(style.getOpacity()); + normalOpacitySpinner.setValue(style.getOpacity()); + normalBorderWidthComBox.setSelectedLineStyle(style.getBorderWidth()); + normalBorderColorBox.setSelectObject(style.getBorderColor()); + normalFontNameComboBox.setSelectedItem(style.getFontFamily()); + normalFontSizeComboBox.setSelectedItem(style.getFontSize()); + normalFontColorButton.setColor(style.getFontColor()); + normalFontItalicButton.setSelected(style.isFontItalic()); + normalFontBoldButton.setSelected(style.isFontBold()); + + selectedBackgroundColorBox.setSelectObject(style.getSelectedBackgroundColor()); + selectedOpacityDragBar.setValue(style.getSelectedOpacity()); + selectedOpacitySpinner.setValue(style.getSelectedOpacity()); + selectedBorderWidthComBox.setSelectedLineStyle(style.getSelectedBorderWidth()); + selectedBorderColorBox.setSelectObject(style.getSelectedBorderColor()); + selectedFontNameComboBox.setSelectedItem(style.getSelectedFontFamily()); + selectedFontSizeComboBox.setSelectedItem(style.getSelectedFontSize()); + selectedFontColorButton.setColor(style.getSelectedFontColor()); + selectedFontItalicButton.setSelected(style.isSelectedFontItalic()); + selectedFontBoldButton.setSelected(style.isSelectedFontBold()); + } + + @Override + public MobileBookMarkStyle updateBean() { + SidebarMobileBookMarkStyle style = new SidebarMobileBookMarkStyle(); + + style.setWidth((int) buttonWidthSpinner.getValue()); + style.setHeight((int) buttonHeightSpinner.getValue()); + style.setGap((int) buttonGapSpinner.getValue()); + style.setBorderRadius((int) buttonBorderRadiusSpinner.getValue()); + + if (normalBackgroundColorBox.getSelectObject() != null) { + style.setBackgroundColor(normalBackgroundColorBox.getSelectObject()); + } + style.setOpacity((int) normalOpacitySpinner.getValue()); + style.setBorderWidth(normalBorderWidthComBox.getSelectedLineStyle()); + style.setBorderColor(normalBorderColorBox.getSelectObject()); + if (normalFontNameComboBox.getSelectedItem() != null) { + style.setFontFamily((String) normalFontNameComboBox.getSelectedItem()); + } + if (normalFontSizeComboBox.getSelectedItem() != null) { + style.setFontSize((Integer) normalFontSizeComboBox.getSelectedItem()); + } + style.setFontColor(normalFontColorButton.getColor()); + style.setFontItalic(normalFontItalicButton.isSelected()); + style.setFontBold(normalFontBoldButton.isSelected()); + + if (selectedBackgroundColorBox.getSelectObject() != null) { + style.setSelectedBackgroundColor(selectedBackgroundColorBox.getSelectObject()); + } + style.setSelectedOpacity((int) selectedOpacitySpinner.getValue()); + style.setSelectedBorderWidth(selectedBorderWidthComBox.getSelectedLineStyle()); + style.setSelectedBorderColor(selectedBorderColorBox.getSelectObject()); + if (selectedFontNameComboBox.getSelectedItem() != null) { + style.setSelectedFontFamily((String) selectedFontNameComboBox.getSelectedItem()); + } + if (selectedFontSizeComboBox.getSelectedItem() != null) { + style.setSelectedFontSize((Integer) selectedFontSizeComboBox.getSelectedItem()); + } + style.setSelectedFontColor(selectedFontColorButton.getColor()); + style.setSelectedFontItalic(selectedFontItalicButton.isSelected()); + style.setSelectedFontBold(selectedFontBoldButton.isSelected()); + + return style; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleProvider.java new file mode 100644 index 0000000000..7c9202f3fd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleProvider.java @@ -0,0 +1,30 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.fun.impl.AbstractMobileBookMarkStyleProvider; +import com.fr.design.i18n.Toolkit; +import com.fr.form.ui.mobile.MobileBookMarkStyle; +import com.fr.form.ui.mobile.impl.SidebarMobileBookMarkStyle; + +/** + * @author Starryi + * @version 10.0 + * Created by Starryi on 2020/02/28 + */ +public class SidebarMobileBookMarkStyleProvider extends AbstractMobileBookMarkStyleProvider { + + @Override + public Class classForMobileBookMarkStyle() { + return SidebarMobileBookMarkStyle.class; + } + + @Override + public Class> classForMobileBookMarkStyleAppearance() { + return SidebarMobileBookMarkStyleCustomDefinePane.class; + } + + @Override + public String displayName() { + return Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar"); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java index db489fb3c5..694389f30a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.template.info; import com.fr.design.mainframe.SiteCenterToken; -import com.fr.general.CloudCenter; +import com.fr.design.mainframe.burying.point.BasePointInfo; import com.fr.general.ComparatorUtils; import com.fr.general.http.HttpToolbox; import com.fr.json.JSONObject; @@ -14,23 +14,20 @@ import java.util.Map; * 负责向服务器发送信息 * Created by plough on 2019/4/18. */ -class SendHelper { - private static final String CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("tempinfo.consuming") + "/single"; - private static final String PROCESS_URL = CloudCenter.getInstance().acquireUrlByKind("tempinfo.process") + "/single"; - - private static boolean sendConsumingInfo(String content) { - return sendSingleTemplateInfo(CONSUMING_URL, content); - } - - private static boolean sendProcessInfo(String content) { - return sendSingleTemplateInfo(PROCESS_URL, content); - } - - static boolean sendTemplateInfo(TemplateInfo templateInfo) { - return SendHelper.sendConsumingInfo(templateInfo.getConsumingMapJsonString()) && SendHelper.sendProcessInfo(templateInfo.getProcessMapJsonString()); +public class SendHelper { + + public static boolean sendPointInfo(BasePointInfo pointInfo) { + boolean success = true; + Map sendInfo = pointInfo.getSendInfo(); + for (Map.Entry entry : sendInfo.entrySet()) { + if (!sendSinglePointInfo(entry.getKey(), entry.getValue())) { + success = false; + } + } + return success; } - private static boolean sendSingleTemplateInfo(String url, String content) { + private static boolean sendSinglePointInfo(String url, String content) { Map para = new HashMap<>(); para.put("token", SiteCenterToken.generateToken()); para.put("content", content); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java index 900210bd0c..e233bc6e53 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java @@ -2,13 +2,13 @@ package com.fr.design.mainframe.template.info; import com.fr.config.MarketConfig; import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.burying.point.AbstractPointInfo; +import com.fr.general.CloudCenter; import com.fr.general.GeneralUtils; import com.fr.json.JSONObject; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; -import com.fr.stable.xml.XMLReadable; -import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLableReader; import java.text.SimpleDateFormat; @@ -20,9 +20,12 @@ import java.util.Map; * 对应一张模版的记录 * Created by plough on 2019/4/18. */ -class TemplateInfo implements XMLReadable, XMLWriter { +public class TemplateInfo extends AbstractPointInfo { static final String XML_TAG = "TemplateInfo"; + private static final String CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("tempinfo.consuming") + "/single"; + private static final String PROCESS_URL = CloudCenter.getInstance().acquireUrlByKind("tempinfo.process") + "/single"; + private static final String XML_PROCESS_MAP = "processMap"; private static final String XML_CONSUMING_MAP = "consumingMap"; private static final String ATTR_DAY_COUNT = "day_count"; @@ -47,7 +50,6 @@ class TemplateInfo implements XMLReadable, XMLWriter { private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数 private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数 - private int idleDayCount; // 到现在为止,模版闲置(上次保存后没有再编辑过)的天数 private String templateID = StringUtils.EMPTY; private String originID = StringUtils.EMPTY; // todo: processMap 和 consumingMap 还可以再拆解为小类,以后继续重构 @@ -62,17 +64,22 @@ class TemplateInfo implements XMLReadable, XMLWriter { this.originID = originID; } - static TemplateInfo newInstanceByRead(XMLableReader reader) { + @Override + protected String key() { + return templateID; + } + + public static TemplateInfo newInstanceByRead(XMLableReader reader) { TemplateInfo templateInfo = new TemplateInfo(); reader.readXMLObject(templateInfo); return templateInfo; } - static TemplateInfo newInstance(String templateID) { + public static TemplateInfo newInstance(String templateID) { return newInstance(templateID, StringUtils.EMPTY, 0); } - static TemplateInfo newInstance(String templateID, String originID, int originTime) { + public static TemplateInfo newInstance(String templateID, String originID, int originTime) { HashMap consumingMap = new HashMap<>(); String username = MarketConfig.getInstance().getBbsUsername(); @@ -107,9 +114,10 @@ class TemplateInfo implements XMLReadable, XMLWriter { } int getTimeConsume() { - return (int)consumingMap.get(ATTR_TIME_CONSUME); + return (int) consumingMap.get(ATTR_TIME_CONSUME); } + @Override public void writeXML(XMLPrintWriter writer) { writer.startTAG(XML_TAG); if (StringUtils.isNotEmpty(templateID)) { @@ -144,13 +152,14 @@ class TemplateInfo implements XMLReadable, XMLWriter { writer.attr(ATTR_JAR_TIME, (String) consumingMap.get(ATTR_JAR_TIME)); writer.attr(ATTR_CREATE_TIME, (String) consumingMap.get(ATTR_CREATE_TIME)); writer.attr(ATTR_UUID, (String) consumingMap.get(ATTR_UUID)); - writer.attr(ATTR_TIME_CONSUME, (int)consumingMap.get(ATTR_TIME_CONSUME)); - writer.attr(ATTR_ORIGIN_TIME, (int)consumingMap.get(ATTR_ORIGIN_TIME)); + writer.attr(ATTR_TIME_CONSUME, (int) consumingMap.get(ATTR_TIME_CONSUME)); + writer.attr(ATTR_ORIGIN_TIME, (int) consumingMap.get(ATTR_ORIGIN_TIME)); writer.attr(ATTR_VERSION, (String) consumingMap.get(ATTR_VERSION)); writer.attr(ATTR_USERNAME, (String) consumingMap.get(ATTR_USERNAME)); writer.end(); } + @Override public void readXML(XMLableReader reader) { if (!reader.isChildNode()) { idleDayCount = reader.getAttrAsInt(ATTR_DAY_COUNT, 0); @@ -185,7 +194,8 @@ class TemplateInfo implements XMLReadable, XMLWriter { } } - boolean isTestTemplate() { + @Override + protected boolean isTestTemplate() { if (!isComplete()) { return false; } @@ -195,6 +205,10 @@ class TemplateInfo implements XMLReadable, XMLWriter { int floatCount = (int) processMap.get(ATTR_FLOAT_COUNT); int blockCount = (int) processMap.get(ATTR_BLOCK_COUNT); int widgetCount = (int) processMap.get(ATTR_WIDGET_COUNT); + return isTestTemplate(reportType, cellCount, floatCount, blockCount, widgetCount); + } + + public static boolean isTestTemplate(int reportType, int cellCount, int floatCount, int blockCount, int widgetCount) { boolean isTestTemplate; if (reportType == 0) { // 普通报表 isTestTemplate = cellCount <= VALID_CELL_COUNT && floatCount <= 1 && widgetCount <= VALID_WIDGET_COUNT; @@ -206,7 +220,8 @@ class TemplateInfo implements XMLReadable, XMLWriter { return isTestTemplate; } - boolean isComplete() { + @Override + protected boolean isComplete() { // 条件 1. 超过15天未编辑 // 条件 2. 设计器在这段未编辑的时间内启动超过 X 次(目前定的 X = 3)。即"设计器最近 X 次启动的时间跨度" < "未编辑时间"; @@ -214,20 +229,16 @@ class TemplateInfo implements XMLReadable, XMLWriter { && DesignerOpenHistory.getInstance().isOpenEnoughTimesInPeriod(idleDayCount); } - String getConsumingMapJsonString() { - return new JSONObject(consumingMap).toString(); - } - - String getProcessMapJsonString() { - return new JSONObject(processMap).toString(); - } - - boolean isReadyForSend() { - return isComplete() && !isTestTemplate(); + @Override + public Map getSendInfo() { + Map sendMap = new HashMap<>(); + sendMap.put(CONSUMING_URL, new JSONObject(consumingMap).toString()); + sendMap.put(PROCESS_URL, new JSONObject(processMap).toString()); + return sendMap; } void addTimeConsume(int timeConsume) { - timeConsume += (int)consumingMap.get(ATTR_TIME_CONSUME); // 加上之前的累计编辑时间 + timeConsume += (int) consumingMap.get(ATTR_TIME_CONSUME); // 加上之前的累计编辑时间 consumingMap.put(ATTR_TIME_CONSUME, timeConsume); } @@ -246,14 +257,6 @@ class TemplateInfo implements XMLReadable, XMLWriter { this.processMap = processMap; } - void resetIdleDayCount() { - this.idleDayCount = 0; - } - - void addIdleDayCountByOne() { - this.idleDayCount += 1; - } - int getIdleDayCount() { return this.idleDayCount; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java index 9a13ed9d79..8c4e7f18d2 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java @@ -1,54 +1,26 @@ package com.fr.design.mainframe.template.info; -import com.fr.base.FRContext; -import com.fr.base.io.XMLReadHelper; -import com.fr.design.DesignerEnvManager; -import com.fr.log.FineLoggerFactory; +import com.fr.design.mainframe.burying.point.AbstractPointCollector; import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; -import com.fr.stable.xml.XMLReadable; -import com.fr.stable.xml.XMLTools; -import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLableReader; -import com.fr.third.javax.xml.stream.XMLStreamException; -import com.fr.third.org.apache.commons.io.FileUtils; -import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; /** * 做模板的过程和耗时收集,辅助类 * Created by plough on 2017/2/21. */ -public class TemplateInfoCollector implements XMLReadable, XMLWriter { +public class TemplateInfoCollector extends AbstractPointCollector { private static final String XML_TAG = "TplInfo"; private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList"; private static final String XML_FILE_NAME = "tpl.info"; private static TemplateInfoCollector instance; - private static final int MAX_SIZE = 512 * 1024 * 1024; - private Map templateInfoMap; private DesignerOpenHistory designerOpenHistory; private TemplateInfoCollector() { - init(); - } - - private void init() { - templateInfoMap = new HashMap<>(); - designerOpenHistory = DesignerOpenHistory.getInstance(); - - loadFromFile(); } public static TemplateInfoCollector getInstance() { @@ -62,17 +34,19 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter { * 根据模板ID是否在收集列表中,判断是否需要收集当前模板的信息 */ public boolean contains(String templateID) { - return StringUtils.isNotEmpty(templateID) && templateInfoMap.containsKey(templateID); + return StringUtils.isNotEmpty(templateID) && pointInfoMap.containsKey(templateID); } /** * 收集模板信息。如果之前没有记录,则新增;如果已有记录,则更新。 * 同时将最新数据保存到文件中。 - * @param templateID 模版id - * @param originID 模版的原始id,仅对另存为的模版有效,对于非另存为的模版,值总是为空 + * + * @param templateID 模版id + * @param originID 模版的原始id,仅对另存为的模版有效,对于非另存为的模版,值总是为空 * @param processInfo 包含模版的一些基本信息(如模版类型、包含控件数量等) * @param timeConsume 本次制作耗时,单位为 s */ + @Override public void collectInfo(String templateID, String originID, TemplateProcessInfo processInfo, int timeConsume) { if (!shouldCollectInfo()) { return; @@ -80,11 +54,11 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter { TemplateInfo templateInfo; if (this.contains(templateID)) { - templateInfo = templateInfoMap.get(templateID); + templateInfo = pointInfoMap.get(templateID); } else { - int originTime = this.contains(originID) ? templateInfoMap.get(originID).getTimeConsume() : 0; + int originTime = this.contains(originID) ? pointInfoMap.get(originID).getTimeConsume() : 0; templateInfo = TemplateInfo.newInstance(templateID, originID, originTime); - templateInfoMap.put(templateID, templateInfo); + pointInfoMap.put(templateID, templateInfo); } // 收集制作耗时 @@ -98,137 +72,51 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter { saveInfo(); } - /** - * 发送本地模板信息到服务器,并清空已发送模版的本地记录 - */ - public void sendTemplateInfo() { - // 每次启动设计器后,都会执行这个函数(被 InformationCollector 的 collectStartTime 调用) - addIdleDayCount(); - - removeTestTemplates(); - - List removeLaterList = new ArrayList<>(); - - for (String key : templateInfoMap.keySet()) { - TemplateInfo templateInfo = templateInfoMap.get(key); - if (templateInfo.isReadyForSend()) { - if (SendHelper.sendTemplateInfo(templateInfo)) { - removeLaterList.add(key); - } - } - } - - // 清空记录 - for (String key : removeLaterList) { - removeFromTemplateInfoList(key); - } - - saveInfo(); - } - /** * 获取缓存文件存放路径 */ - private static File getInfoFile() { + @Override + protected File getInfoFile() { return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), XML_FILE_NAME)); } - void loadFromFile() { - if (!getInfoFile().exists()) { - return; - } - - XMLableReader reader = null; - try (InputStream in = new FileInputStream(getInfoFile())) { - // XMLableReader 还是应该考虑实现 Closable 接口的,这样就能使用 try-with 语句了 - reader = XMLReadHelper.createXMLableReader(in, XMLPrintWriter.XML_ENCODER); - reader.readXMLObject(this); - } catch (FileNotFoundException e) { - // do nothing - } catch (XMLStreamException | IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } finally { - try { - if (reader != null) { - reader.close(); - } - } catch (XMLStreamException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - } - TemplateInfo getOrCreateTemplateInfoByID(String templateID) { - if (templateInfoMap.containsKey(templateID)) { - return templateInfoMap.get(templateID); + if (pointInfoMap.containsKey(templateID)) { + return pointInfoMap.get(templateID); } TemplateInfo templateInfo = TemplateInfo.newInstance(templateID); - templateInfoMap.put(templateID, templateInfo); + pointInfoMap.put(templateID, templateInfo); return templateInfo; } - private boolean shouldCollectInfo() { - return FileUtils.sizeOf(getInfoFile()) <= MAX_SIZE && DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); - } - - /** - * 将包含所有信息的对象保存到文件 - */ - private void saveInfo() { - try { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - XMLTools.writeOutputStreamXML(this, out); - out.flush(); - out.close(); - String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8); - FileUtils.writeStringToFile(getInfoFile(), fileContent, StandardCharsets.UTF_8); - } catch (Exception ex) { - FineLoggerFactory.getLogger().error(ex.getMessage()); - } - } - /** * 更新 day_count:打开设计器却未编辑模板的连续日子 */ - private void addIdleDayCount() { + @Override + protected void addIdleDayCount() { // 判断今天是否第一次打开设计器,为了防止同一天内,多次 addIdleDayCount if (designerOpenHistory.hasOpenedToday()) { return; } - for (TemplateInfo templateInfo : templateInfoMap.values()) { + for (TemplateInfo templateInfo : pointInfoMap.values()) { templateInfo.addIdleDayCountByOne(); } designerOpenHistory.update(); } - // 删除所有已完成的测试模版 - private void removeTestTemplates() { - ArrayList testTemplateKeys = new ArrayList<>(); // 保存测试模板的key - for (String key : templateInfoMap.keySet()) { - if (templateInfoMap.get(key).isTestTemplate()) { - testTemplateKeys.add(key); - } - } - // 删除测试模板 - for (String key : testTemplateKeys) { - removeFromTemplateInfoList(key); - } - } - - private void removeFromTemplateInfoList(String key) { - templateInfoMap.remove(key); - } - @Override public void readXML(XMLableReader reader) { if (reader.isChildNode()) { try { String name = reader.getTagName(); if (DesignerOpenHistory.XML_TAG.equals(name)) { + if (designerOpenHistory == null) { + designerOpenHistory = DesignerOpenHistory.getInstance(); + } reader.readXMLObject(designerOpenHistory); } else if (TemplateInfo.XML_TAG.equals(name)) { TemplateInfo templateInfo = TemplateInfo.newInstanceByRead(reader); - templateInfoMap.put(templateInfo.getTemplateID(), templateInfo); + pointInfoMap.put(templateInfo.getTemplateID(), templateInfo); } } catch (Exception ex) { // 什么也不做,使用默认值 @@ -243,7 +131,7 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter { designerOpenHistory.writeXML(writer); writer.startTAG(XML_TEMPLATE_INFO_LIST); - for (TemplateInfo templateInfo : templateInfoMap.values()) { + for (TemplateInfo templateInfo : pointInfoMap.values()) { templateInfo.writeXML(writer); } writer.end(); 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 d916d967fc..cdafa8c410 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 @@ -528,14 +528,14 @@ public abstract class ToolBarMenuDock { */ public ShortCut[] createHelpShortCuts() { final java.util.List shortCuts = new ArrayList(); - shortCuts.add(new WebDemoAction()); // 英文,把 video 和帮助文档放到 Help 下面 if (GeneralContext.getLocale().equals(Locale.US)) { shortCuts.add(new VideoAction()); shortCuts.add(new TutorialAction()); } - //远程不使用更新升级 + //远程不使用更新升级,产品演示 if (WorkContext.getCurrent().isLocal()) { + shortCuts.add(new WebDemoAction()); shortCuts.add(new SoftwareUpdateAction()); } if (AlphaFineConfigManager.isALPHALicAvailable()) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java index 15d8bae63e..8216ad5735 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java @@ -31,7 +31,7 @@ import java.util.List; public class FileVersionDialog extends UIDialog { - public static final long DELAY = 24 * 60 * 60 * 1000; + public static final long DELAY = 24 * 60 * 60 * 1000L; private UIButton okBtn; private UIButton cancelBtn; private DateEditor dateEditor; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java index cd01d409c4..2bd441c19e 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.vcs.ui; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.frpane.UITextPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; @@ -61,7 +62,7 @@ public class FileVersionRowPanel extends JPanel { confirmBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { - if (JOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Vcs_Version_Revert_Confirm"), Toolkit.i18nText("Fine-Design_Vcs_Version_Revert_Title"), + if (FineJOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Vcs_Version_Revert_Confirm"), Toolkit.i18nText("Fine-Design_Vcs_Version_Revert_Title"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { vcsEntity.setUsername(VcsHelper.getInstance().getCurrentUsername()); WorkContext.getCurrent().get(VcsOperator.class).rollbackTo(vcsEntity); @@ -75,7 +76,7 @@ public class FileVersionRowPanel extends JPanel { deleteBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { - if (JOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Vcs_Delete-Confirm"), Toolkit.i18nText("Fine-Design_Vcs_Remove"), + if (FineJOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Vcs_Delete-Confirm"), Toolkit.i18nText("Fine-Design_Vcs_Remove"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { try { WorkContext.getCurrent().get(VcsOperator.class).deleteVersion(vcsEntity.getFilename(), vcsEntity.getVersion()); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/widget/wrappers/MobileBookMarkStyleWrapper.java b/designer-base/src/main/java/com/fr/design/mainframe/widget/wrappers/MobileBookMarkStyleWrapper.java new file mode 100644 index 0000000000..85c98c1031 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/widget/wrappers/MobileBookMarkStyleWrapper.java @@ -0,0 +1,30 @@ +package com.fr.design.mainframe.widget.wrappers; + +import com.fr.design.Exception.ValidationException; +import com.fr.design.designer.properties.Decoder; +import com.fr.design.designer.properties.Encoder; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/24 + */ +public class MobileBookMarkStyleWrapper implements Encoder, Decoder { + @Override + public Object decode(String txt) { + return null; + } + + @Override + public void validate(String txt) throws ValidationException { + + } + + @Override + public String encode(Object v) { + if (v == null) { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_None_BookMark_Style"); + } + return v.toString(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/os/impl/MacOsAddListenerAction.java b/designer-base/src/main/java/com/fr/design/os/impl/MacOsAddListenerAction.java new file mode 100644 index 0000000000..bc09dbf6a1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/os/impl/MacOsAddListenerAction.java @@ -0,0 +1,45 @@ +package com.fr.design.os.impl; + +import com.fr.design.mainframe.DesignerContext; +import com.fr.exit.DesignerExiter; +import com.fr.invoke.Reflect; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.os.support.OSBasedAction; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/13 + */ +public class MacOsAddListenerAction implements OSBasedAction { + + @Override + public void execute(final Object... objects) { + try { + Class app = Class.forName("com.apple.eawt.Application"); + Class handler = Class.forName("com.apple.eawt.QuitHandler"); + Object instance = Proxy.newProxyInstance(handler.getClassLoader(), new Class[]{handler}, + new InvocationHandler() { + @Override + public Object invoke(Object proxy, Method method, + Object[] args) throws Throwable { + if ("handleQuitRequestWith".equals(method.getName())) { + if (DesignerContext.getDesignerFrame() != null && DesignerContext.getDesignerFrame().isShowing()) { + DesignerContext.getDesignerFrame().exit(); + } else { + DesignerExiter.getInstance().execute(); + } + } + return null; + } + }); + Reflect.on(Reflect.on(app).call("getApplication").get()).call("setQuitHandler", instance); + } catch (ClassNotFoundException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java b/designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java index 31aac9aa11..f6c0e30549 100644 --- a/designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java +++ b/designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java @@ -1,12 +1,19 @@ package com.fr.design.os.impl; import com.fr.base.FRContext; +import com.fr.general.CloudCenter; import com.fr.general.GeneralContext; +import com.fr.json.JSON; +import com.fr.json.JSONFactory; +import com.fr.json.JSONObject; +import com.fr.stable.StringUtils; import com.fr.stable.os.Arch; import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.support.SupportOS; import com.fr.workspace.WorkContext; +import java.util.Locale; + /** * @author pengda * @date 2019/10/9 @@ -44,10 +51,18 @@ public enum SupportOSImpl implements SupportOS { @Override public boolean support() { boolean isLocalEnv = WorkContext.getCurrent().isLocal(); - boolean isChineseEnv = GeneralContext.isChineseEnv(); boolean isLinux = OperatingSystem.isLinux(); // 远程设计和非中文环境以及Linux环境,都不生效 - return isLocalEnv && isChineseEnv && !isLinux; + return isLocalEnv && !isLinux && isPushByConf(); + } + + private boolean isPushByConf() { + String resp = CloudCenter.getInstance().acquireUrlByKind("update.push.conf"); + if (StringUtils.isEmpty(resp)) { + return Locale.CHINA.equals(GeneralContext.getLocale()); + } + JSONObject jo = JSONFactory.createJSON(JSON.OBJECT, resp); + return jo.getBoolean(GeneralContext.getLocale().toString()); } }, /** @@ -58,6 +73,30 @@ public enum SupportOSImpl implements SupportOS { public boolean support() { return FRContext.isChineseEnv() && !OperatingSystem.isMacos() && Arch.getArch() != Arch.ARM; } + }, + + /** + * mac下dock栏右键退出 + */ + DOCK_QUIT { + @Override + public boolean support() { + return OperatingSystem.isMacos(); + } + }, + + NON_GUARDIAN_START { + @Override + public boolean support() { + return OperatingSystem.isLinux() || Arch.getArch() == Arch.ARM; + } + }, + + DOCK_ICON { + @Override + public boolean support() { + return OperatingSystem.isMacos(); + } } } diff --git a/designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java b/designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java index 14487ca5fa..8e8819c67d 100644 --- a/designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java +++ b/designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java @@ -17,6 +17,7 @@ import com.fr.design.editor.editor.Editor; import com.fr.design.editor.editor.FloatEditor; import com.fr.design.editor.editor.IntegerEditor; import com.fr.design.editor.editor.TextEditor; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; @@ -24,6 +25,8 @@ import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import java.awt.*; import java.util.ArrayList; import java.util.Date; @@ -103,6 +106,12 @@ public class ParameterInputPane extends BasicPane { contentPane.add(flowTableLayoutHelper.createLabelFlowPane(parameterDisplayName + ":", editPane)); //add editor to parameter hashtable. + textF.getCurrentEditor().addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(); + } + }); this.editorNameMap.put(textF, parameter.getName()); nameAddedList.add(parameter.getName()); } diff --git a/designer-base/src/main/java/com/fr/design/remote/ui/AbstractListControlPane.java b/designer-base/src/main/java/com/fr/design/remote/ui/AbstractListControlPane.java index c41e4800a0..bca0422eab 100644 --- a/designer-base/src/main/java/com/fr/design/remote/ui/AbstractListControlPane.java +++ b/designer-base/src/main/java/com/fr/design/remote/ui/AbstractListControlPane.java @@ -6,6 +6,7 @@ import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.controlpane.ShortCut4JControlPane; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; @@ -367,7 +368,7 @@ public abstract class AbstractListControlPane extends BasicPane { checkValid(); } catch (Exception exp) { FineLoggerFactory.getLogger().error(exp.getMessage(), exp); - JOptionPane.showMessageDialog(AbstractListControlPane.this, exp.getMessage()); + FineJOptionPane.showMessageDialog(AbstractListControlPane.this, exp.getMessage()); authorityList.setSelectedIndex(idx); return true; } diff --git a/designer-base/src/main/java/com/fr/design/remote/ui/list/AddedMemberList.java b/designer-base/src/main/java/com/fr/design/remote/ui/list/AddedMemberList.java index 5c2b39e6d6..1fc67b2852 100644 --- a/designer-base/src/main/java/com/fr/design/remote/ui/list/AddedMemberList.java +++ b/designer-base/src/main/java/com/fr/design/remote/ui/list/AddedMemberList.java @@ -1,5 +1,6 @@ package com.fr.design.remote.ui.list; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.report.constant.RoleType; @@ -35,7 +36,7 @@ public class AddedMemberList extends MemberList { "Fine-Design_Basic_Utils_Are_You_Sure_To_Delete_The_Role_And_Its_Design_Authorities" : "Fine-Design_Basic_Utils_Are_You_Sure_To_Delete_The_User_And_Its_Design_Authorities"; if (member.isSelected() && member.hasAuthority()){ - int val = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText(keyTitle), + int val = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText(keyTitle), Toolkit.i18nText("Fine-Design_Basic_Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (val == JOptionPane.OK_OPTION) { member.setSelected(!member.isSelected()); diff --git a/designer-base/src/main/java/com/fr/design/remote/ui/list/AddingMemberList.java b/designer-base/src/main/java/com/fr/design/remote/ui/list/AddingMemberList.java index ea748816fc..5851ec48c6 100644 --- a/designer-base/src/main/java/com/fr/design/remote/ui/list/AddingMemberList.java +++ b/designer-base/src/main/java/com/fr/design/remote/ui/list/AddingMemberList.java @@ -1,5 +1,6 @@ package com.fr.design.remote.ui.list; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.report.constant.RoleType; @@ -37,7 +38,7 @@ public class AddingMemberList extends MemberList { "Fine-Design_Basic_Utils_Are_You_Sure_To_Delete_The_Role_And_Its_Design_Authorities" : "Fine-Design_Basic_Utils_Are_You_Sure_To_Delete_The_User_And_Its_Design_Authorities"; if (member.isSelected() && member.hasAuthority()){ - int val = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText(keyTitle), + int val = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText(keyTitle), Toolkit.i18nText("Fine-Design_Basic_Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (val == JOptionPane.OK_OPTION) { member.setSelected(!member.isSelected()); diff --git a/designer-base/src/main/java/com/fr/design/roleAuthority/ReportAndFSManagePane.java b/designer-base/src/main/java/com/fr/design/roleAuthority/ReportAndFSManagePane.java index d839461dda..65f66290ec 100644 --- a/designer-base/src/main/java/com/fr/design/roleAuthority/ReportAndFSManagePane.java +++ b/designer-base/src/main/java/com/fr/design/roleAuthority/ReportAndFSManagePane.java @@ -6,6 +6,7 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.Prepare4DataSourceChange; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itoolbar.UIToolbar; @@ -159,7 +160,7 @@ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSo */ private void checkChanges() { //如若有变化,则弹出下面的对话框 - int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Role_changed_Is_Refresh") + "?", + int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Role_changed_Is_Refresh") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); if (returnVal == JOptionPane.OK_OPTION) { roleTree.refreshTreeNode(); diff --git a/designer-base/src/main/java/com/fr/design/scrollruler/VerticalRulerUI.java b/designer-base/src/main/java/com/fr/design/scrollruler/VerticalRulerUI.java index 3e0a9eb068..2cd482e1e3 100644 --- a/designer-base/src/main/java/com/fr/design/scrollruler/VerticalRulerUI.java +++ b/designer-base/src/main/java/com/fr/design/scrollruler/VerticalRulerUI.java @@ -20,7 +20,7 @@ public class VerticalRulerUI extends RulerUI{ @Override protected void paintRuler(Graphics g, int showText, int extra, Dimension size, int ratio) { int k = pxToLength(extra) * ratio; - for (int i = k; i < (pxToLength(size.height + extra) + 1) * ratio; i++) { + for (int i = k; i < (pxToLength( (double)size.height + extra) + 1) * ratio; i++) { g.setColor(BaseRuler.UNIT_SIGN_COLOR); if (i % BaseRuler.SCALE_10 == 0) { double times = (double) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getJTemplateResolution() / ScreenResolution.getScreenResolution(); @@ -44,7 +44,7 @@ public class VerticalRulerUI extends RulerUI{ @Override protected void paintPTRuler(Graphics g, int extra, Dimension size, int unit) { int k = pxToLength(extra); - for (int i = unit * (k/unit); i < pxToLength(size.height + extra); i += unit) { + for (int i = unit * (k/unit); i < pxToLength((double)size.height + extra); i += unit) { g.setColor(BaseRuler.UNIT_SIGN_COLOR); if (i % BaseRuler.SCALE_100 == 0) { GraphHelper.drawLine(g, size.width, toPX(i) - extra, 0, toPX(i) - extra); diff --git a/designer-base/src/main/java/com/fr/design/style/BorderPane.java b/designer-base/src/main/java/com/fr/design/style/BorderPane.java index aa1185f5de..442f301894 100644 --- a/designer-base/src/main/java/com/fr/design/style/BorderPane.java +++ b/designer-base/src/main/java/com/fr/design/style/BorderPane.java @@ -14,6 +14,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.style.color.ColorSelectBox; +import com.fr.design.style.color.NewColorSelectBox; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; @@ -69,7 +70,7 @@ public class BorderPane extends BasicPane { private JToggleButton rightToggleButton; private LineComboBox currentLineCombo; - private ColorSelectBox currentLineColorPane; + private NewColorSelectBox currentLineColorPane; private UIButton insidebutton; @@ -88,7 +89,7 @@ public class BorderPane extends BasicPane { verticalToggleButton = new ToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/vertical.png"), BorderPane.VERTICAL_BORDER); rightToggleButton = new ToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/right.png"), BorderPane.RIGHT_BORDER); this.currentLineCombo = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY); - this.currentLineColorPane = new ColorSelectBox(100); + this.currentLineColorPane = new NewColorSelectBox(100); this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); this.setLayout(FRGUIPaneFactory.createBorderLayout()); diff --git a/designer-base/src/main/java/com/fr/design/style/background/impl/PatternBackgroundPane.java b/designer-base/src/main/java/com/fr/design/style/background/impl/PatternBackgroundPane.java index ffb4e1eb0b..886076ca08 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/impl/PatternBackgroundPane.java +++ b/designer-base/src/main/java/com/fr/design/style/background/impl/PatternBackgroundPane.java @@ -159,15 +159,15 @@ public class PatternBackgroundPane extends BPane { Dimension d = getSize(); this.patternBackground.paint(g2d, new Rectangle2D.Double(0, 0, - d.width - 1, d.height - 1)); + d.width - 1d, d.height - 1d)); if (this.pIndex == patternIndex) {// it's selected. g2d.setPaint(new Color(255, 51, 0)); } else { g2d.setPaint(Color.gray); } - GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, - d.height - 1)); + GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1d, + d.height - 1d)); } public Dimension getPreferredSize() { diff --git a/designer-base/src/main/java/com/fr/design/style/background/impl/TextureBackgroundPane.java b/designer-base/src/main/java/com/fr/design/style/background/impl/TextureBackgroundPane.java index 8c99a89cdd..3dd59bd5b4 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/impl/TextureBackgroundPane.java +++ b/designer-base/src/main/java/com/fr/design/style/background/impl/TextureBackgroundPane.java @@ -152,8 +152,8 @@ public class TextureBackgroundPane extends BPane { Dimension d = getSize(); g2d.setPaint(this.buttonTexturePaint); - GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, d.width - 1, - d.height - 1)); + GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, d.width - 1d, + d.height - 1d)); if (ComparatorUtils.equals(texturePaint, this.buttonTexturePaint)) {// it's // selected. @@ -161,8 +161,8 @@ public class TextureBackgroundPane extends BPane { } else { g2d.setPaint(Color.gray); } - GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1, - d.height - 1)); + GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1d, + d.height - 1d)); } public Dimension getPreferredSize() { 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 2099a1e8a0..4ee3a119ea 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 @@ -1,40 +1,45 @@ package com.fr.design.style.color; -import java.awt.BorderLayout; -import java.awt.Color; +import com.fr.design.gui.ipoppane.PopupHider; +import com.fr.design.layout.FRGUIPaneFactory; import javax.swing.JPopupMenu; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; - -import com.fr.design.gui.ipoppane.PopupHider; -import com.fr.design.layout.FRGUIPaneFactory; +import java.awt.BorderLayout; +import java.awt.Color; public abstract class ColorControlWindow extends JPopupMenu { - private static final long serialVersionUID = 4317136753151221742L; - private PopupHider popupHider; - private ColorSelectionPopupPane selectionPopupPane; - protected abstract void colorChanged(); + private static final long serialVersionUID = 4317136753151221742L; + private PopupHider popupHider; + private ColorSelectionPopupPane selectionPopupPane; + + protected abstract void colorChanged(); - /** + /** * Constructor. */ public ColorControlWindow(PopupHider popupHider) { - this(false,popupHider); + this(false, popupHider); } - /** + + /** * Constructor. */ public ColorControlWindow(boolean isSupportTransparent, PopupHider popupHider) { this.initComponents(isSupportTransparent); this.popupHider = popupHider; } - + public Color getColor() { - if(selectionPopupPane == null) { - return null; - } - return selectionPopupPane.getColor(); + if (selectionPopupPane == null) { + return null; + } + return selectionPopupPane.getColor(); + } + + public PopupHider getPopupHider() { + return popupHider; } /** @@ -48,34 +53,41 @@ public abstract class ColorControlWindow extends JPopupMenu { setOpaque(false); setDoubleBuffered(true); setFocusable(false); + initSelectionPopupPane(isSupportTransparent); + this.pack(); + } + + protected void initSelectionPopupPane(boolean isSupportTransparent) { selectionPopupPane = new ColorSelectionPopupPane(isSupportTransparent); this.add(selectionPopupPane, BorderLayout.CENTER); - this.pack(); } - + class ColorSelectionPopupPane extends NewColorSelectPane { - private static final long serialVersionUID = 7822856562329146354L; - public ColorSelectionPopupPane(boolean isSupportTransparent) { - super(isSupportTransparent); - this.addChangeListener(new ChangeListener() { - - @Override - public void stateChanged(ChangeEvent e) { - colorChanged(); - } - }); + private static final long serialVersionUID = 7822856562329146354L; + + public ColorSelectionPopupPane(boolean isSupportTransparent) { + super(isSupportTransparent); + this.addChangeListener(new ChangeListener() { + + @Override + public void stateChanged(ChangeEvent e) { + colorChanged(); + } + }); } + @Override protected void doTransparent() { - popupHider.hidePopupMenu(); - super.doTransparent(); - } - @Override - public void customButtonPressed() { - popupHider.hidePopupMenu(); - super.customButtonPressed(); - } - + popupHider.hidePopupMenu(); + super.doTransparent(); + } + + @Override + public void customButtonPressed() { + popupHider.hidePopupMenu(); + super.customButtonPressed(); + } + } } \ No newline at end of file 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 new file mode 100644 index 0000000000..cbb0e97eaa --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindowWithAuto.java @@ -0,0 +1,126 @@ +package com.fr.design.style.color; + +import com.fr.chart.base.ChartConstants; +import com.fr.design.border.UIRoundedBorder; +import com.fr.design.constants.UIConstants; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ipoppane.PopupHider; +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 javax.swing.JPanel; +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.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public abstract class ColorControlWindowWithAuto extends ColorControlWindow { + + private ColorSelectionPopupPaneWithAuto selectionPopupPaneWithAuto; + + public ColorControlWindowWithAuto(PopupHider popupHider) { + this(false, popupHider); + } + + public ColorControlWindowWithAuto(boolean isSupportTransparent, PopupHider popupHider) { + super(isSupportTransparent, popupHider); + } + + public Color getColor() { + if (selectionPopupPaneWithAuto == null) { + return null; + } + return selectionPopupPaneWithAuto.getColor(); + } + + protected void initSelectionPopupPane(boolean isSupportTransparent) { + selectionPopupPaneWithAuto = new ColorSelectionPopupPaneWithAuto(isSupportTransparent); + this.add(selectionPopupPaneWithAuto, BorderLayout.CENTER); + } + + class ColorSelectionPopupPaneWithAuto extends NewColorSelectPane { + private static final long serialVersionUID = 7822856562329146354L; + + private final static int BUTTON_HEIGHT = 15; + + public ColorSelectionPopupPaneWithAuto(boolean isSupportTransparent) { + super(isSupportTransparent); + + this.addChangeListener(new ChangeListener() { + + @Override + public void stateChanged(ChangeEvent e) { + colorChanged(); + } + }); + } + + protected void doTransparent() { + getPopupHider().hidePopupMenu(); + setColor(null); + } + + protected void doAuto() { + getPopupHider().hidePopupMenu(); + setColor(ChartConstants.AUTO_FONT_COLOR); + } + + public void customButtonPressed() { + getPopupHider().hidePopupMenu(); + super.customButtonPressed(); + } + + protected void initSelectButton(boolean isSupportTransparent) { + setSupportTransparent(isSupportTransparent); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(new UIRoundedBorder(UIConstants.TOOLBAR_BORDER_COLOR, 1, 5)); + + UIButton transparentButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency")); + UIButton autoButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto")); + + transparentButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doTransparent(); + } + }); + + autoButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doAuto(); + } + }); + + if (isSupportTransparent) { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {f, 0}; + double[] rowSize = {p, p}; + + Component[][] components = new Component[][]{ + new Component[]{autoButton, null}, + new Component[]{transparentButton, null} + }; + + JPanel buttonGroup = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + this.add(buttonGroup, BorderLayout.NORTH); + } else { + this.add(autoButton, BorderLayout.NORTH); + } + } + + 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); + } + + } + +} \ No newline at end of file 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 758c673fa6..13d8998222 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 @@ -11,6 +11,8 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.*; +import static com.fr.design.i18n.Toolkit.i18nText; + /** * 颜色选择器更多颜色面板 * @@ -56,7 +58,7 @@ public class ColorSelectDetailPane extends BasicPane { @Override protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_Color"); + return i18nText("Fine-Design_Basic_Select_Color"); } protected void initComponents() { @@ -65,20 +67,15 @@ public class ColorSelectDetailPane extends BasicPane { // 颜色选择器面板 selectedPanel = new JColorChooser(this.color); selectedPanel.setPreferredSize(new Dimension(selectedPanel.getWidth(), SELECT_PANEL_HEIGHT)); - AbstractColorChooserPanel[] choosers = selectedPanel.getChooserPanels(); - for (int i = 0; i < choosers.length; i++) { - selectedPanel.removeChooserPanel(choosers[i]); - } selectedPanel.setPreviewPanel(new JPanel()); AbstractColorChooserPanel swatchChooserPanel = new SwatchChooserPanel(); AbstractColorChooserPanel customChooserPanel = new CustomChooserPanel(); - selectedPanel.addChooserPanel(swatchChooserPanel); - selectedPanel.addChooserPanel(customChooserPanel); + selectedPanel.setChooserPanels(new AbstractColorChooserPanel[]{swatchChooserPanel, customChooserPanel}); this.add(selectedPanel, BorderLayout.NORTH); // 最近使用面板 - recentUsePanel = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Used")); + recentUsePanel = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Used")); RecentUseColorPane recent = new RecentUseColorPane(selectedPanel); recentUsePanel.add(recent); @@ -87,7 +84,7 @@ public class ColorSelectDetailPane extends BasicPane { selectedPanel.setPreviewPanel(new JPanel()); // 预览 - previewPanel = FRGUIPaneFactory.createTitledBorderPaneCenter(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview")); + previewPanel = FRGUIPaneFactory.createTitledBorderPaneCenter(i18nText("Fine-Design_Basic_Preview")); final ColorChooserPreview colorChooserPreview = new ColorChooserPreview(); ColorSelectionModel model = selectedPanel.getSelectionModel(); model.addChangeListener(new ChangeListener() { 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 d532324165..6c21c10cba 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 @@ -5,6 +5,7 @@ import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; 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; @@ -39,8 +40,8 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { // 是否支持透明 private boolean isSupportTransparent; - private final static int TRANSPANENT_WINDOW_HEIGHT = 165; - private final static int WINDWO_HEIGHT = 150; + public final static int TRANSPARENT_WINDOW_HEIGHT = 165; + public final static int WINDOW_HEIGHT = 150; // 最近使用颜色 private UsedColorPane usedColorPane; @@ -56,20 +57,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { * Constructor. */ NewColorSelectPane(boolean isSupportTransparent) { - this.isSupportTransparent = isSupportTransparent; - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.setBorder(new UIRoundedBorder(UIConstants.TOOLBAR_BORDER_COLOR, 1, 5)); - if (isSupportTransparent) { - UIButton transpanrentButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency")); - this.add(transpanrentButton, BorderLayout.NORTH); - transpanrentButton.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - doTransparent(); - } - }); - } + initSelectButton(isSupportTransparent); // center JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); @@ -97,7 +85,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { centerPane.add(Box.createVerticalStrut(1)); // mod by anchore 16/11/16 - final UIButton customButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_More_Color")); + final UIButton customButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_More_Color")); // 不能使用 ActionListener,否则设计器工具栏中的"更多颜色"按钮会有问题(REPORT-13654) customButton.addMouseListener(new MouseAdapter() { @@ -117,6 +105,31 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { centerPane.add(centerPane1); } + public boolean isSupportTransparent() { + return isSupportTransparent; + } + + public void setSupportTransparent(boolean supportTransparent) { + isSupportTransparent = supportTransparent; + } + + protected void initSelectButton(boolean isSupportTransparent){ + this.isSupportTransparent = isSupportTransparent; + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(new UIRoundedBorder(UIConstants.TOOLBAR_BORDER_COLOR, 1, 5)); + 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(); + } + }); + } + } + /** * 添加监听 @@ -199,9 +212,9 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { @Override public Dimension getPreferredSize() { if (isSupportTransparent) { - return new Dimension(super.getPreferredSize().width, TRANSPANENT_WINDOW_HEIGHT); + return new Dimension(super.getPreferredSize().width, TRANSPARENT_WINDOW_HEIGHT); } - return new Dimension(super.getPreferredSize().width, WINDWO_HEIGHT); + return new Dimension(super.getPreferredSize().width, WINDOW_HEIGHT); } /** diff --git a/designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java b/designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java index dce7b6c308..9066b4a901 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java +++ b/designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java @@ -3,15 +3,6 @@ */ package com.fr.design.style.color; -import java.awt.Color; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; - -import javax.swing.Icon; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.event.EventListenerList; - import com.fr.base.BaseUtils; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; @@ -20,234 +11,237 @@ import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.ibutton.UICombinationButton; import com.fr.design.gui.ipoppane.PopupHider; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.stable.os.OperatingSystem; + +import javax.swing.Icon; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.EventListenerList; +import java.awt.Color; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; /** * Color select pane2. */ public class UIToolbarColorButton extends UICombinationButton implements PopupHider, ColorSelectable, UIObserver { - private static final long serialVersionUID = 3220957076370197935L; - private Color color = null; - private boolean isCanBeNull = false; - private ColorControlWindow popupWin; - //color setting action. - private EventListenerList colorChangeListenerList = new EventListenerList(); - private UIObserverListener uiObserverListener; - - - public UIToolbarColorButton(Icon icon) { - super(new UIColorButton(icon), new UIButton(BaseUtils.readIcon("/com/fr/design/images/gui/popup.gif"))); - getLeftButton().setEventBanned(true); - getRightButton().addFocusListener(new FocusListener() { - - @Override - public void focusGained(FocusEvent e) { - } - - @Override - public void focusLost(FocusEvent e) { - hidePopupMenu(); - } - }); - iniListener(); - } - - private void iniListener() { - if (shouldResponseChangeListener()) { - this.addColorChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - if (uiObserverListener == null) { - return; - } - uiObserverListener.doChange(); - } - }); - } - } - - @Override - /** - * - */ - public UIColorButton getLeftButton() { - // TODO Auto-generated method stub - return (UIColorButton) super.getLeftButton(); - } - - /** - * @return - */ - public Color getColor() { - return this.color; - } - - /** - * @param color - */ - public void setColor(Color color) { - setColorWithoutchanged(color); - fireColorStateChanged(); - } - - /** - * 设置颜色 - * @param color 颜色 - */ - public void setColorWithoutchanged(Color color) { - this.color = color; - getLeftButton().setColor(color); - } - - /** - * 是否可为NULL值 - * @return 同上 - */ - public boolean isCanBeNull() { - return this.isCanBeNull; - } - - /** - * @param isCanBeNull - */ - public void setCanBeNull(boolean isCanBeNull) { - this.isCanBeNull = isCanBeNull; - } - - @Override - /** - * - */ - public void setEnabled(boolean enabled) { - super.setEnabled(enabled); - - if (!enabled) { - color = null; - } - - getLeftButton().setEnabled(enabled); - getLeftButton().setEnabled(enabled); - } - - @Override - /** - * - */ - public void setToolTipText(String tooltipText) { - getLeftButton().setToolTipText(tooltipText); - getLeftButton().setToolTipText(tooltipText); - } - - private void showPopupMenu() { - if (popupWin != null && popupWin.isVisible()) { - hidePopupMenu(); - return; - } - - if (!this.isEnabled()) { - return; - } - - popupWin = this.getColorControlWindow(); - - GUICoreUtils.showPopupMenu(popupWin, this, 0, this.getSize().height); - } - - /** - * 隐藏弹出框 - */ - public void hidePopupMenu() { - if (popupWin != null) { - popupWin.setVisible(false); - } - - popupWin = null; - } - - private ColorControlWindow getColorControlWindow() { - //find parant. - if (this.popupWin == null) { - this.popupWin = new ColorControlWindow(this.isCanBeNull(), UIToolbarColorButton.this) { - @Override - protected void colorChanged() { - UIToolbarColorButton.this.setColor(this.getColor()); - } - - }; - } - - return popupWin; - } - - /** - * Adds a new ColorChangeListener - * 注册监听 - * @param changeListener 监听 - */ - public void addColorChangeListener(ChangeListener changeListener) { - colorChangeListenerList.add(ChangeListener.class, changeListener); - } - - /** - * Removes an old ColorChangeListener. - * 移除监听 - * @param 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); - } - } - } - - protected void leftButtonClickEvent() { - color = getLeftButton().getColor(); - fireColorStateChanged(); - } - - @Override - protected void rightButtonClickEvent() { - showPopupMenu(); - } - - @Override - /** - * 选中颜色 - * @param colorCell 颜色单元格 - */ - public void colorSetted(ColorCell colorCell) { - hidePopupMenu(); - } - - @Override - /** - * 注册监听 - * @param listener 监听 - */ - public void registerChangeListener(UIObserverListener listener) { - uiObserverListener = listener; - } - - @Override - /** - * 是否响应监听 - * @return 同上 - */ - public boolean shouldResponseChangeListener() { - return true; - } + private static final long serialVersionUID = 3220957076370197935L; + private Color color = null; + private boolean isCanBeNull = false; + private ColorControlWindow popupWin; + //color setting action. + private EventListenerList colorChangeListenerList = new EventListenerList(); + private UIObserverListener uiObserverListener; + + public UIToolbarColorButton(Icon icon) { + super(new UIColorButton(icon), new UIButton(BaseUtils.readIcon("/com/fr/design/images/gui/popup.gif"))); + getLeftButton().setEventBanned(true); + getRightButton().addFocusListener(new FocusListener() { + + @Override + public void focusGained(FocusEvent e) { + } + + @Override + public void focusLost(FocusEvent e) { + hidePopupMenu(); + } + }); + iniListener(); + } + + private void iniListener() { + if (shouldResponseChangeListener()) { + this.addColorChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (uiObserverListener == null) { + return; + } + uiObserverListener.doChange(); + } + }); + } + } + + @Override + public UIColorButton getLeftButton() { + // TODO Auto-generated method stub + return (UIColorButton) super.getLeftButton(); + } + + @Override + public Color getColor() { + return this.color; + } + + @Override + public void setColor(Color color) { + setColorWithoutchanged(color); + fireColorStateChanged(); + } + + /** + * 设置颜色 + * + * @param color 颜色 + */ + public void setColorWithoutchanged(Color color) { + this.color = color; + getLeftButton().setColor(color); + } + + /** + * 是否可为NULL值 + * + * @return 同上 + */ + public boolean isCanBeNull() { + return this.isCanBeNull; + } + + /** + * @param isCanBeNull + */ + public void setCanBeNull(boolean isCanBeNull) { + this.isCanBeNull = isCanBeNull; + } + + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + + if (!enabled) { + color = null; + } + + getLeftButton().setEnabled(enabled); + getLeftButton().setEnabled(enabled); + } + + @Override + public void setToolTipText(String tooltipText) { + getLeftButton().setToolTipText(tooltipText); + getLeftButton().setToolTipText(tooltipText); + } + + private void showPopupMenu() { + if (popupWin != null && popupWin.isVisible()) { + hidePopupMenu(); + return; + } + + if (!this.isEnabled()) { + return; + } + + popupWin = this.getColorControlWindow(); + + GUICoreUtils.showPopupMenu(popupWin, this, 0, this.getSize().height); + } + + /** + * 隐藏弹出框 + */ + @Override + public void hidePopupMenu() { + if (popupWin != null && !OperatingSystem.isMacos()) { + popupWin.setVisible(false); + } + + popupWin = null; + } + + private ColorControlWindow getColorControlWindow() { + //find parant. + if (this.popupWin == null) { + this.popupWin = new ColorControlWindow(this.isCanBeNull(), UIToolbarColorButton.this) { + @Override + protected void colorChanged() { + UIToolbarColorButton.this.setColor(this.getColor()); + } + + }; + } + + return popupWin; + } + + /** + * Adds a new ColorChangeListener + * 注册监听 + * + * @param changeListener 监听 + */ + public void addColorChangeListener(ChangeListener changeListener) { + colorChangeListenerList.add(ChangeListener.class, changeListener); + } + + /** + * Removes an old ColorChangeListener. + * 移除监听 + * + * @param 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); + } + } + } + + @Override + protected void leftButtonClickEvent() { + color = getLeftButton().getColor(); + fireColorStateChanged(); + } + + @Override + protected void rightButtonClickEvent() { + showPopupMenu(); + } + + /** + * 选中颜色 + * + * @param colorCell 颜色单元格 + */ + @Override + public void colorSetted(ColorCell colorCell) { + hidePopupMenu(); + } + + /** + * 注册监听 + * + * @param listener 监听 + */ + @Override + public void registerChangeListener(UIObserverListener listener) { + uiObserverListener = listener; + } + + /** + * 是否响应监听 + * + * @return 同上 + */ + @Override + public boolean shouldResponseChangeListener() { + return true; + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java b/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java index eb25ccea30..827a39fd39 100644 --- a/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java +++ b/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java @@ -30,6 +30,7 @@ public class RecoverForDesigner implements Recover { CommonIOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome, ProjectConstants.LOGS_NAME, UpdateConstants.INSTALL_LIB, UpdateConstants.DESIGNERBACKUPPATH), StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LIB_NAME)); + FineLoggerFactory.getLogger().error("Recover down for designer"); return true; } catch (IOException e) { FineLoggerFactory.getLogger().error("Recover error for designer", e); @@ -54,6 +55,7 @@ public class RecoverForDesigner implements Recover { CommonIOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME), StableUtils.pathJoin(installBackup,UpdateConstants.DESIGNERBACKUPPATH)); DesignerContext.getDesignerFrame().prepareForExit(); + FineLoggerFactory.getLogger().error("Backup down for designer"); return true; } catch (IOException e) { UpdateException exception = new UpdateException("Backup Exception for designer" + e.getMessage()); diff --git a/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java b/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java index dcc282c53f..efd809e791 100644 --- a/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java +++ b/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java @@ -7,16 +7,11 @@ import com.fr.design.mainframe.DesignerFrame; import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.update.ui.dialog.UpdateMainDialog; import com.fr.general.CloudCenter; -import com.fr.general.GeneralContext; import com.fr.general.GeneralUtils; import com.fr.general.http.HttpToolbox; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; -import com.fr.stable.os.OperatingSystem; -import com.fr.stable.os.support.OSBasedAction; -import com.fr.stable.os.support.OSSupportCenter; -import com.fr.workspace.WorkContext; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -32,17 +27,6 @@ public class DesignerPushUpdateManager { private DesignerUpdateInfo updateInfo; - static { - if (DesignerPushUpdateConfigManager.getInstance().isAutoPushUpdateEnabled()) { - DesignerContext.getDesignerFrame().addDesignerOpenedListener(new DesignerOpenedListener() { - @Override - public void designerOpened() { - getInstance().checkAndPop(); - } - }); - } - } - private DesignerPushUpdateManager() { } @@ -53,6 +37,17 @@ public class DesignerPushUpdateManager { return singleton; } + public void preparePushUpdate() { + if (DesignerPushUpdateConfigManager.getInstance().isAutoPushUpdateEnabled()) { + DesignerContext.getDesignerFrame().addDesignerOpenedListener(new DesignerOpenedListener() { + @Override + public void designerOpened() { + getInstance().checkAndPop(); + } + }); + } + } + private void initUpdateInfo(String currentVersion, String latestVersion) { String lastIgnoredVersion = DesignerPushUpdateConfigManager.getInstance().getLastIgnoredVersion(); String updatePushInfo = CloudCenter.getInstance().acquireUrlByKind("update.push"); @@ -63,7 +58,14 @@ public class DesignerPushUpdateManager { private String getFullLatestVersion() { try { - String res = HttpToolbox.get(CloudCenter.getInstance().acquireUrlByKind("jar10.update")); + String url = CloudCenter.getInstance().acquireUrlByKind("jar10.update"); + if(StringUtils.isBlank(url)){ + return StringUtils.EMPTY; + } + String res = HttpToolbox.get(url); + if(StringUtils.isBlank(res)){ + return StringUtils.EMPTY; + } return new JSONObject(res).optString("buildNO"); } catch (Throwable e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java index 1fb21d41cb..78df599c57 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java @@ -5,6 +5,7 @@ import com.fr.decision.update.info.UpdateCallBack; import com.fr.decision.update.info.UpdateProgressCallBack; import com.fr.design.RestartHelper; import com.fr.design.constants.LayoutConstants; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.UIDialog; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; @@ -29,6 +30,8 @@ import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; +import com.fr.process.engine.core.FineProcessContext; +import com.fr.process.engine.core.FineProcessEngineEvent; import com.fr.stable.*; import com.fr.stable.project.ProjectConstants; import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse; @@ -597,6 +600,7 @@ public class UpdateMainDialog extends UIDialog { final String installLib = StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LOGS_NAME, UpdateConstants.INSTALL_LIB); final JFrame frame = DesignerContext.getDesignerFrame(); final RestartHelper helper = new RestartHelper(); + FineProcessContext.getParentPipe().fire(FineProcessEngineEvent.DESTROY); new FileProcess(callBack) { @Override public void onDownloadSuccess() { @@ -608,7 +612,7 @@ public class UpdateMainDialog extends UIDialog { public void onDownloadFailed() { progressBar.setVisible(false); deleteForDesignerUpdate(installLib); - JOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message")); + FineJOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message")); helper.restartForUpdate(frame); } }.execute(); diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java index 5238b0c657..4febad3a99 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java @@ -2,6 +2,7 @@ package com.fr.design.upm; import com.fr.base.FRContext; import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoader; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.UIDialog; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; @@ -64,18 +65,18 @@ public class UpmFinder { if (flag) { if (!checkUPMResourcesExist()){ // upm下载 - int val = JOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Need_Install"), - Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); + int val = FineJOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Need_Install"), + Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); if (val == JOptionPane.OK_OPTION){ try { UpmResourceLoader.INSTANCE.download(); UpmResourceLoader.INSTANCE.install(); - JOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Installed"), - Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE); + FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Installed"), + Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.INFORMATION_MESSAGE); } catch (Exception e){ FineLoggerFactory.getLogger().error(e.getMessage(), e); - JOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Updater_Download_Failed"), - Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE); + FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Updater_Download_Failed"), + Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.INFORMATION_MESSAGE); } } } diff --git a/designer-base/src/main/java/com/fr/design/utils/BrowseUtils.java b/designer-base/src/main/java/com/fr/design/utils/BrowseUtils.java index 8a68593efe..c8f98421c9 100644 --- a/designer-base/src/main/java/com/fr/design/utils/BrowseUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/BrowseUtils.java @@ -1,5 +1,6 @@ package com.fr.design.utils; +import com.fr.design.dialog.FineJOptionPane; import com.fr.log.FineLoggerFactory; import com.fr.stable.OperatingSystem; import com.fr.stable.StringUtils; @@ -27,7 +28,7 @@ public class BrowseUtils { // win10 内存用到到80%左右的时候, Desktop.browser经常提示"存储空间不足, 无法处理改命令", 用rundll32可以打开. Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + uri); } catch (IOException ee) { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Default_Browser_Duplicate")); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Default_Browser_Duplicate")); FineLoggerFactory.getLogger().error(e.getMessage(), e); } } else { diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java index 8d32e6e0ed..09a5b683dc 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java @@ -5,9 +5,11 @@ import com.fr.base.ServerConfig; import com.fr.concurrent.NamedThreadFactory; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.fun.DesignerEnvProcessor; import com.fr.design.gui.UILookAndFeel; import com.fr.design.mainframe.DesignerContext; +import com.fr.exit.DesignerExiter; import com.fr.file.FileFILE; import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; @@ -29,7 +31,9 @@ import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; +import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.ServerSocket; @@ -38,15 +42,21 @@ import java.net.URI; import java.nio.charset.StandardCharsets; import java.util.Enumeration; import java.util.Locale; +import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; /** * Some util method of Designer */ public class DesignUtils { - private static int port = DesignerPort.MESSAGE_PORT; + private static int port = DesignerPort.getInstance().getMessagePort(); + + private static boolean started = false; private DesignUtils() { } @@ -61,15 +71,54 @@ public class DesignUtils { } /** - * 通过端口是否被占用判断设计器有没有启动 - * s + * 判断设计器有没有启动 * * @return 启动了返回true */ public static boolean isStarted() { - try (Socket socket = new Socket("localhost", port)) { + return started; + } + + + /** + * 判断设计器端口是否被其他程序占用 + * 尝试去通信,无回应就是其他程序占用端口,否则需要继续判断是否为设计器进程未关闭 + * @return + */ + public static boolean isPortOccupied() { + ExecutorService executor = null; + Future future = null; + try (Socket socket = new Socket("localhost", port); + BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8)); + PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), StandardCharsets.UTF_8)))) { + writer.println("check"); + writer.flush(); + executor = Executors.newSingleThreadExecutor(); + future = executor.submit(new Callable() { + @Override + public String call() throws Exception { + String line; + while ((line = reader.readLine()) != null) { + if ("response".equals(line)) { + // 正常通信 上一次设计器进程未关闭 + started = true; + return line; + } + } + return StringUtils.EMPTY; + } + }); + future.get(2, TimeUnit.SECONDS); + return false; + } catch (TimeoutException e) { + future.cancel(true); return true; - } catch (Exception ignored) { + } catch (Exception ignore) { + + } finally { + if (executor != null) { + executor.shutdownNow(); + } } return false; } @@ -79,15 +128,12 @@ public class DesignUtils { * * @param lines 命令行 */ - public static void clientSend(String[] lines) { + public static void clientSend(String[] lines, Socket socket) { if (lines == null || lines.length == 0) { return; } - Socket socket = null; PrintWriter writer = null; try { - socket = new Socket("localhost", port); - writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), StandardCharsets.UTF_8))); for (int i = 0; i < lines.length; i++) { writer.println(lines[i]); @@ -96,19 +142,23 @@ public class DesignUtils { } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } finally { - try { - if (writer != null) { - writer.close(); - } - if (socket != null) { - socket.close(); - } - } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + if (writer != null) { + writer.close(); } } } + public static void clientSend(String[] lines) { + if (lines == null || lines.length == 0) { + return; + } + try (Socket socket = new Socket("localhost", port)) { + clientSend(lines, socket); + } catch (Exception ignore) { + + } + } + /** * 建立监听端口 * @@ -138,7 +188,11 @@ public class DesignUtils { if (line.startsWith("demo")) { DesignerEnvManager.getEnvManager().setCurrentEnv2Default(); ServerStarter.browserDemoURL(); - } else if (StringUtils.isNotEmpty(line)) { + } else if ("check".equals(line)) { + clientSend(new String[] {"response"}, socket); + } else if ("end".equals(line)) { + DesignerExiter.getInstance().execute(); } + else if (StringUtils.isNotEmpty(line)) { File f = new File(line); String path = f.getAbsolutePath(); @@ -165,6 +219,14 @@ public class DesignUtils { } + public static void responseToClient(Socket socket) { + try (OutputStream outputStream = socket.getOutputStream()) { + outputStream.write("reponse".getBytes(StandardCharsets.UTF_8)); + outputStream.flush(); + } catch (IOException ignore) { + } + } + /** * 弹出对话框,显示报错 * @@ -176,7 +238,7 @@ public class DesignUtils { @Override public void run() { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), final_msg); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), final_msg); } }); } diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignerPort.java b/designer-base/src/main/java/com/fr/design/utils/DesignerPort.java index 7c082800ed..55dc1f00d9 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignerPort.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignerPort.java @@ -1,26 +1,222 @@ package com.fr.design.utils; +import com.fr.design.DesignerEnvManager; +import com.fr.design.RestartHelper; +import com.fr.design.dialog.TipDialog; +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.utils.gui.GUICoreUtils; +import com.fr.exit.DesignerExiter; +import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; +import com.fr.stable.StringUtils; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLReadable; +import com.fr.stable.xml.XMLWriter; +import com.fr.stable.xml.XMLableReader; + +import javax.swing.*; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + /** * 为的就是能替换 DesignPort.class 实现多开,因此避免编译器常量编译展开优化 */ -public class DesignerPort { +public class DesignerPort implements XMLReadable, XMLWriter { + + public static final String XML_TAG = "DesignerPort"; + private static final int MIN_PORT = 1024; + private static final int MAX_PORT = 65535; + + public static final DesignerPort INSTANCE = new DesignerPort(); + + public static DesignerPort getInstance() { + return INSTANCE; + } + private DesignerPort() { } /** - * 设计器端口,避免编译期常量优化展开 + * 设计器端口 */ - public static final int MESSAGE_PORT = getMessagePort(); + private int messagePort = 51462; + /** - * 设计器端口,避免编译期常量优化展开 + * 设计器端口,debug模式下 */ - public static final int DEBUG_MESSAGE_PORT = getDebugMessagePort(); + private int debugMessagePort = 51463; + + public int getMessagePort() { + return messagePort; + } + + public int getDebugMessagePort() { + return debugMessagePort; + } + + public void setMessagePort(int messagePort) { + this.messagePort = messagePort; + } + + public void setDebugMessagePort(int debugMessagePort) { + this.debugMessagePort = debugMessagePort; + } + + @Override + public void readXML(XMLableReader reader) { + if (reader.isAttr()) { + this.setMessagePort(reader.getAttrAsInt("messagePort", 51462)); + this.setDebugMessagePort(reader.getAttrAsInt("debugMessagePort", 51463)); + } + } - private static int getMessagePort() { - return 51462; + @Override + public void writeXML(XMLPrintWriter writer) { + writer.startTAG(XML_TAG); + writer.attr("messagePort", this.messagePort); + writer.attr("debugMessagePort", this.debugMessagePort); + writer.end(); } - private static int getDebugMessagePort() { - return 51463; + public void resetPort() { + + TipDialog dialog = new TipDialog(null, + StringUtils.EMPTY, + Toolkit.i18nText("Fine-Design_Port_Found_Port_Conflict"), + Toolkit.i18nText("Fine-Design_End_Occupied_Process"), + Toolkit.i18nText("Fine-Design_Modify_Designer_Port")) { + @Override + protected void endEvent() { + dispose(); + } + + @Override + protected void cancelEvent() { + new ResetPortDialog(); + } + }; + dialog.setVisible(true); + DesignerExiter.getInstance().execute(); } + + private class ResetPortDialog extends JDialog { + private UITextField portFiled; + private UILabel warnLabel; + private UIButton okButton; + + private ResetPortDialog() { + this.setLayout(new BorderLayout()); + this.setModal(true); + this.portFiled = new UITextField(); + this.portFiled.setPreferredSize(new Dimension(180, 20)); + this.portFiled.getDocument().addDocumentListener(new DocumentListener() { + @Override + public void insertUpdate(DocumentEvent e) { + checkValid(); + } + + @Override + public void removeUpdate(DocumentEvent e) { + checkValid(); + } + + @Override + public void changedUpdate(DocumentEvent e) { + checkValid(); + } + }); + JPanel iconPanel = new JPanel(); + UILabel iconLabel = new UILabel(); + iconLabel.setIcon(IOUtils.readIcon("com/fr/design/images/edit/edit_typing.png")); + iconPanel.add(iconLabel); + iconPanel.add(iconLabel); + JPanel textPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); + textPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Modify_Designer_Port_Tip"))); + textPane.add(portFiled); + warnLabel = new UILabel(); + warnLabel.setVisible(false); + warnLabel.setForeground(Color.RED); + okButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Button_OK")); + okButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int value = Integer.parseInt(portFiled.getText().trim()); + if (ComparatorUtils.equals("true", System.getProperty("debug"))) { + setDebugMessagePort(value); + } else { + setMessagePort(value); + } + dispose(); + DesignerEnvManager.getEnvManager().saveXMLFile(); + RestartHelper.restart(); + } + }); + UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Button_Cancel")); + cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + JPanel buttonPane = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15)); + buttonPane.add(okButton); + buttonPane.add(cancelButton); + JPanel controlPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + controlPane.add(buttonPane, BorderLayout.EAST); + JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + northPane.add(iconPanel, BorderLayout.WEST); + northPane.add(textPane, BorderLayout.CENTER); + JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + centerPane.add(warnLabel); + JPanel southPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + southPane.add(controlPane); + this.add(northPane, BorderLayout.NORTH); + this.add(centerPane, BorderLayout.CENTER); + this.add(southPane, BorderLayout.SOUTH); + this.setSize(300, 150); + this.setTitle(Toolkit.i18nText("Fine-Design_Modify_Designer_Port")); + this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + this.setResizable(false); + this.setAlwaysOnTop(true); + GUICoreUtils.centerWindow(this); + this.setVisible(true); + } + + private void checkValid() { + String port = this.portFiled.getText().trim(); + if (StringUtils.isEmpty(port)) { + okButton.setEnabled(false); + return; + } + + int value; + try { + value = Integer.parseInt(port); + } catch (NumberFormatException ignore) { + warnLabel.setText(Toolkit.i18nText("Fine-Design_Modify_Designer_Port_Not_Number_Tip")); + warnLabel.setVisible(true); + okButton.setEnabled(false); + return; + } + + if (value < MIN_PORT || value > MAX_PORT) { + warnLabel.setText(Toolkit.i18nText("Fine-Design_Modify_Designer_Port_Out_Of_Range_Tip")); + warnLabel.setVisible(true); + okButton.setEnabled(false); + return; + } + + warnLabel.setVisible(false); + okButton.setEnabled(true); + } + } + } diff --git a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java index f0412a948b..5a9396da64 100644 --- a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java @@ -16,6 +16,7 @@ import com.fr.data.util.function.SumFunction; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.core.ActionFactory; import com.fr.design.border.UITitledBorder; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.icheckbox.UICheckBox; @@ -324,7 +325,7 @@ public final class GUICoreUtils { /** * Gets window/frame to screen center. - * @param 窗口 + * @param win 窗口 */ public static void setWindowFullScreen(Window win) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); @@ -341,7 +342,7 @@ public final class GUICoreUtils { * Shows down component. * 显示弹出关闭菜单 * @param popup 弹出菜单 - * @param 父组件 + * @param parentComponent 父组件 */ public static void showPopupCloseMenu(JPopupMenu popup, Component parentComponent) { if (popup == null) {// check null. @@ -537,7 +538,7 @@ public final class GUICoreUtils { /** * 产生一个Flow Pane, flowAligment是FlowLayout.LEFT, CENTER, RIGHT. * @param comps 组件 - * @param flowAlignement 对齐方式 + * @param flowAlignment 对齐方式 * @param hSpace 水平间隔 * @return 面板 */ @@ -660,7 +661,7 @@ public final class GUICoreUtils { /** * it's a very good method, user can get treePath from treeNode. - * @param 节点 + * @param treeNode 节点 * @return 路径 */ public static TreePath getTreePath(TreeNode treeNode) { @@ -740,7 +741,7 @@ public final class GUICoreUtils { return false; } - int returnVal = JOptionPane.showConfirmDialog(ancestorWindow, com.fr.design.i18n.Toolkit.i18nText(key), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove"), + int returnVal = FineJOptionPane.showConfirmDialog(ancestorWindow, com.fr.design.i18n.Toolkit.i18nText(key), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (returnVal == JOptionPane.OK_OPTION) { int minSelectedIndex = nodeList.getMinSelectionIndex(); 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 e4aedd4219..12c72c5cd3 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 @@ -6,6 +6,7 @@ import com.fr.base.Icon; import com.fr.base.IconManager; import com.fr.design.dialog.BasicPane; 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.ilable.UILabel; @@ -150,7 +151,7 @@ public class CustomIconPane extends BasicPane { } else { // add failed - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message2"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.WARNING_MESSAGE); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message2"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); } } }).setVisible(true); @@ -179,9 +180,9 @@ public class CustomIconPane extends BasicPane { CustomIconPane.this.repaint(); } else { // remove failed - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message2"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); } } @@ -204,9 +205,9 @@ public class CustomIconPane extends BasicPane { // do nothing } if (oldIcon == null) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), - "Error", - "Error", + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE); } @@ -228,7 +229,7 @@ public class CustomIconPane extends BasicPane { // 失败了再弄回去 iconManager.addIcon(oldIcon, true); // edit failed - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message2"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.WARNING_MESSAGE); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message2"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); } } }).setVisible(true); @@ -425,9 +426,9 @@ public class CustomIconPane extends BasicPane { return; } if (WidgetInfoConfig.getInstance().getIconManager().contains(nameTextField.getText())) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message3"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); } } diff --git a/designer-base/src/main/java/com/fr/design/write/submit/CustomJobPane.java b/designer-base/src/main/java/com/fr/design/write/submit/CustomJobPane.java index fcb272dd54..d07d42b3e2 100644 --- a/designer-base/src/main/java/com/fr/design/write/submit/CustomJobPane.java +++ b/designer-base/src/main/java/com/fr/design/write/submit/CustomJobPane.java @@ -29,7 +29,7 @@ import java.awt.event.ActionListener; public abstract class CustomJobPane extends BasicBeanPane { protected UITextField classNameTextField; protected ObjectProperiesPane objectProperiesPane; - public static final int DEFAULT_LENGTH = 30; + private static final int DEFAULT_LENGTH = 25; public CustomJobPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); diff --git a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java index c28f70e5fd..9df5d7916a 100644 --- a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java +++ b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java @@ -17,6 +17,7 @@ import com.fr.design.data.tabledata.tabledatapane.FormatExplanationPane; 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.editor.ValueEditorPane; import com.fr.design.editor.ValueEditorPaneFactory; import com.fr.design.editor.editor.Editor; @@ -584,7 +585,7 @@ public class DBManipulationPane extends BasicBeanPane { return; } - int returnVal = JOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(DBManipulationPane.this), + int returnVal = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(DBManipulationPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_sure_remove_item") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (returnVal == JOptionPane.OK_OPTION) { @@ -700,7 +701,7 @@ public class DBManipulationPane extends BasicBeanPane { } jobs = new NameSubmitJob[dmlConfig.getSubmitJobCount()]; for (int i = 0; i < jobs.length; i++) { - jobs[i] = dmlConfig.getSubmitJob(i); + jobs[i] = dmlConfig.getNameSubmitJob(i); } condition = dmlConfig.getCondition(); UpdateCheckBox.setSelected(dmlConfig.isUpdateSelected()); diff --git a/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java new file mode 100644 index 0000000000..9134d6429f --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java @@ -0,0 +1,135 @@ +package com.fr.env; + +import com.fr.design.DesignerEnvManager; +import com.fr.design.env.RemoteDesignerWorkspaceInfo; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.env.utils.DisplayUtils; +import com.fr.general.FRFont; +import com.fr.general.GeneralContext; +import com.fr.general.IOUtils; + +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.JTextPane; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + +/** + * @author: Maksim + * @Date: Created in 2020/2/3 + * @Description: 远程连接时,服务检测提醒对话框 + */ +public class CheckServiceDialog extends JDialog implements ActionListener { + private JPanel topPanel; + private JPanel centerPanel; + private JPanel bottomPanel; + private UICheckBox remindBox; + + public CheckServiceDialog(Frame parent, String areaText, String localBranch, String remoteBranch){ + super(parent,true); + //上面的标签面板 + topPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); + JPanel imagePanel = new JPanel(); + Icon icon = IOUtils.readIcon("com/fr/design/images/warnings/warning5.png"); + + JLabel imageLabel = new JLabel(); + imageLabel.setIcon(icon); + imagePanel.add(imageLabel); + imagePanel.setPreferredSize(new Dimension(110,100)); + + JPanel verticalPanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); + FRFont font = FRFont.getInstance(); + font = font.applySize(15).applyStyle(1); + JLabel label = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Inconsistency")); + label.setFont(font); + label.setPreferredSize(new Dimension(650,30)); + + String text = Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Local_Designer") + localBranch + + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") + remoteBranch; + String delimiter = DisplayUtils.getDisplayLength(text) > 70? "
":"/"; + JLabel label2 = new JLabel(""+Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Local_Designer") + + localBranch + delimiter + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") + remoteBranch+""); + label2.setPreferredSize(new Dimension(600,30)); + + JTextPane tipsPane = new JTextPane(); + tipsPane.setEditable(false); + tipsPane.setBackground(verticalPanel.getBackground()); + tipsPane.setPreferredSize(new Dimension(500,40)); + tipsPane.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Need_Update")); + + verticalPanel.add(label); + verticalPanel.add(label2); + verticalPanel.add(tipsPane); + + topPanel.add(imagePanel,BorderLayout.WEST); + topPanel.add(verticalPanel,BorderLayout.CENTER); + topPanel.setBorder(BorderFactory.createEmptyBorder(10,10,0,10)); + + //中间的文本域面板 + centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); + centerPanel.setBorder(BorderFactory.createEmptyBorder(0,10,10,10)); + centerPanel.setPreferredSize(new Dimension(480,320)); + + JLabel titleLabel = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Affected_Function")); + titleLabel.setPreferredSize(new Dimension(400,40)); + JTextArea checkArea = new JTextArea(areaText); + checkArea.setEnabled(false); + centerPanel.add(titleLabel,BorderLayout.NORTH); + centerPanel.add(checkArea,BorderLayout.CENTER); + + //下面的按钮面板 + remindBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remind_Show")); + remindBox.addActionListener(remindCheckboxListener); + UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Button_Confirm")); + JPanel buttonPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); + buttonPanel.setBorder(BorderFactory.createEmptyBorder(0,10,10,10)); + buttonPanel.add(remindBox, BorderLayout.WEST); + buttonPanel.add(okButton,BorderLayout.EAST); + okButton.addActionListener(this ); + bottomPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); + bottomPanel.add(buttonPanel); + + this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Title_Hint")); + this.setResizable(false); + + 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)); + + GUICoreUtils.centerWindow(this); + } + @Override + public void actionPerformed(ActionEvent e) { + this.dispose(); + } + + + private ActionListener remindCheckboxListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + String remindTime = format.format(new Date()); + //环境已切换,通过当前环境获取,一定是远程环境 + String currentEnvName = DesignerEnvManager.getEnvManager().getCurEnvName(); + RemoteDesignerWorkspaceInfo currentEnv = (RemoteDesignerWorkspaceInfo)DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentEnvName); + currentEnv.setRemindTime(remindBox.isSelected()? remindTime : ""); + } + }; + +} diff --git a/designer-base/src/main/java/com/fr/env/EnvListPane.java b/designer-base/src/main/java/com/fr/env/EnvListPane.java index 30b4b76f12..911a7b22f8 100644 --- a/designer-base/src/main/java/com/fr/env/EnvListPane.java +++ b/designer-base/src/main/java/com/fr/env/EnvListPane.java @@ -1,6 +1,7 @@ package com.fr.env; import com.fr.design.DesignerEnvManager; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo; @@ -33,13 +34,13 @@ public class EnvListPane extends JListControlPane { allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY; if (StringUtils.isEmpty(tempName)) { nameableList.stopEditing(); - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(EnvListPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Workspace_Empty_Name_Warn_Text")); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(EnvListPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Workspace_Empty_Name_Warn_Text")); setIllegalIndex(editingIndex); return; } if (!ComparatorUtils.equals(tempName, selectedName) && isNameRepeated(new List[]{Arrays.asList(allListNames)}, tempName)) { nameableList.stopEditing(); - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(EnvListPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Workspace_Duplicate_Name_Warn_Text", tempName)); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(EnvListPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Workspace_Duplicate_Name_Warn_Text", tempName)); setIllegalIndex(editingIndex); } } @@ -95,8 +96,9 @@ public class EnvListPane extends JListControlPane { */ public String updateEnvManager() { DesignerEnvManager mgr = DesignerEnvManager.getEnvManager(); - mgr.clearAllEnv(); + //这里代码时序换一下,因为update中需要借助mgr来获取提醒时间,已确认mgr对res无依赖 Nameable[] res = this.update(); + mgr.clearAllEnv(); for (Nameable re : res) { NameObject nameObject = (NameObject) re; mgr.putEnv(nameObject.getName(), (DesignerWorkspaceInfo) nameObject.getObject()); 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 20f698a3fa..9ea2f7019e 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -10,6 +10,7 @@ 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.ilable.UILabel; import com.fr.design.gui.ipasswordfield.UIPassWordField; import com.fr.design.gui.itextfield.UITextField; @@ -17,6 +18,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.scrollruler.ModLineBorder; +import com.fr.license.exception.RegistEditionException; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import com.fr.third.guava.base.Strings; @@ -24,17 +26,7 @@ import com.fr.workspace.WorkContext; import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.engine.exception.WorkspaceAuthException; -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; -import javax.swing.JDialog; -import javax.swing.JFileChooser; -import javax.swing.JPanel; -import javax.swing.JTextPane; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; -import javax.swing.SwingWorker; -import javax.swing.ToolTipManager; -import javax.swing.UIManager; +import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; @@ -220,6 +212,9 @@ public class RemoteEnvPane extends BasicBeanPane { updateHttpsConfigPanel(); remoteWorkspaceURL.setHttps(isHttps); + // reset下url,将勾选状态是否htpps加到url里 + remoteWorkspaceURL.resetUrl(); + fillRemoteEnvURLField(); fillIndividualField(); } @@ -291,10 +286,13 @@ public class RemoteEnvPane extends BasicBeanPane { contentPanel.add(configPanel, BorderLayout.NORTH); contentPanel.add(accountPanel, BorderLayout.CENTER); - + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + panel.add(contentPanel, BorderLayout.NORTH); + panel.add(testPanel, BorderLayout.CENTER); + panel.setPreferredSize(new Dimension(440, 600)); + UIScrollPane scrollPane = new UIScrollPane(panel); this.setLayout(new BorderLayout()); - this.add(contentPanel, BorderLayout.NORTH); - this.add(testPanel, BorderLayout.CENTER); + this.add(scrollPane); } @Override @@ -561,6 +559,9 @@ public class RemoteEnvPane extends BasicBeanPane { 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; } } diff --git a/designer-base/src/main/java/com/fr/env/TestConnectionResult.java b/designer-base/src/main/java/com/fr/env/TestConnectionResult.java index 5362dbbd83..4524254f40 100644 --- a/designer-base/src/main/java/com/fr/env/TestConnectionResult.java +++ b/designer-base/src/main/java/com/fr/env/TestConnectionResult.java @@ -34,7 +34,7 @@ public enum TestConnectionResult { }, /** - * 不完全成功,版本不匹配,但测试连接成功。 + * 不完全成功,版本不匹配,但测试连接成功。该状态先保留 */ PARTLY_SUCCESS { @Override @@ -89,16 +89,7 @@ public enum TestConnectionResult { if (!value) { return FULLY_FAILED; } - try { - String serverVersion = new FunctionalHttpRequest(info).getServerVersion(); - if (AssistUtils.equals(serverVersion, WorkContext.getVersion())) { - return FULLY_SUCCESS; - } - return PARTLY_SUCCESS; - } catch (Exception e) { - // 发生异常,说明没连接上。返回完全失败。 - FineLoggerFactory.getLogger().error(e.getMessage()); - return FULLY_FAILED; - } + //去掉测试连接时所做的检测 + return FULLY_SUCCESS; } } diff --git a/designer-base/src/main/java/com/fr/env/utils/DisplayUtils.java b/designer-base/src/main/java/com/fr/env/utils/DisplayUtils.java new file mode 100644 index 0000000000..1795c5fb14 --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/utils/DisplayUtils.java @@ -0,0 +1,39 @@ +package com.fr.env.utils; + +/** + * @author: Maksim + * @Date: Created in 2020/3/16 + * @Description: + */ +public class DisplayUtils { + + /** + * 获取字符串显示时的计算长度 + * @param text 被计算的字符串 + * @return 计算长度 + */ + public static int getDisplayLength(String text){ + if (text == null) { + return 0; + } + char[] c = text.toCharArray(); + int len = 0; + for (int i = 0; i < c.length; i++) { + len++; + if(!isLetter(c[i])){ + len++; + }; + } + return len; + } + + /** + * 判断字符是否为字母、数字、英文符号 + * @param c 传入的字符 + * @return 如果符合上述条件,返回true + */ + public static boolean isLetter(char c) { + int k = 0x80; + return c / k == 0; + } +} diff --git a/designer-base/src/main/java/com/fr/exit/DesignerExiter.java b/designer-base/src/main/java/com/fr/exit/DesignerExiter.java new file mode 100644 index 0000000000..e7189511a1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/exit/DesignerExiter.java @@ -0,0 +1,33 @@ +package com.fr.exit; + +import com.fr.design.env.DesignerWorkspaceGenerator; +import com.fr.process.engine.core.FineProcessContext; +import com.fr.process.engine.core.FineProcessEngineEvent; +import com.fr.stable.StableUtils; + + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/2/12 + */ +public class DesignerExiter { + + public static final DesignerExiter INSTANCE = new DesignerExiter(); + + public static DesignerExiter getInstance() { + return INSTANCE; + } + + public void execute() { + beforeExit(); + if (FineProcessContext.getParentPipe() != null) { + FineProcessContext.getParentPipe().fire(FineProcessEngineEvent.DESTROY); + } + System.exit(0); + } + + private void beforeExit() { + DesignerWorkspaceGenerator.stop(); + } +} diff --git a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java index 52e63c9bfa..0ca481b09b 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -7,6 +7,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.UIDialog; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceType; @@ -504,6 +505,9 @@ public class FILEChooserPane extends BasicPane { if (StringUtils.isEmpty(fileName) || StringUtils.isEmpty(filterExtension) || fileFilter.containsExtension(fileExtension.getExtension())) { return fileName; } + if (!ComparatorUtils.equals(fileNameExtension, filterExtension)) { + return fileName + filterExtension; + } return fileNameWithOutExtension + filterExtension; } @@ -733,6 +737,7 @@ public class FILEChooserPane extends BasicPane { fileNameTextField.setText(""); fileNameTextField.addDocumentListener(); } + dialog.setAlwaysOnTop(true); dialog.setVisible(true); return option; } @@ -846,7 +851,7 @@ public class FILEChooserPane extends BasicPane { saveDictionary(); dialogExit(); } else { - JOptionPane.showMessageDialog(this, Toolkit.i18nText("Fine-Design_Basic_App_Template_Report_Not_Exist")); + FineJOptionPane.showMessageDialog(this, Toolkit.i18nText("Fine-Design_Basic_App_Template_Report_Not_Exist")); return; } } @@ -876,8 +881,8 @@ public class FILEChooserPane extends BasicPane { if (access(selectedFile) && access(currentDirectory)) { if (selectedFile.exists()) { - int selVal = JOptionPane.showConfirmDialog(dialog, Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Cover_The_Current_File") + " ?", - ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE); + int selVal = FineJOptionPane.showConfirmDialog(dialog, Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Cover_The_Current_File") + " ?", + Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (selVal == JOptionPane.YES_OPTION) { option = JOPTIONPANE_OK_OPTION; saveDictionary(); @@ -891,7 +896,7 @@ public class FILEChooserPane extends BasicPane { saveDictionary(); } } else { - JOptionPane.showMessageDialog(FILEChooserPane.this, Toolkit.i18nText("Fine-Design_Basic_App_Privilege_No") + "!", Toolkit.i18nText("Fine-Design_Basic_App_File_Message"), JOptionPane.WARNING_MESSAGE); + FineJOptionPane.showMessageDialog(FILEChooserPane.this, Toolkit.i18nText("Fine-Design_Basic_App_Privilege_No") + "!", Toolkit.i18nText("Fine-Design_Basic_App_File_Message"), JOptionPane.WARNING_MESSAGE); } } @@ -1553,7 +1558,7 @@ public class FILEChooserPane extends BasicPane { if (access(currentDirectory)) { new MkdirDialog(); } else { - JOptionPane.showMessageDialog( + FineJOptionPane.showMessageDialog( FILEChooserPane.this, Toolkit.i18nText("Fine-Design_Basic_App_Privilege_No") + "!", Toolkit.i18nText("Fine-Design_Basic_App_File_Message"), @@ -1715,9 +1720,9 @@ public class FILEChooserPane extends BasicPane { scrollPane.getVerticalScrollBar().setValue(value); } else { - JOptionPane.showConfirmDialog(FILEChooserPane.this, + FineJOptionPane.showConfirmDialog(FILEChooserPane.this, Toolkit.i18nText("Fine-Design_Basic_Make_Failure"), - UIManager.getString("OptionPane.messageDialogTitle"), + Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } diff --git a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java index dce2c38e0b..138cfe3456 100644 --- a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java @@ -23,7 +23,7 @@ import com.fr.workspace.WorkspaceEvent; import com.fr.workspace.resource.WorkResourceTempRenameStream; import com.fr.workspace.server.lock.TplOperator; -import javax.swing.Icon; +import javax.swing.*; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.OutputStream; @@ -68,14 +68,14 @@ public class FileNodeFILE implements FILE { this.node = new FileNode(StableUtils.pathJoin(parentDir, name), isDir); this.envPath = WorkContext.getCurrent().getPath(); - this.hasFullAuth = NodeAuthProcessor.getInstance().fixFileNodeAuth(node); + this.hasFullAuth = NodeAuthProcessor.getInstance().checkFileNodeAuth(node); } public FileNodeFILE(FileNode node) { this.node = node; this.envPath = WorkContext.getCurrent().getPath(); - this.hasFullAuth = NodeAuthProcessor.getInstance().fixFileNodeAuth(node); + this.hasFullAuth = NodeAuthProcessor.getInstance().checkFileNodeAuth(node); } public FileNodeFILE(FileNode node, boolean hasFullAuth) { @@ -91,7 +91,7 @@ public class FileNodeFILE implements FILE { public FileNodeFILE(FileNode node, String envPath) { this.node = node; this.envPath = envPath; - this.hasFullAuth = NodeAuthProcessor.getInstance().fixFileNodeAuth(node); + this.hasFullAuth = NodeAuthProcessor.getInstance().checkFileNodeAuth(node); } public FileNodeFILE(FileNode node, String envPath, boolean hasFullAuth) { diff --git a/designer-base/src/main/java/com/fr/file/filter/ChooseFileFilter.java b/designer-base/src/main/java/com/fr/file/filter/ChooseFileFilter.java index a25ebe7b6e..147e1946d4 100644 --- a/designer-base/src/main/java/com/fr/file/filter/ChooseFileFilter.java +++ b/designer-base/src/main/java/com/fr/file/filter/ChooseFileFilter.java @@ -4,6 +4,8 @@ import com.fr.base.extension.FileExtension; import com.fr.file.FILE; import com.fr.file.FileFILE; import com.fr.general.ComparatorUtils; +import com.fr.stable.CoreConstants; +import com.fr.stable.StringUtils; import javax.swing.filechooser.FileFilter; import java.io.File; @@ -275,25 +277,25 @@ public class ChooseFileFilter extends FileFilter implements FILEFilter, java.io. } /** + * 默认情况下 返回首位的后缀名 * get extention. */ public String getExtensionString() { - if (filters == null) { - return ""; - } - - StringBuffer extsb = new StringBuffer("."); - -// Enumeration keys = filters.keys(); -// while (keys.hasMoreElements()) { -// extsb.append((String) keys.nextElement()); -// } + return getExtensionString(0); + } - for (int i = 0; i < filters.size(); i++) { - extsb.append(filters.get(i)); + public String getExtensionString(int index) { + if (filters == null || filters.isEmpty() || index >= filters.size()) { + return StringUtils.EMPTY; } + return CoreConstants.DOT + filters.get(index); + } - return extsb.toString(); + public int getExtensionCount() { + if (filters == null || filters.isEmpty()) { + return 0; + } + return filters.size(); } /** 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 833faaef70..90ac634ce0 100644 --- a/designer-base/src/main/java/com/fr/start/BaseDesigner.java +++ b/designer-base/src/main/java/com/fr/start/BaseDesigner.java @@ -14,11 +14,11 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.ui.util.UIUtil; -import com.fr.design.utils.DesignUtils; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; import com.fr.event.Null; +import com.fr.exit.DesignerExiter; import com.fr.file.FILE; import com.fr.file.FILEFactory; import com.fr.file.FileFILE; @@ -26,7 +26,7 @@ import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.OperatingSystem; -import java.awt.*; +import java.awt.Window; import java.io.File; import java.lang.reflect.Method; @@ -47,8 +47,6 @@ public abstract class BaseDesigner extends ToolBarMenuDock { private void init() { prepare(); - // 初始化look and feel.这个在预加载之前执行是因为lookAndFeel里的东西,预加载时也要用到 - DesignUtils.initLookAndFeel(); // 初始化Log Handler DesignerEnvManager.loadLogSetting(); createDesignerFrame(); @@ -137,7 +135,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock { if (!isException) { showDesignerFrame(true); } else { - System.exit(0); + DesignerExiter.getInstance().execute(); } } } diff --git a/designer-base/src/main/java/com/fr/start/ServerStarter.java b/designer-base/src/main/java/com/fr/start/ServerStarter.java index d4e1143c61..d2b8498bb9 100644 --- a/designer-base/src/main/java/com/fr/start/ServerStarter.java +++ b/designer-base/src/main/java/com/fr/start/ServerStarter.java @@ -3,10 +3,9 @@ package com.fr.start; import com.fr.base.ServerConfig; import com.fr.concurrent.NamedThreadFactory; import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.BrowseUtils; -import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; -import com.fr.stable.StableUtils; import com.fr.start.server.FineEmbedServer; import com.fr.start.server.FineEmbedServerMonitor; import com.fr.workspace.WorkContext; @@ -25,23 +24,11 @@ public class ServerStarter { if (!WorkContext.getCurrent().isLocal()) { //有问题,这里拿不到远程的http端口 BrowseUtils.browser(WorkContext.getCurrent().getPath()); - } else if (ComparatorUtils.equals(StableUtils.getInstallHome(), ".")) {//august:供代码使用 - String web = GeneralContext.getCurrentAppNameOfEnv(); - browserURLWithLocalEnv("http://localhost:" + DesignerEnvManager.getEnvManager().getEmbedServerPort() + "/" + web + "/" + ServerConfig.getInstance().getServletName()); } else { - initDemoServerAndBrowser(); - } - - } - - - private static void initDemoServerAndBrowser() { - - try { - FineEmbedServer.start(); - } finally { - //先访问Demo, 后访问报表, 不需要重置服务器. - BrowseUtils.browser("http://localhost:" + DesignerEnvManager.getEnvManager().getEmbedServerPort() + "/" + GeneralContext.getCurrentAppNameOfEnv() + "/" + ServerConfig.getInstance().getServletName()); + browserURLWithLocalEnv("http://localhost:" + + DesignerEnvManager.getEnvManager().getEmbedServerPort() + + "/" + GeneralContext.getCurrentAppNameOfEnv() + + "/" + ServerConfig.getInstance().getServletName()); } } @@ -51,8 +38,8 @@ public class ServerStarter { * @param url 指定路径 */ public static void browserURLWithLocalEnv(final String url) { - - if (!FineEmbedServerMonitor.getInstance().isComplete()) { + // 内置服务器没有启动并且设计器已经打开,可以使用带进度条的启动方式 + if (!FineEmbedServer.isRunning() && DesignerContext.getDesignerFrame().isDesignerOpened()) { FineEmbedServerMonitor.getInstance().monitor(); ExecutorService service = Executors.newSingleThreadExecutor(new NamedThreadFactory("ServerStarter")); service.submit(new Runnable() { @@ -68,8 +55,15 @@ public class ServerStarter { } }); service.shutdown(); + } else if (!FineEmbedServer.isRunning()) { + // 普通方式启动内置服务器 + try { + FineEmbedServer.start(); + } finally { + BrowseUtils.browser(url); + } } else { - FineEmbedServer.start(); + // 已经启动内置服务器只需打开链接 BrowseUtils.browser(url); } } diff --git a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java index 12aebd231a..a67b7e55a8 100644 --- a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java +++ b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java @@ -1,6 +1,5 @@ package com.fr.start.server; -import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; import com.fr.log.FineLoggerFactory; import com.fr.module.Activator; @@ -15,6 +14,7 @@ import org.apache.catalina.Context; import org.apache.catalina.LifecycleException; import org.apache.catalina.loader.WebappLoader; import org.apache.catalina.startup.Tomcat; +import org.apache.catalina.webresources.StandardRoot; import java.io.File; import java.util.HashSet; @@ -63,10 +63,11 @@ public class FineEmbedServerActivator extends Activator { // 设置解码uri使用的字符编码 tomcat.getConnector().setURIEncoding(EncodeConstants.ENCODING_UTF_8); String docBase = new File(WorkContext.getCurrent().getPath()).getParent(); - //内置的上下文是自己定的,这里把WEB_APP_NAME一并设置了,否则下面appName是/null - ProductConstants.setWebAppName(ProductConstants.getAppFolderName()); - String appName = "/" + FRContext.getCommonOperator().getAppName(); - Context context = tomcat.addContext(appName, docBase); + + //内置的上下文使用工程目录比如webroot + String contextPath = "/" + ProductConstants.getAppFolderName(); + final Context context = tomcat.addContext(contextPath, docBase); + context.setResources(new StandardRoot(context)); Tomcat.initWebappDefaults(context); //覆盖tomcat的WebAppClassLoader context.setLoader(new FRTomcatLoader()); diff --git a/designer-base/src/main/resources/com/fr/design/icon/logo.png b/designer-base/src/main/resources/com/fr/design/icon/logo.png new file mode 100644 index 0000000000..d4c7d8b24d Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/icon/logo.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/edit/edit_typing.png b/designer-base/src/main/resources/com/fr/design/images/edit/edit_typing.png new file mode 100644 index 0000000000..929f14137a Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/edit/edit_typing.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/error/error.png b/designer-base/src/main/resources/com/fr/design/images/error/error.png new file mode 100644 index 0000000000..fd4a465091 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/error/error.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/error/error2.png b/designer-base/src/main/resources/com/fr/design/images/error/error2.png new file mode 100644 index 0000000000..ff0450a5a4 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/error/error2.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/gui/color/autoForeground.png b/designer-base/src/main/resources/com/fr/design/images/gui/color/autoForeground.png new file mode 100755 index 0000000000..4186fea2cf Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/gui/color/autoForeground.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/warnings/warning4.png b/designer-base/src/main/resources/com/fr/design/images/warnings/warning4.png new file mode 100644 index 0000000000..a982ee864b Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/warnings/warning4.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/warnings/warning5.png b/designer-base/src/main/resources/com/fr/design/images/warnings/warning5.png new file mode 100644 index 0000000000..059206e0cc Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/warnings/warning5.png differ diff --git a/designer-base/src/main/resources/com/fr/design/ui/update/push/pushUpdate.js b/designer-base/src/main/resources/com/fr/design/ui/update/push/pushUpdate.js index f42fb1ac7b..d1c46cee2a 100644 --- a/designer-base/src/main/resources/com/fr/design/ui/update/push/pushUpdate.js +++ b/designer-base/src/main/resources/com/fr/design/ui/update/push/pushUpdate.js @@ -104,8 +104,7 @@ function getMoreInfo() { function getCloseButton() { return BI.createWidget({ type: "bi.button", - text: "", - iconCls: "close-font", + text: String.fromCharCode(10005), cls: "close-btn", clear: true, handler: function () { diff --git a/designer-base/src/test/java/com/fr/common/detect/CommonPortDetectorTest.java b/designer-base/src/test/java/com/fr/common/detect/CommonPortDetectorTest.java new file mode 100644 index 0000000000..fa9915b315 --- /dev/null +++ b/designer-base/src/test/java/com/fr/common/detect/CommonPortDetectorTest.java @@ -0,0 +1,45 @@ +package com.fr.common.detect; + +import com.fr.invoke.Reflect; +import com.fr.log.FineLoggerFactory; +import junit.framework.TestCase; +import org.junit.Assert; + +import java.io.IOException; +import java.net.ServerSocket; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/10 + */ +public class CommonPortDetectorTest extends TestCase { + + private ServerSocket serverSocket; + + @Override + public void setUp() throws Exception { + serverSocket = new ServerSocket(55555); + new Thread(new Runnable() { + @Override + public void run() { + try { + serverSocket.accept(); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + }).start(); + } + + public void testCheckPort() { + CommonPortDetector detector = CommonPortDetector.getInstance(); + boolean access = Reflect.on(detector).call("checkPort", 55555).get(); + Assert.assertTrue(access); + } + + @Override + public void tearDown() throws Exception { + serverSocket.close(); + } +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java b/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java new file mode 100644 index 0000000000..f37c6e73d1 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java @@ -0,0 +1,58 @@ +package com.fr.design; + +import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceType; +import com.fr.env.CheckServiceDialog; +import com.fr.workspace.connect.WorkspaceConnectionInfo; +import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +/** + * @author: Maksim + * @Date: Created in 2020/3/5 + * @Description: + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({FunctionalHttpRequest.class,EnvChangeEntrance.class,CheckServiceDialog.class}) +public class EnvChangeEntranceTest { + + @Test + public void showServiceDialog() throws Exception { + try { + EnvChangeEntrance entrance = EnvChangeEntrance.getInstance(); + DesignerWorkspaceInfo selectedEnv = EasyMock.mock(DesignerWorkspaceInfo.class); + WorkspaceConnectionInfo connectionInfo = EasyMock.mock(WorkspaceConnectionInfo.class); + + String remoteBranch = "Build#persist-2020.02.15.01.01.12.12"; + EasyMock.expect(selectedEnv.getConnection()).andReturn(connectionInfo); + EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Remote); + EasyMock.expect(selectedEnv.getRemindTime()).andReturn(null); + + FunctionalHttpRequest request = EasyMock.mock(FunctionalHttpRequest.class); + EasyMock.expect(request.getServiceList()).andReturn(null); + + PowerMock.expectNew(FunctionalHttpRequest.class, connectionInfo).andReturn(request).anyTimes(); + EasyMock.expect(request.getServerBranch()).andReturn(remoteBranch); + + CheckServiceDialog dialog = EasyMock.mock(CheckServiceDialog.class); + PowerMock.expectNew(CheckServiceDialog.class, EasyMock.anyObject(), EasyMock.anyObject(), EasyMock.anyObject(), EasyMock.anyObject()).andReturn(dialog); + + EasyMock.replay(request); + EasyMock.replay(selectedEnv); + EasyMock.replay(connectionInfo); + PowerMock.replayAll(); + + entrance.showServiceDialog(selectedEnv); + Assert.assertTrue(true); + }catch (Exception e){ + Assert.assertTrue(false); + } + } + +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java b/designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java index 8d2f522c06..9a5ce7b8c1 100644 --- a/designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java +++ b/designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java @@ -1,11 +1,15 @@ package com.fr.design.data; import com.fr.base.TableData; +import com.fr.data.TableDataSource; import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.design.data.tabledata.wrapper.TableDataFactory; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; +import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; import com.fr.file.ProcedureConfig; import com.fr.file.TableDataConfig; +import com.fr.invoke.Reflect; +import com.fr.stable.ArrayUtils; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Test; @@ -23,6 +27,7 @@ import java.util.Map; @SuppressStaticInitializationFor({"com.fr.design.data.tabledata.wrapper.TableDataFactory"}) public class DesignTableDataManagerTest { + @Test public void testFireDataChange() { @@ -99,4 +104,55 @@ public class DesignTableDataManagerTest { } + + @Test + public void testGetSelectedColumnNames() throws Exception { + PowerMock.mockStatic(TableDataConfig.class); + PowerMock.mockStatic(TemplateTableDataWrapper.class); + TableDataConfig config = EasyMock.mock(TableDataConfig.class); + TableData td1 = EasyMock.mock(TableData.class); + TableData td2 = EasyMock.mock(TableData.class); + TableDataSource dataSource = EasyMock.mock(TableDataSource.class); + EasyMock.expect(config.getTableData("ds1")).andReturn(td1).anyTimes(); + EasyMock.expect(config.getTableData("ds2")).andReturn(td2).anyTimes(); + EasyMock.expect(dataSource.getTableData("ds1")).andReturn(td1).anyTimes(); + EasyMock.expect(dataSource.getTableData("ds2")).andReturn(td2).anyTimes(); + EasyMock.expect(TableDataConfig.getInstance()).andReturn(config).anyTimes(); + PowerMock.mockStatic(TableDataFactory.class); + EasyMock.expect(TableDataFactory.getSortOfChineseNameOfServerData(config)) + .andReturn(new String[]{"ds1", "ds2"}).anyTimes(); + EasyMock.expect(TableDataFactory.getSortOfChineseNameOfTemplateData(dataSource)) + .andReturn(new String[]{"ds1", "ds2"}); + Map> cache = Reflect.on(DesignTableDataManager.class).field( + "columnCache").get(); + Map map = new HashMap<>(); + map.put("ds1", new String[]{"a", "b", "c"}); + cache.put(dataSource, map); + ProcedureConfig proConfig = EasyMock.mock(ProcedureConfig.class); + Map procedureMap = new HashMap<>(); + EasyMock.expect(proConfig.getProcedures()).andReturn(procedureMap).anyTimes(); + PowerMock.mockStatic(ProcedureConfig.class); + EasyMock.expect(ProcedureConfig.getInstance()).andReturn(proConfig).anyTimes(); + EasyMock.replay(config, proConfig, dataSource); + PowerMock.replay(TableDataFactory.class, TableDataConfig.class, ProcedureConfig.class, + TemplateTableDataWrapper.class); + Assert.assertEquals(new String[]{"a", "b", "c"}, + DesignTableDataManager.getSelectedColumnNames(dataSource, "ds1")); + } + + @Test + public void testAddDsColumnNames() { + DesignTableDataManager.addDsColumnNames("ds1", new String[]{"a", "b", "c"}); + Map> map = Reflect.on(DesignTableDataManager.class).field( + "columnCache").get(); + Assert.assertEquals(new String[]{"a", "b", "c"}, map.get(null).get("ds1")); + } + + @Test + public void testGetDsColumnNames() { + Assert.assertTrue(ArrayUtils.isEmpty(DesignTableDataManager.getDsColumnNames("ds1"))); + String[] columnNames = new String[]{"a", "b", "c"}; + DesignTableDataManager.addDsColumnNames("ds1", new String[]{"a", "b", "c"}); + Assert.assertEquals(columnNames, DesignTableDataManager.getDsColumnNames("ds1")); + } } diff --git a/designer-base/src/test/java/com/fr/design/env/RemoteWorkspaceTest.java b/designer-base/src/test/java/com/fr/design/env/RemoteWorkspaceTest.java new file mode 100644 index 0000000000..fe7f365e64 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/env/RemoteWorkspaceTest.java @@ -0,0 +1,54 @@ +package com.fr.design.env; + +import com.fr.base.operator.common.CommonOperator; +import com.fr.invoke.ReflectException; +import com.fr.workspace.WorkContext; +import com.fr.workspace.Workspace; +import com.fr.workspace.connect.WorkspaceConnectionInfo; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/1/2 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({WorkContext.class}) +public class RemoteWorkspaceTest { + @Test + public void testIsWarDeploy() { + + Workspace workspace = EasyMock.mock(Workspace.class); + PowerMock.mockStatic(WorkContext.class); + EasyMock.expect(WorkContext.getCurrent()).andReturn(workspace).anyTimes(); + + CommonOperator operator = EasyMock.createMock(CommonOperator.class); + EasyMock.expect(workspace.get(CommonOperator.class)).andReturn(operator).anyTimes(); + + EasyMock.expect(operator.isWarDeploy()).andReturn(true).once(); + EasyMock.expect(operator.isWarDeploy()).andReturn(false).once(); + EasyMock.expect(operator.isWarDeploy()).andThrow(new ReflectException()).once(); + + EasyMock.replay(workspace, operator); + PowerMock.replayAll(); + + WorkspaceConnectionInfo info = new WorkspaceConnectionInfo("url", "username", "password", "certPath", "certSecretKey"); + + RemoteWorkspace remoteWorkspace= new RemoteWorkspace(null, info); + + Assert.assertTrue(remoteWorkspace.isWarDeploy()); + Assert.assertFalse(remoteWorkspace.isWarDeploy()); + Assert.assertFalse(remoteWorkspace.isWarDeploy()); + + EasyMock.verify(workspace, operator); + PowerMock.verifyAll(); + + + } +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/file/HistoryTemplateListCacheTest.java b/designer-base/src/test/java/com/fr/design/file/HistoryTemplateListCacheTest.java new file mode 100644 index 0000000000..bd9f8484da --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/file/HistoryTemplateListCacheTest.java @@ -0,0 +1,33 @@ +package com.fr.design.file; + +import com.fr.design.mainframe.JTemplate; +import com.fr.file.FILE; +import com.fr.invoke.Reflect; +import junit.framework.TestCase; +import org.easymock.EasyMock; +import org.junit.Assert; + +import java.util.ArrayList; +import java.util.Arrays; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/23 + */ +public class HistoryTemplateListCacheTest extends TestCase { + + public void testContains() { + JTemplate jTemplate = EasyMock.mock(JTemplate.class); + FILE file = EasyMock.mock(FILE.class); + EasyMock.expect(jTemplate.getEditingFILE()).andReturn(file).anyTimes(); + EasyMock.replay(file); + EasyMock.replay(jTemplate); + Assert.assertEquals(-1, HistoryTemplateListCache.getInstance().contains(file)); + Assert.assertEquals(-1, HistoryTemplateListCache.getInstance().contains(jTemplate)); + Reflect.on(HistoryTemplateListCache.getInstance()).set("historyList", new ArrayList<>(Arrays.asList(jTemplate))); + Assert.assertEquals(0, HistoryTemplateListCache.getInstance().contains(file)); + Assert.assertEquals(0, HistoryTemplateListCache.getInstance().contains(jTemplate)); + } + +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/mainfarme/toolbar/ToolBarMenuDockTest.java b/designer-base/src/test/java/com/fr/design/mainfarme/toolbar/ToolBarMenuDockTest.java new file mode 100644 index 0000000000..c5f9f0a700 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/mainfarme/toolbar/ToolBarMenuDockTest.java @@ -0,0 +1,129 @@ +package com.fr.design.mainfarme.toolbar; + +import java.util.Locale; + +import com.fr.design.DesignerEnvManager; +import com.fr.design.actions.community.VideoAction; +import com.fr.design.actions.help.AboutAction; +import com.fr.design.actions.help.FineUIAction; +import com.fr.design.actions.help.TutorialAction; +import com.fr.design.actions.help.WebDemoAction; +import com.fr.design.actions.help.alphafine.AlphaFineAction; +import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; +import com.fr.design.mainframe.toolbar.ToolBarMenuDock; +import com.fr.design.menu.SeparatorDef; +import com.fr.design.menu.ShortCut; +import com.fr.design.os.impl.SupportOSImpl; +import com.fr.design.update.actions.SoftwareUpdateAction; +import com.fr.general.GeneralContext; +import com.fr.workspace.WorkContext; +import com.fr.workspace.Workspace; +import org.easymock.EasyMock; +import org.easymock.Mock; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.reflect.Whitebox; + + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2019/12/11 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({ + ToolBarMenuDock.class, + GeneralContext.class, + Locale.class, + WorkContext.class, + DesignerEnvManager.class, + AlphaFineConfigManager.class}) +public class ToolBarMenuDockTest { + + @Mock + VideoAction videoAction; + @Mock + TutorialAction tutorialAction; + @Mock + WebDemoAction webDemoAction; + @Mock + SoftwareUpdateAction softwareUpdateAction; + @Mock + AlphaFineAction alphaFineAction; + @Mock + FineUIAction fineUIAction; + @Mock + AboutAction aboutAction; + + @Before + public void testCreateHelpShortCutsBefore() { + try { + PowerMock.expectNew(VideoAction.class).andReturn(videoAction).anyTimes(); + PowerMock.expectNew(TutorialAction.class).andReturn(tutorialAction).anyTimes(); + PowerMock.expectNew(WebDemoAction.class).andReturn(webDemoAction).anyTimes(); + PowerMock.expectNew(SoftwareUpdateAction.class).andReturn(softwareUpdateAction).anyTimes(); + PowerMock.expectNew(AlphaFineAction.class).andReturn(alphaFineAction).anyTimes(); + PowerMock.expectNew(FineUIAction.class).andReturn(fineUIAction).anyTimes(); + PowerMock.expectNew(AboutAction.class).andReturn(aboutAction).anyTimes(); + } catch (Exception e) { + Assert.fail(e.getMessage()); + } + } + + @Test + public void testCreateHelpShortCuts() { + + // 处理判断条件 + GeneralContext context = EasyMock.createMock(GeneralContext.class); + PowerMock.mockStatic(GeneralContext.class); + EasyMock.expect(GeneralContext.getLocale()).andReturn(Locale.CHINA).once(); + EasyMock.expect(GeneralContext.getLocale()).andReturn(Locale.US).once(); + + Workspace workspace = EasyMock.createMock(Workspace.class); + PowerMock.mockStatic(WorkContext.class); + EasyMock.expect(WorkContext.getCurrent()).andReturn(workspace).anyTimes(); + + EasyMock.expect(workspace.isLocal()).andReturn(false).once(); + EasyMock.expect(workspace.isLocal()).andReturn(true).once(); + + DesignerEnvManager envManager = EasyMock.createMock(DesignerEnvManager.class); + PowerMock.mockStatic(DesignerEnvManager.class); + EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(envManager).anyTimes(); + + EasyMock.expect(envManager.isOpenDebug()).andReturn(false).once(); + EasyMock.expect(envManager.isOpenDebug()).andReturn(true).once(); + + AlphaFineConfigManager configManager = EasyMock.createMock(AlphaFineConfigManager.class); + PowerMock.mockStatic(AlphaFineConfigManager.class); + EasyMock.expect(AlphaFineConfigManager.isALPHALicAvailable()).andReturn(false).once(); + EasyMock.expect(AlphaFineConfigManager.isALPHALicAvailable()).andReturn(true).once(); + + SupportOSImpl osImpl = EasyMock.createMock(SupportOSImpl.class); + Whitebox.setInternalState(SupportOSImpl.class, "FINEUI", osImpl); + EasyMock.expect(osImpl.support()).andReturn(false).anyTimes(); + + EasyMock.replay(context, workspace, envManager, configManager, osImpl); + PowerMock.replayAll(); + + + ToolBarMenuDock menuDock = new ToolBarMenuDock() { + @Override + public ShortCut[] createNewFileShortCuts() { + return new ShortCut[0]; + } + }; + + ShortCut[] shortCuts1 = new ShortCut[] {SeparatorDef.DEFAULT, aboutAction}; + ShortCut[] shortCuts2 = new ShortCut[] {videoAction, tutorialAction, webDemoAction, + softwareUpdateAction, alphaFineAction, SeparatorDef.DEFAULT, aboutAction}; + + Assert.assertEquals(menuDock.createHelpShortCuts(), shortCuts1); + Assert.assertEquals(menuDock.createHelpShortCuts(), shortCuts2); + + } +} diff --git a/designer-base/src/test/java/com/fr/design/mainframe/template/info/SendHelperTest.java b/designer-base/src/test/java/com/fr/design/mainframe/template/info/SendHelperTest.java index fb89143d8d..8da46557c6 100644 --- a/designer-base/src/test/java/com/fr/design/mainframe/template/info/SendHelperTest.java +++ b/designer-base/src/test/java/com/fr/design/mainframe/template/info/SendHelperTest.java @@ -1,10 +1,12 @@ package com.fr.design.mainframe.template.info; import com.fr.invoke.Reflect; +import com.fr.json.JSONObject; import com.fr.stable.xml.XMLableReader; import com.fr.third.javax.xml.stream.XMLStreamException; import java.io.StringReader; +import java.util.Map; import static org.junit.Assert.assertTrue; @@ -25,11 +27,12 @@ public class SendHelperTest { StringReader sr = new StringReader(NORMAL_INFO); XMLableReader xmlReader = XMLableReader.createXMLableReader(sr); TemplateInfo templateInfo = TemplateInfo.newInstanceByRead(xmlReader); - - boolean res = Reflect.on(SendHelper.class).call("sendSingleTemplateInfo", CONSUMING_URL, templateInfo.getConsumingMapJsonString()).get(); + Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); + Map processMap = Reflect.on(templateInfo).field("processMap").get(); + boolean res = Reflect.on(SendHelper.class).call("sendSinglePointInfo", CONSUMING_URL, new JSONObject(consumingMap).toString()).get(); assertTrue(res); - boolean res2 = Reflect.on(SendHelper.class).call("sendSingleTemplateInfo", PROCESS_URL, templateInfo.getProcessMapJsonString()).get(); + boolean res2 = Reflect.on(SendHelper.class).call("sendSinglePointInfo", PROCESS_URL, new JSONObject(processMap).toString()).get(); assertTrue(res2); } } diff --git a/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java b/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java index d93a7476a9..3235473c63 100644 --- a/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java +++ b/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe.template.info; import com.fr.config.MarketConfig; import com.fr.general.GeneralUtils; import com.fr.invoke.Reflect; +import com.fr.json.JSONObject; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.third.org.apache.commons.io.FileUtils; @@ -71,7 +72,7 @@ public class TemplateInfoCollectorTest { assertEquals(",,", DesignerOpenHistory.getInstance().toString()); TemplateInfoCollector collector = TemplateInfoCollector.getInstance(); - assertEquals(7, ((Map) Reflect.on(collector).field("templateInfoMap").get()).size()); + assertEquals(7, ((Map) Reflect.on(collector).field("pointInfoMap").get()).size()); assertEquals("2019-04-08,2019-04-03,2019-03-29", DesignerOpenHistory.getInstance().toString()); } @@ -86,18 +87,21 @@ public class TemplateInfoCollectorTest { collector.collectInfo(templateID, StringUtils.EMPTY, mockProcessInfo, timeConsume); // 检查是否写入成功 - collector.loadFromFile(); + Reflect.on(collector).call("loadFromFile"); TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID); + Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); + Map processMap = Reflect.on(templateInfo).field("processMap").get(); + assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," + "\"cell_count\":13,\"block_count\":3,\"report_type\":0," + - "\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"}", templateInfo.getProcessMapJsonString()); + "\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"}", new JSONObject(processMap).toString()); assertJsonStringEquals("{\"activitykey\":\"2e0ea413-fa9c241e0-9723-4354fce51e81\"," + "\"jar_time\":\"不是安装版本\",\"create_time\":\"2019-03-26 16:13\"," + "\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\",\"originID\":\"\"," + "\"uuid\":\"476ca2cc-f789-4c5d-8e89-ef146580775c\",\"time_consume\":329,\"originTime\":0," + - "\"version\":\"10.0\",\"username\":\"plough\"}", templateInfo.getConsumingMapJsonString()); + "\"version\":\"10.0\",\"username\":\"plough\"}", new JSONObject(consumingMap).toString()); } @Test @@ -112,15 +116,17 @@ public class TemplateInfoCollectorTest { collector.collectInfo(templateID, StringUtils.EMPTY, mockProcessInfo, timeConsume); // 检查是否写入成功 - collector.loadFromFile(); + Reflect.on(collector).call("loadFromFile"); assertTrue(collector.contains(templateID)); TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID); + Map processMap = Reflect.on(templateInfo).field("processMap").get(); + assertEquals(templateID, templateInfo.getTemplateID()); assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," + "\"cell_count\":13,\"block_count\":3,\"report_type\":0," + - "\"templateID\":\"73a97777-8jnk-47cd-b57c-2ee89991279796\"}", templateInfo.getProcessMapJsonString()); + "\"templateID\":\"73a97777-8jnk-47cd-b57c-2ee89991279796\"}", new JSONObject(processMap).toString()); Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); assertEquals(templateID, consumingMap.get("templateID")); @@ -142,12 +148,13 @@ public class TemplateInfoCollectorTest { collector.collectInfo(templateID, originID, mockProcessInfo, timeConsume); // 检查是否写入成功 - collector.loadFromFile(); + Reflect.on(collector).call("loadFromFile"); TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID); + Map processMap = Reflect.on(templateInfo).field("processMap").get(); assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," + "\"cell_count\":13,\"block_count\":3,\"report_type\":0," + - "\"templateID\":\"423238d4-5223-22vj-vlsj-42jc49245iw3\"}", templateInfo.getProcessMapJsonString()); + "\"templateID\":\"423238d4-5223-22vj-vlsj-42jc49245iw3\"}", new JSONObject(processMap).toString()); Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); assertEquals(templateID, consumingMap.get("templateID")); diff --git a/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTest.java b/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTest.java index 426dba3b1d..7f0ddd0bcc 100644 --- a/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTest.java +++ b/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTest.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe.template.info; import com.fr.config.MarketConfig; import com.fr.general.GeneralUtils; import com.fr.invoke.Reflect; +import com.fr.json.JSONObject; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLableReader; @@ -55,7 +56,6 @@ public class TemplateInfoTest { assertEquals(templateID, templateInfo.getTemplateID()); assertEquals(StringUtils.EMPTY, Reflect.on(templateInfo).field("originID").get()); assertEquals(0, (int) Reflect.on(templateInfo).field("idleDayCount").get()); - assertEquals("{}", templateInfo.getProcessMapJsonString()); Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); assertEquals(templateID, consumingMap.get("templateID")); @@ -78,7 +78,6 @@ public class TemplateInfoTest { assertEquals(templateID, templateInfo.getTemplateID()); assertEquals(originID, Reflect.on(templateInfo).field("originID").get()); assertEquals(0, (int) Reflect.on(templateInfo).field("idleDayCount").get()); - assertEquals("{}", templateInfo.getProcessMapJsonString()); Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); assertEquals(templateID, consumingMap.get("templateID")); @@ -97,24 +96,25 @@ public class TemplateInfoTest { } @Test - public void testGetConsumingMapJsonString() { + public void testGetSendInfo() { + + Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); + Map processMap = Reflect.on(templateInfo).field("processMap").get(); + Map consumingMap1 = Reflect.on(templateInfoSaveAs).field("consumingMap").get(); + Map processMap1 = Reflect.on(templateInfoSaveAs).field("processMap").get(); assertJsonStringEquals("{\"activitykey\":\"2e0ea413-fa9c241e0-9723-4354fce51e81\",\"jar_time\":\"不是安装版本\"," + "\"create_time\":\"2019-03-26 16:13\",\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\",\"originID\":\"\"," + "\"uuid\":\"476ca2cc-f789-4c5d-8e89-ef146580775c\",\"time_consume\":129,\"originTime\":0,\"version\":\"10.0\"," + - "\"username\":\"plough\"}", templateInfo.getConsumingMapJsonString()); + "\"username\":\"plough\"}", new JSONObject(consumingMap).toString()); assertJsonStringEquals("{\"activitykey\":\"2e0ea413-fa9c241e0-9723-4354fce51e81\",\"jar_time\":\"不是安装版本\"," + "\"create_time\":\"2019-03-26 16:13\",\"templateID\":\"49avd2c4-1104-92j2-wx24-3dd0k2136080\",\"originID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"," + "\"uuid\":\"476ca2cc-f789-4c5d-8e89-ef146580775c\",\"time_consume\":429,\"originTime\":129,\"version\":\"10.0\"," + - "\"username\":\"plough\"}", templateInfoSaveAs.getConsumingMapJsonString()); - } - - @Test - public void testGetProcessMapJsonString() { + "\"username\":\"plough\"}", new JSONObject(consumingMap1).toString()); assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":1," + - "\"block_count\":0,\"report_type\":0,\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"}", templateInfo.getProcessMapJsonString()); + "\"block_count\":0,\"report_type\":0,\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"}", new JSONObject(processMap).toString()); assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":1," + - "\"block_count\":0,\"report_type\":0,\"templateID\":\"49avd2c4-1104-92j2-wx24-3dd0k2136080\"}", templateInfoSaveAs.getProcessMapJsonString()); + "\"block_count\":0,\"report_type\":0,\"templateID\":\"49avd2c4-1104-92j2-wx24-3dd0k2136080\"}", new JSONObject(processMap1).toString()); } private TemplateInfo createTemplateInfo(String xmlContent) throws XMLStreamException { diff --git a/designer-base/src/test/java/com/fr/design/os/impl/SupportOSImplTest.java b/designer-base/src/test/java/com/fr/design/os/impl/SupportOSImplTest.java new file mode 100644 index 0000000000..1887537970 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/os/impl/SupportOSImplTest.java @@ -0,0 +1,24 @@ +package com.fr.design.os.impl; + +import com.fr.general.GeneralContext; +import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Locale; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/1/16 + */ +public class SupportOSImplTest extends TestCase { + + @Test + public void testAutoPush() { + Assert.assertTrue(SupportOSImpl.AUTOPUSHUPDATE.support()); + GeneralContext.setLocale(Locale.TAIWAN); + Assert.assertFalse(SupportOSImpl.AUTOPUSHUPDATE.support()); + } + +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/utils/DesignUtilsTest.java b/designer-base/src/test/java/com/fr/design/utils/DesignUtilsTest.java new file mode 100644 index 0000000000..9db729a978 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/utils/DesignUtilsTest.java @@ -0,0 +1,32 @@ +package com.fr.design.utils; + + +import com.fr.general.ComparatorUtils; +import junit.framework.TestCase; +import org.junit.Test; + +import java.net.ServerSocket; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/1/10 + */ +public class DesignUtilsTest extends TestCase { + + @Test + public void testIsPortOccupied() { + assertFalse(DesignUtils.isPortOccupied()); + try { + if (ComparatorUtils.equals("true", System.getProperty("debug"))) { + new ServerSocket(DesignerPort.getInstance().getDebugMessagePort()); + } else { + new ServerSocket(DesignerPort.getInstance().getMessagePort()); + } + } catch (Exception ignore) { + System.exit(0); + } + assertTrue(DesignUtils.isPortOccupied()); + } + +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/env/utils/DisplayUtilsTest.java b/designer-base/src/test/java/com/fr/env/utils/DisplayUtilsTest.java new file mode 100644 index 0000000000..181bd97887 --- /dev/null +++ b/designer-base/src/test/java/com/fr/env/utils/DisplayUtilsTest.java @@ -0,0 +1,52 @@ +package com.fr.env.utils; + +import org.junit.Assert; +import org.junit.Test; + + +/** + * @author: Maksim + * @Date: Created in 2020/3/16 + * @Description: + */ +public class DisplayUtilsTest { + + @Test + public void getDisplayLengthTest() { + String s1 = "本地设计器"; + String s2 = "リモートサーバ"; + String s3 = "Local Designer:"; + String s4 = "本地,设,计器: persist-2020.01.15"; + String s5 = "ローカルデザイナrelease-2020.03.03 ... Remote Server:persist-2020.01.15"; + String s6 = "本地 00:00ロ ーカDE / abc "; + + int length1 = DisplayUtils.getDisplayLength(s1); + int length2 = DisplayUtils.getDisplayLength(s2); + int length3 = DisplayUtils.getDisplayLength(s3); + int length4 = DisplayUtils.getDisplayLength(s4); + int length5 = DisplayUtils.getDisplayLength(s5); + int length6 = DisplayUtils.getDisplayLength(s6); + Assert.assertEquals(10,length1); + Assert.assertEquals(14,length2); + Assert.assertEquals(15,length3); + Assert.assertEquals(34,length4); + Assert.assertEquals(72,length5); + Assert.assertEquals(26,length6); + } + + @Test + public void isLetterTest(){ + char c1 = 'A'; + char c2 = '中'; + char c3 = ','; + char c4 = ','; + char c5 = 'デ'; + char c6 = ' '; + Assert.assertTrue(DisplayUtils.isLetter(c1)); + Assert.assertFalse(DisplayUtils.isLetter(c2)); + Assert.assertTrue(DisplayUtils.isLetter(c3)); + Assert.assertFalse(DisplayUtils.isLetter(c4)); + Assert.assertFalse(DisplayUtils.isLetter(c5)); + Assert.assertTrue(DisplayUtils.isLetter(c6)); + } +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java b/designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java index c8431a8621..064cd05cec 100644 --- a/designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java +++ b/designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java @@ -25,15 +25,30 @@ public class FILEChooserPaneTest { ChooseFileFilter chooseFileFilter2 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); String result3 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cpt", chooseFileFilter2).get(); - Assert.assertEquals("WorkBook1.cptx", result3); + Assert.assertEquals("WorkBook1.cpt.cptx", result3); ChooseFileFilter chooseFileFilter3 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY); String result4 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter3).get(); - Assert.assertEquals("WorkBook1.cpt", result4); + Assert.assertEquals("WorkBook1.cptx.cpt", result4); ChooseFileFilter chooseFileFilter5 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); String result5 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter5).get(); Assert.assertEquals("WorkBook1.cptx", result5); + + ChooseFileFilter chooseFileFilter6 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY); + String result6 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.xls", chooseFileFilter6).get(); + Assert.assertEquals("WorkBook1.xls.cpt", result6); + + ChooseFileFilter chooseFileFilter7 = new ChooseFileFilter(FileExtension.XLS, StringUtils.EMPTY); + chooseFileFilter7.addExtension(".xlsx"); + String result7 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1", chooseFileFilter7).get(); + Assert.assertEquals("WorkBook1.xls", result7); + + ChooseFileFilter chooseFileFilter8 = new ChooseFileFilter(FileExtension.XLSX, StringUtils.EMPTY); + chooseFileFilter8.addExtension(".xls"); + String result8 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1", chooseFileFilter8).get(); + Assert.assertEquals("WorkBook1.xlsx", result8); + } } diff --git a/designer-base/src/test/java/com/fr/file/filter/ChooseFileFilterTest.java b/designer-base/src/test/java/com/fr/file/filter/ChooseFileFilterTest.java new file mode 100644 index 0000000000..ec6779bab0 --- /dev/null +++ b/designer-base/src/test/java/com/fr/file/filter/ChooseFileFilterTest.java @@ -0,0 +1,33 @@ +package com.fr.file.filter; + +import com.fr.base.extension.FileExtension; +import com.fr.stable.CoreConstants; +import com.fr.stable.StringUtils; +import junit.framework.TestCase; +import org.junit.Assert; + + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/18 + */ +public class ChooseFileFilterTest extends TestCase { + + public void testGetExtensionString() { + ChooseFileFilter chooseFileFilter = new ChooseFileFilter(FileExtension.XLSX, StringUtils.EMPTY); + chooseFileFilter.addExtension(FileExtension.XLS.getExtension()); + Assert.assertEquals(CoreConstants.DOT + FileExtension.XLSX.getExtension(), chooseFileFilter.getExtensionString()); + Assert.assertEquals(CoreConstants.DOT + FileExtension.XLS.getExtension(), chooseFileFilter.getExtensionString(1)); + ChooseFileFilter chooseFileFilter1 = new ChooseFileFilter(); + Assert.assertEquals(StringUtils.EMPTY, chooseFileFilter1.getExtensionString()); + Assert.assertEquals(StringUtils.EMPTY, chooseFileFilter1.getExtensionString(1)); + + } + + public void testGetExtensionCount() { + ChooseFileFilter chooseFileFilter = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY); + chooseFileFilter.addExtension(FileExtension.CPTX.getExtension()); + Assert.assertEquals(2, chooseFileFilter.getExtensionCount()); + } +} \ No newline at end of file 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 f6f674ba95..4eb7258348 100644 --- a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java @@ -11,6 +11,18 @@ 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; +import com.fr.design.gui.core.WidgetOption; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.mainframe.chart.AbstractChartAttrPane; +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.gui.type.AbstractChartTypePane; +import com.fr.design.module.DesignModuleFactory; import com.fr.design.type.ui.AreaChartTypeUI; import com.fr.design.type.ui.BarChartTypeUI; import com.fr.design.type.ui.BubbleChartTypeUI; @@ -28,18 +40,6 @@ import com.fr.design.type.ui.RadarChartTypeUI; import com.fr.design.type.ui.RangeChartTypeUI; import com.fr.design.type.ui.StockChartTypeUI; import com.fr.design.type.ui.XYScatterChartTypeUI; -import com.fr.design.condition.ConditionAttributesPane; -import com.fr.design.gui.core.WidgetOption; -import com.fr.design.gui.frpane.AttributeChangeListener; -import com.fr.design.mainframe.chart.AbstractChartAttrPane; -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.gui.type.AbstractChartTypePane; -import com.fr.design.module.DesignModuleFactory; import com.fr.extended.chart.AbstractChart; import com.fr.form.ui.ChartEditor; import com.fr.general.GeneralContext; @@ -80,20 +80,20 @@ import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import com.fr.van.chart.area.AreaIndependentVanChartInterface; import com.fr.van.chart.bar.BarIndependentVanChartInterface; import com.fr.van.chart.bubble.BubbleIndependentVanChartInterface; -import com.fr.van.chart.column.ColumnIndependentVanChartInterface; +import com.fr.van.chart.column.VanColumnChartTypeUI; import com.fr.van.chart.custom.CustomIndependentVanChartInterface; -import com.fr.van.chart.drillmap.DrillMapIndependentVanChartInterface; +import com.fr.van.chart.drillmap.VanDrillMapChartTypeUI; import com.fr.van.chart.funnel.designer.FunnelIndependentVanChartInterface; import com.fr.van.chart.gantt.designer.GanttIndependentVanChartInterface; import com.fr.van.chart.gauge.GaugeIndependentVanChartInterface; -import com.fr.van.chart.heatmap.designer.HeatMapIndependentVanChartInterface; +import com.fr.van.chart.heatmap.designer.VanHeatMapChartTypeUI; import com.fr.van.chart.line.LineIndependentVanChartInterface; -import com.fr.van.chart.map.MapIndependentVanChartInterface; +import com.fr.van.chart.map.VanMapChartTypeUI; import com.fr.van.chart.multilayer.MultiPieIndependentVanChartInterface; import com.fr.van.chart.pie.PieIndependentVanChartInterface; import com.fr.van.chart.radar.RadarIndependentVanChartInterface; import com.fr.van.chart.scatter.ScatterIndependentVanChartInterface; -import com.fr.van.chart.structure.desinger.StructureIndependentVanChartInterface; +import com.fr.van.chart.structure.desinger.VanStructureChartTypeUI; import com.fr.van.chart.treemap.TreeMapIndependentVanChartInterface; import com.fr.van.chart.wordcloud.designer.WordCloudIndependentVanChartInterface; @@ -182,7 +182,7 @@ 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 ColumnIndependentVanChartInterface()); + 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()); @@ -192,14 +192,14 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr 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 MapIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartDrillMapPlot.VAN_CHART_DRILL_MAP_ID, new DrillMapIndependentVanChartInterface()); + 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 HeatMapIndependentVanChartInterface()); + 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 StructureIndependentVanChartInterface()); + addChartTypeInterface(VAN_CHART_PRIORITY, VanChartStructurePlot.STRUCTURE_PLOT_ID, new VanStructureChartTypeUI()); } 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 a7dd9f5641..623271873e 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 @@ -1,5 +1,14 @@ 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.gui.chart.MiddleChartDialog; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.third.joda.time.DateTime; + +import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Dialog; import java.awt.FlowLayout; @@ -7,16 +16,6 @@ import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import javax.swing.JPanel; - -import com.fr.base.chart.BaseChartCollection; -import com.fr.chart.chartattr.ChartCollection; -import com.fr.design.gui.chart.MiddleChartDialog; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.dialog.BasicDialog; - -import com.fr.design.utils.gui.GUICoreUtils; - /** * 封装一层 图表新建的对话框, 配合属性表确定: 先单独只要一种图表类型的对话框. * @author kunsnat E-mail:kunsnat@gmail.com @@ -40,6 +39,8 @@ public class ChartDialog extends MiddleChartDialog { } private void initComponent() { + final String createTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); + this.setModal(true); this.setLayout(new BorderLayout()); final ChartTypePane chartTypePane = new ChartTypePane(); @@ -63,7 +64,7 @@ public class ChartDialog extends MiddleChartDialog { ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - chartTypePane.update((ChartCollection)cc); + chartTypePane.update((ChartCollection)cc, createTime); doOK(); } }); diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartIcon.java b/designer-chart/src/main/java/com/fr/design/chart/ChartIcon.java index 7485d57973..854505d630 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartIcon.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartIcon.java @@ -44,6 +44,7 @@ public class ChartIcon implements Icon, XMLable { * @param x 缩略图的起始坐标x * @param y 缩略图的起始坐标y */ + @Override public void paintIcon(Component c, Graphics g, int x, int y) { Graphics2D g2d = (Graphics2D) g; @@ -66,6 +67,7 @@ public class ChartIcon implements Icon, XMLable { * * @return int 缩略图宽度 */ + @Override public int getIconWidth() { return WIDTH; } @@ -75,6 +77,7 @@ public class ChartIcon implements Icon, XMLable { * * @return int 缩略图高度 */ + @Override public int getIconHeight() { return HEIGHT; } @@ -94,18 +97,21 @@ public class ChartIcon implements Icon, XMLable { } + @Override public void readXML(XMLableReader reader) { - + //do nothing } + @Override public void writeXML(XMLPrintWriter writer) { - + //do nothing } /** * @return 克隆后的对象 * @throws CloneNotSupportedException 如果克隆失败则抛出此异常 */ + @Override public Object clone() throws CloneNotSupportedException { ChartIcon cloned = (ChartIcon) super.clone(); cloned.imagePath = this.imagePath; diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java index 19c6137858..2bb9a99f22 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java @@ -9,6 +9,7 @@ import com.fr.chartx.attr.ChartProvider; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; @@ -119,6 +120,10 @@ public class ChartTypePane extends ChartCommonWizardPane { } public void update(ChartCollection cc) { + update(cc, null); + } + + public void update(ChartCollection cc, String createTime) { if (cc == null) { return; } @@ -130,6 +135,8 @@ public class ChartTypePane extends ChartCommonWizardPane { try { chart4Update = (ChartProvider) chart.clone(); cc.addChart(chart4Update); + //记录埋点 + ChartInfoCollector.getInstance().collection(chart4Update, createTime); } catch (CloneNotSupportedException ex) { FineLoggerFactory.getLogger().error(ex.getMessage(), ex); } 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 2385cabd60..ca1f4f1400 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 @@ -55,12 +55,12 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene this(); populate(cc); } - + public ChartComponent(BaseChartCollection cc) { this(); populate(cc); } - + public ChartComponent(ChartCollection cc, PropertyChangeListener l) { this(); populate(cc); @@ -72,6 +72,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene * 右键编辑 图表编辑层的监听事件, 在停止编辑时 响应整个编辑模板(form, sheet)的改变. * @param l 监听事件 */ + @Override public void addStopEditingListener(PropertyChangeListener l) { if (!listeners.contains(l)) { listeners.add(l); @@ -87,6 +88,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene /** * 停止编辑, 通知事情, 刷新画出新界面. */ + @Override public void reset() { fireStopEditing(); @@ -97,6 +99,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene repaint(); } + @Override public void populate(BaseChartCollection cc) { // kunsnat_bug: 5471 实现设置的即时预览 try {// clone 为了判断编辑前后的值. this.chartCollection4Design = (ChartCollection)cc; @@ -107,6 +110,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene reset(); } + @Override public BaseChartCollection update() { return this.chartCollection4Design; } @@ -180,53 +184,63 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene * @param event 鼠标事件 * 不设置鼠标点击跳转事件 */ + @Override public void mouseClicked(MouseEvent event) { + //do nothing } /** * 鼠标按压 * @param e 鼠标事件 */ + @Override public void mousePressed(MouseEvent e) { - - + //do nothing } /** * 鼠标松开 * @param e 鼠标事件 */ - public void mouseReleased(MouseEvent e) { + @Override + public void mouseReleased(MouseEvent e) { + //do nothing } /** * 鼠标进入 * @param e 鼠标事件 */ + @Override public void mouseEntered(MouseEvent e) { - + //do nothing } /** * 鼠标退出 * @param e 鼠标事件 */ + @Override public void mouseExited(MouseEvent e) { - + //do nothing } /** * 鼠标拖拽 * @param e 鼠标事件 */ - public void mouseDragged(MouseEvent e) { + @Override + public void mouseDragged(MouseEvent e) { + //do nothing } /** * 鼠标移动 * @param e 鼠标事件 */ + @Override public void mouseMoved(MouseEvent e) { + //do nothing } private boolean needRefreshChartGlyph() { @@ -243,7 +257,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene if (resolution == 0){ resolution = ScreenResolution.getScreenResolution(); } - painter.paint(g2d, chartWidth, chartHeight, resolution, null); + painter.paint(g2d, chartWidth, chartHeight, resolution, null, this); } } diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java b/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java index 2148257a41..d6134e0cee 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java @@ -13,6 +13,7 @@ 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.event.ChangeEvent; import com.fr.design.event.ChangeListener; import com.fr.design.event.UIObserver; @@ -327,15 +328,15 @@ public class MapGroupExtensionPane extends BasicPane implements UIObserver { } private void showRenameWaring(String newName){ - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), "\"" + newName + "\"" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Has_Been_Existed") - + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alert"), JOptionPane.WARNING_MESSAGE); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), "\"" + newName + "\"" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Has_Been_Existed") + + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); } private JMenuItem createRenameItem() { JMenuItem renameItem = new JMenuItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Rename")); renameItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - String newName = JOptionPane.showInputDialog(DesignerContext.getDesignerFrame().getContentPane(), + String newName = FineJOptionPane.showInputDialog(DesignerContext.getDesignerFrame().getContentPane(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Rename"), groupExtensionPane.getSelectedObject()); if (StringUtils.isNotBlank(newName)) { String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); diff --git a/designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java index b8690f8df6..c7893ae240 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/AbstractChartDataPane.java @@ -5,7 +5,10 @@ import com.fr.chartx.data.ChartDataDefinitionProvider; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.plugin.chart.vanchart.VanChart; +import com.fr.stable.AssistUtils; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; import java.awt.BorderLayout; /** @@ -13,6 +16,12 @@ import java.awt.BorderLayout; */ public abstract class AbstractChartDataPane extends ChartDataPane { + private VanChart vanChart; + + protected VanChart getVanChart() { + return vanChart; + } + public AbstractChartDataPane(AttributeChangeListener listener) { super(listener); } @@ -26,15 +35,15 @@ public abstract class AbstractChartDataPane paneList; + private UITabGroup tabPane; + + private String[] nameArray; + + @Override + protected void initContentPane() { + if (customPlot == null) { + return; + } + cardLayout = new CardLayout(); + initPaneList(); + relayoutWhenListChange(); + } + + private void initPaneList() { + + paneList = new ArrayList<>(); + + List customPlotList = customPlot.getCustomPlotList(); + + for (int i = 0; i < customPlotList.size(); i++) { + //根据不同的plot创建不同的数据配置界面 + final VanChartPlot vanChartPlot = customPlotList.get(i); + paneList.add(new AbstractVanSingleDataPane(listener) { + @Override + protected SingleDataPane createSingleDataPane() { + return createSingleDataPaneByPlot(vanChartPlot); + } + }); + } + } + + private SingleDataPane createSingleDataPaneByPlot(VanChartPlot plot) { + CustomPlotType customType = CustomPlotFactory.getCustomType(plot); + switch (customType) { + case RING: + case SLOT: + case CUVETTE: + return new SingleDataPane(new GaugeDataSetFieldsPane(), new GaugeCellDataFieldsPane()); + case SCATTER: + case BUBBLE: + return new SingleDataPane(new ScatterDataSetFieldsPane(), new ScatterCellDataFieldsPane()); + case PIE: + case SAME_PIE: + case DIFFERENT_PIE: + case POINTER_180: + case POINTER_360: + return new SingleDataPane(new SingleCategoryDataSetFieldsPane() { + @Override + public void checkBoxUse(boolean hasUse) { + super.checkBoxUse(hasUse); + UIComboBox[] comboBoxes = super.filedComboBoxes(); + for (UIComboBox comboBox : comboBoxes) { + comboBox.setEnabled(false); + } + } + }, new SingleCategoryCellDataFieldsPane() { + @Override + protected TinyFormulaPane[] formulaPanes() { + TinyFormulaPane[] tinyFormulaPanes = super.formulaPanes(); + for (TinyFormulaPane tinyFormulaPane : tinyFormulaPanes) { + GUICoreUtils.setEnabled(tinyFormulaPane, false); + } + return tinyFormulaPanes; + } + }); + default: + if (StringUtils.equals(CustomStyle.CUSTOM.toString(), plot.getCustomType())){ + return new SingleDataPane(new SingleCategoryDataSetFieldsPane(), new SingleCategoryCellDataFieldsPane()); + } else { + return new SingleDataPane(new MultiCategoryDataSetFieldsPane(), new MultiCategoryCellDataFieldsPane()); + } + } + } + + private void relayoutWhenListChange() { + centerPane = new JPanel(cardLayout) { + @Override + public Dimension getPreferredSize() { + return paneList.get(tabPane.getSelectedIndex()).getPreferredSize(); + } + }; + + //获取tab的标题 + initTabTitle(); + + tabPane = new VanChartCustomPlotUITabGroup(nameArray) { + @Override + public void tabChanged(int index) { + dealWithTabChanged(index); + } + }; + tabPane.setSelectedIndex(0); + tabPane.tabChanged(0); + initLayout(); + } + + private void initTabTitle() { + + if (customPlot == null) { + return; + } + + List customPlotList = customPlot.getCustomPlotList(); + nameArray = new String[Math.min(customPlotList.size(), paneList.size())]; + for (int i = 0; i < nameArray.length; i++) { + JPanel pane = paneList.get(i); + VanChartPlot vanChartPlot = customPlotList.get(i); + CustomPlotType plotType = CustomPlotFactory.getCustomType(vanChartPlot); + + nameArray[i] = CustomPlotFactory.getTitle(plotType); + centerPane.add(pane, nameArray[i]); + } + } + + protected void dealWithTabChanged(int index) { + cardLayout.show(centerPane, nameArray[index]); + } + + private void initLayout() { + JPanel tabPanel = new JPanel(new BorderLayout()); + tabPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, getBackground())); + tabPanel.add(tabPane, BorderLayout.CENTER); + this.setLayout(new BorderLayout(HGAP, VGAP)); + this.add(tabPanel, BorderLayout.NORTH); + this.add(centerPane, BorderLayout.CENTER); + } + + @Override + public void populate(ChartCollection collection) { + if (collection == null) { + return; + } + VanChart chart = collection.getSelectedChart(VanChart.class); + if (chart == null) { + return; + } + customPlot = chart.getPlot(); + + this.removeAll(); + initContentPane(); + + CustomChartDataDefinition dataSetCollection = (CustomChartDataDefinition) chart.getChartDataDefinition(); + + if (dataSetCollection != null) { + Map customDefinitions = dataSetCollection.getCustomDefinitions(); + for (int i = 0; i < paneList.size(); i++) { + VanChartPlot vanChartPlot = customPlot.getCustomPlotList().get(i); + AbstractDataDefinition dataDefinition = customDefinitions.get(CustomPlotFactory.getCustomType(vanChartPlot)); + if (dataDefinition != null) { + paneList.get(i).populate(dataDefinition); + } + } + } + + this.initAllListeners(); + this.validate(); + } + + + @Override + public void update(ChartCollection collection) { + if (collection == null) { + return; + } + VanChart chart = collection.getSelectedChart(VanChart.class); + if (chart == null) { + return; + } + Map definitions = new HashMap<>(); + for (int i = 0; i < paneList.size(); i++) { + definitions.put(CustomPlotFactory.getCustomType(customPlot.getCustomPlotList().get(i)), paneList.get(i).update()); + } + CustomChartDataDefinition customDefinition = new CustomChartDataDefinition(); + customDefinition.setCustomDefinitions(definitions); + chart.setChartDataDefinition(customDefinition); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/GanttChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/GanttChartDataPane.java deleted file mode 100644 index d172d7ba5d..0000000000 --- a/designer-chart/src/main/java/com/fr/design/chartx/GanttChartDataPane.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.fr.design.chartx; - -import com.fr.chartx.data.GanttChartDataDefinition; -import com.fr.design.chartx.fields.diff.MultiCategoryCellDataFieldsPane; -import com.fr.design.chartx.fields.diff.MultiCategoryDataSetFieldsPane; -import com.fr.design.chartx.single.SingleDataPane; -import com.fr.design.gui.frpane.AttributeChangeListener; -import com.fr.van.chart.map.designer.VanChartGroupPane; - -import javax.swing.JPanel; - -/** - * Created by shine on 2019/5/22. - */ -public class GanttChartDataPane extends AbstractChartDataPane { - - private AbstractVanSingleDataPane dataPane; - private AbstractVanSingleDataPane linkPane; - - @Override - protected JPanel createContentPane() { - dataPane = new AbstractVanSingleDataPane(listener) { - @Override - protected SingleDataPane createSingleDataPane() { - return new SingleDataPane(new MultiCategoryDataSetFieldsPane(), new MultiCategoryCellDataFieldsPane()); - } - }; - linkPane = new AbstractVanSingleDataPane(listener) { - @Override - protected SingleDataPane createSingleDataPane() { - return new SingleDataPane(new MultiCategoryDataSetFieldsPane(), new MultiCategoryCellDataFieldsPane()); - } - }; - return new VanChartGroupPane(new String[]{"data", "link"}, new JPanel[]{dataPane, linkPane}) { - }; - } - - public GanttChartDataPane(AttributeChangeListener listener) { - super(listener); - } - - @Override - public void populate(GanttChartDataDefinition ganttChartDataDefinition) { - dataPane.populate(ganttChartDataDefinition.getDataDefinition()); - linkPane.populate(ganttChartDataDefinition.getLinkDefinition()); - } - - @Override - public GanttChartDataDefinition update() { - return null; - } -} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java index 443fea07a7..e93900ea6f 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java @@ -22,11 +22,13 @@ import com.fr.stable.StringUtils; import javax.swing.JPanel; import javax.swing.SwingConstants; +import java.util.ArrayList; +import java.util.List; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; -import java.util.ArrayList; -import java.util.List; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; /** * Created by shine on 2018/9/12. @@ -148,9 +150,18 @@ public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane< private void initComponents() { series = new UIComboBox(); + value = valueComboBoxHasNone() ? new UIComboBoxWithNone() : new UIComboBox(); + value.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + function.setEnabled(value.getSelectedItem() != null); + } + }); + function = new CalculateComboBox(); + function.setEnabled(false); Component[][] components = new Component[][]{ new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Series_Name"), SwingConstants.LEFT), series}, @@ -171,7 +182,6 @@ public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane< public void checkBoxUse(boolean hasUse) { series.setEnabled(hasUse); value.setEnabled(hasUse); - function.setEnabled(hasUse); } public void clearAllBoxList() { diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java index 2a8154d7bb..d22d957415 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java @@ -10,13 +10,13 @@ import com.fr.general.IOUtils; import javax.swing.BoxLayout; import javax.swing.JComponent; import javax.swing.JPanel; +import java.util.ArrayList; +import java.util.List; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.List; /** @@ -24,7 +24,6 @@ import java.util.List; * 一列组件 可增可删,通过JComponent后面的加减button增删。 */ public abstract class AbstractMultiComponentPane extends JPanel { - private static final int COM_W = 96; private static final int H = 20; private static final int ICON_W = 20; @@ -35,6 +34,7 @@ public abstract class AbstractMultiComponentPane extends J private List categoryComponentList = new ArrayList(); + private boolean categoryAxis = true; protected abstract T createFirstFieldComponent(); @@ -44,13 +44,23 @@ public abstract class AbstractMultiComponentPane extends J protected abstract void updateField(T component, ColumnField field); + public void setCategoryAxis(boolean categoryAxis) { + this.categoryAxis = categoryAxis; + if(!categoryAxis){ + addButton.setEnabled(false); + for (JComponent component : categoryComponentList) { + component.setEnabled(false); + } + } + } + public AbstractMultiComponentPane() { UILabel label = new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Category")); label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); firstFieldComponent = createFirstFieldComponent(); - firstFieldComponent.setPreferredSize(new Dimension(COM_W, H)); + firstFieldComponent.setPreferredSize(new Dimension(componentWidth(), H)); addButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); addButton.setPreferredSize(new Dimension(ICON_W, H)); @@ -64,7 +74,7 @@ public abstract class AbstractMultiComponentPane extends J }); final JPanel panel = new JPanel(); - panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2)); + panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 2)); panel.add(label); panel.add(firstFieldComponent); @@ -78,6 +88,10 @@ public abstract class AbstractMultiComponentPane extends J this.add(boxPane, BorderLayout.CENTER); } + protected int componentWidth() { + return 96; + } + private JPanel addComboBoxAndButtonToBox(T uiComboBox, UIButton uiButton) { final JPanel panel = new JPanel(); panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2)); @@ -93,7 +107,7 @@ public abstract class AbstractMultiComponentPane extends J private void addNewComboBox() { final T comboBox = createOtherFieldComponent(); - comboBox.setPreferredSize(new Dimension(COM_W, H)); + comboBox.setPreferredSize(new Dimension(componentWidth(), H)); UIButton delButton = new UIButton(IOUtils.readIcon("com/fr/design/images/toolbarbtn/close.png")); delButton.setPreferredSize(new Dimension(ICON_W, H)); @@ -123,7 +137,7 @@ public abstract class AbstractMultiComponentPane extends J } private boolean canAdd() { - return categoryComponentList.size() < 3; + return categoryComponentList.size() < 2 && categoryAxis; } public List componentList() { @@ -165,4 +179,16 @@ public abstract class AbstractMultiComponentPane extends J updateField(comboBox, temp); } } -} + + public void checkEnable(boolean hasUse) { + //增加按钮是否灰化要根据是否选择了数据源,是否分类轴,分类数量是否超标三个判断 + boolean buttonUse = hasUse && categoryAxis && categoryComponentList.size() < 2; + //额外的分类是否灰化根据是否选择了数据源,是否分类轴判断 + boolean categoryUse = hasUse && categoryAxis; + + addButton.setEnabled(buttonUse); + for (JComponent component : categoryComponentList) { + component.setEnabled(categoryUse); + } + } +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPaneWithUISpinner.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPaneWithUISpinner.java index 5f0e6500b0..f784c4a861 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPaneWithUISpinner.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPaneWithUISpinner.java @@ -11,10 +11,10 @@ import com.fr.stable.AssistUtils; import javax.swing.JComponent; import javax.swing.JPanel; -import java.awt.BorderLayout; -import java.awt.Component; import java.util.ArrayList; import java.util.List; +import java.awt.BorderLayout; +import java.awt.Component; /** * Created by shine on 2019/6/18. @@ -148,4 +148,8 @@ public abstract class AbstractMultiComponentPaneWithUISpinner { +public abstract class AbstractSingleFilterPane extends AbstractChartTabPane implements UIObserver { private static final int FIL_HEIGHT = 150; @@ -34,14 +36,12 @@ public abstract class AbstractSingleFilterPane extends AbstractChartTabPane categoryList = fieldCollection.getCategoryList(); + if (!categoryList.isEmpty()) { + populateCategory(categoryList.get(0).getFilterProperties()); + } + } + + public void updateMultiCategoryFieldCollection(MultiCategoryColumnFieldCollection fieldCollection) { + + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = fieldCollection.getSeriesValueCorrelationDefinition(); + if (seriesValueCorrelationDefinition != null) { + seriesValueCorrelationDefinition.setFilterProperties(updateSeries()); + } + + List categoryList = fieldCollection.getCategoryList(); + if (!categoryList.isEmpty()) { + categoryList.get(0).setFilterProperties(updateCategory()); + } + } + + private void populateSeries(DataFilterProperties series) { + seriesFilterPane.populateBean(series); + + } + + private void populateCategory(DataFilterProperties category) { + categoryFilterPane.populateBean(category); + + } + + private DataFilterProperties updateSeries() { + return seriesFilterPane.updateBean(); + + } + + private DataFilterProperties updateCategory() { + return categoryFilterPane.updateBean(); + } + + +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesXYValueCorrelationPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesXYValueCorrelationPane.java new file mode 100644 index 0000000000..d14d59473c --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesXYValueCorrelationPane.java @@ -0,0 +1,66 @@ +package com.fr.design.chartx.component; + +import com.fr.base.Utils; +import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.diff.BubbleColumnField; +import com.fr.chartx.data.field.diff.BubbleColumnFieldCollection; +import com.fr.design.chartx.component.correlation.AbstractCorrelationPane; +import com.fr.design.chartx.component.correlation.FieldEditorComponentWrapper; +import com.fr.design.chartx.component.correlation.TinyFormulaPaneEditorComponent; +import com.fr.design.i18n.Toolkit; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Wim on 2019/11/04. + */ +public class CellDataSeriesXYValueCorrelationPane extends AbstractCorrelationPane { + + @Override + protected FieldEditorComponentWrapper[] createFieldEditorComponentWrappers() { + return new FieldEditorComponentWrapper[]{ + new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Name")), + new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_X_Axis")), + new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Y_Axis")), + new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Value")) + }; + } + + @Override + protected List covertTBeanToTableModelList(BubbleColumnFieldCollection bubbleColumnFieldCollection) { + List result = new ArrayList<>(); + + List bubbleColumnFieldList = bubbleColumnFieldCollection.getList(); + for (BubbleColumnField field : bubbleColumnFieldList) { + Object[] array = new Object[]{ + field.getSeriesName().getFieldName(), + field.getXField().getFieldName(), + field.getYField().getFieldName(), + field.getSizeField().getFieldName() + }; + result.add(array); + } + + return result; + } + + @Override + protected void setTableModelListToTBean(List tableValues, BubbleColumnFieldCollection bubbleColumnFieldCollection) { + List bubbleColumnFieldList = new ArrayList<>(); + for (Object[] oneLine : tableValues) { + BubbleColumnField bubbleColumnField = new BubbleColumnField(); + ColumnField series = new ColumnField(Utils.objectToString(oneLine[0])); + ColumnField xField = new ColumnField(Utils.objectToString(oneLine[1])); + ColumnField yField = new ColumnField(Utils.objectToString(oneLine[2])); + ColumnField value = new ColumnField(Utils.objectToString(oneLine[3])); + bubbleColumnField.setSeriesName(series); + bubbleColumnField.setXField(xField); + bubbleColumnField.setYField(yField); + bubbleColumnField.setSizeField(value); + bubbleColumnFieldList.add(bubbleColumnField); + } + + bubbleColumnFieldCollection.setList(bubbleColumnFieldList); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java new file mode 100644 index 0000000000..41202061cd --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java @@ -0,0 +1,285 @@ +package com.fr.design.chartx.component; + +import com.fr.base.BaseUtils; +import com.fr.chartx.TwoTuple; +import com.fr.data.TableDataSource; +import com.fr.data.TableDataSourceTailor; +import com.fr.data.impl.EmbeddedTableData; +import com.fr.data.impl.NameTableData; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.data.DesignTableDataManager; +import com.fr.design.data.datapane.TableDataComboBox; +import com.fr.design.data.tabledata.wrapper.TableDataWrapper; +import com.fr.design.file.HistoryTemplateListCache; +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.mainframe.chart.gui.data.table.DataPaneHelper; +import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralUtils; +import com.fr.general.data.DataModel; +import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.map.data.MapMatchResult; +import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; +import com.fr.script.Calculator; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.table.DefaultTableModel; +import javax.swing.tree.DefaultMutableTreeNode; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-11-04 + */ +public class MapAreaMatchPane extends BasicBeanPane { + + private TableDataComboBox tableNameCombox; + private UIComboBox areaNameBox; + private UILabel refreshLabel; + + private MatchAreaTable matchAreaTable; + + private MatchResultTable matchResultTable; + + private static final Object[] HEADER = new Object[]{Toolkit.i18nText("Fine-Design_Chart_Area_Name"), Toolkit.i18nText("Fine-Design_Chart_Match_To")}; + + private static final Object[] HEADER_WITH_EMPTY = new Object[]{Toolkit.i18nText("Fine-Design_Chart_Area_Name"), Toolkit.i18nText("Fine-Design_Chart_Match_To"), ""}; + + public MapAreaMatchPane(TwoTuple> treeNodeAndItems) { + initButtonGroup(); + initRefreshLabel(); + areaNameBox = new UIComboBox(); + this.setLayout(new BorderLayout(5, 5)); + this.add(createContentPane(), BorderLayout.NORTH); + initTable(treeNodeAndItems); + + JPanel tablePane = new JPanel(); + tablePane.setLayout(new BorderLayout(5, 10)); + tablePane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); + JScrollPane matchAreaScroll = new JScrollPane(matchAreaTable) { + @Override + public Dimension getPreferredSize() { + return new Dimension(400, 290); + } + }; + tablePane.add(matchAreaScroll, BorderLayout.CENTER); + JScrollPane matchResultScroll = new JScrollPane(matchResultTable) { + @Override + public Dimension getPreferredSize() { + return new Dimension(400, 200); + } + }; + matchResultScroll.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Chart_Custom_Match_List"))); + tablePane.add(matchResultScroll, BorderLayout.SOUTH); + + this.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); + this.add(tablePane, BorderLayout.CENTER); + } + + private JPanel createContentPane() { + JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + + JPanel tableDataPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + panel.add(tableDataPane); + tableDataPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":")); + tableNameCombox.setPreferredSize(new Dimension(96, 20)); + tableDataPane.add(tableNameCombox); + + JPanel areaNamePane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + panel.add(areaNamePane); + areaNamePane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Area_Name") + ":")); + areaNamePane.add(areaNameBox); + areaNameBox.setPreferredSize(new Dimension(96, 20)); + panel.add(refreshLabel); + return panel; + } + + private void initTable(TwoTuple> treeNodeAndItems) { + matchAreaTable = new MatchAreaTable(new Object[0][2], HEADER); + matchAreaTable.setRoot(treeNodeAndItems.getFirst()); + matchAreaTable.setItems(treeNodeAndItems.getSecond()); + + matchResultTable = new MatchResultTable(new Object[0][3], HEADER_WITH_EMPTY); + + DefaultTableModel model = new DefaultTableModel(new Object[0][3], HEADER_WITH_EMPTY); + matchResultTable.setModel(model); + + matchAreaTable.setMatchResultTable(matchResultTable); + matchResultTable.setMatchAreaTable(matchAreaTable); + } + + private void initButtonGroup() { + tableNameCombox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource()); + tableNameCombox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + refreshBox(); + } + } + }); + } + + private void initRefreshLabel() { + Icon refreshImage = BaseUtils.readIcon("/com/fr/design/images/control/refresh.png"); + refreshLabel = new UILabel(refreshImage); + refreshLabel.addMouseListener(new MouseAdapter() { + boolean mouseEntered = false; + boolean buttonPressed = false; + + public void mouseEntered(MouseEvent e) { // 当鼠标进入时候调用. + mouseEntered = true; + if (!buttonPressed) { + refreshLabel.setBackground(java.awt.Color.WHITE); + refreshLabel.setOpaque(true); + refreshLabel.setBorder(BorderFactory.createLineBorder(java.awt.Color.GRAY)); + } + } + + public void mouseExited(MouseEvent e) { + mouseEntered = false; + refreshLabel.setOpaque(false); + refreshLabel.setBorder(BorderFactory.createEmptyBorder()); + } + + public void mousePressed(MouseEvent e) { + buttonPressed = true; + refreshLabel.setBackground(java.awt.Color.lightGray); + } + + public void mouseReleased(MouseEvent e) { + buttonPressed = false; + if (mouseEntered) { + refreshLabel.setBackground(java.awt.Color.WHITE); + populateData(tableNameCombox.getSelectedItem().getTableDataName(), GeneralUtils.objectToString(areaNameBox.getSelectedItem())); + } + } + }); + } + + public void updateBean(MapMatchResult matchResult) { + if (matchResult == null) { + return; + } + + matchResultTable.updateBean(matchResult); + } + + public void populateBean(MapMatchResult matchResult) { + + } + + public void populateBean(MapMatchResult matchResult, String tableName, String areaName) { + //先取保存的数据集名称和区域名,若不存在,就取数据集面板配置的数据集名称和区域名 + matchResultTable.populateBean(matchResult); + tableNameCombox.setSelectedTableDataByName(tableName); + if (StringUtils.isEmpty(areaName)) { + return; + } + areaNameBox.setSelectedItem(areaName); + populateData(tableName, areaName); + } + + private void populateData(String tableName, String columnName) { + Object[] columnData = getColumnData(tableName, columnName); + if (columnData == null) { + return; + } + populateMatchData(columnData); + } + + private Object[] getColumnData(String tableName, String columnName) { + NameTableData nameTableData = new NameTableData(tableName); + TableDataSource dataSource = TableDataSourceTailor.extractTableData(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget()); + Calculator calculator = Calculator.createCalculator(); + calculator.setAttribute(TableDataSource.KEY, dataSource); + nameTableData.createTableData(calculator); + try { + EmbeddedTableData tableData = DesignTableDataManager.previewTableDataNeedInputParameters(dataSource, nameTableData, Integer.MAX_VALUE, false); + int colIndex = getColIndex(tableData, columnName); + if (colIndex == DataModel.COLUMN_NAME_NOT_FOUND) { + return null; + } + int size = tableData.getRowCount(); + HashSet columnData = new LinkedHashSet<>(); + for (int i = 0; i < size; i++) { + Object valueAt = tableData.getValueAt(i, colIndex); + columnData.add(GeneralUtils.objectToString(valueAt)); + } + return columnData.toArray(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + return null; + } + } + + private int getColIndex(EmbeddedTableData tableData, String columnName) { + int colIndex = 0; + + for (int count = tableData.getColumnCount(); colIndex < count; ++colIndex) { + if (ComparatorUtils.tableDataColumnNameEquals(tableData.getColumnName(colIndex), columnName)) { + return colIndex; + } + } + return DataModel.COLUMN_NAME_NOT_FOUND; + } + + private void populateMatchData(Object[] columnData) { + Set geoAreas = matchAreaTable.getItems(); + + Map resultMap = ChartGEOJSONHelper.matchAreaList(columnData, geoAreas, matchResultTable.getCustomResult()); + + Object[][] data = new Object[resultMap.size()][2]; + + //构造table的数据结构 + Map areaNameIndex = new HashMap<>(); + int i = 0; + for (Map.Entry entry : resultMap.entrySet()) { + areaNameIndex.put(entry.getKey(), i); + data[i++] = new Object[]{entry.getKey(), entry.getValue()}; + } + + matchAreaTable.setAreaNameIndex(areaNameIndex); + matchAreaTable.setModel(new DefaultTableModel(data, HEADER)); + } + + private void refreshBox() { + TableDataWrapper dataWrap = tableNameCombox.getSelectedItem(); + + if (dataWrap == null) { + return; + } + + List columnNameList = dataWrap.calculateColumnNameList(); + + DataPaneHelper.refreshBoxItems(areaNameBox, columnNameList); + areaNameBox.setSelectedItem(null); + } + + public MapMatchResult updateBean() { + return null; + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Location_With_Area_Name"); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MatchAreaTable.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MatchAreaTable.java new file mode 100644 index 0000000000..9c16b4663d --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MatchAreaTable.java @@ -0,0 +1,150 @@ +package com.fr.design.chartx.component; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.general.GeneralUtils; +import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; + +import javax.swing.AbstractCellEditor; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumnModel; +import javax.swing.table.TableModel; +import javax.swing.tree.DefaultMutableTreeNode; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-11-19 + */ +public class MatchAreaTable extends JTable { + + private Set items; + + private MatchResultTable matchResultTable; + + private Map areaNameIndex = new HashMap<>(); + + private DefaultMutableTreeNode root; + + public MatchAreaTable(Object[][] data, Object[] header) { + super(data, header); + this.getTableHeader().setReorderingAllowed(false); + } + + public void setItems(Set items) { + this.items = items; + } + + public Set getItems() { + return items; + } + + public void setRoot(DefaultMutableTreeNode root) { + this.root = root; + } + + public void setMatchResultTable(MatchResultTable matchResultTable) { + this.matchResultTable = matchResultTable; + } + + public void setAreaNameIndex(Map areaNameIndex) { + this.areaNameIndex = areaNameIndex; + } + + public void setModel(TableModel dataModel) { + super.setModel(dataModel); + + if (items == null) { + items = new HashSet<>(); + } + TableColumnModel columnModel = getColumnModel(); + columnModel.getColumn(0).setCellEditor(new UILabelEditor()); + columnModel.getColumn(1).setCellEditor(new UIComboBoxRenderAndEditor()); + columnModel.getColumn(1).setCellRenderer(new UIComboBoxRenderAndEditor()); + } + + public void reMatch(Object areaName) { + if (!areaNameIndex.containsKey(areaName)) { + return; + } + int index = areaNameIndex.get(areaName); + String result = ChartGEOJSONHelper.matchArea(GeneralUtils.objectToString(areaName), items); + getColumnModel().getColumn(1).getCellEditor().stopCellEditing(); + this.setValueAt(result, index, 1); + } + + public class UIComboBoxRenderAndEditor extends AbstractCellEditor implements TableCellRenderer, TableCellEditor { + + TableTreeComboBox comboBox; + + public UIComboBoxRenderAndEditor() { + } + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + initComboBox(value, false); + return comboBox; + } + + public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, final int row, int column) { + initComboBox(value, true); + comboBox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + UIComboBoxRenderAndEditor.this.stopCellEditing(); + Object areaName = MatchAreaTable.this.getValueAt(row, 0); + Object result = MatchAreaTable.this.getValueAt(row, 1); + if (items.contains(result)) { + matchResultTable.dealMatch(areaName, result); + } + } + }); + return comboBox; + } + + private void initComboBox(Object value, boolean editor) { + //地图不显示第一层,钻取地图显示第一层。 + boolean showRoot = root.getUserObject() != null; + comboBox = new TableTreeComboBox(new JTree(root), showRoot); + comboBox.setEditable(true); + + comboBox.setSelectedItem(value); + if (!editor && value == null) { + JTextField textField = (JTextField) (comboBox.getEditor().getEditorComponent()); + textField.setForeground(Color.RED); + textField.setText(Toolkit.i18nText("Fine-Design_Chart_Prompt_Not_Selected")); + } + } + + public Object getCellEditorValue() { + comboBox.resetText(); + return comboBox.getSelectedItem(); + } + } + + public static class UILabelEditor extends AbstractCellEditor implements TableCellEditor { + + UILabel uiLabel; + + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, + int row, int column) { + uiLabel = new UILabel(GeneralUtils.objectToString(value)); + return uiLabel; + } + + public Object getCellEditorValue() { + return uiLabel.getText(); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MatchResultTable.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MatchResultTable.java new file mode 100644 index 0000000000..8a85c84a47 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MatchResultTable.java @@ -0,0 +1,146 @@ +package com.fr.design.chartx.component; + +import com.fr.base.BaseUtils; +import com.fr.base.Utils; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.i18n.Toolkit; +import com.fr.general.ComparatorUtils; +import com.fr.plugin.chart.map.data.MapMatchResult; +import com.fr.stable.StringUtils; + +import javax.swing.AbstractCellEditor; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumnModel; +import javax.swing.table.TableModel; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Vector; +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-11-20 + */ +public class MatchResultTable extends JTable { + + private MatchAreaTable matchAreaTable; + + public MatchResultTable(Object[][] data, Object[] header) { + super(data, header); + this.getTableHeader().setReorderingAllowed(false); + } + + public void setMatchAreaTable(MatchAreaTable matchAreaTable) { + this.matchAreaTable = matchAreaTable; + } + + public void setModel(TableModel dataModel) { + super.setModel(dataModel); + + TableColumnModel columnModel = getColumnModel(); + columnModel.getColumn(0).setCellEditor(new MatchAreaTable.UILabelEditor()); + columnModel.getColumn(1).setCellEditor(new MatchAreaTable.UILabelEditor()); + columnModel.getColumn(2).setCellEditor(new UIButtonEditorAndRender()); + columnModel.getColumn(2).setCellRenderer(new UIButtonEditorAndRender()); + columnModel.getColumn(2).setMaxWidth(20); + } + + public void dealMatch(Object areaName, Object result) { + int rowCount = this.getRowCount(); + for (int i = 0; i < rowCount; i++) { + if (ComparatorUtils.equals(this.getValueAt(i, 0), areaName)) { + getColumnModel().getColumn(1).getCellEditor().stopCellEditing(); + this.setValueAt(result, i, 1); + return; + } + } + DefaultTableModel model = (DefaultTableModel) this.getModel(); + Vector vector = new Vector(); + vector.add(areaName); + vector.add(result); + vector.add(""); + model.addRow(vector); + } + + public void populateBean(MapMatchResult matchResult) { + if (matchResult == null) { + return; + } + Map customResult = matchResult.getCustomResult(); + if (customResult == null) { + return; + } + DefaultTableModel model = (DefaultTableModel) this.getModel(); + for (Map.Entry entry : customResult.entrySet()) { + Vector vector = new Vector(); + vector.add(entry.getKey()); + vector.add(entry.getValue()); + vector.add(""); + model.addRow(vector); + } + } + + public void updateBean(MapMatchResult matchResult) { + matchResult.setCustomResult(getCustomResult()); + } + + public Map getCustomResult() { + Map customResult = new LinkedHashMap<>(); + DefaultTableModel model = (DefaultTableModel) this.getModel(); + for (int i = 0, rowCount = model.getRowCount(); i < rowCount; i++) { + customResult.put(Utils.objectToString(model.getValueAt(i, 0)), Utils.objectToString(model.getValueAt(i, 1))); + } + return customResult; + } + + public class UIButtonEditorAndRender extends AbstractCellEditor implements TableCellEditor, TableCellRenderer { + + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, final int row, int column) { + UIButton uiButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/toolbarbtn/close.png")); + uiButton.addMouseListener(new MouseAdapter() { + boolean mouseEntered = false; + + public void mouseEntered(MouseEvent e) { // 当鼠标进入时候调用. + mouseEntered = true; + + } + + public void mouseExited(MouseEvent e) { + mouseEntered = false; + } + + public void mouseReleased(MouseEvent e) { + if (mouseEntered) { + MatchResultTable.this.getCellEditor().stopCellEditing(); + int val = JOptionPane.showConfirmDialog(MatchResultTable.this, Toolkit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + "?", + Toolkit.i18nText("Fine-Design_Basic_Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); + if (val == JOptionPane.OK_OPTION) { + DefaultTableModel model = (DefaultTableModel) MatchResultTable.this.getModel(); + Object areaName = MatchResultTable.this.getValueAt(row, 0); + model.removeRow(row); + matchAreaTable.reMatch(areaName); + } + } + } + }); + return uiButton; + } + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + UIButton button = new UIButton(BaseUtils.readIcon("com/fr/design/images/toolbarbtn/close.png")); + return button; + } + + public Object getCellEditorValue() { + return StringUtils.EMPTY; + } + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java index f1716a0ae0..f66dac3121 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java @@ -14,6 +14,7 @@ import java.util.List; public class MultiComboBoxPane extends AbstractMultiComponentPane { private List currentBoxItems = new ArrayList(); + public void setCurrentBoxItems(List currentBoxItems) { this.currentBoxItems = currentBoxItems; } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java index 5e56b967c4..bec7e6e7b1 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java @@ -8,6 +8,12 @@ import com.fr.design.formula.TinyFormulaPane; * Created by shine on 2019/4/12. */ public class MultiTinyFormulaPane extends AbstractMultiComponentPane { + + @Override + protected int componentWidth() { + return 116; + } + @Override protected TinyFormulaPane createFirstFieldComponent() { return new TinyFormulaPane(); @@ -28,4 +34,4 @@ public class MultiTinyFormulaPane extends AbstractMultiComponentPane { + private DrillMapLayerPane layerPane; + private DrillMapDataPane dataPane; + + public DrillMapChartDataPane(AttributeChangeListener listener) { + super(listener); + } + + private VanChartDrillMapPlot getDrillMapPlot() { + if (getVanChart() != null) { + return getVanChart().getPlot(); + } + return null; + } + + @Override + protected JPanel createContentPane() { + VanChartDrillMapPlot drillMapPlot = getDrillMapPlot(); + if (drillMapPlot == null) { + return new JPanel(); + } + + layerPane = new DrillMapLayerPane(drillMapPlot); + dataPane = new DrillMapDataPane(getVanChart()); + return new VanChartGroupPane(new String[]{Toolkit.i18nText("Fine-Design_Chart_Map_Drill_Level"), Toolkit.i18nText("Fine-Design_Chart_Use_Data")}, + new JPanel[]{layerPane, dataPane}) { + @Override + protected void tabChanged(int index) { + if (index == 0) { + return; + } + dataPane.fireMapTypeChanged(); + } + }; + } + + + @Override + protected void populate(DrillMapChartDataDefinition drillMapChartDataDefinition) { + if (drillMapChartDataDefinition == null) { + return; + } + VanChartDrillMapPlot drillMapPlot = getDrillMapPlot(); + + layerPane.populateBean(drillMapPlot); + dataPane.populateBean(drillMapChartDataDefinition); + } + + @Override + protected DrillMapChartDataDefinition update() { + VanChartDrillMapPlot drillMapPlot = getDrillMapPlot(); + + layerPane.updateBean(drillMapPlot); + + DrillMapChartDataDefinition definition = new DrillMapChartDataDefinition(); + dataPane.updateBean(definition); + + return definition; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/DrillMapDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/DrillMapDataPane.java new file mode 100644 index 0000000000..f8bcf2e915 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/DrillMapDataPane.java @@ -0,0 +1,124 @@ +package com.fr.design.chartx.data.drillMap; + +import com.fr.chartx.data.DrillMapChartDataDefinition; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.chartx.fields.diff.AreaMapCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.AreaMapDataSetFieldsPane; +import com.fr.design.chartx.single.SingleDataPane; +import com.fr.design.gui.frpane.UIComboBoxPane; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; +import com.fr.plugin.chart.vanchart.VanChart; + +import java.util.ArrayList; +import java.util.List; +import java.awt.BorderLayout; + +/** + * Created by Mitisky on 16/6/20. + * 钻取地图数据配置界面中 和钻取层级平级的数据界面 + */ +public class DrillMapDataPane extends BasicBeanPane { + private UIComboBoxPane dataDefinitionType;//数据定义方式:底层数据汇总/各层级分别指定 + + private SingleDataPane bottomDataPane;//底层数据汇总方式定义钻取地图数据 + + private EachLayerDataDefinitionPane eachLayerDataDefinitionPane;//各层级分别指定 + + public DrillMapDataPane(VanChart vanChart) { + AreaMapDataSetFieldsPane areaMapDataSetFieldsPane = new AreaMapDataSetFieldsPane(); + areaMapDataSetFieldsPane.setChart(vanChart); + areaMapDataSetFieldsPane.setLevel(ChartGEOJSONHelper.BOTTOM_LEVEL); + bottomDataPane = new SingleDataPane(areaMapDataSetFieldsPane, new AreaMapCellDataFieldsPane()); + eachLayerDataDefinitionPane = new EachLayerDataDefinitionPane(vanChart); + + dataDefinitionType = new UIComboBoxPane() { + @Override + protected List> initPaneList() { + + List> paneList = new ArrayList>(); + paneList.add(new BottomLayerDataDefinitionPane()); + paneList.add(eachLayerDataDefinitionPane); + return paneList; + } + + @Override + protected String title4PopupWindow() { + return null; + } + }; + + this.setLayout(new BorderLayout()); + this.add(dataDefinitionType, BorderLayout.CENTER); + } + + public void fireMapTypeChanged() { + eachLayerDataDefinitionPane.fireMapTypeChanged(); + } + + @Override + public void populateBean(DrillMapChartDataDefinition ob) { + + dataDefinitionType.setSelectedIndex(ob.isFromBottomData() ? 0 : 1); + + bottomDataPane.populateBean(ob.getBottomDataDefinition()); + eachLayerDataDefinitionPane.populateBean(ob); + } + + /** + * Update. + */ + @Override + public DrillMapChartDataDefinition updateBean() { + return null; + } + + @Override + public void updateBean(DrillMapChartDataDefinition drillMapDefinition) { + if (dataDefinitionType.getSelectedIndex() == 0) { + drillMapDefinition.setFromBottomData(true); + drillMapDefinition.setBottomDataDefinition(bottomDataPane.updateBean()); + } else { + drillMapDefinition.setFromBottomData(false); + eachLayerDataDefinitionPane.updateBean(drillMapDefinition); + } + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Use_Data"); + } + + private class BottomLayerDataDefinitionPane extends FurtherBasicBeanPane { + + private BottomLayerDataDefinitionPane() { + this.setLayout(new BorderLayout()); + this.add(bottomDataPane, BorderLayout.CENTER); + } + + @Override + public boolean accept(Object ob) { + return false; + } + + @Override + public void reset() { + + } + + @Override + public void populateBean(DrillMapChartDataDefinition ob) { + } + + @Override + public DrillMapChartDataDefinition updateBean() { + return null; + } + + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Bottom_Data_Sum"); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/DrillMapLayerPane.java b/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/DrillMapLayerPane.java new file mode 100644 index 0000000000..1102f7a64e --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/DrillMapLayerPane.java @@ -0,0 +1,221 @@ +package com.fr.design.chartx.data.drillMap; + +import com.fr.chartx.TwoTuple; +import com.fr.design.beans.BasicBeanPane; +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.plugin.chart.drillmap.VanChartDrillMapPlot; +import com.fr.plugin.chart.map.data.MapMatchResult; +import com.fr.plugin.chart.map.server.CompatibleGeoJSONTreeHelper; +import com.fr.plugin.chart.type.MapType; +import com.fr.plugin.chart.type.ZoomLevel; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.drillmap.designer.data.comp.MapDataTree; +import com.fr.van.chart.map.designer.type.VanChartMapSourceChoosePane; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.tree.DefaultMutableTreeNode; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.awt.BorderLayout; +import java.awt.Component; + +/** + * Created by Mitisky on 16/6/20. + * 钻取地图数据配置界面--钻取层级界面 + */ +public class DrillMapLayerPane extends BasicBeanPane { + private static final String[] CUSTOM_MAP_TYPES = new String[]{MapType.AREA.getLocaleString(), MapType.POINT.getLocaleString()}; + private static final String[] AREA_MAP_TYPES = new String[]{MapType.AREA.getLocaleString()}; + private static final String[] POINT_MAP_TYPES = new String[]{MapType.POINT.getLocaleString()}; + + private static final java.util.Map TEMP = new HashMap(); + + static { + TEMP.put(MapType.AREA, AREA_MAP_TYPES); + TEMP.put(MapType.POINT, POINT_MAP_TYPES); + TEMP.put(MapType.CUSTOM, CUSTOM_MAP_TYPES); + } + + private MapDataTree mapDataTree; + private Component[][] detailComps; + + + public DrillMapLayerPane(VanChartDrillMapPlot drillMapPlot) { + + initMapTypeAndZoom(drillMapPlot); + + JPanel contentPane = createContentPane(drillMapPlot); + + this.setLayout(new BorderLayout()); + this.add(contentPane, BorderLayout.CENTER); + } + + private void initMapTypeAndZoom(VanChartDrillMapPlot drillMapPlot) { + + if (drillMapPlot != null) { + + int depth = getRootAndDepth(drillMapPlot).getSecond(); + + java.util.List levelList = drillMapPlot.getLayerLevelList(); + java.util.List mapTypeList = drillMapPlot.getLayerMapTypeList(); + List matchResultList = drillMapPlot.getMatchResultList(); + + //根据层级初始属性,一切以json那边读到的层级为准 + int levelSize = levelList.size(); + for (int i = levelSize; i < depth; i++) { + levelList.add(ZoomLevel.AUTO); + } + MapType mapType = drillMapPlot.getMapType() == MapType.POINT ? MapType.POINT : MapType.AREA; + int typeSize = mapTypeList.size(); + for (int j = typeSize; j < depth; j++) { + mapTypeList.add(mapType); + } + + int matchSize = matchResultList.size(); + for (int k = matchSize; k < depth; k++) { + matchResultList.add(new MapMatchResult()); + } + } + } + + public static TwoTuple getRootAndDepth(VanChartDrillMapPlot drillMapPlot) { + int depth = 1; + + DefaultMutableTreeNode root = CompatibleGeoJSONTreeHelper.getNodeByJSONPath(drillMapPlot.getGeoUrl()); + if (root != null) { + depth = root.getDepth() + 1;//根节点也算一层 + } + + return new TwoTuple<>(root, depth); + } + + private JPanel createContentPane(VanChartDrillMapPlot drillMapPlot) { + if (drillMapPlot == null) { + return new JPanel(); + } + + DefaultMutableTreeNode root = CompatibleGeoJSONTreeHelper.getNodeByJSONPath(drillMapPlot.getGeoUrl()); + + if (mapDataTree == null) { + mapDataTree = new MapDataTree(root); + mapDataTree.setRootVisible(true); + } else { + mapDataTree.changeRootNode(root); + } + + + JPanel mapDataTreePanel = new JPanel(new BorderLayout()); + mapDataTreePanel.add(mapDataTree); + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {f}; + double[] rowSize = {p, p}; + Component[][] components = new Component[][]{ + new Component[]{createTitlePane(Toolkit.i18nText("Fine-Design_Chart_Layer_Tree"), mapDataTreePanel)}, + new Component[]{createTitlePane(Toolkit.i18nText("Fine-Design_Chart_Layer_Detail"), createLayerDetailPane(drillMapPlot))} + }; + + JPanel contentPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + JPanel panel = new JPanel(new BorderLayout()); + panel.add(contentPane, BorderLayout.CENTER); + return panel; + } + + private JPanel createTitlePane(String title, JPanel panel) { + JPanel jPanel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(title, panel); + panel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); + jPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + return jPanel; + } + + private JPanel createLayerDetailPane(VanChartDrillMapPlot drillMapPlot) { + int depth = getRootAndDepth(drillMapPlot).getSecond(); + String[] items = TEMP.get(drillMapPlot.getMapType()); + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {f, p, p}; + double[] rowSize = new double[depth + 1]; + detailComps = new Component[depth + 1][3]; + rowSize[0] = p; + detailComps[0] = new Component[]{ + new UILabel(Toolkit.i18nText("Fine-Design_Chart_Descriptor")), + new UILabel(Toolkit.i18nText("Fine-Design_Chart_Zoom_Layer")), + new UILabel(Toolkit.i18nText("Fine-Design_Chart_Layer_Map_Type")) + }; + for (int i = 0; i < depth; i++) { + rowSize[i + 1] = p; + int d = i + 1; + UILabel label = new UILabel(String.format("%s%d%s", Toolkit.i18nText("Fine-Design_Chart_Index_Article"), d, Toolkit.i18nText("Fine-Design_Chart_Index_Layer"))); + UIComboBox level = new UIComboBox(VanChartMapSourceChoosePane.ZOOM_LEVELS); + level.setEnabled(i != 0); + UIComboBox type = new UIComboBox(items); + detailComps[i + 1] = new Component[]{label, level, type}; + } + + return TableLayoutHelper.createGapTableLayoutPane(detailComps, rowSize, columnSize, 10, 6); + } + + @Override + public void populateBean(VanChartDrillMapPlot drillMapPlot) { + + if (drillMapPlot != null) { + java.util.List levelList = drillMapPlot.getLayerLevelList(); + java.util.List mapTypeList = drillMapPlot.getLayerMapTypeList(); + + for (int i = 0; i < levelList.size(); i++) { + Component[] components = detailComps[i + 1]; + if (components != null) { + UIComboBox level = (UIComboBox) components[1]; + UIComboBox type = (UIComboBox) components[2]; + if (level != null) { + level.setSelectedItem(levelList.get(i)); + } + if (type != null) { + type.setSelectedItem(mapTypeList.get(i).getLocaleString()); + } + } + } + } + } + + /** + * Update. + */ + @Override + public VanChartDrillMapPlot updateBean() { + return null; + } + + @Override + public void updateBean(VanChartDrillMapPlot drillMapPlot) { + if (drillMapPlot != null && detailComps != null) { + java.util.List levelList = new ArrayList(); + java.util.List mapTypeList = new ArrayList(); + for (Component[] com : detailComps) { + if (com[1] instanceof UIComboBox && com[2] instanceof UIComboBox) { + UIComboBox level = (UIComboBox) com[1]; + UIComboBox type = (UIComboBox) com[2]; + levelList.add((ZoomLevel) level.getSelectedItem()); + if (type.getSelectedItem() != null) { + mapTypeList.add(MapType.parseLocale(type.getSelectedItem().toString())); + } + } + } + drillMapPlot.setLayerLevelList(levelList); + drillMapPlot.setLayerMapTypeList(mapTypeList); + } + } + + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Map_Drill_Level"); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/EachLayerDataDefinitionPane.java b/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/EachLayerDataDefinitionPane.java new file mode 100644 index 0000000000..a7180e4c5d --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/EachLayerDataDefinitionPane.java @@ -0,0 +1,144 @@ +package com.fr.design.chartx.data.drillMap; + +import com.fr.chartx.data.AbstractDataDefinition; +import com.fr.chartx.data.DrillMapChartDataDefinition; +import com.fr.design.chartx.fields.diff.AreaMapCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.AreaMapDataSetFieldsPane; +import com.fr.design.chartx.fields.diff.PointMapCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.PointMapDataSetFieldsPane; +import com.fr.design.chartx.single.SingleDataPane; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.MultiTabPane; +import com.fr.design.i18n.Toolkit; +import com.fr.general.ComparatorUtils; +import com.fr.plugin.chart.drillmap.VanChartDrillMapPlot; +import com.fr.plugin.chart.type.MapType; +import com.fr.plugin.chart.vanchart.VanChart; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Mitisky on 16/6/20. + * 各层级分别指定的界面 + */ +public class EachLayerDataDefinitionPane extends MultiTabPane { + + private List oldTypeList; + private VanChartDrillMapPlot plot; + + private VanChart vanChart; + + public EachLayerDataDefinitionPane(VanChart vanChart) { + this.vanChart = vanChart; + this.plot = vanChart.getPlot(); + initComps(); + } + + private void initComps() { + paneList = initPaneList(this.plot); + super.relayoutWhenListChange(); + } + + public void fireMapTypeChanged() { + if (!ComparatorUtils.equals(plot.getLayerMapTypeList(), oldTypeList)) { + initComps(); + } + } + + protected List initPaneList(VanChartDrillMapPlot drillMapPlot) { + List paneList = new ArrayList(); + + oldTypeList = drillMapPlot.getLayerMapTypeList(); + int depth = DrillMapLayerPane.getRootAndDepth(drillMapPlot).getSecond(); + + for (int i = 0; i < depth; i++) { + final String title = String.format("%s%d%s", Toolkit.i18nText("Fine-Design_Chart_Index_Article"), i, Toolkit.i18nText("Fine-Design_Chart_Index_Layer")); + MapType mapType = oldTypeList.get(i); + + SingleDataPane pane; + if (mapType == MapType.AREA) { + AreaMapDataSetFieldsPane areaMapDataSetFieldsPane = new AreaMapDataSetFieldsPane(); + areaMapDataSetFieldsPane.setChart(vanChart); + areaMapDataSetFieldsPane.setLevel(i); + pane = new SingleDataPane(areaMapDataSetFieldsPane, new AreaMapCellDataFieldsPane()) { + @Override + protected String title4PopupWindow() { + return title; + } + + }; + } else { + PointMapDataSetFieldsPane pointMapDataSetFieldsPane = new PointMapDataSetFieldsPane(); + pointMapDataSetFieldsPane.setChart(vanChart); + pointMapDataSetFieldsPane.setLevel(i); + pane = new SingleDataPane(pointMapDataSetFieldsPane, new PointMapCellDataFieldsPane()) { + @Override + protected String title4PopupWindow() { + return title; + } + }; + } + + paneList.add(pane); + } + + return paneList; + } + + @Override + public void relayoutWhenListChange() { + } + + @Override + protected List initPaneList() { + return new ArrayList(); + } + + @Override + public void populateBean(DrillMapChartDataDefinition drillMapChartDataDefinition) { + List eachLayerDataDefinitionList = drillMapChartDataDefinition.getEachLayerDataDefinitionList(); + + if (eachLayerDataDefinitionList == null) { + return; + } + + for (int i = 0, len = Math.min(paneList.size(), eachLayerDataDefinitionList.size()); i < len; i++) { + BasicPane basicPane = paneList.get(i); + if (basicPane instanceof SingleDataPane) { + ((SingleDataPane) basicPane).populateBean(eachLayerDataDefinitionList.get(i)); + } + } + } + + @Override + public DrillMapChartDataDefinition updateBean() { + return null; + } + + @Override + public void updateBean(DrillMapChartDataDefinition drillMapDefinition) { + List eachLayerDataDefinitionList = new ArrayList(); + for (BasicPane basicPane : paneList) { + if (basicPane instanceof SingleDataPane) { + eachLayerDataDefinitionList.add(((SingleDataPane) basicPane).updateBean()); + } + } + drillMapDefinition.setEachLayerDataDefinitionList(eachLayerDataDefinitionList); + } + + @Override + public boolean accept(Object ob) { + return false; + } + + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Each_Layer_Data_Special"); + } + + @Override + public void reset() { + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/data/map/AbstractAreaLngLatPane.java b/designer-chart/src/main/java/com/fr/design/chartx/data/map/AbstractAreaLngLatPane.java new file mode 100644 index 0000000000..09393918a5 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/data/map/AbstractAreaLngLatPane.java @@ -0,0 +1,115 @@ +package com.fr.design.chartx.data.map; + +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.gui.ChartDataPane; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.util.Arrays; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2019/11/13 + */ +public abstract class AbstractAreaLngLatPane extends JPanel { + private JPanel centerPane; + private UIButtonGroup locationType; + + private JPanel areaPane; + private JPanel lngLatAreaPane; + + protected abstract JPanel createAreaPane(); + + protected abstract JPanel createAreaLngLatPane(); + + public AbstractAreaLngLatPane() { + initComponents(); + } + + protected void initComponents() { + centerPane = new JPanel(new CardLayout()) { + @Override + public Dimension getPreferredSize() { + if (locationType.getSelectedIndex() == 0) { + return areaPane.getPreferredSize(); + } else { + return lngLatAreaPane.getPreferredSize(); + } + } + }; + + locationType = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Location_With_Area_Name"), + Toolkit.i18nText("Fine-Design_Chart_Location_With_LongAndLat")}); + locationType.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + checkCenterPane(); + } + }); + + lngLatAreaPane = createAreaLngLatPane(); + areaPane = createAreaPane(); + + centerPane.add(areaPane, "area"); + centerPane.add(lngLatAreaPane, "longLat"); + + locationType.setSelectedIndex(0); + + this.setLayout(new BorderLayout(0, 6)); + this.add(locationType, BorderLayout.NORTH); + this.add(centerPane, BorderLayout.CENTER); + } + + private void checkCenterPane() { + CardLayout cardLayout = (CardLayout) centerPane.getLayout(); + if (locationType.getSelectedIndex() == 0) { + cardLayout.show(centerPane, "area"); + } else { + cardLayout.show(centerPane, "longLat"); + } + } + + public void populate(boolean useAreaName) { + locationType.setSelectedIndex(useAreaName ? 0 : 1); + + checkCenterPane(); + } + + public boolean update() { + return locationType.getSelectedIndex() == 0; + } + + protected JPanel createPane(String[] labels, JComponent... fieldComponents) { + + int len = Math.min(labels.length, fieldComponents.length); + + if (len == 0) { + return new JPanel(); + } + + Component[][] components = new Component[len][2]; + for (int i = 0; i < len; i++) { + components[i] = new Component[]{new UILabel(labels[i], SwingConstants.LEFT), fieldComponents[i]}; + } + double p = TableLayout.PREFERRED; + double[] columnSize = {ChartDataPane.LABEL_WIDTH, 122}; + double[] rowSize = new double[len]; + Arrays.fill(rowSize, p); + + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 6); + } + +} + diff --git a/designer-chart/src/main/java/com/fr/design/chartx/data/map/LineMapAreaLngLatPaneWithComboBox.java b/designer-chart/src/main/java/com/fr/design/chartx/data/map/LineMapAreaLngLatPaneWithComboBox.java new file mode 100644 index 0000000000..5d2f2298a8 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/data/map/LineMapAreaLngLatPaneWithComboBox.java @@ -0,0 +1,121 @@ +package com.fr.design.chartx.data.map; + +import com.fr.chartx.data.field.diff.LineMapColumnFieldCollection; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.chartx.fields.diff.LineMapDataSetFieldsPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; + +import javax.swing.JPanel; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2019/11/13 + */ +public class LineMapAreaLngLatPaneWithComboBox extends LineMapAreaLngLatPaneWithTinyFormula { + private UIComboBox fromArea_tab0; + private UIComboBox toArea_tab0; + + private UIComboBox fromArea_tab1; + private UIComboBox fromLng_tab1; + private UIComboBox fromLat_tab1; + private UIComboBox toArea_tab1; + private UIComboBox toLng_tab1; + private UIComboBox toLat_tab1; + + private LineMapDataSetFieldsPane lineMapDataSetFieldsPane; + + public LineMapAreaLngLatPaneWithComboBox(LineMapDataSetFieldsPane lineMapDataSetFieldsPane) { + this.lineMapDataSetFieldsPane = lineMapDataSetFieldsPane; + initComponents(); + } + + protected void initComponents() { + if (lineMapDataSetFieldsPane == null) { + return; + } + super.initComponents(); + } + + + @Override + protected JPanel createAreaPane() { + if (fromArea_tab0 == null) { + fromArea_tab0 = new UIComboBox(); + toArea_tab0 = new UIComboBox(); + } + return createPane( + new String[]{Toolkit.i18nText("Fine-Design_Chart_Start_Area_Name"), + Toolkit.i18nText("Fine-Design_Chart_End_Area_Name")}, + lineMapDataSetFieldsPane.createAreaPanel(fromArea_tab0), lineMapDataSetFieldsPane.createAreaPanel(toArea_tab0) + ); + } + + @Override + protected JPanel createAreaLngLatPane() { + if (fromArea_tab1 == null) { + fromArea_tab1 = new UIComboBox(); + fromLng_tab1 = new UIComboBox(); + fromLat_tab1 = new UIComboBox(); + toArea_tab1 = new UIComboBox(); + toLng_tab1 = new UIComboBox(); + toLat_tab1 = new UIComboBox(); + } + return createPane( + new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Start_Area_Name"), + Toolkit.i18nText("Fine-Design_Chart_Start_Longitude"), + Toolkit.i18nText("Fine-Design_Chart_Start_Latitude"), + Toolkit.i18nText("Fine-Design_Chart_End_Area_Name"), + Toolkit.i18nText("Fine-Design_Chart_End_Longitude"), + Toolkit.i18nText("Fine-Design_Chart_End_Latitude")}, + lineMapDataSetFieldsPane.createAreaPanel(fromArea_tab1), + fromLng_tab1, + fromLat_tab1, + lineMapDataSetFieldsPane.createAreaPanel(toArea_tab1), + toLng_tab1, + toLat_tab1); + } + + protected void populateTab0(LineMapColumnFieldCollection fieldCollection) { + AbstractDataSetFieldsPane.populateField(fromArea_tab0, fieldCollection.getFromAreaName()); + AbstractDataSetFieldsPane.populateField(toArea_tab0, fieldCollection.getToAreaName()); + } + + protected void updateTab0(LineMapColumnFieldCollection fieldCollection) { + AbstractDataSetFieldsPane.updateField(fromArea_tab0, fieldCollection.getFromAreaName()); + AbstractDataSetFieldsPane.updateField(toArea_tab0, fieldCollection.getToAreaName()); + } + + protected void populateTab1(LineMapColumnFieldCollection fieldCollection) { + AbstractDataSetFieldsPane.populateField(fromArea_tab1, fieldCollection.getFromAreaName()); + AbstractDataSetFieldsPane.populateField(toArea_tab1, fieldCollection.getToAreaName()); + AbstractDataSetFieldsPane.populateField(fromLng_tab1, fieldCollection.getFromLng()); + AbstractDataSetFieldsPane.populateField(toLng_tab1, fieldCollection.getToLng()); + AbstractDataSetFieldsPane.populateField(fromLat_tab1, fieldCollection.getFromLat()); + AbstractDataSetFieldsPane.populateField(toLat_tab1, fieldCollection.getToLat()); + } + + protected void updateTab1(LineMapColumnFieldCollection fieldCollection) { + AbstractDataSetFieldsPane.updateField(fromArea_tab1, fieldCollection.getFromAreaName()); + AbstractDataSetFieldsPane.updateField(toArea_tab1, fieldCollection.getToAreaName()); + AbstractDataSetFieldsPane.updateField(fromLng_tab1, fieldCollection.getFromLng()); + AbstractDataSetFieldsPane.updateField(toLng_tab1, fieldCollection.getToLng()); + AbstractDataSetFieldsPane.updateField(fromLat_tab1, fieldCollection.getFromLat()); + AbstractDataSetFieldsPane.updateField(toLat_tab1, fieldCollection.getToLat()); + } + + public UIComboBox[] allFieldComboBox() { + return new UIComboBox[]{ + fromArea_tab0, + toArea_tab0, + fromArea_tab1, + fromLng_tab1, + fromLat_tab1, + toArea_tab1, + toLng_tab1, + toLat_tab1 + }; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/data/map/LineMapAreaLngLatPaneWithTinyFormula.java b/designer-chart/src/main/java/com/fr/design/chartx/data/map/LineMapAreaLngLatPaneWithTinyFormula.java new file mode 100644 index 0000000000..2fb37fee55 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/data/map/LineMapAreaLngLatPaneWithTinyFormula.java @@ -0,0 +1,113 @@ +package com.fr.design.chartx.data.map; + +import com.fr.chartx.data.field.diff.LineMapColumnFieldCollection; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.i18n.Toolkit; + +import javax.swing.JPanel; + + +/** + * @author shine + * @version 10.0 + * Created by shine on 2019/11/13 + */ +public class LineMapAreaLngLatPaneWithTinyFormula extends AbstractAreaLngLatPane { + private TinyFormulaPane fromArea_tab0; + private TinyFormulaPane toArea_tab0; + + private TinyFormulaPane fromArea_tab1; + private TinyFormulaPane fromLng_tab1; + private TinyFormulaPane fromLat_tab1; + private TinyFormulaPane toArea_tab1; + private TinyFormulaPane toLng_tab1; + private TinyFormulaPane toLat_tab1; + + + @Override + protected JPanel createAreaPane() { + if (fromArea_tab0 == null) { + fromArea_tab0 = new TinyFormulaPane(); + toArea_tab0 = new TinyFormulaPane(); + } + return createPane( + new String[]{Toolkit.i18nText("Fine-Design_Chart_Start_Area_Name"), + Toolkit.i18nText("Fine-Design_Chart_End_Area_Name")}, + fromArea_tab0, toArea_tab0 + ); + } + + @Override + protected JPanel createAreaLngLatPane() { + if (fromArea_tab1 == null) { + fromArea_tab1 = new TinyFormulaPane(); + fromLng_tab1 = new TinyFormulaPane(); + fromLat_tab1 = new TinyFormulaPane(); + toArea_tab1 = new TinyFormulaPane(); + toLng_tab1 = new TinyFormulaPane(); + toLat_tab1 = new TinyFormulaPane(); + } + return createPane( + new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Start_Area_Name"), + Toolkit.i18nText("Fine-Design_Chart_Start_Longitude"), + Toolkit.i18nText("Fine-Design_Chart_Start_Latitude"), + Toolkit.i18nText("Fine-Design_Chart_End_Area_Name"), + Toolkit.i18nText("Fine-Design_Chart_End_Longitude"), + Toolkit.i18nText("Fine-Design_Chart_End_Latitude")}, + fromArea_tab1, + fromLng_tab1, + fromLat_tab1, + toArea_tab1, + toLng_tab1, + toLat_tab1); + } + + protected void populateTab0(LineMapColumnFieldCollection fieldCollection) { + AbstractCellDataFieldsPane.populateField(fromArea_tab0, fieldCollection.getFromAreaName()); + AbstractCellDataFieldsPane.populateField(toArea_tab0, fieldCollection.getToAreaName()); + } + + protected void updateTab0(LineMapColumnFieldCollection fieldCollection) { + AbstractCellDataFieldsPane.updateField(fromArea_tab0, fieldCollection.getFromAreaName()); + AbstractCellDataFieldsPane.updateField(toArea_tab0, fieldCollection.getToAreaName()); + } + + protected void populateTab1(LineMapColumnFieldCollection fieldCollection) { + AbstractCellDataFieldsPane.populateField(fromArea_tab1, fieldCollection.getFromAreaName()); + AbstractCellDataFieldsPane.populateField(toArea_tab1, fieldCollection.getToAreaName()); + AbstractCellDataFieldsPane.populateField(fromLng_tab1, fieldCollection.getFromLng()); + AbstractCellDataFieldsPane.populateField(toLng_tab1, fieldCollection.getToLng()); + AbstractCellDataFieldsPane.populateField(fromLat_tab1, fieldCollection.getFromLat()); + AbstractCellDataFieldsPane.populateField(toLat_tab1, fieldCollection.getToLat()); + } + + protected void updateTab1(LineMapColumnFieldCollection fieldCollection) { + AbstractCellDataFieldsPane.updateField(fromArea_tab1, fieldCollection.getFromAreaName()); + AbstractCellDataFieldsPane.updateField(toArea_tab1, fieldCollection.getToAreaName()); + AbstractCellDataFieldsPane.updateField(fromLng_tab1, fieldCollection.getFromLng()); + AbstractCellDataFieldsPane.updateField(toLng_tab1, fieldCollection.getToLng()); + AbstractCellDataFieldsPane.updateField(fromLat_tab1, fieldCollection.getFromLat()); + AbstractCellDataFieldsPane.updateField(toLat_tab1, fieldCollection.getToLat()); + } + + public void populate(LineMapColumnFieldCollection fieldCollection) { + super.populate(fieldCollection.isUseAreaName()); + if (fieldCollection.isUseAreaName()) { + populateTab0(fieldCollection); + } else { + populateTab1(fieldCollection); + } + } + + public void update(LineMapColumnFieldCollection fieldCollection) { + fieldCollection.setUseAreaName(super.update()); + if (fieldCollection.isUseAreaName()) { + updateTab0(fieldCollection); + } else { + updateTab1(fieldCollection); + } + } +} + diff --git a/designer-chart/src/main/java/com/fr/design/chartx/data/map/MapChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/data/map/MapChartDataPane.java new file mode 100644 index 0000000000..fd4790d57d --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/data/map/MapChartDataPane.java @@ -0,0 +1,108 @@ +package com.fr.design.chartx.data.map; + +import com.fr.chartx.data.MapChartDataDefinition; +import com.fr.design.chartx.AbstractChartDataPane; +import com.fr.design.chartx.fields.diff.AreaMapCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.AreaMapDataSetFieldsPane; +import com.fr.design.chartx.fields.diff.LineMapCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.LineMapDataSetFieldsPane; +import com.fr.design.chartx.fields.diff.PointMapCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.PointMapDataSetFieldsPane; +import com.fr.design.chartx.single.SingleDataPane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.plugin.chart.map.VanChartMapPlot; +import com.fr.plugin.chart.type.MapType; +import com.fr.van.chart.map.designer.VanMapAreaPointAndLineGroupPane; + +import javax.swing.JPanel; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2019/11/12 + */ +public class MapChartDataPane extends AbstractChartDataPane { + + private SingleDataPane areaPane; + private SingleDataPane pointPane; + private SingleDataPane linePane; + + public MapChartDataPane(AttributeChangeListener listener) { + super(listener); + } + + @Override + protected JPanel createContentPane() { + MapType mapType = MapType.AREA; + if (this.getVanChart() != null) { + VanChartMapPlot mapPlot = this.getVanChart().getPlot(); + mapType = mapPlot == null ? mapType : mapPlot.getMapType(); + } + AreaMapDataSetFieldsPane areaMapDataSetFieldsPane; + PointMapDataSetFieldsPane pointMapDataSetFieldsPane; + LineMapDataSetFieldsPane lineMapDataSetFieldsPane; + switch (mapType) { + case AREA: + areaMapDataSetFieldsPane = new AreaMapDataSetFieldsPane(); + areaMapDataSetFieldsPane.setChart(getVanChart()); + areaPane = new SingleDataPane(areaMapDataSetFieldsPane, new AreaMapCellDataFieldsPane()); + return areaPane; + case POINT: + pointMapDataSetFieldsPane = new PointMapDataSetFieldsPane(); + pointMapDataSetFieldsPane.setChart(getVanChart()); + pointPane = new SingleDataPane(pointMapDataSetFieldsPane, new PointMapCellDataFieldsPane()); + return pointPane; + case LINE: + lineMapDataSetFieldsPane = new LineMapDataSetFieldsPane(); + lineMapDataSetFieldsPane.setChart(getVanChart()); + linePane = new SingleDataPane(lineMapDataSetFieldsPane, new LineMapCellDataFieldsPane()); + return linePane; + case CUSTOM: + areaMapDataSetFieldsPane = new AreaMapDataSetFieldsPane(); + areaMapDataSetFieldsPane.setChart(getVanChart()); + pointMapDataSetFieldsPane = new PointMapDataSetFieldsPane(); + pointMapDataSetFieldsPane.setChart(getVanChart()); + lineMapDataSetFieldsPane = new LineMapDataSetFieldsPane(); + lineMapDataSetFieldsPane.setChart(getVanChart()); + areaPane = new SingleDataPane(areaMapDataSetFieldsPane, new AreaMapCellDataFieldsPane()); + pointPane = new SingleDataPane(pointMapDataSetFieldsPane, new PointMapCellDataFieldsPane()); + linePane = new SingleDataPane(lineMapDataSetFieldsPane, new LineMapCellDataFieldsPane()); + return new VanMapAreaPointAndLineGroupPane(areaPane, pointPane, linePane); + default: + areaPane = new SingleDataPane(new AreaMapDataSetFieldsPane(), new AreaMapCellDataFieldsPane()); + return areaPane; + } + } + + @Override + protected void populate(MapChartDataDefinition mapChartDataDefinition) { + if (mapChartDataDefinition == null) { + return; + } + if (areaPane != null) { + areaPane.populateBean(mapChartDataDefinition.getAreaMapDataDefinition()); + } + if (pointPane != null) { + pointPane.populateBean(mapChartDataDefinition.getPointMapDataDefinition()); + } + if (linePane != null) { + linePane.populateBean(mapChartDataDefinition.getLineMapDataDefinition()); + } + + } + + @Override + protected MapChartDataDefinition update() { + MapChartDataDefinition mapChartDataDefinition = new MapChartDataDefinition(); + if (areaPane != null) { + mapChartDataDefinition.setAreaMapDataDefinition(areaPane.updateBean()); + } + if (pointPane != null) { + mapChartDataDefinition.setPointMapDataDefinition(pointPane.updateBean()); + } + if (linePane != null) { + mapChartDataDefinition.setLineMapDataDefinition(linePane.updateBean()); + } + return mapChartDataDefinition; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/data/map/PointMapAreaLngLatPaneWithComboBox.java b/designer-chart/src/main/java/com/fr/design/chartx/data/map/PointMapAreaLngLatPaneWithComboBox.java new file mode 100644 index 0000000000..b3b503ddda --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/data/map/PointMapAreaLngLatPaneWithComboBox.java @@ -0,0 +1,86 @@ +package com.fr.design.chartx.data.map; + +import com.fr.chartx.data.field.diff.PointMapColumnFieldCollection; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.chartx.fields.diff.PointMapDataSetFieldsPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; + +import javax.swing.JPanel; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2019/11/13 + */ +public class PointMapAreaLngLatPaneWithComboBox extends PointMapAreaLngLatPaneWithTinyFormula { + private UIComboBox area_tab0; + + private UIComboBox area_tab1; + private UIComboBox lng_tab1; + private UIComboBox lat_tab1; + + private PointMapDataSetFieldsPane pointMapDataSetFieldsPane; + + public PointMapAreaLngLatPaneWithComboBox(PointMapDataSetFieldsPane pointMapDataSetFieldsPane) { + this.pointMapDataSetFieldsPane = pointMapDataSetFieldsPane; + initComponents(); + } + + protected void initComponents() { + if (pointMapDataSetFieldsPane == null) { + return; + } + super.initComponents(); + } + + @Override + protected JPanel createAreaPane() { + if (area_tab0 == null) { + area_tab0 = new UIComboBox(); + } + return createPane( + new String[]{Toolkit.i18nText("Fine-Design_Chart_Area_Name")}, + pointMapDataSetFieldsPane.createAreaPanel(area_tab0) + ); + } + + @Override + protected JPanel createAreaLngLatPane() { + if (area_tab1 == null) { + area_tab1 = new UIComboBox(); + lng_tab1 = new UIComboBox(); + lat_tab1 = new UIComboBox(); + } + return createPane( + new String[]{Toolkit.i18nText("Fine-Design_Chart_Area_Name"), Toolkit.i18nText("Fine-Design_Chart_Longitude"), Toolkit.i18nText("Fine-Design_Chart_Latitude")}, + pointMapDataSetFieldsPane.createAreaPanel(area_tab1), lng_tab1, lat_tab1 + ); + } + + protected void populateTab0(PointMapColumnFieldCollection fieldCollection) { + AbstractDataSetFieldsPane.populateField(area_tab0, fieldCollection.getAreaName()); + } + + protected void updateTab0(PointMapColumnFieldCollection fieldCollection) { + AbstractDataSetFieldsPane.updateField(area_tab0, fieldCollection.getAreaName()); + } + + protected void populateTab1(PointMapColumnFieldCollection fieldCollection) { + AbstractDataSetFieldsPane.populateField(area_tab1, fieldCollection.getAreaName()); + AbstractDataSetFieldsPane.populateField(lng_tab1, fieldCollection.getLng()); + AbstractDataSetFieldsPane.populateField(lat_tab1, fieldCollection.getLat()); + } + + protected void updateTab1(PointMapColumnFieldCollection fieldCollection) { + AbstractDataSetFieldsPane.updateField(area_tab1, fieldCollection.getAreaName()); + AbstractDataSetFieldsPane.updateField(lng_tab1, fieldCollection.getLng()); + AbstractDataSetFieldsPane.updateField(lat_tab1, fieldCollection.getLat()); + } + + public UIComboBox[] allFieldComboBox() { + return new UIComboBox[]{ + area_tab0, area_tab1, lng_tab1, lat_tab1 + }; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/data/map/PointMapAreaLngLatPaneWithTinyFormula.java b/designer-chart/src/main/java/com/fr/design/chartx/data/map/PointMapAreaLngLatPaneWithTinyFormula.java new file mode 100644 index 0000000000..6da5a1b383 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/data/map/PointMapAreaLngLatPaneWithTinyFormula.java @@ -0,0 +1,84 @@ +package com.fr.design.chartx.data.map; + +import com.fr.chartx.data.field.diff.PointMapColumnFieldCollection; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.i18n.Toolkit; + +import javax.swing.JPanel; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2019/11/13 + */ +public class PointMapAreaLngLatPaneWithTinyFormula extends AbstractAreaLngLatPane { + private TinyFormulaPane area_tab0; + + private TinyFormulaPane area_tab1; + private TinyFormulaPane lng_tab1; + private TinyFormulaPane lat_tab1; + + + @Override + protected JPanel createAreaPane() { + if (area_tab0 == null) { + area_tab0 = new TinyFormulaPane(); + } + return createPane( + new String[]{Toolkit.i18nText("Fine-Design_Chart_Area_Name")}, + area_tab0 + ); + } + + @Override + protected JPanel createAreaLngLatPane() { + if (area_tab1 == null) { + area_tab1 = new TinyFormulaPane(); + lng_tab1 = new TinyFormulaPane(); + lat_tab1 = new TinyFormulaPane(); + } + return createPane( + new String[]{Toolkit.i18nText("Fine-Design_Chart_Area_Name"), Toolkit.i18nText("Fine-Design_Chart_Longitude"), Toolkit.i18nText("Fine-Design_Chart_Latitude")}, + area_tab1, lng_tab1, lat_tab1 + ); + } + + protected void populateTab0(PointMapColumnFieldCollection fieldCollection) { + AbstractCellDataFieldsPane.populateField(area_tab0, fieldCollection.getAreaName()); + } + + protected void updateTab0(PointMapColumnFieldCollection fieldCollection) { + AbstractCellDataFieldsPane.updateField(area_tab0, fieldCollection.getAreaName()); + } + + protected void populateTab1(PointMapColumnFieldCollection fieldCollection) { + AbstractCellDataFieldsPane.populateField(area_tab1, fieldCollection.getAreaName()); + AbstractCellDataFieldsPane.populateField(lng_tab1, fieldCollection.getLng()); + AbstractCellDataFieldsPane.populateField(lat_tab1, fieldCollection.getLat()); + } + + protected void updateTab1(PointMapColumnFieldCollection fieldCollection) { + AbstractCellDataFieldsPane.updateField(area_tab1, fieldCollection.getAreaName()); + AbstractCellDataFieldsPane.updateField(lng_tab1, fieldCollection.getLng()); + AbstractCellDataFieldsPane.updateField(lat_tab1, fieldCollection.getLat()); + } + + public void populate(PointMapColumnFieldCollection fieldCollection) { + super.populate(fieldCollection.isUseAreaName()); + if (fieldCollection.isUseAreaName()) { + populateTab0(fieldCollection); + } else { + populateTab1(fieldCollection); + } + } + + public void update(PointMapColumnFieldCollection fieldCollection) { + fieldCollection.setUseAreaName(super.update()); + if (fieldCollection.isUseAreaName()) { + updateTab0(fieldCollection); + } else { + updateTab1(fieldCollection); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java index b302ec8632..6d1cf932ad 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java @@ -47,7 +47,7 @@ public abstract class AbstractCellDataFieldsPane extends BasicBeanPane { + public String tableName; + public AbstractDataSetFieldsPane() { initComponents(); } + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + protected void initComponents() { this.setLayout(new BorderLayout(0, 6)); - this.setBorder(BorderFactory.createEmptyBorder(2, 24, 0, 15)); + this.setBorder(BorderFactory.createEmptyBorder(6, 24, 0, 15)); JPanel north = createNorthPane(), center = createCenterPane(), @@ -95,7 +107,7 @@ public abstract class AbstractDataSetFieldsPane +public abstract class AbstractCellDataFieldsWithSeriesValuePane extends AbstractCellDataFieldsPane { private CellDataSeriesValueCorrelationPane seriesValueFieldsPane; @@ -41,12 +41,12 @@ public abstract class AbstractCellDataFieldsWithSeriesValuePane +public abstract class AbstractDataSetFieldsWithSeriesValuePane extends AbstractDataSetFieldsPane { private SeriesValueFieldComboBoxPane seriesValueFieldComboBoxPane; @@ -61,11 +61,11 @@ public abstract class AbstractDataSetFieldsWithSeriesValuePane { + private TinyFormulaPane areaName; + + @Override + protected String[] fieldLabels() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Area_Name") + }; + } + + @Override + protected TinyFormulaPane[] formulaPanes() { + return new TinyFormulaPane[]{ + createAreaName() + }; + } + + private TinyFormulaPane createAreaName() { + if (areaName == null) { + areaName = new TinyFormulaPane(); + } + return areaName; + } + + @Override + public void populateBean(AreaMapColumnFieldCollection ob) { + populateField(areaName, ob.getAreaName()); + populateSeriesValuePane(ob); + } + + @Override + public AreaMapColumnFieldCollection updateBean() { + AreaMapColumnFieldCollection fieldCollection = new AreaMapColumnFieldCollection(); + updateField(areaName, fieldCollection.getAreaName()); + updateSeriesValuePane(fieldCollection); + return fieldCollection; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AreaMapDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AreaMapDataSetFieldsPane.java new file mode 100644 index 0000000000..2f4dc37ea1 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AreaMapDataSetFieldsPane.java @@ -0,0 +1,59 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.AreaMapColumnFieldCollection; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; + +import java.awt.Component; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2019/11/7 + */ +public class AreaMapDataSetFieldsPane extends MapDataSetFieldsPane { + + private UIComboBox areaName; + + @Override + protected String[] fieldLabels() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Area_Name") + }; + } + + @Override + protected UIComboBox[] filedComboBoxes() { + return new UIComboBox[]{ + createAreaName() + }; + } + + @Override + protected Component[] fieldComponents() { + return new Component[]{ + createAreaPanel(createAreaName()) + }; + } + + private UIComboBox createAreaName() { + if (areaName == null) { + areaName = new UIComboBox(); + } + return areaName; + } + + @Override + public void populateBean(AreaMapColumnFieldCollection ob) { + populateField(areaName, ob.getAreaName()); + populateSeriesValuePane(ob); + } + + @Override + public AreaMapColumnFieldCollection updateBean() { + AreaMapColumnFieldCollection fieldCollection = new AreaMapColumnFieldCollection(); + updateField(areaName, fieldCollection.getAreaName()); + updateSeriesValuePane(fieldCollection); + return fieldCollection; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/FunnelCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/FunnelCellDataFieldsPane.java new file mode 100644 index 0000000000..c1766576c4 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/FunnelCellDataFieldsPane.java @@ -0,0 +1,69 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; +import com.fr.chartx.data.field.diff.ColumnFieldCollectionWithSeriesValue; +import com.fr.design.chartx.component.AbstractSingleFilterPane; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; + +/** + * Created by Wim on 2019/10/23. + * 饼图、多指针仪表盘 在组合图中 没有分类配置项, 也用这个。 + */ +public class FunnelCellDataFieldsPane extends AbstractCellDataFieldsWithSeriesValuePane { + + private AbstractSingleFilterPane filterPane; + + @Override + protected void initComponents() { + filterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Series"); + } + }; + + JPanel northPane = new JPanel(new BorderLayout(0, 6)); + northPane.add(createCenterPane(), BorderLayout.CENTER); + northPane.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 8)); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + JPanel contentPane = new JPanel(new BorderLayout()); + contentPane.add(new JPanel(), BorderLayout.NORTH); + contentPane.add(filterPane, BorderLayout.CENTER); + this.add(TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), contentPane), BorderLayout.CENTER); + } + + @Override + protected String[] fieldLabels() { + return new String[0]; + } + + @Override + protected TinyFormulaPane[] formulaPanes() { + return new TinyFormulaPane[0]; + } + + @Override + public ColumnFieldCollectionWithSeriesValue updateBean() { + ColumnFieldCollectionWithSeriesValue fieldCollection = new ColumnFieldCollectionWithSeriesValue(); + updateSeriesValuePane(fieldCollection); + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = fieldCollection.getSeriesValueCorrelationDefinition(); + seriesValueCorrelationDefinition.setFilterProperties(filterPane.updateBean()); + return fieldCollection; + } + + @Override + public void populateBean(ColumnFieldCollectionWithSeriesValue ob) { + populateSeriesValuePane(ob); + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = ob.getSeriesValueCorrelationDefinition(); + filterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties()); + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/FunnelDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/FunnelDataSetFieldsPane.java new file mode 100644 index 0000000000..ee15e39450 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/FunnelDataSetFieldsPane.java @@ -0,0 +1,71 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; +import com.fr.chartx.data.field.diff.ColumnFieldCollectionWithSeriesValue; +import com.fr.design.chartx.component.AbstractSingleFilterPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.JSeparator; +import java.awt.BorderLayout; + +/** + * Created by Wim on 2019/10/23. + * 饼图、多指针仪表盘 在组合图中 没有分类配置项, 也用这个。 + */ +public class FunnelDataSetFieldsPane extends AbstractDataSetFieldsWithSeriesValuePane { + + + private AbstractSingleFilterPane filterPane; + + @Override + protected void initComponents() { + filterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Series"); + } + }; + + JPanel northPane = new JPanel(new BorderLayout(0, 6)); + northPane.add(new JSeparator(), BorderLayout.CENTER); + northPane.add(createCenterPane(), BorderLayout.SOUTH); + northPane.setBorder(BorderFactory.createEmptyBorder(4, 24, 0, 15)); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + JPanel contentPane = new JPanel(new BorderLayout()); + contentPane.add(new JPanel(), BorderLayout.NORTH); + contentPane.add(filterPane, BorderLayout.CENTER); + this.add(TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), contentPane), BorderLayout.CENTER); + } + + @Override + protected String[] fieldLabels() { + return new String[0]; + } + + @Override + protected UIComboBox[] filedComboBoxes() { + return new UIComboBox[0]; + } + + @Override + public ColumnFieldCollectionWithSeriesValue updateBean() { + ColumnFieldCollectionWithSeriesValue collection = new ColumnFieldCollectionWithSeriesValue(); + updateSeriesValuePane(collection); + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = collection.getSeriesValueCorrelationDefinition(); + seriesValueCorrelationDefinition.setFilterProperties(filterPane.updateBean()); + return collection; + } + + @Override + public void populateBean(ColumnFieldCollectionWithSeriesValue ob) { + populateSeriesValuePane(ob); + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = ob.getSeriesValueCorrelationDefinition(); + filterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/GaugeCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/GaugeCellDataFieldsPane.java new file mode 100644 index 0000000000..f93cf0effa --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/GaugeCellDataFieldsPane.java @@ -0,0 +1,82 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.GaugeColumnFieldCollection; +import com.fr.design.chartx.component.AbstractSingleFilterPane; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; + +/** + * Created by Wim on 2019/11/07. + */ +public class GaugeCellDataFieldsPane extends AbstractCellDataFieldsPane { + + private TinyFormulaPane category; + private TinyFormulaPane value; + private AbstractSingleFilterPane filterPane; + + @Override + protected void initComponents() { + category = new TinyFormulaPane(); + value = new TinyFormulaPane(); + + filterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Category"); + } + }; + + JPanel northPane = new JPanel(new BorderLayout(0, 6)); + northPane.add(createCenterPane(), BorderLayout.CENTER); + northPane.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 15)); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + JPanel contentPane = new JPanel(new BorderLayout()); + contentPane.add(new JPanel(), BorderLayout.NORTH); + contentPane.add(filterPane, BorderLayout.CENTER); + this.add(TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), contentPane), BorderLayout.CENTER); + } + + @Override + protected JPanel createSouthPane() { + return filterPane; + } + + @Override + protected String[] fieldLabels() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Style_Format_Category_Name"), + Toolkit.i18nText("Fine-Design_Chart_Pointer_Value") + }; + } + + @Override + protected TinyFormulaPane[] formulaPanes() { + return new TinyFormulaPane[]{ + category, value + }; + } + + @Override + public GaugeColumnFieldCollection updateBean() { + GaugeColumnFieldCollection gauge = new GaugeColumnFieldCollection(); + updateField(category, gauge.getCategory()); + updateField(value, gauge.getValue()); + gauge.getCategory().setFilterProperties(filterPane.updateBean()); + return gauge; + } + + @Override + public void populateBean(GaugeColumnFieldCollection ob) { + populateField(category, ob.getCategory()); + populateField(value, ob.getValue()); + filterPane.populateBean(ob.getCategory().getFilterProperties()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/GaugeDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/GaugeDataSetFieldsPane.java new file mode 100644 index 0000000000..2ff333cc79 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/GaugeDataSetFieldsPane.java @@ -0,0 +1,84 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.GaugeColumnFieldCollection; +import com.fr.design.chartx.component.AbstractSingleFilterPane; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.JSeparator; +import java.awt.BorderLayout; + +/** + * Created by Wim on 2019/11/07. + */ +public class GaugeDataSetFieldsPane extends AbstractDataSetFieldsPane { + + private UIComboBox category; + private UIComboBox value; + + private AbstractSingleFilterPane filterPane; + + + @Override + protected void initComponents() { + category = new UIComboBox(); + value = new UIComboBox(); + + filterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Category"); + } + }; + + JPanel northPane = new JPanel(new BorderLayout(0, 6)); + northPane.add(new JSeparator(), BorderLayout.CENTER); + northPane.add(createCenterPane(), BorderLayout.SOUTH); + northPane.setBorder(BorderFactory.createEmptyBorder(4, 24, 0, 15)); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + JPanel contentPane = new JPanel(new BorderLayout()); + contentPane.add(new JPanel(), BorderLayout.NORTH); + contentPane.add(filterPane, BorderLayout.CENTER); + this.add(TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), contentPane), BorderLayout.CENTER); + + } + + @Override + protected String[] fieldLabels() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Style_Format_Category_Name"), + Toolkit.i18nText("Fine-Design_Chart_Pointer_Value") + }; + } + + @Override + protected UIComboBox[] filedComboBoxes() { + return new UIComboBox[]{ + category, value + }; + } + + @Override + public GaugeColumnFieldCollection updateBean() { + GaugeColumnFieldCollection gauge = new GaugeColumnFieldCollection(); + updateField(category, gauge.getCategory()); + updateField(value, gauge.getValue()); + gauge.getCategory().setFilterProperties(filterPane.updateBean()); + return gauge; + } + + @Override + public void populateBean(GaugeColumnFieldCollection ob) { + populateField(category, ob.getCategory()); + populateField(value, ob.getValue()); + filterPane.populateBean(ob.getCategory().getFilterProperties()); + } + + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/LineMapCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/LineMapCellDataFieldsPane.java new file mode 100644 index 0000000000..7a321f0bec --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/LineMapCellDataFieldsPane.java @@ -0,0 +1,64 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.LineMapColumnFieldCollection; +import com.fr.design.chartx.data.map.LineMapAreaLngLatPaneWithTinyFormula; +import com.fr.design.formula.TinyFormulaPane; + +import javax.swing.JPanel; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2019/11/11 + */ +public class LineMapCellDataFieldsPane extends AbstractCellDataFieldsWithSeriesValuePane { + + private LineMapAreaLngLatPaneWithTinyFormula areaLngLatPane; + + private TinyFormulaPane lineName; + + @Override + protected JPanel createNorthPane() { + if (areaLngLatPane == null) { + areaLngLatPane = new LineMapAreaLngLatPaneWithTinyFormula(); + } + return areaLngLatPane; + } + + @Override + protected String[] fieldLabels() { + return new String[]{ + "lineName" + }; + } + + @Override + protected TinyFormulaPane[] formulaPanes() { + if (lineName == null) { + lineName = new TinyFormulaPane(); + } + return new TinyFormulaPane[]{ + lineName + }; + } + + @Override + public void populateBean(LineMapColumnFieldCollection ob) { + areaLngLatPane.populate(ob); + + populateField(lineName, ob.getLineName()); + + populateSeriesValuePane(ob); + } + + @Override + public LineMapColumnFieldCollection updateBean() { + LineMapColumnFieldCollection fieldCollection = new LineMapColumnFieldCollection(); + areaLngLatPane.update(fieldCollection); + + updateField(lineName, fieldCollection.getLineName()); + + updateSeriesValuePane(fieldCollection); + return fieldCollection; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/LineMapDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/LineMapDataSetFieldsPane.java new file mode 100644 index 0000000000..b1a0587830 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/LineMapDataSetFieldsPane.java @@ -0,0 +1,61 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.LineMapColumnFieldCollection; +import com.fr.design.chartx.data.map.LineMapAreaLngLatPaneWithComboBox; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.third.jodd.util.ArraysUtil; + +import javax.swing.JPanel; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2019/11/11 + */ +public class LineMapDataSetFieldsPane extends MapDataSetFieldsPane { + private LineMapAreaLngLatPaneWithComboBox areaLngLatPane; + + private UIComboBox lineName; + + @Override + protected JPanel createNorthPane() { + if (areaLngLatPane == null) { + areaLngLatPane = new LineMapAreaLngLatPaneWithComboBox(this); + } + return areaLngLatPane; + } + + @Override + protected String[] fieldLabels() { + return new String[]{ + "lineName" + }; + } + + @Override + protected UIComboBox[] filedComboBoxes() { + if (lineName == null) { + lineName = new UIComboBox(); + } + UIComboBox[] result = areaLngLatPane.allFieldComboBox(); + return ArraysUtil.join(new UIComboBox[]{ + lineName + }, result); + } + + @Override + public void populateBean(LineMapColumnFieldCollection ob) { + areaLngLatPane.populate(ob); + populateField(lineName, ob.getLineName()); + populateSeriesValuePane(ob); + } + + @Override + public LineMapColumnFieldCollection updateBean() { + LineMapColumnFieldCollection columnFieldCollection = new LineMapColumnFieldCollection(); + areaLngLatPane.update(columnFieldCollection); + updateField(lineName, columnFieldCollection.getLineName()); + updateSeriesValuePane(columnFieldCollection); + return columnFieldCollection; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MapDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MapDataSetFieldsPane.java new file mode 100644 index 0000000000..1b6c6f9be0 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MapDataSetFieldsPane.java @@ -0,0 +1,92 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.base.BaseUtils; +import com.fr.base.Utils; +import com.fr.chartx.TwoTuple; +import com.fr.chartx.data.field.diff.ColumnFieldCollectionWithSeriesValue; +import com.fr.design.chartx.component.MapAreaMatchPane; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionListener; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.plugin.chart.map.data.MapMatchResult; +import com.fr.plugin.chart.map.VanChartMapPlot; +import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; +import com.fr.plugin.chart.vanchart.VanChart; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.tree.DefaultMutableTreeNode; +import java.util.Set; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-12-25 + */ +public abstract class MapDataSetFieldsPane extends AbstractDataSetFieldsWithSeriesValuePane { + + private VanChart chart; + + //钻取地图有层级,默认-1代表无层级关系 + private int level = ChartGEOJSONHelper.DEFAULT_LEVEL; + + public int getLevel() { + return level; + } + + public void setLevel(int level) { + this.level = level; + } + + public void setChart(VanChart chart) { + this.chart = chart; + } + + public VanChart getChart() { + return chart; + } + + public JPanel createAreaPanel(final UIComboBox areaBox) { + JPanel areaPanel = new JPanel(new BorderLayout(10, 0)); + areaBox.setPreferredSize(new Dimension(91, 20)); + areaPanel.add(areaBox, BorderLayout.WEST); + UIButton uiButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/config.png")); + uiButton.addActionListener(new ActionListener() { + private TwoTuple> treeNodeAndItems; + + @Override + public void actionPerformed(ActionEvent e) { + VanChartMapPlot plot = chart.getPlot(); + if (treeNodeAndItems == null) { + treeNodeAndItems = ChartGEOJSONHelper.getTreeNodeAndItems(plot.getGeoUrl(), level, plot.getMapType()); + } + final MapAreaMatchPane pane = new MapAreaMatchPane(treeNodeAndItems); + + String nameTable = getTableName(); + final MapMatchResult matchResult = plot.getMatchResult(level); + + pane.populateBean(matchResult, nameTable, Utils.objectToString(areaBox.getSelectedItem())); + BasicDialog dialog = pane.showWindow(new JFrame()); + dialog.addDialogActionListener(new DialogActionListener() { + @Override + public void doOk() { + pane.updateBean(matchResult); + } + + @Override + public void doCancel() { + + } + }); + dialog.setVisible(true); + } + }); + areaPanel.add(uiButton, BorderLayout.EAST); + return areaPanel; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java index 3645a08db7..72236f5684 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java @@ -1,15 +1,15 @@ package com.fr.design.chartx.fields.diff; import com.fr.chartx.data.field.ColumnField; -import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; -import com.fr.design.chartx.component.AbstractSingleFilterPane; +import com.fr.design.chartx.component.CategorySeriesFilterPane; import com.fr.design.chartx.component.MultiTinyFormulaPane; import com.fr.design.formula.TinyFormulaPane; -import com.fr.van.chart.map.designer.VanChartGroupPane; +import javax.swing.BorderFactory; import javax.swing.JPanel; import java.util.List; +import java.awt.BorderLayout; /** * Created by shine on 2019/4/12. @@ -18,43 +18,21 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS private MultiTinyFormulaPane multiCategoryPane; - private AbstractSingleFilterPane seriesFilterPane; - private AbstractSingleFilterPane categoryFilterPane; - - private void createMultiFormulaPane() { - if (multiCategoryPane == null) { - multiCategoryPane = new MultiTinyFormulaPane(); - } - } - - @Override - protected JPanel createNorthPane() { - - createMultiFormulaPane(); - - return multiCategoryPane; - } + private CategorySeriesFilterPane filterPane; @Override - protected JPanel createSouthPane() { - if (seriesFilterPane == null) { - seriesFilterPane = new AbstractSingleFilterPane() { - @Override - public String title4PopupWindow() { - //todo@shinerefactor - return "series"; - } - }; - categoryFilterPane = new AbstractSingleFilterPane() { - @Override - public String title4PopupWindow() { - return "category"; - } - }; - } - return new VanChartGroupPane(new String[]{seriesFilterPane.title4PopupWindow(), categoryFilterPane.title4PopupWindow()} - , new JPanel[]{seriesFilterPane, categoryFilterPane}) { - }; + protected void initComponents() { + multiCategoryPane = new MultiTinyFormulaPane(); + filterPane = new CategorySeriesFilterPane(); + + JPanel northPane = new JPanel(new BorderLayout(0, 6)); + northPane.add(multiCategoryPane, BorderLayout.NORTH); + northPane.add(createCenterPane(), BorderLayout.CENTER); + northPane.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 8)); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + this.add(filterPane, BorderLayout.CENTER); } @Override @@ -64,9 +42,6 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS @Override protected TinyFormulaPane[] formulaPanes() { - - createMultiFormulaPane(); - List list = multiCategoryPane.componentList(); return list.toArray(new TinyFormulaPane[list.size()]); } @@ -80,15 +55,7 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS populateSeriesValuePane(multiCategoryColumnFieldCollection); - SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = multiCategoryColumnFieldCollection.getSeriesValueCorrelationDefinition(); - if (seriesValueCorrelationDefinition != null) { - seriesFilterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties()); - - } - - if (categoryList != null && !categoryList.isEmpty()) { - categoryFilterPane.populateBean(categoryList.get(0).getFilterProperties()); - } + filterPane.populateMultiCategoryFieldCollection(multiCategoryColumnFieldCollection); } @Override @@ -101,15 +68,12 @@ public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithS updateSeriesValuePane(fieldCollection); - SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = fieldCollection.getSeriesValueCorrelationDefinition(); - if (seriesValueCorrelationDefinition != null) { - seriesValueCorrelationDefinition.setFilterProperties(seriesFilterPane.updateBean()); - } - - if (categoryList != null && !categoryList.isEmpty()) { - categoryList.get(0).setFilterProperties(categoryFilterPane.updateBean()); - } + filterPane.updateMultiCategoryFieldCollection(fieldCollection); return fieldCollection; } -} + + public void setCategoryAxis(boolean categoryAxis){ + multiCategoryPane.setCategoryAxis(categoryAxis); + } +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java index 5b18d8ae83..cba3807a92 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java @@ -1,15 +1,16 @@ package com.fr.design.chartx.fields.diff; import com.fr.chartx.data.field.ColumnField; -import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; -import com.fr.design.chartx.component.AbstractSingleFilterPane; +import com.fr.design.chartx.component.CategorySeriesFilterPane; import com.fr.design.chartx.component.MultiComboBoxPane; import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.van.chart.map.designer.VanChartGroupPane; +import javax.swing.BorderFactory; import javax.swing.JPanel; +import javax.swing.JSeparator; import java.util.List; +import java.awt.BorderLayout; /** @@ -19,8 +20,23 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer private MultiComboBoxPane multiCategoryPane; - private AbstractSingleFilterPane seriesFilterPane; - private AbstractSingleFilterPane categoryFilterPane; + private CategorySeriesFilterPane filterPane; + + @Override + protected void initComponents() { + multiCategoryPane = new MultiComboBoxPane(); + filterPane = new CategorySeriesFilterPane(); + + JPanel northPane = new JPanel(new BorderLayout(0, 6)); + northPane.add(multiCategoryPane, BorderLayout.NORTH); + northPane.add(new JSeparator(), BorderLayout.CENTER); + northPane.add(createCenterPane(), BorderLayout.SOUTH); + northPane.setBorder(BorderFactory.createEmptyBorder(4, 24, 0, 15)); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + this.add(filterPane, BorderLayout.CENTER); + } @Override protected String[] fieldLabels() { @@ -29,42 +45,14 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer @Override protected UIComboBox[] filedComboBoxes() { - List list = initMultiCategoryPane().componentList(); + List list = multiCategoryPane.componentList(); return list.toArray(new UIComboBox[list.size()]); } - private MultiComboBoxPane initMultiCategoryPane() { - if (multiCategoryPane == null) { - multiCategoryPane = new MultiComboBoxPane(); - } - return multiCategoryPane; - } - @Override - protected JPanel createNorthPane() { - return initMultiCategoryPane(); - } - - @Override - protected JPanel createSouthPane() { - if (seriesFilterPane == null) { - seriesFilterPane = new AbstractSingleFilterPane() { - @Override - public String title4PopupWindow() { - //todo@shinerefactor - return "series"; - } - }; - categoryFilterPane = new AbstractSingleFilterPane() { - @Override - public String title4PopupWindow() { - return "category"; - } - }; - } - return new VanChartGroupPane(new String[]{seriesFilterPane.title4PopupWindow(), categoryFilterPane.title4PopupWindow()} - , new JPanel[]{seriesFilterPane, categoryFilterPane}) { - }; + public void checkBoxUse(boolean hasUse) { + super.checkBoxUse(hasUse); + multiCategoryPane.checkEnable(hasUse); } @Override @@ -81,15 +69,7 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer populateSeriesValuePane(multiCategoryColumnFieldCollection); - SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = multiCategoryColumnFieldCollection.getSeriesValueCorrelationDefinition(); - if (seriesValueCorrelationDefinition != null) { - seriesFilterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties()); - - } - - if (categoryList != null && !categoryList.isEmpty()) { - categoryFilterPane.populateBean(categoryList.get(0).getFilterProperties()); - } + filterPane.populateMultiCategoryFieldCollection(multiCategoryColumnFieldCollection); } @Override @@ -102,15 +82,12 @@ public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSer updateSeriesValuePane(columnFieldCollection); - SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = columnFieldCollection.getSeriesValueCorrelationDefinition(); - if (seriesValueCorrelationDefinition != null) { - seriesValueCorrelationDefinition.setFilterProperties(seriesFilterPane.updateBean()); - } - - if (categoryList != null && !categoryList.isEmpty()) { - categoryList.get(0).setFilterProperties(categoryFilterPane.updateBean()); - } + filterPane.updateMultiCategoryFieldCollection(columnFieldCollection); return columnFieldCollection; } + + public void setCategoryAxis(boolean categoryAxis){ + multiCategoryPane.setCategoryAxis(categoryAxis); + } } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java index 950f49401a..32ab6e604c 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java @@ -4,10 +4,19 @@ import com.fr.chartx.data.field.diff.MultiPieColumnFieldCollection; import com.fr.design.chartx.component.MultiTinyFormulaPaneWithUISpinner; import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import javax.swing.BorderFactory; import javax.swing.JPanel; +import javax.swing.JSeparator; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; /** * Created by shine on 2019/6/18. @@ -30,7 +39,18 @@ public class MultiPieCellDataFieldsPane extends AbstractCellDataFieldsPane { + private PointMapAreaLngLatPaneWithTinyFormula areaLngLatPane; + + @Override + protected JPanel createNorthPane() { + if (areaLngLatPane == null) { + areaLngLatPane = new PointMapAreaLngLatPaneWithTinyFormula(); + } + return areaLngLatPane; + } + + @Override + protected String[] fieldLabels() { + return new String[0]; + } + + @Override + protected TinyFormulaPane[] formulaPanes() { + return new TinyFormulaPane[0]; + } + + @Override + public void populateBean(PointMapColumnFieldCollection ob) { + areaLngLatPane.populate(ob); + populateSeriesValuePane(ob); + } + + @Override + public PointMapColumnFieldCollection updateBean() { + PointMapColumnFieldCollection fieldCollection = new PointMapColumnFieldCollection(); + areaLngLatPane.update(fieldCollection); + updateSeriesValuePane(fieldCollection); + return fieldCollection; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/PointMapDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/PointMapDataSetFieldsPane.java new file mode 100644 index 0000000000..220f840d33 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/PointMapDataSetFieldsPane.java @@ -0,0 +1,51 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.PointMapColumnFieldCollection; +import com.fr.design.chartx.data.map.PointMapAreaLngLatPaneWithComboBox; +import com.fr.design.gui.icombobox.UIComboBox; + +import javax.swing.JPanel; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2019/11/8 + */ +public class PointMapDataSetFieldsPane extends MapDataSetFieldsPane { + private PointMapAreaLngLatPaneWithComboBox areaLngLatPane; + + @Override + protected JPanel createNorthPane() { + if (areaLngLatPane == null) { + areaLngLatPane = new PointMapAreaLngLatPaneWithComboBox(this); + } + return areaLngLatPane; + } + + @Override + protected String[] fieldLabels() { + return new String[0]; + } + + @Override + protected UIComboBox[] filedComboBoxes() { + if (areaLngLatPane == null) { + areaLngLatPane = new PointMapAreaLngLatPaneWithComboBox(this); + } + return areaLngLatPane.allFieldComboBox(); + } + + @Override + public void populateBean(PointMapColumnFieldCollection ob) { + areaLngLatPane.populate(ob); + populateSeriesValuePane(ob); + } + + @Override + public PointMapColumnFieldCollection updateBean() { + PointMapColumnFieldCollection fieldCollection = new PointMapColumnFieldCollection(); + areaLngLatPane.update(fieldCollection); + updateSeriesValuePane(fieldCollection); + return fieldCollection; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/ScatterCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/ScatterCellDataFieldsPane.java new file mode 100644 index 0000000000..06a177ea9a --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/ScatterCellDataFieldsPane.java @@ -0,0 +1,88 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.BubbleColumnFieldCollection; +import com.fr.design.chartx.component.AbstractSingleFilterPane; +import com.fr.design.chartx.component.CellDataSeriesXYValueCorrelationPane; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.JPanel; +import java.awt.BorderLayout; + +/** + * Created by Wim on 2019/11/04. + */ +public class ScatterCellDataFieldsPane extends AbstractCellDataFieldsPane { + + private CellDataSeriesXYValueCorrelationPane seriesXYValueCorrelationPane; + private AbstractSingleFilterPane filterPane; + + + public CellDataSeriesXYValueCorrelationPane getSeriesXYValueCorrelationPane() { + return seriesXYValueCorrelationPane; + } + + public void setSeriesXYValueCorrelationPane(CellDataSeriesXYValueCorrelationPane seriesXYValueCorrelationPane) { + this.seriesXYValueCorrelationPane = seriesXYValueCorrelationPane; + } + + @Override + protected void initComponents() { + filterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Series"); + } + }; + + this.setLayout(new BorderLayout(0, 6)); + this.add(createCenterPane(), BorderLayout.NORTH); + JPanel contentPane = new JPanel(new BorderLayout()); + contentPane.add(new JPanel(), BorderLayout.NORTH); + contentPane.add(filterPane, BorderLayout.CENTER); + this.add(TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), contentPane), BorderLayout.CENTER); + + } + + @Override + protected JPanel createCenterPane() { + JPanel normalCenter = super.createCenterPane(); + seriesXYValueCorrelationPane = new CellDataSeriesXYValueCorrelationPane(); + + if (normalCenter != null) { + JPanel panel = new JPanel(new BorderLayout(0, 6)); + panel.add(normalCenter, BorderLayout.NORTH); + panel.add(seriesXYValueCorrelationPane, BorderLayout.CENTER); + return panel; + } else { + return seriesXYValueCorrelationPane; + } + + } + + @Override + protected String[] fieldLabels() { + return new String[0]; + } + + @Override + protected TinyFormulaPane[] formulaPanes() { + return new TinyFormulaPane[0]; + } + + @Override + public BubbleColumnFieldCollection updateBean() { + BubbleColumnFieldCollection collection = new BubbleColumnFieldCollection(); + seriesXYValueCorrelationPane.updateBean(collection); + collection.setFilterProperties(filterPane.updateBean()); + return collection; + } + + @Override + public void populateBean(BubbleColumnFieldCollection ob) { + seriesXYValueCorrelationPane.populateBean(ob); + filterPane.populateBean(ob.getFilterProperties()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/ScatterDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/ScatterDataSetFieldsPane.java new file mode 100644 index 0000000000..c5f4fdc3d8 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/ScatterDataSetFieldsPane.java @@ -0,0 +1,100 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.BubbleColumnField; +import com.fr.chartx.data.field.diff.BubbleColumnFieldCollection; +import com.fr.design.chartx.component.AbstractSingleFilterPane; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.i18n.Toolkit; +import com.fr.extended.chart.UIComboBoxWithNone; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.JSeparator; +import java.awt.BorderLayout; + +/** + * Created by Wim on 2019/10/29. + */ +public class ScatterDataSetFieldsPane extends AbstractDataSetFieldsPane { + + private UIComboBoxWithNone series; + private UIComboBox xField; + private UIComboBox yField; + private UIComboBoxWithNone size; + + private AbstractSingleFilterPane filterPane; + + + @Override + protected void initComponents() { + + series = new UIComboBoxWithNone(); + xField = new UIComboBox(); + yField = new UIComboBox(); + size = new UIComboBoxWithNone(); + + filterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Series"); + } + }; + + JPanel northPane = new JPanel(new BorderLayout(0, 6)); + northPane.add(new JSeparator(), BorderLayout.CENTER); + northPane.add(createCenterPane(), BorderLayout.SOUTH); + northPane.setBorder(BorderFactory.createEmptyBorder(4, 24, 0, 15)); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + JPanel contentPane = new JPanel(new BorderLayout()); + contentPane.add(new JPanel(), BorderLayout.NORTH); + contentPane.add(filterPane, BorderLayout.CENTER); + this.add(TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), contentPane), BorderLayout.CENTER); + } + + @Override + protected UIComboBox[] filedComboBoxes() { + return new UIComboBox[]{ + series, xField, yField, size + }; + } + + @Override + protected String[] fieldLabels() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Series_Name"), + "x", + "y", + Toolkit.i18nText("Fine-Design_Chart_Use_Value") + }; + } + + @Override + public BubbleColumnFieldCollection updateBean() { + BubbleColumnFieldCollection collection = new BubbleColumnFieldCollection(); + BubbleColumnField field = new BubbleColumnField(); + updateField(series, field.getSeriesName()); + updateField(xField, field.getXField()); + updateField(yField, field.getYField()); + updateField(size, field.getSizeField()); + collection.setFilterProperties(filterPane.updateBean()); + collection.add(field); + return collection; + } + + @Override + public void populateBean(BubbleColumnFieldCollection ob) { + if (ob.getList().isEmpty()){ + return; + } + BubbleColumnField field = ob.getBubbleColumnField(0); + populateField(series, field.getSeriesName()); + populateField(xField, field.getXField()); + populateField(yField, field.getYField()); + populateField(size, field.getSizeField()); + filterPane.populateBean(ob.getFilterProperties()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/SingleCategoryCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/SingleCategoryCellDataFieldsPane.java new file mode 100644 index 0000000000..dc90ee09f0 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/SingleCategoryCellDataFieldsPane.java @@ -0,0 +1,84 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; +import com.fr.design.chartx.component.CategorySeriesFilterPane; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.ilable.BoldFontTextLabel; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-10-24 + */ +public class SingleCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithSeriesValuePane { + + private TinyFormulaPane categoryPane; + + private CategorySeriesFilterPane filterPane; + + @Override + protected void initComponents() { + categoryPane = new TinyFormulaPane(); + filterPane = new CategorySeriesFilterPane(); + + UILabel label = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Style_Category")); + label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); + + JPanel northPane = new JPanel(new BorderLayout(0, 6)); + northPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{categoryPane, null, null, label, null}), BorderLayout.NORTH); + northPane.add(createCenterPane(), BorderLayout.CENTER); + northPane.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 8)); + + this.setLayout(new BorderLayout(0, 6)); + this.add(northPane, BorderLayout.NORTH); + this.add(filterPane, BorderLayout.CENTER); + } + + @Override + protected String[] fieldLabels() { + return new String[0]; + } + + @Override + protected TinyFormulaPane[] formulaPanes() { + return new TinyFormulaPane[]{categoryPane}; + } + + @Override + public void populateBean(MultiCategoryColumnFieldCollection fieldCollection) { + if (fieldCollection.getCategoryList().size() > 0) { + populateField(categoryPane, fieldCollection.getCategoryList().get(0)); + } + + populateSeriesValuePane(fieldCollection); + + filterPane.populateMultiCategoryFieldCollection(fieldCollection); + } + + @Override + public MultiCategoryColumnFieldCollection updateBean() { + + MultiCategoryColumnFieldCollection fieldCollection = new MultiCategoryColumnFieldCollection(); + fieldCollection.getCategoryList().add(new ColumnField()); + + updateField(categoryPane, fieldCollection.getCategoryList().get(0)); + + updateSeriesValuePane(fieldCollection); + + filterPane.updateMultiCategoryFieldCollection(fieldCollection); + + return fieldCollection; + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/SingleCategoryDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/SingleCategoryDataSetFieldsPane.java new file mode 100644 index 0000000000..9eb6d94e2d --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/SingleCategoryDataSetFieldsPane.java @@ -0,0 +1,108 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; +import com.fr.design.chartx.component.CategorySeriesFilterPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.BoldFontTextLabel; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.extended.chart.UIComboBoxWithNone; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.JSeparator; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-10-24 + */ +public class SingleCategoryDataSetFieldsPane + extends AbstractDataSetFieldsWithSeriesValuePane { + + private static final int HGAP = 0; + private static final int VGAP = 6; + private static final int TOP = 4; + private static final int LEFT = 24; + private static final int BOTTOM = 0; + private static final int RIGHT = 15; + + private UIComboBox categoryPane; + + private CategorySeriesFilterPane filterPane; + + + public SingleCategoryDataSetFieldsPane() { + } + + public SingleCategoryDataSetFieldsPane(UIComboBox categoryPane, CategorySeriesFilterPane filterPane) { + this.categoryPane = categoryPane; + this.filterPane = filterPane; + } + + @Override + protected void initComponents() { + categoryPane = new UIComboBoxWithNone(); + filterPane = new CategorySeriesFilterPane(); + + UILabel label = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Style_Category")); + label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); + + JPanel northPane = new JPanel(new BorderLayout(HGAP, VGAP)); + northPane.add(GUICoreUtils.createBorderLayoutPane( + new Component[]{categoryPane, null, null, label, null}), + BorderLayout.NORTH + ); + northPane.add(new JSeparator(), BorderLayout.CENTER); + northPane.add(createCenterPane(), BorderLayout.SOUTH); + northPane.setBorder(BorderFactory.createEmptyBorder(TOP, LEFT, BOTTOM, RIGHT)); + + this.setLayout(new BorderLayout(HGAP, VGAP)); + this.add(northPane, BorderLayout.NORTH); + this.add(filterPane, BorderLayout.CENTER); + } + + @Override + protected String[] fieldLabels() { + return new String[0]; + } + + @Override + protected UIComboBox[] filedComboBoxes() { + return new UIComboBox[]{categoryPane}; + } + + + @Override + public void populateBean(MultiCategoryColumnFieldCollection columnFieldCollection) { + if (columnFieldCollection.getCategoryList().size() > 0) { + populateField(categoryPane, columnFieldCollection.getCategoryList().get(0)); + } + + populateSeriesValuePane(columnFieldCollection); + + filterPane.populateMultiCategoryFieldCollection(columnFieldCollection); + } + + @Override + public MultiCategoryColumnFieldCollection updateBean() { + + MultiCategoryColumnFieldCollection columnFieldCollection = new MultiCategoryColumnFieldCollection(); + columnFieldCollection.getCategoryList().add(new ColumnField()); + + updateField(categoryPane, columnFieldCollection.getCategoryList().get(0)); + + updateSeriesValuePane(columnFieldCollection); + + filterPane.updateMultiCategoryFieldCollection(columnFieldCollection); + + return columnFieldCollection; + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/StructureCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/StructureCellDataFieldsPane.java index 87ff4d3954..b9db310625 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/StructureCellDataFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/StructureCellDataFieldsPane.java @@ -59,7 +59,7 @@ public class StructureCellDataFieldsPane extends AbstractCellDataFieldsPane { @Override public void populateBean(CellDataDefinition ob) { + + if (ob == null || ob.getColumnFieldCollection() == null) { + return; + } + cellDataFieldsPane.populateBean(ob.getColumnFieldCollection()); } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java b/designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java index 98394c31a0..cfb9a2c18a 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java @@ -12,9 +12,9 @@ import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.data.DatabaseTableDataPane; import com.fr.design.utils.gui.UIComponentUtils; +import java.util.List; import java.awt.BorderLayout; import java.awt.Dimension; -import java.util.List; /** * Created by shine on 2019/5/21. @@ -39,7 +39,7 @@ public class DataSetPane extends FurtherBasicBeanPane { tableDataPane = new DatabaseTableDataPane(label) { @Override protected void userEvent() { - refreshBoxList(); + refreshBoxListAndTableName(); checkBoxUse(); } }; @@ -50,6 +50,7 @@ public class DataSetPane extends FurtherBasicBeanPane { this.setLayout(new BorderLayout()); this.add(tableDataPane, BorderLayout.NORTH); this.add(dataSetFieldsPane, BorderLayout.CENTER); + checkBoxUse(); } /** @@ -66,7 +67,7 @@ public class DataSetPane extends FurtherBasicBeanPane { /** * 刷新字段下拉列表 */ - private void refreshBoxList() { + private void refreshBoxListAndTableName() { TableDataWrapper dataWrap = tableDataPane.getTableDataWrapper(); if (dataWrap == null) { @@ -77,6 +78,7 @@ public class DataSetPane extends FurtherBasicBeanPane { if (dataSetFieldsPane != null) { dataSetFieldsPane.refreshBoxListWithSelectTableData(columnNameList); + dataSetFieldsPane.setTableName(dataWrap.getTableDataName()); } } @@ -97,12 +99,17 @@ public class DataSetPane extends FurtherBasicBeanPane { @Override public void populateBean(DataSetDefinition ob) { - refreshBoxList(); - checkBoxUse(); + if (ob == null || ob.getColumnFieldCollection() == null) { + return; + } + + refreshBoxListAndTableName(); tableDataPane.populateBean(ob.getNameTableData()); dataSetFieldsPane.populateBean(ob.getColumnFieldCollection()); + + checkBoxUse(); } @Override diff --git a/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java index a4e6949983..dc4dfc65ad 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java @@ -7,23 +7,24 @@ import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; import com.fr.design.constants.LayoutConstants; import com.fr.design.gui.frpane.UIComboBoxPane; +import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.mainframe.chart.gui.ChartDataPane; -import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.design.i18n.Toolkit; +import com.fr.design.utils.gui.UIComponentUtils; import javax.swing.BorderFactory; import javax.swing.JPanel; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; import java.util.ArrayList; import java.util.List; +import java.awt.BorderLayout; /** * Created by shine on 2019/5/21. */ public class SingleDataPane extends BasicBeanPane { + private static final int TABLE_DATA_LABEL_LINE_WIDTH = 81; + private UIComboBoxPane comboBoxPane; private DataSetPane dataSetPane; @@ -51,11 +52,13 @@ public class SingleDataPane extends BasicBeanPane { protected void initLayout() { this.setLayout(new BorderLayout(LayoutConstants.HGAP_LARGE, 6)); JPanel northPane = new JPanel(new BorderLayout(LayoutConstants.HGAP_LARGE, 0)); + + UILabel label = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Data_Source")); + UIComponentUtils.setPreferedWidth(label, TABLE_DATA_LABEL_LINE_WIDTH); + northPane.add(label,BorderLayout.WEST); northPane.add(jcb, BorderLayout.CENTER); - UILabel label1 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Source")); - 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)); + + northPane.setBorder(BorderFactory.createEmptyBorder(5,24,0,15)); this.add(northPane, BorderLayout.NORTH); this.add(cardPane, BorderLayout.CENTER); @@ -70,7 +73,6 @@ public class SingleDataPane extends BasicBeanPane { this.setLayout(new BorderLayout()); this.add(comboBoxPane, BorderLayout.CENTER); - } @Override 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 a2d824f51c..98ba448d70 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 @@ -6,6 +6,7 @@ import com.fr.chart.chartattr.ChartCollection; import com.fr.chartx.attr.ChartProvider; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.dialog.BasicPane; @@ -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.info.ChartInfoCollector; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.vanchart.VanChart; @@ -26,13 +28,13 @@ 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 { +public class ChartEditPane extends BasicPane implements AttributeChange, Prepare4DataSourceChange, ChartEditPaneProvider { private final static int CHANGE_MIN_TIME = 80; @@ -107,6 +109,9 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 return; } AbstractChartAttrPane selectedPane = paneList.get(tabsHeaderIconPane.getSelectedIndex()); + //图表配置变化,埋点记录 + ChartInfoCollector.getInstance().updateChartPropertyTime(collection.getSelectedChartProvider(ChartProvider.class)); + selectedPane.update(collection); if (!ComparatorUtils.equals(collection, lastCollection)) { @@ -122,7 +127,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error("error in clone ChartEditPane"); } - if(ComparatorUtils.equals(selectedPane.title4PopupWindow(),PaneTitleConstants.CHART_STYLE_TITLE)){ + if (ComparatorUtils.equals(selectedPane.title4PopupWindow(), PaneTitleConstants.CHART_STYLE_TITLE)) { dealWithStyleChange(); } @@ -138,10 +143,11 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 /** * 重新构造面板 + * * @param currentChart 图表 */ public void reLayout(ChartProvider currentChart) { - if(currentChart != null){ + if (currentChart != null) { int chartIndex = getSelectedChartIndex(currentChart); this.removeAll(); this.setLayout(new BorderLayout()); @@ -151,18 +157,18 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 String chartID = currentChart.getID(); boolean isDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartID); - if(isDefault){ + if (isDefault) { paneList.add(dataPane4SupportCell); paneList.add(stylePane); paneList.add(otherPane); this.isDefaultPane = true; - }else{ + } else { ChartDataPane chartDataPane = createChartDataPane(chartID); if (chartDataPane != null) { paneList.add(chartDataPane); } AbstractChartAttrPane[] otherPaneList = ChartTypeInterfaceManager.getInstance().getAttrPaneArray(chartID, listener); - for(int i = 0; i < otherPaneList.length; i++){ + for (int i = 0; i < otherPaneList.length; i++) { otherPaneList[i].addAttributeChangeListener(listener); paneList.add(otherPaneList[i]); } @@ -235,7 +241,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 if (checkNeedsReLayout(chartProvider)) { String chartID = chartProvider.getID(); if ("WaferChipChart".equals(chartID) || "BoxPlotChart".equals(chartID)) { - reLayout((Chart)chartProvider); + reLayout((Chart) chartProvider); } else { reLayout(chartProvider); } @@ -266,10 +272,10 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 public int getSelectedChartIndex(ChartProvider chart) { int index = 0; - if(typePane != null){ + if (typePane != null) { FurtherBasicBeanPane[] paneList = typePane.getPaneList(); - for(; index < paneList.length; index++){ - if(paneList[index].accept(chart)){ + for (; index < paneList.length; index++) { + if (paneList[index].accept(chart)) { return index; } } @@ -279,7 +285,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 //populate的时候看看要不要重构面板 private boolean checkNeedsReLayout(ChartProvider chart) { - if(chart != null){ + if (chart != null) { int lastIndex = typePane.getSelectedIndex(); int currentIndex = getSelectedChartIndex(chart); String chartID = chart.getID(); @@ -292,9 +298,10 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 /** * 当前界面是否是默认的界面 + * * @return 是否是默认的界面 */ - public boolean isDefaultPane(){ + public boolean isDefaultPane() { return this.isDefaultPane; } @@ -326,15 +333,16 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 } } - protected void dealWithStyleChange(){ + protected void dealWithStyleChange() { } /** - *主要用于图表设计器,判断样式改变是否来自工具栏的全局样式按钮 + * 主要用于图表设计器,判断样式改变是否来自工具栏的全局样式按钮 + * * @param isFromToolBar 是否来自工具栏 */ - public void styleChange(boolean isFromToolBar){ + public void styleChange(boolean isFromToolBar) { } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java index cc8a7db137..3de9aaa09a 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChangeConfigPane.java @@ -14,6 +14,7 @@ import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.design.i18n.Toolkit; import com.fr.van.chart.designer.TableLayout4VanChartHelper; @@ -70,7 +71,7 @@ public class ChangeConfigPane extends BasicBeanPane { double[] columnSize = {p, f}; double[] rowSize = {p,p}; Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Change_Style")),configStyleButton}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Change_Style")),configStyleButton}, new Component[]{configPane, null}, }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); @@ -107,19 +108,19 @@ public class ChangeConfigPane extends BasicBeanPane { double[] rowSize = {p, p, p}; timeInterval = new UISpinner(MIN_TIME, MAX_TIME, 1, 0); colorSelectBox4carousel = new ColorSelectBoxWithOutTransparent(WIDTH); - switchStyleGroup = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Show"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Hide")}); + switchStyleGroup = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Show"), Toolkit.i18nText("Fine-Design_Report_Hide")}); Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Arrow_Style")), switchStyleGroup, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Time_Interval")), timeInterval, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Time_Second"))}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background")),colorSelectBox4carousel, null} + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Arrow_Style")), switchStyleGroup, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Time_Interval")), timeInterval, new UILabel(Toolkit.i18nText("Fine-Design_Chart_Time_Second"))}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Background")),colorSelectBox4carousel, null} }; return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); } private JPanel createTitleStylePane() { - final UILabel text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); + final UILabel text = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); styleAttrPane = new ChartTextAttrPane() { protected JPanel getContentPane(JPanel buttonPane) { double p = TableLayout.PREFERRED; @@ -132,7 +133,7 @@ public class ChangeConfigPane extends BasicBeanPane { protected Component[][] getComponents(JPanel buttonPane) { return new Component[][]{ - new Component[]{text, fontNameComboBox}, + new Component[]{text, getFontNameComboBox()}, new Component[]{null, buttonPane} }; } @@ -143,7 +144,7 @@ public class ChangeConfigPane extends BasicBeanPane { private JPanel createButtonBackgroundColorPane(){ colorSelectBox4button = new ColorSelectBoxWithOutTransparent(WIDTH); - return TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"), colorSelectBox4button, EDIT_AREA_WIDTH); + return TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Basic_Background"), colorSelectBox4button, EDIT_AREA_WIDTH); } private JPanel createButtonConfigPane() { @@ -160,8 +161,8 @@ public class ChangeConfigPane extends BasicBeanPane { } private void initButtonGroup() { - configStyleButton = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Button_Style"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Carousel_Style")}); + configStyleButton = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Button_Style"), + Toolkit.i18nText("Fine-Design_Chart_Carousel_Style")}); configStyleButton.setPreferredSize(new Dimension(WIDTH * 2, (int) configStyleButton.getPreferredSize().getHeight())); configStyleButton.addActionListener(new ActionListener() { @Override @@ -227,6 +228,6 @@ public class ChangeConfigPane extends BasicBeanPane { @Override protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Change_Config_Attributes"); + return Toolkit.i18nText("Fine-Design_Chart_Change_Config_Attributes"); } } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java index 5aed1e47d6..ad549c5afd 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java @@ -11,8 +11,8 @@ import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.data.DataContentsPane; import com.fr.design.mainframe.chart.gui.data.NormalChartDataPane; -import javax.swing.*; -import java.awt.*; +import javax.swing.JPanel; +import java.awt.BorderLayout; public class ChartDataPane extends AbstractChartAttrPane { @@ -35,6 +35,7 @@ public class ChartDataPane extends AbstractChartAttrPane { return contentsPane; } + /** * 界面标题 */ 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 8877ed9dac..4d7673b3e7 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 @@ -6,6 +6,7 @@ import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chartx.attr.ChartProvider; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.dialog.DialogActionListener; import com.fr.design.dialog.UIDialog; import com.fr.design.event.UIObserver; @@ -25,6 +26,9 @@ 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; @@ -41,9 +45,6 @@ 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; /** * 图表 类型 增删 控制按钮界面. @@ -151,6 +152,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen try { ChartProvider newChart = (ChartProvider) chart.clone(); editingCollection.addNamedChart(name, newChart); + ChartInfoCollector.getInstance().collection(newChart, null); } catch (CloneNotSupportedException e1) { FineLoggerFactory.getLogger().error("Error in Clone"); } @@ -438,6 +440,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen private void changeChartName(String name) { this.setText(name); + this.setToolTipText(name); buttonName = name; } @@ -500,6 +503,13 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen if (this.isSelected()) { indexList.get(0).setSelected(true); changeCollectionSelected(indexList.get(0).getButtonName()); + } else {//删除的tab非选中状态, 原为选中状态的tab保持选中不变 + for (ChartChangeButton button : indexList) { + if (button.isSelected()) { + changeCollectionSelected(button.getButtonName()); + break; + } + } } } 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 3740e3e121..6c7edc2d2f 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 @@ -294,13 +294,14 @@ public class ChartTypePane extends AbstractChartAttrPane{ * @param collection */ public void reLayoutEditPane(String lastPlotID, ChartCollection collection){ + if (editPane == null) { + return; + } ChartProvider chart = collection.getSelectedChartProvider(ChartProvider.class); String plotID = chart.getID(); boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); - if (editPane != null && editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, plotID))){ + if (editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, plotID))) { editPane.reLayout(chart); - }else { - throw new IllegalArgumentException("editPane can not be null."); } } 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 1277ae4632..42cf782c35 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 @@ -8,16 +8,15 @@ 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.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; /** * 一般数据界面 @@ -133,6 +132,14 @@ public class NormalChartDataPane extends DataContentsPane { tableDataPane.checkBoxUse(); } + /** + * 钻取地图需要同时更新层级 + */ + public void populate(ChartCollection collection, int level) { + populate(collection); + tableDataPane.refreshLevel(level); + } + /** * 保存 数据界面内容 */ diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java index 7f22a03a6b..8863977740 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java @@ -75,6 +75,7 @@ public class TableDataPane extends FurtherBasicBeanPane{ } if(dataContentPane != null) { dataContentPane.onSelectTableData(dataWrap); + dataContentPane.setTableName(dataWrap.getTableDataName()); } } @@ -124,6 +125,11 @@ public class TableDataPane extends FurtherBasicBeanPane{ add(dataContentPane, BorderLayout.CENTER); } } + + public void refreshLevel(int level){ + dataContentPane.refreshLevel(level); + } + /** * 更新界面属性 */ diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java index df5d99fbdb..710b2a4218 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java @@ -6,16 +6,26 @@ import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.gui.icombobox.UIComboBox; import javax.swing.JSeparator; +import java.util.List; import java.awt.Dimension; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; -import java.util.List; public abstract class AbstractTableDataContentPane extends BasicBeanPane{ protected static final double COMPONENT_WIDTH = 124; private boolean isNeedSummaryCaculateMethod = true; + + public String tableName; + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } public abstract void updateBean(ChartCollection ob); @@ -129,4 +139,8 @@ public abstract class AbstractTableDataContentPane extends BasicBeanPane { this.add(cardPane, BorderLayout.CENTER); dataScreeningPane = new ChartDataFilterPane(this.initplot, parent); JPanel panel = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), 290, 24, dataScreeningPane); - panel.setBorder(BorderFactory.createEmptyBorder(0,5,0,5)); + panel.setBorder(BorderFactory.createEmptyBorder(0,10,0,10)); dataScreeningPane.setBorder(BorderFactory.createEmptyBorder(10,5,0,5)); this.add(panel, BorderLayout.SOUTH); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoColorPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoColorPane.java index 820f0c3358..177168cd77 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoColorPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoColorPane.java @@ -4,19 +4,17 @@ package com.fr.design.mainframe.chart.gui.style; -import com.fr.base.BaseUtils; -import com.fr.base.Utils; 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.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.general.FRFont; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.FRFont; +import com.fr.general.GeneralUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; /** * Created by IntelliJ IDEA. @@ -25,34 +23,27 @@ import java.awt.*; * Date: 14-9-11 * Time: 上午11:27 */ -public class ChartTextAttrNoColorPane extends ChartTextAttrPane{ +public class ChartTextAttrNoColorPane extends ChartTextAttrPane { - public ChartTextAttrNoColorPane() { - super(); + public ChartTextAttrNoColorPane() { + super(); } protected void initComponents() { - fontColor = new UIColorButton(); - 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")); - double p = TableLayout.PREFERRED; double f = TableLayout.FILL; Component[] components1 = new Component[]{ - italic, bold + getItalic(), getBold() }; JPanel buttonPane = new JPanel(new BorderLayout()); - buttonPane.add(fontSizeComboBox, BorderLayout.CENTER); + buttonPane.add(getFontSizeComboBox(), BorderLayout.CENTER); buttonPane.add(GUICoreUtils.createFlowPane(components1, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE), BorderLayout.EAST); - double[] columnSize = {f}; double[] rowSize = {p, p}; Component[][] components = new Component[][]{ - new Component[]{fontNameComboBox}, + new Component[]{getFontNameComboBox()}, new Component[]{buttonPane} }; @@ -62,20 +53,9 @@ public class ChartTextAttrNoColorPane extends ChartTextAttrPane{ populate(FRFont.getInstance()); } - /** - * 更新字体 - * @return 字体 - */ public FRFont updateFRFont() { - 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 FRFont.getInstance(Utils.objectToString(fontNameComboBox.getSelectedItem()), style, - Float.valueOf(Utils.objectToString(fontSizeComboBox.getSelectedItem()))); + String name = GeneralUtils.objectToString(getFontNameComboBox().getSelectedItem()); + + return FRFont.getInstance(name, updateFontStyle(), updateFontSize()); } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoFontSizePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoFontSizePane.java index e1b17eb156..d04df2f72a 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoFontSizePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoFontSizePane.java @@ -1,47 +1,36 @@ package com.fr.design.mainframe.chart.gui.style; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.FlowLayout; - -import javax.swing.JPanel; - -import com.fr.base.BaseUtils; -import com.fr.base.Utils; 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.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.general.FRFont; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.FRFont; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; /** * 字体格式设置, 无字体大小设置. + * * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2013-1-21 下午03:35:47 */ public class ChartTextAttrNoFontSizePane extends ChartTextAttrPane { - - private static final long serialVersionUID = 4890526255627852602L; - public ChartTextAttrNoFontSizePane() { - super(); - } - - protected void initComponents() { - fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); - fontColor = new UIColorButton(); - 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")); + private static final long serialVersionUID = 4890526255627852602L; + + public ChartTextAttrNoFontSizePane() { + super(); + } + protected void initComponents() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; Component[] components1 = new Component[]{ - fontColor, italic, bold + getFontColor(), getItalic(), getBold() }; JPanel buttonPane = new JPanel(new BorderLayout()); buttonPane.add(GUICoreUtils.createFlowPane(components1, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE), BorderLayout.CENTER); @@ -49,7 +38,7 @@ public class ChartTextAttrNoFontSizePane extends ChartTextAttrPane { double[] columnSize = {f}; double[] rowSize = {p, p}; Component[][] components = new Component[][]{ - new Component[]{fontNameComboBox}, + new Component[]{getFontNameComboBox()}, new Component[]{buttonPane} }; 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 dea30d0c97..a6be91a248 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 @@ -10,10 +10,12 @@ 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.utils.gui.GUICoreUtils; import com.fr.general.FRFont; +import com.fr.general.GeneralUtils; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import javax.swing.JPanel; @@ -25,25 +27,52 @@ import java.awt.Font; public class ChartTextAttrPane extends BasicPane { private static final long serialVersionUID = 6731679928019436869L; - private static final int FONT_START = 6; - private static final int FONT_END = 72; - protected UIComboBox fontNameComboBox; - protected UIComboBox fontSizeComboBox; - protected UIToggleButton bold; - protected UIToggleButton italic; - protected 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] = new Integer(i); + 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; + 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; } } + public ChartTextAttrPane() { + initState(); initComponents(); } + public UIComboBox getFontNameComboBox() { + return fontNameComboBox; + } + + public UIComboBox getFontSizeComboBox() { + return fontSizeComboBox; + } + + public UIToggleButton getBold() { + return bold; + } + + public UIToggleButton getItalic() { + return italic; + } + + public UIColorButton getFontColor() { + return fontColor; + } + + public void setFontColor(UIColorButton fontColor) { + this.fontColor = fontColor; + } + /** * 标题 + * * @return 标题 */ public String title4PopupWindow() { @@ -84,9 +113,7 @@ public class ChartTextAttrPane extends BasicPane { fontNameComboBox.setSelectedItem(frFont.getFamily()); bold.setSelected(frFont.isBold()); italic.setSelected(frFont.isItalic()); - if(fontSizeComboBox != null) { - fontSizeComboBox.setSelectedItem(frFont.getSize()); - } + populateFontSize(frFont); if (fontColor != null) { fontColor.setColor(frFont.getForeground()); } @@ -96,6 +123,12 @@ public class ChartTextAttrPane extends BasicPane { registerAllComboBoxListener(listener); } + protected void populateFontSize(FRFont frFont) { + if (fontSizeComboBox != null) { + fontSizeComboBox.setSelectedItem(frFont.getSize()); + } + } + private void removeAllComboBoxListener() { fontNameComboBox.removeChangeListener(); fontSizeComboBox.removeChangeListener(); @@ -108,9 +141,16 @@ public class ChartTextAttrPane extends BasicPane { /** * 更新字 + * * @return 更新字 */ public FRFont updateFRFont() { + String name = GeneralUtils.objectToString(fontNameComboBox.getSelectedItem()); + + return FRFont.getInstance(name, updateFontStyle(), updateFontSize(), fontColor.getColor()); + } + + protected int updateFontStyle() { int style = Font.PLAIN; if (bold.isSelected() && !italic.isSelected()) { style = Font.BOLD; @@ -119,8 +159,12 @@ public class ChartTextAttrPane extends BasicPane { } else if (bold.isSelected() && italic.isSelected()) { style = 3; } - return FRFont.getInstance(Utils.objectToString(fontNameComboBox.getSelectedItem()), style, - Float.valueOf(Utils.objectToString(fontSizeComboBox.getSelectedItem())), fontColor.getColor()); + + return style; + } + + protected float updateFontSize() { + return Float.parseFloat(GeneralUtils.objectToString(fontSizeComboBox.getSelectedItem())); } public void setEnabled(boolean enabled) { @@ -131,13 +175,23 @@ public class ChartTextAttrPane extends BasicPane { this.italic.setEnabled(enabled); } - protected void initComponents() { + protected Object[] getFontSizeComboBoxModel() { + return FONT_SIZES; + } + + protected void initState() { fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); - fontSizeComboBox = new UIComboBox(Font_Sizes); - fontColor = new UIColorButton(); + fontSizeComboBox = new UIComboBox(getFontSizeComboBoxModel()); 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")); + initFontColorState(); + } + protected void initFontColorState() { + setFontColor(new UIColorButton()); + } + + protected void initComponents() { Component[] components1 = new Component[]{ fontColor, italic, bold }; @@ -151,21 +205,21 @@ public class ChartTextAttrPane extends BasicPane { populate(FRFont.getInstance()); } - protected JPanel getContentPane (JPanel buttonPane) { + protected JPanel getContentPane(JPanel buttonPane) { double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] columnSize = {f,e}; + double[] columnSize = {f, e}; return TableLayout4VanChartHelper.createGapTableLayoutPane(getComponents(buttonPane), getRowSize(), columnSize); } - protected double[] getRowSize () { + protected double[] getRowSize() { double p = TableLayout.PREFERRED; return new double[]{p, p, p}; } protected Component[][] getComponents(JPanel buttonPane) { - UILabel text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); + UILabel text = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); return new Component[][]{ new Component[]{null, null}, new Component[]{text, fontNameComboBox}, diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithAuto.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithAuto.java new file mode 100644 index 0000000000..292d83c9e7 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithAuto.java @@ -0,0 +1,69 @@ +package com.fr.design.mainframe.chart.gui.style; + +import com.fr.chart.base.ChartConstants; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.ibutton.UIColorButtonWithAuto; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.type.FontAutoType; +import com.fr.general.ComparatorUtils; +import com.fr.general.FRFont; +import com.fr.general.GeneralUtils; + +public class ChartTextAttrPaneWithAuto extends ChartTextAttrPane { + + private static final String AUTO = Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto"); + private FontAutoType type; + public static String[] FONT_SIZES_WITH_AUTO = new String[FONT_END - FONT_START + 2]; + + static { + FONT_SIZES_WITH_AUTO[0] = AUTO; + + for (int i = 1; i < FONT_SIZES_WITH_AUTO.length; i++) { + FONT_SIZES_WITH_AUTO[i] = FONT_START + i - 1 + ""; + } + } + + public ChartTextAttrPaneWithAuto(FontAutoType type) { + this.type = type; + initState(); + initComponents(); + } + + private boolean isFontSizeAuto() { + return type == FontAutoType.SIZE || type == FontAutoType.SIZE_AND_COLOR; + } + + private boolean isFontColorAuto() { + return type == FontAutoType.COLOR || type == FontAutoType.SIZE_AND_COLOR; + } + + protected void initFontColorState() { + setFontColor(isFontColorAuto() ? new UIColorButtonWithAuto() : new UIColorButton()); + } + + protected Object[] getFontSizeComboBoxModel() { + return isFontSizeAuto() ? FONT_SIZES_WITH_AUTO : FONT_SIZES; + } + + protected float updateFontSize() { + if (isFontSizeAuto() && ComparatorUtils.equals(getFontSizeComboBox().getSelectedItem(), AUTO)) { + return ChartConstants.AUTO_FONT_SIZE; + } + + return Float.parseFloat(GeneralUtils.objectToString(getFontSizeComboBox().getSelectedItem())); + } + + protected void populateFontSize(FRFont frFont) { + if (getFontSizeComboBox() != null && isFontSizeAuto()) { + if (frFont.getSize() == ChartConstants.AUTO_FONT_SIZE) { + getFontSizeComboBox().setSelectedItem(AUTO); + } else { + getFontSizeComboBox().setSelectedItem(frFont.getSize() + ""); + } + } + + if (getFontSizeComboBox() != null && !isFontSizeAuto()) { + getFontSizeComboBox().setSelectedItem(frFont.getSize()); + } + } +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.java index 77409e4c02..2259389fab 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.java @@ -25,7 +25,7 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { private static final long serialVersionUID = 2595221900000305396L; private static final int GISMAP = 0; - + private UITextField keyInput; public GisMapPlotPane(){ @@ -34,7 +34,7 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { Component[][] components = null; styleList = createStyleList(); - + checkDemosBackground(); JPanel layoutPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(4); @@ -45,7 +45,7 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { tmp.setDemoGroup(styleList.toArray(new ChartSelectDemoPane[styleList.size()])); } } - + keyInput = new UITextField(); double[] columnSize = { f }; @@ -58,16 +58,16 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { new Component[]{keyInput}, }; } - + JPanel panel = TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); this.setLayout(new BorderLayout()); this.add(panel,BorderLayout.CENTER); - + } @Override public void reLayout(String chartID){ - + //do nothing } @Override @@ -93,7 +93,8 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { return ChartConstants.GIS_CHAER; } - protected String[] getTypeLayoutPath() { + @Override + protected String[] getTypeLayoutPath() { return new String[]{"/com/fr/design/images/chart/GisMapPlot/layout/0.png", "/com/fr/design/images/chart/GisMapPlot/layout/1.png", }; @@ -110,6 +111,7 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { /** * 保存界面属性 */ + @Override public void updateBean(Chart chart) { if(needsResetChart(chart)){ resetChart(chart); @@ -126,14 +128,14 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { } else { plot = new GisMapPlot(); } - + try { chart.switchPlot((Plot)plot.clone()); } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error("Error In LineChart"); chart.switchPlot(new GisMapPlot()); } - + plot = (GisMapPlot) chart.getPlot(); boolean index = plot.isGisType(); if(styleList.get(BAIDU).isPressing){ @@ -141,7 +143,7 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { }else{ plot.setGisType(false); } - + if(index != plot.isGisType()){ if(plot.isGisType()){ this.keyInput.setText(plot.getBaiduKey()); @@ -161,6 +163,7 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { /** * 更新界面内容 */ + @Override public void populateBean(Chart chart) { GisMapPlot plot = (GisMapPlot) chart.getPlot(); @@ -168,7 +171,7 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { styleList.get(BAIDU).isPressing = true; styleList.get(GOOGLE).isPressing = false; keyInput.setText(plot.getBaiduKey()); - + }else{ styleList.get(GOOGLE).isPressing = true; styleList.get(BAIDU).isPressing =false; @@ -182,6 +185,7 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { * 界面标题 * @return 标题 */ + @Override public String title4PopupWindow() { return Toolkit.i18nText("Fine-Design_Chart_GIS_Map_OLD"); } @@ -195,7 +199,8 @@ public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { } - public Chart getDefaultChart() { + @Override + public Chart getDefaultChart() { return GisMapIndependentChart.gisChartTypes[0]; } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MapPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MapPlotPane.java index 9880739265..a6c78de948 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MapPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MapPlotPane.java @@ -67,6 +67,15 @@ public class MapPlotPane extends AbstractDeprecatedChartTypePane { return new String[0]; } + public void reLayout(String chartID) { + + } + + @Override + public String getPlotID() { + return ChartConstants.MAP_CHART; + } + /** * 界面标题 * @return 界面标题 diff --git a/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java b/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java index 77347e0fd8..6df855cd70 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java @@ -14,6 +14,11 @@ public class UIComboBoxWithNone extends UIComboBox { return Toolkit.i18nText("Fine-Design_Chart_Use_None"); } + public UIComboBoxWithNone() { + super(); + addDefaultItem(); + } + @Override public void refreshBoxItems(List list) { super.refreshBoxItems(list); diff --git a/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java b/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java index 8849cc17c9..c0fd710680 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java +++ b/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java @@ -2,6 +2,7 @@ package com.fr.van.chart; import com.fr.chart.base.ChartConstants; import com.fr.design.RestartHelper; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginConstants; import com.fr.design.gui.ilable.UILabel; import com.fr.design.utils.gui.GUICoreUtils; @@ -80,7 +81,8 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent { public void installOnline() { - int choose = JOptionPane.showConfirmDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Download_Online_Sources"), null, JOptionPane.YES_NO_OPTION); + int choose = JOptionPane.showConfirmDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Download_Online_Sources"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION); if (choose == JOptionPane.OK_OPTION) { initDialog(); @@ -203,13 +205,14 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent { dialog.dispose(); if (result) { - int choose = JOptionPane.showConfirmDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Work_After_Restart_Designer"), null, JOptionPane.YES_NO_OPTION); + int choose = FineJOptionPane.showConfirmDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Work_After_Restart_Designer"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION); if (choose == JOptionPane.OK_OPTION) { RestartHelper.restart(); } } else { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Dependence_Install_Failed")); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Dependence_Install_Failed")); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java index abf6ca31ce..45beccc7ef 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java @@ -15,15 +15,15 @@ public class VanChartAreaSeriesPane extends VanChartLineSeriesPane { private static final long serialVersionUID = 5497989595104913025L; - public VanChartAreaSeriesPane(ChartStylePane parent, Plot plot){ + public VanChartAreaSeriesPane(ChartStylePane parent, Plot plot) { super(parent, plot); } - protected JPanel getContentInPlotType(){ + protected JPanel getContentInPlotType() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] row = {p,p,p,p,p,p,p}; + double[] row = {p, p, p, p, p, p, p}; double[] col = {f}; Component[][] components = new Component[][]{ @@ -32,6 +32,7 @@ public class VanChartAreaSeriesPane extends VanChartLineSeriesPane { new Component[]{createMarkerPane()}, new Component[]{createAreaFillColorPane()}, new Component[]{createStackedAndAxisPane()}, + //大数据模式 恢复用注释。下面1行删除。 new Component[]{createLargeDataModelPane()}, new Component[]{createTrendLinePane()}, }; 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 0321132b32..63a8e7640c 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 @@ -1,5 +1,6 @@ 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.condition.ConditionAttributesPane; @@ -10,7 +11,9 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.van.chart.column.VanChartColumnConditionPane; import com.fr.van.chart.column.VanChartColumnSeriesPane; +import com.fr.van.chart.designer.other.VanChartInteractivePane; import com.fr.van.chart.designer.other.VanChartOtherPane; +import com.fr.van.chart.designer.other.zoom.ZoomPane; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.vanchart.AbstractMultiCategoryVanChartUI; @@ -57,21 +60,37 @@ public class BarIndependentVanChartInterface extends AbstractMultiCategoryVanCha return new VanChartBarPlotPane(); } - public ConditionAttributesPane getPlotConditionPane(Plot plot){ + public ConditionAttributesPane getPlotConditionPane(Plot plot) { return new VanChartColumnConditionPane(plot); } - public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot){ + public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot) { return new VanChartColumnSeriesPane(parent, plot); } /** * 图表的属性界面数组 + * * @return 属性界面 */ - public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener){ + public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener) { VanChartStylePane stylePane = new VanChartBarStylePane(listener); - VanChartOtherPane otherPane = new VanChartOtherPane(); + VanChartOtherPane otherPane = new VanChartOtherPane() { + @Override + protected BasicBeanPane createInteractivePane() { + return new VanChartInteractivePane() { + @Override + protected ZoomPane createZoomPane() { + return new ZoomPane(); + } + + @Override + protected boolean isCurrentChartSupportLargeDataMode() { + return true; + } + }; + } + }; return new AbstractChartAttrPane[]{stylePane, otherPane}; } 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 8e732b406e..985e811ac2 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 @@ -13,9 +13,12 @@ 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.plugin.chart.base.VanChartConstants; import com.fr.plugin.chart.bubble.VanChartBubblePlot; import com.fr.van.chart.bubble.data.VanChartBubblePlotTableDataContentPane; +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; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; @@ -63,22 +66,23 @@ public class BubbleIndependentVanChartInterface extends AbstractIndependentVanCh public String getIconPath() { return "com/fr/design/images/form/toolbar/bubble.png"; } + @Override - public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot){ + public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot) { return new VanChartBubbleSeriesPane(parent, plot); } @Override - public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent){ - if(((VanChartBubblePlot) plot).isForceBubble()){ + public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { + if (((VanChartBubblePlot) plot).isForceBubble()) { return super.getTableDataSourcePane(plot, parent); } return new VanChartBubblePlotTableDataContentPane(parent); } @Override - public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent){ - if(((VanChartBubblePlot) plot).isForceBubble()){ + public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { + if (((VanChartBubblePlot) plot).isForceBubble()) { return super.getReportDataSourcePane(plot, parent); } return new BubblePlotReportDataContentPane(parent); @@ -86,19 +90,66 @@ public class BubbleIndependentVanChartInterface extends AbstractIndependentVanCh /** * 图表的属性界面数组 + * * @return 属性界面 */ - public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener){ + public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener) { VanChartStylePane stylePane = new VanChartBubbleStylePane(listener); - VanChartOtherPane otherPane = new VanChartOtherPane(){ + VanChartOtherPane otherPane = new VanChartOtherPane() { protected BasicBeanPane createInteractivePane() { - return new VanChartBubbleInteractivePane(); + return new VanChartInteractivePaneWithOutSort() { + + //图表缩放新设计 恢复用注释。删除下面两个方法 getNameArray getValueArray。 + protected String[] getNameArray() { + Plot plot = chart.getPlot(); + if (plot instanceof VanChartBubblePlot && ((VanChartBubblePlot) plot).isForceBubble()) { + return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_XY_Axis"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")}; + } + return super.getNameArray(); + } + + protected String[] getValueArray() { + Plot plot = chart.getPlot(); + if (plot instanceof VanChartBubblePlot && ((VanChartBubblePlot) plot).isForceBubble()) { + return new String[]{VanChartConstants.ZOOM_TYPE_XY, VanChartConstants.ZOOM_TYPE_NONE}; + } + return super.getValueArray(); + } + + @Override + protected ZoomPane createZoomPane() { + return new ZoomPane(); + } + + @Override + protected boolean isCurrentChartSupportLargeDataMode() { + return true; + } + }; } }; return new AbstractChartAttrPane[]{stylePane, otherPane}; } - public ConditionAttributesPane getPlotConditionPane(Plot plot){ + public ConditionAttributesPane getPlotConditionPane(Plot plot) { return new VanChartBubbleConditionPane(plot); } + + //图表数据结构 恢复用注释。取消注释。 +// @Override +// public ChartDataPane getChartDataPane(AttributeChangeListener listener) { +// return new AbstractVanSingleDataPane(listener) { +// @Override +// protected SingleDataPane createSingleDataPane() { +// VanChartBubblePlot plot = null; +// if (getVanChart() != null) { +// plot = getVanChart().getPlot(); +// } +// if (plot != null && plot.isForceBubble()) { +// return new SingleDataPane(new SingleCategoryDataSetFieldsPane(), new SingleCategoryCellDataFieldsPane()); +// } +// return new SingleDataPane(new ScatterDataSetFieldsPane(), new ScatterCellDataFieldsPane()); +// } +// }; +// } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleInteractivePane.java deleted file mode 100644 index 7dad3847a0..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleInteractivePane.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.fr.van.chart.bubble; - -import com.fr.chart.chartattr.Plot; - -import com.fr.plugin.chart.base.VanChartConstants; -import com.fr.plugin.chart.bubble.VanChartBubblePlot; -import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; - -/** - * Created by Mitisky on 16/3/31. - */ -public class VanChartBubbleInteractivePane extends VanChartInteractivePaneWithOutSort { - protected String[] getNameArray() { - Plot plot = chart.getPlot(); - if(plot instanceof VanChartBubblePlot && ((VanChartBubblePlot) plot).isForceBubble()) { - return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_XY_Axis"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")}; - } - return super.getNameArray(); - } - - protected String[] getValueArray() { - Plot plot = chart.getPlot(); - if(plot instanceof VanChartBubblePlot && ((VanChartBubblePlot) plot).isForceBubble()) { - return new String[]{VanChartConstants.ZOOM_TYPE_XY, VanChartConstants.ZOOM_TYPE_NONE}; - } - return super.getValueArray(); - } - -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubblePlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubblePlotPane.java index d1f93a19e8..407c7758ba 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubblePlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubblePlotPane.java @@ -6,7 +6,13 @@ import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionCollection; +import com.fr.chartx.data.AbstractDataDefinition; +import com.fr.chartx.data.ChartDataDefinitionProvider; +import com.fr.chartx.data.field.AbstractColumnFieldCollection; +import com.fr.chartx.data.field.diff.BubbleColumnFieldCollection; +import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.base.VanChartZoom; import com.fr.plugin.chart.bubble.BubbleIndependentVanChart; @@ -33,26 +39,26 @@ public class VanChartBubblePlotPane extends AbstractVanChartTypePane { }; } - private void removeDefaultAttr(ConditionAttr conditionAttr, Class targetClass) { + private void removeDefaultAttr(ConditionAttr conditionAttr, Class targetClass) { DataSeriesCondition attr = conditionAttr.getExisted(targetClass); - if (attr != null){ + if (attr != null) { conditionAttr.remove(targetClass); } } - protected Plot getSelectedClonedPlot(){ + protected Plot getSelectedClonedPlot() { VanChartBubblePlot newPlot = null; Chart[] bubbleChart = BubbleIndependentVanChart.BubbleVanChartTypes; - for(int i = 0, len = bubbleChart.length; i < len; i++){ - if(typeDemo.get(i).isPressing){ - newPlot = (VanChartBubblePlot)bubbleChart[i].getPlot(); + for (int i = 0, len = bubbleChart.length; i < len; i++) { + if (typeDemo.get(i).isPressing) { + newPlot = (VanChartBubblePlot) bubbleChart[i].getPlot(); } } Plot cloned = null; try { - if(newPlot != null) { - cloned = (Plot) newPlot.clone(); - } + if (newPlot != null) { + cloned = (Plot) newPlot.clone(); + } } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error("Error In BubbleChart"); } @@ -64,16 +70,16 @@ public class VanChartBubblePlotPane extends AbstractVanChartTypePane { } @Override - /** - * 力學氣泡圖切換到其他氣泡圖時,刪除條件屬性 - * 并且将bubbleAttr属性重置 - */ - protected void cloneOldConditionCollection(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException{ + /** + * 力學氣泡圖切換到其他氣泡圖時,刪除條件屬性 + * 并且将bubbleAttr属性重置 + */ + protected void cloneOldConditionCollection(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException { cloneOldDefaultAttrConditionCollection(oldPlot, newPlot); } @Override - protected void cloneOldDefaultAttrConditionCollection(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException{ + protected void cloneOldDefaultAttrConditionCollection(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException { if (oldPlot.getConditionCollection() != null) { ConditionCollection newCondition = new ConditionCollection(); newCondition.setDefaultAttr((ConditionAttr) oldPlot.getConditionCollection().getDefaultAttr().clone()); @@ -88,7 +94,7 @@ public class VanChartBubblePlotPane extends AbstractVanChartTypePane { removeDefaultAttr(attrList, ScatterAttrLabel.class); AttrAlpha attrAlpha = new AttrAlpha(); - attrAlpha.setAlpha(((VanChartBubblePlot)newPlot).isForceBubble() ? FORCE_ALPHA : ALPHA); + attrAlpha.setAlpha(((VanChartBubblePlot) newPlot).isForceBubble() ? FORCE_ALPHA : ALPHA); attrList.addDataSeriesCondition(attrAlpha); } @@ -96,8 +102,8 @@ public class VanChartBubblePlotPane extends AbstractVanChartTypePane { @Override protected void cloneHotHyperLink(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException { - if(oldPlot instanceof VanChartBubblePlot && newPlot instanceof VanChartBubblePlot){ - if(((VanChartBubblePlot) oldPlot).isForceBubble() == ((VanChartBubblePlot) newPlot).isForceBubble()){ + if (oldPlot instanceof VanChartBubblePlot && newPlot instanceof VanChartBubblePlot) { + if (((VanChartBubblePlot) oldPlot).isForceBubble() == ((VanChartBubblePlot) newPlot).isForceBubble()) { super.cloneHotHyperLink(oldPlot, newPlot); } } @@ -112,13 +118,33 @@ public class VanChartBubblePlotPane extends AbstractVanChartTypePane { /** * 气泡图相同图表类型之间切换的时候,chart的部分属性也需要重置 + * * @param chart */ @Override - protected void resetChartAttr4SamePlot(Chart chart){ + protected void resetChartAttr4SamePlot(Chart chart) { + //图表缩放新设计 恢复用注释。下面2行删除。 VanChartZoom vanChartZoom = new VanChartZoom(); - ((VanChart)chart).setVanChartZoom(vanChartZoom); + ((VanChart) chart).setVanChartZoom(vanChartZoom); + + //图表缩放新设计 恢复用注释。下面一行取消注释。 + //((VanChart) chart).setZoomAttribute(new ZoomAttribute()); + //重置监控刷新选项 - resetRefreshMoreLabelAttr((VanChart)chart); + resetRefreshMoreLabelAttr((VanChart) chart); + } + + @Override + protected boolean acceptDefinition(ChartDataDefinitionProvider definition, VanChartPlot vanChartPlot) { + if (definition instanceof AbstractDataDefinition) { + AbstractColumnFieldCollection columnFieldCollection = ((AbstractDataDefinition) definition).getColumnFieldCollection(); + boolean isForce = ((VanChartBubblePlot) vanChartPlot).isForceBubble(); + if (isForce) { + return columnFieldCollection instanceof MultiCategoryColumnFieldCollection; + } + return columnFieldCollection instanceof BubbleColumnFieldCollection; + + } + return false; } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java index 01c72649d6..44077c0ba7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java @@ -6,7 +6,6 @@ import com.fr.design.beans.BasicBeanPane; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; - import com.fr.plugin.chart.bubble.VanChartBubblePlot; import com.fr.plugin.chart.bubble.attr.VanChartAttrBubble; import com.fr.van.chart.bubble.component.VanChartBubblePane; @@ -44,7 +43,7 @@ public class VanChartBubbleSeriesPane extends VanChartAbstractPlotSeriesPane { new Component[]{null} }; - if (!((VanChartBubblePlot)plot).isForceBubble()) { + if (!((VanChartBubblePlot) plot).isForceBubble()) { components[3] = new Component[]{createLargeDataModelPane()}; } @@ -54,25 +53,25 @@ public class VanChartBubbleSeriesPane extends VanChartAbstractPlotSeriesPane { //设置色彩面板内容 @Override - protected void setColorPaneContent (JPanel panel) { + protected void setColorPaneContent(JPanel panel) { panel.add(createAlphaPane(), BorderLayout.CENTER); } @Override //堆积和坐标轴设置(自定义柱形图等用到) protected JPanel createStackedAndAxisPane() { - stackAndAxisEditPane = new VanChartStackedAndAxisListControlPane(){ + stackAndAxisEditPane = new VanChartStackedAndAxisListControlPane() { @Override protected Class getStackAndAxisPaneClass() { return VanChartCustomAxisConditionPane.class; } @Override - public String getPaneTitle(){ + public String getPaneTitle() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Axis"); } }; - stackAndAxisEditExpandablePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(stackAndAxisEditPane.getPaneTitle(), stackAndAxisEditPane); + stackAndAxisEditExpandablePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(stackAndAxisEditPane.getPaneTitle(), stackAndAxisEditPane); return stackAndAxisEditExpandablePane; } @@ -81,18 +80,18 @@ public class VanChartBubbleSeriesPane extends VanChartAbstractPlotSeriesPane { return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Bubble"), bubblePane); } - protected void populateCondition(ConditionAttr defaultAttr){ - super.populateCondition(defaultAttr); - if(bubblePane != null) { - VanChartAttrBubble attrBubble = (VanChartAttrBubble) defaultAttr.getExisted(VanChartAttrBubble.class); + protected void populateCondition(ConditionAttr defaultAttr) { + super.populateCondition(defaultAttr); + if (bubblePane != null) { + VanChartAttrBubble attrBubble = defaultAttr.getExisted(VanChartAttrBubble.class); bubblePane.populateBean(attrBubble); } } - protected void updateCondition(ConditionAttr defaultAttr){ + protected void updateCondition(ConditionAttr defaultAttr) { super.updateCondition(defaultAttr); - if(bubblePane != null){ - VanChartAttrBubble attrBubble = (VanChartAttrBubble) defaultAttr.getExisted(VanChartAttrBubble.class); + if (bubblePane != null) { + VanChartAttrBubble attrBubble = defaultAttr.getExisted(VanChartAttrBubble.class); if (attrBubble != null) { defaultAttr.remove(attrBubble); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/ColumnIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanColumnChartTypeUI.java similarity index 80% rename from designer-chart/src/main/java/com/fr/van/chart/column/ColumnIndependentVanChartInterface.java rename to designer-chart/src/main/java/com/fr/van/chart/column/VanColumnChartTypeUI.java index ebecf18caa..0d491f9046 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/column/ColumnIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/column/VanColumnChartTypeUI.java @@ -11,7 +11,7 @@ import com.fr.van.chart.vanchart.AbstractMultiCategoryVanChartUI; /** * Created by Mitisky on 15/9/24. */ -public class ColumnIndependentVanChartInterface extends AbstractMultiCategoryVanChartUI { +public class VanColumnChartTypeUI extends AbstractMultiCategoryVanChartUI { @Override public String getName() { @@ -60,13 +60,4 @@ public class ColumnIndependentVanChartInterface extends AbstractMultiCategoryVan return new VanChartColumnSeriesPane(parent, plot); } -// @Override -// public ChartDataPane getChartDataPane(AttributeChangeListener listener) { -// return new AbstractDataPane(listener) { -// @Override -// protected SingleDataPane createSingleDataPane() { -// return new SingleDataPane(new MultiCategoryDataSetFieldsPane(), new MultiCategoryCellDataFieldsPane()); -// } -// }; -// } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/CustomIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/custom/CustomIndependentVanChartInterface.java index ffb44ca326..e16151a849 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/CustomIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/CustomIndependentVanChartInterface.java @@ -73,6 +73,9 @@ public class CustomIndependentVanChartInterface extends AbstractIndependentVanCh } public ChartDataPane getChartDataPane(AttributeChangeListener listener){ + //图表数据结构 恢复用注释。下面1行删除。 return new VanChartCustomDataPane(listener); + //图表数据结构 恢复用注释。取消注释。 + //return new CustomChartDataPane(listener); } } \ No newline at end of file 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 927fa31485..5e6953746a 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 @@ -6,10 +6,14 @@ import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionCollection; +import com.fr.chartx.data.AbstractDataDefinition; +import com.fr.chartx.data.ChartDataDefinitionProvider; +import com.fr.chartx.data.CustomChartDataDefinition; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.type.ChartImagePane; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.VanChartAttrLine; import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.custom.CustomDefinition; @@ -24,11 +28,11 @@ import com.fr.van.chart.designer.type.AbstractVanChartTypePane; import javax.swing.JPanel; import javax.swing.JSeparator; +import java.util.HashMap; +import java.util.Map; import java.awt.CardLayout; import java.awt.Component; import java.awt.Dimension; -import java.util.HashMap; -import java.util.Map; /** * Created by Mitisky on 16/2/16. @@ -123,6 +127,7 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { //如果上次的状态和这次的装填不在同一个页面,说明同一个图表內切换了,需要情況数据配置 if (lastState != chart.getPlot().getDetailType()) { chart.setFilterDefinition(null); + ((VanChart) chart).setChartDataDefinition(null); } Chart[] customChart = CustomIndependentVanChart.CustomVanChartTypes; @@ -137,6 +142,9 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { dealCustomDefinition(chart); customSelectPane.updateBean(chart); + + //更新新的数据配置 + dealCustomChartDataDefinition(chart); } else if (isSamePlot()) {//如果是同一个图表切换过来,则重置面板 customSelectPane.populateBean(chart); } @@ -150,6 +158,27 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { } + private void dealCustomChartDataDefinition(Chart chart) { + CustomChartDataDefinition chartDataDefinition = (CustomChartDataDefinition) ((VanChart) chart).getChartDataDefinition(); + + if (chartDataDefinition == null) { + return; + } + + Map customDefinitions = chartDataDefinition.getCustomDefinitions(); + + Map newCustomDefinitions = new HashMap<>(); + + VanChartCustomPlot customPlot = chart.getPlot(); + for (int i = 0; i < customPlot.getCustomPlotList().size(); i++) { + CustomPlotType plotType = CustomPlotFactory.getCustomType(customPlot.getCustomPlotList().get(i)); + AbstractDataDefinition definition = customDefinitions.get(plotType); + newCustomDefinitions.put(plotType, definition); + } + + chartDataDefinition.setCustomDefinitions(newCustomDefinitions); + } + private void dealCustomDefinition(Chart chart) { CustomDefinition definition = (CustomDefinition) chart.getFilterDefinition(); @@ -229,9 +258,9 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { } Plot cloned = null; try { - if(newPlot != null) { - cloned = (Plot) newPlot.clone(); - } + if (newPlot != null) { + cloned = (Plot) newPlot.clone(); + } } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error("Error In ScatterChart"); } @@ -268,4 +297,9 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { } } } + + @Override + protected boolean acceptDefinition(ChartDataDefinitionProvider definition, VanChartPlot vanChartPlot) { + return definition instanceof CustomDefinition; + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotSelectPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotSelectPane.java index 133cba525f..8f7b9557d0 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotSelectPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotSelectPane.java @@ -2,6 +2,7 @@ package com.fr.van.chart.custom.component; import com.fr.chart.chartattr.Chart; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; @@ -115,7 +116,7 @@ public class VanChartCustomPlotSelectPane extends BasicBeanPane { customTypeList.get(index).getCheckBox().setSelected(true); //彈出警告框 - JOptionPane.showMessageDialog(new JPanel(), MASSAGE,"", JOptionPane.WARNING_MESSAGE); + FineJOptionPane.showMessageDialog(new JPanel(), MASSAGE,com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); } //点击后更新已选顺序 diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java index af11a8b960..b5efad3b66 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java @@ -279,4 +279,4 @@ public class VanChartHyperLinkPane extends VanChartUIListControlPane { } -} +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java index 7c46b8b085..d3e1adbb90 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java @@ -7,7 +7,6 @@ import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.style.FormatPane; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; - import com.fr.plugin.chart.area.VanChartAreaPlot; import com.fr.plugin.chart.bubble.VanChartBubblePlot; import com.fr.plugin.chart.column.VanChartColumnPlot; @@ -86,14 +85,15 @@ public class PlotFactory { autoAdjustLabelPlots.add(VanChartStructurePlot.class); } - public static boolean plotAutoAdjustLabelPosition(Plot plot){ + public static boolean plotAutoAdjustLabelPosition(Plot plot) { return autoAdjustLabelPlots.contains(plot.getClass()); } + /** - * * 标签Map */ private static Map, Class> labelMap = new HashMap, Class>(); + static { labelMap.put(VanChartGaugePlot.class, VanChartGaugePlotLabelPane.class); labelMap.put(VanChartScatterPlot.class, VanChartScatterPlotLabelPane.class); @@ -104,6 +104,7 @@ public class PlotFactory { * 图例Map */ private static Map, Class> legendMap = new HashMap, Class>(); + static { legendMap.put(VanChartGaugePlot.class, VanLegendPaneWidthOutHighlight.class); legendMap.put(VanChartMultiPiePlot.class, VanLegendPaneWidthOutHighlight.class); @@ -119,6 +120,7 @@ public class PlotFactory { * 数据点提示Map */ private static Map, Class> toolTipMap = new HashMap, Class>(); + static { toolTipMap.put(VanChartGaugePlot.class, VanChartGaugePlotTooltipPane.class); toolTipMap.put(VanChartScatterPlot.class, VanChartScatterPlotTooltipPane.class); @@ -156,18 +158,19 @@ public class PlotFactory { } - /** * 监控刷新 自动数据点提示Map */ private static Map, Class> refreshToolTipMap = new HashMap, Class>(); + static { refreshToolTipMap.put(VanChartGaugePlot.class, VanChartGaugePlotRefreshTooltipPane.class); refreshToolTipMap.put(VanChartBubblePlot.class, VanChartBubbleRefreshTooltipPane.class); } + private static Map, Class> refreshTooltipContentMap = new HashMap, Class>(); static { @@ -186,18 +189,19 @@ public class PlotFactory { /** * 根据图表类型创建标签界面 - * @param plot 图表 + * + * @param plot 图表 * @param stylePane 样式界面 * @return 标签界面 */ public static VanChartPlotLabelPane createPlotLabelPane(Plot plot, VanChartStylePane stylePane) { Class key = plot.getClass(); - if(labelMap.containsKey(key)){ - try{ + if (labelMap.containsKey(key)) { + try { Class cl = labelMap.get(key); - Constructor constructor = cl.getConstructor(Plot.class, VanChartStylePane.class); + Constructor constructor = cl.getConstructor(Plot.class, VanChartStylePane.class); return constructor.newInstance(plot, stylePane); - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } @@ -206,18 +210,19 @@ public class PlotFactory { /** * 根据图表类型创建图例界面 - * @param plot 图表 + * + * @param plot 图表 * @param stylePane 样式界面 * @return 图例界面 */ public static VanChartPlotLegendPane createPlotLegendPane(Plot plot, VanChartStylePane stylePane) { Class key = plot.getClass(); - if(legendMap.containsKey(key)){ - try{ + if (legendMap.containsKey(key)) { + try { Class cl = legendMap.get(key); - Constructor constructor = cl.getConstructor(VanChartStylePane.class); + Constructor constructor = cl.getConstructor(VanChartStylePane.class); return constructor.newInstance(stylePane); - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } @@ -226,18 +231,19 @@ public class PlotFactory { /** * 根据图表类型创建数据点提示界面 - * @param plot 图表 + * + * @param plot 图表 * @param stylePane 样式界面 * @return 数据点提示界面 */ - public static VanChartPlotTooltipPane createPlotTooltipPane(Plot plot, VanChartStylePane stylePane) { + public static VanChartPlotTooltipPane createPlotTooltipPane(Plot plot, VanChartStylePane stylePane) { Class key = plot.getClass(); - if(toolTipMap.containsKey(key)){ - try{ + if (toolTipMap.containsKey(key)) { + try { Class cl = toolTipMap.get(key); - Constructor constructor = cl.getConstructor(Plot.class, VanChartStylePane.class); + Constructor constructor = cl.getConstructor(Plot.class, VanChartStylePane.class); return constructor.newInstance(plot, stylePane); - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } @@ -246,19 +252,20 @@ public class PlotFactory { /** * 根据图表类型创建标签的具体内容界面.分类名系列名等 - * @param plot 图表 - * @param parent 样式界面 + * + * @param plot 图表 + * @param parent 样式界面 * @param showOnPane formatpane用到 * @return 标签的具体内容界面 */ - public static VanChartTooltipContentPane createPlotLabelContentPane(Plot plot, VanChartStylePane parent, JPanel showOnPane){ + public static VanChartTooltipContentPane createPlotLabelContentPane(Plot plot, VanChartStylePane parent, JPanel showOnPane) { Class key = plot.getClass(); - if(labelContentMap.containsKey(key)){ - try{ + if (labelContentMap.containsKey(key)) { + try { Class cl = labelContentMap.get(key); - Constructor constructor = cl.getConstructor(VanChartStylePane.class, JPanel.class); + Constructor constructor = cl.getConstructor(VanChartStylePane.class, JPanel.class); return constructor.newInstance(parent, showOnPane); - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } @@ -267,19 +274,20 @@ public class PlotFactory { /** * 根据图表类型创建数据点提示的具体内容界面.分类名系列名等 - * @param plot 图表 - * @param parent 样式界面 + * + * @param plot 图表 + * @param parent 样式界面 * @param showOnPane formatpane用到 * @return 数据点提示的具体内容界面 */ - public static VanChartTooltipContentPane createPlotTooltipContentPane(Plot plot, VanChartStylePane parent, JPanel showOnPane){ + public static VanChartTooltipContentPane createPlotTooltipContentPane(Plot plot, VanChartStylePane parent, JPanel showOnPane) { Class key = plot.getClass(); - if(tooltipContentMap.containsKey(key)){ - try{ + if (tooltipContentMap.containsKey(key)) { + try { Class cl = tooltipContentMap.get(key); - Constructor constructor = cl.getConstructor(VanChartStylePane.class, JPanel.class); + Constructor constructor = cl.getConstructor(VanChartStylePane.class, JPanel.class); return constructor.newInstance(parent, showOnPane); - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } @@ -287,56 +295,59 @@ public class PlotFactory { } - /** * 根据图表类型创建数据点提示界面 + * * @param plot 图表 * @return 数据点提示界面 */ public static VanChartPlotTooltipPane createPlotRefreshTooltipPane(Plot plot) { Class key = plot.getClass(); - if(refreshToolTipMap.containsKey(key)){ - try{ + if (refreshToolTipMap.containsKey(key)) { + try { Class cl = refreshToolTipMap.get(key); - Constructor constructor = cl.getConstructor(Plot.class); + Constructor constructor = cl.getConstructor(Plot.class); return constructor.newInstance(plot); - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } return new VanChartPlotRefreshTooltipPane(plot); } + /** * 根据图表类型创建监控刷新中数据点提示的具体内容界面.分类名系列名等 - * @param plot 图表 - * @param parent 交互属性界面 + * + * @param plot 图表 + * @param parent 交互属性界面 * @param showOnPane formatpane用到 * @return 数据点提示的具体内容界面 */ - public static VanChartTooltipContentPane createPlotRefreshTooltipContentPane(Plot plot, VanChartStylePane parent, JPanel showOnPane){ + public static VanChartTooltipContentPane createPlotRefreshTooltipContentPane(Plot plot, VanChartStylePane parent, JPanel showOnPane) { Class key = plot.getClass(); - if(refreshTooltipContentMap.containsKey(key)){ - try{ + if (refreshTooltipContentMap.containsKey(key)) { + try { Class cl = refreshTooltipContentMap.get(key); - Constructor constructor = cl.getConstructor(VanChartStylePane.class, JPanel.class); + Constructor constructor = cl.getConstructor(VanChartStylePane.class, JPanel.class); return constructor.newInstance(parent, showOnPane); - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } return new VanChartRefreshTooltipContentPane(parent, showOnPane); } - public static FormatPane createAutoFormatPane(){ - FormatPane formatPane = new FormatPane(){ - protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane) { + public static FormatPane createAutoFormatPane() { + FormatPane formatPane = new FormatPane() { + protected Component[][] getComponent(JPanel fontPane, JPanel centerPane, JPanel typePane) { typePane.setBorder(BorderFactory.createEmptyBorder()); return new Component[][]{ - new Component[]{typePane,null}, + new Component[]{typePane, null}, new Component[]{centerPane, null}, }; } - protected UIComboBoxRenderer createComBoxRender(){ + + protected UIComboBoxRenderer createComBoxRender() { return new UIComboBoxRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { @@ -358,14 +369,18 @@ public class PlotFactory { return formatPane; } - /** - * 判断是否为大数据模式 - */ - public static boolean largeDataModel(Plot plot){ + + //大数据模式 恢复用注释。取消注释。 +// public static boolean largeDataModel(Plot plot) { +// return plot != null && plot.convertDataProcessor().getMark() == LargeDataModel.MARK; +// } + + //大数据模式 恢复用注释。删除下面2个方法 largeDataModel lineMapLargeModel。 + public static boolean largeDataModel(Plot plot) { return plot != null && plot.getDataProcessor().getMark() == LargeDataModel.MARK; } - public static boolean lineMapLargeModel(Plot plot){ + public static boolean lineMapLargeModel(Plot plot) { return plot instanceof VanChartMapPlot && ((VanChartMapPlot) plot).getLineMapDataProcessor().getMark() == LargeDataModel.MARK; } } 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 new file mode 100644 index 0000000000..0b3bc7571a --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java @@ -0,0 +1,85 @@ +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; + +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; + +/** + * Created by shine on 2019/08/30. + */ +public class LineTypeComboBox extends UIComboBox { + + public LineTypeComboBox(LineType[] lineType) { + super(lineType); + + this.setRenderer(new CellRenderer()); + } + + private static class CellRenderer extends UIComboBoxRenderer { + + private LineType lineType; + + 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); + return comp; + } + + public void paint(Graphics g) { + super.paint(g); + Graphics2D g2d = (Graphics2D) g; + + Dimension d = getSize(); + 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 NORMAL: + GraphHelper.drawLine(g2d, 4, d.height / 2, d.width - 8, d.height / 2); + break; + case DASH: + GraphHelper.drawLine(g2d, 4, d.height / 2, d.width - 8, d.height / 2, Constants.LINE_DASH); + break; + default: + break; + + } + } + + public Dimension getPreferredSize() { + return new Dimension(60, 16); + } + + public Dimension getMinimumSize() { + return getPreferredSize(); + } + + } + + +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePane.java index 78f93162f8..f5adcf26d1 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePane.java @@ -4,12 +4,15 @@ import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButtonGroup; 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.TableLayout; - import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; +import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.base.VanChartAttrLine; import com.fr.plugin.chart.type.LineStyle; +import com.fr.plugin.chart.type.LineType; import com.fr.stable.Constants; import com.fr.stable.CoreConstants; import com.fr.van.chart.designer.TableLayout4VanChartHelper; @@ -17,6 +20,9 @@ import com.fr.van.chart.designer.TableLayout4VanChartHelper; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Arrays; /** * line相关设置 @@ -24,64 +30,143 @@ import java.awt.Component; public class VanChartLineTypePane extends BasicPane { private static final long serialVersionUID = -6581862503009962973L; + //线型支持虚线 恢复用注释。下面1行删除。 protected LineComboBox lineWidth;//线型 + + private LineTypeComboBox lineTypeComboBox;//线型 + private UISpinner lineWidthSpinner;//线宽 protected UIButtonGroup lineStyle;//形态 - protected UIButtonGroup nullValueBreak;//空值断开 + private UIButtonGroup nullValueBreak;//空值断开 + + private JPanel lineWidthPane; + private JPanel lineStylePane; public VanChartLineTypePane() { + //线型支持虚线 恢复用注释。下面1行删除。 lineWidth = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART); + JPanel typeAndWidthPane = createTypeAndWidthPane(); + createLineStyle(); - nullValueBreak = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}); + nullValueBreak = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open"), Toolkit.i18nText("Fine-Design_Chart_Close")}); - this.setLayout(new BorderLayout()); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - this.add(createContentPane(p, f), BorderLayout.CENTER); + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + + Component[] lineStyleComponent = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Style_Present")), lineStyle}, + nullValueBreakComponent = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Null_Value_Break")), nullValueBreak}; + + Component[][] components = createContentComponent(lineStyleComponent, nullValueBreakComponent); + + double[] row = new double[components.length]; + Arrays.fill(row, p); + double[] col = {f, e}; + + lineStylePane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); + + this.setLayout(new BorderLayout(0, 6)); + //线型支持虚线 恢复用注释。取消注释。 + //this.add(typeAndWidthPane, BorderLayout.NORTH); + this.add(lineStylePane, BorderLayout.CENTER); + } + + private JPanel createTypeAndWidthPane() { + + lineTypeComboBox = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.NORMAL, LineType.DASH}); + + lineWidthSpinner = new UISpinner(0.5, Integer.MAX_VALUE, 0.5, 2); + + lineTypeComboBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkLineWidth(); + checkLineStyle(); + } + }); + + Component[][] lineTypeComps = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), lineTypeComboBox} + }; + Component[][] lineWidthComps = new Component[][]{ + new Component[]{ + FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Width")), + UIComponentUtils.wrapWithBorderLayoutPane(lineWidthSpinner)} + }; + + double p = TableLayout.PREFERRED, f = TableLayout.FILL, e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double[] row = {p}, col = {f, e}; + + JPanel lineTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(lineTypeComps, row, col); + lineWidthPane = TableLayout4VanChartHelper.createGapTableLayoutPane(lineWidthComps, row, col); + + JPanel contentPane = new JPanel(new BorderLayout(0, 6)); + + contentPane.add(lineTypePane, BorderLayout.CENTER); + contentPane.add(lineWidthPane, BorderLayout.SOUTH); + + return contentPane; } protected void createLineStyle() { - String[] textArray = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Normal_Line"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_StepLine"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_CurveLine")}; + String[] textArray = new String[]{Toolkit.i18nText("Fine-Design_Chart_Normal_Line"), + Toolkit.i18nText("Fine-Design_Chart_StepLine"), Toolkit.i18nText("Fine-Design_Chart_CurveLine")}; lineStyle = new UIButtonGroup(textArray, LineStyle.values()); } - protected JPanel createContentPane(double p, double f) { - double[] row = {p, p, p, p}; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] col = {f, e}; - - Component[][] components = new Component[][]{ - new Component[]{null,null}, + protected Component[][] createContentComponent(Component[] lineStyleComponent, Component[] nullValueBreakComponent) { + return new Component[][]{ + //线型支持虚线 恢复用注释。下面5行删除。 + new Component[]{null, null}, new Component[]{ - FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")), + FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), UIComponentUtils.wrapWithBorderLayoutPane(lineWidth) }, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Present")),lineStyle}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Break")),nullValueBreak}, + lineStyleComponent, + nullValueBreakComponent }; + } - return TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); + private void checkLineWidth() { + if (lineWidthPane != null && lineTypeComboBox != null) { + lineWidthPane.setVisible(!ComparatorUtils.equals(lineTypeComboBox.getSelectedItem(), LineType.NONE)); + } + } + + private void checkLineStyle() { + if (lineStylePane != null && lineTypeComboBox != null) { + lineStylePane.setVisible(!ComparatorUtils.equals(lineTypeComboBox.getSelectedItem(),LineType.NONE)); + } } - public void checkLarge(boolean large){ - if(large){ + public void checkLarge(boolean large) { + //线型支持虚线 恢复用注释。下面4行删除。 + if (large) { lineWidth.setSelectedLineStyle(Constants.LINE_NONE); } lineWidth.setEnabled(!large); + //线型支持虚线 恢复用注释。取消注释。 +// if (large) { +// lineTypeComboBox.setSelectedItem(LineType.NONE); +// } +// lineTypeComboBox.setEnabled(!large); lineStyle.setEnabled(!large); } protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line"); + return Toolkit.i18nText("Fine-Design_Chart_Line"); } public void populate(VanChartAttrLine line) { if (line == null) { line = initVanChartAttrLine(); } + //线型支持虚线 恢复用注释。下面1行删除。 lineWidth.setSelectedLineStyle(line.getLineWidth()); + //线型支持虚线 恢复用注释。取消注释。 +// lineTypeComboBox.setSelectedItem(line.getLineType()); +// lineWidthSpinner.setValue(line.getLineWidth()); lineStyle.setSelectedItem(line.getLineStyle()); nullValueBreak.setSelectedIndex(line.isNullValueBreak() ? 0 : 1); } @@ -92,7 +177,11 @@ public class VanChartLineTypePane extends BasicPane { public VanChartAttrLine update() { VanChartAttrLine line = new VanChartAttrLine(); + //线型支持虚线 恢复用注释。下面1行删除。 line.setLineWidth(lineWidth.getSelectedLineStyle()); + //线型支持虚线 恢复用注释。取消注释。 +// line.setLineType((LineType) lineTypeComboBox.getSelectedItem()); +// line.setLineWidth(lineWidthSpinner.getValue()); line.setLineStyle(lineStyle.getSelectedItem()); line.setNullValueBreak(nullValueBreak.getSelectedIndex() == 0); return line; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineWidthPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineWidthPane.java index 72ee1666ae..ed06b3d4db 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineWidthPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineWidthPane.java @@ -1,30 +1,23 @@ package com.fr.van.chart.designer.component; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.i18n.Toolkit; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; - -import javax.swing.JPanel; import java.awt.Component; /** - * 线-线型 + * 线型+线宽+空值断开 */ public class VanChartLineWidthPane extends VanChartLineTypePane { private static final long serialVersionUID = 4537158946119294689L; - protected JPanel createContentPane(double p, double f) { - double[] row = {p, p, p}; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] col = {f, e}; - - Component[][] components = new Component[][]{ - new Component[]{null,null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")), lineWidth}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Break")), nullValueBreak}, + @Override + protected Component[][] createContentComponent(Component[] lineStyleComponent, Component[] nullValueBreakComponent) { + return new Component[][]{ + //线型支持虚线 恢复用注释。下面2行删除。 + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), lineWidth}, + nullValueBreakComponent }; - - return TableLayoutHelper.createTableLayoutPane(components, row, col); } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java index 134598bd71..de01ab612c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java @@ -9,21 +9,24 @@ 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.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.style.color.ColorSelectBox; - import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.plugin.chart.base.TrendLineType; import com.fr.plugin.chart.base.VanChartAttrTrendLine; import com.fr.plugin.chart.base.VanChartConstants; +import com.fr.plugin.chart.type.LineType; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import javax.swing.JPanel; import javax.swing.SwingConstants; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; /** * Created by Mitisky on 15/10/19. @@ -33,62 +36,118 @@ public class VanChartTrendLinePane extends BasicPane{ private UITextField trendLineName; private ColorSelectBox trendLineColor; + + //线型支持虚线 恢复用注释。下面1行删除。 private LineComboBox trendLineStyle;//线型 + //线型支持虚线 恢复用注释。取消注释。 +// private LineTypeComboBox trendLineStyle;//线型 +// private UISpinner lineWidthSpinner;//线宽 private UIComboBox trendLineType;//趋势线函数类型 private UISpinner prePeriod; private UISpinner afterPeriod; + private JPanel trendLineHidePane; + public VanChartTrendLinePane() { - this.setLayout(new BorderLayout()); + initComponents(); + } + + private void initComponents(){ + this.setLayout(new BorderLayout(0,6)); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] row = {p,p,p,p,p,p}; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double[] row = {p, p, p, p, p, p}; double[] col = {f, e}; trendLineName = new UITextField(); trendLineColor = new ColorSelectBox(100); + //线型支持虚线 恢复用注释。下面1行删除。 trendLineStyle = new LineComboBox(VanChartConstants.ALERT_LINE_STYLE); - + //线型支持虚线 恢复用注释。取消注释。 +// trendLineStyle = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.NORMAL, LineType.DASH}); +// lineWidthSpinner = new UISpinner(0.5, Integer.MAX_VALUE, 0.5, 2); trendLineType = new UIComboBox(TYPES); prePeriod = new UISpinner(0, Integer.MAX_VALUE, 1, 0); afterPeriod = new UISpinner(0, Integer.MAX_VALUE, 1, 0); + double[] r = {p, p}; double[] c = {f, p, f, p}; Component[][] periodComps = new Component[][]{ - new Component[]{prePeriod, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Cycle")), afterPeriod, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Cycle"))}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TrendLine_Forward")), null, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_After_Period")), null}, + new Component[]{prePeriod, new UILabel(Toolkit.i18nText("Fine-Design_Chart_Cycle")), afterPeriod, new UILabel(Toolkit.i18nText("Fine-Design_Chart_Cycle"))}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_TrendLine_Forward")), null, new UILabel(Toolkit.i18nText("Fine-Design_Chart_After_Period")), null}, }; JPanel periodPane = TableLayoutHelper.createTableLayoutPane(periodComps, r, c); - UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Period")); + UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Period")); label.setVerticalAlignment(SwingConstants.TOP); + //线型支持虚线 恢复用注释。开始删除。 Component[][] components = new Component[][]{ new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Name")), trendLineName}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Name")), trendLineName}, new Component[]{ - FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")), - UIComponentUtils.wrapWithBorderLayoutPane(trendLineStyle) + FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), + UIComponentUtils.wrapWithBorderLayoutPane(trendLineStyle) }, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")), trendLineColor}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Type")), trendLineType}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), trendLineColor}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Type")), trendLineType}, new Component[]{label, periodPane} }; + //线型支持虚线 恢复用注释。结束删除。 + + //线型支持虚线 恢复用注释。取消注释。 +// Component[][] components = new Component[][]{ +// new Component[]{null, null}, +// new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Name")), trendLineName}, +// new Component[]{ +// FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), +// UIComponentUtils.wrapWithBorderLayoutPane(trendLineStyle) +// } +// }; +// +// Component[][] componentsMayHide = new Component[][]{ +// new Component[]{ +// FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Width")), +// UIComponentUtils.wrapWithBorderLayoutPane(lineWidthSpinner)}, +// new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), trendLineColor}, +// new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Type")), trendLineType}, +// new Component[]{label, periodPane} +// }; +// trendLineHidePane = TableLayout4VanChartHelper.createGapTableLayoutPane(componentsMayHide, row, col); + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); + + trendLineStyle.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkHidePaneVisible(); + } + }); + + checkHidePaneVisible(); + this.add(panel, BorderLayout.CENTER); + //线型支持虚线 恢复用注释。取消注释。 + //this.add(trendLineHidePane, BorderLayout.SOUTH); } + protected String title4PopupWindow(){ - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TrendLine"); + return Toolkit.i18nText("Fine-Design_Chart_TrendLine"); } public void populate(VanChartAttrTrendLine trendLine) { + checkHidePaneVisible(); if(trendLine != null){ trendLineName.setText(trendLine.getTrendLineName()); LineStyleInfo lineStyleInfo = trendLine.getLineStyleInfo(); trendLineColor.setSelectObject(lineStyleInfo.getAttrLineColor().getSeriesColor()); + //线型支持虚线 恢复用注释。下面1行删除。 trendLineStyle.setSelectedLineStyle(lineStyleInfo.getAttrLineStyle().getLineStyle()); + //线型支持虚线 恢复用注释。取消注释。 +// trendLineStyle.setSelectedItem(lineStyleInfo.getAttrLineStyle().getLineType()); +// lineWidthSpinner.setValue(lineStyleInfo.getAttrLineStyle().getLineWidth()); trendLineType.setSelectedItem(trendLine.getTrendLineType()); prePeriod.setValue(trendLine.getPrePeriod()); afterPeriod.setValue(trendLine.getAfterPeriod()); @@ -100,7 +159,11 @@ public class VanChartTrendLinePane extends BasicPane{ trendLine.setTrendLineName(trendLineName.getText()); LineStyleInfo lineStyleInfo = trendLine.getLineStyleInfo(); + //线型支持虚线 恢复用注释。下面1行删除。 lineStyleInfo.setAttrLineStyle(new AttrLineStyle(trendLineStyle.getSelectedLineStyle())); + //线型支持虚线 恢复用注释。取消注释。 +// lineStyleInfo.getAttrLineStyle().setLineWidth(lineWidthSpinner.getValue()); +// lineStyleInfo.getAttrLineStyle().setLineType((LineType) trendLineStyle.getSelectedItem()); lineStyleInfo.setAttrLineColor(new AttrColor(trendLineColor.getSelectObject())); trendLine.setTrendLineType((TrendLineType) trendLineType.getSelectedItem()); @@ -110,4 +173,10 @@ public class VanChartTrendLinePane extends BasicPane{ return trendLine; } + private void checkHidePaneVisible(){ + if (trendLineHidePane != null && trendLineStyle != null){ + trendLineHidePane.setVisible(trendLineStyle.getSelectedItem() != LineType.NONE); + } + } + } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java index 664b3d8cf6..f25cbe9923 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java @@ -4,28 +4,38 @@ import com.fr.base.BaseFormula; import com.fr.base.Utils; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; +import com.fr.chart.chartglyph.ConditionAttr; +import com.fr.chart.chartglyph.ConditionCollection; +import com.fr.chartx.attr.LargeDataModeType; import com.fr.design.formula.TinyFormulaPane; import com.fr.design.gui.ibutton.UIButtonGroup; 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.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; - import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; import com.fr.plugin.chart.axis.type.AxisPlotType; +import com.fr.plugin.chart.base.AttrEffect; +import com.fr.plugin.chart.base.AttrLabel; import com.fr.plugin.chart.base.RefreshMoreLabel; +import com.fr.plugin.chart.base.VanChartAttrMarker; import com.fr.plugin.chart.base.VanChartConstants; import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.base.VanChartZoom; +import com.fr.plugin.chart.map.line.condition.AttrLineEffect; +import com.fr.plugin.chart.scatter.attr.ScatterAttrLabel; import com.fr.plugin.chart.vanchart.VanChart; import com.fr.stable.StableUtils; import com.fr.van.chart.custom.component.VanChartHyperLinkPane; import com.fr.van.chart.designer.AbstractVanChartScrollPane; import com.fr.van.chart.designer.PlotFactory; import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.other.zoom.ZoomPane; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -46,6 +56,10 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { protected UICheckBox fullScreenDisplay; protected UIToggleButton collapse; + protected VanChart chart; + private UIComboBox largeDataMode; + private UISpinner largeModeThresholdNumber; + protected UIButtonGroup isChartAnimation; //坐标轴翻转属性 @@ -53,6 +67,7 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { private AutoRefreshPane autoRefreshPane; + //图表缩放新设计 恢复用注释。删除下面八行代码。 private UIButtonGroup zoomWidget; protected UIButtonGroup zoomGesture;//地图手势缩放 private UIButtonGroup zoomResize; @@ -62,13 +77,16 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { private JPanel changeEnablePane; private JPanel zoomTypePane; - protected VanChartHyperLinkPane superLink; + //图表缩放新设计 恢复用注释。取消注释。 + //private ZoomPane zoomPane; - protected Chart chart; + protected VanChartHyperLinkPane superLink; + private JPanel largeModeThresholdNumberPane; protected JPanel interactivePane; /** * 界面标题. + * * @return 返回标题. */ @@ -82,7 +100,7 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { return new JPanel(); } - private void reLayoutContentPane(VanChartPlot plot){ + private void reLayoutContentPane(VanChartPlot plot) { if (interactivePane != null) { interactivePane.removeAll(); } @@ -90,27 +108,75 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { reloaPane(interactivePane); } - protected JPanel getInteractivePane(VanChartPlot plot){ + protected JPanel getInteractivePane(VanChartPlot plot) { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double[] columnSize = {f, e}; - double[] rowSize = {p,p,p,p,p,p}; + double[] rowSize = {p, p, p, p, p, p, p}; Component[][] components = 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(new double[]{p,p,p}, columnSize, plot),null}, - new Component[]{createAutoRefreshPane(plot),null}, - new Component[]{createHyperlinkPane(),null} + new Component[]{createToolBarPane(getToolBarRowSize(), columnSize), null}, + //大数据模式 恢复用注释。取消注释。 + //new Component[]{createLargeDataModePane(), null}, + new Component[]{createAnimationPane(), null}, + new Component[]{createAxisRotationPane(new double[]{p, p}, columnSize, plot), null}, + new Component[]{createZoomPane(new double[]{p, p, p}, columnSize, plot), null}, + new Component[]{createAutoRefreshPane(plot), null}, + new Component[]{createHyperlinkPane(), null} }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } + //大数据模式 恢复用注释。取消注释。 +// private JPanel createLargeDataModePane() { +// if (!isCurrentChartSupportLargeDataMode()) { +// return null; +// } +// largeDataMode = new UIComboBox(new LargeDataModeType[]{LargeDataModeType.CLOSE, LargeDataModeType.OPEN_BEYOND_THRESHOLD}); +// largeModeThresholdNumber = new UISpinner(0, Integer.MAX_VALUE, 100, chart.getPlot().getLargeDataAttribute().getLargeModeThresholdNumber()); +// +// largeDataMode.addActionListener(new ActionListener() { +// @Override +// public void actionPerformed(ActionEvent e) { +// checkLargeDataMode(); +// } +// }); +// +// Component[][] comps1 = new Component[][]{ +// new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Large_Model")), largeDataMode} +// }; +// Component[][] comps2 = new Component[][]{ +// new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Threshold_Number")), largeModeThresholdNumber} +// }; +// +// double[] row = {TableLayout.PREFERRED}, col = {TableLayout.FILL, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}; +// +// +// JPanel contentPane = new JPanel(new BorderLayout(0, 6)); +// +// contentPane.add(TableLayout4VanChartHelper.createGapTableLayoutPane(comps1, row, col), BorderLayout.CENTER); +// largeModeThresholdNumberPane = TableLayout4VanChartHelper.createGapTableLayoutPane(comps2, row, col); +// contentPane.add(largeModeThresholdNumberPane, BorderLayout.SOUTH); +// +// return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Large_Data"), contentPane); +// } + + protected boolean isCurrentChartSupportLargeDataMode() { + return false; + } + protected JPanel createZoomPane(double[] row, double[] col, VanChartPlot plot) { + //图表缩放新设计 恢复用注释。取消注释。 +// zoomPane = createZoomPane(); +// if (zoomPane == null) { +// return null; +// } +// return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Zoom"), zoomPane); + + //图表缩放新设计 恢复用注释。删除下面方法体所有代码。 if (!plot.isSupportZoomDirection()) { return null; } @@ -134,7 +200,7 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; double[] columnSize = {f, e}; changeEnablePane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, columnSize); - changeEnablePane.setBorder(BorderFactory.createEmptyBorder(10,12,0,0)); + changeEnablePane.setBorder(BorderFactory.createEmptyBorder(10, 12, 0, 0)); zoomTypePane = getzoomTypePane(zoomType); JPanel panel = createZoomPaneContent(zoomWidgetPane, zoomGesturePane, changeEnablePane, zoomTypePane, plot); zoomWidget.addActionListener(new ActionListener() { @@ -146,7 +212,8 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Zoom"), panel); } - + //图表缩放新设计 恢复用注释。删除下面八个方法getzoomTypePane createZoomPaneContent + // checkZoomEnabled getNameArray getValueArray checkZoomPane populateChartZoom updateChartZoom。 protected JPanel getzoomTypePane(UIButtonGroup zoomType) { return TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Zoom_Direction"), zoomType); } @@ -161,26 +228,6 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { return panel; } - private JPanel createAxisRotationPane(double[] row, double[] col, VanChartPlot plot){ - if (!(plot.getAxisPlotType() == AxisPlotType.RECTANGLE)){ - return null; - } - axisRotation = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}); - axisRotation.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - checkZoomEnabled(); - } - }); - Component[][] components = new Component[][]{ - new Component[]{null,null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Reversal")),axisRotation} - }; - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis"), panel); - } - private void checkZoomEnabled() { if (zoomWidget != null && axisRotation != null) { if (axisRotation.getSelectedIndex() == 0) { @@ -195,16 +242,99 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { protected String[] getNameArray() { return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_X_Axis"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Y_Axis") - ,com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_XY_Axis"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")}; + , com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_XY_Axis"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")}; } protected String[] getValueArray() { return new String[]{VanChartConstants.ZOOM_TYPE_X, VanChartConstants.ZOOM_TYPE_Y - ,VanChartConstants.ZOOM_TYPE_XY, VanChartConstants.ZOOM_TYPE_NONE}; + , VanChartConstants.ZOOM_TYPE_XY, VanChartConstants.ZOOM_TYPE_NONE}; } - protected JPanel createToolBarPane(double[] row, double[] col){ + private void checkZoomPane() { + boolean zoomWidgetEnabled = zoomWidget.getSelectedIndex() == 0; + changeEnablePane.setVisible(zoomWidgetEnabled); + zoomType.setEnabled(!zoomWidgetEnabled); + } + + private void populateChartZoom(VanChart chart) { + VanChartZoom zoom = chart.getVanChartZoom(); + if (zoom == null) { + zoom = new VanChartZoom(); + } + zoomWidget.setSelectedIndex(zoom.isZoomVisible() ? 0 : 1); + zoomGesture.setSelectedIndex(zoom.isZoomGesture() ? 0 : 1); + zoomResize.setSelectedIndex(zoom.isZoomResize() ? 0 : 1); + if (zoom.getFrom() instanceof BaseFormula) { + from.populateBean(((BaseFormula) zoom.getFrom()).getContent()); + } else { + from.populateBean(Utils.objectToString(zoom.getFrom())); + } + if (zoom.getTo() instanceof BaseFormula) { + to.populateBean(((BaseFormula) zoom.getTo()).getContent()); + } else { + to.populateBean(Utils.objectToString(zoom.getTo())); + } + zoomType.setSelectedItem(zoom.getZoomType()); + } + + private void updateChartZoom(VanChart chart) { + VanChartZoom zoom = chart.getVanChartZoom(); + if (zoom == null) { + zoom = new VanChartZoom(); + chart.setVanChartZoom(zoom); + } + zoom.setZoomVisible(zoomWidget.getSelectedIndex() == 0); + zoom.setZoomGesture(zoomGesture.getSelectedIndex() == 0); + zoom.setZoomResize(zoomResize.getSelectedIndex() == 0); + String fromString = from.updateBean(); + Object fromObject; + if (StableUtils.maybeFormula(fromString)) { + fromObject = BaseFormula.createFormulaBuilder().build(fromString); + } else { + fromObject = fromString; + } + zoom.setFrom(fromObject); + String toString = to.updateBean(); + Object toObject; + if (StableUtils.maybeFormula(toString)) { + toObject = BaseFormula.createFormulaBuilder().build(toString); + } else { + toObject = toString; + } + zoom.setTo(toObject); + zoom.setZoomType(zoomType.getSelectedItem()); + } + + protected ZoomPane createZoomPane() { + return null; + } + + private JPanel createAxisRotationPane(double[] row, double[] col, VanChartPlot plot) { + if (!(plot.getAxisPlotType() == AxisPlotType.RECTANGLE)) { + return null; + } + axisRotation = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}); + + //图表缩放新设计 恢复用注释。删除下面六行代码。 + axisRotation.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + checkZoomEnabled(); + } + }); + + Component[][] components = new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Reversal")), axisRotation} + }; + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis"), panel); + } + + + protected JPanel createToolBarPane(double[] row, double[] col) { isSort = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Sort")); exportImages = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Export_Image")); fullScreenDisplay = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_FullScreen_Display")); @@ -216,17 +346,17 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_ToolBar"), panel); } - protected double[] getToolBarRowSize () { + protected double[] getToolBarRowSize() { double p = TableLayout.PREFERRED; - return new double[]{p,p,p,p,p}; + return new double[]{p, p, p, p, p}; } protected Component[][] createToolBarComponents() { return new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content")),isSort}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content")), isSort}, new Component[]{null, exportImages}, new Component[]{null, fullScreenDisplay}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout")),collapse}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout")), collapse}, }; } @@ -234,18 +364,18 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { return new Component[][]{ new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content")), exportImages}, new Component[]{null, fullScreenDisplay}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout")),collapse} + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout")), collapse} }; } - protected JPanel createAnimationPane(){ + protected JPanel createAnimationPane() { isChartAnimation = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}); JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Animation_Effects"), isChartAnimation); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Animation"), panel); } - protected JPanel createAutoRefreshPane(VanChartPlot plot){ + protected JPanel createAutoRefreshPane(VanChartPlot plot) { autoRefreshPane = getMoreLabelPane(plot); @@ -254,7 +384,7 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { protected AutoRefreshPane getMoreLabelPane(VanChartPlot plot) { boolean isLargeModel = largeModel(plot); - return new AutoRefreshPane((VanChart) chart, isLargeModel); + return new AutoRefreshPane(chart, isLargeModel); } protected JPanel createHyperlinkPane() { @@ -262,11 +392,42 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_Insert_Hyperlink"), superLink); } + private void checkLargeDataMode() { + largeModeThresholdNumberPane.setVisible(largeDataMode.getSelectedItem() == LargeDataModeType.OPEN_BEYOND_THRESHOLD); - private void checkZoomPane() { - boolean zoomWidgetEnabled = zoomWidget.getSelectedIndex() == 0; - changeEnablePane.setVisible(zoomWidgetEnabled); - zoomType.setEnabled(!zoomWidgetEnabled); + resetAttr(); + } + + private void resetAttr() { + if (largeDataMode.getSelectedItem() == LargeDataModeType.OPEN_BEYOND_THRESHOLD) { + VanChartPlot plot = this.chart.getPlot(); + + AttrLabel attrLabel = plot.getAttrLabelFromConditionCollection(); + if (attrLabel == null) { + attrLabel = plot.getDefaultAttrLabel(); + ConditionAttr defaultAttr = plot.getConditionCollection().getDefaultAttr(); + defaultAttr.addDataSeriesCondition(attrLabel); + } + attrLabel.setEnable(false); + + resetCustomCondition(plot.getConditionCollection()); + } + } + + + public static void resetCustomCondition(ConditionCollection conditionCollection) { + for (int i = 0, len = conditionCollection.getConditionAttrSize(); i < len; i++) { + ConditionAttr conditionAttr = conditionCollection.getConditionAttr(i); + conditionAttr.remove(AttrLabel.class); + conditionAttr.remove(ScatterAttrLabel.class); + conditionAttr.remove(AttrEffect.class); + conditionAttr.remove(AttrLineEffect.class); + + VanChartAttrMarker attrMarker = conditionAttr.getExisted(VanChartAttrMarker.class); + if (attrMarker != null && !attrMarker.isCommon()) { + conditionAttr.remove(VanChartAttrMarker.class); + } + } } @Override @@ -274,28 +435,37 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { if (chart == null || chart.getPlot() == null) { return; } - this.chart = chart; - VanChartPlot plot = (VanChartPlot)chart.getPlot(); + this.chart = (VanChart) chart; + VanChartPlot plot = chart.getPlot(); - if(interactivePane == null){ + if (interactivePane == null) { this.remove(leftcontentPane); reLayoutContentPane(plot); } - if(plot.isSupportZoomDirection()){//支持缩放方向=方向+控件 - populateChartZoom((VanChart)chart); + + //图表缩放新设计 恢复用注释。下面3行取消注释。 +// if (zoomPane != null) { +// zoomPane.populateBean(this.chart.getZoomAttribute()); +// } + + //图表缩放新设计 恢复用注释。删除下面三行代码。 + if (plot.isSupportZoomDirection()) {//支持缩放方向=方向+控件 + populateChartZoom((VanChart) chart); checkZoomPane(); } - if (plot.getAxisPlotType() == AxisPlotType.RECTANGLE){ + if (plot.getAxisPlotType() == AxisPlotType.RECTANGLE) { populateChartAxisRotation(plot); } - populateChartTools((VanChart) chart); - populateChartAnimate(chart, plot); - populateAutoRefresh((VanChart)chart); + populateChartTools(this.chart); + populateLargeMode(plot); + populateChartAnimate(this.chart, plot); + populateAutoRefresh(this.chart); populateHyperlink(plot); + //图表缩放新设计 恢复用注释。删除下面一行代码。 checkZoomEnabled(); } @@ -312,25 +482,14 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { collapse.setSelected(vanChartTools.isHidden()); } - private void populateChartZoom(VanChart chart) { - VanChartZoom zoom = chart.getVanChartZoom(); - if(zoom == null){ - zoom = new VanChartZoom(); - } - zoomWidget.setSelectedIndex(zoom.isZoomVisible() ? 0 : 1); - zoomGesture.setSelectedIndex(zoom.isZoomGesture() ? 0 : 1); - zoomResize.setSelectedIndex(zoom.isZoomResize() ? 0 : 1); - if (zoom.getFrom() instanceof BaseFormula) { - from.populateBean(((BaseFormula) zoom.getFrom()).getContent()); - } else { - from.populateBean(Utils.objectToString(zoom.getFrom())); - } - if (zoom.getTo() instanceof BaseFormula) { - to.populateBean(((BaseFormula) zoom.getTo()).getContent()); - } else { - to.populateBean(Utils.objectToString(zoom.getTo())); - } - zoomType.setSelectedItem(zoom.getZoomType()); + private void populateLargeMode(Plot plot) { + //大数据模式 恢复用注释。取消注释。 +// if (largeDataMode != null) { +// LargeDataAttribute attribute = plot.getLargeDataAttribute(); +// +// largeDataMode.setSelectedItem(attribute.getLargeDataModeType()); +// largeModeThresholdNumber.setValue(attribute.getLargeModeThresholdNumber()); +// } } private void populateChartAxisRotation(VanChartPlot plot) { @@ -338,7 +497,7 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { } private void populateChartAnimate(Chart chart, Plot plot) { - if(plot.isSupportAnimate()) { + if (plot.isSupportAnimate()) { isChartAnimation.setSelectedIndex(chart.isJSDraw() ? 0 : 1); isChartAnimation.setEnabled(!largeModel(plot)); } @@ -349,11 +508,11 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { } protected void populateAutoRefresh(VanChart chart) { - VanChartPlot plot = (VanChartPlot)chart.getPlot(); + VanChartPlot plot = chart.getPlot(); RefreshMoreLabel refreshMoreLabel = chart.getRefreshMoreLabel(); - if(refreshMoreLabel == null) { - refreshMoreLabel = new RefreshMoreLabel(((VanChartPlot)chart.getPlot()).getAutoAttrTooltip()); + if (refreshMoreLabel == null) { + refreshMoreLabel = new RefreshMoreLabel(((VanChartPlot) chart.getPlot()).getAutoAttrTooltip()); } autoRefreshPane.populateBean(refreshMoreLabel); @@ -366,21 +525,29 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { return; } - VanChartPlot plot = (VanChartPlot)chart.getPlot(); + VanChart vanChart = (VanChart) chart; + VanChartPlot plot = chart.getPlot(); - if(plot.isSupportZoomDirection()){ - updateChartZoom((VanChart)chart); + //图表缩放新设计 恢复用注释。下面3行取消注释。 +// if (zoomPane != null) { +// vanChart.setZoomAttribute(zoomPane.updateBean()); +// } + //图表缩放新设计 恢复用注释。下面3行删除。 + if (plot.isSupportZoomDirection()) { + updateChartZoom((VanChart) chart); } - if(plot.getAxisPlotType() == AxisPlotType.RECTANGLE){ - updateChartAxisRotation((VanChart)chart); + + if (plot.getAxisPlotType() == AxisPlotType.RECTANGLE) { + updateChartAxisRotation(vanChart); } - updateChartTools((VanChart)chart); - updateChartAnimate(chart, plot); - updateAutoRefresh((VanChart)chart); + updateChartTools(vanChart); + updateChartAnimate(vanChart, plot); + updateLargeData(plot); + updateAutoRefresh(vanChart); updateHyperlink(plot); } - protected void updateHyperlink(Plot plot){ + protected void updateHyperlink(Plot plot) { superLink.update(plot); } @@ -393,37 +560,9 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { chart.setVanChartTools(vanChartTools); } - private void updateChartZoom(VanChart chart) { - VanChartZoom zoom = chart.getVanChartZoom(); - if(zoom == null){ - zoom = new VanChartZoom(); - chart.setVanChartZoom(zoom); - } - zoom.setZoomVisible(zoomWidget.getSelectedIndex() == 0); - zoom.setZoomGesture(zoomGesture.getSelectedIndex() == 0); - zoom.setZoomResize(zoomResize.getSelectedIndex() == 0); - String fromString = from.updateBean(); - Object fromObject; - if (StableUtils.maybeFormula(fromString)) { - fromObject = BaseFormula.createFormulaBuilder().build(fromString); - } else { - fromObject = fromString; - } - zoom.setFrom(fromObject); - String toString = to.updateBean(); - Object toObject; - if (StableUtils.maybeFormula(toString)) { - toObject = BaseFormula.createFormulaBuilder().build(toString); - } else { - toObject = toString; - } - zoom.setTo(toObject); - zoom.setZoomType(zoomType.getSelectedItem()); - } - private void updateChartAxisRotation(VanChart chart) { //坐标轴和plot都需要这个属性,因为坐标轴和plot是分开画的 - VanChartPlot plot = (VanChartPlot) chart.getPlot(); + VanChartPlot plot = chart.getPlot(); plot.setAxisRotation(axisRotation.getSelectedIndex() == 0); //同时更新坐标轴旋转属性 for (VanChartAxis axis : ((VanChartRectanglePlot) plot).getXAxisList()) { @@ -435,14 +574,24 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { } //更新数据表属性 - if (plot.isAxisRotation()){ + if (plot.isAxisRotation()) { plot.getDataSheet().setVisible(false); } } + private void updateLargeData(Plot plot) { + //大数据模式 恢复用注释。取消注释。 +// if (largeDataMode != null) { +// LargeDataAttribute attribute = new LargeDataAttribute(); +// attribute.setLargeDataModeType((LargeDataModeType) largeDataMode.getSelectedItem()); +// attribute.setLargeModeThresholdNumber(largeModeThresholdNumber.getValue()); +// plot.setLargeDataAttribute(attribute); +// } + } + private void updateChartAnimate(Chart chart, Plot plot) { - if(plot.isSupportAnimate()) { - chart.setJSDraw(isChartAnimation.getSelectedIndex()==0); + if (plot.isSupportAnimate()) { + chart.setJSDraw(isChartAnimation.getSelectedIndex() == 0); } } @@ -450,15 +599,15 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { private void updateAutoRefresh(VanChart chart) { RefreshMoreLabel refreshMoreLabel = chart.getRefreshMoreLabel(); - if(refreshMoreLabel == null) { - refreshMoreLabel = new RefreshMoreLabel(((VanChartPlot)chart.getPlot()).getAutoAttrTooltip()); + if (refreshMoreLabel == null) { + refreshMoreLabel = new RefreshMoreLabel(((VanChartPlot) chart.getPlot()).getAutoAttrTooltip()); chart.setRefreshMoreLabel(refreshMoreLabel); } autoRefreshPane.updateBean(refreshMoreLabel); } @Override - public Chart updateBean() { + public VanChart updateBean() { return null; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePaneWithMapZoom.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePaneWithMapZoom.java index ec1ed0d9db..7de7ca3d5d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePaneWithMapZoom.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePaneWithMapZoom.java @@ -9,6 +9,8 @@ import java.awt.BorderLayout; * Created by mengao on 2017/4/7. */ public class VanChartInteractivePaneWithMapZoom extends VanChartInteractivePaneWithOutSort { + + //图表缩放新设计 恢复用注释。删除下面方法 createZoomPaneContent。 @Override protected JPanel createZoomPaneContent(JPanel zoomWidgetPane, JPanel zoomGesturePane, JPanel changeEnablePane, JPanel zoomTypePane, VanChartPlot plot) { JPanel panel = new JPanel(new BorderLayout(0, 4)); @@ -16,4 +18,10 @@ public class VanChartInteractivePaneWithMapZoom extends VanChartInteractivePaneW panel.add(zoomGesturePane, BorderLayout.CENTER); return panel; } + + //图表缩放新设计 恢复用注释。取消注释。 +// @Override +// protected ZoomPane createZoomPane() { +// return new MapZoomPane(); +// } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/MapZoomPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/MapZoomPane.java new file mode 100644 index 0000000000..22395cd9e5 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/MapZoomPane.java @@ -0,0 +1,47 @@ +package com.fr.van.chart.designer.other.zoom; + +import com.fr.chartx.attr.ZoomAttribute; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; + +import java.awt.Component; + +/** + * Created by shine on 2019/08/28. + */ +public class MapZoomPane extends ZoomPane { + + private UIButtonGroup mapZoomWidget;//地图缩放控件 + private UIButtonGroup gestureZoomGroup;//地图手势缩放 + + @Override + protected Component[][] getSouthComps() { + mapZoomWidget = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open") + , Toolkit.i18nText("Fine-Design_Chart_Close")}, new Boolean[]{true, false}); + + gestureZoomGroup = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open") + , Toolkit.i18nText("Fine-Design_Chart_Close")}, new Boolean[]{true, false}); + + + return new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Zoom_Widget")), mapZoomWidget}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_ZoomGesture")), gestureZoomGroup} + }; + } + + @Override + public void populateBean(ZoomAttribute ob) { + super.populateBean(ob); + mapZoomWidget.setSelectedItem(ob.isMapZoomWidget()); + gestureZoomGroup.setSelectedItem(ob.isGestureZoom()); + } + + @Override + public ZoomAttribute updateBean() { + ZoomAttribute zoomAttribute = super.updateBean(); + zoomAttribute.setMapZoomWidget(mapZoomWidget.getSelectedItem()); + zoomAttribute.setGestureZoom(gestureZoomGroup.getSelectedItem()); + return zoomAttribute; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPane.java new file mode 100644 index 0000000000..dfbf2d640a --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPane.java @@ -0,0 +1,252 @@ +package com.fr.van.chart.designer.other.zoom; + +import com.fr.chartx.attr.ZoomAttribute; +import com.fr.chartx.attr.ZoomInitialDisplayType; +import com.fr.chartx.attr.ZoomModeType; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.extended.chart.StringFormula; +import com.fr.general.ComparatorUtils; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +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.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Arrays; + +/** + * Created by shine on 2019/08/28. + */ +public class ZoomPane extends BasicBeanPane { + + private UIButtonGroup modeTypeButtonGroup; + + private JPanel customModePane; + private UIComboBox initialDisplayTypeComboBox; + private JPanel initialDisplayCardPane; + private UISpinner topCategorySpinner; + private TinyFormulaPane leftFormulaPane; + private TinyFormulaPane rightFormulaPane; + + private UIButtonGroup selectionZoomGroup; + + public ZoomPane() { + initComponent(); + } + + private void initComponent() { + + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; + double p = TableLayout.PREFERRED; + double[] columnSize = {f, e}; + + JPanel northPane = createNorthPane(f, p); + + initCustomModePane(columnSize, p); + + JPanel southPane = createSouthPane(f, p); + + this.setLayout(new BorderLayout(0, 6)); + + if (northPane != null) { + this.add(northPane, BorderLayout.NORTH); + } + if (customModePane != null) { + this.add(customModePane, BorderLayout.CENTER); + } + if (southPane != null) { + this.add(southPane, BorderLayout.SOUTH); + } + } + + protected JPanel createNorthPane(double f, double p) { + modeTypeButtonGroup = new UIButtonGroup(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Mode_Auto"), + Toolkit.i18nText("Fine-Design_Chart_Mode_Custom"), + Toolkit.i18nText("Fine-Design_Chart_Close") + }, new ZoomModeType[]{ZoomModeType.AUTO, ZoomModeType.CUSTOM, ZoomModeType.CLOSE}); + + modeTypeButtonGroup.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + checkCustomModePane(); + } + }); + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Zoom_Mode_type")), modeTypeButtonGroup} + }; + return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p} + , new double[]{f, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}); + } + + private JPanel createSouthPane(double f, double p) { + + Component[][] components = getSouthComps(); + + double[] rows = new double[components.length]; + Arrays.fill(rows, p); + + return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rows + , new double[]{f, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}); + } + + protected Component[][] getSouthComps() { + selectionZoomGroup = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open") + , Toolkit.i18nText("Fine-Design_Chart_Close")}, new Boolean[]{true, false}); + + return new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Selection_Zoom")), selectionZoomGroup} + }; + } + + protected void initCustomModePane(double[] columnSize, double p) { + initialDisplayTypeComboBox = new UIComboBox(new ZoomInitialDisplayType[]{ + ZoomInitialDisplayType.TOP_CATEGORY, + ZoomInitialDisplayType.LEFT_RIGHT_BOUNDARY}); + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_InitialDisplay")), initialDisplayTypeComboBox} + }; + JPanel northPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p}, columnSize); + + + initInitialDisplayCardPane(columnSize, p); + + customModePane = new JPanel(new BorderLayout(0, 6)); + customModePane.add(northPane, BorderLayout.NORTH); + customModePane.add(initialDisplayCardPane, BorderLayout.CENTER); + customModePane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); + } + + private void initInitialDisplayCardPane(double[] columnSize, double p) { + topCategorySpinner = new UISpinner(1, Integer.MAX_VALUE, 1); + Component[][] components1 = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Category_Number")), topCategorySpinner} + }; + final JPanel topPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components1, new double[]{p}, columnSize); + + + leftFormulaPane = new TinyFormulaPane(); + rightFormulaPane = new TinyFormulaPane(); + Component[][] components2 = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Left_Boundary")), leftFormulaPane}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Right_Boundary")), rightFormulaPane} + }; + final JPanel leftRightPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components2, new double[]{p, p}, columnSize); + + initialDisplayCardPane = new JPanel(new CardLayout()) { + @Override + public Dimension getPreferredSize() { + return initialDisplayTypeComboBox.getSelectedIndex() == 0 ? topPane.getPreferredSize() : leftRightPane.getPreferredSize(); + } + }; + initialDisplayCardPane.add(topPane, ZoomInitialDisplayType.TOP_CATEGORY.toString()); + initialDisplayCardPane.add(leftRightPane, ZoomInitialDisplayType.LEFT_RIGHT_BOUNDARY.toString()); + initialDisplayTypeComboBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkInitialDisplayCardPane(); + } + }); + } + + private void checkCustomModePane() { + if (customModePane == null){ + return; + } + customModePane.setVisible(modeTypeButtonGroup.getSelectedItem() == ZoomModeType.CUSTOM); + } + + private void checkInitialDisplayCardPane() { + if (initialDisplayCardPane == null){ + return; + } + + CardLayout cardLayout = (CardLayout) initialDisplayCardPane.getLayout(); + if (ComparatorUtils.equals(initialDisplayTypeComboBox.getSelectedItem(), ZoomInitialDisplayType.TOP_CATEGORY)) { + cardLayout.show(initialDisplayCardPane, ZoomInitialDisplayType.TOP_CATEGORY.toString()); + } else { + cardLayout.show(initialDisplayCardPane, ZoomInitialDisplayType.LEFT_RIGHT_BOUNDARY.toString()); + } + } + + + @Override + public void populateBean(ZoomAttribute ob) { + if (modeTypeButtonGroup != null) { + modeTypeButtonGroup.setSelectedItem(ob.getModeType()); + } + + if (initialDisplayTypeComboBox != null){ + initialDisplayTypeComboBox.setSelectedItem(ob.getInitialDisplayType()); + } + + if (topCategorySpinner != null) { + topCategorySpinner.setValue(ob.getTopCategory()); + } + + if (ob.getLeft() != null && leftFormulaPane != null) { + leftFormulaPane.populateBean(ob.getLeft().getContent()); + } + if (ob.getRight() != null && rightFormulaPane != null) { + rightFormulaPane.populateBean(ob.getRight().getContent()); + } + + if (selectionZoomGroup != null) { + selectionZoomGroup.setSelectedItem(ob.isSelectionZoom()); + } + + checkInitialDisplayCardPane(); + checkCustomModePane(); + } + + @Override + public ZoomAttribute updateBean() { + ZoomAttribute zoomAttribute = new ZoomAttribute(); + + if (modeTypeButtonGroup != null) { + zoomAttribute.setModeType(modeTypeButtonGroup.getSelectedItem()); + } + + if (initialDisplayTypeComboBox != null) { + zoomAttribute.setInitialDisplayType((ZoomInitialDisplayType) initialDisplayTypeComboBox.getSelectedItem()); + } + + if (topCategorySpinner != null){ + zoomAttribute.setTopCategory((int) topCategorySpinner.getValue()); + } + + if (leftFormulaPane != null){ + zoomAttribute.setLeft(new StringFormula(leftFormulaPane.updateBean())); + } + + if (rightFormulaPane != null){ + zoomAttribute.setRight(new StringFormula(rightFormulaPane.updateBean())); + } + + if (selectionZoomGroup != null) { + zoomAttribute.setSelectionZoom(selectionZoomGroup.getSelectedItem()); + } + + return zoomAttribute; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPaneWithOutMode.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPaneWithOutMode.java new file mode 100644 index 0000000000..5edda21333 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/zoom/ZoomPaneWithOutMode.java @@ -0,0 +1,18 @@ +package com.fr.van.chart.designer.other.zoom; + +import javax.swing.JPanel; + +/** + * Created by shine on 2019/08/28. + */ +public class ZoomPaneWithOutMode extends ZoomPane { + @Override + protected JPanel createNorthPane(double f, double p) { + return null; + } + + @Override + protected void initCustomModePane(double[] columnSize, double p) { + //do nothing + } +} 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 d3a437ef25..f4e1127f24 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 @@ -13,7 +13,6 @@ 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.utils.gui.UIComponentUtils; import com.fr.plugin.chart.attr.VanChartLegend; import com.fr.stable.Constants; @@ -55,11 +54,14 @@ public class VanChartPlotLegendPane extends BasicPane { protected UIButtonGroup location; protected UIToggleButton customFloatPositionButton; protected VanChartFloatPositionPane customFloatPositionPane; + + //区域显示策略 恢复用注释。下面4行删除。 protected UIButtonGroup limitSize; protected UISpinner maxProportion; private UILabel limitSizeTitle; private JPanel maxProportionPane; - + //区域显示策略 恢复用注释。取消注释。 + //private LimitPane limitPane; //高亮显示的按钮 protected UIButtonGroup highlightButton; @@ -180,7 +182,7 @@ public class VanChartPlotLegendPane extends BasicPane { initPositionListener(); JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components,row,col); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), panel); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Form_Layout"), panel); } private void initPositionListener(){ @@ -232,14 +234,15 @@ public class VanChartPlotLegendPane extends BasicPane { } protected JPanel createDisplayStrategy(){ - maxProportion = new UISpinner(0,100,1,30); - limitSize = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Limit"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Not_Limit")}); + //区域显示策略 恢复用注释。开始删除。 + maxProportion = new UISpinner(0, 100, 1, 30); + limitSize = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Limit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Not_Limit")}); limitSizeTitle = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Max_Proportion")); - JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Size"),limitSize); - maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"),maxProportion,TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); - maxProportionPane.setBorder(BorderFactory.createEmptyBorder(0,12,0,0)); + JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Size"), limitSize); + maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"), maxProportion, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + maxProportionPane.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); JPanel panel = new JPanel(new BorderLayout()); panel.add(limitSizePane, BorderLayout.NORTH); panel.add(maxProportionPane, BorderLayout.CENTER); @@ -251,6 +254,11 @@ public class VanChartPlotLegendPane extends BasicPane { } }); return panel; + //区域显示策略 恢复用注释。结束删除。 + + //区域显示策略 恢复用注释。取消注释。 +// limitPane = new LimitPane(false); +// return limitPane; } private JPanel createHighlightPane(){ @@ -276,15 +284,19 @@ public class VanChartPlotLegendPane extends BasicPane { //检查显示策略界面是否可用 protected void checkDisplayStrategyUse() { + //区域显示策略 恢复用注释。下面2行删除。 limitSize.setEnabled(!customFloatPositionButton.isSelected()); checkMaxProPortionUse(); + //区域显示策略 恢复用注释。取消注释。 +// GUICoreUtils.setEnabled(limitPane, !customFloatPositionButton.isSelected()); +// limitPane.checkMaxProPortionUse(); } + //区域显示策略 恢复用注释。删除下面方法。 //检查最大显示占比是否可用 private void checkMaxProPortionUse() { maxProportion.setVisible(limitSize.getSelectedIndex() == 0 && limitSize.isEnabled()); maxProportionPane.setVisible(limitSize.getSelectedIndex() == 0 && limitSize.isEnabled()); - } protected void checkBoxUse() { @@ -315,8 +327,11 @@ public class VanChartPlotLegendPane extends BasicPane { legend.setPosition(-1); } legend.setFloating(customFloatPositionButton.isSelected()); + //区域显示策略 恢复用注释。下面2行删除。 legend.setLimitSize(limitSize.getSelectedIndex() == 0); legend.setMaxHeight(maxProportion.getValue()); + //区域显示策略 恢复用注释。取消注释。 + //legend.setLimitAttribute(limitPane.updateBean()); legend.setFloatPercentX(customFloatPositionPane.getFloatPosition_x()); legend.setFloatPercentY(customFloatPositionPane.getFloatPosition_y()); if(highlightButton != null && highlightButton.getSelectedItem() != null){ @@ -336,8 +351,11 @@ public class VanChartPlotLegendPane extends BasicPane { customFloatPositionButton.setSelected(legend.isFloating()); customFloatPositionPane.setFloatPosition_x(legend.getFloatPercentX()); customFloatPositionPane.setFloatPosition_y(legend.getFloatPercentY()); + //区域显示策略 恢复用注释。下面2行删除。 limitSize.setSelectedIndex(legend.isLimitSize() ? 0 : 1); maxProportion.setValue(legend.getMaxHeight()); + //区域显示策略 恢复用注释。取消注释。 + //limitPane.populateBean(legend.getLimitAttribute()); if(highlightButton != null){ highlightButton.setSelectedItem(legend.isHighlight()); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java index 39d0b8f1bd..2e7ae32781 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java @@ -192,26 +192,12 @@ public class VanChartRangeLegendPane extends VanChartPlotLegendPane { public void populateBean(VanChartLegend legend) { VanChartRangeLegend scatterLegend = (VanChartRangeLegend)legend; if (scatterLegend != null) { - isLegendVisible.setSelected(scatterLegend.isLegendVisible()); - textAttrPane.populate(scatterLegend.getFRFont()); - borderPane.populate(scatterLegend); - backgroundPane.populate(scatterLegend); - if(!scatterLegend.isFloating()){ - location.setSelectedItem(scatterLegend.getPosition()); - } - customFloatPositionButton.setSelected(scatterLegend.isFloating()); - customFloatPositionPane.setFloatPosition_x(scatterLegend.getFloatPercentX()); - customFloatPositionPane.setFloatPosition_y(scatterLegend.getFloatPercentY()); - limitSize.setSelectedIndex(scatterLegend.isLimitSize() ? 0 : 1); - maxProportion.setValue(scatterLegend.getMaxHeight()); + //范围图例部分 legendTypeButton.setSelectedItem(scatterLegend.getLegendType()); gradualLegendPane.populate(scatterLegend.getGradualLegend()); sectionLegendPane.populate(scatterLegend.getSectionLegend()); - - if(highlightButton != null){ - highlightButton.setSelectedItem(legend.isHighlight()); - } + super.populateBean(scatterLegend); } checkAllUse(); this.checkHighlightVisible(); 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 c99dccace9..6a7987bcdb 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 @@ -16,7 +16,6 @@ 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.utils.gui.UIComponentUtils; import com.fr.plugin.chart.attr.VanChartTitle; import com.fr.plugin.chart.vanchart.VanChart; @@ -60,9 +59,13 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { private UIToggleButton useHtml; private UIToggleButton customFloatPositionButton; private VanChartFloatPositionPane customFloatPositionPane; + + //区域显示策略 恢复用注释。下面3行删除。 private UIButtonGroup limitSize; private UISpinner maxProportion; private JPanel maxProportionPane; + //区域显示策略 恢复用注释。取消注释。 + //private LimitPane limitPane; protected VanChartStylePane parent; @@ -162,7 +165,7 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { initPositionListener(); JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components,row,col); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout"), panel); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Form_Layout"), panel); } private JPanel createTitleStylePane(){ @@ -171,12 +174,13 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { } private JPanel createDisplayStrategy(){ - maxProportion = new UISpinner(0,100,1,30); - limitSize = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Limit"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Not_Limit")}); + //区域显示策略 恢复用注释。开始删除。 + maxProportion = new UISpinner(0, 100, 1, 30); + limitSize = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Limit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Not_Limit")}); - JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Size"),limitSize); - maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"),maxProportion, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); - maxProportionPane.setBorder(BorderFactory.createEmptyBorder(0,12,0,0)); + JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Size"), limitSize); + maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"), maxProportion, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + maxProportionPane.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); JPanel panel = new JPanel(new BorderLayout()); panel.add(limitSizePane, BorderLayout.NORTH); panel.add(maxProportionPane, BorderLayout.CENTER); @@ -189,6 +193,12 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { }); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel); + + //区域显示策略 恢复用注释。结束删除。 + + //区域显示策略 恢复用注释。取消注释。 +// limitPane = new LimitPane(); +// return limitPane; } private void initPositionListener(){ @@ -250,10 +260,15 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { //检查显示策略界面是否可用 private void checkDisplayStrategyUse() { + //区域显示策略 恢复用注释。下面2行删除。 limitSize.setEnabled(!customFloatPositionButton.isSelected()); checkMaxProPortionUse(); + //区域显示策略 恢复用注释。取消注释。 +// GUICoreUtils.setEnabled(limitPane, !customFloatPositionButton.isSelected()); +// limitPane.checkMaxProPortionUse(); } + //区域显示策略 恢复用注释。删除下面方法。 //检查最大显示占比是否可用 private void checkMaxProPortionUse() { maxProportion.setVisible(limitSize.getSelectedIndex() == 0 && limitSize.isEnabled()); @@ -301,8 +316,11 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { customFloatPositionButton.setSelected(title.isFloating()); customFloatPositionPane.setFloatPosition_x(title.getFloatPercentX()); customFloatPositionPane.setFloatPosition_y(title.getFloatPercentY()); + //区域显示策略 恢复用注释。下面2行删除。 limitSize.setSelectedIndex(title.isLimitSize() ? 0 : 1); maxProportion.setValue(title.getMaxHeight()); + //区域显示策略 恢复用注释。取消注释。 + //limitPane.populateBean(title.getLimitAttribute()); checkAllUse(); } @@ -335,8 +353,11 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { } title.setUseHtml(useHtml.isSelected()); title.setFloating(customFloatPositionButton.isSelected()); + //区域显示策略 恢复用注释。下面2行删除。 title.setLimitSize(limitSize.getSelectedIndex() == 0); title.setMaxHeight(maxProportion.getValue()); + //区域显示策略 恢复用注释。取消注释。 + //title.setLimitAttribute(limitPane.updateBean()); title.setFloatPercentX(customFloatPositionPane.getFloatPosition_x()); title.setFloatPercentY(customFloatPositionPane.getFloatPosition_y()); textAttrPane.update(textAttr); 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 ac88b9be4d..064a7156bd 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 @@ -15,6 +15,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.style.FormatPane; +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; @@ -23,11 +24,13 @@ import com.fr.design.style.color.ColorSelectBox; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.plugin.chart.attr.axis.VanChartAxis; +import com.fr.plugin.chart.base.OverlapHandleType; import com.fr.plugin.chart.base.VanChartConstants; import com.fr.plugin.chart.type.AxisTickLineType; import com.fr.stable.Constants; import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartHtmlLabelPane; import com.fr.van.chart.designer.style.VanChartStylePane; @@ -36,6 +39,8 @@ import javax.swing.BorderFactory; import javax.swing.Icon; 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.CardLayout; import java.awt.Component; @@ -58,10 +63,18 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { protected UIButtonGroup showLabel; protected ChartTextAttrPane labelTextAttrPane; protected UINumberDragPane labelTextRotation; - protected UIButtonGroup labelGapStyle; + + //轴标签缩略间隔显示 恢复用注释。下面6行删除。 protected UITextField labelGapValue; - protected JPanel labelPanel; + private UIButtonGroup overlapHandleTypeGroup; + protected UIButtonGroup labelGapStyle; + //轴标签缩略间隔显示 恢复用注释。取消注释。 + //protected UISpinner labelGapValue; + + protected JPanel labelPanel; + private JPanel labelGapStylePane; + private JPanel labelGapValuePane; protected LineComboBox axisLineStyle; protected ColorSelectBox axisLineColor; @@ -71,15 +84,17 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { protected UIButtonGroup position; protected UIButtonGroup reversed; + //区域显示策略 恢复用注释。下面3行删除。 protected UIButtonGroup axisLimitSize; protected UISpinner maxProportion; protected JPanel maxProportionPane; + //区域显示策略 恢复用注释。取消注释。 + //private LimitPane limitPane; protected UIButtonGroup valueFormatStyle; protected FormatPane valueFormat; protected JPanel centerPane; private VanChartHtmlLabelPane htmlLabelPane; - private JPanel labelGapValuePane; public VanChartBaseAxisPane(){ this(true); @@ -112,7 +127,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { new Component[]{createLabelPane(new double[]{p, p}, column), null}, new Component[]{createLineStylePane(new double[]{p, p, p, p, p}, columnSize), null}, new Component[]{createAxisPositionPane(new double[]{p, p, p}, columnSize, isXAxis), null}, - new Component[]{createDisplayStrategy(new double[]{p, p, p}, columnSize), null}, + new Component[]{createDisplayStrategy(), null}, new Component[]{createValueStylePane(), null}, }; @@ -169,8 +184,8 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { showLabel = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Show"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Hidden")}); labelTextAttrPane = getChartTextAttrPane(); - labelTextRotation = new UINumberDragPane(-ROTATION_MAX,ROTATION_MAX); - labelGapStyle = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Automatic"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Fixed")}); + labelTextRotation = new UINumberDragPane(-ROTATION_MAX, ROTATION_MAX); + labelGapStyle = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Automatic"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Fixed")}); labelGapValue = new UITextField(); Component[][] gapComponents = new Component[][]{ new Component[]{ @@ -180,14 +195,14 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Label_Interval")), labelGapStyle}, }; JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(gapComponents, row, col); - labelGapValuePane= TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText(""),labelGapValue, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + labelGapValuePane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText(""), labelGapValue, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); JPanel gapPanel = new JPanel(new BorderLayout()); gapPanel.add(panel, BorderLayout.CENTER); gapPanel.add(labelGapValuePane, BorderLayout.SOUTH); - Component[][] components = new Component[][]{ + Component[][] components = new Component[][]{ new Component[]{labelTextAttrPane, null}, - new Component[]{gapPanel,null}, + new Component[]{gapPanel, null}, }; JPanel showLabelPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Label"),showLabel); @@ -211,6 +226,88 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { return TableLayout4VanChartHelper.createExpandablePaneWithTitle(PaneTitleConstants.CHART_STYLE_LABEL_TITLE, jPanel); } +// protected JPanel createLabelPane(double[] row, double[] col){ +// double p = TableLayout.PREFERRED; +// showLabel = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Show"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Hidden")}); +// labelTextAttrPane = getChartTextAttrPane(); +// +// JPanel rotationPane = createLabelRotationPane(col); +// JPanel overlapPane = createLabelOverlapPane(); +// +// +// Component[][] components = new Component[][]{ +// new Component[]{labelTextAttrPane, null}, +// new Component[]{rotationPane, null}, +// new Component[]{overlapPane, null}, +// }; +// +// JPanel showLabelPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Label"),showLabel); +// labelPanel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p, p}, col); +// labelPanel.setBorder(BorderFactory.createEmptyBorder(0,10,0,0)); +// showLabel.addActionListener(new ActionListener() { +// @Override +// public void actionPerformed(ActionEvent e) { +// checkLabelPane(); +// } +// }); +// JPanel jPanel = new JPanel(new BorderLayout()); +// jPanel.add(showLabelPane, BorderLayout.NORTH); +// jPanel.add(labelPanel, BorderLayout.CENTER); +// return TableLayout4VanChartHelper.createExpandablePaneWithTitle(PaneTitleConstants.CHART_STYLE_LABEL_TITLE, jPanel); +// } + + private JPanel createLabelRotationPane(double[] col) { + labelTextRotation = new UINumberDragPane(-ROTATION_MAX, ROTATION_MAX); + + Component[][] gapComponents = new Component[][]{ + new Component[]{ + FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TextRotation")), + UIComponentUtils.wrapWithBorderLayoutPane(labelTextRotation) + } + }; + return TableLayout4VanChartHelper.createGapTableLayoutPane(gapComponents, new double[]{TableLayout.PREFERRED}, col); + } + + private JPanel createLabelOverlapPane() { + + labelGapStyle = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Automatic"), Toolkit.i18nText("Fine-Design_Chart_Fixed")}); + labelGapStylePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Label_Interval"), labelGapStyle, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + + //轴标签缩略间隔显示 恢复用注释。取消注释。 + //labelGapValue = new UISpinner(0, Integer.MAX_VALUE, 1, 1); + labelGapValuePane = TableLayout4VanChartHelper.createGapTableLayoutPane(StringUtils.EMPTY, labelGapValue, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + + JPanel panel = new JPanel(new BorderLayout(0, 0)); + addOverlapGroupButton(panel); + panel.add(labelGapStylePane, BorderLayout.CENTER); + panel.add(labelGapValuePane, BorderLayout.SOUTH); + + labelGapStyle.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkLabelGapValuePane(); + } + }); + + return panel; + } + + protected void addOverlapGroupButton(JPanel panel) { + overlapHandleTypeGroup = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Label_OverlapAbbreviate"), Toolkit.i18nText("Fine-Design_Chart_Label_OverlapInterval")}, + new OverlapHandleType[]{OverlapHandleType.ABBREVIATE, OverlapHandleType.INTERVAL}); + JPanel north = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Label_WhenOverlap"), overlapHandleTypeGroup, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + + panel.add(north, BorderLayout.NORTH); + + overlapHandleTypeGroup.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + checkLabelGapAndStylePane(); + } + }); + + } + protected ChartTextAttrPane getChartTextAttrPane(){ return new ChartTextAttrPane(){ @@ -285,13 +382,14 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { } } - protected JPanel createDisplayStrategy(double[] row, double[] col){ - maxProportion = new UISpinner(0,100,1,30); - axisLimitSize = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Limit"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Not_Limit")}); + protected JPanel createDisplayStrategy(){ + //区域显示策略 恢复用注释。删除到return,即除了注释的代码都删除。 + maxProportion = new UISpinner(0, 100, 1, 30); + axisLimitSize = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Limit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Not_Limit")}); - JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Size"),axisLimitSize); - maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"),maxProportion, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); - maxProportionPane.setBorder(BorderFactory.createEmptyBorder(0,12,0,0)); + JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Size"), axisLimitSize); + maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"), maxProportion, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + maxProportionPane.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); JPanel panel = new JPanel(new BorderLayout()); panel.add(limitSizePane, BorderLayout.NORTH); panel.add(maxProportionPane, BorderLayout.CENTER); @@ -304,6 +402,10 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { }); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel); + + //区域显示策略 恢复用注释。取消注释。 +// limitPane = new LimitPane(); +// return limitPane; } protected JPanel createValueStylePane(){ @@ -360,7 +462,21 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { protected void checkAllUse() { checkCardPane(); checkLabelPane(); + //区域显示策略 恢复用注释。删除下面一行。 checkMaxProPortionUse(); + + //区域显示策略 恢复用注释。取消注释。 +// if (limitPane != null){ +// limitPane.checkMaxProPortionUse(); +// } + } + + //区域显示策略 恢复用注释。删除此方法。 + //检查最大显示占比是否可用 + private void checkMaxProPortionUse() { + if (maxProportionPane != null && axisLimitSize != null) { + maxProportionPane.setVisible(axisLimitSize.getSelectedIndex() == 0 && axisLimitSize.isEnabled()); + } } protected void checkCardPane() { @@ -381,24 +497,35 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { labelPanel.setVisible(enabled); } if(enabled){ + //轴标签缩略间隔显示 恢复用注释。下面1行删除。 checkLabelGapValuePane(); + //轴标签缩略间隔显示 恢复用注释。取消注释。 + //checkLabelGapAndStylePane(); } } } - protected void checkLabelGapValuePane() { - if(labelGapValuePane != null && labelGapStyle != null){ - labelGapValuePane.setVisible(labelGapStyle.getSelectedIndex() == 1); + private void checkLabelGapAndStylePane() { + if (overlapHandleTypeGroup != null && labelGapStylePane != null) { + boolean visible = overlapHandleTypeGroup.getSelectedItem() == OverlapHandleType.INTERVAL; + + labelGapStylePane.setVisible(visible); } + checkLabelGapValuePane(); } - //检查最大显示占比是否可用 - private void checkMaxProPortionUse() { - if(maxProportionPane != null && axisLimitSize != null){ - maxProportionPane.setVisible(axisLimitSize.getSelectedIndex() == 0 && axisLimitSize.isEnabled()); + protected void checkLabelGapValuePane() { + if (labelGapValuePane != null && labelGapStyle != null) { + boolean visible = labelGapStyle.getSelectedIndex() == 1; + //轴标签缩略间隔显示 恢复用注释。取消注释。 +// if (overlapHandleTypeGroup != null) { +// visible = visible && overlapHandleTypeGroup.getSelectedItem() == OverlapHandleType.INTERVAL; +// } + labelGapValuePane.setVisible(visible); } } + /** * 是否是指定类型 * @param ob 对象 @@ -477,11 +604,18 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { if(labelTextRotation != null){ labelTextRotation.populateBean((double)labelTextAttr.getRotation()); } + //轴标签缩略间隔显示 恢复用注释。取消注释。 +// if (overlapHandleTypeGroup != null) { +// overlapHandleTypeGroup.setSelectedItem(axis.getOverlapHandleType()); +// } if(labelGapStyle != null){ labelGapStyle.setSelectedIndex(axis.isAutoLabelGap() ? 0 : 1); } if(labelGapValue != null){ + //轴标签缩略间隔显示 恢复用注释。下面1行删除。 labelGapValue.setText(axis.getLabelNumber().getContent()); + //轴标签缩略间隔显示 恢复用注释。取消注释。 + //labelGapValue.setValue(axis.getIntervalNumber()); } } @@ -516,13 +650,18 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { //显示策略 private void populateDisplayStrategy(VanChartAxis axis) { - if(axisLimitSize != null){ + //区域显示策略 恢复用注释。下面6行删除。 + if (axisLimitSize != null) { axisLimitSize.setSelectedIndex(axis.isLimitSize() ? 0 : 1); } - if(maxProportion != null){ + if (maxProportion != null) { maxProportion.setValue(axis.getMaxHeight()); } + //区域显示策略 恢复用注释。取消注释。 +// if (limitPane != null) { +// limitPane.populateBean(axis.getLimitAttribute()); +// } } //格式 @@ -597,15 +736,22 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { if(labelTextRotation != null){ labelTextAttr.setRotation(labelTextRotation.updateBean().intValue()); } + //轴标签缩略间隔显示 恢复用注释。取消注释。 +// if (overlapHandleTypeGroup != null) { +// axis.setOverlapHandleType(overlapHandleTypeGroup.getSelectedItem()); +// } if(labelGapStyle != null){ axis.setAutoLabelGap(labelGapStyle.getSelectedIndex() == 0); } if(labelGapValue != null){ - if(axis.isAutoLabelGap()){ + //轴标签缩略间隔显示 恢复用注释。下面5行删除。 + if (axis.isAutoLabelGap()) { axis.setLabelIntervalNumber(BaseFormula.createFormulaBuilder().build("1")); } else { axis.setLabelIntervalNumber(BaseFormula.createFormulaBuilder().build(labelGapValue.getText())); } + //轴标签缩略间隔显示 恢复用注释。取消注释。 + //axis.setIntervalNumber((int) labelGapValue.getValue()); } } @@ -637,12 +783,17 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { //显示策略 private void updateDisplayStrategy(VanChartAxis axis){ - if(axisLimitSize != null){ + //区域显示策略 恢复用注释。下面6行删除。 + if (axisLimitSize != null) { axis.setLimitSize(axisLimitSize.getSelectedIndex() == 0); } - if(maxProportion != null){ + if (maxProportion != null) { axis.setMaxHeight(maxProportion.getValue()); } + //区域显示策略 恢复用注释。取消注释。 +// if (limitPane != null) { +// axis.setLimitAttribute(limitPane.updateBean()); +// } } protected void updateFormat(VanChartAxis axis) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java index 3a43866a23..2d408c9050 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java @@ -17,7 +17,6 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.general.DateUtils; import com.fr.log.FineLoggerFactory; - import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.axis.VanChartTimeAxis; import com.fr.plugin.chart.base.VanChartConstants; @@ -58,6 +57,7 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane { super(isXAxis); } + @Override protected JPanel createContentPane(boolean isXAxis){ double p = TableLayout.PREFERRED; @@ -73,13 +73,18 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane { new Component[]{createValueDefinition(),null}, new Component[]{createLineStylePane(new double[]{p, p,p,p,p}, columnSize),null}, new Component[]{createAxisPositionPane(new double[]{p, p, p}, columnSize, isXAxis),null}, - new Component[]{createDisplayStrategy(new double[]{p, p,p}, columnSize),null}, + new Component[]{createDisplayStrategy(),null}, new Component[]{createValueStylePane(),null}, }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } + @Override + protected void addOverlapGroupButton(JPanel panel) { + //do nothing + } + private JPanel createValueDefinition(){ timeMinMaxValuePane = new TimeMinMaxValuePane(); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), timeMinMaxValuePane); @@ -90,6 +95,7 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane { return PlotFactory.createAutoFormatPane(); } + @Override protected void checkFormatType() { valueFormat.setComboBoxModel(true); } @@ -101,6 +107,7 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane { timeMinMaxValuePane.update(timeAxis); } + @Override public VanChartTimeAxis updateBean(String axisName, int position) { VanChartTimeAxis axis = new VanChartTimeAxis(axisName, VanChartConstants.AXIS_BOTTOM); updateBean(axis); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java index 39ae32372f..2b90633e67 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java @@ -7,7 +7,6 @@ import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; - import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.axis.VanChartValueAxis; import com.fr.stable.StringUtils; @@ -39,6 +38,7 @@ public class VanChartValueAxisPane extends VanChartBaseAxisPane { super(isXAxis); } + @Override protected JPanel createContentPane(boolean isXAxis){ double p = TableLayout.PREFERRED; @@ -54,13 +54,18 @@ public class VanChartValueAxisPane extends VanChartBaseAxisPane { new Component[]{createMinMaxValuePane(new double[]{p, p}, columnSize), null}, new Component[]{createLineStylePane(new double[]{p, p, p, p, p}, columnSize), null}, new Component[]{createAxisPositionPane(new double[]{p, p, p}, columnSize, isXAxis), null}, - new Component[]{createDisplayStrategy(new double[]{p, p, p}, columnSize), null}, + new Component[]{createDisplayStrategy(), null}, new Component[]{createValueStylePane(), null}, }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } + @Override + protected void addOverlapGroupButton(JPanel panel) { + //do nothing + } + protected JPanel createMinMaxValuePane(double[] row, double[] col){ JPanel panel = createCommenValuePane(row,col); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), panel); @@ -123,6 +128,7 @@ public class VanChartValueAxisPane extends VanChartBaseAxisPane { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Axis"); } + @Override public void populateBean(VanChartAxis axis){ VanChartValueAxis valueAxis = (VanChartValueAxis)axis; super.populateBean(valueAxis); @@ -150,6 +156,7 @@ public class VanChartValueAxisPane extends VanChartBaseAxisPane { } } + @Override public VanChartValueAxis updateBean(String axisName, int position){ VanChartValueAxis axis = new VanChartValueAxis(axisName, position); updateBean(axis); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeAxisPane.java index ac1a0a0f7f..b1f516e342 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeAxisPane.java @@ -24,6 +24,8 @@ public class VanChartGaugeAxisPane extends VanChartAxisPane { this.setLayout(new BorderLayout()); gaugeAxisPane = new VanChartAxisScrollPaneWithGauge(); this.add(gaugeAxisPane, BorderLayout.CENTER); + + gaugeAxisPane.setParentPane(parent); } @Override 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 e047830291..cdb6b04b4c 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 @@ -2,14 +2,18 @@ package com.fr.van.chart.designer.style.axis.gauge; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithAuto; import com.fr.design.style.color.ColorSelectBox; import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.axis.VanChartGaugeAxis; import com.fr.plugin.chart.gauge.VanChartGaugePlot; +import com.fr.plugin.chart.type.FontAutoType; import com.fr.plugin.chart.type.GaugeStyle; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.style.VanChartStylePane; @@ -77,13 +81,13 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane { } protected JPanel createLabelPane(double[] row, double[] col){ - showLabel = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Show"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Hidden")}); + showLabel = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Use_Show"), Toolkit.i18nText("Fine-Design_Chart_Hidden")}); labelTextAttrPane = getChartTextAttrPane(); labelPanel = new JPanel(new BorderLayout()); labelPanel.add(labelTextAttrPane); labelPanel.setBorder(BorderFactory.createEmptyBorder(0,15,0,0)); JPanel panel = new JPanel(new BorderLayout(0, 6)); - panel.add(TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Label"), showLabel), BorderLayout.NORTH); + panel.add(TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Label"), showLabel), BorderLayout.NORTH); panel.add(labelPanel, BorderLayout.CENTER); showLabel.addActionListener(new ActionListener() { @Override @@ -96,11 +100,17 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane { return jPanel; } + protected ChartTextAttrPane getChartTextAttrPane() { + if (isMulti(gaugeStyle)) { + return new ChartTextAttrPaneWithAuto(FontAutoType.SIZE_AND_COLOR); + } else { + return new ChartTextAttrPane(); + } + } + private JPanel createValueDefinition(){ switch (gaugeStyle){ case RING: - minMaxValuePane = new MinMaxValuePaneWithOutTick(); - break; case SLOT: minMaxValuePane = new MinMaxValuePaneWithOutTick(); break; @@ -108,18 +118,18 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane { minMaxValuePane = new VanChartMinMaxValuePane(); break; } - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), minMaxValuePane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), minMaxValuePane); } private JPanel createTickColorPane(double[] row, double[] col){ mainTickColor = new ColorSelectBox(100); secTickColor = new ColorSelectBox(100); Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Main_Graduation_Line")), mainTickColor}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Second_Graduation_Line")), secTickColor}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Main_Graduation_Line")), mainTickColor}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Second_Graduation_Line")), secTickColor}, }; JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col); - JPanel jPanel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TickColor"), panel); + JPanel jPanel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_TickColor"), panel); panel.setBorder(BorderFactory.createEmptyBorder(10,10,0,15)); return jPanel; } 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 f7567ed211..d30d245731 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 @@ -54,6 +54,7 @@ public class VanChartRadarYAxisPane extends VanChartValueAxisPane { return new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART); } + @Override protected JPanel createMinMaxValuePane(double[] row, double[] col) { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java index 282ad45129..27336baf0c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java @@ -16,7 +16,6 @@ import com.fr.design.style.color.ColorSelectBox; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRFont; import com.fr.general.GeneralUtils; - import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.attr.axis.VanChartAlertValue; import com.fr.plugin.chart.base.VanChartConstants; @@ -42,7 +41,11 @@ public class VanChartAlertValuePane extends BasicBeanPane { private static final long serialVersionUID = -1208941770684286439L; private UIButtonGroup alertAxis; protected TinyFormulaPane alertValue; + //线型支持虚线 恢复用注释。下面1行删除。 protected LineComboBox alertLineStyle; + //线型支持虚线 恢复用注释。取消注释。 +// protected LineTypeComboBox alertLineStyle;//线型 +// private UISpinner lineWidthSpinner;//线宽 protected ColorSelectBox alertLineColor; private UIButtonGroup alertTextPosition; @@ -63,7 +66,11 @@ public class VanChartAlertValuePane extends BasicBeanPane { //設置大小,防止文本過長導致界面“變形” alertValue.setPreferredSize(new Dimension(VALUE_WD, HT)); + //线型支持虚线 恢复用注释。下面1行删除。 alertLineStyle = new LineComboBox(VanChartConstants.ALERT_LINE_STYLE); + //线型支持虚线 恢复用注释。取消注释。 +// alertLineStyle = new LineTypeComboBox(new LineType[]{LineType.NORMAL, LineType.DASH}); +// lineWidthSpinner = new UISpinner(0.5, Integer.MAX_VALUE, 0.5, 2); alertLineColor = new ColorSelectBox(100); alertTextPosition = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Top"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Bottom")}); alertText = new TinyFormulaPane(); @@ -95,7 +102,7 @@ public class VanChartAlertValuePane extends BasicBeanPane { { double p = TableLayout.PREFERRED; double[] columnSize = {p,p}; - double[] rowSize = {p,p,p,p}; + double[] rowSize = {p,p,p,p,p}; Component[][] components = getTopPaneComponents(); return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); @@ -106,6 +113,8 @@ public class VanChartAlertValuePane extends BasicBeanPane { new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position")),alertAxis}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Value")),alertValue}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")),alertLineStyle}, + //线型支持虚线 恢复用注释。取消注释。 + //new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Width")), lineWidthSpinner}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")),alertLineColor}, }; } @@ -154,7 +163,11 @@ public class VanChartAlertValuePane extends BasicBeanPane { checkPositionPane(); alertValue.populateBean(Utils.objectToString(chartAlertValue.getAlertValueFormula())); + //线型支持虚线 恢复用注释。下面1行删除。 alertLineStyle.setSelectedLineStyle(chartAlertValue.getLineStyle().getLineStyle()); + //线型支持虚线 恢复用注释。取消注释。 +// alertLineStyle.setSelectedItem(chartAlertValue.getLineStyle().getLineType()); +// lineWidthSpinner.setValue(chartAlertValue.getLineStyle().getLineWidth()); alertLineColor.setSelectObject(chartAlertValue.getLineColor().getSeriesColor()); if(VanChartAttrHelper.isXAxis(chartAlertValue.getAxisName())){ @@ -178,7 +191,11 @@ public class VanChartAlertValuePane extends BasicBeanPane { chartAlertValue.setAlertValueFormula(BaseFormula.createFormulaBuilder().build(alertValue.updateBean())); chartAlertValue.getLineColor().setSeriesColor(alertLineColor.getSelectObject()); + //线型支持虚线 恢复用注释。下面1行删除。 chartAlertValue.getLineStyle().setLineStyle(alertLineStyle.getSelectedLineStyle()); + //线型支持虚线 恢复用注释。取消注释。 +// chartAlertValue.getLineStyle().setLineType((LineType) alertLineStyle.getSelectedItem()); +// chartAlertValue.getLineStyle().setLineWidth(lineWidthSpinner.getValue()); String contentString = alertText.updateBean(); Object contentObj; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAxisAreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAxisAreaPane.java index 08c474c3ed..7e09e987ce 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAxisAreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAxisAreaPane.java @@ -4,11 +4,11 @@ import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.style.color.ColorSelectBox; import com.fr.general.ComparatorUtils; - import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; import com.fr.van.chart.designer.TableLayout4VanChartHelper; @@ -20,6 +20,7 @@ import java.awt.CardLayout; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.Arrays; /** * 样式-背景-绘图区背景-坐标轴图表特有(间隔背景、网格线、警戒线) @@ -39,11 +40,23 @@ public class VanChartAxisAreaPane extends BasicBeanPane { private ColorSelectBox verticalColorBackground; protected BackgroundListControlPane customIntervalBackground; + //线型支持虚线 恢复用注释。取消注释。 +// private LineTypeComboBox horizonLineType;//横向线型 +// private LineTypeComboBox verticalLineType;//纵向线型 +// private JPanel horizontalColorPane; +// private JPanel verticalColorPane; + public VanChartAxisAreaPane() { initComponents(); } protected void initComponents() { + horizontalGridLine = new ColorSelectBox(100); + verticalGridLine = new ColorSelectBox(100); + //线型支持虚线 恢复用注释。取消注释。 +// horizonLineType = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.NORMAL, LineType.DASH}); +// verticalLineType = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.NORMAL, LineType.DASH}); + double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; @@ -52,7 +65,7 @@ public class VanChartAxisAreaPane extends BasicBeanPane { double[] rowSize = {p, p, p}; Component[][] components = new Component[][]{ - new Component[]{createGridLinePane(new double[]{p, p, p}, new double[]{f, e})}, + new Component[]{createGridLinePane()}, new Component[]{createAlertLinePane()}, new Component[]{createIntervalPane(new double[]{p, p, p, p}, new double[]{f, s})}, }; @@ -61,25 +74,82 @@ public class VanChartAxisAreaPane extends BasicBeanPane { this.add(panel, BorderLayout.CENTER); } - private JPanel createGridLinePane(double[] row, double[] col) { + //线型支持虚线 恢复用注释。删除下面方法。 + protected JPanel createGridLinePane() { horizontalGridLine = new ColorSelectBox(100); verticalGridLine = new ColorSelectBox(100); - Component[][] components = getGridLinePaneComponents(); - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Grid_Line"), panel); - } - - protected Component[][] getGridLinePaneComponents() { - return new Component[][]{ + Component[][] components = new Component[][]{ new Component[]{null, null}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal")), horizontalGridLine}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical")), verticalGridLine}, }; + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double[] row = new double[components.length]; + Arrays.fill(row, p); + double[] col = {f, e}; + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Grid_Line"), panel); } + //线型支持虚线 恢复用注释。取消注释。 +// protected JPanel createGridLinePane() { +// +// Component[][] upComponent = new Component[][]{ +// new Component[]{null, null}, +// new Component[]{null, horizontalGridLine} +// }; +// horizontalColorPane = TableLayout4VanChartHelper.createGapTableLayoutPane(upComponent); +// +// Component[][] downComponent = new Component[][]{ +// new Component[]{null,null}, +// new Component[]{null, verticalGridLine} +// }; +// verticalColorPane = TableLayout4VanChartHelper.createGapTableLayoutPane(downComponent); +// +// horizonLineType.addActionListener(new ActionListener() { +// @Override +// public void actionPerformed(ActionEvent e) { +// if (horizontalGridLine == null || horizonLineType == null){ +// return; +// } +// horizontalColorPane.setVisible(horizonLineType.getSelectedItem() != LineType.NONE); +// } +// }); +// +// verticalLineType.addActionListener(new ActionListener() { +// @Override +// public void actionPerformed(ActionEvent e) { +// if (verticalGridLine == null || verticalLineType == null){ +// return; +// } +// verticalColorPane.setVisible(verticalLineType.getSelectedItem() != LineType.NONE); +// } +// }); +// +// checkColorBoxVisible(); +// +// JPanel horizonLineTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal"), horizonLineType); +// JPanel horizontal = new JPanel(new BorderLayout()); +// horizontal.add(horizonLineTypePane, BorderLayout.NORTH); +// horizontal.add(horizontalColorPane, BorderLayout.CENTER); +// +// JPanel verticalLineTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical"), verticalLineType); +// JPanel vertical = new JPanel(new BorderLayout()); +// vertical.add(verticalLineTypePane, BorderLayout.NORTH); +// vertical.add(verticalColorPane, BorderLayout.CENTER); +// +// JPanel panel = new JPanel(new BorderLayout(0, 4)); +// panel.add(horizontal, BorderLayout.NORTH); +// panel.add(vertical, BorderLayout.CENTER); +// +// return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Grid_Line"), panel); +// } + protected JPanel createAlertLinePane() { alertLine = getAlertLinePane(); - JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Alert_Line"), alertLine); + JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Alert_Line"), alertLine); alertLine.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); return panel; } @@ -89,7 +159,7 @@ public class VanChartAxisAreaPane extends BasicBeanPane { } protected JPanel createIntervalPane(double[] row, double[] col) { - isDefaultIntervalBackground = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Default_Interval"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Interval_Background")}); + isDefaultIntervalBackground = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Default_Interval"), Toolkit.i18nText("Fine-Design_Chart_Custom_Interval_Background")}); horizontalColorBackground = new ColorSelectBox(100); verticalColorBackground = new ColorSelectBox(100); Component[][] components = getIntervalPaneComponents(); @@ -99,8 +169,8 @@ public class VanChartAxisAreaPane extends BasicBeanPane { cardLayout = new CardLayout(); centerPane = new JPanel(cardLayout); - centerPane.add(defaultPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Default_Interval")); - centerPane.add(customIntervalBackground, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Interval_Background")); + centerPane.add(defaultPane, Toolkit.i18nText("Fine-Design_Chart_Default_Interval")); + centerPane.add(customIntervalBackground, Toolkit.i18nText("Fine-Design_Chart_Custom_Interval_Background")); isDefaultIntervalBackground.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -108,10 +178,10 @@ public class VanChartAxisAreaPane extends BasicBeanPane { } }); JPanel intervalPane = new JPanel(new BorderLayout(0, 6)); - JPanel panel1 = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Interval_Background"), isDefaultIntervalBackground); + JPanel panel1 = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Interval_Background"), isDefaultIntervalBackground); intervalPane.add(panel1, BorderLayout.NORTH); intervalPane.add(centerPane, BorderLayout.CENTER); - JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Interval_Background"), intervalPane); + JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Interval_Background"), intervalPane); intervalPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); return panel; } @@ -123,16 +193,16 @@ public class VanChartAxisAreaPane extends BasicBeanPane { protected Component[][] getIntervalPaneComponents() { return new Component[][]{ new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal")), horizontalColorBackground}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical")), verticalColorBackground}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal")), horizontalColorBackground}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical")), verticalColorBackground}, }; } private void checkCardPane() { if (isDefaultIntervalBackground.getSelectedIndex() == 0) { - cardLayout.show(centerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Default_Interval")); + cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Default_Interval")); } else { - cardLayout.show(centerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Interval_Background")); + cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Custom_Interval_Background")); } } @@ -142,6 +212,7 @@ public class VanChartAxisAreaPane extends BasicBeanPane { public void populateBean(Plot plot) { VanChartRectanglePlot rectanglePlot = (VanChartRectanglePlot) plot; + checkColorBoxVisible(); populateGridLine(rectanglePlot); @@ -155,9 +226,12 @@ public class VanChartAxisAreaPane extends BasicBeanPane { checkCardPane(); } - protected void populateGridLine(VanChartRectanglePlot rectanglePlot) { + private void populateGridLine(VanChartRectanglePlot rectanglePlot) { horizontalGridLine.setSelectObject(rectanglePlot.getDefaultYAxis().getMainGridColor()); verticalGridLine.setSelectObject(rectanglePlot.getDefaultXAxis().getMainGridColor()); +//线型支持虚线 恢复用注释。取消注释。 +// horizonLineType.setSelectedItem(rectanglePlot.getDefaultYAxis().getGridLineType()); +// verticalLineType.setSelectedItem(rectanglePlot.getDefaultXAxis().getGridLineType()); } @@ -179,9 +253,12 @@ public class VanChartAxisAreaPane extends BasicBeanPane { customIntervalBackground.update(plot, isDefaultIntervalBackground.getSelectedIndex() == 0); } - protected void updateGirdLine(VanChartRectanglePlot rectanglePlot) { + private void updateGirdLine(VanChartRectanglePlot rectanglePlot) { rectanglePlot.getDefaultYAxis().setMainGridColor(horizontalGridLine.getSelectObject()); rectanglePlot.getDefaultXAxis().setMainGridColor(verticalGridLine.getSelectObject()); + //线型支持虚线 恢复用注释。取消注释。 +// rectanglePlot.getDefaultYAxis().setGridLineType((LineType)horizonLineType.getSelectedItem()); +// rectanglePlot.getDefaultXAxis().setGridLineType((LineType)verticalLineType.getSelectedItem()); } /** @@ -199,4 +276,15 @@ public class VanChartAxisAreaPane extends BasicBeanPane { public Plot updateBean() { return null; } + + private void checkColorBoxVisible() { +//线型支持虚线 恢复用注释。取消注释。 +// if (horizontalColorPane != null && horizonLineType != null){ +// horizontalColorPane.setVisible(horizonLineType.getSelectedItem() != LineType.NONE); +// } +// +// if (verticalColorPane != null && verticalLineType != null){ +// verticalColorPane.setVisible(verticalLineType.getSelectedItem() != LineType.NONE); +// } + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/radar/VanChartRadarAxisAreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/radar/VanChartRadarAxisAreaPane.java index a304b0a59d..687516c357 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/radar/VanChartRadarAxisAreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/radar/VanChartRadarAxisAreaPane.java @@ -2,12 +2,16 @@ package com.fr.van.chart.designer.style.background.radar; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ilable.UILabel; - +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.style.background.AlertLineListControlPane; import com.fr.van.chart.designer.style.background.BackgroundListControlPane; import com.fr.van.chart.designer.style.background.VanChartAxisAreaPane; +import javax.swing.JPanel; import java.awt.Component; +import java.util.Arrays; /** * 样式-背景-绘图区背景-雷达图只有Y轴的配置(间隔背景、网格线、警戒线) @@ -17,11 +21,21 @@ public class VanChartRadarAxisAreaPane extends VanChartAxisAreaPane { private static final long serialVersionUID = 2459614679918546393L; //雷达图只有横向的y轴的网格线配置 - protected Component[][] getGridLinePaneComponents() { - return new Component[][]{ + @Override + protected JPanel createGridLinePane() { + + Component[][] components = new Component[][]{ new Component[]{null,null}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")),horizontalGridLine}, }; + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double[] row = new double[components.length]; + Arrays.fill(row, p); + double[] col = {f, e}; + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Grid_Line"), panel); } protected Component[][] getIntervalPaneComponents() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/component/LimitPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/component/LimitPane.java new file mode 100644 index 0000000000..4fd8c77d4b --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/component/LimitPane.java @@ -0,0 +1,85 @@ +package com.fr.van.chart.designer.style.component; + +import com.fr.chartx.attr.LimitAttribute; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * Created by shine on 2019/08/28. + */ +public class LimitPane extends BasicBeanPane { + + private UIButtonGroup autoCustomTypeGroup; + private UISpinner maxProportion; + private JPanel maxProportionPane; + + public LimitPane() { + this(true); + } + + public LimitPane(boolean hasTitle) { + initComponent(hasTitle); + } + + private void initComponent(boolean hasTitle) { + maxProportion = new UISpinner(0, 100, 1, 30); + autoCustomTypeGroup = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Mode_Auto") + , Toolkit.i18nText("Fine-Design_Chart_Mode_Custom")}, new Boolean[]{true, false}); + + JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Area_Size"), autoCustomTypeGroup); + maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"), maxProportion, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + maxProportionPane.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); + JPanel panel = new JPanel(new BorderLayout()); + panel.add(limitSizePane, BorderLayout.NORTH); + panel.add(maxProportionPane, BorderLayout.CENTER); + + autoCustomTypeGroup.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkMaxProPortionUse(); + } + }); + + this.setLayout(new BorderLayout()); + if (hasTitle) { + JPanel contentPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel); + this.add(contentPane); + } else { + this.add(panel); + } + } + + //检查最大显示占比是否可用 + public void checkMaxProPortionUse() { + maxProportion.setVisible(!autoCustomTypeGroup.getSelectedItem() && autoCustomTypeGroup.isEnabled()); + maxProportionPane.setVisible(!autoCustomTypeGroup.getSelectedItem() && autoCustomTypeGroup.isEnabled()); + } + + @Override + public void populateBean(LimitAttribute ob) { + autoCustomTypeGroup.setSelectedItem(ob.isAuto()); + maxProportion.setValue(ob.getMaxSize()); + } + + @Override + public LimitAttribute updateBean() { + LimitAttribute attribute = new LimitAttribute(); + attribute.setAuto(autoCustomTypeGroup.getSelectedItem()); + attribute.setMaxSize(maxProportion.getValue()); + return attribute; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} 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 4199e8f7c3..64187f89b9 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 @@ -1,11 +1,6 @@ package com.fr.van.chart.designer.style.label; import com.fr.chart.chartattr.Plot; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.layout.TableLayout; -import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; - -import com.fr.plugin.chart.gauge.VanChartGaugePlot; import com.fr.plugin.chart.type.GaugeStyle; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.label.LabelContentPaneWithCate; @@ -13,39 +8,34 @@ import com.fr.van.chart.designer.component.label.LabelContentPaneWithPercent; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; -import javax.swing.SwingConstants; import java.awt.Component; /** * 仪表盘的分类(多指针时)或者百分比标签 */ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabelDetailPane { - //todo 重新整理这个面板 private static final long serialVersionUID = 5176535960949074945L; - private GaugeStyle gaugeStyle; - public VanChartGaugeCateOrPercentLabelDetailPane(Plot plot, VanChartStylePane parent) { super(plot, parent); } protected double[] getLabelPaneRowSize(Plot plot, double p) { - return hasLabelPosition(plot) ? new double[]{p,p,p} : new double[]{p,p}; - } + if (hasLabelAlign(plot)) { + return new double[]{p, p, p, p}; + } - private void initGaugeStyle(Plot plot) { - if(gaugeStyle == null){ - gaugeStyle = ((VanChartGaugePlot)plot).getGaugeStyle(); + if (hasLabelPosition(plot)) { + return new double[]{p, p, p}; } + + return new double[]{p, p}; } protected void initToolTipContentPane(Plot plot) { - initGaugeStyle(plot); - switch (gaugeStyle){ + switch (getGaugeStyle()) { case POINTER: - dataLabelContentPane = new LabelContentPaneWithCate(parent, VanChartGaugeCateOrPercentLabelDetailPane.this); - break; case POINTER_SEMI: dataLabelContentPane = new LabelContentPaneWithCate(parent, VanChartGaugeCateOrPercentLabelDetailPane.this); break; @@ -55,13 +45,17 @@ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabe } } + protected boolean isFontSizeAuto() { + return getGaugeStyle() == GaugeStyle.RING || getGaugeStyle() == GaugeStyle.SLOT; + } + protected boolean isFontColorAuto() { + return getGaugeStyle() == GaugeStyle.RING || getGaugeStyle() == GaugeStyle.SLOT; + } protected boolean hasLabelPosition(Plot plot) { - initGaugeStyle(plot); - switch (gaugeStyle){ + switch (getGaugeStyle()) { case RING: - return false; case SLOT: return false; default: @@ -70,67 +64,10 @@ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabe } protected double[] getLabelStyleRowSize(double p) { - switch (gaugeStyle){ - case RING: - return new double[] {p, p}; - case SLOT: - return new double[] {p, p}; - default: - return new double[] {p}; - } + return new double[]{p, p}; } protected JPanel createTableLayoutPaneWithTitle(String title, Component component) { return TableLayout4VanChartHelper.createTableLayoutPaneWithSmallTitle(title, component); } - - - protected Component[][] getLabelStyleComponents(Plot plot) { - initGaugeStyle(plot); - if (gaugeStyle == GaugeStyle.RING || gaugeStyle == GaugeStyle.SLOT) { - UILabel text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); - return new Component[][]{ - new Component[]{text,style}, - new Component[]{textFontPane,null}, - }; - } else { - return new Component[][]{ - new Component[]{textFontPane, null}, - }; - } - } - - protected ChartTextAttrPane initTextFontPane () { - //todo 需要再整理下 - if (gaugeStyle == GaugeStyle.RING || gaugeStyle == GaugeStyle.SLOT){ - return new ChartTextAttrPane(){ - protected double[] getRowSize () { - double p = TableLayout.PREFERRED; - return new double[]{p, p}; - } - - protected Component[][] getComponents(JPanel buttonPane) { - return new Component[][]{ - new Component[]{null, fontNameComboBox}, - new Component[]{null, buttonPane} - }; - } - }; - } else { - return new ChartTextAttrPane(){ - protected double[] getRowSize () { - double p = TableLayout.PREFERRED; - return new double[]{p, p}; - } - - protected Component[][] getComponents(JPanel buttonPane) { - UILabel text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); - return new Component[][]{ - new Component[]{text, fontNameComboBox}, - new Component[]{null, buttonPane} - }; - } - }; - } - } } \ No newline at end of file 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 3cf057df59..bbdb6acb3d 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 @@ -1,28 +1,61 @@ package com.fr.van.chart.designer.style.label; +import com.fr.chart.base.ChartConstants; import com.fr.chart.chartattr.Plot; +import com.fr.chartx.TwoTuple; import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; - +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithAuto; +import com.fr.general.ComparatorUtils; +import com.fr.plugin.chart.base.AttrLabelDetail; +import com.fr.plugin.chart.gauge.VanChartGaugePlot; +import com.fr.plugin.chart.type.FontAutoType; +import com.fr.plugin.chart.type.GaugeStyle; +import com.fr.stable.Constants; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dimension; /** * Created by mengao on 2017/8/13. */ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { + private static final int TEXT_FONT_PANE_HEIGHT = 50; + private GaugeStyle gaugeStyle; + private UIButtonGroup align; + private JPanel alignPane; + private Integer[] oldAlignValues; + public VanChartGaugeLabelDetailPane(Plot plot, VanChartStylePane parent) { super(plot, parent); } + protected void initLabelDetailPane(Plot plot) { + setGaugeStyle(((VanChartGaugePlot) plot).getGaugeStyle()); + super.initLabelDetailPane(plot); + } + + public GaugeStyle getGaugeStyle() { + return ((VanChartGaugePlot)this.getPlot()).getGaugeStyle(); + } + + public void setGaugeStyle(GaugeStyle gaugeStyle) { + this.gaugeStyle = gaugeStyle; + } + protected JPanel createLabelStylePane(double[] row, double[] col, Plot plot) { - style = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Automatic"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")}); + style = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Automatic"), + Toolkit.i18nText("Fine-Design_Chart_Custom")}); textFontPane = initTextFontPane(); initStyleListener(); @@ -30,16 +63,168 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { return TableLayoutHelper.createTableLayoutPane(getLabelStyleComponents(plot), row, col); } + protected boolean isFontSizeAuto() { + return false; + } + + protected boolean isFontColorAuto() { + return false; + } - protected ChartTextAttrPane initTextFontPane () { - return new ChartTextAttrPane(); + private FontAutoType getFontAutoType() { + if (isFontSizeAuto() && isFontColorAuto()) { + return FontAutoType.SIZE_AND_COLOR; + } + if (isFontSizeAuto()) { + return FontAutoType.SIZE; + } + if (isFontColorAuto()) { + return FontAutoType.COLOR; + } + return FontAutoType.NONE; } - protected JPanel getLabelPositionPane (Component[][] comps, double[] row, double[] col){ - return TableLayoutHelper.createTableLayoutPane(comps,row,col); + protected ChartTextAttrPane initTextFontPane() { + return new ChartTextAttrPaneWithAuto(getFontAutoType()) { + protected double[] getRowSize() { + double p = TableLayout.PREFERRED; + return new double[]{p, p}; + } + + protected Component[][] getComponents(JPanel buttonPane) { + UILabel text = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); + return new Component[][]{ + new Component[]{text, getFontNameComboBox()}, + new Component[]{null, buttonPane} + }; + } + }; + } + + protected JPanel getLabelPositionPane(Component[][] comps, double[] row, double[] col) { + return TableLayoutHelper.createTableLayoutPane(comps, row, col); } protected JPanel createTableLayoutPaneWithTitle(String title, JPanel panel) { return TableLayout4VanChartHelper.createGapTableLayoutPane(title, panel); } + + protected Component[][] getLabelPaneComponents(Plot plot, double p, double[] columnSize) { + if (hasLabelAlign(plot)) { + + return new Component[][]{ + new Component[]{dataLabelContentPane, null}, + new Component[]{createLabelPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Vertical"), plot), null}, + new Component[]{createLabelAlignPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Horizontal")), null}, + new Component[]{createLabelStylePane(getLabelStyleRowSize(p), columnSize, plot), null}, + }; + } else { + + return super.getLabelPaneComponents(plot, p, columnSize); + } + } + + private JPanel createLabelAlignPane(String title) { + JPanel panel = new JPanel(new BorderLayout()); + + alignPane = new JPanel(); + checkAlignPane(title); + panel.add(alignPane, BorderLayout.CENTER); + + return panel; + } + + protected void checkAlignPane(String title) { + if (alignPane == null && !hasLabelAlign(getPlot())) { + return; + } + if (alignPane != null && !hasLabelAlign(getPlot())) { + oldAlignValues = null; + alignPane.removeAll(); + return; + } + if (alignPane == null && hasLabelAlign(getPlot())) { + alignPane = new JPanel(); + } + TwoTuple result = getAlignNamesAndValues(); + + String[] names = result.getFirst(); + Integer[] values = result.getSecond(); + if (ComparatorUtils.equals(values, oldAlignValues)) { + return; + } + + oldAlignValues = values; + + align = new UIButtonGroup(names, values); + + Component[][] comps = new Component[2][2]; + + comps[0] = new Component[]{null, null}; + comps[1] = new Component[]{new UILabel(title, SwingConstants.LEFT), align}; + + double[] row = new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; + double[] col = new double[]{TableLayout.FILL, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}; + + alignPane.removeAll(); + alignPane.setLayout(new BorderLayout()); + alignPane.add(getLabelPositionPane(comps, row, col), BorderLayout.CENTER); + + if (parent != null) { + parent.initListener(alignPane); + } + } + + private TwoTuple getAlignNamesAndValues() { + String[] names = new String[]{Toolkit.i18nText("Fine-Design_Chart_Follow"), Toolkit.i18nText("Fine-Design_Chart_Align_Left"), Toolkit.i18nText("Fine-Design_Chart_Align_Right")}; + Integer[] values = new Integer[]{ChartConstants.AUTO_LABEL_POSITION, Constants.LEFT, Constants.RIGHT}; + + return new TwoTuple<>(names, values); + } + + protected Component[][] getLabelStyleComponents(Plot plot) { + return new Component[][]{ + new Component[]{textFontPane, null}, + }; + } + + protected void checkPane() { + String verticalTitle = hasLabelAlign(getPlot()) + ? Toolkit.i18nText("Fine-Design_Chart_Layout_Vertical") + : Toolkit.i18nText("Fine-Design_Chart_Layout_Position"); + + checkPositionPane(verticalTitle); + checkAlignPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Horizontal")); + } + + protected void checkStyleUse() { + textFontPane.setVisible(true); + textFontPane.setPreferredSize(new Dimension(0, TEXT_FONT_PANE_HEIGHT)); + } + + protected boolean hasLabelAlign(Plot plot) { + return getGaugeStyle() == GaugeStyle.THERMOMETER && !((VanChartGaugePlot) plot).getGaugeDetailStyle().isHorizontalLayout(); + } + + public void populate(AttrLabelDetail detail) { + super.populate(detail); + + style.setSelectedIndex(1); + if (hasLabelAlign(this.getPlot()) && align != null) { + align.setSelectedItem(detail.getAlign()); + } + } + + public void update(AttrLabelDetail detail) { + super.update(detail); + + detail.setCustom(true); + if (align != null) { + if (align.getSelectedItem() != null) { + detail.setAlign(align.getSelectedItem()); + } else { + align.setSelectedItem(detail.getAlign()); + } + } + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugePlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugePlotLabelPane.java index 42e6909e9f..0f81deefca 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugePlotLabelPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugePlotLabelPane.java @@ -7,6 +7,7 @@ import com.fr.plugin.chart.gauge.VanChartGaugePlot; import com.fr.plugin.chart.type.GaugeStyle; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.design.i18n.Toolkit; import javax.swing.JPanel; import java.awt.BorderLayout; @@ -28,16 +29,14 @@ public class VanChartGaugePlotLabelPane extends VanChartPlotLabelPane { labelDetailPane = new VanChartGaugeCateOrPercentLabelDetailPane(this.plot, this.parent); gaugeValueLabelPane = new VanChartGaugeValueLabelDetailPane(this.plot, this.parent); GaugeStyle gaugeStyle = ((VanChartGaugePlot)this.plot).getGaugeStyle(); - String cateTitle, valueTitle = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Label"); + String cateTitle, valueTitle = Toolkit.i18nText("Fine-Design_Chart_Value_Label"); switch (gaugeStyle){ case POINTER: - cateTitle = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Category_Label"); - break; case POINTER_SEMI: - cateTitle = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Category_Label"); + cateTitle = Toolkit.i18nText("Fine-Design_Chart_Category_Label"); break; default: - cateTitle = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Percent_Label"); + cateTitle = Toolkit.i18nText("Fine-Design_Chart_Percent_Label"); break; } JPanel cateOrPercentPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(cateTitle, labelDetailPane); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java index 1d66925554..01a21d3823 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java @@ -1,7 +1,6 @@ package com.fr.van.chart.designer.style.label; import com.fr.chart.chartattr.Plot; -import com.fr.plugin.chart.gauge.VanChartGaugePlot; import com.fr.plugin.chart.type.GaugeStyle; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.label.LabelContentPaneWithCateValue; @@ -17,24 +16,13 @@ import java.awt.Component; public class VanChartGaugeValueLabelDetailPane extends VanChartGaugeLabelDetailPane { private static final long serialVersionUID = 2601073419430634281L; - private GaugeStyle gaugeStyle; - public VanChartGaugeValueLabelDetailPane(Plot plot, VanChartStylePane parent) { super(plot, parent); } - private void initGaugeStyle(Plot plot) { - if(gaugeStyle == null){ - gaugeStyle = ((VanChartGaugePlot)plot).getGaugeStyle(); - } - } - protected void initToolTipContentPane(Plot plot) { - initGaugeStyle(plot); - switch (gaugeStyle){ + switch (getGaugeStyle()) { case POINTER: - dataLabelContentPane = new LabelContentPaneWithOutCate(parent, VanChartGaugeValueLabelDetailPane.this); - break; case POINTER_SEMI: dataLabelContentPane = new LabelContentPaneWithOutCate(parent, VanChartGaugeValueLabelDetailPane.this); break; @@ -45,10 +33,8 @@ public class VanChartGaugeValueLabelDetailPane extends VanChartGaugeLabelDetailP } protected Component[][] getLabelPaneComponents(Plot plot, double p, double[] columnSize) { - initGaugeStyle(plot); - switch (gaugeStyle){ + switch (getGaugeStyle()) { case POINTER: - return getLabelPaneComponentsWithBackground(plot, p, columnSize); case POINTER_SEMI: return getLabelPaneComponentsWithBackground(plot, p, columnSize); default: @@ -57,43 +43,32 @@ public class VanChartGaugeValueLabelDetailPane extends VanChartGaugeLabelDetailP } private Component[][] getLabelPaneComponentsWithBackground(Plot plot, double p, double[] columnSize) { - return new Component[][]{ - new Component[]{dataLabelContentPane,null}, - new Component[]{createLabelStylePane(new double[]{p}, columnSize, plot),null}, - new Component[]{createBackgroundColorPane(),null}, + return new Component[][]{ + new Component[]{dataLabelContentPane, null}, + new Component[]{createLabelStylePane(new double[]{p}, columnSize, plot), null}, + new Component[]{createBackgroundColorPane(), null}, }; } protected double[] getLabelPaneRowSize(Plot plot, double p) { - initGaugeStyle(plot); - switch (gaugeStyle){ + switch (getGaugeStyle()) { case POINTER: - return new double[]{p,p,p,p,p}; case POINTER_SEMI: - return new double[]{p,p,p,p,p}; + return new double[]{p, p, p, p, p}; default: return super.getLabelPaneRowSize(plot, p); } } + protected boolean isFontSizeAuto() { + return getGaugeStyle() != GaugeStyle.THERMOMETER; + } + protected boolean hasLabelPosition(Plot plot) { - initGaugeStyle(plot); - switch (gaugeStyle){ - case THERMOMETER: - return true; - default: - return false; - } + return getGaugeStyle() == GaugeStyle.THERMOMETER; } protected JPanel createTableLayoutPaneWithTitle(String title, Component component) { return TableLayout4VanChartHelper.createTableLayoutPaneWithSmallTitle(title, component); } - - protected Component[][] getLabelStyleComponents(Plot plot) { - return new Component[][]{ - new Component[]{textFontPane,null}, - }; - } - } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java index b774de89ea..c506d89ea1 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java @@ -11,6 +11,7 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.style.color.ColorSelectBox; +import com.fr.design.i18n.Toolkit; import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.attr.plot.VanChartLabelPositionPlot; @@ -58,13 +59,20 @@ public class VanChartPlotLabelDetailPane extends BasicPane { public VanChartPlotLabelDetailPane(Plot plot, VanChartStylePane parent) { this.parent = parent; this.plot = plot; + initLabelDetailPane(plot); + } + protected void initLabelDetailPane (Plot plot) { this.setLayout(new BorderLayout()); initToolTipContentPane(plot); JPanel contentPane = createLabelPane(plot); this.add(contentPane,BorderLayout.CENTER); } + public Plot getPlot() { + return plot; + } + //默认从factory中取 protected void initToolTipContentPane(Plot plot) { dataLabelContentPane = PlotFactory.createPlotLabelContentPane(plot, parent, VanChartPlotLabelDetailPane.this); @@ -85,7 +93,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { if(hasLabelPosition(plot)){ return new Component[][]{ new Component[]{dataLabelContentPane,null}, - new Component[]{createLabelPositionPane(new double[]{p,p,p}, columnSize, plot),null}, + new Component[]{createLabelPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), plot), null}, new Component[]{createLabelStylePane(getLabelStyleRowSize(p), columnSize, plot),null}, }; } else { @@ -112,7 +120,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return TableLayout4VanChartHelper.createExpandablePaneWithTitle(title, panel); } - private TwoTuple getPositionNamesAndValues() { + protected TwoTuple getPositionNamesAndValues() { if (plot instanceof VanChartLabelPositionPlot) { String[] names = ((VanChartLabelPositionPlot) plot).getLabelLocationNameArray(); @@ -130,33 +138,33 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return null; } - private JPanel createLabelPositionPane(double[] row, double[] col, Plot plot) { + protected JPanel createLabelPositionPane(String title, Plot plot) { if (getPositionNamesAndValues() == null) { return new JPanel(); } - autoAdjust = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_On"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false}); + autoAdjust = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_On"), Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false}); JPanel panel = new JPanel(new BorderLayout()); positionPane = new JPanel(); - checkPositionPane(); + checkPositionPane(title); panel.add(positionPane, BorderLayout.CENTER); if (plot.isSupportLeadLine()) { - tractionLine = new UIToggleButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Show_Guideline")); + tractionLine = new UIToggleButton(Toolkit.i18nText("Fine-Design_Chart_Show_Guideline")); tractionLinePane = TableLayout4VanChartHelper.createGapTableLayoutPane("", tractionLine); panel.add(tractionLinePane, BorderLayout.SOUTH); initPositionListener(); } else if (PlotFactory.plotAutoAdjustLabelPosition(plot)) { - panel.add(TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Auto_Adjust"), autoAdjust), BorderLayout.SOUTH); + panel.add(TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Auto_Adjust"), autoAdjust), BorderLayout.SOUTH); } return panel; } - private void checkPositionPane() { + protected void checkPositionPane(String title) { if (positionPane == null) { return; } @@ -176,7 +184,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { Component[][] comps = new Component[2][2]; comps[0] = new Component[]{null, null}; - comps[1] = new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), SwingConstants.LEFT), position}; + comps[1] = new Component[]{new UILabel(title, SwingConstants.LEFT), position}; double[] row = new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; double[] col = new double[]{TableLayout.FILL, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}; @@ -193,7 +201,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { protected JPanel getLabelPositionPane (Component[][] comps, double[] row, double[] col){ JPanel panel = TableLayoutHelper.createTableLayoutPane(comps,row,col); - return createTableLayoutPaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout"), panel); + return createTableLayoutPaneWithTitle(Toolkit.i18nText("Fine-Design_Form_Attr_Layout"), panel); } @@ -207,14 +215,14 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } protected JPanel createLabelStylePane(double[] row, double[] col, Plot plot) { - style = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Automatic"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")}); + style = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Automatic"), + Toolkit.i18nText("Fine-Design_Chart_Custom")}); textFontPane =initTextFontPane(); initStyleListener(); JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(getLabelStyleComponents(plot),row,col); - return createTableLayoutPaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel); + return createTableLayoutPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel); } protected ChartTextAttrPane initTextFontPane () { @@ -222,7 +230,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { protected Component[][] getComponents(JPanel buttonPane) { return new Component[][]{ new Component[]{null, null}, - new Component[]{null, fontNameComboBox}, + new Component[]{null, getFontNameComboBox()}, new Component[]{null, buttonPane} }; } @@ -230,7 +238,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } protected Component[][] getLabelStyleComponents(Plot plot) { - UILabel text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); + UILabel text = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); return new Component[][]{ new Component[]{null,null}, new Component[]{text,style}, @@ -249,7 +257,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { protected JPanel createBackgroundColorPane() { backgroundColor = new ColorSelectBox(100); - return createTableLayoutPaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundColor); + return createTableLayoutPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundColor); } protected String title4PopupWindow() { @@ -264,7 +272,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { checkPositionEnabled(); } - private void checkStyleUse() { + protected void checkStyleUse() { textFontPane.setVisible(style.getSelectedIndex() == 1); textFontPane.setPreferredSize(style.getSelectedIndex() == 1 ? new Dimension(0, 60) : new Dimension(0, 0)); } @@ -277,9 +285,12 @@ public class VanChartPlotLabelDetailPane extends BasicPane { tractionLinePane.setVisible(position.getSelectedItem() == Constants.OUTSIDE); } - public void populate(AttrLabelDetail detail) { - checkPositionPane(); + protected void checkPane(){ + checkPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Position")); + } + public void populate(AttrLabelDetail detail) { + checkPane(); dataLabelContentPane.populateBean(detail.getContent()); if(position != null){ position.setSelectedItem(detail.getPosition()); @@ -306,7 +317,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { if(position != null && position.getSelectedItem() != null){ detail.setPosition(position.getSelectedItem()); - + } else if(position != null){ position.setSelectedItem(detail.getPosition()); } 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 efc91258a0..9b912ee9f7 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 @@ -8,26 +8,22 @@ import com.fr.chart.base.AttrBorder; import com.fr.chart.base.ChartConstants; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; -import com.fr.chart.chartglyph.ConditionCollection; import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.style.ChartFillStylePane; import com.fr.design.mainframe.chart.gui.style.series.AbstractPlotSeriesPane; - import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; import com.fr.plugin.chart.attr.radius.VanChartRadiusPlot; import com.fr.plugin.chart.base.AttrAreaSeriesFillColorBackground; -import com.fr.plugin.chart.base.AttrEffect; import com.fr.plugin.chart.base.AttrLabel; import com.fr.plugin.chart.base.VanChartAttrLine; import com.fr.plugin.chart.base.VanChartAttrMarker; import com.fr.plugin.chart.base.VanChartAttrTrendLine; -import com.fr.plugin.chart.map.line.condition.AttrLineEffect; -import com.fr.plugin.chart.scatter.attr.ScatterAttrLabel; import com.fr.van.chart.custom.style.VanChartCustomStylePane; +import com.fr.design.i18n.Toolkit; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartAreaSeriesFillColorPane; import com.fr.van.chart.designer.component.VanChartBeautyPane; @@ -36,6 +32,7 @@ import com.fr.van.chart.designer.component.VanChartLineTypePane; import com.fr.van.chart.designer.component.VanChartMarkerPane; import com.fr.van.chart.designer.component.VanChartTrendLinePane; import com.fr.van.chart.designer.component.border.VanChartBorderPane; +import com.fr.van.chart.designer.other.VanChartInteractivePane; import com.fr.van.chart.pie.RadiusCardLayoutPane; import javax.swing.BorderFactory; @@ -73,11 +70,12 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP private RadiusCardLayoutPane radiusPane;//半径设置界面 private JPanel radiusPaneWithTitle; + //大数据模式 恢复用注释。下面1行删除。 private UIButtonGroup largeDataModelGroup;//大数据模式 protected JPanel contentPane; - public VanChartAbstractPlotSeriesPane(ChartStylePane parent, Plot plot){ + public VanChartAbstractPlotSeriesPane(ChartStylePane parent, Plot plot) { super(parent, plot); } @@ -110,17 +108,17 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP } //获取颜色面板 - protected JPanel getColorPane () { + protected JPanel getColorPane() { JPanel panel = new JPanel(new BorderLayout()); stylePane = createStylePane(); setColorPaneContent(panel); - JPanel colorPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color"), panel); - panel.setBorder(BorderFactory.createEmptyBorder(10,5,0,0)); + JPanel colorPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Color"), panel); + panel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); return panel.getComponentCount() == 0 ? null : colorPane; } //设置色彩面板内容 - protected void setColorPaneContent (JPanel panel) { + protected void setColorPaneContent(JPanel panel) { if (stylePane != null) { panel.add(stylePane, BorderLayout.CENTER); } @@ -129,13 +127,13 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP //趋势线 protected JPanel createTrendLinePane() { trendLinePane = new VanChartTrendLinePane(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TrendLine"), trendLinePane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_TrendLine"), trendLinePane); } //线 protected JPanel createLineTypePane() { lineTypePane = getLineTypePane(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line"), lineTypePane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Line"), lineTypePane); } protected VanChartLineTypePane getLineTypePane() { @@ -145,29 +143,30 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP //标记点类型 protected JPanel createMarkerPane() { markerPane = new VanChartMarkerPane(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Marker"), markerPane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Marker"), markerPane); } //填充颜色 protected JPanel createAreaFillColorPane() { areaSeriesFillColorPane = new VanChartAreaSeriesFillColorPane(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area"), areaSeriesFillColorPane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Area"), areaSeriesFillColorPane); } //边框(默认没有圆角) protected JPanel createBorderPane() { borderPane = createDiffBorderPane(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane); } //半径界面 - protected JPanel createRadiusPane() { + protected JPanel createRadiusPane(String title) { radiusPane = initRadiusPane(); - radiusPaneWithTitle = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Radius_Set"), radiusPane); - return ((VanChartPlot)plot).isInCustom() ? null : radiusPaneWithTitle; + radiusPaneWithTitle = TableLayout4VanChartHelper.createGapTableLayoutPane(title, radiusPane); + return ((VanChartPlot) plot).isInCustom() ? null : radiusPaneWithTitle; } + //大数据模式 恢复用注释。删除下面4个方法 createLargeDataModelPane checkLarge createLargeDataModelPane createLargeDataModelGroup。 protected JPanel createLargeDataModelPane() { largeDataModelGroup = createLargeDataModelGroup(); largeDataModelGroup.addChangeListener(new ChangeListener() { @@ -176,12 +175,12 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP checkLarge(); } }); - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Large_Model"), largeDataModelGroup); + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Large_Model"), largeDataModelGroup); return createLargeDataModelPane(panel); } protected void checkLarge() { - if(largeModel()) { + if (largeModel(plot)) { AttrLabel attrLabel = ((VanChartPlot) plot).getAttrLabelFromConditionCollection(); if (attrLabel == null) { attrLabel = ((VanChartPlot) this.plot).getDefaultAttrLabel(); @@ -190,56 +189,45 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP } attrLabel.setEnable(false); - resetCustomCondition(plot.getConditionCollection()); + VanChartInteractivePane.resetCustomCondition(plot.getConditionCollection()); } - checkCompsEnabledWithLarge(); + checkCompsEnabledWithLarge(plot); } - protected void checkCompsEnabledWithLarge() { - if(markerPane != null && largeDataModelGroup != null){ - markerPane.checkLargePlot(largeModel()); - } + protected JPanel createLargeDataModelPane(JPanel jPanel) { + JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Large_Data"), jPanel); + return panel; } - protected void checkLinePane() { - if(lineTypePane != null && largeDataModelGroup != null){ - lineTypePane.checkLarge(largeModel()); - } + protected UIButtonGroup createLargeDataModelGroup() { + String[] strings = new String[]{Toolkit.i18nText("Fine-Design_Chart_Open"), Toolkit.i18nText("Fine-Design_Chart_Close")}; + DataProcessor[] values = new DataProcessor[]{new LargeDataModel(), new NormalDataModel()}; + return new UIButtonGroup(strings, values); } - - protected boolean largeModel() { - return largeDataModelGroup != null && largeDataModelGroup.getSelectedIndex() == 0; + protected void checkCompsEnabledWithLarge(Plot plot) { + if (markerPane != null) { + markerPane.checkLargePlot(largeModel(plot)); + } } - protected void resetCustomCondition(ConditionCollection conditionCollection) { - for(int i = 0, len = conditionCollection.getConditionAttrSize(); i < len; i++){ - ConditionAttr conditionAttr = conditionCollection.getConditionAttr(i); - conditionAttr.remove(AttrLabel.class); - conditionAttr.remove(ScatterAttrLabel.class); - conditionAttr.remove(AttrEffect.class); - conditionAttr.remove(AttrLineEffect.class); - - VanChartAttrMarker attrMarker = conditionAttr.getExisted(VanChartAttrMarker.class); - if(attrMarker != null && !attrMarker.isCommon()){ - conditionAttr.remove(VanChartAttrMarker.class); - } + protected void checkLinePane() { + if (lineTypePane != null) { + lineTypePane.checkLarge(largeModel(plot)); } } - protected JPanel createLargeDataModelPane(JPanel jPanel) { - JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Large_Data"), jPanel); - return panel; - } - protected UIButtonGroup createLargeDataModelGroup() { - String[] strings = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}; - DataProcessor[] values = new DataProcessor[]{new LargeDataModel(), new NormalDataModel()}; - return new UIButtonGroup(strings, values); + protected boolean largeModel(Plot plot) { + //大数据模式 恢复用注释。下面1行删除。 + return largeDataModelGroup != null && largeDataModelGroup.getSelectedIndex() == 0; + //大数据模式 恢复用注释。取消注释。 + //return PlotFactory.largeDataModel(plot); } + protected RadiusCardLayoutPane initRadiusPane() { return new RadiusCardLayoutPane(); } @@ -252,13 +240,13 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP //不透明度 protected JPanel createAlphaPane() { transparent = new UINumberDragPane(0, 100); - return TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alpha"), transparent); + return TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Report_Alpha"), transparent); } //堆积和坐标轴设置(自定义柱形图等用到) protected JPanel createStackedAndAxisPane() { stackAndAxisEditPane = new VanChartStackedAndAxisListControlPane(); - stackAndAxisEditExpandablePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(stackAndAxisEditPane.getPaneTitle(), stackAndAxisEditPane); + stackAndAxisEditExpandablePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(stackAndAxisEditPane.getPaneTitle(), stackAndAxisEditPane); return stackAndAxisEditExpandablePane; } @@ -272,7 +260,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP * 更新Plot的属性到系列界面 */ public void populateBean(Plot plot) { - if(plot == null) { + if (plot == null) { return; } @@ -280,24 +268,25 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP super.populateBean(plot);//配色 - if(stylePane != null){//风格 + if (stylePane != null) {//风格 stylePane.populateBean(plot.getPlotStyle()); } - if(largeDataModelGroup != null){ + //大数据模式 恢复用注释。下面3行删除。 + if (largeDataModelGroup != null) { largeDataModelGroup.setSelectedItem(plot.getDataProcessor()); } - if(stackAndAxisEditPane != null && plot instanceof VanChartRectanglePlot){//堆积和坐标轴 - VanChartRectanglePlot rectanglePlot = (VanChartRectanglePlot)plot; - if(rectanglePlot.isCustomChart()){ + if (stackAndAxisEditPane != null && plot instanceof VanChartRectanglePlot) {//堆积和坐标轴 + VanChartRectanglePlot rectanglePlot = (VanChartRectanglePlot) plot; + if (rectanglePlot.isCustomChart()) { stackAndAxisEditPane.populate(rectanglePlot); } else { removeStackWholePane(); } } - if(radiusPane != null && plot instanceof VanChartRadiusPlot){ + if (radiusPane != null && plot instanceof VanChartRadiusPlot) { radiusPane.populateBean(plot); checkRadiusPane(plot); } @@ -306,17 +295,18 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP checkAreaSeriesFillColorPane(plot.getPlotStyle()); - checkCompsEnabledWithLarge(); + checkCompsEnabledWithLarge(plot); } /** * radius界面是否显示 + * * @param plot */ private void checkRadiusPane(Plot plot) { radiusPaneWithTitle.setVisible(true); - if (plot instanceof VanChartPlot){ - if (((VanChartPlot) plot).isInCustom()){ + if (plot instanceof VanChartPlot) { + if (((VanChartPlot) plot).isInCustom()) { radiusPaneWithTitle.setVisible(false); } } @@ -326,7 +316,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP * 保存 系列界面的属性到Plot */ public void updateBean(Plot plot) { - if(plot == null) { + if (plot == null) { return; } @@ -335,22 +325,23 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP super.updateBean(plot);//配色 - if(stylePane != null){//风格 + if (stylePane != null) {//风格 plot.setPlotStyle(stylePane.updateBean()); } - if(largeDataModelGroup != null){ + //大数据模式 恢复用注释。下面3行删除。 + if (largeDataModelGroup != null) { plot.setDataProcessor(largeDataModelGroup.getSelectedItem()); } - if(stackAndAxisEditPane != null && plot instanceof VanChartRectanglePlot){//堆积和坐标轴 - VanChartRectanglePlot rectanglePlot = (VanChartRectanglePlot)plot; - if(rectanglePlot.isCustomChart()){ + if (stackAndAxisEditPane != null && plot instanceof VanChartRectanglePlot) {//堆积和坐标轴 + VanChartRectanglePlot rectanglePlot = (VanChartRectanglePlot) plot; + if (rectanglePlot.isCustomChart()) { stackAndAxisEditPane.update(rectanglePlot); } } - if (radiusPane != null && plot instanceof VanChartRadiusPlot){ + if (radiusPane != null && plot instanceof VanChartRadiusPlot) { radiusPane.updateBean(plot); checkRadiusPane(plot); } @@ -360,47 +351,47 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP checkAreaSeriesFillColorPane(plot.getPlotStyle()); } - protected void checkoutMapType(Plot plot){ + protected void checkoutMapType(Plot plot) { } - protected void checkAreaSeriesFillColorPane(int plotStyle){ + protected void checkAreaSeriesFillColorPane(int plotStyle) { if (areaSeriesFillColorPane != null) { areaSeriesFillColorPane.checkoutAlpha(plotStyle == ChartConstants.STYLE_NONE); } } - protected void populateCondition(ConditionAttr defaultAttr){ - if(trendLinePane != null){//趋势线 - VanChartAttrTrendLine attrTrendLine =(VanChartAttrTrendLine)defaultAttr.getExisted(VanChartAttrTrendLine.class); + protected void populateCondition(ConditionAttr defaultAttr) { + if (trendLinePane != null) {//趋势线 + VanChartAttrTrendLine attrTrendLine = defaultAttr.getExisted(VanChartAttrTrendLine.class); trendLinePane.populate(attrTrendLine); } - if(lineTypePane != null){//线-线型、控制断开等 - VanChartAttrLine attrLine = (VanChartAttrLine)defaultAttr.getExisted(VanChartAttrLine.class); + if (lineTypePane != null) {//线-线型、控制断开等 + VanChartAttrLine attrLine = defaultAttr.getExisted(VanChartAttrLine.class); lineTypePane.populate(attrLine); } - if(markerPane != null){//标记点 - VanChartAttrMarker attrMarker = (VanChartAttrMarker)defaultAttr.getExisted(VanChartAttrMarker.class); + if (markerPane != null) {//标记点 + VanChartAttrMarker attrMarker = defaultAttr.getExisted(VanChartAttrMarker.class); markerPane.populate(attrMarker); } - if(areaSeriesFillColorPane != null){//填充颜色 - AttrAreaSeriesFillColorBackground seriesFillColorBackground = (AttrAreaSeriesFillColorBackground)defaultAttr.getExisted(AttrAreaSeriesFillColorBackground.class); + if (areaSeriesFillColorPane != null) {//填充颜色 + AttrAreaSeriesFillColorBackground seriesFillColorBackground = defaultAttr.getExisted(AttrAreaSeriesFillColorBackground.class); areaSeriesFillColorPane.populate(seriesFillColorBackground); } - if(borderPane != null){//边框 - AttrBorder attrBorder = (AttrBorder)defaultAttr.getExisted(AttrBorder.class); - if(attrBorder != null){ + if (borderPane != null) {//边框 + AttrBorder attrBorder = defaultAttr.getExisted(AttrBorder.class); + if (attrBorder != null) { borderPane.populate(attrBorder); } } populateAlpha(defaultAttr); } - protected void populateAlpha(ConditionAttr defaultAttr){ - if(transparent != null){//不透明度 - AttrAlpha attrAlpha = (AttrAlpha)defaultAttr.getExisted(AttrAlpha.class); - if(attrAlpha != null){ + protected void populateAlpha(ConditionAttr defaultAttr) { + if (transparent != null) {//不透明度 + AttrAlpha attrAlpha = defaultAttr.getExisted(AttrAlpha.class); + if (attrAlpha != null) { transparent.populateBean(attrAlpha.getAlpha() * VanChartAttrHelper.PERCENT); } else { //初始值为100 @@ -409,35 +400,35 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP } } - protected void updateCondition(ConditionAttr defaultAttr){ - if(trendLinePane != null){ + protected void updateCondition(ConditionAttr defaultAttr) { + if (trendLinePane != null) { VanChartAttrTrendLine newTrendLine = trendLinePane.update(); - VanChartAttrTrendLine attrTrendLine =(VanChartAttrTrendLine)defaultAttr.getExisted(VanChartAttrTrendLine.class); + VanChartAttrTrendLine attrTrendLine = defaultAttr.getExisted(VanChartAttrTrendLine.class); defaultAttr.remove(attrTrendLine); defaultAttr.addDataSeriesCondition(newTrendLine); } - if(lineTypePane != null){ - VanChartAttrLine attrLine = (VanChartAttrLine)defaultAttr.getExisted(VanChartAttrLine.class); + if (lineTypePane != null) { + VanChartAttrLine attrLine = defaultAttr.getExisted(VanChartAttrLine.class); defaultAttr.remove(attrLine); defaultAttr.addDataSeriesCondition(lineTypePane.update()); } - if(markerPane != null){ + if (markerPane != null) { VanChartAttrMarker newMarker = markerPane.update(); - VanChartAttrMarker attrMarker = (VanChartAttrMarker)defaultAttr.getExisted(VanChartAttrMarker.class); + VanChartAttrMarker attrMarker = defaultAttr.getExisted(VanChartAttrMarker.class); defaultAttr.remove(attrMarker); defaultAttr.addDataSeriesCondition(newMarker); } - if(areaSeriesFillColorPane != null){ + if (areaSeriesFillColorPane != null) { AttrAreaSeriesFillColorBackground newFillColorBackground = areaSeriesFillColorPane.update(); AttrAreaSeriesFillColorBackground oldFillColorBackground = defaultAttr.getExisted(AttrAreaSeriesFillColorBackground.class); - if(oldFillColorBackground != null){ + if (oldFillColorBackground != null) { defaultAttr.remove(oldFillColorBackground); } defaultAttr.addDataSeriesCondition(newFillColorBackground); } - if(borderPane != null){ - AttrBorder attrBorder = (AttrBorder)defaultAttr.getExisted(AttrBorder.class); - if(attrBorder == null){ + if (borderPane != null) { + AttrBorder attrBorder = defaultAttr.getExisted(AttrBorder.class); + if (attrBorder == null) { attrBorder = new AttrBorder(); defaultAttr.addDataSeriesCondition(attrBorder); } @@ -446,14 +437,14 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP updateAlpha(defaultAttr); } - protected void updateAlpha(ConditionAttr defaultAttr){ - if(transparent != null){ - AttrAlpha attrAlpha = (AttrAlpha)defaultAttr.getExisted(AttrAlpha.class); - if(attrAlpha == null){ + protected void updateAlpha(ConditionAttr defaultAttr) { + if (transparent != null) { + AttrAlpha attrAlpha = defaultAttr.getExisted(AttrAlpha.class); + if (attrAlpha == null) { attrAlpha = new AttrAlpha(); defaultAttr.addDataSeriesCondition(attrAlpha); } - attrAlpha.setAlpha((float)(transparent.updateBean()/VanChartAttrHelper.PERCENT)); + attrAlpha.setAlpha((float) (transparent.updateBean() / VanChartAttrHelper.PERCENT)); } } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotTooltipPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotTooltipPane.java index e3f45a9c0a..1c3ed4aa53 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotTooltipPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotTooltipPane.java @@ -4,7 +4,7 @@ import com.fr.chart.chartattr.Plot; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.icheckbox.UICheckBox; -import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; @@ -52,7 +52,7 @@ public class VanChartPlotTooltipPane extends BasicPane { } protected void addComponents(Plot plot) { - isTooltipShow = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Tooltip")); + isTooltipShow = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Use_Tooltip")); tooltipPane = createTooltipPane(plot); double p = TableLayout.PREFERRED; @@ -96,8 +96,8 @@ public class VanChartPlotTooltipPane extends BasicPane { Component[][] components = new Component[][]{ new Component[]{tooltipContentPane,null}, new Component[]{createLabelStylePane(),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Border"),borderPane),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane),null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"),borderPane),null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane),null}, new Component[]{createDisplayStrategy(plot),null}, }; return components; @@ -109,25 +109,25 @@ public class VanChartPlotTooltipPane extends BasicPane { } protected JPanel createLabelStylePane() { - style = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Automatic"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")}); + style = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Automatic"),Toolkit.i18nText("Fine-Design_Chart_Custom")}); textFontPane = new ChartTextAttrPane() { protected Component[][] getComponents(JPanel buttonPane) { return new Component[][]{ new Component[]{null, null}, - new Component[]{null, fontNameComboBox}, + new Component[]{null, getFontNameComboBox()}, new Component[]{null, buttonPane} }; } }; - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Character"), style); + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Character"), style); JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(panel, BorderLayout.CENTER); panel1.add(textFontPane, BorderLayout.SOUTH); initStyleListener(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel1); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel1); } @@ -142,8 +142,8 @@ public class VanChartPlotTooltipPane extends BasicPane { protected JPanel createDisplayStrategy(Plot plot) { showAllSeries = new UICheckBox(getShowAllSeriesLabelText()); - followMouse = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Follow_Mouse"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Not_Follow_Mouse")}); + followMouse = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Follow_Mouse"), + Toolkit.i18nText("Fine-Design_Chart_Not_Follow_Mouse")}); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; @@ -151,17 +151,17 @@ public class VanChartPlotTooltipPane extends BasicPane { double[] rowSize = { p,p,p}; Component[][] components = new Component[3][2]; components[0] = new Component[]{null,null}; - components[1] = new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Prompt_Box")), UIComponentUtils.wrapWithBorderLayoutPane(followMouse)}; + components[1] = new Component[]{FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Prompt_Box")), UIComponentUtils.wrapWithBorderLayoutPane(followMouse)}; if(plot.isSupportTooltipSeriesType() && hasTooltipSeriesType()){ components[2] = new Component[]{showAllSeries,null}; } JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components,rowSize,columnSize); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel); } protected String getShowAllSeriesLabelText() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Show_All_Series"); + return Toolkit.i18nText("Fine-Design_Chart_Show_All_Series"); }; protected boolean hasTooltipSeriesType() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java index b8550e0d42..36f34c9953 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java @@ -7,11 +7,16 @@ import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionCollection; import com.fr.chart.chartglyph.DataSheet; +import com.fr.chartx.data.AbstractDataDefinition; +import com.fr.chartx.data.ChartDataDefinitionProvider; +import com.fr.chartx.data.field.AbstractColumnFieldCollection; +import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.MultilineLabel; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.design.mainframe.chart.gui.type.ChartImagePane; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.general.Background; import com.fr.js.NameJavaScriptGroup; import com.fr.log.FineLoggerFactory; @@ -105,8 +110,22 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane initPaneList() { List paneList = new ArrayList(); - if(layerPane != null) { + if (layerPane != null) { paneList.add(layerPane); } - if(dataPane != null) { + if (dataPane != null) { paneList.add(dataPane); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapDataPane.java b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapDataPane.java index 4f5ab5e21d..322d46972a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapDataPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapDataPane.java @@ -7,14 +7,14 @@ import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.UIComboBoxPane; import com.fr.design.mainframe.chart.gui.ChartDataPane; - import com.fr.plugin.chart.drillmap.data.DrillMapDefinition; +import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; import com.fr.plugin.chart.type.MapType; import com.fr.van.chart.map.designer.data.MapDataPaneHelper; -import java.awt.*; import java.util.ArrayList; import java.util.List; +import java.awt.BorderLayout; /** * Created by Mitisky on 16/6/20. @@ -28,7 +28,7 @@ public class DrillMapDataPane extends BasicBeanPane { private ChartDataPane parent; - public DrillMapDataPane(final AttributeChangeListener listener,final ChartDataPane parent) { + public DrillMapDataPane(final AttributeChangeListener listener, final ChartDataPane parent) { this.parent = parent; bottomDataDefinitionPane = new SingleLayerDataDefinitionPane(listener, parent); eachLayerDataDefinitionPane = new EachLayerDataDefinitionPane(listener, parent); @@ -78,7 +78,8 @@ public class DrillMapDataPane extends BasicBeanPane { dataDefinitionType.setSelectedIndex(MapDataPaneHelper.isFromBottomData(ob) ? 0 : 1); ChartCollection bottomDataChartCollection = MapDataPaneHelper.getBottomDataDrillMapChartCollection(ob); - bottomDataDefinitionPane.populateBean(bottomDataChartCollection); + + bottomDataDefinitionPane.populateBean(bottomDataChartCollection, ChartGEOJSONHelper.BOTTOM_LEVEL); eachLayerDataDefinitionPane.populateBean(ob); parent.initAllListeners(); @@ -95,11 +96,11 @@ public class DrillMapDataPane extends BasicBeanPane { @Override public void updateBean(ChartCollection ob) { DrillMapDefinition drillMapDefinition = MapDataPaneHelper.getDrillMapDefinition(ob); - if(drillMapDefinition == null){ + if (drillMapDefinition == null) { drillMapDefinition = new DrillMapDefinition(); ob.getSelectedChart().setFilterDefinition(drillMapDefinition); } - if(dataDefinitionType.getSelectedIndex() == 0){ + if (dataDefinitionType.getSelectedIndex() == 0) { drillMapDefinition.setFromBottomData(true); ChartCollection temp = new ChartCollection(new Chart()); bottomDataDefinitionPane.updateBean(temp); diff --git a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapLayerPane.java b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapLayerPane.java index 6fd6ecabbc..0c6fcc1e4c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapLayerPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapLayerPane.java @@ -7,9 +7,9 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.general.ComparatorUtils; - import com.fr.plugin.chart.drillmap.DrillMapHelper; import com.fr.plugin.chart.drillmap.VanChartDrillMapPlot; +import com.fr.plugin.chart.map.data.MapMatchResult; import com.fr.plugin.chart.map.server.CompatibleGeoJSONTreeHelper; import com.fr.plugin.chart.type.MapType; import com.fr.plugin.chart.type.ZoomLevel; @@ -19,10 +19,11 @@ import com.fr.van.chart.map.designer.type.VanChartMapSourceChoosePane; import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.tree.DefaultMutableTreeNode; -import java.awt.BorderLayout; -import java.awt.Component; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; +import java.awt.BorderLayout; +import java.awt.Component; /** * Created by Mitisky on 16/6/20. @@ -125,6 +126,7 @@ public class DrillMapLayerPane extends BasicScrollPane { if (drillMapPlot != null) { java.util.List levelList = drillMapPlot.getLayerLevelList(); java.util.List mapTypeList = drillMapPlot.getLayerMapTypeList(); + List matchResultList = drillMapPlot.getMatchResultList(); if (detailComps == null || drillMapPlot.getMapType() != oldMapType || !ComparatorUtils.equals(drillMapPlot.getGeoUrl(), oldGeoUrl)) { oldMapType = drillMapPlot.getMapType(); @@ -151,6 +153,11 @@ public class DrillMapLayerPane extends BasicScrollPane { mapTypeList.add(mapType); } + int matchSize = matchResultList.size(); + for (int k = matchSize; k < depth; k++) { + matchResultList.add(new MapMatchResult()); + } + for (int i = 0; i < depth; i++) { Component[] components = detailComps[i + 1]; if (components != null) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/EachLayerDataDefinitionPane.java b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/EachLayerDataDefinitionPane.java index 3a688dcfb7..37e7f823f0 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/EachLayerDataDefinitionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/EachLayerDataDefinitionPane.java @@ -8,7 +8,6 @@ import com.fr.design.dialog.MultiTabPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.general.ComparatorUtils; - import com.fr.plugin.chart.drillmap.DrillMapHelper; import com.fr.plugin.chart.drillmap.VanChartDrillMapPlot; import com.fr.plugin.chart.drillmap.data.DrillMapDefinition; @@ -17,9 +16,9 @@ import com.fr.plugin.chart.type.MapType; import com.fr.van.chart.map.designer.data.MapDataPaneHelper; import javax.swing.tree.DefaultMutableTreeNode; -import java.awt.*; import java.util.ArrayList; import java.util.List; +import java.awt.CardLayout; /** * Created by Mitisky on 16/6/20. @@ -38,7 +37,7 @@ public class EachLayerDataDefinitionPane extends MultiTabPane { cardLayout = new CardLayout(); } - private void initComponents(){ + private void initComponents() { super.relayoutWhenListChange(); } @@ -56,7 +55,7 @@ public class EachLayerDataDefinitionPane extends MultiTabPane { protected List initPaneList() { List paneList = new ArrayList(); - for(int i = 1; i < depth + 1; i++){ + for (int i = 1; i < depth + 1; i++) { String tile = String.format("%s%d%s", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Index_Article"), i, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Index_Layer")); SingleLayerDataDefinitionPane pane = new SingleLayerDataDefinitionPane(tile, this.listener, this.parent); @@ -70,10 +69,10 @@ public class EachLayerDataDefinitionPane extends MultiTabPane { @Override public void populateBean(ChartCollection ob) { VanChartDrillMapPlot drillMapPlot = DrillMapHelper.getDrillMapPlot(ob); - if(drillMapPlot == null){ + if (drillMapPlot == null) { return; } - if(!ComparatorUtils.equals(oldGeoUrl, drillMapPlot.getGeoUrl())) { + if (!ComparatorUtils.equals(oldGeoUrl, drillMapPlot.getGeoUrl())) { oldGeoUrl = drillMapPlot.getGeoUrl(); DefaultMutableTreeNode root = CompatibleGeoJSONTreeHelper.getNodeByJSONPath(oldGeoUrl); if (root == null) { @@ -90,13 +89,13 @@ public class EachLayerDataDefinitionPane extends MultiTabPane { populatePaneList(ob); } - private void populatePaneList(ChartCollection chartCollection){ - for(int i = 0, len = paneList.size(); i < len; i++){ + private void populatePaneList(ChartCollection chartCollection) { + for (int i = 0, len = paneList.size(); i < len; i++) { BasicPane basicPane = paneList.get(i); MapType mapType = oldMapList.get(i); - if(basicPane instanceof SingleLayerDataDefinitionPane){ + if (basicPane instanceof SingleLayerDataDefinitionPane) { ChartCollection clone = MapDataPaneHelper.getLayerChartCollection(chartCollection, i, mapType); - ((SingleLayerDataDefinitionPane) basicPane).populateBean(clone); + ((SingleLayerDataDefinitionPane) basicPane).populateBean(clone, i); } } } @@ -113,8 +112,8 @@ public class EachLayerDataDefinitionPane extends MultiTabPane { public void updateBean(ChartCollection ob) { DrillMapDefinition drillMapDefinition = MapDataPaneHelper.getDrillMapDefinition(ob); List eachLayerDataDefinitionList = new ArrayList(); - for(BasicPane basicPane : paneList){ - if(basicPane instanceof SingleLayerDataDefinitionPane){ + for (BasicPane basicPane : paneList) { + if (basicPane instanceof SingleLayerDataDefinitionPane) { ChartCollection temp = new ChartCollection(new Chart()); ((SingleLayerDataDefinitionPane) basicPane).updateBean(temp); eachLayerDataDefinitionList.add(temp.getSelectedChart().getFilterDefinition()); @@ -159,11 +158,11 @@ public class EachLayerDataDefinitionPane extends MultiTabPane { * @param supportCellData */ public void setSupportCellData(boolean supportCellData) { - if(paneList == null){ + if (paneList == null) { return; } - for(BasicPane basicPane : paneList){ - if(basicPane instanceof SingleLayerDataDefinitionPane){ + for (BasicPane basicPane : paneList) { + if (basicPane instanceof SingleLayerDataDefinitionPane) { ((SingleLayerDataDefinitionPane) basicPane).setSupportCellData(supportCellData); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/SingleLayerDataDefinitionPane.java b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/SingleLayerDataDefinitionPane.java index 5ec0e1f4a4..16906845e7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/SingleLayerDataDefinitionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/SingleLayerDataDefinitionPane.java @@ -6,7 +6,6 @@ import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.data.NormalChartDataPane; - import java.awt.BorderLayout; /** @@ -79,6 +78,11 @@ public class SingleLayerDataDefinitionPane extends FurtherBasicBeanPane()); drillMapPlot.setLayerMapTypeList(new ArrayList()); } + + @Override + protected boolean acceptDefinition(ChartDataDefinitionProvider definition, VanChartPlot vanChartPlot) { + return definition instanceof DrillMapDefinition; + } } 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 5496959700..2899a9e117 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 @@ -90,4 +90,15 @@ public class FunnelIndependentVanChartInterface extends AbstractIndependentVanCh return "com/fr/design/images/form/toolbar/funnel.png"; } + //图表数据结构 恢复用注释。取消注释。 +// @Override +// public ChartDataPane getChartDataPane(AttributeChangeListener listener) { +// return new AbstractVanSingleDataPane(listener) { +// @Override +// protected SingleDataPane createSingleDataPane() { +// return new SingleDataPane(new FunnelDataSetFieldsPane(), new FunnelCellDataFieldsPane()); +// } +// }; +// +// } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/type/VanChartFunnelTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/type/VanChartFunnelTypePane.java index 884f211002..444f9a4d80 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/type/VanChartFunnelTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/type/VanChartFunnelTypePane.java @@ -2,7 +2,12 @@ package com.fr.van.chart.funnel.designer.type; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; +import com.fr.chartx.data.AbstractDataDefinition; +import com.fr.chartx.data.ChartDataDefinitionProvider; +import com.fr.chartx.data.field.AbstractColumnFieldCollection; +import com.fr.chartx.data.field.diff.ColumnFieldCollectionWithSeriesValue; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.funnel.FunnelIndependentVanChart; import com.fr.plugin.chart.funnel.VanChartFunnelPlot; @@ -43,4 +48,13 @@ public class VanChartFunnelTypePane extends AbstractVanChartTypePane { public Chart getDefaultChart() { return FunnelIndependentVanChart.FunnelVanChartTypes[0]; } + + @Override + protected boolean acceptDefinition(ChartDataDefinitionProvider definition, VanChartPlot vanChartPlot) { + if (definition instanceof AbstractDataDefinition) { + AbstractColumnFieldCollection columnFieldCollection = ((AbstractDataDefinition) definition).getColumnFieldCollection(); + return columnFieldCollection.getClass().equals(ColumnFieldCollectionWithSeriesValue.class); + } + return false; + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/type/VanChartGanttPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/type/VanChartGanttPlotPane.java index 367041ae0c..5e63dab7ae 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/type/VanChartGanttPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/type/VanChartGanttPlotPane.java @@ -2,7 +2,10 @@ package com.fr.van.chart.gantt.designer.type; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; +import com.fr.chartx.data.ChartDataDefinitionProvider; +import com.fr.chartx.data.GanttChartDataDefinition; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.gantt.GanttIndependentVanChart; import com.fr.plugin.chart.gantt.VanChartGanttPlot; import com.fr.van.chart.designer.type.AbstractVanChartTypePane; @@ -21,16 +24,21 @@ public class VanChartGanttPlotPane extends AbstractVanChartTypePane { return GanttIndependentVanChart.ganttVanChartTypes[0]; } - protected Plot getSelectedClonedPlot(){ + protected Plot getSelectedClonedPlot() { Chart chart = getDefaultChart(); VanChartGanttPlot newPlot = (VanChartGanttPlot) chart.getPlot(); Plot cloned = null; try { - cloned = (Plot)newPlot.clone(); + cloned = (Plot) newPlot.clone(); } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } return cloned; } + + @Override + protected boolean acceptDefinition(ChartDataDefinitionProvider definition, VanChartPlot vanChartPlot) { + return definition instanceof GanttChartDataDefinition; + } } \ No newline at end of file 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 af4aa2c8ff..1e7a6fb322 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 @@ -64,10 +64,10 @@ public class GaugeIndependentVanChartInterface extends AbstractIndependentVanCha return new VanChartGaugePlotPane(); } - public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent){ - if(plot instanceof VanChartGaugePlot){ - VanChartGaugePlot gaugePlot = (VanChartGaugePlot)plot; - switch (gaugePlot.getGaugeStyle()){ + public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { + if (plot instanceof VanChartGaugePlot) { + VanChartGaugePlot gaugePlot = (VanChartGaugePlot) plot; + switch (gaugePlot.getGaugeStyle()) { case POINTER: return gaugePlot.isInCustom() ? new CategoryCustomPlotTableDataContentPane(parent) : new CategoryPlotTableDataContentPane(parent); case POINTER_SEMI: @@ -76,13 +76,13 @@ public class GaugeIndependentVanChartInterface extends AbstractIndependentVanCha break; } } - return ((VanChartGaugePlot)plot).isInCustom() ? new MeterCustomPlotTableDataContentPane(parent) : new MeterPlotTableDataContentPane(parent); + return ((VanChartGaugePlot) plot).isInCustom() ? new MeterCustomPlotTableDataContentPane(parent) : new MeterPlotTableDataContentPane(parent); } - public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent){ - if(plot instanceof VanChartGaugePlot){ - VanChartGaugePlot gaugePlot = (VanChartGaugePlot)plot; - switch (gaugePlot.getGaugeStyle()){ + public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { + if (plot instanceof VanChartGaugePlot) { + VanChartGaugePlot gaugePlot = (VanChartGaugePlot) plot; + switch (gaugePlot.getGaugeStyle()) { case POINTER: return new CategoryPlotReportDataContentPane(parent); case POINTER_SEMI: @@ -96,15 +96,34 @@ public class GaugeIndependentVanChartInterface extends AbstractIndependentVanCha /** * 图表的属性界面数组 + * * @return 属性界面 */ - public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener){ + public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener) { VanChartStylePane stylePane = new VanChartGaugeStylePane(listener); VanChartOtherPane otherPane = new VanChartOtherPane(); return new AbstractChartAttrPane[]{stylePane, otherPane}; } - public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot){ + public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot) { return new VanChartGaugeSeriesPane(parent, plot); } + + //图表数据结构 恢复用注释。取消注释。 +// @Override +// public ChartDataPane getChartDataPane(AttributeChangeListener listener) { +// return new AbstractVanSingleDataPane(listener) { +// @Override +// protected SingleDataPane createSingleDataPane() { +// VanChartGaugePlot gaugePlot = null; +// if (getVanChart() != null) { +// gaugePlot = getVanChart().getPlot(); +// } +// if (gaugePlot != null && !gaugePlot.isMultiPointer()) { +// return new SingleDataPane(new GaugeDataSetFieldsPane(), new GaugeCellDataFieldsPane()); +// } +// return new SingleDataPane(new SingleCategoryDataSetFieldsPane(), new SingleCategoryCellDataFieldsPane()); +// } +// }; +// } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugePlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugePlotPane.java index 4ae8606693..1ede3efb39 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugePlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugePlotPane.java @@ -2,9 +2,16 @@ package com.fr.van.chart.gauge; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; +import com.fr.chartx.data.AbstractDataDefinition; +import com.fr.chartx.data.ChartDataDefinitionProvider; +import com.fr.chartx.data.field.AbstractColumnFieldCollection; +import com.fr.chartx.data.field.diff.GaugeColumnFieldCollection; +import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.gauge.GaugeIndependentVanChart; import com.fr.plugin.chart.gauge.VanChartGaugePlot; +import com.fr.plugin.chart.type.GaugeStyle; import com.fr.van.chart.designer.type.AbstractVanChartTypePane; /** @@ -73,4 +80,23 @@ public class VanChartGaugePlotPane extends AbstractVanChartTypePane { } } } + + @Override + protected boolean acceptDefinition(ChartDataDefinitionProvider definition, VanChartPlot vanChartPlot) { + if(definition instanceof AbstractDataDefinition) { + AbstractColumnFieldCollection columnFieldCollection = ((AbstractDataDefinition) definition).getColumnFieldCollection(); + GaugeStyle gaugeStyle = ((VanChartGaugePlot) vanChartPlot).getGaugeStyle(); + switch (gaugeStyle) { + case RING: + case SLOT: + case THERMOMETER: + return columnFieldCollection instanceof GaugeColumnFieldCollection; + case POINTER: + case POINTER_SEMI: + default: + return columnFieldCollection instanceof MultiCategoryColumnFieldCollection; + } + } + return false; + } } \ No newline at end of file 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 79509aee25..c4ce90edc7 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 @@ -2,8 +2,10 @@ package com.fr.van.chart.gauge; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; +import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; @@ -11,9 +13,11 @@ import com.fr.design.mainframe.chart.gui.style.series.ColorPickerPaneWithFormula import com.fr.design.mainframe.chart.gui.style.series.UIColorPickerPane; import com.fr.design.style.color.ColorSelectBox; import com.fr.general.ComparatorUtils; +import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.attr.GaugeDetailStyle; import com.fr.plugin.chart.base.AttrLabel; +import com.fr.plugin.chart.base.AttrLabelDetail; import com.fr.plugin.chart.gauge.VanChartGaugePlot; import com.fr.plugin.chart.type.GaugeStyle; import com.fr.stable.Constants; @@ -46,6 +50,9 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { private UIColorPickerPane colorPickerPane; + private UISpinner thermometerWidth; + private UINumberDragPane chutePercent; + public VanChartGaugeSeriesPane(ChartStylePane parent, Plot plot) { super(parent, plot); } @@ -66,15 +73,26 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { } private JPanel createGaugeLayoutPane() { - gaugeLayout = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical")}); - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Page_Setup_Orientation"),gaugeLayout); + gaugeLayout = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal"), Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical")}); + + String title = Toolkit.i18nText("Fine-Design_Report_Page_Setup_Orientation"); + + if (plot instanceof VanChartGaugePlot) { + VanChartGaugePlot gaugePlot = (VanChartGaugePlot) plot; + + if (gaugePlot.getGaugeStyle() == GaugeStyle.THERMOMETER) { + title = Toolkit.i18nText("Fine-Design_Report_Page_Setup_Sort_Orientation"); + } + } + + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(title, gaugeLayout); gaugeLayout.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { changeLabelPosition(); } }); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout"), panel); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Layout"), panel); } private void changeLabelPosition() { @@ -86,13 +104,16 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { if(attrLabel == null){ return; } + AttrLabelDetail attrLabelDetail = attrLabel.getAttrLabelDetail(); + if(attrLabelDetail == null || attrLabelDetail.getTextAttr() == null){ + return; + } + attrLabelDetail.getTextAttr().setFRFont(VanChartGaugePlot.THERMOMETER_LABEL_FONT); if(gaugeLayout.getSelectedIndex() == 0){ attrLabel.getAttrLabelDetail().setPosition(Constants.LEFT); - attrLabel.getAttrLabelDetail().getTextAttr().setFRFont(VanChartGaugePlot.THERMOMETER_VERTICAL_PERCENT_LABEL_FONT); attrLabel.getGaugeValueLabelDetail().setPosition(Constants.LEFT); } else { attrLabel.getAttrLabelDetail().setPosition(Constants.BOTTOM); - attrLabel.getAttrLabelDetail().getTextAttr().setFRFont(VanChartGaugePlot.THERMOMETER_PERCENT_LABEL_FONT); attrLabel.getGaugeValueLabelDetail().setPosition(Constants.BOTTOM); } } @@ -104,10 +125,10 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { JPanel centerPanel = TableLayoutHelper.createTableLayoutPane(getDiffComponentsWithGaugeStyle(), row, col); panel.add(centerPanel, BorderLayout.CENTER); if(rotate != null){ - JPanel panel1 = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Rotation_Direction"), rotate); + JPanel panel1 = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Rotation_Direction"), rotate); panel.add(panel1, BorderLayout.NORTH); } - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel); } private Component[][] getDiffComponentsWithGaugeStyle() { @@ -119,21 +140,24 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { new Component[]{null, null}, getPaneBackgroundColor(), getInnerPaneBackgroundColor(), - new Component[]{createRadiusPane(), null} + new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Radius_Set")), null}, + getChutePercent() }; case SLOT: return new Component[][]{ new Component[]{null, null}, getNeedleColor(), getSlotBackgroundColor(), - new Component[]{createRadiusPane(), null} + new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Radius_Set")), null}, + getChutePercent() }; case THERMOMETER: return new Component[][]{ new Component[]{null, null}, getNeedleColor(), getSlotBackgroundColor(), - new Component[]{createRadiusPane(), null} + new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Length_Set")), null}, + getThermometerWidth() }; default: return new Component[][]{ @@ -142,48 +166,58 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { getHingeBackgroundColor(), getNeedleColor(), getPaneBackgroundColor(), - new Component[]{createRadiusPane(), null} + new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Radius_Set")), null} }; } } private Component[] getHingeColor() { hingeColor = new ColorSelectBox(120); - return new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Hinge")),hingeColor}; + return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Hinge")),hingeColor}; } private Component[] getHingeBackgroundColor() { hingeBackgroundColor = new ColorSelectBox(120); - return new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Hinge_Background")),hingeBackgroundColor}; + return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Hinge_Background")),hingeBackgroundColor}; } private Component[] getNeedleColor() { needleColor = new ColorSelectBox(120); - return new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Needle")),needleColor}; + return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Needle")),needleColor}; } private Component[] getPaneBackgroundColor() { paneBackgroundColor = new ColorSelectBox(120); - return new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Pane_Background")),paneBackgroundColor}; + return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Pane_Background")),paneBackgroundColor}; } private Component[] getSlotBackgroundColor() { slotBackgroundColor = new ColorSelectBox(120); - return new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Slot_Background")),slotBackgroundColor}; + return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Slot_Background")),slotBackgroundColor}; + } + + private Component[] getThermometerWidth() { + thermometerWidth = new UISpinner(0, Double.MAX_VALUE, 0.1, 10); + return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Thermometer_Width")),thermometerWidth}; + } + + private Component[] getChutePercent() { + chutePercent = new UINumberDragPane(0, 100, 1); + return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Chute_Percent")),chutePercent}; } private void initRotate() { - rotate = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_AntiClockWise"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_ClockWise")}); + rotate = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_AntiClockWise"), Toolkit.i18nText("Fine-Design_Chart_ClockWise")}); } private Component[] getInnerPaneBackgroundColor() { innerPaneBackgroundColor = new ColorSelectBox(120); - return new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Inner_Pane_Background")),innerPaneBackgroundColor}; + return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Inner_Pane_Background")),innerPaneBackgroundColor}; } private JPanel createGaugeBandsPane() { colorPickerPane = new ColorPickerPaneWithFormula(parentPane, "meterString"); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Range"), colorPickerPane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Range"), colorPickerPane); } @@ -218,6 +252,12 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { if(innerPaneBackgroundColor != null){ innerPaneBackgroundColor.setSelectObject(detailStyle.getInnerPaneBackgroundColor()); } + if(thermometerWidth != null){ + thermometerWidth.setValue(detailStyle.getThermometerWidth()); + } + if(chutePercent != null){ + chutePercent.populateBean(detailStyle.getChutePercent()); + } colorPickerPane.populateBean(detailStyle.getHotAreaColor()); } @@ -256,6 +296,12 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { if(innerPaneBackgroundColor != null){ detailStyle.setInnerPaneBackgroundColor(innerPaneBackgroundColor.getSelectObject()); } + if(thermometerWidth != null){ + detailStyle.setThermometerWidth(thermometerWidth.getValue()); + } + if(chutePercent != null){ + detailStyle.setChutePercent(chutePercent.updateBean()); + } colorPickerPane.updateBean(detailStyle.getHotAreaColor()); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/HeatMapIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/VanHeatMapChartTypeUI.java similarity index 66% rename from designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/HeatMapIndependentVanChartInterface.java rename to designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/VanHeatMapChartTypeUI.java index b4e49606e3..712d3a3b76 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/HeatMapIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/VanHeatMapChartTypeUI.java @@ -15,13 +15,13 @@ import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.heatmap.designer.other.VanChartHeatMapConditionPane; import com.fr.van.chart.heatmap.designer.style.VanChartHeatMapSeriesPane; import com.fr.van.chart.heatmap.designer.type.VanChartHeatMapTypePane; -import com.fr.van.chart.map.MapIndependentVanChartInterface; +import com.fr.van.chart.map.VanMapChartTypeUI; import com.fr.van.chart.map.designer.style.VanChartMapStylePane; /** * Created by Mitisky on 16/10/20. */ -public class HeatMapIndependentVanChartInterface extends MapIndependentVanChartInterface { +public class VanHeatMapChartTypeUI extends VanMapChartTypeUI { /** * 图标路径 @@ -56,28 +56,48 @@ public class HeatMapIndependentVanChartInterface extends MapIndependentVanChartI return new VanChartHeatMapTypePane(); } + //图表数据结构 恢复用注释。删除下面方法。 @Override - protected boolean areaPlot(Plot plot){ + protected boolean areaPlot(Plot plot) { return false; } - public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot){ + //图表数据结构 恢复用注释。取消注释。 +// @Override +// public ChartDataPane getChartDataPane(AttributeChangeListener listener) { +// return new AbstractVanSingleDataPane(listener) { +// @Override +// protected SingleDataPane createSingleDataPane() { +// PointMapDataSetFieldsPane pointMapDataSetFieldsPane = new PointMapDataSetFieldsPane(); +// pointMapDataSetFieldsPane.setChart(getVanChart()); +// return new SingleDataPane(pointMapDataSetFieldsPane, new PointMapCellDataFieldsPane()); +// } +// }; +// } + + public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot) { return new VanChartHeatMapSeriesPane(parent, plot); } - public ConditionAttributesPane getPlotConditionPane(Plot plot){ + public ConditionAttributesPane getPlotConditionPane(Plot plot) { return new VanChartHeatMapConditionPane(plot); } /** * 图表的属性界面数组 + * * @return 属性界面 */ - public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener){ + public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener) { VanChartStylePane stylePane = new VanChartMapStylePane(listener); - VanChartOtherPane otherPane = new VanChartOtherPane(){ + VanChartOtherPane otherPane = new VanChartOtherPane() { protected BasicBeanPane createInteractivePane() { - return new VanChartInteractivePaneWithMapZoom(); + return new VanChartInteractivePaneWithMapZoom() { + @Override + protected boolean isCurrentChartSupportLargeDataMode() { + return true; + } + }; } }; return new AbstractChartAttrPane[]{stylePane, otherPane}; diff --git a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapTypePane.java index 6ffd80055a..43f03a13d3 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/type/VanChartHeatMapTypePane.java @@ -2,8 +2,10 @@ package com.fr.van.chart.heatmap.designer.type; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; +import com.fr.chartx.data.ChartDataDefinitionProvider; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.heatmap.HeatMapIndependentVanChart; import com.fr.plugin.chart.heatmap.VanChartHeatMapPlot; @@ -70,4 +72,9 @@ public class VanChartHeatMapTypePane extends VanChartMapPlotPane { public Chart getDefaultChart() { return HeatMapIndependentVanChart.HeatMapVanCharts[0]; } + + @Override + protected boolean acceptDefinition(ChartDataDefinitionProvider definition, VanChartPlot vanChartPlot) { + return false; + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/line/VanChartLineSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/line/VanChartLineSeriesPane.java index 21d5b60d37..aea7ace9e5 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/line/VanChartLineSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/line/VanChartLineSeriesPane.java @@ -12,23 +12,24 @@ import java.awt.Component; /** * 折线图的系列界面 */ -public class VanChartLineSeriesPane extends VanChartAbstractPlotSeriesPane{ +public class VanChartLineSeriesPane extends VanChartAbstractPlotSeriesPane { private static final long serialVersionUID = 5595016643808487932L; - public VanChartLineSeriesPane(ChartStylePane parent, Plot plot){ + public VanChartLineSeriesPane(ChartStylePane parent, Plot plot) { super(parent, plot); } - protected JPanel getContentInPlotType(){ + protected JPanel getContentInPlotType() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] row = {p,p,p,p,p,p,p,p}; + double[] row = {p, p, p, p, p, p, p, p}; double[] col = {f}; Component[][] components = new Component[][]{ new Component[]{createLineTypePane()}, new Component[]{createMarkerPane()}, new Component[]{createStackedAndAxisPane()}, + //大数据模式 恢复用注释。下面1行删除。 new Component[]{createLargeDataModelPane()}, new Component[]{createTrendLinePane()}, }; 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 df23244ccb..fd00a87c87 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 @@ -12,7 +12,6 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.style.color.ColorSelectBox; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; - import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.base.AttrBorderWithAlpha; import com.fr.plugin.chart.base.AttrEffect; @@ -30,6 +29,7 @@ import com.fr.van.chart.bubble.component.VanChartBubblePane; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.border.VanChartBorderWithAlphaPane; import com.fr.van.chart.designer.component.marker.VanChartImageMarkerPane; +import com.fr.van.chart.designer.other.VanChartInteractivePane; import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; import com.fr.van.chart.designer.style.series.VanChartEffectPane; import com.fr.van.chart.map.designer.style.series.VanChartMapScatterMarkerPane; @@ -79,6 +79,8 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { //line private VanChartCurvePane curvePane; private VanChartLineMapEffectPane lineMapEffectPane; + + //大数据模式 恢复用注释。下面1行删除。 private UIButtonGroup lineMapLargeDataModelGroup;//大数据模式 private MapType mapType = MapType.AREA; @@ -87,53 +89,71 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { super(parent, plot); } + //大数据模式 恢复用注释。删除下面4个方法 checkLarge lineMapLargeModel checkLineMapLarge createLineMapLargeDataModelPane。 @Override protected void checkLarge() { - if(largeModel()) { - if(plot instanceof VanChartMapPlot) { + if (largeModel(plot)) { + if (plot instanceof VanChartMapPlot) { ConditionAttr defaultAttr = plot.getConditionCollection().getDefaultAttr(); - AttrMapLabel attrMapLabel = defaultAttr.getExisted(AttrMapLabel.class); - if(attrMapLabel == null){ + AttrMapLabel attrMapLabel = defaultAttr.getExisted(AttrMapLabel.class); + if (attrMapLabel == null) { attrMapLabel = new AttrMapLabel(); defaultAttr.addDataSeriesCondition(attrMapLabel); } attrMapLabel.getPointLabel().setEnable(false); - resetCustomCondition(((VanChartMapPlot) plot).getPointConditionCollection()); + VanChartInteractivePane.resetCustomCondition(((VanChartMapPlot) plot).getPointConditionCollection()); } } - checkPointCompsEnabledWithLarge(); + checkPointCompsEnabledWithLarge(plot); } - protected void checkCompsEnabledWithLarge() { - checkPointCompsEnabledWithLarge(); - checkLineCompsEnabledWithLarge(); - } - - private void checkPointCompsEnabledWithLarge() { - if(pointEffectPane != null) { - GUICoreUtils.setEnabled(pointEffectPane, !largeModel()); - } - } private boolean lineMapLargeModel() { return lineMapLargeDataModelGroup != null && lineMapLargeDataModelGroup.getSelectedIndex() == 0; } private void checkLineMapLarge() { - if(lineMapLargeModel()) { - if(plot instanceof VanChartMapPlot) { - resetCustomCondition(((VanChartMapPlot) plot).getLineConditionCollection()); + if (lineMapLargeModel()) { + if (plot instanceof VanChartMapPlot) { + VanChartInteractivePane.resetCustomCondition(((VanChartMapPlot) plot).getLineConditionCollection()); } } - checkLineCompsEnabledWithLarge(); + checkLineCompsEnabledWithLarge(plot); } - private void checkLineCompsEnabledWithLarge() { - if(lineMapEffectPane != null) { + private JPanel createLineMapLargeDataModelPane() { + lineMapLargeDataModelGroup = createLargeDataModelGroup(); + lineMapLargeDataModelGroup.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + checkLineMapLarge(); + } + }); + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Large_Model"), lineMapLargeDataModelGroup); + return createLargeDataModelPane(panel); + } + + + protected void checkCompsEnabledWithLarge(Plot plot) { + checkPointCompsEnabledWithLarge(plot); + checkLineCompsEnabledWithLarge(plot); + } + + private void checkPointCompsEnabledWithLarge(Plot plot) { + if (pointEffectPane != null) { + GUICoreUtils.setEnabled(pointEffectPane, !largeModel(plot)); + } + } + + private void checkLineCompsEnabledWithLarge(Plot plot) { + if (lineMapEffectPane != null) { + //大数据模式 恢复用注释。下面1行删除。 GUICoreUtils.setEnabled(lineMapEffectPane, !lineMapLargeModel()); + //大数据模式 恢复用注释。取消注释。 + //GUICoreUtils.setEnabled(lineMapEffectPane, !largeModel(plot)); } } @@ -195,6 +215,7 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { Component[][] components = new Component[][]{ new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle((com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")), createPointAlphaPane())}, new Component[]{createMarkerComPane()}, + //大数据模式 恢复用注释。下面1行删除。 new Component[]{createLargeDataModelPane()}, new Component[]{createPointEffectPane()}, }; @@ -212,6 +233,7 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { Component[][] components = new Component[][]{ new Component[]{createCurvePane()}, + //大数据模式 恢复用注释。下面1行删除。 new Component[]{createLineMapLargeDataModelPane()}, new Component[]{createAnimationPane()} }; @@ -219,18 +241,6 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { return TableLayoutHelper.createTableLayoutPane(components, row, col); } - private JPanel createLineMapLargeDataModelPane() { - lineMapLargeDataModelGroup = createLargeDataModelGroup(); - lineMapLargeDataModelGroup.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - checkLineMapLarge(); - } - }); - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Large_Model"), lineMapLargeDataModelGroup); - return createLargeDataModelPane(panel); - } - private Component createCurvePane() { curvePane = new VanChartCurvePane(); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Curve"), curvePane); @@ -257,8 +267,8 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { commonMarkerPane = new VanChartMapScatterMarkerPane(); commonMarkerPane.setBorder(TableLayout4VanChartHelper.SECOND_EDIT_AREA_BORDER); - bubblePane = new VanChartBubblePane(){ - protected JPanel getContentPane () { + bubblePane = new VanChartBubblePane() { + protected JPanel getContentPane() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; @@ -304,7 +314,7 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { JPanel pointPane = createPointPane(); JPanel linePane = createLinePane(); - JPanel panel = createGroupPane(plot, areaPane, pointPane, linePane); + JPanel panel = createGroupPane(plot, areaPane, pointPane, linePane); return panel; } @@ -313,7 +323,7 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { JPanel panel; if (ComparatorUtils.equals(plot.getClass(), VanChartDrillMapPlot.class)) { panel = createDrillMapCustomGroupPane(areaPane, pointPane); - }else { + } else { panel = createMapCustomGroupPane(areaPane, pointPane, linePane); } return panel; @@ -334,7 +344,7 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { public void stateChanged(ChangeEvent e) { if (areaPointAndLineGroup.getSelectedIndex() == 0) { cardLayout.show(centerPane, AREA_STRING); - } else if (areaPointAndLineGroup.getSelectedIndex() == 1){ + } else if (areaPointAndLineGroup.getSelectedIndex() == 1) { cardLayout.show(centerPane, POINT_STRING); } else { cardLayout.show(centerPane, LINE_STRING); @@ -375,14 +385,15 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { } public void populateBean(Plot plot) { - if(plot != null && plot instanceof VanChartMapPlot){ - if(markerTypeCom != null){ + if (plot != null && plot instanceof VanChartMapPlot) { + if (markerTypeCom != null) { markerTypeCom.setSelectedItem(((VanChartMapPlot) plot).getMapMarkerType().toLocalString()); } - if(nullValueColorBox != null){ + if (nullValueColorBox != null) { nullValueColorBox.setSelectObject(((VanChartMapPlot) plot).getNullValueColor()); } - if(lineMapLargeDataModelGroup != null){ + //大数据模式 恢复用注释。下面3行删除。 + if (lineMapLargeDataModelGroup != null) { lineMapLargeDataModelGroup.setSelectedItem(((VanChartMapPlot) plot).getLineMapDataProcessor()); } } @@ -390,21 +401,22 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { } public void updateBean(Plot plot) { - if(plot != null && plot instanceof VanChartMapPlot){ - if(markerTypeCom != null){ + if (plot != null && plot instanceof VanChartMapPlot) { + if (markerTypeCom != null) { ((VanChartMapPlot) plot).setMapMarkerType(MapMarkerType.parseInt(markerTypeCom.getSelectedIndex())); } - if(nullValueColorBox != null){ + if (nullValueColorBox != null) { ((VanChartMapPlot) plot).setNullValueColor(nullValueColorBox.getSelectObject()); } - if(lineMapLargeDataModelGroup != null){ + //大数据模式 恢复用注释。下面3行删除。 + if (lineMapLargeDataModelGroup != null) { ((VanChartMapPlot) plot).setLineMapDataProcessor(lineMapLargeDataModelGroup.getSelectedItem()); } } super.updateBean(plot); } - @Override + @Override protected void populateCondition(ConditionAttr defaultAttr) { switch (mapType) { case AREA: @@ -427,50 +439,50 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { protected void populateArea(ConditionAttr defaultAttr) { populateAlpha(defaultAttr); if (borderWithAlphaPane != null) { - AttrBorderWithAlpha attrBorderWithAlpha = (AttrBorderWithAlpha) defaultAttr.getExisted(AttrBorderWithAlpha.class); + AttrBorderWithAlpha attrBorderWithAlpha = defaultAttr.getExisted(AttrBorderWithAlpha.class); borderWithAlphaPane.populate(attrBorderWithAlpha); } } private void populatePoint(ConditionAttr defaultAttr) { - if(pointAlphaPane != null){ - AttrMarkerAlpha attrAlpha = (AttrMarkerAlpha)defaultAttr.getExisted(AttrMarkerAlpha.class); + if (pointAlphaPane != null) { + AttrMarkerAlpha attrAlpha = defaultAttr.getExisted(AttrMarkerAlpha.class); double alpha = VanChartAttrHelper.PERCENT * (attrAlpha == null ? 1 : attrAlpha.getAlpha()); pointAlphaPane.populateBean(alpha); } - if(pointEffectPane != null){ + if (pointEffectPane != null) { AttrEffect attrEffect = defaultAttr.getExisted(AttrEffect.class); - if(attrEffect == null){//老的模板做界面上的兼容 + if (attrEffect == null) {//老的模板做界面上的兼容 attrEffect = new AttrEffect(3.2); attrEffect.setEnabled(false); } pointEffectPane.populateBean(attrEffect); } - VanChartAttrMarker attrMarker = (VanChartAttrMarker) defaultAttr.getExisted(VanChartAttrMarker.class); - if(commonMarkerPane != null) { + VanChartAttrMarker attrMarker = defaultAttr.getExisted(VanChartAttrMarker.class); + if (commonMarkerPane != null) { commonMarkerPane.populateBean(attrMarker); } - if(imageMarkerPane != null) { + if (imageMarkerPane != null) { imageMarkerPane.populateBean(attrMarker); } - if(bubblePane != null) { - VanChartAttrBubble attrBubble = (VanChartAttrBubble) defaultAttr.getExisted(VanChartAttrBubble.class); + if (bubblePane != null) { + VanChartAttrBubble attrBubble = defaultAttr.getExisted(VanChartAttrBubble.class); bubblePane.populateBean(attrBubble); } } private void populateLine(ConditionAttr defaultAttr) { - if (curvePane != null){ - if (defaultAttr.getExisted(AttrCurve.class) == null){ + if (curvePane != null) { + if (defaultAttr.getExisted(AttrCurve.class) == null) { defaultAttr.addDataSeriesCondition(new AttrCurve()); } - curvePane.populateBean((AttrCurve) defaultAttr.getExisted(AttrCurve.class)); + curvePane.populateBean(defaultAttr.getExisted(AttrCurve.class)); } - if (lineMapEffectPane != null){ - if (defaultAttr.getExisted(AttrLineEffect.class) == null){ + if (lineMapEffectPane != null) { + if (defaultAttr.getExisted(AttrLineEffect.class) == null) { defaultAttr.addDataSeriesCondition(new AttrLineEffect()); } AttrLineEffect attrLineEffect = defaultAttr.getExisted(AttrLineEffect.class); @@ -498,40 +510,40 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { } } - protected void checkoutMapType(Plot plot){ - this.mapType = ((VanChartMapPlot)plot).getMapType(); + protected void checkoutMapType(Plot plot) { + this.mapType = ((VanChartMapPlot) plot).getMapType(); } protected void updateArea(ConditionAttr defaultAttr) { updateAlpha(defaultAttr); if (borderWithAlphaPane != null) { - AttrBorderWithAlpha attrBorderWithAlpha = (AttrBorderWithAlpha) defaultAttr.getExisted(AttrBorderWithAlpha.class); + AttrBorderWithAlpha attrBorderWithAlpha = defaultAttr.getExisted(AttrBorderWithAlpha.class); defaultAttr.remove(attrBorderWithAlpha); defaultAttr.addDataSeriesCondition(borderWithAlphaPane.update()); } } private void updatePoint(ConditionAttr defaultAttr) { - if(pointAlphaPane != null){ - AttrMarkerAlpha attrAlpha = (AttrMarkerAlpha)defaultAttr.getExisted(AttrMarkerAlpha.class); - if(attrAlpha == null){ + if (pointAlphaPane != null) { + AttrMarkerAlpha attrAlpha = defaultAttr.getExisted(AttrMarkerAlpha.class); + if (attrAlpha == null) { attrAlpha = new AttrMarkerAlpha(); defaultAttr.addDataSeriesCondition(attrAlpha); } - attrAlpha.setAlpha((float)(pointAlphaPane.updateBean()/VanChartAttrHelper.PERCENT)); + attrAlpha.setAlpha((float) (pointAlphaPane.updateBean() / VanChartAttrHelper.PERCENT)); } - if(pointEffectPane != null){ + if (pointEffectPane != null) { AttrEffect attrEffect = defaultAttr.getExisted(AttrEffect.class); defaultAttr.remove(attrEffect); defaultAttr.addDataSeriesCondition(pointEffectPane.updateBean()); } - VanChartAttrMarker attrMarker = (VanChartAttrMarker) defaultAttr.getExisted(VanChartAttrMarker.class); + VanChartAttrMarker attrMarker = defaultAttr.getExisted(VanChartAttrMarker.class); defaultAttr.remove(attrMarker); - VanChartAttrBubble attrBubble = (VanChartAttrBubble) defaultAttr.getExisted(VanChartAttrBubble.class); + VanChartAttrBubble attrBubble = defaultAttr.getExisted(VanChartAttrBubble.class); defaultAttr.remove(attrBubble); - if(markerTypeCom != null) { + if (markerTypeCom != null) { if (markerTypeCom.getSelectedIndex() == 1) { defaultAttr.addDataSeriesCondition(commonMarkerPane.updateBean()); } else if (markerTypeCom.getSelectedIndex() == 2) { @@ -543,17 +555,17 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { } private void updateLine(ConditionAttr defaultAttr) { - if(curvePane != null){ + if (curvePane != null) { AttrCurve attrCurve = defaultAttr.getExisted(AttrCurve.class); - if(attrCurve != null){ + if (attrCurve != null) { defaultAttr.remove(AttrCurve.class); } attrCurve = curvePane.updateBean(); defaultAttr.addDataSeriesCondition(attrCurve); } - if (lineMapEffectPane != null){ + if (lineMapEffectPane != null) { AttrLineEffect attrLineEffect = defaultAttr.getExisted(AttrLineEffect.class); - if (attrLineEffect != null){ + if (attrLineEffect != null) { defaultAttr.remove(AttrLineEffect.class); } attrLineEffect = (AttrLineEffect) lineMapEffectPane.updateBean(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/MapIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/map/VanMapChartTypeUI.java similarity index 81% rename from designer-chart/src/main/java/com/fr/van/chart/map/MapIndependentVanChartInterface.java rename to designer-chart/src/main/java/com/fr/van/chart/map/VanMapChartTypeUI.java index 76deff2d3f..50636ad28f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/MapIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/VanMapChartTypeUI.java @@ -21,6 +21,7 @@ import com.fr.van.chart.map.designer.data.contentpane.report.VanLineMapPlotRepor import com.fr.van.chart.map.designer.data.contentpane.report.VanPointMapPlotReportDataContentPane; import com.fr.van.chart.map.designer.data.contentpane.table.VanAreaMapPlotTableDataContentPane; import com.fr.van.chart.map.designer.data.contentpane.table.VanLineMapPlotTableDataContentPane; +import com.fr.van.chart.map.designer.data.contentpane.table.VanMapTableDataContentPane; import com.fr.van.chart.map.designer.data.contentpane.table.VanPointMapPlotTableDataContentPane; import com.fr.van.chart.map.designer.other.VanChartMapOtherPane; import com.fr.van.chart.map.designer.other.condition.pane.VanChartMapConditionPane; @@ -31,7 +32,7 @@ import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; /** * Created by Mitisky on 16/5/4. */ -public class MapIndependentVanChartInterface extends AbstractIndependentVanChartUI { +public class VanMapChartTypeUI extends AbstractIndependentVanChartUI { @Override public String getName() { @@ -70,27 +71,36 @@ public class MapIndependentVanChartInterface extends AbstractIndependentVanChart return new VanChartMapPlotPane(); } - public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent){ - return areaPlot(plot) ? new VanAreaMapPlotTableDataContentPane(parent) +//图表数据结构 恢复用注释。取消注释。 +// public ChartDataPane getChartDataPane(AttributeChangeListener listener){ +// return new MapChartDataPane(listener); +// } + + //图表数据结构 恢复用注释。删除下面5个方法 getTableDataSourcePane getReportDataSourcePane getChartDataPane areaPlot linePlot。 + public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { + VanMapTableDataContentPane vanMapTableDataContentPane = areaPlot(plot) ? new VanAreaMapPlotTableDataContentPane(parent) : linePlot(plot) ? new VanLineMapPlotTableDataContentPane(parent) - : new VanPointMapPlotTableDataContentPane(parent); + : new VanPointMapPlotTableDataContentPane(parent); + + vanMapTableDataContentPane.setPlot((VanChartMapPlot)plot); + return vanMapTableDataContentPane; } - public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent){ + public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { return areaPlot(plot) ? new VanAreaMapPlotReportDataContentPane(parent) : linePlot(plot) ? new VanLineMapPlotReportDataContentPane(parent) - : new VanPointMapPlotReportDataContentPane(parent); + : new VanPointMapPlotReportDataContentPane(parent); } public ChartDataPane getChartDataPane(AttributeChangeListener listener){ return new VanChartMapDataPane(listener); } - protected boolean areaPlot(Plot plot){ + protected boolean areaPlot(Plot plot) { return plot != null && plot instanceof VanChartMapPlot && ((VanChartMapPlot) plot).getMapType() == MapType.AREA; } - protected boolean linePlot(Plot plot){ + protected boolean linePlot(Plot plot) { return plot != null && plot instanceof VanChartMapPlot && ((VanChartMapPlot) plot).getMapType() == MapType.LINE; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/VanChartGroupPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/VanChartGroupPane.java index d086a70314..bc84b001d9 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/VanChartGroupPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/VanChartGroupPane.java @@ -35,6 +35,7 @@ public abstract class VanChartGroupPane extends JPanel{ @Override public void stateChanged(ChangeEvent e) { cardLayout.show(centerPane, nameList[buttonGroup.getSelectedIndex()]); + tabChanged(buttonGroup.getSelectedIndex()); } }); buttonGroup.setBorder(getButtonGroupBorder()); @@ -43,6 +44,9 @@ public abstract class VanChartGroupPane extends JPanel{ this.add(centerPane, BorderLayout.CENTER); } + protected void tabChanged(int index) { + } + protected Border getButtonGroupBorder () { return null; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/CustomMapChartDataContentsPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/CustomMapChartDataContentsPane.java index 4cfb35d704..ef9dd00d51 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/CustomMapChartDataContentsPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/CustomMapChartDataContentsPane.java @@ -12,7 +12,7 @@ import javax.swing.JPanel; /** * Created by Mitisky on 16/5/17. */ -public class CustomMapChartDataContentsPane extends DataContentsPane{ +public class CustomMapChartDataContentsPane extends DataContentsPane { private NormalChartDataPane areaMapChartDataPane; private NormalChartDataPane pointMapChartDataPane; private NormalChartDataPane lineMapChartDataPane; diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/MapDataPaneHelper.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/MapDataPaneHelper.java index 158f9dbf1b..3c4f6f976a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/MapDataPaneHelper.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/MapDataPaneHelper.java @@ -18,42 +18,42 @@ import java.util.List; */ public class MapDataPaneHelper { public static ChartCollection getPointMapChartCollection(ChartCollection chartCollection) { - try{ + try { ChartCollection cloneCollection = (ChartCollection) chartCollection.clone(); Chart chart = cloneCollection.getSelectedChart(); TopDefinitionProvider definition = chart.getFilterDefinition(); - if(definition != null && definition instanceof VanMapDefinition) { + if (definition != null && definition instanceof VanMapDefinition) { chart.setFilterDefinition(((VanMapDefinition) definition).getPointDefinition()); } Plot plot = chart.getPlot(); - if(plot != null && plot instanceof VanChartMapPlot){ + if (plot != null && plot instanceof VanChartMapPlot) { ((VanChartMapPlot) plot).setMapType(MapType.POINT); } return cloneCollection; - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return chartCollection; } } public static ChartCollection getLineMapChartCollection(ChartCollection chartCollection) { - try{ + try { ChartCollection cloneCollection = (ChartCollection) chartCollection.clone(); Chart chart = cloneCollection.getSelectedChart(); TopDefinitionProvider definition = chart.getFilterDefinition(); - if(definition != null && definition instanceof VanMapDefinition) { + if (definition != null && definition instanceof VanMapDefinition) { chart.setFilterDefinition(((VanMapDefinition) definition).getLineDefinition()); } Plot plot = chart.getPlot(); - if(plot != null && plot instanceof VanChartMapPlot){ + if (plot != null && plot instanceof VanChartMapPlot) { ((VanChartMapPlot) plot).setMapType(MapType.LINE); } return cloneCollection; - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return chartCollection; } @@ -61,71 +61,71 @@ public class MapDataPaneHelper { public static ChartCollection getAreaMapChartCollection(ChartCollection chartCollection) { - try{ + try { ChartCollection cloneCollection = (ChartCollection) chartCollection.clone(); Chart chart = cloneCollection.getSelectedChart(); TopDefinitionProvider definition = chart.getFilterDefinition(); - if(definition != null && definition instanceof VanMapDefinition) { + if (definition != null && definition instanceof VanMapDefinition) { chart.setFilterDefinition(((VanMapDefinition) definition).getAreaDefinition()); } Plot plot = chart.getPlot(); - if(plot != null && plot instanceof VanChartMapPlot){ + if (plot != null && plot instanceof VanChartMapPlot) { ((VanChartMapPlot) plot).setMapType(MapType.AREA); } return cloneCollection; - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return chartCollection; } } public static ChartCollection getBottomDataDrillMapChartCollection(ChartCollection chartCollection) { - try{ + try { ChartCollection cloneCollection = (ChartCollection) chartCollection.clone(); Chart chart = cloneCollection.getSelectedChart(); TopDefinitionProvider definition = chart.getFilterDefinition(); - if(definition != null && definition instanceof DrillMapDefinition) { + if (definition != null && definition instanceof DrillMapDefinition) { chart.setFilterDefinition(((DrillMapDefinition) definition).getBottomDataDefinition()); } Plot plot = chart.getPlot(); - if(plot != null && plot instanceof VanChartDrillMapPlot){ + if (plot != null && plot instanceof VanChartDrillMapPlot) { List list = ((VanChartDrillMapPlot) plot).getLayerMapTypeList(); MapType mapType = (list != null && list.size() > 0) ? list.get(list.size() - 1) : MapType.AREA; ((VanChartMapPlot) plot).setMapType(mapType); } return cloneCollection; - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return chartCollection; } } - public static ChartCollection getLayerChartCollection(ChartCollection chartCollection, int level, MapType mapType){ - if(mapType == null){ + public static ChartCollection getLayerChartCollection(ChartCollection chartCollection, int level, MapType mapType) { + if (mapType == null) { mapType = MapType.AREA; } - try{ + try { ChartCollection cloneCollection = (ChartCollection) chartCollection.clone(); Chart chart = cloneCollection.getSelectedChart(); TopDefinitionProvider definition = chart.getFilterDefinition(); - if(definition != null && definition instanceof DrillMapDefinition) { + if (definition != null && definition instanceof DrillMapDefinition) { List list = ((DrillMapDefinition) definition).getEachLayerDataDefinitionList(); - if(list.size() > level){ + if (list.size() > level) { chart.setFilterDefinition(list.get(level)); } } Plot plot = chart.getPlot(); - if(plot != null && plot instanceof VanChartMapPlot){ + if (plot != null && plot instanceof VanChartMapPlot) { ((VanChartMapPlot) plot).setMapType(mapType); } return cloneCollection; - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return chartCollection; } @@ -138,11 +138,11 @@ public class MapDataPaneHelper { } public static DrillMapDefinition getDrillMapDefinition(ChartCollection chartCollection) { - if(chartCollection != null){ + if (chartCollection != null) { Chart chart = chartCollection.getSelectedChart(); - if(chart != null){ + if (chart != null) { TopDefinitionProvider definitionProvider = chart.getFilterDefinition(); - if(definitionProvider instanceof DrillMapDefinition){ + if (definitionProvider instanceof DrillMapDefinition) { return (DrillMapDefinition) definitionProvider; } } @@ -151,25 +151,25 @@ public class MapDataPaneHelper { } public static List getDrillMapLayerMapTypeList(ChartCollection chartCollection) { - if(chartCollection != null){ + if (chartCollection != null) { Chart chart = chartCollection.getSelectedChart(); - if(chart != null){ + if (chart != null) { Plot plot = chart.getPlot(); - if(plot instanceof VanChartDrillMapPlot){ - return((VanChartDrillMapPlot) plot).getLayerMapTypeList(); + if (plot instanceof VanChartDrillMapPlot) { + return ((VanChartDrillMapPlot) plot).getLayerMapTypeList(); } } } return null; } - public static MapType getPlotMapType(ChartCollection chartCollection){ + public static MapType getPlotMapType(ChartCollection chartCollection) { Plot plot = chartCollection.getSelectedChart().getPlot(); return getPlotMapType(plot); } - public static MapType getPlotMapType(Plot plot){ - if(plot != null && plot instanceof VanChartMapPlot){ + public static MapType getPlotMapType(Plot plot) { + if (plot != null && plot instanceof VanChartMapPlot) { return ((VanChartMapPlot) plot).getMapType(); } return MapType.AREA; diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/VanChartMapDataPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/VanChartMapDataPane.java index 5ebe14ed0a..a6fdd49ce6 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/VanChartMapDataPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/VanChartMapDataPane.java @@ -27,12 +27,12 @@ public class VanChartMapDataPane extends ChartDataPane { } protected void repeatLayout(ChartCollection collection) { - if(contentsPane != null) { + if (contentsPane != null) { this.remove(contentsPane); } this.setLayout(new BorderLayout(0, 0)); - switch (mapType){ + switch (mapType) { case CUSTOM: contentsPane = new CustomMapChartDataContentsPane(listener, VanChartMapDataPane.this); break; @@ -54,7 +54,7 @@ public class VanChartMapDataPane extends ChartDataPane { repeatLayout(collection); - switch (mapType){ + switch (mapType) { case AREA: ChartCollection areaClone = MapDataPaneHelper.getAreaMapChartCollection(collection); contentsPane.populate(areaClone); @@ -71,8 +71,8 @@ public class VanChartMapDataPane extends ChartDataPane { ChartCollection areaClone1 = MapDataPaneHelper.getAreaMapChartCollection(collection); ChartCollection pointClone1 = MapDataPaneHelper.getPointMapChartCollection(collection); ChartCollection lineClone1 = MapDataPaneHelper.getLineMapChartCollection(collection); - ((CustomMapChartDataContentsPane)contentsPane).populateAreaMap(areaClone1); - ((CustomMapChartDataContentsPane)contentsPane).populatePointMap(pointClone1); + ((CustomMapChartDataContentsPane) contentsPane).populateAreaMap(areaClone1); + ((CustomMapChartDataContentsPane) contentsPane).populatePointMap(pointClone1); ((CustomMapChartDataContentsPane) contentsPane).populateLineMap(lineClone1); } @@ -82,14 +82,14 @@ public class VanChartMapDataPane extends ChartDataPane { * 保存 数据界面内容 */ public void update(ChartCollection collection) { - if(contentsPane != null) { + if (contentsPane != null) { VanMapDefinition vanMapDefinition = new VanMapDefinition(); ChartCollection pointClone = MapDataPaneHelper.getPointMapChartCollection(collection); ChartCollection areaClone = MapDataPaneHelper.getAreaMapChartCollection(collection); ChartCollection lineClone = MapDataPaneHelper.getLineMapChartCollection(collection); - switch (mapType){ + switch (mapType) { case AREA: contentsPane.update(areaClone); pointClone.getSelectedChart().setFilterDefinition(null); @@ -106,8 +106,8 @@ public class VanChartMapDataPane extends ChartDataPane { pointClone.getSelectedChart().setFilterDefinition(null); break; case CUSTOM: - ((CustomMapChartDataContentsPane)contentsPane).updateAreaMap(areaClone); - ((CustomMapChartDataContentsPane)contentsPane).updatePointMap(pointClone); + ((CustomMapChartDataContentsPane) contentsPane).updateAreaMap(areaClone); + ((CustomMapChartDataContentsPane) contentsPane).updatePointMap(pointClone); ((CustomMapChartDataContentsPane) contentsPane).updateLineMap(lineClone); break; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/AbstractLongLatAreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/AbstractLongLatAreaPane.java index 2415e99bc8..abf098dded 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/AbstractLongLatAreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/AbstractLongLatAreaPane.java @@ -9,5 +9,6 @@ import javax.swing.JPanel; */ public abstract class AbstractLongLatAreaPane extends JPanel { public abstract void populate(VanMapReportDefinition vanMapReportDefinition); + public abstract void update(VanMapReportDefinition vanMapReportDefinition); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/AreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/AreaPane.java index 8517e64fb8..dc5df28f30 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/AreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/AreaPane.java @@ -6,7 +6,6 @@ import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; - import com.fr.van.chart.map.designer.data.component.LongitudeLatitudeAndArea; import javax.swing.JPanel; @@ -31,12 +30,12 @@ public class AreaPane extends AbstractReportDataContentPane { double f = TableLayout.FILL; double[] columnSize = {f, COMPONENT_WIDTH}; double[] rowSize = {p}; - Component[][] components = getComponent (); - return TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); + Component[][] components = getComponent(); + return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } - protected Component[][] getComponent () { - return new Component[][]{ + protected Component[][] getComponent() { + return new Component[][]{ new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Name")), areaName} }; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/LineMapAreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/LineMapAreaPane.java index 79a4a433ca..0f7e047e9b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/LineMapAreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/LineMapAreaPane.java @@ -1,7 +1,6 @@ package com.fr.van.chart.map.designer.data.component.report; import com.fr.design.gui.ilable.BoldFontTextLabel; - import com.fr.plugin.chart.map.data.VanMapReportDefinition; import com.fr.van.chart.map.designer.data.component.LongitudeLatitudeAndArea; @@ -27,18 +26,19 @@ public class LineMapAreaPane extends PointMapAreaPane { } protected void initEndAreaPane() { - endAreaPane = new AreaPane(){ - protected Component[][] getComponent () { + endAreaPane = new AreaPane() { + protected Component[][] getComponent() { return new Component[][]{ new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_End_Area_Name")), areaName} }; } }; } + @Override protected void initAreaPane() { - areaPane =new AreaPane(){ - protected Component[][] getComponent () { + areaPane = new AreaPane() { + protected Component[][] getComponent() { return new Component[][]{ new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Start_Area_Name")), areaName} }; diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/LineMapLongLatAreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/LineMapLongLatAreaPane.java index f8fc771828..1fd653dc70 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/LineMapLongLatAreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/LineMapLongLatAreaPane.java @@ -3,7 +3,6 @@ package com.fr.van.chart.map.designer.data.component.report; import com.fr.design.gui.ilable.BoldFontTextLabel; - import java.awt.Component; /** @@ -12,8 +11,8 @@ import java.awt.Component; public class LineMapLongLatAreaPane extends LineMapAreaPane { protected void initEndAreaPane() { - endAreaPane = new LongLatAreaPane(){ - protected Component[][] getComponent () { + endAreaPane = new LongLatAreaPane() { + protected Component[][] getComponent() { return new Component[][]{ new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_End_Longitude")), longitude}, new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_End_Latitude")), latitude}, @@ -24,8 +23,8 @@ public class LineMapLongLatAreaPane extends LineMapAreaPane { } protected void initAreaPane() { - areaPane = new LongLatAreaPane(){ - protected Component[][] getComponent () { + areaPane = new LongLatAreaPane() { + protected Component[][] getComponent() { return new Component[][]{ new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Start_Longitude")), longitude}, new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Start_Latitude")), latitude}, diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/LongLatAreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/LongLatAreaPane.java index f03cda28ac..af6b100661 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/LongLatAreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/LongLatAreaPane.java @@ -5,7 +5,6 @@ import com.fr.design.formula.TinyFormulaPane; import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; - import com.fr.van.chart.map.designer.data.component.LongitudeLatitudeAndArea; import javax.swing.JPanel; @@ -35,10 +34,10 @@ public class LongLatAreaPane extends AreaPane { double[] columnSize = {f, COMPONENT_WIDTH}; double[] rowSize = {p, p, p}; Component[][] components = getComponent(); - return TableLayoutHelper.createGapTableLayoutPane(components,rowSize,columnSize,12,6); + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 12, 6); } - protected Component[][] getComponent () { + protected Component[][] getComponent() { return new Component[][]{ new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Longitude")), longitude}, new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Latitude")), latitude}, @@ -62,7 +61,7 @@ public class LongLatAreaPane extends AreaPane { if (longLatArea.getLongitude() != null) { longitude.getUITextField().setText(longLatArea.getLongitude().toString()); } - if (longLatArea.getLatitude() != null){ + if (longLatArea.getLatitude() != null) { latitude.getUITextField().setText(longLatArea.getLatitude().toString()); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/PointMapAreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/PointMapAreaPane.java index 29cb4930a9..f47e2623ac 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/PointMapAreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/report/PointMapAreaPane.java @@ -28,6 +28,7 @@ public class PointMapAreaPane extends AbstractLongLatAreaPane { protected void initAreaPane() { areaPane = new AreaPane(); } + @Override public void populate(VanMapReportDefinition vanMapReportDefinition) { LongitudeLatitudeAndArea longLatArea = new LongitudeLatitudeAndArea(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/AbstractLongLatAreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/AbstractLongLatAreaPane.java index 585b42de1c..9d2603f136 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/AbstractLongLatAreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/AbstractLongLatAreaPane.java @@ -8,7 +8,7 @@ import java.util.List; /** * Created by hufan on 2016/12/21. */ -public abstract class AbstractLongLatAreaPane extends JPanel{ +public abstract class AbstractLongLatAreaPane extends JPanel { public abstract boolean isSelectedItem(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/AreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/AreaPane.java index d765ed425f..d7934dc294 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/AreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/AreaPane.java @@ -6,7 +6,6 @@ import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; - import com.fr.van.chart.map.designer.data.component.LongitudeLatitudeAndArea; import com.fr.van.chart.map.designer.data.contentpane.table.VanPointMapPlotTableDataContentPane; @@ -23,6 +22,7 @@ import java.util.List; public class AreaPane extends AbstractTableDataContentPane { protected VanPointMapPlotTableDataContentPane.LongLatAreaTableComboPane listener; protected UIComboBox areaNameCom; + public AreaPane(VanPointMapPlotTableDataContentPane.LongLatAreaTableComboPane parentPane) { this.listener = parentPane; this.setLayout(new BorderLayout()); @@ -47,10 +47,10 @@ public class AreaPane extends AbstractTableDataContentPane { double[] columnSize = {f, COMPONENT_WIDTH}; double[] rowSize = {p}; Component[][] components = getComponent(); - return TableLayoutHelper.createGapTableLayoutPane(components,rowSize,columnSize,12,6); + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 12, 6); } - protected Component[][] getComponent () { + protected Component[][] getComponent() { return new Component[][]{ new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Name")), areaNameCom} }; @@ -86,7 +86,7 @@ public class AreaPane extends AbstractTableDataContentPane { } public void populate(LongitudeLatitudeAndArea longLatArea) { - if (longLatArea.getArea() != null){ + if (longLatArea.getArea() != null) { areaNameCom.setSelectedItem(longLatArea.getArea()); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/LineMapAreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/LineMapAreaPane.java index 4d2f2d86ce..200ae1e513 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/LineMapAreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/LineMapAreaPane.java @@ -1,7 +1,6 @@ package com.fr.van.chart.map.designer.data.component.table; import com.fr.design.gui.ilable.BoldFontTextLabel; - import com.fr.plugin.chart.map.data.VanMapTableDefinitionProvider; import com.fr.van.chart.map.designer.data.component.LongitudeLatitudeAndArea; import com.fr.van.chart.map.designer.data.contentpane.table.VanPointMapPlotTableDataContentPane; @@ -18,6 +17,7 @@ import java.util.List; public class LineMapAreaPane extends PointMapAreaPane { private static final int V_GAP = 10; protected AreaPane endAreaPane; + public LineMapAreaPane(VanPointMapPlotTableDataContentPane.LongLatAreaTableComboPane parentPane) { super(parentPane); } @@ -33,8 +33,8 @@ public class LineMapAreaPane extends PointMapAreaPane { } protected void initAreaPane(VanPointMapPlotTableDataContentPane.LongLatAreaTableComboPane parentPane) { - areaPane = new AreaPane(parentPane){ - protected Component[][] getComponent () { + areaPane = new AreaPane(parentPane) { + protected Component[][] getComponent() { return new Component[][]{ new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Start_Area_Name")), areaNameCom} }; @@ -43,8 +43,8 @@ public class LineMapAreaPane extends PointMapAreaPane { } protected void initEndAreaPane(VanPointMapPlotTableDataContentPane.LongLatAreaTableComboPane parentPane) { - endAreaPane = new AreaPane(parentPane){ - protected Component[][] getComponent () { + endAreaPane = new AreaPane(parentPane) { + protected Component[][] getComponent() { return new Component[][]{ new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_End_Area_Name")), areaNameCom} }; diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/LineMapLongLatAreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/LineMapLongLatAreaPane.java index bb0f7a5bbe..8e6fc3c905 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/LineMapLongLatAreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/LineMapLongLatAreaPane.java @@ -2,7 +2,6 @@ package com.fr.van.chart.map.designer.data.component.table; import com.fr.design.gui.ilable.BoldFontTextLabel; - import com.fr.van.chart.map.designer.data.contentpane.table.VanPointMapPlotTableDataContentPane; import java.awt.Component; @@ -17,8 +16,8 @@ public class LineMapLongLatAreaPane extends LineMapAreaPane { } protected void initEndAreaPane(VanPointMapPlotTableDataContentPane.LongLatAreaTableComboPane parentPane) { - endAreaPane = new LongLatAreaPane(parentPane){ - protected Component[][] getComponent () { + endAreaPane = new LongLatAreaPane(parentPane) { + protected Component[][] getComponent() { return new Component[][]{ new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_End_Longitude")), longitudeCom}, new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_End_Latitude")), latitudeCom}, @@ -29,8 +28,8 @@ public class LineMapLongLatAreaPane extends LineMapAreaPane { } protected void initAreaPane(VanPointMapPlotTableDataContentPane.LongLatAreaTableComboPane parentPane) { - areaPane = new LongLatAreaPane(parentPane){ - protected Component[][] getComponent () { + areaPane = new LongLatAreaPane(parentPane) { + protected Component[][] getComponent() { return new Component[][]{ new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Start_Longitude")), longitudeCom}, new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Start_Latitude")), latitudeCom}, diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/LongLatAreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/LongLatAreaPane.java index 68e71f7e3e..b3e3dbd114 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/LongLatAreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/component/table/LongLatAreaPane.java @@ -4,7 +4,6 @@ import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; - import com.fr.van.chart.map.designer.data.component.LongitudeLatitudeAndArea; import com.fr.van.chart.map.designer.data.contentpane.table.VanPointMapPlotTableDataContentPane; @@ -37,10 +36,10 @@ public class LongLatAreaPane extends AreaPane { double[] rowSize = {p, p, p}; Component[][] components = getComponent(); - return TableLayoutHelper.createGapTableLayoutPane(components,rowSize,columnSize,12,6); + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 12, 6); } - protected Component[][] getComponent () { + protected Component[][] getComponent() { return new Component[][]{ new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Longitude")), longitudeCom}, new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Latitude")), latitudeCom}, @@ -69,10 +68,10 @@ public class LongLatAreaPane extends AreaPane { @Override public void populate(LongitudeLatitudeAndArea longLatArea) { super.populate(longLatArea); - if(longLatArea.getLongitude() != null){ + if (longLatArea.getLongitude() != null) { longitudeCom.setSelectedItem(longLatArea.getLongitude()); } - if(longLatArea.getLatitude() != null){ + if (longLatArea.getLatitude() != null) { latitudeCom.setSelectedItem(longLatArea.getLatitude()); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/report/VanAreaMapPlotReportDataContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/report/VanAreaMapPlotReportDataContentPane.java index 3de16e047a..d19ad82df5 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/report/VanAreaMapPlotReportDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/report/VanAreaMapPlotReportDataContentPane.java @@ -7,7 +7,6 @@ import com.fr.design.formula.TinyFormulaPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; - import com.fr.plugin.chart.map.data.VanMapReportDefinition; import javax.swing.BorderFactory; @@ -26,7 +25,7 @@ public class VanAreaMapPlotReportDataContentPane extends AbstractReportDataConte initEveryPane(); initAreaName(); JPanel panel = getContent(); - panel.setBorder(BorderFactory.createEmptyBorder(0,24,0,15)); + panel.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 15)); this.add(panel, "0,0,2,0"); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/report/VanPointMapPlotReportDataContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/report/VanPointMapPlotReportDataContentPane.java index 3f82744eab..00e4d67182 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/report/VanPointMapPlotReportDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/report/VanPointMapPlotReportDataContentPane.java @@ -6,7 +6,6 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartDataPane; - import com.fr.plugin.chart.map.data.VanMapReportDefinition; import com.fr.van.chart.map.designer.data.component.report.AbstractLongLatAreaPane; import com.fr.van.chart.map.designer.data.component.report.PointMapAreaPane; @@ -67,12 +66,12 @@ public class VanPointMapPlotReportDataContentPane extends VanAreaMapPlotReportDa public LongLatReportFormulaPane() { this.setLayout(new BorderLayout(0, 5)); - centerPane = new JPanel(new CardLayout()){ + centerPane = new JPanel(new CardLayout()) { @Override public Dimension getPreferredSize() { - if (locationType.getSelectedIndex() == 0){ + if (locationType.getSelectedIndex() == 0) { return areaPane.getPreferredSize(); - }else { + } else { return longLatAreaPane.getPreferredSize(); } } @@ -99,10 +98,10 @@ public class VanPointMapPlotReportDataContentPane extends VanAreaMapPlotReportDa double[] rowSize = {p}; Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Geographic")),locationType}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Geographic")), locationType}, }; - JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components,rowSize,columnSize,12,6); + JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 12, 6); this.add(panel, BorderLayout.NORTH); @@ -114,7 +113,7 @@ public class VanPointMapPlotReportDataContentPane extends VanAreaMapPlotReportDa CardLayout cardLayout = (CardLayout) centerPane.getLayout(); if (locationType.getSelectedIndex() == 0) { cardLayout.show(centerPane, "area"); - }else { + } else { cardLayout.show(centerPane, "longLat"); } } @@ -124,7 +123,7 @@ public class VanPointMapPlotReportDataContentPane extends VanAreaMapPlotReportDa if (locationType.getSelectedIndex() == 0) { areaPane.populate(mapReportDefinition); - }else { + } else { longLatAreaPane.populate(mapReportDefinition); } @@ -137,7 +136,7 @@ public class VanPointMapPlotReportDataContentPane extends VanAreaMapPlotReportDa mapReportDefinition.setUseAreaName(useAreaName); if (useAreaName) { areaPane.update(mapReportDefinition); - }else { + } else { longLatAreaPane.update(mapReportDefinition); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanAreaMapPlotTableDataContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanAreaMapPlotTableDataContentPane.java index 331b7a843c..284320cebc 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanAreaMapPlotTableDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanAreaMapPlotTableDataContentPane.java @@ -8,26 +8,25 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartDataPane; -import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; - import com.fr.plugin.chart.map.VanChartMapPlot; +import com.fr.plugin.chart.map.data.MapMatchResult; import com.fr.plugin.chart.map.data.VanMapTableDefinitionProvider; import com.fr.van.chart.map.designer.data.component.SeriesTypeUseComboxPaneWithOutFilter; import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.JSeparator; +import java.util.List; 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; /** * Created by Mitisky on 16/5/16. */ -public class VanAreaMapPlotTableDataContentPane extends AbstractTableDataContentPane { +public class VanAreaMapPlotTableDataContentPane extends VanMapTableDataContentPane { private UIComboBox areaNameCom; protected SeriesTypeUseComboxPaneWithOutFilter seriesTypeUseComboxPane; @@ -39,8 +38,8 @@ public class VanAreaMapPlotTableDataContentPane extends AbstractTableDataContent JPanel areaNamePane = createAreaNamePane(); JSeparator jSeparator = new JSeparator(); - areaNamePane.setBorder(BorderFactory.createEmptyBorder(0,24,0,15)); - jSeparator.setPreferredSize(new Dimension(246,2)); + areaNamePane.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 15)); + jSeparator.setPreferredSize(new Dimension(246, 2)); this.add(areaNamePane, BorderLayout.NORTH); this.add(jSeparator, BorderLayout.CENTER); @@ -73,7 +72,7 @@ public class VanAreaMapPlotTableDataContentPane extends AbstractTableDataContent double[] rowSize = {p}; Component[][] components = new Component[][]{ - new Component[]{label, areaNameCom}, + new Component[]{label, createAreaPanel(areaNameCom)}, }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); @@ -108,7 +107,7 @@ public class VanAreaMapPlotTableDataContentPane extends AbstractTableDataContent } } - protected boolean isAreaSelectedItem(){ + protected boolean isAreaSelectedItem() { return areaNameCom.getSelectedItem() != null; } @@ -139,13 +138,14 @@ public class VanAreaMapPlotTableDataContentPane extends AbstractTableDataContent public void updateBean(ChartCollection collection) { seriesTypeUseComboxPane.updateBean(collection); TopDefinitionProvider topDefinitionProvider = collection.getSelectedChart().getFilterDefinition(); - if(topDefinitionProvider instanceof VanMapTableDefinitionProvider){ - VanMapTableDefinitionProvider mapTableDefinitionProvider = (VanMapTableDefinitionProvider)topDefinitionProvider; + if (topDefinitionProvider instanceof VanMapTableDefinitionProvider) { + VanMapTableDefinitionProvider mapTableDefinitionProvider = (VanMapTableDefinitionProvider) topDefinitionProvider; + mapTableDefinitionProvider.setMatchResult((MapMatchResult) this.getMatchResult().clone()); updateDefinition(mapTableDefinitionProvider); } } - protected void updateDefinition(VanMapTableDefinitionProvider mapTableDefinitionProvider){ + protected void updateDefinition(VanMapTableDefinitionProvider mapTableDefinitionProvider) { Object o = areaNameCom.getSelectedItem(); mapTableDefinitionProvider.setCategoryName(o == null ? null : o.toString()); } @@ -156,13 +156,14 @@ public class VanAreaMapPlotTableDataContentPane extends AbstractTableDataContent public void populateBean(ChartCollection collection) { seriesTypeUseComboxPane.populateBean(collection, this.isNeedSummaryCaculateMethod()); TopDefinitionProvider topDefinitionProvider = collection.getSelectedChart().getFilterDefinition(); - if(topDefinitionProvider instanceof VanMapTableDefinitionProvider){ - VanMapTableDefinitionProvider mapTableDefinitionProvider = (VanMapTableDefinitionProvider)topDefinitionProvider; + if (topDefinitionProvider instanceof VanMapTableDefinitionProvider) { + VanMapTableDefinitionProvider mapTableDefinitionProvider = (VanMapTableDefinitionProvider) topDefinitionProvider; + this.setMatchResult((MapMatchResult) mapTableDefinitionProvider.getMatchResult().clone()); populateDefinition(mapTableDefinitionProvider); } } - protected void populateDefinition(VanMapTableDefinitionProvider mapTableDefinitionProvider){ + protected void populateDefinition(VanMapTableDefinitionProvider mapTableDefinitionProvider) { if (mapTableDefinitionProvider.getCategoryName() != null) { areaNameCom.setSelectedItem(mapTableDefinitionProvider.getCategoryName()); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanLineMapPlotTableDataContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanLineMapPlotTableDataContentPane.java index de2b9ded6a..141b2eb2e0 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanLineMapPlotTableDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanLineMapPlotTableDataContentPane.java @@ -1,22 +1,49 @@ package com.fr.van.chart.map.designer.data.contentpane.table; +import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.van.chart.map.designer.data.component.table.AbstractLongLatAreaPane; +import com.fr.van.chart.map.designer.data.component.table.AreaPane; import com.fr.van.chart.map.designer.data.component.table.LineMapAreaPane; import com.fr.van.chart.map.designer.data.component.table.LineMapLongLatAreaPane; +import java.awt.Component; + /** * Created by hufan on 2016/12/15. */ -public class VanLineMapPlotTableDataContentPane extends VanPointMapPlotTableDataContentPane{ +public class VanLineMapPlotTableDataContentPane extends VanPointMapPlotTableDataContentPane { public VanLineMapPlotTableDataContentPane(ChartDataPane parent) { super(parent); } protected AbstractLongLatAreaPane createAreaPane(LongLatAreaTableComboPane longLatAreaTableComboPane) { - return new LineMapAreaPane(longLatAreaTableComboPane); + return new LineMapAreaPane(longLatAreaTableComboPane) { + @Override + protected void initAreaPane(VanPointMapPlotTableDataContentPane.LongLatAreaTableComboPane parentPane) { + areaPane = new AreaPane(parentPane) { + @Override + protected Component[][] getComponent () { + return new Component[][]{ + new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Start_Area_Name")), VanLineMapPlotTableDataContentPane.this.createAreaPanel(areaNameCom)} + }; + } + }; + } + @Override + protected void initEndAreaPane(VanPointMapPlotTableDataContentPane.LongLatAreaTableComboPane parentPane) { + endAreaPane = new AreaPane(parentPane) { + @Override + protected Component[][] getComponent () { + return new Component[][]{ + new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_End_Area_Name")), VanLineMapPlotTableDataContentPane.this.createAreaPanel(areaNameCom)} + }; + } + }; + } + }; } protected AbstractLongLatAreaPane createLongLatAreaPane(LongLatAreaTableComboPane longLatAreaTableComboPane) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanMapTableDataContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanMapTableDataContentPane.java new file mode 100644 index 0000000000..09d72a72e6 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanMapTableDataContentPane.java @@ -0,0 +1,137 @@ +package com.fr.van.chart.map.designer.data.contentpane.table; + +import com.fr.base.BaseUtils; +import com.fr.base.Utils; +import com.fr.chartx.TwoTuple; +import com.fr.design.chartx.component.MapAreaMatchPane; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionListener; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; +import com.fr.plugin.chart.map.VanChartMapPlot; +import com.fr.plugin.chart.map.data.MapMatchResult; +import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.tree.DefaultMutableTreeNode; +import java.util.Set; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2019-12-25 + */ +public abstract class VanMapTableDataContentPane extends AbstractTableDataContentPane { + + private VanChartMapPlot plot; + + //钻取地图有层级,默认-1代表无层级关系 + private int level = ChartGEOJSONHelper.DEFAULT_LEVEL; + + private MapMatchResult matchResult = new MapMatchResult(); + + public void setLevel(int level) { + this.level = level; + } + + public void setPlot(VanChartMapPlot plot) { + this.plot = plot; + } + + public MapMatchResult getMatchResult() { + return matchResult; + } + + public void setMatchResult(MapMatchResult matchResult) { + this.matchResult = matchResult; + } + + public JPanel createAreaPanel(UIComboBox areaBox) { + JPanel areaPanel = new JPanel(new BorderLayout(4, 0)); + areaBox.setPreferredSize(new Dimension(70, 20)); + areaPanel.add(areaBox, BorderLayout.CENTER); + UIButton uiButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/config.png")); + uiButton.addActionListener(createActionListener(areaBox)); + areaPanel.add(uiButton, BorderLayout.EAST); + return areaPanel; + } + + private ActionListener createActionListener(final UIComboBox areaBox){ + return new ActionListener() { + private TwoTuple> treeNodeAndItems; + + @Override + public void actionPerformed(ActionEvent e) { + if (treeNodeAndItems == null) { + treeNodeAndItems = ChartGEOJSONHelper.getTreeNodeAndItems(plot.getGeoUrl(), level, plot.getMapType()); + } + final MapAreaMatchPane pane = new MapAreaMatchPane(treeNodeAndItems); + + final String nameTable = getTableName(); + + BasicDialog dialog = pane.showWindow(new JFrame()); + dialog.addDialogActionListener(new DialogActionListener() { + @Override + public void doOk() { + pane.updateBean(matchResult); + } + + @Override + public void doCancel() { + + } + }); + dialog.addWindowListener(new WindowListener() { + @Override + public void windowOpened(WindowEvent e) { + pane.populateBean(matchResult, nameTable, Utils.objectToString(areaBox.getSelectedItem())); + } + + @Override + public void windowClosing(WindowEvent e) { + + } + + @Override + public void windowClosed(WindowEvent e) { + + } + + @Override + public void windowIconified(WindowEvent e) { + + } + + @Override + public void windowDeiconified(WindowEvent e) { + + } + + @Override + public void windowActivated(WindowEvent e) { + + } + + @Override + public void windowDeactivated(WindowEvent e) { + + } + }); + dialog.setVisible(true); + } + }; + } + + @Override + public void refreshLevel(int level) { + this.setLevel(level); + } +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanPointMapPlotTableDataContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanPointMapPlotTableDataContentPane.java index 40ea3fe3a3..2e25e1bc20 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanPointMapPlotTableDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanPointMapPlotTableDataContentPane.java @@ -2,13 +2,14 @@ package com.fr.van.chart.map.designer.data.contentpane.table; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartDataPane; - import com.fr.plugin.chart.map.data.VanMapTableDefinitionProvider; import com.fr.van.chart.map.designer.data.component.table.AbstractLongLatAreaPane; +import com.fr.van.chart.map.designer.data.component.table.AreaPane; import com.fr.van.chart.map.designer.data.component.table.PointMapAreaPane; import com.fr.van.chart.map.designer.data.component.table.PointMapLongLatAreaPane; @@ -16,11 +17,11 @@ import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import java.util.List; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Component; import java.awt.Dimension; -import java.util.List; /** * Created by Mitisky on 16/5/17. @@ -41,7 +42,7 @@ public class VanPointMapPlotTableDataContentPane extends VanAreaMapPlotTableData protected JPanel createAreaNamePane() { JPanel panel = new JPanel(new BorderLayout()); - panel.setBorder(BorderFactory.createEmptyBorder(0,LEFT_GAP,V_GAP,0)); + panel.setBorder(BorderFactory.createEmptyBorder(0, LEFT_GAP, V_GAP, 0)); panel.add(longLatTableComboPane, BorderLayout.CENTER); return panel; } @@ -56,7 +57,7 @@ public class VanPointMapPlotTableDataContentPane extends VanAreaMapPlotTableData longLatTableComboPane.checkBoxUse(hasUse); } - protected boolean isAreaSelectedItem(){ + protected boolean isAreaSelectedItem() { return longLatTableComboPane.isSelectedItem(); } @@ -92,12 +93,12 @@ public class VanPointMapPlotTableDataContentPane extends VanAreaMapPlotTableData double f = TableLayout.FILL; this.setLayout(new BorderLayout(0, 5)); - centerPane = new JPanel(new CardLayout()){ + centerPane = new JPanel(new CardLayout()) { @Override public Dimension getPreferredSize() { - if (locationType.getSelectedIndex() == 0){ + if (locationType.getSelectedIndex() == 0) { return new Dimension(180, (int) areaNamePane.getPreferredSize().getHeight()); - }else { + } else { return new Dimension(180, (int) longLatAreaPane.getPreferredSize().getHeight()); } } @@ -124,17 +125,17 @@ public class VanPointMapPlotTableDataContentPane extends VanAreaMapPlotTableData double[] columnSize = {p, f}; double[] rowSize = {p}; Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Geographic")),locationType}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Geographic")), locationType}, }; - JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components,rowSize,columnSize,30,6); + JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 30, 6); this.add(panel, BorderLayout.NORTH); this.add(centerPane, BorderLayout.CENTER); } - public void fireCheckSeriesUse(boolean hasUse){ + public void fireCheckSeriesUse(boolean hasUse) { checkSeriseUse(hasUse); } @@ -142,7 +143,7 @@ public class VanPointMapPlotTableDataContentPane extends VanAreaMapPlotTableData CardLayout cardLayout = (CardLayout) centerPane.getLayout(); if (locationType.getSelectedIndex() == 0) { cardLayout.show(centerPane, "area"); - }else { + } else { cardLayout.show(centerPane, "longLat"); } fireCheckSeriesUse(true); @@ -177,18 +178,18 @@ public class VanPointMapPlotTableDataContentPane extends VanAreaMapPlotTableData if (locationType.getSelectedIndex() == 0) { areaNamePane.populate(mapTableDefinitionProvider); - }else { + } else { longLatAreaPane.populate(mapTableDefinitionProvider); } checkCenterPane(); } - public void updateBean(VanMapTableDefinitionProvider mapTableDefinitionProvider){ + public void updateBean(VanMapTableDefinitionProvider mapTableDefinitionProvider) { boolean useAreaName = locationType.getSelectedIndex() == 0; mapTableDefinitionProvider.setUseAreaName(useAreaName); if (useAreaName) { areaNamePane.update(mapTableDefinitionProvider); - }else { + } else { longLatAreaPane.update(mapTableDefinitionProvider); } @@ -206,16 +207,26 @@ public class VanPointMapPlotTableDataContentPane extends VanAreaMapPlotTableData } public boolean isSelectedItem() { - if (locationType.getSelectedIndex() == 0){ + if (locationType.getSelectedIndex() == 0) { return areaNamePane.isSelectedItem(); - }else { + } else { return longLatAreaPane.isSelectedItem(); } } } protected AbstractLongLatAreaPane createAreaPane(LongLatAreaTableComboPane longLatAreaTableComboPane) { - return new PointMapAreaPane(longLatAreaTableComboPane); + return new PointMapAreaPane(longLatAreaTableComboPane) { + protected void initAreaPane(VanPointMapPlotTableDataContentPane.LongLatAreaTableComboPane parentPane) { + areaPane = new AreaPane(parentPane) { + protected Component[][] getComponent () { + return new Component[][]{ + new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Name")), VanPointMapPlotTableDataContentPane.this.createAreaPanel(areaNameCom)} + }; + } + }; + } + }; } protected AbstractLongLatAreaPane createLongLatAreaPane(LongLatAreaTableComboPane longLatAreaTableComboPane) { 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 2419604142..0f89fed693 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 @@ -1,11 +1,9 @@ package com.fr.van.chart.map.designer.other; import com.fr.chart.chartattr.Plot; - import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.map.VanChartMapPlot; import com.fr.plugin.chart.type.MapType; -import com.fr.plugin.chart.vanchart.VanChart; import com.fr.van.chart.designer.PlotFactory; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.other.AutoRefreshPane; @@ -20,11 +18,13 @@ import javax.swing.JPanel; public class VanChartMapInteractivePane extends VanChartInteractivePaneWithMapZoom { private static final int HYPERLINK_LEFT_GAP = 36; private VanChartMapHyperLinkPane hyperlinkPane; + @Override protected JPanel createHyperlinkPane() { hyperlinkPane = new VanChartMapHyperLinkPane(); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_Insert_Hyperlink"), hyperlinkPane); } + @Override protected void populateHyperlink(Plot plot) { hyperlinkPane.populateBean(plot); @@ -35,11 +35,12 @@ public class VanChartMapInteractivePane extends VanChartInteractivePaneWithMapZo hyperlinkPane.updateBean(plot); } + //大数据模式 恢复用注释。删除下面方法。 @Override protected boolean largeModel(Plot plot) { - if(plot instanceof VanChartMapPlot){ - VanChartMapPlot mapPlot = (VanChartMapPlot)plot; - switch (mapPlot.getMapType()){ + if (plot instanceof VanChartMapPlot) { + VanChartMapPlot mapPlot = (VanChartMapPlot) plot; + switch (mapPlot.getMapType()) { case LINE: return PlotFactory.lineMapLargeModel(mapPlot); default: @@ -49,13 +50,23 @@ public class VanChartMapInteractivePane extends VanChartInteractivePaneWithMapZo return false; } + @Override + protected boolean isCurrentChartSupportLargeDataMode() { + if (this.chart == null || this.chart.getPlot() == null) { + return false; + } + VanChartMapPlot mapPlot = this.chart.getPlot(); + + return mapPlot.getMapType() == MapType.POINT || mapPlot.getMapType() == MapType.LINE; + } + protected AutoRefreshPane getMoreLabelPane(VanChartPlot plot) { boolean isLargeModel = largeModel(plot); - VanChartMapPlot mapPlot = (VanChartMapPlot)plot; + VanChartMapPlot mapPlot = (VanChartMapPlot) plot; if (mapPlot.getMapType().equals(MapType.LINE)) { - return new AutoRefreshPaneWithoutTooltip((VanChart) chart, isLargeModel); + return new AutoRefreshPaneWithoutTooltip(chart, isLargeModel); } - return new AutoRefreshPane((VanChart) chart, isLargeModel); + return new AutoRefreshPane(chart, isLargeModel); } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartLineMapConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartLineMapConditionPane.java index b6862a38e2..89bc16b7e3 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartLineMapConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/condition/pane/VanChartLineMapConditionPane.java @@ -46,7 +46,10 @@ public class VanChartLineMapConditionPane extends DataSeriesConditionPane { classPaneMap.put(AttrFloatColor.class, new VanChartFloatColorConditionPane(this)); classPaneMap.put(AttrCurve.class, new VanChartCurveConditionPane(this)); classPaneMap.put(AttrTooltip.class, new VanChartLineMapTooltipConditionPane(this, plot)); - if(!PlotFactory.lineMapLargeModel(plot)){ + //大数据模式 恢复用注释。下面1行删除。 + if (!PlotFactory.lineMapLargeModel(plot)) { + //大数据模式 恢复用注释。取消注释。 + //if (!PlotFactory.largeDataModel(plot)) { classPaneMap.put(AttrLineEffect.class, new VanChartLineEffectConditionPane(this, EffectHelper.getLineMapDefaultLineEffect())); } } @@ -56,6 +59,7 @@ public class VanChartLineMapConditionPane extends DataSeriesConditionPane { /** * 返回图表class对象 + * * @return class对象 */ public Class class4Correspond() { 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 6698652202..004ac81b38 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 @@ -2,9 +2,12 @@ package com.fr.van.chart.map.designer.type; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; +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.utils.gui.GUICoreUtils; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.map.MapIndependentVanChart; import com.fr.plugin.chart.map.VanChartMapPlot; @@ -31,10 +34,10 @@ public class VanChartMapPlotPane extends AbstractVanChartTypePane { }; } - protected Component[][] getPaneComponents(JPanel typePane){ + protected Component[][] getPaneComponents(JPanel typePane) { try { sourceChoosePane = createSourceChoosePane(); - } catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } return new Component[][]{ @@ -51,10 +54,10 @@ public class VanChartMapPlotPane extends AbstractVanChartTypePane { * 更新界面内容 */ public void populateBean(Chart chart) { - for(ChartImagePane imagePane : typeDemo) { + for (ChartImagePane imagePane : typeDemo) { imagePane.isPressing = false; } - VanChartMapPlot plot = (VanChartMapPlot)chart.getPlot(); + VanChartMapPlot plot = (VanChartMapPlot) chart.getPlot(); typeDemo.get(plot.getDetailType()).isPressing = true; populateSourcePane(plot); @@ -69,7 +72,7 @@ public class VanChartMapPlotPane extends AbstractVanChartTypePane { protected void populateSourcePane(VanChartMapPlot plot) { //populate需要使用clone的plot try { - VanChartMapPlot mapPlot = (VanChartMapPlot)plot.clone(); + VanChartMapPlot mapPlot = (VanChartMapPlot) plot.clone(); sourceChoosePane.populateBean(mapPlot); } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); @@ -79,21 +82,21 @@ public class VanChartMapPlotPane extends AbstractVanChartTypePane { public void updateBean(Chart chart) { super.updateBean(chart); Plot plot = chart.getPlot(); - if(plot instanceof VanChartMapPlot) { + if (plot instanceof VanChartMapPlot) { sourceChoosePane.updateBean((VanChartMapPlot) plot); - if(!isSamePlot() || (typeChanged && isSamePlot())){ + if (!isSamePlot() || (typeChanged && isSamePlot())) { resetAttr(plot); } } } - /** * 不同地图类型的超链不需要复制 + * * @param oldPlot * @param newPlot * @throws CloneNotSupportedException */ - protected void cloneHotHyperLink(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException{ + protected void cloneHotHyperLink(Plot oldPlot, Plot newPlot) throws CloneNotSupportedException { } @@ -106,11 +109,11 @@ public class VanChartMapPlotPane extends AbstractVanChartTypePane { sourceChoosePane.resetComponentValue((VanChartMapPlot) plot); } - protected Plot getSelectedClonedPlot(){ + protected Plot getSelectedClonedPlot() { VanChartMapPlot newPlot = null; Chart[] charts = getDefaultCharts(); - for(int i = 0, len = charts.length; i < len; i++){ - if(typeDemo.get(i).isPressing){ + for (int i = 0, len = charts.length; i < len; i++) { + if (typeDemo.get(i).isPressing) { newPlot = (VanChartMapPlot) charts[i].getPlot(); } } @@ -119,7 +122,7 @@ public class VanChartMapPlotPane extends AbstractVanChartTypePane { return cloned; } try { - cloned = (Plot)newPlot.clone(); + cloned = (Plot) newPlot.clone(); } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } @@ -142,8 +145,12 @@ public class VanChartMapPlotPane extends AbstractVanChartTypePane { return MapIndependentVanChart.MapVanCharts[0]; } - public VanChartMapSourceChoosePane getSourceChoosePane(){ + public VanChartMapSourceChoosePane getSourceChoosePane() { return this.sourceChoosePane; } + @Override + protected boolean acceptDefinition(ChartDataDefinitionProvider definition, VanChartPlot vanChartPlot) { + return definition instanceof MapChartDataDefinition; + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java index 297d781667..f609debe90 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java @@ -5,6 +5,7 @@ import com.fr.base.Utils; import com.fr.decision.webservice.v10.map.WMSFactory; import com.fr.decision.webservice.v10.map.geojson.helper.GEOJSONHelper; import com.fr.design.constants.LayoutConstants; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.file.HistoryTemplateListPane; @@ -427,7 +428,7 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver { if(list != null && list.size() > 0) { resetWMSLayerPane(list); } else { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Invalid_WMS")); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Invalid_WMS")); } } }.execute(); 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 c7a44d1b88..1cc66a2bf5 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 @@ -41,19 +41,10 @@ public class MultiPieIndependentVanChartInterface extends AbstractIndependentVan }; } - @Override - public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { - return new MultiPiePlotTableDataContentPane(parent); - } - - @Override - public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { - return new MultiPiePlotReportDataContentPane(parent); - } - + //图表数据结构 恢复用注释。取消注释。 // @Override // public ChartDataPane getChartDataPane(AttributeChangeListener listener) { -// return new AbstractDataPane(listener) { +// return new AbstractVanSingleDataPane(listener) { // @Override // protected SingleDataPane createSingleDataPane() { // return new SingleDataPane(new MultiPieDataSetFieldsPane(), new MultiPieCellDataFieldsPane()); @@ -61,6 +52,17 @@ public class MultiPieIndependentVanChartInterface extends AbstractIndependentVan // }; // } + //图表数据结构 恢复用注释。删除下面两个方法 getTableDataSourcePane getReportDataSourcePane。 + @Override + public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent){ + return new MultiPiePlotTableDataContentPane(parent); + } + + @Override + public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent){ + return new MultiPiePlotReportDataContentPane(parent); + } + public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot){ return new VanChartMultiPieSeriesPane(parent, plot); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/VanChartMultiPiePlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/VanChartMultiPiePlotPane.java index 397a118926..555cca468d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/VanChartMultiPiePlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/VanChartMultiPiePlotPane.java @@ -2,7 +2,12 @@ package com.fr.van.chart.multilayer; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; +import com.fr.chartx.data.AbstractDataDefinition; +import com.fr.chartx.data.ChartDataDefinitionProvider; +import com.fr.chartx.data.field.AbstractColumnFieldCollection; +import com.fr.chartx.data.field.diff.MultiPieColumnFieldCollection; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.multilayer.MultiPieIndependentVanChart; import com.fr.plugin.chart.multilayer.VanChartMultiPiePlot; @@ -20,11 +25,11 @@ public class VanChartMultiPiePlotPane extends AbstractVanChartTypePane { } @Override - protected Plot getSelectedClonedPlot(){ + protected Plot getSelectedClonedPlot() { VanChartMultiPiePlot newPlot = null; Chart[] multilayerCharts = MultiPieIndependentVanChart.MultilayerVanChartTypes; - for(int i = 0, len = multilayerCharts.length; i < len; i++){ - if(typeDemo.get(i).isPressing){ + for (int i = 0, len = multilayerCharts.length; i < len; i++) { + if (typeDemo.get(i).isPressing) { newPlot = (VanChartMultiPiePlot) multilayerCharts[i].getPlot(); } } @@ -34,7 +39,7 @@ public class VanChartMultiPiePlotPane extends AbstractVanChartTypePane { return cloned; } try { - cloned = (Plot)newPlot.clone(); + cloned = (Plot) newPlot.clone(); } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error("Error In MultiPieChart"); } @@ -43,13 +48,14 @@ public class VanChartMultiPiePlotPane extends AbstractVanChartTypePane { /** * 防止新建其他图表从而切换很卡 + * * @return */ public Chart getDefaultChart() { return MultiPieIndependentVanChart.MultilayerVanChartTypes[0]; } - protected void resetChartAttr(Chart chart, Plot newPlot){ + protected void resetChartAttr(Chart chart, Plot newPlot) { super.resetChartAttr(chart, newPlot); //重置工具栏选项 VanChartTools tools = ((VanChart) chart).getVanChartTools(); @@ -59,4 +65,13 @@ public class VanChartMultiPiePlotPane extends AbstractVanChartTypePane { tools.setExport(false); } } + + @Override + protected boolean acceptDefinition(ChartDataDefinitionProvider definition, VanChartPlot vanChartPlot) { + if (definition instanceof AbstractDataDefinition) { + AbstractColumnFieldCollection columnFieldCollection = ((AbstractDataDefinition) definition).getColumnFieldCollection(); + return columnFieldCollection instanceof MultiPieColumnFieldCollection; + } + return false; + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java index 0ec79c3b8a..2169c4a20c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java @@ -8,6 +8,7 @@ import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; +import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.PiePlot4VanChart; import com.fr.van.chart.designer.TableLayout4VanChartHelper; @@ -53,21 +54,21 @@ public class VanChartPieSeriesPane extends VanChartAbstractPlotSeriesPane { startAngle = new UISpinner(MIN_ANGLE, MAX_ANGLE, 1, 0); endAngle = new UISpinner(MIN_ANGLE, MAX_ANGLE, 1, 0); innerRadius = new UISpinner(0, 100, 1, 0); - supportRotation = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_On"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false}); + supportRotation = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_On"), Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false}); Component[][] components = new Component[][]{ new Component[]{null,null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Start_Angle")),startAngle}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_End_Angle")),endAngle}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Inner_Radius")),innerRadius}, - new Component[]{createRadiusPane(),null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Rotation")),supportRotation} + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Start_Angle")),startAngle}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_End_Angle")),endAngle}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Inner_Radius")),innerRadius}, + new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Radius_Set")),null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Rotation")),supportRotation} }; JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel); } public void populateBean(Plot plot) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionIntervalConfigPane.java b/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionIntervalConfigPane.java index 94bb9a4dae..f4103e0d2f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionIntervalConfigPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionIntervalConfigPane.java @@ -3,8 +3,9 @@ package com.fr.van.chart.range.component; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.layout.TableLayout; +import com.fr.design.mainframe.chart.gui.ColorSelectBoxWithOutTransparent; import com.fr.design.mainframe.chart.gui.style.series.MapColorPickerPaneWithFormula; - +import com.fr.design.style.color.ColorSelectBox; import java.awt.Component; @@ -34,4 +35,9 @@ public class SectionIntervalConfigPane extends MapColorPickerPaneWithFormula { }; } + + @Override + protected ColorSelectBox getColorSelectBox() { + return new ColorSelectBoxWithOutTransparent(100); + } } \ No newline at end of file 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 263ce191af..1b7063af4d 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 @@ -16,6 +16,7 @@ import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; 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; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.scatter.component.VanChartScatterStylePane; import com.fr.van.chart.scatter.data.VanChartScatterPlotTableDataContentPane; @@ -56,18 +57,19 @@ public class ScatterIndependentVanChartInterface extends AbstractIndependentVanC public String getIconPath() { return "com/fr/design/images/form/toolbar/scatter.png"; } + @Override - public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot){ + public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot) { return new VanChartScatterSeriesPane(parent, plot); } @Override - public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent){ + public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { return new VanChartScatterPlotTableDataContentPane(parent); } @Override - public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent){ + public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { return new BubblePlotReportDataContentPane(parent); } @@ -76,19 +78,40 @@ public class ScatterIndependentVanChartInterface extends AbstractIndependentVanC * 图表的属性界面数组 * @return 属性界面 */ - public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener){ + public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener) { VanChartStylePane stylePane = new VanChartScatterStylePane(listener); - VanChartOtherPane otherPane = new VanChartOtherPane(){ + VanChartOtherPane otherPane = new VanChartOtherPane() { @Override protected BasicBeanPane createInteractivePane() { - return new VanChartInteractivePaneWithOutSort(); + return new VanChartInteractivePaneWithOutSort() { + @Override + protected ZoomPane createZoomPane() { + return new ZoomPane(); + } + + @Override + protected boolean isCurrentChartSupportLargeDataMode() { + return true; + } + }; } }; return new AbstractChartAttrPane[]{stylePane, otherPane}; } - public ConditionAttributesPane getPlotConditionPane(Plot plot){ + public ConditionAttributesPane getPlotConditionPane(Plot plot) { return new VanChartScatterConditionPane(plot); } + + //图表数据结构 恢复用注释。取消注释。 +// @Override +// public ChartDataPane getChartDataPane(AttributeChangeListener listener) { +// return new AbstractVanSingleDataPane(listener) { +// @Override +// protected SingleDataPane createSingleDataPane() { +// return new SingleDataPane(new ScatterDataSetFieldsPane(), new ScatterCellDataFieldsPane()); +// } +// }; +// } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterPlotPane.java index b2d6be16e2..f93051a747 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterPlotPane.java @@ -5,7 +5,12 @@ import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionCollection; +import com.fr.chartx.data.AbstractDataDefinition; +import com.fr.chartx.data.ChartDataDefinitionProvider; +import com.fr.chartx.data.field.AbstractColumnFieldCollection; +import com.fr.chartx.data.field.diff.BubbleColumnFieldCollection; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.VanChartAttrLine; import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.scatter.ScatterIndependentVanChart; @@ -81,4 +86,13 @@ public class VanChartScatterPlotPane extends AbstractVanChartTypePane { } } } + + @Override + protected boolean acceptDefinition(ChartDataDefinitionProvider definition, VanChartPlot vanChartPlot) { + if(definition instanceof AbstractDataDefinition) { + AbstractColumnFieldCollection columnFieldCollection = ((AbstractDataDefinition) definition).getColumnFieldCollection(); + return columnFieldCollection instanceof BubbleColumnFieldCollection; + } + return false; + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java index 456c6a135d..a85725a8e7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java @@ -5,7 +5,6 @@ import com.fr.design.beans.BasicBeanPane; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; - import com.fr.van.chart.custom.component.VanChartCustomAxisConditionPane; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartLineTypePane; @@ -20,19 +19,19 @@ import java.awt.Component; /** * 散点图的系列界面 */ -public class VanChartScatterSeriesPane extends VanChartAbstractPlotSeriesPane{ +public class VanChartScatterSeriesPane extends VanChartAbstractPlotSeriesPane { private static final long serialVersionUID = 5595016643808487932L; - public VanChartScatterSeriesPane(ChartStylePane parent, Plot plot){ + public VanChartScatterSeriesPane(ChartStylePane parent, Plot plot) { super(parent, plot); } - protected JPanel getContentInPlotType(){ + protected JPanel getContentInPlotType() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] row = {p,p,p,p,p,p,p,p,p,p}; + double[] row = {p, p, p, p, p, p, p, p, p, p}; double[] col = {f}; Component[][] components = new Component[][]{ @@ -40,6 +39,7 @@ public class VanChartScatterSeriesPane extends VanChartAbstractPlotSeriesPane{ new Component[]{createLineTypePane()}, new Component[]{createMarkerPane()}, new Component[]{createStackedAndAxisPane()}, + //大数据模式 恢复用注释。下面1行删除。 new Component[]{createLargeDataModelPane()}, new Component[]{createTrendLinePane()}, }; @@ -49,25 +49,25 @@ public class VanChartScatterSeriesPane extends VanChartAbstractPlotSeriesPane{ } //设置色彩面板内容 - protected void setColorPaneContent (JPanel panel) { + protected void setColorPaneContent(JPanel panel) { panel.add(createAlphaPane(), BorderLayout.CENTER); } @Override //堆积和坐标轴设置(自定义柱形图等用到) protected JPanel createStackedAndAxisPane() { - stackAndAxisEditPane = new VanChartStackedAndAxisListControlPane(){ + stackAndAxisEditPane = new VanChartStackedAndAxisListControlPane() { @Override protected Class getStackAndAxisPaneClass() { return VanChartCustomAxisConditionPane.class; } @Override - public String getPaneTitle(){ + public String getPaneTitle() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Axis"); } }; - stackAndAxisEditExpandablePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(stackAndAxisEditPane.getPaneTitle(), stackAndAxisEditPane); + stackAndAxisEditExpandablePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(stackAndAxisEditPane.getPaneTitle(), stackAndAxisEditPane); return stackAndAxisEditExpandablePane; } @@ -77,8 +77,8 @@ public class VanChartScatterSeriesPane extends VanChartAbstractPlotSeriesPane{ } @Override - protected void checkCompsEnabledWithLarge() { - super.checkCompsEnabledWithLarge(); + protected void checkCompsEnabledWithLarge(Plot plot) { + super.checkCompsEnabledWithLarge(this.plot); checkLinePane(); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/VanChartScatterLineTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/VanChartScatterLineTypePane.java index b9dac828c6..8808a78e38 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/VanChartScatterLineTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/VanChartScatterLineTypePane.java @@ -2,15 +2,12 @@ package com.fr.van.chart.scatter.component; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.layout.TableLayoutHelper; - +import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.base.VanChartAttrLine; import com.fr.plugin.chart.type.LineStyle; import com.fr.stable.Constants; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartLineTypePane; -import javax.swing.JPanel; import java.awt.Component; /** @@ -21,29 +18,28 @@ public class VanChartScatterLineTypePane extends VanChartLineTypePane { @Override protected void createLineStyle() { String[] textArray = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Normal_Line"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_CurveLine")}; + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_CurveLine")}; lineStyle = new UIButtonGroup(textArray, new LineStyle[]{LineStyle.NORMAL, LineStyle.CURVE}); } @Override - protected JPanel createContentPane(double p, double f) { - double[] row = {p,p,p}; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] col = {f, e}; - Component[][] components = new Component[][]{ - new Component[]{null,null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")), lineWidth}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Present")), lineStyle}, + protected Component[][] createContentComponent(Component[] lineStyleComponent, Component[] nullValueBreakComponent) { + return new Component[][]{ + //线型支持虚线 恢复用注释。下面2行删除。 + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), lineWidth}, + lineStyleComponent }; - - return TableLayoutHelper.createTableLayoutPane(components, row, col); } @Override protected VanChartAttrLine initVanChartAttrLine() { - VanChartAttrLine attrLine = new VanChartAttrLine(); + VanChartAttrLine attrLine = new VanChartAttrLine(); //默认为无线型,且默認空值不斷開 + //线型支持虚线 恢复用注释。下面1行删除。 attrLine.setLineWidth(Constants.LINE_NONE); + //线型支持虚线 恢复用注释。取消注释。 + //attrLine.setLineType(LineType.NONE); attrLine.setNullValueBreak(false); return attrLine; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/StructureIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/VanStructureChartTypeUI.java similarity index 81% rename from designer-chart/src/main/java/com/fr/van/chart/structure/desinger/StructureIndependentVanChartInterface.java rename to designer-chart/src/main/java/com/fr/van/chart/structure/desinger/VanStructureChartTypeUI.java index 6be8c692ba..8109adeb0c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/StructureIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/VanStructureChartTypeUI.java @@ -15,6 +15,8 @@ import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.plugin.chart.base.VanChartConstants; 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; +import com.fr.van.chart.designer.other.zoom.ZoomPaneWithOutMode; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.structure.desinger.data.StructurePlotReportDataContentPane; import com.fr.van.chart.structure.desinger.data.StructurePlotTableDataContentPane; @@ -26,7 +28,7 @@ import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; /** * Created by shine on 2017/2/15. */ -public class StructureIndependentVanChartInterface extends AbstractIndependentVanChartUI { +public class VanStructureChartTypeUI extends AbstractIndependentVanChartUI { @Override public AbstractChartTypePane getPlotTypePane() { return new VanChartStructureTypePane(); @@ -83,6 +85,7 @@ public class StructureIndependentVanChartInterface extends AbstractIndependentVa protected BasicBeanPane createInteractivePane() { return new VanChartInteractivePaneWithOutSort(){ + //图表缩放新设计 恢复用注释。删除下面两个方法 getNameArray getValueArray。 @Override protected String[] getNameArray() { return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_XY_Axis"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")}; @@ -94,6 +97,10 @@ public class StructureIndependentVanChartInterface extends AbstractIndependentVa return new String[]{VanChartConstants.ZOOM_TYPE_XY, VanChartConstants.ZOOM_TYPE_NONE}; } + @Override + protected ZoomPane createZoomPane() { + return new ZoomPaneWithOutMode(); + } }; } }; @@ -105,8 +112,14 @@ public class StructureIndependentVanChartInterface extends AbstractIndependentVa return new VanChartStructureConditionPane(plot); } - /* @Override - public ChartDataPane getChartDataPane(AttributeChangeListener listener) { - return new StructureChartDataPane(listener); - }*/ + //图表数据结构 恢复用注释。取消注释。 +// @Override +// public ChartDataPane getChartDataPane(AttributeChangeListener listener) { +// return new AbstractVanSingleDataPane(listener) { +// @Override +// protected SingleDataPane createSingleDataPane() { +// return new SingleDataPane(new StructureDataSetFieldsPane(), new StructureCellDataFieldsPane()); +// } +// }; +// } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/type/VanChartStructureTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/type/VanChartStructureTypePane.java index 1674c850c7..96544a56a4 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/type/VanChartStructureTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/type/VanChartStructureTypePane.java @@ -2,7 +2,12 @@ package com.fr.van.chart.structure.desinger.type; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; +import com.fr.chartx.data.AbstractDataDefinition; +import com.fr.chartx.data.ChartDataDefinitionProvider; +import com.fr.chartx.data.field.AbstractColumnFieldCollection; +import com.fr.chartx.data.field.diff.StructureColumnFieldCollection; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.structure.StructureIndependentVanChart; import com.fr.plugin.chart.structure.VanChartStructurePlot; @@ -54,4 +59,12 @@ public class VanChartStructureTypePane extends AbstractVanChartTypePane { return WordCloudIndependentVanChart.WordCloudVanCharts[0]; } + @Override + protected boolean acceptDefinition(ChartDataDefinitionProvider definition, VanChartPlot vanChartPlot) { + if(definition instanceof AbstractDataDefinition) { + AbstractColumnFieldCollection columnFieldCollection = ((AbstractDataDefinition) definition).getColumnFieldCollection(); + return columnFieldCollection instanceof StructureColumnFieldCollection; + } + return false; + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractIndependentVanChartUI.java b/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractIndependentVanChartUI.java index e1234c90fe..57bed739b7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractIndependentVanChartUI.java +++ b/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractIndependentVanChartUI.java @@ -46,4 +46,15 @@ public abstract class AbstractIndependentVanChartUI extends AbstractIndependentC public int currentAPILevel() { return CURRENT_API_LEVEL; } + + //图表数据结构 恢复用注释。取消注释。 +// @Override +// public ChartDataPane getChartDataPane(AttributeChangeListener listener) { +// return new AbstractVanSingleDataPane(listener) { +// @Override +// protected SingleDataPane createSingleDataPane() { +// return new SingleDataPane(new SingleCategoryDataSetFieldsPane(), new SingleCategoryCellDataFieldsPane()); +// } +// }; +// } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractMultiCategoryVanChartUI.java b/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractMultiCategoryVanChartUI.java index 9dfac7c2c1..b9794b1c83 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractMultiCategoryVanChartUI.java +++ b/designer-chart/src/main/java/com/fr/van/chart/vanchart/AbstractMultiCategoryVanChartUI.java @@ -13,19 +13,80 @@ import com.fr.van.chart.designer.data.VanChartMoreCateTableDataContentPane; /** * Created by mengao on 2017/7/6. */ -public abstract class AbstractMultiCategoryVanChartUI extends AbstractIndependentVanChartUI { - public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent){ +public abstract class AbstractMultiCategoryVanChartUI extends AbstractIndependentVanChartUI { + public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { //自定义组合图特殊处理 - if (((VanChartPlot)plot).isInCustom() && ((VanChartPlot)plot).getCustomType().equals("CUSTOM")) { + if (((VanChartPlot) plot).isInCustom() && ((VanChartPlot) plot).getCustomType().equals("CUSTOM")) { return new CategoryPlotTableDataContentPane(parent); } - return new VanChartMoreCateTableDataContentPane(parent); } + return new VanChartMoreCateTableDataContentPane(parent); + } - public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent){ + public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { //自定义组合图特殊处理 - if (((VanChartPlot)plot).isInCustom() && ((VanChartPlot)plot).getCustomType().equals("CUSTOM")) { + if (((VanChartPlot) plot).isInCustom() && ((VanChartPlot) plot).getCustomType().equals("CUSTOM")) { return new CategoryPlotReportDataContentPane(parent); } return new VanChartMoreCateReportDataContentPane(parent); } + + + //图表缩放新设计 恢复用注释。取消注释。 +// @Override +// public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener) { +// +// VanChartStylePane stylePane = new VanChartStylePane(listener); +// VanChartOtherPane otherPane = new VanChartOtherPane() { +// @Override +// protected BasicBeanPane createInteractivePane() { +// return new VanChartInteractivePane() { +// @Override +// protected ZoomPane createZoomPane() { +// return new ZoomPane(); +// } +// +// @Override +// protected boolean isCurrentChartSupportLargeDataMode() { +// return true; +// } +// }; +// } +// }; +// return new AbstractChartAttrPane[]{stylePane, otherPane}; +// } + + //图表数据结构 恢复用注释。取消注释。 +// @Override +// public ChartDataPane getChartDataPane(AttributeChangeListener listener) { +// return new AbstractVanSingleDataPane(listener) { +// MultiCategoryDataSetFieldsPane multiCategoryDataSetFieldsPane; +// MultiCategoryCellDataFieldsPane multiCategoryCellDataFieldsPane; +// +// @Override +// protected SingleDataPane createSingleDataPane() { +// multiCategoryDataSetFieldsPane = new MultiCategoryDataSetFieldsPane(); +// multiCategoryCellDataFieldsPane = new MultiCategoryCellDataFieldsPane(); +// return new SingleDataPane(multiCategoryDataSetFieldsPane, multiCategoryCellDataFieldsPane); +// } +// +// @Override +// public void populate(ChartCollection collection) { +// super.populate(collection); +// VanChart vanChart = this.getVanChart(); +// if (vanChart == null) { +// return; +// } +// +// VanChartRectanglePlot plot = vanChart.getPlot(); +// VanChartAxis axis = plot.getDefaultXAxis(); +// if (plot instanceof VanChartColumnPlot +// && ((VanChartColumnPlot) plot).isBar()) { +// axis = plot.getDefaultYAxis(); +// } +// +// multiCategoryDataSetFieldsPane.setCategoryAxis(ComparatorUtils.equals(axis.getAxisType(), AxisType.AXIS_CATEGORY)); +// multiCategoryCellDataFieldsPane.setCategoryAxis(ComparatorUtils.equals(axis.getAxisType(), AxisType.AXIS_CATEGORY)); +// } +// }; +// } } 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 ff4b9bbce8..5ff077a4b6 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 @@ -16,6 +16,8 @@ import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.plugin.chart.base.VanChartConstants; 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; +import com.fr.van.chart.designer.other.zoom.ZoomPaneWithOutMode; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; import com.fr.van.chart.wordcloud.designer.data.WordCloudPlotReportDataContentPane; @@ -97,9 +99,10 @@ public class WordCloudIndependentVanChartInterface extends AbstractIndependentVa protected BasicBeanPane createInteractivePane() { return new VanChartInteractivePaneWithOutSort(){ + //图表缩放新设计 恢复用注释。删除下面两个方法 getNameArray getValueArray。 @Override protected String[] getNameArray() { - return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_XY_Axis"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")}; + return new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_XY_Axis"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")}; } @Override @@ -107,15 +110,21 @@ public class WordCloudIndependentVanChartInterface extends AbstractIndependentVa return new String[]{VanChartConstants.ZOOM_TYPE_XY, VanChartConstants.ZOOM_TYPE_NONE}; } + + @Override + protected ZoomPane createZoomPane() { + return new ZoomPaneWithOutMode(); + } }; } }; return new AbstractChartAttrPane[]{stylePane, otherPane}; } + //图表数据结构 恢复用注释。取消注释。 // @Override // public ChartDataPane getChartDataPane(AttributeChangeListener listener) { -// return new AbstractDataPane(listener) { +// return new AbstractVanSingleDataPane(listener) { // @Override // protected SingleDataPane createSingleDataPane() { // return new SingleDataPane(new WordCloudDataSetFieldsPane(), new WordCloudCellDataFieldsPane()); diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/type/VanChartWordCloudTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/type/VanChartWordCloudTypePane.java index 1a75c18e14..99f330e06a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/type/VanChartWordCloudTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/type/VanChartWordCloudTypePane.java @@ -2,7 +2,12 @@ package com.fr.van.chart.wordcloud.designer.type; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; +import com.fr.chartx.data.AbstractDataDefinition; +import com.fr.chartx.data.ChartDataDefinitionProvider; +import com.fr.chartx.data.field.AbstractColumnFieldCollection; +import com.fr.chartx.data.field.diff.WordCloudColumnFieldCollection; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.wordcloud.VanChartWordCloudPlot; import com.fr.plugin.chart.wordcloud.WordCloudIndependentVanChart; @@ -63,4 +68,13 @@ public class VanChartWordCloudTypePane extends AbstractVanChartTypePane { public Chart getDefaultChart() { return WordCloudIndependentVanChart.WordCloudVanCharts[0]; } + + @Override + protected boolean acceptDefinition(ChartDataDefinitionProvider definition, VanChartPlot vanChartPlot) { + if(definition instanceof AbstractDataDefinition) { + AbstractColumnFieldCollection columnFieldCollection = ((AbstractDataDefinition) definition).getColumnFieldCollection(); + return columnFieldCollection instanceof WordCloudColumnFieldCollection; + } + return false; + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java index 4e6adee4b4..4bc0f22e49 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java @@ -241,16 +241,12 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter { LayoutUtils.layoutRootContainer(container); }else{ //添加到其父组件布局中的时候,要用其父组件布局添加 - container.getLayoutAdapter().addBean(creator, x, y); if (creator.shouldScaleCreator() || creator.hasTitleStyle()) { - addParentCreator(creator); + XLayoutContainer parentPanel = creator.initCreatorWrapper(creator.getHeight()); + container.getLayoutAdapter().addBean(parentPanel, x, y); } else { - container.add(creator, creator.toData().getWidgetName(),0); + container.getLayoutAdapter().addBean(creator, x, y); } - XWFitLayout layout = (XWFitLayout) container; - // 更新对应的BoundsWidget - layout.updateBoundsWidget(); - updateCreatorBackBound(); } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XRadio.java b/designer-form/src/main/java/com/fr/design/designer/creator/XRadio.java index 3e122d070e..af207457f9 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XRadio.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XRadio.java @@ -15,7 +15,9 @@ import java.beans.IntrospectionException; /** * @author richer * @since 6.5.3 + * @deprecated */ +@Deprecated public class XRadio extends XWidgetCreator { public XRadio(Radio widget, Dimension initSize) { diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java index 56fcf64866..22d702dfd5 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -13,8 +13,11 @@ import com.fr.design.designer.beans.adapters.layout.FRAbsoluteLayoutAdapter; import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; +import com.fr.design.designer.properties.mobile.MobileBooKMarkUsePropertyUI; import com.fr.design.form.layout.FRAbsoluteLayout; +import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.form.util.XCreatorConstants; +import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.icon.IconPathConstants; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.EditingMouseListener; @@ -590,4 +593,13 @@ public class XWAbsoluteLayout extends XLayoutContainer { public boolean isSupportShared() { return true; } + + @Override + public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { + if (FormDesignerUtils.isAppRelayout(WidgetPropertyPane.getInstance().getEditingFormDesigner())) { + return new WidgetPropertyUIProvider[] {new MobileBooKMarkUsePropertyUI(this)}; + } else { + return super.getWidgetPropertyUIProviders(); + } + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java index 714bd0a2ea..3fb0b5f969 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java @@ -22,7 +22,6 @@ import com.fr.general.FRLogger; import com.fr.general.FRScreen; import com.fr.stable.ArrayUtils; import com.fr.stable.AssistUtils; -import edu.emory.mathcs.backport.java.util.Arrays; import javax.swing.JOptionPane; import java.awt.Component; @@ -31,6 +30,7 @@ import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.event.ContainerEvent; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWidgetCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWidgetCreator.java index 4835ec16bf..590aea3395 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWidgetCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWidgetCreator.java @@ -4,6 +4,7 @@ package com.fr.design.designer.creator; import com.fr.base.BaseUtils; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.FormDesigner; @@ -183,7 +184,7 @@ public abstract class XWidgetCreator extends XCreator { */ public void ChangeCreatorName(FormDesigner designer, XCreator creator) { String oldName = creator.toData().getWidgetName(); - String value = JOptionPane.showInputDialog(designer, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Change_Widget_Name_Discription"), oldName); + String value = FineJOptionPane.showInputDialog(designer, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Change_Widget_Name_Discription"), oldName); if (value != null) { designer.renameCreator(creator, value); } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java index 5a7ae9817c..f0e23b977f 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java @@ -1,5 +1,5 @@ /** - * + * */ package com.fr.design.designer.creator.cardlayout; @@ -12,6 +12,7 @@ import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.XButton; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIPopupMenu; @@ -61,6 +62,8 @@ public class XCardSwitchButton extends XButton { private static final int MIN_SIZE = 1; + private static final int HALF_NUMBER = 2; + // 删除按钮识别区域偏移量 private static final int CLOSE_ICON_RIGHT_OFFSET = 15; private static final int CLOSE_ICON_TOP_OFFSET = 15; @@ -80,7 +83,7 @@ public class XCardSwitchButton extends XButton { private UILabel label; private Icon closeIcon = MOUSE_CLOSE; - + public XWCardTagLayout getTagLayout() { return tagLayout; } @@ -126,12 +129,12 @@ public class XCardSwitchButton extends XButton { /** * 响应点击事件 - * + * * @param editingMouseListener * 事件处理器 * @param e * 点击事件 - * + * */ @Override public void respondClick(EditingMouseListener editingMouseListener, @@ -143,12 +146,12 @@ public class XCardSwitchButton extends XButton { if(cardLayout == null){ initRelateLayout(); } - + //获取当前tab的index CardSwitchButton currentButton = (CardSwitchButton) this.toData(); int index = currentButton.getIndex(); int maxIndex = cardLayout.getComponentCount() - 1; - + //点击删除图标时 if (isSelectedClose(e, designer)) { //当删除到最后一个tab时,删除整个tab布局 @@ -210,8 +213,8 @@ public class XCardSwitchButton extends XButton { //删除card,同时修改其他switchbutton和tabfit的index private void deleteCard(XCardSwitchButton button, int index){ String titleName = button.getContentLabel().getText(); - int value = JOptionPane.showConfirmDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Confirm_Dialog_Content") + "“" + titleName + "”", - ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION); + int value = FineJOptionPane.showConfirmDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Confirm_Dialog_Content") + "“" + titleName + "”", + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION); if (value != JOptionPane.OK_OPTION) { return; } @@ -235,8 +238,8 @@ public class XCardSwitchButton extends XButton { } } } - - + + //SwitchButton对应的XWCardLayout和XWCardTagLayout暂未存到xml中,重新打开时根据父子层关系获取 private void initRelateLayout(){ this.tagLayout = (XWCardTagLayout)this.getBackupParent(); @@ -244,28 +247,28 @@ public class XCardSwitchButton extends XButton { XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout)titleLayout.getBackupParent(); this.cardLayout = borderLayout.getCardPart(); } - + //是否进入点击关闭按钮区域 private boolean isSelectedClose(MouseEvent e, FormDesigner designer){ - + int diff = designer.getArea().getHorScrollBar().getValue(); - + // mouse position int ex = e.getX() + diff; int ey = e.getY(); - + //获取tab布局的位置,鼠标相对于tab按钮的位置 XLayoutContainer mainLayout = cardLayout.getBackupParent(); Point point = mainLayout.getLocation(); double mainX = point.getX(); double mainY = point.getY(); - + // 参数界面对坐标的影响 JForm jform = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if(jform.getFormDesign().getParaComponent() != null){ ey -= jform.getFormDesign().getParaHeight(); } - + //减掉tab布局的相对位置 ex -= mainX; ey -= mainY; @@ -280,10 +283,10 @@ public class XCardSwitchButton extends XButton { // 鼠标进入按钮右侧删除图标区域 double recX = position.getX() + titlePoint.getX() + (width - CLOSE_ICON_RIGHT_OFFSET); double recY = position.getY() + titlePoint.getY() + CLOSE_ICON_TOP_OFFSET; - + return (recX < ex && ex < recX + CLOSE_ICON_RIGHT_OFFSET && ey < recY && ey > position.getY()); } - + //将当前switchButton改为选中状态 private void changeButtonState(int index) { for (int i = 0; i < this.tagLayout.getComponentCount(); i++) { @@ -292,7 +295,7 @@ public class XCardSwitchButton extends XButton { tempButton.setShowButton(tempButton.getIndex() == index); } } - + @Override public void paintComponent(Graphics g) { super.paintComponent(g); @@ -305,12 +308,12 @@ public class XCardSwitchButton extends XButton { this.getContentBackground().paint(g, new Rectangle2D.Double(0, 0, panelSize.getWidth(), panelSize.getHeight())); drawCloseIcon(g2d); } - + //画删除图标 private void drawCloseIcon(Graphics2D g2d){ closeIcon.paintIcon(this, g2d, this.getWidth() - LEFT_GAP, 0); } - + //画背景 private void drawBackground(CardSwitchButton button, TitlePacker widgetTitle){ Background background = widgetTitle.getBackground() == null ? ColorBackground.getInstance(NORMAL_GRAL) : widgetTitle.getBackground(); @@ -328,7 +331,7 @@ public class XCardSwitchButton extends XButton { this.setContentBackground(initialBackground == null ? background : initialBackground); } } - + //画标题 private void drawTitle(CardSwitchButton button, TitlePacker widgetTitle) { String titleText = button.getText(); @@ -348,12 +351,12 @@ public class XCardSwitchButton extends XButton { BorderPacker style = this.cardLayout.toData().getBorderStyle(); return style.getTitle(); } - + //删除tab布局 private void deleteTabLayout(SelectionModel selectionModel, FormDesigner designer){ String titleName = this.getContentLabel().getText(); - int value = JOptionPane.showConfirmDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Confirm_Dialog_Content") + "“" + titleName + "”", - ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION); + int value = FineJOptionPane.showConfirmDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Confirm_Dialog_Content") + "“" + titleName + "”", + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION); if (value != JOptionPane.OK_OPTION) { return; } @@ -455,7 +458,8 @@ public class XCardSwitchButton extends XButton { StringBuilder titleStringBuf = new StringBuilder(); TitlePacker title = getWidgetTitle(); FRFont font = title.getFrFont(); - FRFont newFont = FRFont.getInstance(font.getName(), font.getStyle(), font.getSize() + FONT_SIZE_ADJUST); + int fontSize = font.getSize() + FONT_SIZE_ADJUST; + FRFont newFont = FRFont.getInstance(font.getName(), font.getStyle(), fontSize); FontMetrics fm = GraphHelper.getFontMetrics(newFont); for (int i = 0; i < titleText.length(); i++) { titleStringBuf.append(titleText.charAt(i)); @@ -469,12 +473,13 @@ public class XCardSwitchButton extends XButton { for (int i = 0; i < verticalTextList.size(); i++) { String paint_str = (String) verticalTextList.get(i); - GraphHelper.drawString(g2d, paint_str, (width - fm.stringWidth(paint_str)) / 2, textY); + GraphHelper.drawString(g2d, paint_str, + (width - fm.stringWidth(paint_str)) / (HALF_NUMBER * 1.0D), textY); textY += textHeight; textY += PT.pt2pix(0, RESLUTION); if (textY > height - textHeight && i < verticalTextList.size() - 1) { textY -= DOTS_HEIGHT; - paintDots(g2d, textY, (width - fm.stringWidth(paint_str)) / 2); + paintDots(g2d, textY, (width - fm.stringWidth(paint_str)) / HALF_NUMBER); break; } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java index edbabeadf3..c51fe491e4 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java @@ -16,7 +16,10 @@ import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWidgetCreator; +import com.fr.design.designer.properties.mobile.MobileBooKMarkUsePropertyUI; +import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.form.util.XCreatorConstants; +import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.icon.IconPathConstants; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.EditingMouseListener; @@ -512,4 +515,12 @@ public class XWCardMainBorderLayout extends XWBorderLayout { return true; } + @Override + public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { + if (FormDesignerUtils.isAppRelayout(WidgetPropertyPane.getInstance().getEditingFormDesigner())) { + return new WidgetPropertyUIProvider[] {new MobileBooKMarkUsePropertyUI(this)}; + } else { + return super.getWidgetPropertyUIProviders(); + } + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java index f2f58f17b3..f17ac09250 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java @@ -8,11 +8,15 @@ import com.fr.design.designer.creator.CRPropertyDescriptor; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.properties.mobile.MobileBooKMarkUsePropertyUI; +import com.fr.design.designer.properties.mobile.MobileBookMarkPropertyUI; +import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormHierarchyTreePane; +import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.widget.editors.ButtonTypeEditor; import com.fr.design.mainframe.widget.editors.ImgBackgroundEditor; import com.fr.design.utils.gui.LayoutUtils; @@ -589,7 +593,11 @@ public class XWTabFitLayout extends XWFitLayout { */ @Override public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { - return new WidgetPropertyUIProvider[0]; + if (FormDesignerUtils.isAppRelayout(WidgetPropertyPane.getInstance().getEditingFormDesigner())) { + return new WidgetPropertyUIProvider[] {new MobileBookMarkPropertyUI(this), new MobileBooKMarkUsePropertyUI(this)}; + } else { + return new WidgetPropertyUIProvider[0]; + } } @Override diff --git a/designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileBooKMarkUsePropertyUI.java b/designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileBooKMarkUsePropertyUI.java new file mode 100644 index 0000000000..6b6a773e9b --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileBooKMarkUsePropertyUI.java @@ -0,0 +1,36 @@ +package com.fr.design.designer.properties.mobile; + +import com.fr.design.designer.creator.XCreator; +import com.fr.design.dialog.BasicPane; +import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider; +import com.fr.design.gui.itable.AbstractPropertyTable; +import com.fr.design.widget.ui.designer.mobile.MobileBookMarkDefinePane; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/2/12 + */ +public class MobileBooKMarkUsePropertyUI extends AbstractWidgetPropertyUIProvider { + + private XCreator xCreator; + + public MobileBooKMarkUsePropertyUI(XCreator xCreator) { + this.xCreator = xCreator; + } + + @Override + public AbstractPropertyTable createWidgetAttrTable() { + return null; + } + + @Override + public BasicPane createWidgetAttrPane() { + return new MobileBookMarkDefinePane(xCreator); + } + + @Override + public String tableTitle() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Mobile_Attr"); + } +} diff --git a/designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileBookMarkPropertyUI.java b/designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileBookMarkPropertyUI.java new file mode 100644 index 0000000000..91451d81f4 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileBookMarkPropertyUI.java @@ -0,0 +1,36 @@ +package com.fr.design.designer.properties.mobile; + +import com.fr.design.designer.creator.XCreator; +import com.fr.design.dialog.BasicPane; +import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider; +import com.fr.design.gui.itable.AbstractPropertyTable; +import com.fr.design.widget.ui.designer.mobile.MobileAdvanceDefinePane; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/24 + */ +public class MobileBookMarkPropertyUI extends AbstractWidgetPropertyUIProvider { + + private XCreator xCreator; + + public MobileBookMarkPropertyUI(XCreator xCreator) { + this.xCreator = xCreator; + } + + @Override + public AbstractPropertyTable createWidgetAttrTable() { + return null; + } + + @Override + public BasicPane createWidgetAttrPane() { + return new MobileAdvanceDefinePane(xCreator); + } + + @Override + public String tableTitle() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Mobile_Attr"); + } +} 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 3ed29d0475..f61eb2f8a4 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 @@ -1,6 +1,8 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.DesignModelAdapter; import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.designer.beans.AdapterBus; @@ -8,25 +10,36 @@ import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.Painter; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.models.AddingModel; -import com.fr.design.designer.creator.*; +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.form.util.XCreatorConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.icon.IconPathConstants; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.utils.ComponentUtils; import com.fr.form.share.SharableEditorProvider; import com.fr.form.share.ShareLoader; +import com.fr.form.ui.ChartEditor; import com.fr.form.ui.SharableWidgetBindInfo; import com.fr.form.ui.Widget; - import com.fr.stable.Constants; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.JWindow; +import java.util.Map; +import java.awt.Color; +import java.awt.Component; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; import java.awt.dnd.DropTarget; import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.DropTargetEvent; -import java.util.Map; /** * 添加模式下鼠标事件处理器。 @@ -80,7 +93,9 @@ public class FormCreatorDropTarget extends DropTarget { //SetSelection时要确保选中的是最顶层的布局 //tab布局添加的时候是初始化了XWCardLayout,实际上最顶层的布局是XWCardMainBorderLayout XCreator addingXCreator = addingModel.getXCreator(); - Widget widget = (addingXCreator.getTopLayout() != null) ? (addingXCreator.getTopLayout().toData()) : addingXCreator.toData(); + Widget widget = (addingXCreator.getBackupParent() != null && addingXCreator.getTopLayout() != null) ? (addingXCreator.getTopLayout().toData()) : addingXCreator.toData(); + //图表埋点 + dealChartBuryingPoint(widget); if (addingXCreator.isShared()) { String shareId = addingXCreator.getShareId(); SharableEditorProvider sharableEditor = ShareLoader.getLoader().getSharedElCaseEditorById(shareId); @@ -242,6 +257,7 @@ public class FormCreatorDropTarget extends DropTarget { */ @Override public synchronized void dropActionChanged(DropTargetDragEvent dtde) { + //do nothing } /** @@ -266,4 +282,11 @@ public class FormCreatorDropTarget extends DropTarget { //针对在表单中拖入一个控件直接ctrl+s无反应 designer.requestFocus(); } + + private void dealChartBuryingPoint(Widget widget) { + if (widget instanceof ChartEditor) { + ChartCollection chartCollection = (ChartCollection)((ChartEditor) widget).getChartCollection(); + ChartInfoCollector.getInstance().collection(chartCollection.getSelectedChartProvider(ChartProvider.class), null); + } + } } 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 fbf52d021f..b94ad57dbb 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 @@ -37,6 +37,7 @@ 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.properties.FormWidgetAuthorityEditPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.event.DesignerOpenedListener; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.form.util.XCreatorConstants; @@ -388,8 +389,8 @@ public class FormDesigner extends TargetComponent
implements TreeSelection } private void addParaPaneTooltips() { - JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Please_Drag_ParaPane"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); + FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Please_Drag_ParaPane"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); } /** @@ -635,8 +636,8 @@ public class FormDesigner extends TargetComponent implements TreeSelection return false; } if (this.getTarget().isNameExist(newName)) { - JOptionPane.showMessageDialog(this, "\"" + newName + "\"" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Has_Been_Existed") - + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alert"), JOptionPane.WARNING_MESSAGE); + FineJOptionPane.showMessageDialog(this, "\"" + newName + "\"" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Has_Been_Existed") + + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); return false; } creator.resetCreatorName(newName); @@ -645,7 +646,7 @@ public class FormDesigner extends TargetComponent implements TreeSelection } public void showMessageDialog(String message) { - JOptionPane.showMessageDialog(this, message, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alert"), JOptionPane.WARNING_MESSAGE); + FineJOptionPane.showMessageDialog(this, message, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); FormSelectionUtils.rebuildSelection(this); repaint(); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormEditToolBar.java b/designer-form/src/main/java/com/fr/design/mainframe/FormEditToolBar.java index 275730d8ff..b5fac75e5a 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormEditToolBar.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormEditToolBar.java @@ -4,6 +4,7 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; @@ -287,7 +288,8 @@ public class FormEditToolBar extends BasicPane { if (i < 0 || !(listModel.getElementAt(i) instanceof FormToolBarButton)) { return; } - int val = JOptionPane.showConfirmDialog(FormEditToolBar.this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Are_You_Sure_To_Delete_The_Data") + "?", "Message", JOptionPane.YES_NO_OPTION); + int val = FineJOptionPane.showConfirmDialog(FormEditToolBar.this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Are_You_Sure_To_Delete_The_Data") + "?", + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION); if (val != JOptionPane.YES_OPTION) { return; } 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 9424a1f15e..cee0d5b90d 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 @@ -5,6 +5,7 @@ import com.fr.base.PaperSize; import com.fr.base.Parameter; import com.fr.base.extension.FileExtension; import com.fr.base.vcs.DesignerMode; +import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; import com.fr.design.actions.FormMobileAttrAction; import com.fr.design.actions.TemplateParameterAction; @@ -12,6 +13,7 @@ import com.fr.design.actions.core.WorkBookSupportable; import com.fr.design.actions.file.export.EmbeddedFormExportExportAction; import com.fr.design.base.mode.DesignModeContext; import com.fr.design.cell.FloatElementsProvider; +import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.designer.TargetComponent; import com.fr.design.designer.beans.actions.CopyAction; import com.fr.design.designer.beans.actions.CutAction; @@ -543,8 +545,12 @@ public class JForm extends JTemplate implements BaseJForm implements BaseJForm set = ExtraDesignClassManager.getInstance().getArray(WidgetPropertyUIProvider.XML_TAG); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/editors/ElementCaseToolBarPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/editors/ElementCaseToolBarPane.java index 4288d47caa..2e1564a2d2 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/editors/ElementCaseToolBarPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/editors/ElementCaseToolBarPane.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.widget.editors; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; @@ -98,7 +99,7 @@ public class ElementCaseToolBarPane extends BasicBeanPane northToolBar.validate(); northToolBar.repaint(); } else { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Choose_One_Button")); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Choose_One_Button")); } } }); @@ -123,7 +124,7 @@ public class ElementCaseToolBarPane extends BasicBeanPane southToolBar.validate(); southToolBar.repaint(); } else { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Choose_One_Button")); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Choose_One_Button")); } } }); diff --git a/designer-form/src/main/java/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java b/designer-form/src/main/java/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java index 8d43e08e29..9df0a32012 100644 --- a/designer-form/src/main/java/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java +++ b/designer-form/src/main/java/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java @@ -106,7 +106,6 @@ public class FormWidgetDefinePaneFactoryBase { defineMap.put(FreeButton.class, new Appearance(FreeButtonDefinePane.class, WidgetConstants.BUTTON + "")); defineMap.put(FormSubmitButton.class, new Appearance(FreeButtonDefinePane.class, WidgetConstants.BUTTON + "")); defineMap.put(WFitLayout.class, new Appearance(FRFitLayoutDefinePane.class, "wFitLayout")); - defineMap.put(WCardMainBorderLayout.class, new Appearance(WCardMainLayoutDefinePane.class, "wCardMainBorderLayout")); if (StableFactory.getMarkedClass(BridgeMark.CHART_EDITOR, AbstractBorderStyleWidget.class) != null) { defineMap.put(StableFactory.getMarkedClass(BridgeMark.CHART_EDITOR, AbstractBorderStyleWidget.class), new Appearance(BorderStyleWidgetDefinePane.class, "chartEditor")); } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/RadioDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/RadioDefinePane.java index 9117b5c517..140e294e08 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/RadioDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/RadioDefinePane.java @@ -11,6 +11,10 @@ import com.fr.general.FRFont; import javax.swing.*; import java.awt.*; +/** + * @deprecated + */ +@Deprecated public class RadioDefinePane extends AbstractDataModify { public RadioDefinePane(XCreator xCreator) { super(xCreator); diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java index 51811d7634..7ddff022f9 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java @@ -26,10 +26,10 @@ public class WidgetAbsoluteBoundPane extends WidgetBoundPane { @Override public void initBoundPane() { - x = new UIBoundSpinner(0, Integer.MAX_VALUE, 1); - y = new UIBoundSpinner(0, Integer.MAX_VALUE, 1); - width = new UIBoundSpinner(0, Integer.MAX_VALUE, 1); - height = new UIBoundSpinner(0, Integer.MAX_VALUE, 1); + x = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d); + y = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d); + width = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d); + height = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d); x.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size")); y.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size")); width.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size")); diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java index 26861e7ecc..c9928759bf 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java @@ -56,8 +56,8 @@ public class WidgetBoundPane extends BasicPane { } public void initBoundPane() { - width = new UIBoundSpinner(0, Integer.MAX_VALUE, 1); - height = new UIBoundSpinner(0, Integer.MAX_VALUE, 1); + width = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d); + height = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d); width.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size")); height.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size")); if (creator.acceptType(XWCardLayout.class)) { diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/BodyMobileDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/BodyMobileDefinePane.java index bfd0ea7ea7..8327fc1ab7 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/BodyMobileDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/BodyMobileDefinePane.java @@ -11,6 +11,7 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.MobileWidgetListPane; import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.widget.ui.designer.mobile.component.MobileBookMarkSettingPane; import com.fr.design.widget.ui.designer.mobile.component.MobileComponentFrozenPane; import com.fr.design.widget.ui.designer.mobile.component.MobileComponentMarginPane; import com.fr.design.widget.ui.designer.mobile.component.MobileComponentLayoutIntervalPane; @@ -34,6 +35,7 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane { private MobileComponentMarginPane marginPane; private MobileComponentLayoutIntervalPane intervalPane; private MobileComponentFrozenPane frozenPane; + private MobileBookMarkSettingPane bookMarkSettingPane; private UIExpandablePane advancePane; private UIExpandablePane layoutPane; @@ -96,10 +98,14 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane { marginPane = new MobileComponentMarginPane(FormBodyPaddingAttrMark.XML_TAG); intervalPane = new MobileComponentLayoutIntervalPane(FormBodyPaddingAttrMark.XML_TAG); frozenPane = new MobileComponentFrozenPane(); + bookMarkSettingPane = new MobileBookMarkSettingPane(); JPanel wrapLayoutPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel wrapAdvancePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); wrapLayoutPane.add(intervalPane, BorderLayout.NORTH); wrapLayoutPane.add(frozenPane, BorderLayout.CENTER); - advancePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, marginPane); + wrapAdvancePane.add(marginPane, BorderLayout.CENTER); + wrapAdvancePane.add(bookMarkSettingPane, BorderLayout.SOUTH); + advancePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, wrapAdvancePane); layoutPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout"), 280, 20, wrapLayoutPane); //高级 holder.add(advancePane, BorderLayout.CENTER); @@ -109,8 +115,9 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane { boolean flag = !shouldHidePadding(designer); advancePane.setVisible(flag); layoutPane.setVisible(flag); - frozenPane.setVisible(appRelayoutCheck.isSelected()); - + boolean appRelayout = FormDesignerUtils.isAppRelayout(designer); + frozenPane.setVisible(appRelayout); + bookMarkSettingPane.setVisible(appRelayout); return holder; } @@ -147,13 +154,15 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane { @Override public void populate(FormDesigner designer) { this.designer = designer; + XCreator xCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); appRelayoutCheck.setSelected(FormDesignerUtils.isAppRelayout(designer)); // 数据 populate 完成后,再设置监听 this.bindListeners2Widgets(); this.addAttributeChangeListener(changeListener); marginPane.populate((RichStyleWidgetProvider) getBodyCreator().toData()); intervalPane.populate((RichStyleWidgetProvider) getBodyCreator().toData()); - frozenPane.populate(designer.getSelectionModel().getSelection().getSelectedCreator()); + frozenPane.populate(xCreator); + bookMarkSettingPane.populate(xCreator); } @Override @@ -164,6 +173,7 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane { advancePane.setVisible(appPaddingVisible); layoutPane.setVisible(appPaddingVisible); frozenPane.setVisible(appRelayout); + bookMarkSettingPane.setVisible(appRelayout); mobileWidgetListPane.updateToDesigner(); designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); @@ -174,7 +184,9 @@ public class BodyMobileDefinePane extends MobileWidgetDefinePane { intervalPane.update((RichStyleWidgetProvider) getBodyCreator().toData()); } if (appRelayout) { - frozenPane.update(designer.getSelectionModel().getSelection().getSelectedCreator()); + XCreator xCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); + frozenPane.update(xCreator); + bookMarkSettingPane.update(xCreator); } } } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java index ed97fc0ee8..7427a0281b 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java @@ -20,7 +20,11 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.mainframe.mobile.ui.MobileCollapsedStylePane; +import com.fr.design.mainframe.mobile.ui.MobileComboBoxDialogEditor; import com.fr.form.ui.BaseChartEditor; +import com.fr.form.ui.ChartEditor; +import com.fr.form.ui.mobile.MobileCollapsedStyle; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -49,6 +53,7 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane { private UILabel tipLabel; private UICheckBox allowFullCheckBox;//允许全屏 private UICheckBox functionalWhenUnactivatedCheckBox;//组件未激活时可使用组件内功能 + private MobileComboBoxDialogEditor mobileCollapsedStyleEditor; public ChartEditorDefinePane(XCreator xCreator) { this.xCreator = xCreator; @@ -88,9 +93,9 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane { unavailableTipLabel.setForeground(Color.gray); panel.add(unavailableTipLabel, BorderLayout.NORTH); allowFullCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Allow_Full_Screen")); - panel.add(allowFullCheckBox); - functionalWhenUnactivatedCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Functional_When_Unactivated")); - panel.add(functionalWhenUnactivatedCheckBox); + panel.add(allowFullCheckBox,BorderLayout.CENTER); + functionalWhenUnactivatedCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Functional_When_Unactivated"), true); + panel.add(functionalWhenUnactivatedCheckBox, BorderLayout.SOUTH); return panel; } @@ -101,11 +106,18 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane { tipLabel.setForeground(Color.gray); updateTipLabel(); allowFullCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Allow_Full_Screen")); - functionalWhenUnactivatedCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Functional_When_Unactivated")); + functionalWhenUnactivatedCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Functional_When_Unactivated"), true); + mobileCollapsedStyleEditor = new MobileComboBoxDialogEditor(new MobileCollapsedStylePane()) { + @Override + protected void firePropertyChanged() { + ChartEditorDefinePane.this.update(); + } + }; Component[][] components = new Component[][]{ new Component[] {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Zoom_In_Logic"), SwingConstants.LEFT), new UILabel(ChartMobileFitAttrState.PROPORTION.description())}, new Component[] {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Zoom_Out_Logic"), SwingConstants.LEFT), zoomOutComboBox}, + new Component[] {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Collapse_Expand")), mobileCollapsedStyleEditor}, new Component[] {tipLabel, null}, new Component[] {allowFullCheckBox, null}, new Component[] {functionalWhenUnactivatedCheckBox, null} @@ -113,9 +125,9 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; - double[] rowSize = {p, p, p, p, p}; + double[] rowSize = {p, p, p, p, p, p}; double[] columnSize = {p,f}; - int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; + int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 30, LayoutConstants.VGAP_LARGE); panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); final JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); @@ -186,6 +198,10 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane { } } }); + + MobileCollapsedStyle style = ((ChartEditor) xCreator.toData()).getMobileCollapsedStyle(); + this.mobileCollapsedStyleEditor.setStyle(style); + this.mobileCollapsedStyleEditor.setSelected(style.isCollapsedWork()); } @Override @@ -200,6 +216,11 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane { mobileAttr.setAllowFullScreen(allowFullCheckBox.isSelected()); mobileAttr.setFunctionalWhenUnactivated(!functionalWhenUnactivatedCheckBox.isSelected()); } + MobileCollapsedStyle style = this.mobileCollapsedStyleEditor.getStyle(); + if (style != null) { + ((ChartEditor) xCreator.toData()).setMobileCollapsedStyle(style); + style.setCollapsedWork(this.mobileCollapsedStyleEditor.isSelectedCustom()); + } DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); // 触发设计器保存按钮亮起来 } } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java index 9a87003632..31c29d72e5 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java @@ -3,8 +3,11 @@ package com.fr.design.widget.ui.designer.mobile; import com.fr.base.mobile.MobileFitAttrState; import com.fr.design.constants.LayoutConstants; import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XWAbsoluteBodyLayout; +import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.properties.items.Item; import com.fr.design.foldablepane.UIExpandablePane; +import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; @@ -16,16 +19,18 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.mainframe.mobile.ui.MobileCollapsedStyleExpandPane; +import com.fr.design.mainframe.mobile.ui.MobileComboBoxDialogEditor; import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.ui.mobile.MobileCollapsedStyle; import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.SwingConstants; -import java.awt.BorderLayout; -import java.awt.Component; +import java.awt.*; /** * 报表块-移动端属性面板 @@ -51,6 +56,7 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane { private AttributeChangeListener changeListener; private UICheckBox allowFullCheckBox; private UICheckBox functionalWhenUnactivatedCheckBox; + private MobileComboBoxDialogEditor mobileCollapsedStyleEditor; public ElementCaseDefinePane(XCreator xCreator) { this.xCreator = xCreator; @@ -88,11 +94,19 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane { allowFullCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Allow_Full_Screen")); - functionalWhenUnactivatedCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Functional_When_Unactivated")); + functionalWhenUnactivatedCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Functional_When_Unactivated"), true); + + mobileCollapsedStyleEditor = new MobileComboBoxDialogEditor(new MobileCollapsedStyleExpandPane()) { + @Override + protected void firePropertyChanged() { + ElementCaseDefinePane.this.update(); + } + }; Component[][] components = new Component[][]{ new Component[] {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Mobile_Horizontal"), SwingConstants.LEFT), hComboBox}, new Component[] {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Mobile_Vertical"), SwingConstants.LEFT), vComboBox}, + createComponents(), new Component[] {heightRestrictCheckBox, null}, new Component[] {allowFullCheckBox, null}, new Component[] {functionalWhenUnactivatedCheckBox, null}, @@ -100,9 +114,9 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane { }; double f = TableLayout.FILL; double p = TableLayout.PREFERRED; - double[] rowSize = {p, p, p, p, p, p}; + double[] rowSize = {p, p, p, p, p, p, p}; double[] columnSize = {p, f}; - int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; + int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 30, LayoutConstants.VGAP_LARGE); panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); final JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); @@ -114,6 +128,23 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane { this.repaint(); } + private Component[] createComponents() { + return FormDesignerUtils.isAppRelayout(designer) && !isInAbsoluteLayout() ? + new Component[] {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Collapse_Expand")), mobileCollapsedStyleEditor} : + new Component[0]; + } + + private boolean isInAbsoluteLayout() { + Container parent = xCreator.getParent(); + while (parent != null) { + if (parent instanceof XWAbsoluteLayout && !(parent instanceof XWAbsoluteBodyLayout)) { + return true; + } + parent = parent.getParent(); + } + return false; + } + private void bingListeners2Widgets() { reInitAllListeners(); this.changeListener = new AttributeChangeListener() { @@ -144,6 +175,8 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane { this.maxHeightSpinner.setValue(elementCaseEditor.getHeightPercent()); this.allowFullCheckBox.setSelected(elementCaseEditor.isAllowFullScreen()); this.functionalWhenUnactivatedCheckBox.setSelected(!elementCaseEditor.isFunctionalWhenUnactivated()); + this.mobileCollapsedStyleEditor.setStyle(elementCaseEditor.getMobileCollapsedStyle()); + this.mobileCollapsedStyleEditor.setSelected(elementCaseEditor.getMobileCollapsedStyle().isCollapsedWork()); } @Override @@ -172,6 +205,11 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane { case "functionalWhenUnactivatedCheckBox": ((ElementCaseEditor) xCreator.toData()).setFunctionalWhenUnactivated(!functionalWhenUnactivatedCheckBox.isSelected()); } + MobileCollapsedStyle style = this.mobileCollapsedStyleEditor.getStyle(); + if (style != null) { + style.setCollapsedWork(this.mobileCollapsedStyleEditor.isSelectedCustom()); + ((ElementCaseEditor) xCreator.toData()).setMobileCollapsedStyle(style); + } } private void setGlobalNames() { diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java new file mode 100644 index 0000000000..587ea53950 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java @@ -0,0 +1,193 @@ +package com.fr.design.widget.ui.designer.mobile; + +import com.fr.design.constants.LayoutConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.foldablepane.UIExpandablePane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.form.main.Form; +import com.fr.form.ui.FormWidgetHelper; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WLayout; +import com.fr.form.ui.container.WSortLayout; +import com.fr.form.ui.mobile.MobileBookMark; +import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.util.Iterator; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/24 + */ +public class MobileAdvanceDefinePane extends MobileWidgetDefinePane { + + private XCreator xCreator; + private UICheckBox useBookMarkCheck; + private UITextField bookMarkNameField; + + public MobileAdvanceDefinePane(XCreator xCreator) { + this.xCreator = xCreator; + } + + @Override + public void initPropertyGroups(Object source) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.useBookMarkCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Use_BookMark"), false); + this.bookMarkNameField = new UITextField() { + @Override + protected void initListener() { + if (shouldResponseChangeListener()) { + addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + attributeChange(); + } + }); + addKeyListener(new KeyAdapter() { + @Override + public void keyTyped(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + attributeChange(); + } + } + }); + } + } + }; + JPanel useBookMarkPane = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{useBookMarkCheck}}, + TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.HGAP_LARGE); + final JPanel bookMarkNamePane = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{new UILabel( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark_Name")), bookMarkNameField}}, + TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.HGAP_LARGE); + this.useBookMarkCheck.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + boolean selected = MobileAdvanceDefinePane.this.useBookMarkCheck.isSelected(); + Widget widget = MobileAdvanceDefinePane.this.xCreator.toData(); + MobileBookMark bookMark = widget.getMobileBookMark(); + bookMarkNamePane.setVisible(selected); + if (selected && StringUtils.isEmpty(bookMark.getBookMarkName())) { + String name = widget.getWidgetName(); + MobileAdvanceDefinePane.this.bookMarkNameField.setText(name); + bookMark.setBookMarkName(name); + } + } + }); + bookMarkNamePane.setVisible(xCreator.toData().getMobileBookMark().isUseBookMark()); + contentPane.add(useBookMarkPane, BorderLayout.NORTH); + contentPane.add(bookMarkNamePane, BorderLayout.CENTER); + UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark"), 280, 20, contentPane); + JPanel wrapPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + wrapPane.add(uiExpandablePane, BorderLayout.NORTH); + this.add(wrapPane, BorderLayout.NORTH); + initData(); + } + + private void initData() { + MobileBookMark bookMark = xCreator.toData().getMobileBookMark(); + String bookMarkName = bookMark.getBookMarkName(); + if (StringUtils.isEmpty(bookMarkName)) { + String widgetName = xCreator.toData().getWidgetName(); + this.bookMarkNameField.setText(widgetName); + bookMark.setBookMarkName(widgetName); + } else { + this.bookMarkNameField.setText(bookMarkName); + } + } + + private void bindListeners2Widgets() { + reInitAllListeners(); + AttributeChangeListener changeListener = new AttributeChangeListener() { + @Override + public void attributeChange() { + update(); + } + }; + this.addAttributeChangeListener(changeListener); + } + + private void reInitAllListeners() { + initListener(this); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(super.getPreferredSize().width, 80); + } + + @Override + public Dimension getMaximumSize() { + return new Dimension(400, 200); + } + + @Override + public void populate(FormDesigner designer) { + MobileBookMark bookMark = xCreator.toData().getMobileBookMark(); + this.bookMarkNameField.setText(bookMark.getBookMarkName()); + if (bookMark.isFrozen()) { + this.useBookMarkCheck.setSelected(false); + this.useBookMarkCheck.setEnabled(false); + } else { + this.useBookMarkCheck.setSelected(bookMark.isUseBookMark()); + } + this.bindListeners2Widgets(); + } + + @Override + public void update() { + MobileBookMark bookMark = xCreator.toData().getMobileBookMark(); + bookMark.setUseBookMark(this.useBookMarkCheck.isSelected()); + String newBookMarkName = this.bookMarkNameField.getText(); + DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); + if (ComparatorUtils.equals(newBookMarkName, bookMark.getBookMarkName())) { + return; + } + if (!isExist(newBookMarkName)) { + bookMark.setBookMarkName(newBookMarkName); + } else { + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark_Rename_Failure"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Joption_News"), + JOptionPane.ERROR_MESSAGE, IOUtils.readIcon("com/fr/design/form/images/joption_failure.png")); + this.bookMarkNameField.setText(bookMark.getBookMarkName()); + } + } + + private boolean isExist(String name) { + Form form = WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget(); + WLayout container = form.getContainer(); + WSortLayout wSortLayout = (WSortLayout) container.getWidget(container.getWidgetCount() - 1); + Iterator iterator = wSortLayout.getMobileWidgetIterator(); + while (iterator.hasNext()) { + Widget widget = form.getWidgetByName(iterator.next()); + if (widget != null && ComparatorUtils.equals(widget.getMobileBookMark().getBookMarkName(), name)) { + return true; + } + } + return false; + } + +} diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileBookMarkDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileBookMarkDefinePane.java new file mode 100644 index 0000000000..4a53d2971e --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileBookMarkDefinePane.java @@ -0,0 +1,62 @@ +package com.fr.design.widget.ui.designer.mobile; + +import com.fr.design.designer.creator.XCreator; +import com.fr.design.foldablepane.UIExpandablePane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.widget.ui.designer.mobile.component.MobileBookMarkUsePane; + +import javax.swing.JPanel; +import java.awt.BorderLayout; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/2/12 + */ +public class MobileBookMarkDefinePane extends MobileWidgetDefinePane { + + private XCreator xCreator; + private MobileBookMarkUsePane mobileBookMarkUsePane; + + public MobileBookMarkDefinePane(XCreator xCreator) { + this.xCreator = xCreator; + } + + @Override + public void initPropertyGroups(Object source) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.mobileBookMarkUsePane = new MobileBookMarkUsePane(); + UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, mobileBookMarkUsePane); + panel.add(uiExpandablePane); + this.add(panel, BorderLayout.NORTH); + } + + private void bindListeners2Widgets() { + reInitAllListeners(); + AttributeChangeListener changeListener = new AttributeChangeListener() { + @Override + public void attributeChange() { + update(); + } + }; + this.addAttributeChangeListener(changeListener); + } + + private void reInitAllListeners() { + initListener(this); + } + + @Override + public void populate(FormDesigner designer) { + this.mobileBookMarkUsePane.populate(xCreator); + this.bindListeners2Widgets(); + } + + @Override + public void update() { + this.mobileBookMarkUsePane.update(xCreator); + } +} diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileWidgetStyleDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileWidgetStyleDefinePane.java index fb6f81fe58..d96be00836 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileWidgetStyleDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileWidgetStyleDefinePane.java @@ -66,7 +66,7 @@ public class MobileWidgetStyleDefinePane extends MobileWidgetDefinePane { @Override public Dimension getMaximumSize() { - return new Dimension(400, 200); + return new Dimension(400, 30); } private void bindListeners2Widgets() { diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkSettingPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkSettingPane.java new file mode 100644 index 0000000000..5f3f3663ed --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkSettingPane.java @@ -0,0 +1,100 @@ +package com.fr.design.widget.ui.designer.mobile.component; + +import com.fr.design.constants.LayoutConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.gui.icheckbox.UICheckBox; +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.WidgetPropertyPane; +import com.fr.design.mainframe.mobile.ui.MobileBookMarkStylePane; +import com.fr.design.mainframe.widget.accessibles.UneditableAccessibleEditor; +import com.fr.design.mainframe.widget.wrappers.MobileBookMarkStyleWrapper; +import com.fr.form.ui.container.WSortLayout; +import com.fr.form.ui.mobile.MobileBookMarkStyle; + +import javax.swing.*; +import java.awt.*; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2019/12/18 + */ +public class MobileBookMarkSettingPane extends BasicPane { + + private AccessibleMobileBookMarkStyleEditor mobileBookMarkStyleEditor; + private MobileBookMarkUsePane showBookMarkPane; + + public MobileBookMarkSettingPane() { + initComponent(); + } + + private void initComponent() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.mobileBookMarkStyleEditor = new AccessibleMobileBookMarkStyleEditor(new MobileBookMarkStylePane()); + JPanel booKMarkPane = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText( + "Fine-Design_Mobile_BookMark_Style")), this.mobileBookMarkStyleEditor}}, + TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.HGAP_LARGE + ); + this.showBookMarkPane = new MobileBookMarkUsePane(); + JPanel wrapPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + wrapPane.add(booKMarkPane, BorderLayout.NORTH); + wrapPane.add(showBookMarkPane, BorderLayout.CENTER); + this.add(wrapPane, BorderLayout.CENTER); + } + + @Override + protected String title4PopupWindow() { + return "MobileBookMarkSettingPane"; + } + + public void populate(XCreator xCreator) { + WSortLayout wSortLayout = ((WSortLayout) xCreator.toData()); + this.mobileBookMarkStyleEditor.setValue(wSortLayout.getMobileBookMarkStyle()); + this.showBookMarkPane.populate(xCreator); + } + + public void update(XCreator xCreator) { + WSortLayout wSortLayout = ((WSortLayout) xCreator.toData()); + wSortLayout.setMobileBookMarkStyle((MobileBookMarkStyle) mobileBookMarkStyleEditor.getValue()); + this.showBookMarkPane.update(xCreator); + } + + + class AccessibleMobileBookMarkStyleEditor extends UneditableAccessibleEditor { + + private MobileBookMarkStylePane mobileBookMarkStylePane; + + public AccessibleMobileBookMarkStyleEditor(MobileBookMarkStylePane mobileBookMarkStylePane) { + super(new MobileBookMarkStyleWrapper()); + this.mobileBookMarkStylePane = mobileBookMarkStylePane; + } + + @Override + public void showEditorPane() { + mobileBookMarkStylePane.setPreferredSize(BasicDialog.MEDIUM); + BasicDialog dialog = mobileBookMarkStylePane.showWindow(SwingUtilities.getWindowAncestor(this)); + dialog.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + MobileBookMarkStyle mobileBookMarkStyle = mobileBookMarkStylePane.updateBean(); + WSortLayout wSortLayout = (WSortLayout) WidgetPropertyPane.getInstance().getEditingFormDesigner().getSelectionModel().getSelection().getSelectedCreator().toData(); + setValue(mobileBookMarkStyle); + wSortLayout.setMobileBookMarkStyle(mobileBookMarkStyle); + fireStateChanged(); + } + }); + mobileBookMarkStylePane.populateBean((MobileBookMarkStyle) getValue()); + dialog.setVisible(true); + } + } + + +} \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkUsePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkUsePane.java new file mode 100644 index 0000000000..7038330697 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkUsePane.java @@ -0,0 +1,87 @@ +package com.fr.design.widget.ui.designer.mobile.component; + +import com.fr.design.designer.IntervalConstants; +import com.fr.design.designer.beans.events.DesignerEvent; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.icheckbox.UICheckBox; +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.WidgetPropertyPane; +import com.fr.form.ui.container.WLayout; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/2/12 + */ +public class MobileBookMarkUsePane extends BasicPane { + + private UICheckBox showHierarchicalBookmarksCheck; + + public MobileBookMarkUsePane() { + initComponent(); + } + + + private void initComponent() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.showHierarchicalBookmarksCheck = new UICheckBox( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Show_BookMark"), true) { + @Override + protected void initListener() { + this.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + attributeChange(); + } + }); + } + }; + UILabel hintLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Show_BookMark_Hint")); + hintLabel.setForeground(Color.GRAY); + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p}; + double[] columnSize = {f}; + int[][] rowCount = {{1}, {1}}; + Component[][] components = new Component[][]{ + new Component[]{this.showHierarchicalBookmarksCheck}, + new Component[]{hintLabel} + }; + JPanel wrapPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel showBookMarkPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, + IntervalConstants.INTERVAL_L1, + IntervalConstants.INTERVAL_L1); + showBookMarkPane.setBorder( + BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0)); + wrapPane.add(showBookMarkPane, BorderLayout.CENTER); + this.add(showBookMarkPane, BorderLayout.CENTER); + } + + public void populate(XCreator xCreator) { + WLayout wLayout = ((WLayout) xCreator.toData()); + this.showHierarchicalBookmarksCheck.setSelected(wLayout.isShowBookmarks()); + } + + public void update(XCreator xCreator) { + WLayout wLayout = ((WLayout) xCreator.toData()); + wLayout.setShowBookmarks(showHierarchicalBookmarksCheck.isSelected()); + WidgetPropertyPane.getInstance().getEditingFormDesigner().getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); + } + + @Override + protected String title4PopupWindow() { + return "MobileBookMarkUsePane"; + } +} diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentFrozenPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentFrozenPane.java index 0d5ce4b711..2492650972 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentFrozenPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentFrozenPane.java @@ -11,6 +11,7 @@ import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; +import com.fr.form.ui.FormWidgetHelper; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WSortLayout; import com.fr.stable.ArrayUtils; @@ -63,13 +64,26 @@ public class MobileComponentFrozenPane extends BasicPane { public void update(XCreator xCreator) { List selected = new ArrayList<>(); WSortLayout wSortLayout = ((WSortLayout) xCreator.toData()); + List all = wSortLayout.getNonContainerWidgetList(); + for (String widgetName : all) { + updateMobileBookMark(wSortLayout, widgetName, false); + } Object[] values = uiComboCheckBox.getSelectedValues(); - for (Object widgetName : values) { - selected.add((String) widgetName); + for (Object value : values) { + String widgetName = (String) value; + selected.add(widgetName); + updateMobileBookMark(wSortLayout, widgetName, true); } wSortLayout.updateFrozenWidgets(selected); } + private void updateMobileBookMark(WSortLayout wSortLayout, String widgetName, boolean frozen) { + Widget widget = FormWidgetHelper.findWidgetWithBound(wSortLayout, widgetName); + if (widget != null) { + widget.getMobileBookMark().setFrozen(frozen); + } + } + public void populate(XCreator xCreator) { WSortLayout wSortLayout = ((WSortLayout) xCreator.toData()); List all = wSortLayout.getNonContainerWidgetList(); diff --git a/designer-form/src/test/java/com/fr/design/mainframe/JFormTest.java b/designer-form/src/test/java/com/fr/design/mainframe/JFormTest.java new file mode 100644 index 0000000000..f419ef7203 --- /dev/null +++ b/designer-form/src/test/java/com/fr/design/mainframe/JFormTest.java @@ -0,0 +1,20 @@ +package com.fr.design.mainframe; + +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; + +public class JFormTest { + + @Test + public void testRun() { + + JForm mockForm = EasyMock.partialMockBuilder(JForm.class).addMockedMethod("getUndoManager").createMock(); + try { + mockForm.canUndo(); + } catch (Exception e) { + Assert.fail(); + } + } + +} \ No newline at end of file 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 3ea8d984b2..66870ff6fe 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 @@ -9,9 +9,13 @@ 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; +import java.awt.*; + public class NewPresentAction extends PresentCheckBoxAction { private String itemName = null; @@ -28,10 +32,28 @@ public class NewPresentAction extends PresentCheckBoxAction { if (!ComparatorUtils.equals(this.itemName, "NOPRESENT")) { CellElementPropertyPane.getInstance().GoToPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Present"), this.itemName); } else { - TemplateCellElement ce = getSelectedCellElement(); - // 只有原来ce设置了形态的情况下才有undo操作 - if (ce != null && ce.getPresent() != null) { - ce.setPresent(null); + ElementCasePane ePane = this.getEditingComponent(); + TemplateElementCase elementCase = ePane.getEditingElementCase(); + Selection sel = ePane.getSelection(); + if (sel instanceof CellSelection) { + CellSelection cs = (CellSelection) sel; + int cellRectangleCount = cs.getCellRectangleCount(); + for (int rect = 0; rect < cellRectangleCount; rect++) { + Rectangle cellRectangle = cs.getCellRectangle(rect); + for (int j = 0; j < cellRectangle.height; j++) { + for (int i = 0; i < cellRectangle.width; i++) { + int column = i + cellRectangle.x; + int row = j + cellRectangle.y; + TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); + if (cellElement == null) { + cellElement = new DefaultTemplateCellElement(column, row); + elementCase.addCellElement(cellElement); + } else if (cellElement.getPresent() != null) { + cellElement.setPresent(null); + } + } + } + } return true; } else { return false; diff --git a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java index b8f05c2e4a..39b11d4c2a 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java @@ -17,7 +17,6 @@ import com.fr.design.menu.MenuKeySet; import com.fr.design.module.DesignModuleFactory; import com.fr.grid.Grid; import com.fr.grid.selection.FloatSelection; -import com.fr.log.FineLoggerFactory; import com.fr.report.ReportHelper; import com.fr.report.cell.FloatElement; import com.fr.report.elementcase.TemplateElementCase; @@ -86,43 +85,39 @@ public class ChartFloatAction extends ElementCaseAction { public void doOk() { isRecordNeeded = true; FloatElement newFloatElement; - try { - newFloatElement = new FloatElement(chartDialog.getChartCollection().clone()); - newFloatElement.setWidth(new OLDPIX(BaseChartCollection.CHART_DEFAULT_WIDTH)); - newFloatElement.setHeight(new OLDPIX(BaseChartCollection.CHART_DEFAULT_HEIGHT)); - - Grid grid = reportPane.getGrid(); - TemplateElementCase report = reportPane.getEditingElementCase(); - DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); - DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); - int horizentalScrollValue = grid.getHorizontalValue(); - int verticalScrollValue = grid.getVerticalValue(); - - int resolution = grid.getResolution(); - int floatWdith = newFloatElement.getWidth().toPixI(resolution); - int floatHeight = newFloatElement.getWidth().toPixI(resolution); - - int leftDifference = (grid.getWidth() - floatWdith) > 0 ? (grid.getWidth() - floatWdith) : 0; - int topDifference = (grid.getHeight() - floatHeight) > 0 ? (grid.getHeight() - floatHeight) : 0; - FU evtX_fu = FU.valueOfPix((leftDifference) / 2, resolution); - FU evtY_fu = FU.valueOfPix((topDifference) / 2, resolution); - - FU leftDistance = FU.getInstance(evtX_fu.toFU() + columnWidthList.getRangeValue(0, horizentalScrollValue).toFU()); - FU topDistance = FU.getInstance(evtY_fu.toFU() + rowHeightList.getRangeValue(0, verticalScrollValue).toFU()); - - newFloatElement.setLeftDistance(leftDistance); - newFloatElement.setTopDistance(topDistance); - - Style style = newFloatElement.getStyle(); - if (style != null) { - newFloatElement.setStyle(style.deriveBorder(Constants.LINE_NONE, Color.black, Constants.LINE_NONE, Color.black, Constants.LINE_NONE, Color.black, Constants.LINE_NONE, Color.black)); - } - reportPane.getEditingElementCase().addFloatElement(newFloatElement); - reportPane.setSelection(new FloatSelection(newFloatElement.getName())); - reportPane.fireSelectionChangeListener(); - } catch (CloneNotSupportedException e) { - FineLoggerFactory.getLogger().error("Error in Float"); + newFloatElement = new FloatElement(chartDialog.getChartCollection()); + newFloatElement.setWidth(new OLDPIX(BaseChartCollection.CHART_DEFAULT_WIDTH)); + newFloatElement.setHeight(new OLDPIX(BaseChartCollection.CHART_DEFAULT_HEIGHT)); + + Grid grid = reportPane.getGrid(); + TemplateElementCase report = reportPane.getEditingElementCase(); + DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); + DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); + int horizentalScrollValue = grid.getHorizontalValue(); + int verticalScrollValue = grid.getVerticalValue(); + + int resolution = grid.getResolution(); + int floatWdith = newFloatElement.getWidth().toPixI(resolution); + int floatHeight = newFloatElement.getWidth().toPixI(resolution); + + int leftDifference = (grid.getWidth() - floatWdith) > 0 ? (grid.getWidth() - floatWdith) : 0; + int topDifference = (grid.getHeight() - floatHeight) > 0 ? (grid.getHeight() - floatHeight) : 0; + FU evtX_fu = FU.valueOfPix((leftDifference) / 2, resolution); + FU evtY_fu = FU.valueOfPix((topDifference) / 2, resolution); + + FU leftDistance = FU.getInstance(evtX_fu.toFU() + columnWidthList.getRangeValue(0, horizentalScrollValue).toFU()); + FU topDistance = FU.getInstance(evtY_fu.toFU() + rowHeightList.getRangeValue(0, verticalScrollValue).toFU()); + + newFloatElement.setLeftDistance(leftDistance); + newFloatElement.setTopDistance(topDistance); + + Style style = newFloatElement.getStyle(); + if (style != null) { + newFloatElement.setStyle(style.deriveBorder(Constants.LINE_NONE, Color.black, Constants.LINE_NONE, Color.black, Constants.LINE_NONE, Color.black, Constants.LINE_NONE, Color.black)); } + reportPane.getEditingElementCase().addFloatElement(newFloatElement); + reportPane.setSelection(new FloatSelection(newFloatElement.getName())); + reportPane.fireSelectionChangeListener(); } }); diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java b/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java index e97a92b4d1..f3cea39410 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java +++ b/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java @@ -88,7 +88,7 @@ public class BiasTextPainterCellEditor extends AbstractCellEditor { Window parentWindow = SwingUtilities.getWindowAncestor(grid); this.biasTextPainterPane = new BiasTextPainterPane(); Dimension dimension = this.biasTextPainterPane.getPreferredSize(); - Dimension wrapDimension = new Dimension((int) (dimension.width * MULTIPLE), (int) (dimension.height * MULTIPLE)); + Dimension wrapDimension = new Dimension((int) (dimension.width * MULTIPLE), (int) (dimension.height * Math.pow(MULTIPLE, 2))); this.biasTextPainterPane.populate(biasTextPainter); return this.biasTextPainterPane.showWindowWithCustomSize(parentWindow, new DialogActionAdapter() { diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/DSColumnCellEditor.java b/designer-realize/src/main/java/com/fr/design/cell/editor/DSColumnCellEditor.java index 5f3ae97f1e..a7fb154e05 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/DSColumnCellEditor.java +++ b/designer-realize/src/main/java/com/fr/design/cell/editor/DSColumnCellEditor.java @@ -3,6 +3,7 @@ package com.fr.design.cell.editor; import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionListener; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dscolumn.DSColumnPane; import com.fr.design.mainframe.ElementCasePane; import com.fr.grid.Grid; @@ -71,8 +72,8 @@ public class DSColumnCellEditor extends AbstractCellEditor implements DialogActi try { this.dsColumnPane.populate(DesignTableDataManager.getEditingTableDataSource(), cellElement); } catch (Exception exp) { - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(grid), exp.getMessage(), - ProductConstants.APP_NAME, JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(grid), exp.getMessage(), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE); FineLoggerFactory.getLogger().error(exp.getMessage(), exp); } diff --git a/designer-realize/src/main/java/com/fr/design/headerfooter/HFContainer.java b/designer-realize/src/main/java/com/fr/design/headerfooter/HFContainer.java index 577a0710b3..1726b21c27 100644 --- a/designer-realize/src/main/java/com/fr/design/headerfooter/HFContainer.java +++ b/designer-realize/src/main/java/com/fr/design/headerfooter/HFContainer.java @@ -24,6 +24,7 @@ import javax.swing.event.ChangeListener; import com.fr.base.headerfooter.HFElement; import com.fr.base.headerfooter.NewLineHFElement; +import com.fr.design.dialog.FineJOptionPane; /** @@ -283,7 +284,7 @@ public class HFContainer extends JPanel implements Scrollable { Object obj = evt.getSource(); if (obj instanceof HFComponent) { - int returnVal = JOptionPane.showConfirmDialog( + int returnVal = FineJOptionPane.showConfirmDialog( SwingUtilities.getWindowAncestor(HFContainer.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_HF_Are_You_Sure_To_Delete_It") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Delete"), 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 f2dea0e7e6..58b778065e 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 @@ -645,26 +645,10 @@ public class ElementCasePaneAuthorityEditPane extends AuthorityEditPane { return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, LayoutConstants.VGAP_SMALL); } -// private JPanel populateWidgetCheckPane() { -// double f = TableLayout.FILL; -// double p = TableLayout.PREFERRED; -// Component[][] components = new Component[][]{ -// new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Cell"), SwingConstants.LEFT), cellElementVisibleCheckBoxes}, -// new Component[]{null, newValue}, -// new Component[]{null, valueEditor}, -// new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Widget"), SwingConstants.LEFT), widgetVisible}, -// new Component[]{null, widgetAvailable} -// }; -// double[] rowSize = {p, p, p, p, p}; -// double[] columnSize = {p, f}; -// int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; -// return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); -// } - private JPanel populateWidgetCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; - UILabel cv = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Cell_Value") + " "); + UILabel cv = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Cell_Value") + " "); cv.setBorder(BorderFactory.createEmptyBorder(0, LEFT_CHECKPANE, 0, 0)); Component[][] components = new Component[][]{ new Component[]{cellElementVisibleCheckBoxes, null}, @@ -705,27 +689,13 @@ public class ElementCasePaneAuthorityEditPane extends AuthorityEditPane { return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } -// private JPanel populatCellCheckPane() { -// double f = TableLayout.FILL; -// double p = TableLayout.PREFERRED; -// Component[][] components = new Component[][]{ -// new Component[]{cellElementVisibleCheckBoxes}, -// new Component[]{newValue}, -// new Component[]{valueEditor} -// }; -// double[] rowSize = {p, p, p}; -// double[] columnSize = {f}; -// int[][] rowCount = {{1}, {1}, {1}}; -// return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); -// } - private JPanel populatCellCheckPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; double[] rowSize = {p, p, p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}}; - UILabel cv = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Cell_Value") + " "); + UILabel cv = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Cell_Value") + " "); cv.setBorder(BorderFactory.createEmptyBorder(0, LEFT_CHECKPANE, 0, 0)); Component[][] components = new Component[][]{ new Component[]{cellElementVisibleCheckBoxes,null}, diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java index 62d1d4a3ea..b4b43cafd9 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java @@ -7,6 +7,7 @@ import com.fr.base.FRContext; import com.fr.concurrent.NamedThreadFactory; import com.fr.config.MarketConfig; import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.mainframe.errorinfo.ErrorInfoUploader; import com.fr.design.mainframe.messagecollect.impl.FocusPointMessageUploader; import com.fr.design.mainframe.messagecollect.solid.SolidCollector; @@ -234,7 +235,8 @@ public class InformationCollector implements XMLReadable, XMLWriter { SolidCollector.getInstance().sendToCloudCenterAndDeleteFile(); sendUserInfo(); FocusPointMessageUploader.getInstance().sendToCloudCenter(); - TemplateInfoCollector.getInstance().sendTemplateInfo(); + TemplateInfoCollector.getInstance().sendPointInfo(); + ChartInfoCollector.getInstance().sendPointInfo(); ErrorInfoUploader.getInstance().sendErrorInfo(); } }, SEND_DELAY, TimeUnit.MILLISECONDS); 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 621d3f40b6..0759ddf983 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 @@ -1188,4 +1188,9 @@ public class JWorkBook extends JTemplate { provider.addChooseFileFilter(fileChooser, this.suffix()); } } + + @Override + public void whenClose() { + reportComposite.doRemoveAction(); + } } 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 71fb275029..0299899a06 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 @@ -3,6 +3,7 @@ package com.fr.design.mainframe; import com.fr.base.ScreenResolution; import com.fr.common.inputevent.InputEventBaseOnOS; import com.fr.design.designer.EditingState; +import com.fr.design.event.RemoveListener; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icontainer.UIModeControlContainer; @@ -30,7 +31,7 @@ import java.util.ArrayList; * @editor zhou * @since 2012-3-27下午12:12:05 */ -public class ReportComponentComposite extends JComponent { +public class ReportComponentComposite extends JComponent implements RemoveListener { private static final int MAX = 400; private static final int HUND = 100; @@ -250,4 +251,9 @@ public class ReportComponentComposite extends JComponent { public void fireTargetModified() { parent.fireTargetModified(); } + + @Override + public void doRemoveAction() { + sheetNameTab.doRemoveAction(); + } } 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 9fdc9d5a8c..74443e831c 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 @@ -5,6 +5,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; @@ -26,6 +27,8 @@ import com.fr.base.GraphHelper; import com.fr.base.vcs.DesignerMode; import com.fr.design.actions.UpdateAction; import com.fr.design.constants.UIConstants; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.event.RemoveListener; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonUI; @@ -43,7 +46,6 @@ import com.fr.poly.PolyDesigner; import com.fr.report.poly.PolyWorkSheet; import com.fr.report.report.TemplateReport; import com.fr.report.worksheet.WorkSheet; -import com.fr.stable.ProductConstants; /** * NameTabPane of sheets @@ -51,7 +53,7 @@ import com.fr.stable.ProductConstants; * @editor zhou * @since 2012-3-26下午1:45:53 */ -public class SheetNameTabPane extends JComponent implements MouseListener, MouseMotionListener { +public class SheetNameTabPane extends JComponent implements MouseListener, MouseMotionListener, RemoveListener { private static final Color LINE_COLOR = new Color(0xababab); @@ -139,6 +141,10 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse private boolean isAuthorityEditing = false; + private ComponentListener listener; + + private DesignerFrame designerFrame; + public SheetNameTabPane(ReportComponentComposite reportCompositeX) { this.reportComposite = reportCompositeX; this.setLayout(new BorderLayout(0, 0)); @@ -202,14 +208,20 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse } } }); - - DesignerContext.getDesignerFrame().addComponentListener(new ComponentAdapter(){ + listener = new ComponentAdapter(){ @Override public void componentResized(ComponentEvent e) { for (int i = 0; i < lastOneIndex * NUM; i++) { moveLeft(); } } - }); + }; + designerFrame = DesignerContext.getDesignerFrame(); + designerFrame.addComponentListener(listener); + } + + @Override + public void doRemoveAction() { + designerFrame.removeComponentListener(listener); } private ActionListener createLeftButtonActionListener() { @@ -875,7 +887,8 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(reportComposite), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_At_Least_One_Visual_Worksheet") + "!"); return; } - int returnValue = JOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(reportComposite), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Des_Remove_Work_Sheet"), ProductConstants.APP_NAME, + int returnValue = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(reportComposite), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Des_Remove_Work_Sheet"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.OK_CANCEL_OPTION); if (returnValue == JOptionPane.OK_OPTION) { if (DesignerContext.getFormatState() != DesignerContext.FORMAT_STATE_NULL) { @@ -927,7 +940,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse return; } - String newName = JOptionPane.showInputDialog(reportComposite, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Rename") + ":", reportComposite.getEditingWorkBook().getReportName(selectedIndex)); + String newName = FineJOptionPane.showInputDialog(reportComposite, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Rename") + ":", reportComposite.getEditingWorkBook().getReportName(selectedIndex)); if (newName != null) { // marks:判断是否重名 boolean isExisted = false; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java index d44a9402f6..d504b9d859 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java @@ -9,7 +9,7 @@ import com.fr.log.FineLoggerFactory; import com.fr.stable.AssistUtils; import com.fr.stable.EncodeConstants; import com.fr.stable.StringUtils; -import org.apache.commons.codec.digest.DigestUtils; +import com.fr.third.org.apache.commons.codec.digest.DigestUtils; import java.awt.Desktop; import java.io.IOException; @@ -50,7 +50,7 @@ public class RobotModel extends AlphaCellModel { try { String result = HttpToolbox.get(url); - if(StringUtils.isEmpty(result)){ + if (StringUtils.isEmpty(result)) { return StringUtils.EMPTY; } JSONObject jsonObject = new JSONObject(result); @@ -94,7 +94,7 @@ public class RobotModel extends AlphaCellModel { @Override public final boolean equals(Object obj) { return obj instanceof RobotModel - && AssistUtils.equals(this.title, ((RobotModel)obj).title) + && AssistUtils.equals(this.title, ((RobotModel) obj).title) && AssistUtils.equals(this.content, ((RobotModel) obj).content); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java index 68cc882a92..d090b9e8f1 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java @@ -1,22 +1,18 @@ package com.fr.design.mainframe.messagecollect.solid; +import com.fr.analysis.cloud.solid.SolidRecordExecutor; import com.fr.general.CloudCenter; import com.fr.general.http.HttpToolbox; -import com.fr.json.JSON; -import com.fr.json.JSONFactory; import com.fr.log.FineLoggerFactory; -import com.fr.security.JwtUtils; +import com.fr.rpc.ExceptionHandler; +import com.fr.rpc.RPCInvokerExceptionInfo; import com.fr.stable.CommonUtils; import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; -import java.io.IOException; import java.util.HashMap; import java.util.Map; -import static com.fr.design.mainframe.messagecollect.solid.SolidCollectConstants.REQUEST_SUBJECT; -import static com.fr.design.mainframe.messagecollect.solid.SolidCollectConstants.TIME_OUT; - /** * 设计器固化信息回传类 * Created by alex sung on 2019/8/22. @@ -24,9 +20,6 @@ import static com.fr.design.mainframe.messagecollect.solid.SolidCollectConstants public class SolidCollector { - private static final String CONTENT_URL = "/v10/collect/solid"; - private static final String DELETE_URL = "/v10/collect/solid/delete"; - private static final String UNLOCK_URL = "/v10/collect/solid/unlock"; private static final String ATTR_CIPHER_TEXT = "cipherText"; private static final String ATTR_SIGNATURE = "signature"; private static final String SOLID_UPLOAD_URL = CloudCenter.getInstance().acquireUrlByKind("design.solid"); @@ -53,27 +46,22 @@ public class SolidCollector { } FineLoggerFactory.getLogger().info("start to get solid content from server..."); try { - String content = requestContent(); - if (StringUtils.isNotEmpty(content)) { - String cipherText = JSONFactory.createJSON(JSON.OBJECT, content).optString("data"); - if(StringUtils.isNotEmpty(cipherText)){ - Map params = new HashMap<>(); - params.put(ATTR_CIPHER_TEXT, cipherText); - params.put(ATTR_SIGNATURE, String.valueOf(CommonUtils.signature())); - HttpToolbox.post(SOLID_UPLOAD_URL, params); + String cipherText = requestContent(); + if (StringUtils.isNotEmpty(cipherText)) { + Map params = new HashMap<>(); + params.put(ATTR_CIPHER_TEXT, cipherText); + params.put(ATTR_SIGNATURE, String.valueOf(CommonUtils.signature())); + HttpToolbox.post(SOLID_UPLOAD_URL, params); - String deleteUrl = WorkContext.getCurrent().getPath() + DELETE_URL; - HttpToolbox.post(deleteUrl, getParams()); - } + deleteSolidFile(); } FineLoggerFactory.getLogger().info("send solid content to cloud center success."); } catch (Exception e) { FineLoggerFactory.getLogger().info(e.getMessage(), e); } finally { - String unlockUrl = WorkContext.getCurrent().getPath() + UNLOCK_URL; try { - HttpToolbox.post(unlockUrl, getParams()); - } catch (IOException e) { + unlockSolidFile(); + } catch (Exception e) { FineLoggerFactory.getLogger().warn(e.getMessage(), e); } } @@ -81,17 +69,42 @@ public class SolidCollector { /** * 获取服务端固化文件内容 + * * @return 回传内容 */ - public String requestContent() throws Exception { - Map params = new HashMap(); - params.put("token", JwtUtils.createDefaultJWT(REQUEST_SUBJECT, TIME_OUT)); - return HttpToolbox.get(WorkContext.getCurrent().getPath() + CONTENT_URL, params); + private String requestContent() throws Exception { + return WorkContext.getCurrent().get(SolidRecordExecutor.class, new ExceptionHandler() { + @Override + public String callHandler(RPCInvokerExceptionInfo info) { + FineLoggerFactory.getLogger().error(info.getException().getMessage(), info.getException()); + return StringUtils.EMPTY; + } + }).feedBackTask(StringUtils.EMPTY); } - private Map getParams() { - Map params = new HashMap(); - params.put("token", JwtUtils.createDefaultJWT(REQUEST_SUBJECT, TIME_OUT)); - return params; + /** + * 删除服务端固化文件 + */ + private void deleteSolidFile() throws Exception { + WorkContext.getCurrent().get(SolidRecordExecutor.class, new ExceptionHandler() { + @Override + public Void callHandler(RPCInvokerExceptionInfo info) { + FineLoggerFactory.getLogger().error(info.getException().getMessage(), info.getException()); + return null; + } + }).deleteSolidFile(); + } + + /** + * unlock + */ + private void unlockSolidFile() throws Exception { + WorkContext.getCurrent().get(SolidRecordExecutor.class, new ExceptionHandler() { + @Override + public Void callHandler(RPCInvokerExceptionInfo info) { + FineLoggerFactory.getLogger().error(info.getException().getMessage(), info.getException()); + return null; + } + }).unlockSolidFile(); } } diff --git a/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java b/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java index 168f65ecea..ea78f568f5 100644 --- a/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java +++ b/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java @@ -4,6 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.base.Parameter; import com.fr.base.parameter.ParameterUI; import com.fr.base.vcs.DesignerMode; +import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; import com.fr.design.actions.AllowAuthorityEditAction; import com.fr.design.actions.ExitAuthorityEditAction; @@ -326,7 +327,8 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus } private boolean isWithoutParaXCreator() { - return paraDesignEditor.isWithoutParaXCreator(allParameters); + // allParameters只包含全部的模板参数 + return paraDesignEditor.isWithoutParaXCreator(DesignModelAdapter.getCurrentModelAdapter().getParameters()); } /** diff --git a/designer-realize/src/main/java/com/fr/design/report/LayerReportPane.java b/designer-realize/src/main/java/com/fr/design/report/LayerReportPane.java index 0cfab61199..1b1c1692f0 100644 --- a/designer-realize/src/main/java/com/fr/design/report/LayerReportPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/LayerReportPane.java @@ -1,6 +1,7 @@ package com.fr.design.report; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.editor.editor.IntegerEditor; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.FRExplainLabel; @@ -150,8 +151,8 @@ public class LayerReportPane extends BasicBeanPane { public void checkValid() throws Exception { if (isLayerReportBox.isSelected()) { if (!ReportUtils.isLayerReportUsable(worksheet)) { - int value = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_After_Changed_Some_Attributes_Are_Different") + "?", - ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION); + int value = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_After_Changed_Some_Attributes_Are_Different") + "?", + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION); if (value != JOptionPane.YES_OPTION) { isLayerReportBox.setSelected(false); } diff --git a/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java b/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java index 2ee1d57811..558cf42913 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java @@ -1,6 +1,7 @@ package com.fr.design.report; import com.fr.config.ServerPreferenceConfig; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.style.StylePane; import com.fr.design.utils.gui.GUICoreUtils; @@ -31,14 +32,14 @@ public class ReportStylePane extends StylePane { popupMenu.add(menuItem); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - String name = JOptionPane.showInputDialog(getParent(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Input_The_Name_Of_Gloabel_Style")); + String name = FineJOptionPane.showInputDialog(getParent(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Input_The_Name_Of_Gloabel_Style")); if (ComparatorUtils.equals(name, "")) { return; } if (ServerPreferenceConfig.getInstance().getStyle(name) == null) { ServerPreferenceConfig.getInstance().putStyle(name, ReportStylePane.this.updateBean()); } else { - JOptionPane.showMessageDialog(getParent(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_This_Name_Has_Exsit") + "!", com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Warning"), JOptionPane.WARNING_MESSAGE); + FineJOptionPane.showMessageDialog(getParent(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_This_Name_Has_Exsit") + "!", com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Warning"), JOptionPane.WARNING_MESSAGE); } } }); diff --git a/designer-realize/src/main/java/com/fr/design/report/RichTextEditingPane.java b/designer-realize/src/main/java/com/fr/design/report/RichTextEditingPane.java index 0406abffb9..39061a4b6d 100644 --- a/designer-realize/src/main/java/com/fr/design/report/RichTextEditingPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/RichTextEditingPane.java @@ -14,9 +14,14 @@ import com.fr.log.FineLoggerFactory; import com.fr.report.cell.cellattr.core.RichText; import com.fr.report.cell.cellattr.core.RichTextConverter; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; +import javax.swing.text.DefaultHighlighter; import javax.swing.text.Element; +import javax.swing.text.Highlighter; import javax.swing.text.StyledDocument; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -44,6 +49,7 @@ public class RichTextEditingPane extends UITextPane{ */ public RichTextEditingPane() { this.addMouseListener(doubleClickFormulaListener); + this.addFocusListener(focusListener); } /** @@ -195,4 +201,34 @@ public class RichTextEditingPane extends UITextPane{ } } }; + + private FocusListener focusListener = new FocusAdapter() { + /** + * 移除高亮,重新选中文本 + * @param e + */ + public void focusGained(FocusEvent e) { + RichTextEditingPane richTextPane = RichTextEditingPane.this; + richTextPane.getHighlighter().removeAllHighlights(); + richTextPane.select(richTextPane.getSelectionStart(), richTextPane.getSelectionEnd()); + } + + /** + * 失去焦点时,被选中的文本保持着被选中时的样式 + * @param e + */ + public void focusLost(FocusEvent e) { + RichTextEditingPane richTextPane = RichTextEditingPane.this; + int start = richTextPane.getSelectionStart(); + int end = richTextPane.getSelectionEnd(); + richTextPane.select(start, end); + Highlighter highlighter = richTextPane.getHighlighter(); + richTextPane.getHighlighter().removeAllHighlights(); + try { + highlighter.addHighlight(start, end, DefaultHighlighter.DefaultPainter); + } catch (BadLocationException exception) { + FineLoggerFactory.getLogger().error(exception.getMessage(), exception); + } + } + }; } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/report/SubReportPane.java b/designer-realize/src/main/java/com/fr/design/report/SubReportPane.java index 0254f5e85c..ae08cf6718 100644 --- a/designer-realize/src/main/java/com/fr/design/report/SubReportPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/SubReportPane.java @@ -2,6 +2,7 @@ package com.fr.design.report; import com.fr.base.core.KV; import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.frpane.ReportletParameterViewPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; @@ -62,7 +63,7 @@ public class SubReportPane extends BasicPane { if (chooseFILE != null && chooseFILE.exists()) { pathTextField.setText(chooseFILE.prefix() + chooseFILE.getPath()); } else { - JOptionPane.showConfirmDialog(SubReportPane.this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sub_Report_Message1"), + FineJOptionPane.showConfirmDialog(SubReportPane.this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sub_Report_Message1"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sub_Report_ToolTips"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); chooseFILE = null; pathTextField.setText(""); diff --git a/designer-realize/src/main/java/com/fr/design/style/StylePane.java b/designer-realize/src/main/java/com/fr/design/style/StylePane.java index 7fd8db07d4..78b0b289cf 100644 --- a/designer-realize/src/main/java/com/fr/design/style/StylePane.java +++ b/designer-realize/src/main/java/com/fr/design/style/StylePane.java @@ -8,7 +8,11 @@ import com.fr.base.NameStyle; import com.fr.base.ScreenResolution; import com.fr.base.Style; import com.fr.base.core.StyleUtils; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.fun.MultiStyleUIConfigProvider; +import com.fr.design.fun.StyleUIConfigProvider; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.ElementCasePane; @@ -18,6 +22,7 @@ import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.Selection; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.solution.sandbox.collection.PluginSandboxCollections; import com.fr.report.cell.CellElement; import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.FloatElement; @@ -26,7 +31,6 @@ import com.fr.report.elementcase.ElementCase; import com.fr.report.elementcase.TemplateElementCase; import javax.swing.JComponent; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.event.ChangeEvent; @@ -38,6 +42,8 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; +import java.util.List; +import java.util.Set; /** * Style Pane. @@ -48,6 +54,7 @@ public class StylePane extends BasicBeanPane