From de747cfbd8a1516d0dba00e01c4ec0ccb0f4feb3 Mon Sep 17 00:00:00 2001 From: xiaxiang <1438003374@qq.com> Date: Tue, 28 Jun 2016 14:06:11 +0800 Subject: [PATCH] rt --- .../src/com/fr/design/mainframe/JForm.java | 15 +++-- .../actions/TemplateParameterAction.java | 60 +++++++++++++++++++ 2 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 designer_form/src/com/fr/design/mainframe/actions/TemplateParameterAction.java diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index e7342fc875..0ab170429b 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -20,14 +20,12 @@ import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.xpane.FormHyperlinkGroupPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.actions.EmbeddedFormExportExportAction; +import com.fr.design.mainframe.actions.TemplateParameterAction; import com.fr.design.mainframe.form.FormECCompositeProvider; import com.fr.design.mainframe.form.FormECDesignerProvider; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; -import com.fr.design.menu.KeySetUtils; -import com.fr.design.menu.MenuDef; -import com.fr.design.menu.ShortCut; -import com.fr.design.menu.ToolBarDef; +import com.fr.design.menu.*; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.utils.gui.LayoutUtils; import com.fr.file.FILE; @@ -378,8 +376,13 @@ public class JForm extends JTemplate implements BaseJForm { * @return 返回菜单 */ public ShortCut[] shortcut4TemplateMenu() { - return this.index == FORM_TAB ? new ShortCut[0] : - this.elementCaseDesign.shortcut4TemplateMenu(); + if (this.index == FORM_TAB) { + return (ShortCut[]) ArrayUtils.addAll(new ShortCut[]{ + new TemplateParameterAction(this) + }, new ShortCut[0]); + } else { + return this.elementCaseDesign.shortcut4TemplateMenu(); + } } /** diff --git a/designer_form/src/com/fr/design/mainframe/actions/TemplateParameterAction.java b/designer_form/src/com/fr/design/mainframe/actions/TemplateParameterAction.java new file mode 100644 index 0000000000..59e08ae03b --- /dev/null +++ b/designer_form/src/com/fr/design/mainframe/actions/TemplateParameterAction.java @@ -0,0 +1,60 @@ +package com.fr.design.mainframe.actions; + +import com.fr.base.BaseUtils; +import com.fr.base.Parameter; +import com.fr.design.actions.JTemplateAction; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.JForm; +import com.fr.design.menu.KeySetUtils; +import com.fr.design.parameter.ParameterArrayPane; +import com.fr.form.main.Form; + +import javax.swing.*; +import java.awt.event.ActionEvent; + +/** + * Created by 夏翔 on 2016/6/18. + */ +public class TemplateParameterAction extends JTemplateAction { + public TemplateParameterAction(JForm jwb) { + super(jwb); + this.setMenuKeySet(KeySetUtils.REPORT_PARAMETER_ATTR); + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/p.png")); + } + + @Override + public void actionPerformed(ActionEvent e) { + final JForm jwb = getEditingComponent(); + if (jwb == null) { + return; + } + final Form wbTpl = jwb.getTarget(); + + final ParameterArrayPane parameterArrayPane = new ParameterArrayPane(); + BasicDialog parameterArrayDialog = parameterArrayPane.showWindow(SwingUtilities.getWindowAncestor(jwb)); + parameterArrayDialog.setModal(true); + + final Parameter[] copyTemplateParameters = wbTpl.getTemplateParameters(); + parameterArrayPane.populate(copyTemplateParameters); + parameterArrayDialog.addDialogActionListener(new DialogActionAdapter() { + + @Override + public void doOk() { + wbTpl.clearParameters(); + Parameter[] parameters = parameterArrayPane.updateParameters(); + for (int i = 0; i < parameters.length; i++) { + wbTpl.addParameter(parameters[i]); + } + jwb.fireTargetModified(); + jwb.getFormDesign().setParameterArray(parameters); + jwb.getFormDesign().refreshParameter(); + } + }); + parameterArrayDialog.setVisible(true); + + } + +}