From 15496270fec145bf72306e71839e5b8cba5acba2 Mon Sep 17 00:00:00 2001 From: plough Date: Thu, 7 Dec 2017 15:20:09 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-4634=20=E7=BB=84=E4=BB=B6=E5=8F=A0?= =?UTF-8?q?=E5=8A=A0=E4=BD=93=E9=AA=8C=E4=BC=98=E5=8C=96=3D>3=3D>=E5=A4=84?= =?UTF-8?q?=E7=90=86=E6=93=8D=E4=BD=9C=E7=BD=AE=E7=81=B0=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../beans/actions/MoveDownAction.java | 9 ++++++ .../beans/actions/MoveToBottomAction.java | 10 +++++++ .../beans/actions/MoveToTopAction.java | 10 +++++++ .../designer/beans/actions/MoveUpAction.java | 10 +++++++ .../fr/design/designer/creator/XCreator.java | 28 ++++++++++++------- .../creator/XWAbsoluteBodyLayout.java | 4 +++ .../design/designer/creator/XWFitLayout.java | 6 +++- .../designer/creator/XWParameterLayout.java | 5 ++++ .../form/parameter/FormParaDesigner.java | 5 ++-- .../com/fr/design/mainframe/FormDesigner.java | 25 +++++++++++++++-- 10 files changed, 96 insertions(+), 16 deletions(-) diff --git a/designer_form/src/com/fr/design/designer/beans/actions/MoveDownAction.java b/designer_form/src/com/fr/design/designer/beans/actions/MoveDownAction.java index 7310016620..1fb579c685 100644 --- a/designer_form/src/com/fr/design/designer/beans/actions/MoveDownAction.java +++ b/designer_form/src/com/fr/design/designer/beans/actions/MoveDownAction.java @@ -47,4 +47,13 @@ public class MoveDownAction extends FormEditAction { return true; } + @Override + public void update() { + FormDesigner designer = getEditingComponent(); + if (designer == null) { + this.setEnabled(false); + return; + } + this.setEnabled(designer.isCurrentComponentMovableDown()); + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/beans/actions/MoveToBottomAction.java b/designer_form/src/com/fr/design/designer/beans/actions/MoveToBottomAction.java index ac1ab74b5a..61d36afd74 100644 --- a/designer_form/src/com/fr/design/designer/beans/actions/MoveToBottomAction.java +++ b/designer_form/src/com/fr/design/designer/beans/actions/MoveToBottomAction.java @@ -47,4 +47,14 @@ public class MoveToBottomAction extends FormEditAction { return true; } + + @Override + public void update() { + FormDesigner designer = getEditingComponent(); + if (designer == null) { + this.setEnabled(false); + return; + } + this.setEnabled(designer.isCurrentComponentMovableDown()); + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/beans/actions/MoveToTopAction.java b/designer_form/src/com/fr/design/designer/beans/actions/MoveToTopAction.java index 8a37926936..5a69b2d101 100644 --- a/designer_form/src/com/fr/design/designer/beans/actions/MoveToTopAction.java +++ b/designer_form/src/com/fr/design/designer/beans/actions/MoveToTopAction.java @@ -46,4 +46,14 @@ public class MoveToTopAction extends FormEditAction { return true; } + @Override + public void update() { + FormDesigner designer = getEditingComponent(); + if (designer == null) { + this.setEnabled(false); + return; + } + this.setEnabled(designer.isCurrentComponentMovableUp()); + } + } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/beans/actions/MoveUpAction.java b/designer_form/src/com/fr/design/designer/beans/actions/MoveUpAction.java index b86e9807a9..3e214a768a 100644 --- a/designer_form/src/com/fr/design/designer/beans/actions/MoveUpAction.java +++ b/designer_form/src/com/fr/design/designer/beans/actions/MoveUpAction.java @@ -46,4 +46,14 @@ public class MoveUpAction extends FormEditAction { return true; } + @Override + public void update() { + FormDesigner designer = getEditingComponent(); + if (designer == null) { + this.setEnabled(false); + return; + } + this.setEnabled(designer.isCurrentComponentMovableUp()); + } + } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/XCreator.java b/designer_form/src/com/fr/design/designer/creator/XCreator.java index cc15466222..665db751a4 100644 --- a/designer_form/src/com/fr/design/designer/creator/XCreator.java +++ b/designer_form/src/com/fr/design/designer/creator/XCreator.java @@ -4,6 +4,7 @@ package com.fr.design.designer.creator; import com.fr.base.BaseUtils; +import com.fr.design.actions.UpdateAction; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.actions.*; @@ -48,8 +49,9 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo private Rectangle backupBound; private String shareId = StringUtils.EMPTY;//如果组件是共享的会有这个属性 private boolean isHelpBtnOnFocus = false;//焦点是否在帮助按钮上 + private static final int SHORTS_SEPARATOR_POS = 4; // 弹出菜单分割的位置 - public XCreator(Widget ob, Dimension initSize) { + public XCreator(Widget ob, Dimension initSize) { this.data = ob; this.initEditor(); @@ -670,17 +672,23 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo * */ public JPopupMenu createPopupMenu(FormDesigner formDesigner) { + UpdateAction[] actions = formDesigner.getActions(); JPopupMenu popup = new JPopupMenu(); - popup.add(new CutAction(formDesigner).createMenuItem()); - popup.add(new CopyAction(formDesigner).createMenuItem()); - popup.add(new PasteAction(formDesigner).createMenuItem()); - popup.add(new FormDeleteAction(formDesigner).createMenuItem()); - popup.addSeparator(); - popup.add(new MoveToTopAction(formDesigner).createMenuItem()); - popup.add(new MoveToBottomAction(formDesigner).createMenuItem()); - popup.add(new MoveUpAction(formDesigner).createMenuItem()); - popup.add(new MoveDownAction(formDesigner).createMenuItem()); + for (int i = 0; i < actions.length; i++) { + if (i == SHORTS_SEPARATOR_POS) { + popup.addSeparator(); + } + popup.add(actions[i].createMenuItem()); + } return popup; } + /** + * 是否支持上移一层、下移一层等操作 + * + */ + public boolean isMovable() { + return true; + } + } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java index 895eaf0310..1c389230b6 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java @@ -107,5 +107,9 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout { initStyle(); } + @Override + public boolean isMovable() { + return false; + } } diff --git a/designer_form/src/com/fr/design/designer/creator/XWFitLayout.java b/designer_form/src/com/fr/design/designer/creator/XWFitLayout.java index 7e0600ba44..712a8588d1 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWFitLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/XWFitLayout.java @@ -1180,5 +1180,9 @@ public class XWFitLayout extends XLayoutContainer { public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { return new WidgetPropertyUIProvider[]{ new BodyMobilePropertyUI(this)}; } - + + @Override + public boolean isMovable() { + return false; + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java b/designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java index a158dc753d..84011c9c41 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java @@ -227,4 +227,9 @@ public class XWParameterLayout extends XWAbsoluteLayout { } + @Override + public boolean isMovable() { + return false; + } + } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java b/designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java index b9d24b2cd8..0b39f987d2 100644 --- a/designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java +++ b/designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java @@ -22,6 +22,7 @@ import com.fr.base.BaseUtils; import com.fr.base.Parameter; import com.fr.base.parameter.ParameterUI; import com.fr.design.DesignModelAdapter; +import com.fr.design.actions.UpdateAction; import com.fr.design.designer.beans.actions.CopyAction; import com.fr.design.designer.beans.actions.CutAction; import com.fr.design.designer.beans.actions.FormDeleteAction; @@ -322,9 +323,9 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP * * @return 同上 */ - public Action[] getActions() { + public UpdateAction[] getActions() { if (designerActions == null) { - designerActions = new Action[]{new CutAction(this), new CopyAction(this), new PasteAction(this), + designerActions = new UpdateAction[]{new CutAction(this), new CopyAction(this), new PasteAction(this), new FormDeleteAction(this)}; } return designerActions; diff --git a/designer_form/src/com/fr/design/mainframe/FormDesigner.java b/designer_form/src/com/fr/design/mainframe/FormDesigner.java index b24da9268c..dad299c2c9 100644 --- a/designer_form/src/com/fr/design/mainframe/FormDesigner.java +++ b/designer_form/src/com/fr/design/mainframe/FormDesigner.java @@ -4,6 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.base.Parameter; import com.fr.base.ScreenResolution; import com.fr.design.DesignState; +import com.fr.design.actions.UpdateAction; import com.fr.design.designer.TargetComponent; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.Painter; @@ -105,7 +106,7 @@ public class FormDesigner extends TargetComponent
implements TreeSelection private int resolution = ScreenResolution.getScreenResolution(); // 编辑状态的事件表 private CreatorEventListenerTable edit; - protected Action[] designerActions; + protected UpdateAction[] designerActions; private FormDesignerModeForSpecial desigerMode; private Action switchAction; private FormElementCaseContainerProvider elementCaseContainer; @@ -668,6 +669,10 @@ public class FormDesigner extends TargetComponent implements TreeSelection setParameterArray(getNoRepeatParas(getTarget().getParameters())); refreshParameter(); } + } else { + for( UpdateAction action : getActions()) { + action.update(); + } } } @@ -1122,15 +1127,29 @@ public class FormDesigner extends TargetComponent implements TreeSelection * * @return 同上 */ - public Action[] getActions() { + public UpdateAction[] getActions() { if (designerActions == null) { - designerActions = new Action[]{new CutAction(this), new CopyAction(this), new PasteAction(this), + designerActions = new UpdateAction[]{new CutAction(this), new CopyAction(this), new PasteAction(this), new FormDeleteAction(this), new MoveToTopAction(this), new MoveToBottomAction(this), new MoveUpAction(this), new MoveDownAction(this)}; } return designerActions; } + // 当前选中控件可以上移一层吗? + public boolean isCurrentComponentMovableUp() { + XCreator creator = getSelectionModel().getSelection().getSelectedCreator(); + Container container = creator.getParent(); + return creator.isMovable() && container.getComponentZOrder(creator) > 0; + } + + // 当前选中控件可以下移一层吗? + public boolean isCurrentComponentMovableDown() { + XCreator creator = getSelectionModel().getSelection().getSelectedCreator(); + Container container = creator.getParent(); + return creator.isMovable() && container.getComponentZOrder(creator) < container.getComponentCount() - 1; + } + protected Border getOuterBorder() { return XCreatorConstants.AREA_BORDER; }