Browse Source

REPORT-4634 组件叠加体验优化=>5 支持 delete 和 backspace 删除组件

master
plough 7 years ago
parent
commit
3c01476b7b
  1. 83
      designer_form/src/com/fr/design/designer/beans/actions/FormDeleteAction.java

83
designer_form/src/com/fr/design/designer/beans/actions/FormDeleteAction.java

@ -5,7 +5,7 @@ package com.fr.design.designer.beans.actions;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import javax.swing.KeyStroke; import javax.swing.*;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
@ -19,44 +19,45 @@ import com.fr.design.mainframe.FormSelection;
*/ */
public class FormDeleteAction extends FormUndoableAction { public class FormDeleteAction extends FormUndoableAction {
public FormDeleteAction(FormDesigner t) { public FormDeleteAction(FormDesigner t) {
super(t); super(t);
this.setName(Inter.getLocText("M_Edit-Delete")); this.setName(Inter.getLocText("M_Edit-Delete"));
this.setMnemonic('D'); this.setMnemonic('D');
// Richie:删除菜单图标 // Richie:删除菜单图标
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/delete.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/delete.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0));
} }
/** @Override
* 删除 public JComponent createToolBarComponent() {
* JComponent comp = super.createToolBarComponent();
* @return 是否删除成功 // 除了 BACKSPACE 之外,DELETE 键也要能删除(直接在此处添加绑定,没有按钮提示)
*/ comp.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
@Override return comp;
public boolean executeActionReturnUndoRecordNeeded() { }
FormDesigner designer = getEditingComponent();
if (designer == null) { /**
return false; * 删除
} *
FormSelection selection = designer.getSelectionModel().getSelection(); * @return 是否删除成功
XCreator creator = selection.getSelectedCreator(); */
designer.getSelectionModel().deleteSelection(); @Override
public boolean executeActionReturnUndoRecordNeeded() {
creator.deleteRelatedComponent(creator, designer); FormDesigner designer = getEditingComponent();
return false; if (designer == null) {
} return false;
}
@Override FormSelection selection = designer.getSelectionModel().getSelection();
public void update() { XCreator creator = selection.getSelectedCreator();
// FormDesigner f = this.getEditingComponent(); designer.getSelectionModel().deleteSelection();
// if (f == null) {
// this.setEnabled(false); creator.deleteRelatedComponent(creator, designer);
// return; return false;
// } }
// SelectionModel selection = f.getSelectionModel();
// this.setEnabled(selection.hasSelectionComponent()); @Override
this.setEnabled(true); public void update() {
} this.setEnabled(true);
}
} }
Loading…
Cancel
Save