Browse Source

REPORT-57590 表单参数面板剪切复制按钮禁用

zheng-1641779399395
kuangshuai 3 years ago
parent
commit
8857a2d07f
  1. 5
      designer-form/src/main/java/com/fr/design/designer/beans/actions/CopyAction.java
  2. 3
      designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java
  3. 6
      designer-form/src/main/java/com/fr/design/designer/beans/actions/FormDeleteAction.java
  4. 16
      designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/CopyableEnable.java
  5. 16
      designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/CutableEnable.java
  6. 16
      designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/DeletableEnable.java
  7. 8
      designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java
  8. 17
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

5
designer-form/src/main/java/com/fr/design/designer/beans/actions/CopyAction.java

@ -1,8 +1,7 @@
package com.fr.design.designer.beans.actions; package com.fr.design.designer.beans.actions;
import com.fr.design.base.mode.DesignModeContext; import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.designer.beans.actions.behavior.ComponentEnable; import com.fr.design.designer.beans.actions.behavior.CopyableEnable;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
@ -18,7 +17,7 @@ public class CopyAction extends FormWidgetEditAction {
this.setMnemonic('C'); this.setMnemonic('C');
this.setSmallIcon("/com/fr/design/images/m_edit/copy"); this.setSmallIcon("/com/fr/design/images/m_edit/copy");
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER)); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER));
setUpdateBehavior(new ComponentEnable()); setUpdateBehavior(new CopyableEnable());
this.setEnabled(!DesignModeContext.isBanCopyAndCut()); this.setEnabled(!DesignModeContext.isBanCopyAndCut());
} }

3
designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java

@ -3,6 +3,7 @@ package com.fr.design.designer.beans.actions;
import com.fr.design.base.mode.DesignModeContext; import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.designer.beans.actions.behavior.ComponentEnable; import com.fr.design.designer.beans.actions.behavior.ComponentEnable;
import com.fr.design.designer.beans.actions.behavior.CutableEnable;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
@ -18,7 +19,7 @@ public class CutAction extends FormWidgetEditAction {
this.setMnemonic('T'); this.setMnemonic('T');
this.setSmallIcon("/com/fr/design/images/m_edit/cut"); this.setSmallIcon("/com/fr/design/images/m_edit/cut");
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER));
this.setUpdateBehavior(new ComponentEnable()); this.setUpdateBehavior(new CutableEnable());
this.setEnabled(!DesignModeContext.isBanCopyAndCut()); this.setEnabled(!DesignModeContext.isBanCopyAndCut());
} }

6
designer-form/src/main/java/com/fr/design/designer/beans/actions/FormDeleteAction.java

@ -7,9 +7,7 @@ import java.awt.event.KeyEvent;
import javax.swing.*; import javax.swing.*;
import com.fr.design.designer.beans.actions.behavior.DeletableEnable;
import com.fr.design.designer.beans.actions.behavior.ComponentEnable;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
/** /**
@ -26,7 +24,7 @@ public class FormDeleteAction extends FormWidgetEditAction {
// Richie:删除菜单图标 // Richie:删除菜单图标
this.setSmallIcon("/com/fr/design/images/m_report/delete"); this.setSmallIcon("/com/fr/design/images/m_report/delete");
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0)); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0));
this.setUpdateBehavior(new ComponentEnable()); this.setUpdateBehavior(new DeletableEnable());
} }
@Override @Override

16
designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/CopyableEnable.java

@ -0,0 +1,16 @@
package com.fr.design.designer.beans.actions.behavior;
import com.fr.design.designer.beans.actions.FormWidgetEditAction;
import com.fr.design.mainframe.FormDesigner;
public class CopyableEnable implements UpdateBehavior<FormWidgetEditAction> {
@Override
public void doUpdate(FormWidgetEditAction action) {
FormDesigner designer = action.getEditingComponent();
if (designer == null) {
action.setEnabled(false);
return;
}
action.setEnabled(designer.isCurrentComponentCopyable());
}
}

16
designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/CutableEnable.java

@ -0,0 +1,16 @@
package com.fr.design.designer.beans.actions.behavior;
import com.fr.design.designer.beans.actions.FormWidgetEditAction;
import com.fr.design.mainframe.FormDesigner;
public class CutableEnable implements UpdateBehavior<FormWidgetEditAction> {
@Override
public void doUpdate(FormWidgetEditAction action) {
FormDesigner designer = action.getEditingComponent();
if (designer == null) {
action.setEnabled(false);
return;
}
action.setEnabled(designer.isCurrentComponentCutable());
}
}

16
designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/DeletableEnable.java

@ -0,0 +1,16 @@
package com.fr.design.designer.beans.actions.behavior;
import com.fr.design.designer.beans.actions.FormWidgetEditAction;
import com.fr.design.mainframe.FormDesigner;
public class DeletableEnable implements UpdateBehavior<FormWidgetEditAction> {
@Override
public void doUpdate(FormWidgetEditAction action) {
FormDesigner designer = action.getEditingComponent();
if (designer == null) {
action.setEnabled(false);
return;
}
action.setEnabled(designer.isCurrentComponentDeletable());
}
}

8
designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java

@ -745,5 +745,13 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
return false; return false;
} }
@Override
public boolean isCurrentComponentCutable() {
return !isRootSelected();
}
@Override
public boolean isCurrentComponentCopyable() {
return !isRootSelected();
}
} }

17
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -1266,6 +1266,11 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return isForm || isRoot(getSelectionModel().getSelection().getSelectedCreator()); return isForm || isRoot(getSelectionModel().getSelection().getSelectedCreator());
} }
public boolean isParameterSelected() {
XCreator xCreator = getSelectionModel().getSelection().getSelectedCreator();
return xCreator != null && xCreator.acceptType(XWParameterLayout.class);
}
/** /**
* 显示权限编辑界面 * 显示权限编辑界面
*/ */
@ -1384,6 +1389,18 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
} }
} }
public boolean isCurrentComponentCutable() {
return !(isRootSelected() || isParameterSelected());
}
public boolean isCurrentComponentCopyable() {
return !(isRootSelected() || isParameterSelected());
}
public boolean isCurrentComponentDeletable() {
return !isRootSelected();
}
// 当前选中控件可以上移一层吗? // 当前选中控件可以上移一层吗?
public boolean isCurrentComponentMovableUp() { public boolean isCurrentComponentMovableUp() {
XCreator creator = getSelectionModel().getSelection().getSelectedCreator(); XCreator creator = getSelectionModel().getSelection().getSelectedCreator();

Loading…
Cancel
Save