From 0966e83473754e2f774d1da4d8ddebee0b736e0c Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Fri, 18 Jan 2019 22:22:28 +0800 Subject: [PATCH 1/6] =?UTF-8?q?REPORT-13202=20=E5=8C=85=E5=90=AB=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=8E=A7=E4=BB=B6=E7=9A=84=E6=A8=A1=E6=9D=BF=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E7=8E=AF=E5=A2=83=E5=90=8E=E5=AD=98=E5=82=A8=E5=87=BA?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/file/HistoryTemplateListCache.java | 33 +++--- .../design/mainframe/AbstractAppProvider.java | 10 +- .../fr/design/mainframe/DesignerFrame.java | 68 ++++------- .../fr/design/mainframe/JTemplateFactory.java | 63 +++++++++++ .../main/java/com/fr/file/StashedFILE.java | 106 ++++++++++++++++++ .../mainframe/app/DesignerAppActivator.java | 6 +- .../com/fr/start/module/DesignerStartup.java | 15 ++- .../start/module/WorkspaceEventPriority.java | 16 +++ 8 files changed, 239 insertions(+), 78 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java create mode 100644 designer-base/src/main/java/com/fr/file/StashedFILE.java create mode 100644 designer-realize/src/main/java/com/fr/start/module/WorkspaceEventPriority.java 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 a84442c58..e162fee3e 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 @@ -2,7 +2,6 @@ package com.fr.design.file; import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.base.io.BaseBook; -import com.fr.base.io.IOFile; import com.fr.design.DesignerEnvManager; import com.fr.design.base.mode.DesignModeContext; import com.fr.design.data.DesignTableDataManager; @@ -10,17 +9,18 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.JTemplateFactory; import com.fr.design.mainframe.JVirtualTemplate; import com.fr.design.module.DesignModuleFactory; import com.fr.file.FILE; import com.fr.file.FileNodeFILE; +import com.fr.file.StashedFILE; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.CoreConstants; import com.fr.stable.StringUtils; import com.fr.third.org.apache.commons.io.FilenameUtils; -import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.ArrayList; import java.util.Collections; @@ -315,7 +315,7 @@ public class HistoryTemplateListCache implements CallbackEvent { /** * 切换环境时暂存打开的模板内容,key 是在历史中的index,value 是模板xml 内容byte[] */ - private Map bytesMap; + private Map stashFILEMap; /** * 切换环境前将正在编辑的模板暂存起来,并且在新环境中重新读取一遍,暂存的不是模板文件的内容而是模板对象的内容 @@ -326,20 +326,21 @@ public class HistoryTemplateListCache implements CallbackEvent { */ public void stash() { FineLoggerFactory.getLogger().info("Env Change Template Stashing..."); - if (bytesMap == null) { - bytesMap = new HashMap(); + if (stashFILEMap == null) { + stashFILEMap = new HashMap(); } else { - bytesMap.clear(); + stashFILEMap.clear(); } int size = historyList.size(); for (int i = 0; i < size; i++) { JTemplate template = historyList.get(i); + FILE file = template.getEditingFILE(); try { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); BaseBook target = template.getTarget(); if (target != null) { target.export(outputStream); - bytesMap.put(i, outputStream.toByteArray()); + stashFILEMap.put(i, new StashedFILE(file, outputStream.toByteArray())); } // 如果 target == null 那么这个模板是被模板内存优化功能处理过的,不用处理 } catch (Exception e) { @@ -358,27 +359,25 @@ public class HistoryTemplateListCache implements CallbackEvent { */ public void load() { FineLoggerFactory.getLogger().info("Env Change Template Loading..."); - if (bytesMap != null && bytesMap.size() != 0) { + if (stashFILEMap != null && stashFILEMap.size() != 0) { int size = historyList.size(); for (int i = 0; i < size; i++) { try { - byte[] bytes = bytesMap.get(i); + FILE stashedFile = stashFILEMap.get(i); // 可能有模板 stash 失败的情况,在 load 的时候不更新它 - if (bytes == null) { + // 或者这个模板是被模板内存优化功能处理过的,不用处理 + if (stashedFile == null) { continue; } - ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes); - BaseBook target = historyList.get(i).getTarget(); - if (target != null) { - // todo readStream 这个行为应该上升到 BaseBook 上 - ((IOFile) target).readStream(inputStream); + JTemplate template = JTemplateFactory.createJTemplate(stashedFile); + if (template != null) { + historyList.set(i, template); } - // 如果 target == null 那么这个模板是被模板内存优化功能处理过的,不用处理 } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } - bytesMap.clear(); + stashFILEMap.clear(); MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList); MutilTempalteTabPane.getInstance().repaint(); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/AbstractAppProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/AbstractAppProvider.java index 95a969635..cc859ce17 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/AbstractAppProvider.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/AbstractAppProvider.java @@ -8,7 +8,7 @@ import com.fr.stable.fun.mark.API; * Created by Administrator on 2016/3/17/0017. */ @API(level = App.CURRENT_LEVEL) -public abstract class AbstractAppProvider extends AbstractProvider implements App{ +public abstract class AbstractAppProvider extends AbstractProvider implements App { public int currentAPILevel() { return CURRENT_LEVEL; @@ -21,12 +21,12 @@ public abstract class AbstractAppProvider extends AbstractProv @Override public void process() { - DesignerFrame.registApp(this); + JTemplateFactory.register(this); } - + @Override public void undo() { - - DesignerFrame.removeApp(this); + + JTemplateFactory.remove(this); } } 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 714c561e7..2cc83543c 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 @@ -51,7 +51,6 @@ 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.CoreConstants; import com.fr.stable.OperatingSystem; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; @@ -115,11 +114,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private static final int MENU_HEIGHT = 26; - private static final Integer SECOND_LAYER = new Integer(100); + private static final Integer SECOND_LAYER = 100; - private static final Integer TOP_LAYER = new Integer((200)); - - private static java.util.List> appList = new java.util.ArrayList>(); + private static final Integer TOP_LAYER = 200; private List designerOpenedListenerList = new ArrayList<>(); @@ -326,7 +323,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta this.progressDialog = new ProgressDialog(this); } - public void closeAuthorityEditing(){ + public void closeAuthorityEditing() { DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL); WestRegionContainerPane.getInstance().replaceDownPane( TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); @@ -342,19 +339,22 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta * 注册app. * * @param app 注册app. + * @deprecated use {@link JTemplateFactory#register(App)} instead */ + @Deprecated public static void registApp(App app) { - - if (app != null) { - appList.add(app); - } + JTemplateFactory.register(app); } + /** + * 移除app + * + * @param app app + * @deprecated use {@link JTemplateFactory#remove(App)} instead + */ + @Deprecated public static void removeApp(App app) { - - if (app != null) { - appList.remove(app); - } + JTemplateFactory.remove(app); } /** @@ -1027,39 +1027,17 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ private void openFile(FILE tplFile) { - String fileName = tplFile.getName(); - int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT); - if (indexOfLastDot < 0) { + JTemplate jt = JTemplateFactory.createJTemplate(tplFile); + if (jt == null) { return; } - String fileExtention = fileName.substring(indexOfLastDot + 1); - for (int i = 0, len = appList.size(); i < len; i++) { - App app = appList.get(i); - String[] defaultAppExtentions = app.defaultExtensions(); - boolean opened = false; - for (int j = 0; j < defaultAppExtentions.length; j++) { - if (defaultAppExtentions[j].equalsIgnoreCase(fileExtention)) { - // 不要catch - JTemplate jt = app.openTemplate(tplFile); - - if (jt == null) { - return; - } - // 新的form不往前兼容 - if (inValidDesigner(jt)) { - this.addAndActivateJTemplate(); - MutilTempalteTabPane.getInstance().setTemTemplate( - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); - } else { - activeTemplate(jt); - } - opened = true; - break; - } - } - if (opened) { - break; - } + // 新的form不往前兼容 + if (inValidDesigner(jt)) { + this.addAndActivateJTemplate(); + MutilTempalteTabPane.getInstance().setTemTemplate( + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + } else { + activeTemplate(jt); } } 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 new file mode 100644 index 000000000..1c6866535 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java @@ -0,0 +1,63 @@ +package com.fr.design.mainframe; + +import com.fr.file.FILE; +import com.fr.stable.CoreConstants; +import com.fr.third.javax.annotation.Nonnull; +import com.fr.third.javax.annotation.Nullable; + +import java.util.ArrayList; +import java.util.List; + +public final class JTemplateFactory { + private static final List> ALL_APP = new ArrayList>(); + + private JTemplateFactory() { + } + + /** + * 生成设计器编辑模板对象 + * + * @param file 包含了模板名称,类型以及内容的文件 + * @return 设计器编辑的模板对象 + */ + @Nullable + public static JTemplate createJTemplate(@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)) { + JTemplate jt = app.openTemplate(file); + if (jt != null) { + return jt; + } + } + } + } + return null; + } + + + /** + * 注册app. + * + * @param app 注册app. + */ + public static void register(App app) { + if (app != null) { + ALL_APP.add(app); + } + } + + public static void remove(App app) { + if (app != null) { + ALL_APP.remove(app); + } + } +} diff --git a/designer-base/src/main/java/com/fr/file/StashedFILE.java b/designer-base/src/main/java/com/fr/file/StashedFILE.java new file mode 100644 index 000000000..4bc9b431e --- /dev/null +++ b/designer-base/src/main/java/com/fr/file/StashedFILE.java @@ -0,0 +1,106 @@ +package com.fr.file; + +import javax.swing.Icon; +import javax.transaction.NotSupportedException; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.OutputStream; + +/** + * 切换环境用于暂存的文件类型 + */ +public class StashedFILE implements FILE { + + private FILE file; + private byte[] content; + + public StashedFILE(FILE file, byte[] content) { + this.file = file; + this.content = content; + } + + @Override + public String prefix() { + return file.prefix(); + } + + @Override + public boolean isDirectory() { + return file.isDirectory(); + } + + @Override + public String getName() { + return file.getName(); + } + + @Override + public Icon getIcon() { + return file.getIcon(); + } + + @Override + public String getPath() { + return file.getPath(); + } + + @Override + public void setPath(String path) { + throw new UnsupportedOperationException(); + } + + @Override + public FILE getParent() { + throw new UnsupportedOperationException(); + } + + @Override + public FILE[] listFiles() { + throw new UnsupportedOperationException(); + } + + @Override + public boolean createFolder(String name) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean mkfile() throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public boolean exists() { + return false; + } + + @Override + public void closeTemplate() throws Exception { + // do nothing + } + + @Override + public InputStream asInputStream() throws Exception { + return new ByteArrayInputStream(content); + } + + @Override + public OutputStream asOutputStream() throws Exception { + throw new NotSupportedException(); + } + + @Override + public String getEnvFullName() { + return file.getEnvFullName(); + } + + @Override + public boolean isMemFile() { + return true; + } + + @Override + public boolean isEnvFile() { + return false; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppActivator.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppActivator.java index f91b0d9a1..b13cdca85 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppActivator.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppActivator.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.app; import com.fr.design.mainframe.App; -import com.fr.design.mainframe.DesignerFrame; +import com.fr.design.mainframe.JTemplateFactory; import com.fr.module.Activator; import com.fr.module.extension.Prepare; @@ -17,7 +17,7 @@ public class DesignerAppActivator extends Activator implements Prepare { List appList = rightCollectMutable(App.KEY); for (App app : appList) { - DesignerFrame.registApp(app); + JTemplateFactory.register(app); } } @@ -26,7 +26,7 @@ public class DesignerAppActivator extends Activator implements Prepare { List appList = rightCollectMutable(App.KEY); for (App app : appList) { - DesignerFrame.removeApp(app); + JTemplateFactory.remove(app); } } diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java index 98e1f8f18..25fdeb77d 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java @@ -82,17 +82,16 @@ public class DesignerStartup extends Activator { */ private void registerEnvListener() { - - /*切换环境前,关闭所有相关模块*/ - listenEvent(WorkspaceEvent.BeforeSwitch, new Listener() { + /*切换环境前,关闭所有相关模块,最后执行*/ + listenEvent(WorkspaceEvent.BeforeSwitch, new Listener(WorkspaceEventPriority.MIN) { @Override public void on(Event event, Workspace current) { getSub(EnvBasedModule.class).stop(); } }); - /*切换环境后,重新启动所有相关模块*/ - listenEvent(WorkspaceEvent.AfterSwitch, new Listener(Integer.MAX_VALUE) { + /*切换环境后,重新启动所有相关模块,最先执行*/ + listenEvent(WorkspaceEvent.AfterSwitch, new Listener(WorkspaceEventPriority.MAX) { @Override public void on(Event event, Workspace current) { @@ -110,8 +109,8 @@ public class DesignerStartup extends Activator { } } }); - /*切换环境前,存储一下打开的所有文件对象,优先级高于默认优先级,要先于 关闭相关模块部分 被触发*/ - listenEvent(WorkspaceEvent.BeforeSwitch, new Listener(Integer.MAX_VALUE) { + /*切换环境前,存储一下打开的所有文件对象,要先于 关闭相关模块部分 被触发*/ + listenEvent(WorkspaceEvent.BeforeSwitch, new Listener(WorkspaceEventPriority.MAX) { @Override public void on(Event event, Workspace workspace) { HistoryTemplateListCache.getInstance().stash(); @@ -119,7 +118,7 @@ public class DesignerStartup extends Activator { }); /*切换环境后,装载一下打开的所有文件对象,优先级低于默认优先级,要后于 启动相关模块部分 被触发*/ - listenEvent(WorkspaceEvent.AfterSwitch, new Listener(Integer.MIN_VALUE) { + listenEvent(WorkspaceEvent.AfterSwitch, new Listener(WorkspaceEventPriority.MIN) { @Override public void on(Event event, Workspace workspace) { HistoryTemplateListCache.getInstance().load(); diff --git a/designer-realize/src/main/java/com/fr/start/module/WorkspaceEventPriority.java b/designer-realize/src/main/java/com/fr/start/module/WorkspaceEventPriority.java new file mode 100644 index 000000000..a0473f610 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/start/module/WorkspaceEventPriority.java @@ -0,0 +1,16 @@ +package com.fr.start.module; + +/** + * 切换环境事件优先级暂时方案 + * todo 看是不是需要使用另外的类型处理优先级 + */ +public final class WorkspaceEventPriority { + + private WorkspaceEventPriority() { + } + + public static final int MAX = 999; + public static final int MID = 0; + public static final int MIN = -999; + +} From dbc09c2781ffd0b9058b4008bb33373c45287f18 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Mon, 21 Jan 2019 13:56:45 +0800 Subject: [PATCH 2/6] =?UTF-8?q?REPORT-14361=20=E9=83=A8=E5=88=86=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E5=8F=AF=E8=83=BD=E5=AF=BC=E8=87=B4AWT=20EDT=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E5=90=8C=E6=AD=A5=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/parameter/ParaDefinitePane.java | 2 +- .../beans/events/DesignerEditListener.java | 7 +- .../form/parameter/FormParaDesigner.java | 62 ++-- .../com/fr/design/mainframe/FormDesigner.java | 30 +- .../mainframe/FormHierarchyTreePane.java | 349 +++++++++--------- 5 files changed, 238 insertions(+), 212 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/parameter/ParaDefinitePane.java b/designer-base/src/main/java/com/fr/design/parameter/ParaDefinitePane.java index 43e260bfd..192171a97 100644 --- a/designer-base/src/main/java/com/fr/design/parameter/ParaDefinitePane.java +++ b/designer-base/src/main/java/com/fr/design/parameter/ParaDefinitePane.java @@ -1 +1 @@ -package com.fr.design.parameter; import com.fr.base.Parameter; public interface ParaDefinitePane { public Parameter[] getNoRepeatParas(Parameter[] paras); public void setParameterArray(Parameter[] ps); public Parameter[] getParameterArray(); public void refreshParameter(); public boolean isWithQueryButton(); public void addingParameter2Editor(Parameter p); public void addingParameter2EditorWithQueryButton(Parameter p); public void addingAllParameter2Editor(); } \ No newline at end of file +package com.fr.design.parameter; import com.fr.base.Parameter; public interface ParaDefinitePane { Parameter[] getNoRepeatParas(Parameter[] paras); void setParameterArray(Parameter[] ps); Parameter[] getParameterArray(); void refreshParameter(); boolean isWithQueryButton(); void addingParameter2Editor(Parameter p); void addingParameter2EditorWithQueryButton(Parameter p); void addingAllParameter2Editor(); } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditListener.java b/designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditListener.java index fe170dc6d..798c6090d 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditListener.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditListener.java @@ -4,11 +4,12 @@ import java.util.EventListener; /** * 界面设计组件触发的编辑处理器接口 - * @since 6.5.4 + * * @author richer + * @since 6.5.4 */ public interface DesignerEditListener extends EventListener { - void fireCreatorModified(DesignerEvent evt); - + void fireCreatorModified(DesignerEvent evt); + } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java index 62cea356d..1afd86743 100644 --- a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java +++ b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java @@ -3,21 +3,6 @@ */ package com.fr.design.form.parameter; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Insets; -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.swing.BorderFactory; -import javax.swing.JComponent; -import javax.swing.JPanel; - import com.fr.base.BaseUtils; import com.fr.base.Parameter; import com.fr.base.parameter.ParameterUI; @@ -39,7 +24,17 @@ import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.form.util.XCreatorConstants; -import com.fr.design.mainframe.*; +import com.fr.design.mainframe.AuthorityEditPane; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.EastRegionContainerPane; +import com.fr.design.mainframe.FormArea; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.FormDesignerModeForSpecial; +import com.fr.design.mainframe.FormParaPane; +import com.fr.design.mainframe.FormWidgetDetailPane; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.mainframe.WidgetToolBarPane; import com.fr.design.parameter.ParaDefinitePane; import com.fr.design.parameter.ParameterDesignerProvider; import com.fr.design.parameter.ParameterPropertyPane; @@ -51,9 +46,23 @@ import com.fr.form.ui.WidgetValue; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WParameterLayout; - import com.fr.stable.ArrayUtils; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Insets; +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + /** * Created by IntelliJ IDEA. * User : Richer @@ -169,12 +178,17 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP this.getEditListenerTable().addListener(new DesignerEditListener() { @Override - public void fireCreatorModified(DesignerEvent evt) { - if (evt.getCreatorEventID() != DesignerEvent.CREATOR_SELECTED) { - paraDefinitePane.setParameterArray( - paraDefinitePane.getNoRepeatParas(DesignModelAdapter.getCurrentModelAdapter().getParameters())); - paraDefinitePane.refreshParameter(); - } + public void fireCreatorModified(final DesignerEvent evt) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + if (evt.getCreatorEventID() != DesignerEvent.CREATOR_SELECTED) { + paraDefinitePane.setParameterArray( + paraDefinitePane.getNoRepeatParas(DesignModelAdapter.getCurrentModelAdapter().getParameters())); + paraDefinitePane.refreshParameter(); + } + } + }); } }); } @@ -220,7 +234,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP /** * 刷新参数 * - * @param p 参数面板 + * @param p 参数面板 * @param jt 当前模版 */ public void refreshParameter(ParaDefinitePane p, JTemplate jt) { 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 5dd42de8d..c3a3dc41c 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 @@ -71,6 +71,7 @@ import javax.swing.Action; import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.swing.SwingUtilities; import javax.swing.TransferHandler; import javax.swing.border.Border; import javax.swing.event.TreeSelectionEvent; @@ -692,19 +693,24 @@ public class FormDesigner extends TargetComponent
implements TreeSelection getEditListenerTable().addListener(new DesignerEditListener() { @Override - public void fireCreatorModified(DesignerEvent evt) { - // 只有选择组件时不触发模版更新,其他都要触发 - if (evt.getCreatorEventID() != DesignerEvent.CREATOR_SELECTED) { - FormDesigner.this.fireTargetModified(); - if (evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED) { - setParameterArray(getNoRepeatParas(getTarget().getParameters())); - refreshParameter(); + public void fireCreatorModified(final DesignerEvent evt) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + // 只有选择组件时不触发模版更新,其他都要触发 + if (evt.getCreatorEventID() != DesignerEvent.CREATOR_SELECTED) { + FormDesigner.this.fireTargetModified(); + if (evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED) { + setParameterArray(getNoRepeatParas(getTarget().getParameters())); + refreshParameter(); + } + } else { + for (UpdateAction action : getActions()) { + action.update(); + } + } } - } else { - for (UpdateAction action : getActions()) { - action.update(); - } - } + }); } }); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java b/designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java index c2b8ff7f3..12d109802 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java @@ -18,12 +18,12 @@ import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.design.parameter.HierarchyTreePane; - import javax.swing.Action; import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JPanel; +import javax.swing.SwingUtilities; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; @@ -37,112 +37,117 @@ import java.util.ArrayList; */ public class FormHierarchyTreePane extends FormDockView implements HierarchyTreePane { - private static final int NODE_LENGTH = 2; - private static final int PARA = 0; - private static final int BODY = 1; + private static final int NODE_LENGTH = 2; + private static final int PARA = 0; + private static final int BODY = 1; private static final int SHORTS_SEPARATOR_POS = 4; private static final int TOOLBAR_PADDING_RIGHT = 10; - private ShortCut4JControlPane[] shorts; - private ComponentTree componentTree; - - public static FormHierarchyTreePane getInstance() { - return HOLDER.singleton; - } - - public static FormHierarchyTreePane getInstance(FormDesigner editor) { - HOLDER.singleton.setEditingFormDesigner(editor); - HOLDER.singleton.refreshDockingView(); - return HOLDER.singleton; - } - - private static class HOLDER { - private static FormHierarchyTreePane singleton = new FormHierarchyTreePane(); - } - - private FormHierarchyTreePane() { - setLayout(new BorderLayout(0, 0)); - } - - @Override - public String getViewTitle() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Hierarchy_Tree"); - } - - @Override - public Icon getViewIcon() { - return BaseUtils.readIcon("/com/fr/design/images/m_report/tree.png"); - } - - public ComponentTree getComponentTree() { - return componentTree; - } - - /** - * 清除 - */ - public void clearDockingView() { - this.componentTree = null; - } - - @Override - /** - * 刷新 - */ - public void refreshDockingView() { - FormDesigner formDesigner = this.getEditingFormDesigner(); - removeAll(); - if(this.componentTree != null) { - this.componentTree.removeAll(); - } - if (formDesigner == null) { - clearDockingView(); - return; - } - componentTree = new ComponentTree(formDesigner); - formDesigner.addDesignerEditListener(new DesignerEditListener() { - @Override - public void fireCreatorModified(DesignerEvent evt) { - refreshComponentTree(); - } - }); - - ComponentTreeModel treeModel = (ComponentTreeModel) componentTree.getModel(); - XCreator root = (XCreator)treeModel.getRoot(); - int childCount = treeModel.getChildCount(root); - //按照节点添加para在下的,但这里需要para节点在上,调整一下位置 - if(childCount == NODE_LENGTH){ - adjustPosition(treeModel, formDesigner); - } - - add(getWidgetPane(), BorderLayout.CENTER); - - // 这里要刷新一下,否则控件树中没有任何一个控件处于选中状态 - refreshComponentTree(); - } - - private void refreshComponentTree() { - componentTree.setAndScrollSelectionPath(componentTree.getSelectedTreePath()); - componentTree.refreshUI(); - } - - private JPanel getWidgetPane() { - shorts = createShortcuts(); - - JPanel widgetPane = new JPanel(); - widgetPane.setLayout(FRGUIPaneFactory.createBorderLayout()); - - widgetPane.add(getToolBarPane(), BorderLayout.CENTER); - UIScrollPane scrollPane = new UIScrollPane(componentTree); - scrollPane.setBorder(BorderFactory.createEmptyBorder()); - scrollPane.setPreferredSize(new Dimension(210, 170)); - widgetPane.add(scrollPane, BorderLayout.SOUTH); - return widgetPane; - } - - private JPanel getToolBarPane() { - UIToolbar toolBar = ToolBarDef.createJToolBar(); - toolBar.setUI(new UIToolBarUI(){ + private ShortCut4JControlPane[] shorts; + private ComponentTree componentTree; + + public static FormHierarchyTreePane getInstance() { + return HOLDER.singleton; + } + + public static FormHierarchyTreePane getInstance(FormDesigner editor) { + HOLDER.singleton.setEditingFormDesigner(editor); + HOLDER.singleton.refreshDockingView(); + return HOLDER.singleton; + } + + private static class HOLDER { + private static FormHierarchyTreePane singleton = new FormHierarchyTreePane(); + } + + private FormHierarchyTreePane() { + setLayout(new BorderLayout(0, 0)); + } + + @Override + public String getViewTitle() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Hierarchy_Tree"); + } + + @Override + public Icon getViewIcon() { + return BaseUtils.readIcon("/com/fr/design/images/m_report/tree.png"); + } + + public ComponentTree getComponentTree() { + return componentTree; + } + + /** + * 清除 + */ + public void clearDockingView() { + this.componentTree = null; + } + + @Override + /** + * 刷新 + */ + public void refreshDockingView() { + FormDesigner formDesigner = this.getEditingFormDesigner(); + removeAll(); + if (this.componentTree != null) { + this.componentTree.removeAll(); + } + if (formDesigner == null) { + clearDockingView(); + return; + } + componentTree = new ComponentTree(formDesigner); + formDesigner.addDesignerEditListener(new DesignerEditListener() { + @Override + public void fireCreatorModified(DesignerEvent evt) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + refreshComponentTree(); + } + }); + } + }); + + ComponentTreeModel treeModel = (ComponentTreeModel) componentTree.getModel(); + XCreator root = (XCreator) treeModel.getRoot(); + int childCount = treeModel.getChildCount(root); + //按照节点添加para在下的,但这里需要para节点在上,调整一下位置 + if (childCount == NODE_LENGTH) { + adjustPosition(treeModel, formDesigner); + } + + add(getWidgetPane(), BorderLayout.CENTER); + + // 这里要刷新一下,否则控件树中没有任何一个控件处于选中状态 + refreshComponentTree(); + } + + private void refreshComponentTree() { + componentTree.setAndScrollSelectionPath(componentTree.getSelectedTreePath()); + componentTree.refreshUI(); + } + + private JPanel getWidgetPane() { + shorts = createShortcuts(); + + JPanel widgetPane = new JPanel(); + widgetPane.setLayout(FRGUIPaneFactory.createBorderLayout()); + + widgetPane.add(getToolBarPane(), BorderLayout.CENTER); + UIScrollPane scrollPane = new UIScrollPane(componentTree); + scrollPane.setBorder(BorderFactory.createEmptyBorder()); + scrollPane.setPreferredSize(new Dimension(210, 170)); + widgetPane.add(scrollPane, BorderLayout.SOUTH); + return widgetPane; + } + + private JPanel getToolBarPane() { + UIToolbar toolBar = ToolBarDef.createJToolBar(); + toolBar.setUI(new UIToolBarUI() { @Override public void paint(Graphics g, JComponent c) { Graphics2D g2 = (Graphics2D) g; @@ -157,80 +162,80 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree shorts[i].getShortCut().intoJToolBar(toolBar); } - JPanel toolBarPane = new JPanel(new BorderLayout()); - toolBarPane.add(toolBar, BorderLayout.CENTER); - toolBarPane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.BARNOMAL)); - JPanel toolBarPaneWrapper = new JPanel(new BorderLayout()); - toolBarPaneWrapper.add(toolBarPane, BorderLayout.CENTER); - toolBarPaneWrapper.setBorder(BorderFactory.createEmptyBorder(1, 0, 2, TOOLBAR_PADDING_RIGHT)); - return toolBarPaneWrapper; - } + JPanel toolBarPane = new JPanel(new BorderLayout()); + toolBarPane.add(toolBar, BorderLayout.CENTER); + toolBarPane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.BARNOMAL)); + JPanel toolBarPaneWrapper = new JPanel(new BorderLayout()); + toolBarPaneWrapper.add(toolBarPane, BorderLayout.CENTER); + toolBarPaneWrapper.setBorder(BorderFactory.createEmptyBorder(1, 0, 2, TOOLBAR_PADDING_RIGHT)); + return toolBarPaneWrapper; + } - protected ShortCut4JControlPane[] createShortcuts() { + protected ShortCut4JControlPane[] createShortcuts() { ArrayList shortCutList = new ArrayList<>(); FormDesigner designer = getEditingFormDesigner(); for (Action action : designer.getActions()) { - shortCutList.add(new WidgetEnableShortCut((UndoableAction)action)); + shortCutList.add(new WidgetEnableShortCut((UndoableAction) action)); } return shortCutList.toArray(new ShortCut4JControlPane[shortCutList.size()]); - } - - /** - * 调整结构树para和body的位置 - * - * @param treeModel - * @param formDesigner - */ - private void adjustPosition(ComponentTreeModel treeModel,FormDesigner formDesigner){ - XCreator root = (XCreator)treeModel.getRoot(); - XCreator firstChild = (XCreator)treeModel.getChild(root,PARA); - if(firstChild.acceptType(XWParameterLayout.class)){ - return; - } - // 绝对布局作为body的时候 - // 获取第一个子节点的方法中屏蔽了fit - // 这边另外处理一下 - else if (firstChild.acceptType(XWAbsoluteBodyLayout.class) && firstChild.getBackupParent() != null) { - firstChild = firstChild.getBackupParent(); - } - root.add(firstChild,BODY); - treeModel.setRoot(root); - componentTree = new ComponentTree(formDesigner,treeModel); - } - - /** - * 刷新树 - */ - public void refreshRoot() { - if (componentTree == null) { - return; - } - componentTree.refreshTreeRoot(); - } - - @Override - /** - * 位置 - * - * @return 位置 - */ - public Location preferredLocation() { - return Location.WEST_BELOW; - } - - private class WidgetEnableShortCut extends ShortCut4JControlPane { - public WidgetEnableShortCut(ShortCut shortCut) { - this.shortCut = shortCut; - } - - /** - * 检查是否可用 - */ - @Override - public void checkEnable() { - this.shortCut.setEnabled(false); - } - } + } + + /** + * 调整结构树para和body的位置 + * + * @param treeModel + * @param formDesigner + */ + private void adjustPosition(ComponentTreeModel treeModel, FormDesigner formDesigner) { + XCreator root = (XCreator) treeModel.getRoot(); + XCreator firstChild = (XCreator) treeModel.getChild(root, PARA); + if (firstChild.acceptType(XWParameterLayout.class)) { + return; + } + // 绝对布局作为body的时候 + // 获取第一个子节点的方法中屏蔽了fit + // 这边另外处理一下 + else if (firstChild.acceptType(XWAbsoluteBodyLayout.class) && firstChild.getBackupParent() != null) { + firstChild = firstChild.getBackupParent(); + } + root.add(firstChild, BODY); + treeModel.setRoot(root); + componentTree = new ComponentTree(formDesigner, treeModel); + } + + /** + * 刷新树 + */ + public void refreshRoot() { + if (componentTree == null) { + return; + } + componentTree.refreshTreeRoot(); + } + + @Override + /** + * 位置 + * + * @return 位置 + */ + public Location preferredLocation() { + return Location.WEST_BELOW; + } + + private class WidgetEnableShortCut extends ShortCut4JControlPane { + public WidgetEnableShortCut(ShortCut shortCut) { + this.shortCut = shortCut; + } + + /** + * 检查是否可用 + */ + @Override + public void checkEnable() { + this.shortCut.setEnabled(false); + } + } } \ No newline at end of file From 374b9d6a5f27705e007316e505274878ed8217f3 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Mon, 21 Jan 2019 16:46:36 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=EF=BC=8C?= =?UTF-8?q?=E5=85=AC=E5=BC=8F=E7=BC=96=E8=BE=91=E5=99=A8=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E5=8F=82=E6=95=B0=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/DesignModelAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java b/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java index 4ebc64103..84fd684ae 100644 --- a/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java +++ b/designer-base/src/main/java/com/fr/design/DesignModelAdapter.java @@ -134,7 +134,7 @@ public abstract class DesignModelAdapter Date: Mon, 21 Jan 2019 20:28:02 +0800 Subject: [PATCH 4/6] =?UTF-8?q?REPORT-13870=20=E8=BF=9C=E7=A8=8B=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E9=97=AE=E9=A2=98=E4=BB=A5=E5=8F=8A=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 1 + .../java/com/fr/design/mainframe/JTemplate.java | 2 +- .../mainframe/socketio/DesignerSocketIO.java | 6 +++++- .../com/fr/start/module/DesignerStartup.java | 8 ++++---- .../fr/start/module/WorkspaceEventPriority.java | 16 ---------------- 5 files changed, 11 insertions(+), 22 deletions(-) delete mode 100644 designer-realize/src/main/java/com/fr/start/module/WorkspaceEventPriority.java 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 38a262916..110b97563 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -224,6 +224,7 @@ public class EnvChangeEntrance { @Override public void doCancel() { envListDialog.dispose(); + // todo 断开了但是没选择新的环境,那么尝试重连旧环境,等接口 } }); envListDialog.setVisible(true); 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 3e7b95286..852502379 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 @@ -610,7 +610,7 @@ public abstract class JTemplate> } else { JOptionPane.showMessageDialog( DesignerContext.getDesignerFrame(), - Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"), + Toolkit.i18nText("Fine-Design-Basic_Save_Failure"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.WARNING_MESSAGE); return false; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index bcf7450e1..dac28a627 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -82,6 +82,10 @@ public class DesignerSocketIO { socketIO.get().on(Socket.EVENT_DISCONNECT, new Emitter.Listener() { @Override public void call(Object... objects) { + /* + * todo 远程心跳断开不一定 socketio 断开 和远程紧密相关的业务都绑定在心跳上,切换成心跳断开之后进行提醒, + * socketio 只用推日志和通知配置变更 + */ if (status != Status.Disconnecting) { try { SwingUtilities.invokeAndWait(new Runnable() { @@ -114,7 +118,7 @@ public class DesignerSocketIO { Integer[] ports = WorkContext.getCurrent().get(SocketInfoOperator.class).getPort(); WorkspaceConnection connection = WorkContext.getCurrent().getConnection(); String[] result = new String[ports.length]; - for (int i = 0; i < ports.length; i++ ) { + for (int i = 0; i < ports.length; i++) { result[i] = String.format("%s://%s:%s%s?%s=%s&%s=%s", url.getProtocol(), url.getHost(), diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java index 25fdeb77d..4a3db7b2c 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java @@ -83,7 +83,7 @@ public class DesignerStartup extends Activator { private void registerEnvListener() { /*切换环境前,关闭所有相关模块,最后执行*/ - listenEvent(WorkspaceEvent.BeforeSwitch, new Listener(WorkspaceEventPriority.MIN) { + listenEvent(WorkspaceEvent.BeforeSwitch, new Listener(Integer.MIN_VALUE) { @Override public void on(Event event, Workspace current) { @@ -91,7 +91,7 @@ public class DesignerStartup extends Activator { } }); /*切换环境后,重新启动所有相关模块,最先执行*/ - listenEvent(WorkspaceEvent.AfterSwitch, new Listener(WorkspaceEventPriority.MAX) { + listenEvent(WorkspaceEvent.AfterSwitch, new Listener(Integer.MAX_VALUE) { @Override public void on(Event event, Workspace current) { @@ -110,7 +110,7 @@ public class DesignerStartup extends Activator { } }); /*切换环境前,存储一下打开的所有文件对象,要先于 关闭相关模块部分 被触发*/ - listenEvent(WorkspaceEvent.BeforeSwitch, new Listener(WorkspaceEventPriority.MAX) { + listenEvent(WorkspaceEvent.BeforeSwitch, new Listener(Integer.MAX_VALUE) { @Override public void on(Event event, Workspace workspace) { HistoryTemplateListCache.getInstance().stash(); @@ -118,7 +118,7 @@ public class DesignerStartup extends Activator { }); /*切换环境后,装载一下打开的所有文件对象,优先级低于默认优先级,要后于 启动相关模块部分 被触发*/ - listenEvent(WorkspaceEvent.AfterSwitch, new Listener(WorkspaceEventPriority.MIN) { + listenEvent(WorkspaceEvent.AfterSwitch, new Listener(Integer.MIN_VALUE) { @Override public void on(Event event, Workspace workspace) { HistoryTemplateListCache.getInstance().load(); diff --git a/designer-realize/src/main/java/com/fr/start/module/WorkspaceEventPriority.java b/designer-realize/src/main/java/com/fr/start/module/WorkspaceEventPriority.java deleted file mode 100644 index a0473f610..000000000 --- a/designer-realize/src/main/java/com/fr/start/module/WorkspaceEventPriority.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.fr.start.module; - -/** - * 切换环境事件优先级暂时方案 - * todo 看是不是需要使用另外的类型处理优先级 - */ -public final class WorkspaceEventPriority { - - private WorkspaceEventPriority() { - } - - public static final int MAX = 999; - public static final int MID = 0; - public static final int MIN = -999; - -} From f2280372d0f08ed0878cf731fe500267159cd75d Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Mon, 21 Jan 2019 20:30:56 +0800 Subject: [PATCH 5/6] line separator --- .../fr/design/parameter/ParaDefinitePane.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/parameter/ParaDefinitePane.java b/designer-base/src/main/java/com/fr/design/parameter/ParaDefinitePane.java index 192171a97..303e48a40 100644 --- a/designer-base/src/main/java/com/fr/design/parameter/ParaDefinitePane.java +++ b/designer-base/src/main/java/com/fr/design/parameter/ParaDefinitePane.java @@ -1 +1,24 @@ -package com.fr.design.parameter; import com.fr.base.Parameter; public interface ParaDefinitePane { Parameter[] getNoRepeatParas(Parameter[] paras); void setParameterArray(Parameter[] ps); Parameter[] getParameterArray(); void refreshParameter(); boolean isWithQueryButton(); void addingParameter2Editor(Parameter p); void addingParameter2EditorWithQueryButton(Parameter p); void addingAllParameter2Editor(); } \ No newline at end of file +package com.fr.design.parameter; + +import com.fr.base.Parameter; + + +public interface ParaDefinitePane { + + Parameter[] getNoRepeatParas(Parameter[] paras); + + void setParameterArray(Parameter[] ps); + + Parameter[] getParameterArray(); + + void refreshParameter(); + + boolean isWithQueryButton(); + + void addingParameter2Editor(Parameter p); + + void addingParameter2EditorWithQueryButton(Parameter p); + + void addingAllParameter2Editor(); + +} \ No newline at end of file From f6f5da0f009caa8ee65d9545cbf2f873e2584af3 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Mon, 21 Jan 2019 20:57:22 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=9C=A8=E4=B8=8A=E5=B1=82=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E5=A4=84=E7=90=86=20swing=20=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../events/CreatorEventListenerTable.java | 18 +++++++---- .../form/parameter/FormParaDesigner.java | 16 ++++------ .../com/fr/design/mainframe/FormDesigner.java | 30 ++++++++----------- .../mainframe/FormHierarchyTreePane.java | 8 +---- 4 files changed, 30 insertions(+), 42 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/events/CreatorEventListenerTable.java b/designer-form/src/main/java/com/fr/design/designer/beans/events/CreatorEventListenerTable.java index 94665c02b..2c0c28504 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/events/CreatorEventListenerTable.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/events/CreatorEventListenerTable.java @@ -1,10 +1,11 @@ package com.fr.design.designer.beans.events; -import java.util.ArrayList; - import com.fr.design.designer.creator.XComponent; import com.fr.general.ComparatorUtils; +import javax.swing.SwingUtilities; +import java.util.ArrayList; + public class CreatorEventListenerTable { protected ArrayList listeners; @@ -18,7 +19,7 @@ public class CreatorEventListenerTable { return; } for (int i = 0; i < listeners.size(); i++) { - if (ComparatorUtils.equals(listener,listeners.get(i))) { + if (ComparatorUtils.equals(listener, listeners.get(i))) { listeners.set(i, listener); return; } @@ -26,10 +27,15 @@ public class CreatorEventListenerTable { listeners.add(listener); } - private void fireCreatorModified(DesignerEvent evt) { + private void fireCreatorModified(final DesignerEvent evt) { for (int i = 0; i < listeners.size(); i++) { - DesignerEditListener listener = listeners.get(i); - listener.fireCreatorModified(evt); + final DesignerEditListener listener = listeners.get(i); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + listener.fireCreatorModified(evt); + } + }); } } diff --git a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java index 1afd86743..bac50642e 100644 --- a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java +++ b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java @@ -51,7 +51,6 @@ import com.fr.stable.ArrayUtils; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JPanel; -import javax.swing.SwingUtilities; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; @@ -179,16 +178,11 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP @Override public void fireCreatorModified(final DesignerEvent evt) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - if (evt.getCreatorEventID() != DesignerEvent.CREATOR_SELECTED) { - paraDefinitePane.setParameterArray( - paraDefinitePane.getNoRepeatParas(DesignModelAdapter.getCurrentModelAdapter().getParameters())); - paraDefinitePane.refreshParameter(); - } - } - }); + if (evt.getCreatorEventID() != DesignerEvent.CREATOR_SELECTED) { + paraDefinitePane.setParameterArray( + paraDefinitePane.getNoRepeatParas(DesignModelAdapter.getCurrentModelAdapter().getParameters())); + paraDefinitePane.refreshParameter(); + } } }); } 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 c3a3dc41c..5dd42de8d 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 @@ -71,7 +71,6 @@ import javax.swing.Action; import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.JPanel; -import javax.swing.SwingUtilities; import javax.swing.TransferHandler; import javax.swing.border.Border; import javax.swing.event.TreeSelectionEvent; @@ -693,24 +692,19 @@ public class FormDesigner extends TargetComponent implements TreeSelection getEditListenerTable().addListener(new DesignerEditListener() { @Override - public void fireCreatorModified(final DesignerEvent evt) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - // 只有选择组件时不触发模版更新,其他都要触发 - if (evt.getCreatorEventID() != DesignerEvent.CREATOR_SELECTED) { - FormDesigner.this.fireTargetModified(); - if (evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED) { - setParameterArray(getNoRepeatParas(getTarget().getParameters())); - refreshParameter(); - } - } else { - for (UpdateAction action : getActions()) { - action.update(); - } - } + public void fireCreatorModified(DesignerEvent evt) { + // 只有选择组件时不触发模版更新,其他都要触发 + if (evt.getCreatorEventID() != DesignerEvent.CREATOR_SELECTED) { + FormDesigner.this.fireTargetModified(); + if (evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED) { + setParameterArray(getNoRepeatParas(getTarget().getParameters())); + refreshParameter(); } - }); + } else { + for (UpdateAction action : getActions()) { + action.update(); + } + } } }); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java b/designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java index 12d109802..3346f7d14 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java @@ -23,7 +23,6 @@ import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JPanel; -import javax.swing.SwingUtilities; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; @@ -103,12 +102,7 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree formDesigner.addDesignerEditListener(new DesignerEditListener() { @Override public void fireCreatorModified(DesignerEvent evt) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - refreshComponentTree(); - } - }); + refreshComponentTree(); } });