Browse Source

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

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

18
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;
@ -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);
}
});
}
}

16
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();
}
}
});
}

30
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<Form> 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();
}
}
}
});

8
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();
}
});

Loading…
Cancel
Save