diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..bffddaa --- /dev/null +++ b/build.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo-design-rightSelection.iml b/demo-design-rightSelection.iml new file mode 100644 index 0000000..19dbd15 --- /dev/null +++ b/demo-design-rightSelection.iml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..d59f89e --- /dev/null +++ b/plugin.xml @@ -0,0 +1,15 @@ + + com.fr.plugin.designer.right.selection + + yes + 1.0 + 9.0 + 2018-11-13 + zack + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..eb2524d --- /dev/null +++ b/pom.xml @@ -0,0 +1,18 @@ + + + 4.0.0 + + + com.fr.plugin + starter + 10.0 + + jar + demo-design-rightSelection + + + E:/默认工程/WebReport90/WEB-INF/plugins/plugin-com.fr.plugin.designer.right.selection-1.0/classes + + \ No newline at end of file diff --git a/screenshots/demo.png b/screenshots/demo.png new file mode 100644 index 0000000..5d9ff85 Binary files /dev/null and b/screenshots/demo.png differ diff --git a/src/main/java/com/fr/plugin/designer/MyActionImpl.java b/src/main/java/com/fr/plugin/designer/MyActionImpl.java new file mode 100644 index 0000000..031eaa6 --- /dev/null +++ b/src/main/java/com/fr/plugin/designer/MyActionImpl.java @@ -0,0 +1,41 @@ +package com.fr.plugin.designer; + +import com.fr.design.actions.UpdateAction; +import com.fr.design.designer.TargetComponent; +import com.fr.design.fun.impl.AbstractRightSelectionHandlerProvider; +import com.fr.design.gui.imenu.UIPopupMenu; +import com.fr.design.mainframe.BaseFormDesigner; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.selection.SelectableElement; +import com.fr.grid.selection.CellSelection; +import com.fr.grid.selection.FloatSelection; +import com.fr.plugin.transform.ExecuteFunctionRecord; +import com.fr.plugin.transform.FunctionRecorder; + +import java.util.List; + +@FunctionRecorder +public class MyActionImpl extends AbstractRightSelectionHandlerProvider { + + + @Override + @ExecuteFunctionRecord + public void dmlMenu(TargetComponent ePane, UIPopupMenu popupMenu) { + popupMenu.add(new MyCopyAction(ePane).createMenuItem()); + } + + @Override + public boolean accept(SelectableElement selectableElement) { + return selectableElement instanceof CellSelection || selectableElement instanceof FloatSelection; + } + + @Override + public void dmlUpdateActions(BaseFormDesigner formDesigner ,List actions) { + actions.add(new MyCutAction((FormDesigner) formDesigner)); + } + + @Override + public boolean accept(BaseFormDesigner formDesigner) { + return formDesigner instanceof FormDesigner; + } +} \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/designer/MyCopyAction.java b/src/main/java/com/fr/plugin/designer/MyCopyAction.java new file mode 100644 index 0000000..d937a2c --- /dev/null +++ b/src/main/java/com/fr/plugin/designer/MyCopyAction.java @@ -0,0 +1,46 @@ +/* + * Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. + */ +package com.fr.plugin.designer; + +import com.fr.base.BaseUtils; +import com.fr.design.actions.TemplateComponentAction; +import com.fr.design.designer.TargetComponent; +import com.fr.general.Inter; + +import javax.swing.KeyStroke; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; + +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + +/** + * Cut. + */ +public class MyCopyAction extends TemplateComponentAction { + /** + * Constructor + */ + public MyCopyAction(TargetComponent t) { + super(t); + + this.setName(Inter.getLocText("新增插件菜单测试")); + this.setMnemonic('T'); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png")); + this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)); + } + + @Override + public boolean executeActionReturnUndoRecordNeeded() { + TargetComponent editPane = getEditingComponent(); + if (editPane == null) { + return false; + } + return editPane.cut(); + } + + @Override + public void actionPerformed(ActionEvent evt) { + System.out.println(111111); + } +} \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/designer/MyCutAction.java b/src/main/java/com/fr/plugin/designer/MyCutAction.java new file mode 100644 index 0000000..579e1bb --- /dev/null +++ b/src/main/java/com/fr/plugin/designer/MyCutAction.java @@ -0,0 +1,40 @@ +package com.fr.plugin.designer; + +import com.fr.base.BaseUtils; +import com.fr.design.actions.UndoableAction; +import com.fr.design.mainframe.FormDesigner; +import com.fr.general.Inter; + +import javax.swing.KeyStroke; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; + +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + +/** + * 注意表单和参数面板的右键扩展必须是UndoableAction的子类 + */ +public class MyCutAction extends UndoableAction { + + public MyCutAction(FormDesigner t) { + this.setName(Inter.getLocText("M_Edit-Cut")); + this.setMnemonic('T'); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png")); + this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)); + } + + @Override + public void actionPerformed(ActionEvent e) { + System.out.println("3333333"); + } + + @Override + public boolean executeActionReturnUndoRecordNeeded() { + return false; + } + + @Override + public void prepare4Undo() { + + } +} \ No newline at end of file