Browse Source

REPORT-14361 部分操作可能导致AWT EDT线程同步异常

bugfix/10.0
yaoh.wu 6 years ago
parent
commit
dbc09c2781
  1. 2
      designer-base/src/main/java/com/fr/design/parameter/ParaDefinitePane.java
  2. 7
      designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditListener.java
  3. 62
      designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java
  4. 30
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  5. 349
      designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java

2
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(); }
package com.fr.design.parameter; import com.fr.base.Parameter; public interface ParaDefinitePane { public Parameter[] getNoRepeatParas(Parameter[] paras); public Parameter[] getNoRepeatParas(Parameter[] paras); public Parameter[] getNoRepeatParas(Parameter[] paras); public void setParameterArray(Parameter[] ps); public Parameter[] getNoRepeatParas(Parameter[] paras); public Parameter[] getParameterArray(); public Parameter[] getNoRepeatParas(Parameter[] paras); public void refreshParameter(); public Parameter[] getNoRepeatParas(Parameter[] paras); public boolean isWithQueryButton(); public Parameter[] getNoRepeatParas(Parameter[] paras); public void addingParameter2Editor(Parameter p); public Parameter[] getNoRepeatParas(Parameter[] paras); public void addingParameter2EditorWithQueryButton(Parameter p); void addingAllParameter2Editor(); }

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

62
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) {

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

349
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<ShortCut4JControlPane> 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);
}
}
}
Loading…
Cancel
Save