Browse Source

在上层统一处理 swing 线程同步问题

bugfix/10.0
yaoh.wu 6 years ago
parent
commit
f6f5da0f00
  1. 14
      designer-form/src/main/java/com/fr/design/designer/beans/events/CreatorEventListenerTable.java
  2. 6
      designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java
  3. 8
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  4. 6
      designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java

14
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<DesignerEditListener> listeners;
@ -26,11 +27,16 @@ 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);
final DesignerEditListener listener = listeners.get(i);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
listener.fireCreatorModified(evt);
}
});
}
}
public void fireCreatorModified(XComponent creator, int eventID) {

6
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,9 +178,6 @@ 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()));
@ -190,8 +186,6 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
}
});
}
});
}
/**
* 包裹一层FormArea

8
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,10 +692,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
getEditListenerTable().addListener(new DesignerEditListener() {
@Override
public void fireCreatorModified(final DesignerEvent evt) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
public void fireCreatorModified(DesignerEvent evt) {
// 只有选择组件时不触发模版更新,其他都要触发
if (evt.getCreatorEventID() != DesignerEvent.CREATOR_SELECTED) {
FormDesigner.this.fireTargetModified();
@ -710,8 +706,6 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
}
}
}
});
}
});

6
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,14 +102,9 @@ 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();
}
});
}
});
ComponentTreeModel treeModel = (ComponentTreeModel) componentTree.getModel();
XCreator root = (XCreator) treeModel.getRoot();

Loading…
Cancel
Save