From 3c01476b7b09a6b47117c93de4825e803e9d6759 Mon Sep 17 00:00:00 2001 From: plough Date: Mon, 11 Dec 2017 15:12:26 +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>5=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=20delete=20=E5=92=8C=20backspace=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../beans/actions/FormDeleteAction.java | 83 ++++++++++--------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/designer_form/src/com/fr/design/designer/beans/actions/FormDeleteAction.java b/designer_form/src/com/fr/design/designer/beans/actions/FormDeleteAction.java index 58c30543c7..6678200cfd 100644 --- a/designer_form/src/com/fr/design/designer/beans/actions/FormDeleteAction.java +++ b/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 javax.swing.KeyStroke; +import javax.swing.*; import com.fr.base.BaseUtils; import com.fr.general.Inter; @@ -19,44 +19,45 @@ import com.fr.design.mainframe.FormSelection; */ public class FormDeleteAction extends FormUndoableAction { - public FormDeleteAction(FormDesigner t) { - super(t); - - this.setName(Inter.getLocText("M_Edit-Delete")); - this.setMnemonic('D'); - // Richie:删除菜单图标 - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/delete.png")); - this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)); - } - - /** - * 删除 - * - * @return 是否删除成功 - */ - @Override - public boolean executeActionReturnUndoRecordNeeded() { - FormDesigner designer = getEditingComponent(); - if (designer == null) { - return false; - } - FormSelection selection = designer.getSelectionModel().getSelection(); - XCreator creator = selection.getSelectedCreator(); - designer.getSelectionModel().deleteSelection(); - - creator.deleteRelatedComponent(creator, designer); - return false; - } - - @Override - public void update() { -// FormDesigner f = this.getEditingComponent(); -// if (f == null) { -// this.setEnabled(false); -// return; -// } -// SelectionModel selection = f.getSelectionModel(); -// this.setEnabled(selection.hasSelectionComponent()); - this.setEnabled(true); - } + public FormDeleteAction(FormDesigner t) { + super(t); + + this.setName(Inter.getLocText("M_Edit-Delete")); + this.setMnemonic('D'); + // Richie:删除菜单图标 + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/delete.png")); + this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0)); + } + + @Override + public JComponent createToolBarComponent() { + JComponent comp = super.createToolBarComponent(); + // 除了 BACKSPACE 之外,DELETE 键也要能删除(直接在此处添加绑定,没有按钮提示) + comp.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); + return comp; + } + + /** + * 删除 + * + * @return 是否删除成功 + */ + @Override + public boolean executeActionReturnUndoRecordNeeded() { + FormDesigner designer = getEditingComponent(); + if (designer == null) { + return false; + } + FormSelection selection = designer.getSelectionModel().getSelection(); + XCreator creator = selection.getSelectedCreator(); + designer.getSelectionModel().deleteSelection(); + + creator.deleteRelatedComponent(creator, designer); + return false; + } + + @Override + public void update() { + this.setEnabled(true); + } } \ No newline at end of file