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