From f6f5da0f009caa8ee65d9545cbf2f873e2584af3 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Mon, 21 Jan 2019 20:57:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E4=B8=8A=E5=B1=82=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E5=A4=84=E7=90=86=20swing=20=E7=BA=BF=E7=A8=8B=E5=90=8C?= =?UTF-8?q?=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(); } });