diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java index ebe41b2bc7..3ddb144a5f 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java @@ -10,6 +10,7 @@ import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.form.event.Listener; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; @@ -76,9 +77,12 @@ class JControlUpdatePane extends JPanel { cardPane.add(updatePanes[i], String.valueOf(i)); } card.show(cardPane, String.valueOf(i)); - try{ + try { + if (ob2Populate instanceof Listener) { + listControlPane.wrapperListener((Listener) ob2Populate); + } updatePanes[i].populateBean(ob2Populate); - }catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } break; @@ -103,12 +107,15 @@ class JControlUpdatePane extends JPanel { if (pane != null && pane.isVisible()) { Object bean = pane.updateBean(); try { + if (bean instanceof Listener) { + listControlPane.wrapperListener((Listener) bean); + } if (bean instanceof RemoteDesignerWorkspaceInfo) { DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(elEditing.wrapper.getName()); String remindTime = info.getRemindTime(); ((RemoteDesignerWorkspaceInfo) bean).setRemindTime(remindTime); } - }catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().info("remindTime is not exist"); } if (i < creators.length) { diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java index b82a584679..f119c55cd3 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java @@ -6,6 +6,7 @@ import com.fr.design.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ModNameActionListener; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.form.event.Listener; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; import com.fr.invoke.Reflect; @@ -417,4 +418,10 @@ public abstract class JListControlPane extends JControlPane implements ListContr public JControlUpdatePane getControlUpdatePane() { return (JControlUpdatePane) controlUpdatePane; } + + @Override + public void wrapperListener(Listener listener){ + + } + } diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneProvider.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneProvider.java index 1565f348d0..6d000c1153 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneProvider.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneProvider.java @@ -3,6 +3,7 @@ package com.fr.design.gui.controlpane; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.ListModelElement; +import com.fr.form.event.Listener; import com.fr.stable.Nameable; import javax.swing.DefaultListModel; @@ -32,4 +33,6 @@ public interface ListControlPaneProvider extends UnrepeatedNameHelper { void showSelectPane(); void showEditPane(); ShortCut4JControlPane[] getShorts(); + + void wrapperListener(Listener listener); } diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java index b7b8674be7..7ba536492a 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java @@ -6,6 +6,7 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.UINameEdList; +import com.fr.form.event.Listener; import com.fr.stable.ArrayUtils; import com.fr.stable.Nameable; @@ -314,4 +315,10 @@ public abstract class UIListControlPane extends UIControlPane implements ListCon public JNameEdList getNameableList() { return nameableList; } + + @Override + public void wrapperListener(Listener listener){ + + } + } diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java index 82bf99bf33..6ec5f496a6 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java @@ -391,7 +391,7 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li @Override public Nameable[] update() { - java.util.List res = new java.util.ArrayList(); + List res = new ArrayList(); getControlUpdatePane().update(); Iterator> iterator = nameEdListMap.entrySet().iterator(); while (iterator.hasNext()) { @@ -516,6 +516,11 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li return StringUtils.EMPTY; } + @Override + public void wrapperListener(Listener listener){ + + } + private class ListWrapperPane extends JPanel { private UINameEdList nameEdList; diff --git a/designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java b/designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java index dbccb7c50c..e5100b54b3 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java @@ -1,16 +1,17 @@ package com.fr.design.javascript; -import com.fr.design.write.submit.DBManipulationPane; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.gui.frpane.CommitTabbedPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.layout.FRGUIPaneFactory; - +import com.fr.design.write.submit.DBManipulationPane; import com.fr.js.Commit2DBJavaScript; import com.fr.write.DBManipulation; -import javax.swing.*; -import java.awt.*; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Dimension; import java.util.ArrayList; import java.util.List; @@ -25,63 +26,64 @@ public class Commit2DBJavaScriptPane extends FurtherBasicBeanPane 1){ + /** + * 界面重置 + */ + public void reset() { + this.javaScriptActionPane.setCall(null); + //重置后只保留,只留第一个tab + while (dbmPaneList.size() > 1) { dbmPaneList.remove(1); } - ((DBManipulationPane)dbmPaneList.get(0)).populateBean(null); - } + ((DBManipulationPane) dbmPaneList.get(0)).populateBean(null); + } - @Override + @Override /** * 将JavaBean内的数据输出至界面上 */ @@ -131,11 +134,15 @@ public class Commit2DBJavaScriptPane extends FurtherBasicBeanPane { private List contentDBManiPane; + private JavaScriptResourceInfo resourceInfo; + private JavaScript call = null; public JavaScriptActionPane() { @@ -75,6 +78,14 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane { } + public JavaScriptResourceInfo getResourceInfo() { + return resourceInfo; + } + + public void setResourceInfo(JavaScriptResourceInfo resourceInfo) { + this.resourceInfo = resourceInfo; + } + /** * 生成回调函数的按钮 * @@ -182,8 +193,8 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane { * @return 返回生成的面板 */ - public static JavaScriptActionPane createDefault() { - return new JavaScriptActionPane() { + public static JavaScriptActionPane createDefault() { + return new JavaScriptActionPane() { @Override public DBManipulationPane createDBManipulationPane() { return new DBManipulationPane(); diff --git a/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java b/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java index df05e7880d..73e1caafa7 100644 --- a/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java +++ b/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java @@ -15,6 +15,8 @@ import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.write.submit.DBManipulationPane; import com.fr.form.event.Listener; import com.fr.js.JavaScript; +import com.fr.report.web.util.ReportEngineEventMapping; +import com.fr.write.JavaScriptResourceInfo; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -44,6 +46,8 @@ public class ListenerEditPane extends BasicBeanPane { private Listener listener; + JavaScriptActionPane javaScriptActionPane; + public ListenerEditPane() { this.initComponents(new String[0]); } @@ -87,7 +91,8 @@ public class ListenerEditPane extends BasicBeanPane { // 提交入库 List dbManiList = new ArrayList(); dbManiList.add(autoCreateDBManipulationPane()); - Commit2DBJavaScriptPane commit2DBJavaScriptPane = new Commit2DBJavaScriptPane(JavaScriptActionPane.createDefaultJavaScriptActionPane(), + javaScriptActionPane = JavaScriptActionPane.createDefaultJavaScriptActionPane(); + Commit2DBJavaScriptPane commit2DBJavaScriptPane = new Commit2DBJavaScriptPane(javaScriptActionPane, dbManiList); hyperlinkPane.add(DBCOMMIT, commit2DBJavaScriptPane); // 自定义事件 @@ -176,9 +181,12 @@ public class ListenerEditPane extends BasicBeanPane { @Override public Listener updateBean() { + String actionLocaleName = ReportEngineEventMapping.getLocaleName(listener.getEventName()); + javaScriptActionPane.setResourceInfo(new JavaScriptResourceInfo(JavaScriptResourceInfo.Type.WEB_CONFIG, Toolkit.i18nText(actionLocaleName))); this.listener.setEventName(this.nameText.getText()); FurtherBasicBeanPane pane = this.cards.get(this.styleBox.getSelectedIndex()); this.listener.setAction(pane.updateBean()); + return this.listener; } } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/webattr/EditToolBar.java b/designer-realize/src/main/java/com/fr/design/webattr/EditToolBar.java index f1cd05a907..c75c6607c7 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/EditToolBar.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/EditToolBar.java @@ -38,6 +38,7 @@ import com.fr.report.web.button.write.AppendColumnRow; import com.fr.report.web.button.write.Submit; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; +import com.fr.write.JavaScriptResourceInfo; import javax.swing.BorderFactory; import javax.swing.Box; @@ -67,473 +68,476 @@ import java.util.Set; public class EditToolBar extends BasicPane { - private static final String EMAIL = "email"; - private static final String CUSTOM = "custom"; - private static final String EXPORT = "export"; - private static final String NONE = "none"; - private static final String EDIT_EXCEL = "editexcel"; - private static final String APPEND_COUNT = "appendcount"; - private static final String SUBMIT = "submit"; - - private JWorkBook jwb; - private JList list; - private DefaultListModel listModel; - private JPanel right; - private CardLayout card; - private ButtonPane bp; - private ToolBarButton lastButton; - private Background background = null; - private UICheckBox defaultCheckBox; - - private ListSelectionListener listSelectionListener = new ListSelectionListener() { - public void valueChanged(ListSelectionEvent evt) { - if (lastButton != null) { - lastButton.setWidget(bp.update()); - } - if (list.getSelectedValue() instanceof ToolBarButton) { - lastButton = (ToolBarButton) list.getSelectedValue(); - if (lastButton.getWidget() instanceof Button) { - card.show(right, "button"); - bp.populate(lastButton.getWidget()); - } else { - bp.populate(lastButton.getWidget()); - card.show(right, "none"); - } - } - } - }; - - - private ActionListener actioner = new ActionListener() { - /** - * - */ - public void actionPerformed(ActionEvent arg0) { - final BackgroundPane backgroundPane = new BackgroundPane(); - BasicDialog dialog = backgroundPane.showWindow(DesignerContext.getDesignerFrame()); - backgroundPane.populate(EditToolBar.this.background); - dialog.addDialogActionListener(new DialogActionAdapter() { - public void doOk() { - EditToolBar.this.background = backgroundPane.update(); - if (EditToolBar.this.background != null) { - EditToolBar.this.defaultCheckBox.setSelected(false); - } - } - }); - dialog.setVisible(true); - } - }; - - public EditToolBar() { - initComponent(); - } - - /** - * 初始化 - */ - public void initComponent() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - JPanel left = FRGUIPaneFactory.createBorderLayout_S_Pane(); - listModel = new DefaultListModel(); - list = new JList(listModel); - list.setCellRenderer(render); - left.add(new JScrollPane(list), BorderLayout.CENTER); - if (listModel.getSize() > 0) { - list.setSelectedIndex(0); - } - - ToolBarDef toolbarDef = new ToolBarDef(); - toolbarDef.addShortCut(new MoveUpItemAction()); - toolbarDef.addShortCut(new MoveDownItemAction()); - toolbarDef.addShortCut(new RemoveAction()); - UIToolbar toolBar = ToolBarDef.createJToolBar(); - toolbarDef.updateToolBar(toolBar); - left.add(toolBar, BorderLayout.NORTH); - - right = FRGUIPaneFactory.createCardLayout_S_Pane(); - card = new CardLayout(); - right.setLayout(card); - bp = new ButtonPane(); - right.add("none", FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane()); - right.add("button", bp); - - JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, left, right); - // splitPane.setDividerLocation(left.getMinimumSize().width); - splitPane.setDividerLocation(120); - this.add(splitPane); - list.addListSelectionListener(listSelectionListener); - JPanel backgroundPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - UIButton bgButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Background")); - defaultCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default_Background")); - bgButton.addActionListener(actioner); - backgroundPane.add(defaultCheckBox); - backgroundPane.add(bgButton); - backgroundPane.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Background"))); - this.add(backgroundPane, BorderLayout.SOUTH); - } - - ListCellRenderer render = new DefaultListCellRenderer() { - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - if (value instanceof ToolBarButton) { - ToolBarButton button = (ToolBarButton) value; - this.setText(button.getNameOption().optionName()); - this.setIcon(button.getNameOption().optionIcon()); - } - return this; - } - }; - - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit"); - } - - public void populate(FToolBar ftoolbar) { - this.populate(ftoolbar, null); - } - - public void populate(FToolBar ftoolbar, ToolBarButton button) { - if (ftoolbar == null) { - return; - } - for (int i = 0; i < ftoolbar.getButtonlist().size(); i++) { - listModel.addElement(ftoolbar.getButtonlist().get(i)); - } - this.list.validate(); - this.list.repaint(); - if (ftoolbar.getButtonlist().size() > 0) { - this.list.setSelectedIndex(0); - } - if (button != null) { - this.list.setSelectedValue(button, true); - } - this.background = ftoolbar.getBackground(); - - this.defaultCheckBox.setSelected(ftoolbar.isDefault() ? true : false); - } - - public FToolBar update() { - if (this.list.getSelectedIndex() > -1) { - for (int i = 0; i < listModel.getSize(); i++) { - this.list.setSelectedIndex(i); - ToolBarButton toolBarButton = (ToolBarButton) this.list.getSelectedValue(); - Widget widget = this.bp.update(); - toolBarButton.setWidget(widget); - if (widget instanceof Button) { - String iconname = ((Button) widget).getIconName(); - if (StringUtils.isNotBlank(iconname)) { - Image iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(iconname); - if (iconImage != null) { - toolBarButton.setIcon(new ImageIcon(iconImage)); - } else { - FineLoggerFactory.getLogger().warn(iconname + " can not find in finedb!"); - } - } - } - } - } - List list = new ArrayList(); - for (int i = 0; i < listModel.size(); i++) { - list.add((ToolBarButton) listModel.get(i)); - } - FToolBar ftoolBar = new FToolBar(); - ftoolBar.setButtonlist(list); - - ftoolBar.setDefault(this.defaultCheckBox.isSelected()); - if (!ftoolBar.isDefault()) { - ftoolBar.setBackground(this.background); - } - return ftoolBar; - } - - private class MoveUpItemAction extends UpdateAction { - public MoveUpItemAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Move_Up")); - this.setMnemonic('U'); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/up.png")); - } - - /** - * - */ - public void actionPerformed(ActionEvent evt) { - int selectedIndex = list.getSelectedIndex(); - if (selectedIndex == -1) { - return; - } - - // 上移 - if (selectedIndex > 0) { - DefaultListModel listModel = (DefaultListModel) list.getModel(); - - Object selecteObj1 = listModel.get(selectedIndex - 1); - listModel.set(selectedIndex - 1, listModel.get(selectedIndex)); - listModel.set(selectedIndex, selecteObj1); - - list.setSelectedIndex(selectedIndex - 1); - list.ensureIndexIsVisible(selectedIndex - 1); - list.validate(); - } - } - } - - private class MoveDownItemAction extends UpdateAction { - public MoveDownItemAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Move_Down")); - this.setMnemonic('D'); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/down.png")); - } - - /** - * - */ - public void actionPerformed(ActionEvent evt) { - int selectedIndex = list.getSelectedIndex(); - if (selectedIndex == -1) { - return; - } - - // 下移 - if (selectedIndex == -1) { - return; - } - - if (selectedIndex < list.getModel().getSize() - 1) { - DefaultListModel listModel = (DefaultListModel) list.getModel(); - - Object selecteObj1 = listModel.get(selectedIndex + 1); - listModel.set(selectedIndex + 1, listModel.get(selectedIndex)); - listModel.set(selectedIndex, selecteObj1); - - list.setSelectedIndex(selectedIndex + 1); - list.ensureIndexIsVisible(selectedIndex + 1); - list.validate(); - } - } - } - - public class RemoveAction extends UpdateAction { - public RemoveAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Delete")); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/remove.png")); - } - - /** - * 动作 - * @param e 事件 - */ - public void actionPerformed(ActionEvent e) { - int i = list.getSelectedIndex(); - if (i < 0 || !(listModel.getElementAt(i) instanceof ToolBarButton)) { - return; - } - int val = FineJOptionPane.showConfirmDialog(EditToolBar.this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Are_You_Sure_To_Delete_The_Data") + "?", - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION); - if (val != JOptionPane.YES_OPTION) { - return; - } - listModel.removeElementAt(i); - list.validate(); - if (listModel.size() > 0) { - list.setSelectedIndex(0); - } else { - card.show(right, "none"); - } - } - } - - public class ButtonPane extends BasicPane { - private CardLayout card; - private JPanel centerPane; - private UICheckBox icon, text, pdf, excelP, excelO, excelS, image, word, - isPopup, isVerify, failSubmit, isCurSheet, excelImClean, - excelImCover, excelImAppend, excelImCust, - customConsignee, consigneeByDepartment, consigneeByRole; - private UIBasicSpinner count; - private Widget widget; - private UITextField nameField; - private IconDefinePane iconPane; - private UIButton button; - private JavaScriptActionPane javaScriptPane; - private ExportToolBarProvider[] exportToolBarProviders; - - private ActionListener actionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - if (isVerify.isSelected()) { - failSubmit.setVisible(true); - } else { - failSubmit.setVisible(false); - failSubmit.setSelected(false); - } - } - }; - - public ButtonPane() { - this.initComponents(); - } - - /** - * 初始化元素 - */ - public void initComponents() { - Set set = ExtraDesignClassManager.getInstance().getArray(ExportToolBarProvider.XML_TAG); - exportToolBarProviders = set.toArray(new ExportToolBarProvider[set.size()]); - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - JPanel north = FRGUIPaneFactory.createBorderLayout_S_Pane(); - icon = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Show_Icon")); - text = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Show_Text")); - - north.add(icon, BorderLayout.NORTH); - north.add(text, BorderLayout.CENTER); - - nameField = new UITextField(8); - iconPane = new IconDefinePane(); - javaScriptPane = JavaScriptActionPane.createDefault(); - - double p = TableLayout.PREFERRED; - double rowSize[] = {p, p}; - double columnSize[] = {p, p}; - - Component[][] coms = new Component[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Printer_Alias") + ":"), nameField}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Icon") + ":"), iconPane}}; - - JPanel nameIconPane = TableLayoutHelper.createTableLayoutPane(coms, rowSize, columnSize); - - north.add(nameIconPane, BorderLayout.SOUTH); - - north.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Form_Button_Property"))); - this.add(north, BorderLayout.NORTH); - JPanel none = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - centerPane = FRGUIPaneFactory.createCardLayout_S_Pane(); - card = new CardLayout(); - centerPane.setLayout(card); - centerPane.add(CUSTOM, getCustomPane()); - centerPane.add(EXPORT, getExport()); - centerPane.add(EMAIL, getEmail()); - centerPane.add(NONE, none); - centerPane.add(getCpane(), APPEND_COUNT); - centerPane.add(getSubmitPane(), SUBMIT); - - Set extraButtonSet = ExtraDesignClassManager.getInstance().getArray(ExtraButtonToolBarProvider.XML_TAG); - for (ExtraButtonToolBarProvider provider : extraButtonSet) { - provider.updateCenterPane(centerPane); - } - - this.add(centerPane, BorderLayout.CENTER); - } - - - private JPanel getCustomPane() { - JPanel customPane = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); - - button = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_User_Defined_Event")); - customPane.add(button); - customPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit") + "JS", null)); - button.addActionListener(l); - return customPane; - } - - private JPanel getExport() { - JPanel export = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); - // export.setLayout(new BoxLayout(export, BoxLayout.Y_AXIS)); - pdf = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_PDF")); - excelP = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Output_Excel_Page")); - excelO = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_Excel_Simple")); - excelS = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_Excel_Sheet")); - word = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_Word")); - image = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Image")); - export.add(pdf); - export.add(Box.createVerticalStrut(2)); - export.add(excelP); - export.add(Box.createVerticalStrut(2)); - export.add(excelO); - export.add(Box.createVerticalStrut(2)); - export.add(excelS); - export.add(Box.createVerticalStrut(2)); - export.add(word); - export.add(Box.createVerticalStrut(2)); - export.add(image); - for(int i=0; i 0) { + list.setSelectedIndex(0); + } + + ToolBarDef toolbarDef = new ToolBarDef(); + toolbarDef.addShortCut(new MoveUpItemAction()); + toolbarDef.addShortCut(new MoveDownItemAction()); + toolbarDef.addShortCut(new RemoveAction()); + UIToolbar toolBar = ToolBarDef.createJToolBar(); + toolbarDef.updateToolBar(toolBar); + left.add(toolBar, BorderLayout.NORTH); + + right = FRGUIPaneFactory.createCardLayout_S_Pane(); + card = new CardLayout(); + right.setLayout(card); + bp = new ButtonPane(); + right.add("none", FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane()); + right.add("button", bp); + + JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, left, right); + // splitPane.setDividerLocation(left.getMinimumSize().width); + splitPane.setDividerLocation(120); + this.add(splitPane); + list.addListSelectionListener(listSelectionListener); + JPanel backgroundPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + UIButton bgButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Background")); + defaultCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default_Background")); + bgButton.addActionListener(actioner); + backgroundPane.add(defaultCheckBox); + backgroundPane.add(bgButton); + backgroundPane.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Background"))); + this.add(backgroundPane, BorderLayout.SOUTH); + } + + ListCellRenderer render = new DefaultListCellRenderer() { + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + if (value instanceof ToolBarButton) { + ToolBarButton button = (ToolBarButton) value; + this.setText(button.getNameOption().optionName()); + this.setIcon(button.getNameOption().optionIcon()); + } + return this; + } + }; + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit"); + } + + public void populate(FToolBar ftoolbar) { + this.populate(ftoolbar, null); + } + + public void populate(FToolBar ftoolbar, ToolBarButton button) { + if (ftoolbar == null) { + return; + } + for (int i = 0; i < ftoolbar.getButtonlist().size(); i++) { + listModel.addElement(ftoolbar.getButtonlist().get(i)); + } + this.list.validate(); + this.list.repaint(); + if (ftoolbar.getButtonlist().size() > 0) { + this.list.setSelectedIndex(0); + } + if (button != null) { + this.list.setSelectedValue(button, true); + } + this.background = ftoolbar.getBackground(); + + this.defaultCheckBox.setSelected(ftoolbar.isDefault() ? true : false); + } + + public FToolBar update() { + if (this.list.getSelectedIndex() > -1) { + for (int i = 0; i < listModel.getSize(); i++) { + this.list.setSelectedIndex(i); + ToolBarButton toolBarButton = (ToolBarButton) this.list.getSelectedValue(); + Widget widget = this.bp.update(); + toolBarButton.setWidget(widget); + if (widget instanceof Button) { + String iconname = ((Button) widget).getIconName(); + if (StringUtils.isNotBlank(iconname)) { + Image iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(iconname); + if (iconImage != null) { + toolBarButton.setIcon(new ImageIcon(iconImage)); + } else { + FineLoggerFactory.getLogger().warn(iconname + " can not find in finedb!"); + } + } + } + } + } + List list = new ArrayList(); + for (int i = 0; i < listModel.size(); i++) { + list.add((ToolBarButton) listModel.get(i)); + } + FToolBar ftoolBar = new FToolBar(); + ftoolBar.setButtonlist(list); + + ftoolBar.setDefault(this.defaultCheckBox.isSelected()); + if (!ftoolBar.isDefault()) { + ftoolBar.setBackground(this.background); + } + return ftoolBar; + } + + private class MoveUpItemAction extends UpdateAction { + public MoveUpItemAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Move_Up")); + this.setMnemonic('U'); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/up.png")); + } + + /** + * + */ + public void actionPerformed(ActionEvent evt) { + int selectedIndex = list.getSelectedIndex(); + if (selectedIndex == -1) { + return; + } + + // 上移 + if (selectedIndex > 0) { + DefaultListModel listModel = (DefaultListModel) list.getModel(); + + Object selecteObj1 = listModel.get(selectedIndex - 1); + listModel.set(selectedIndex - 1, listModel.get(selectedIndex)); + listModel.set(selectedIndex, selecteObj1); + + list.setSelectedIndex(selectedIndex - 1); + list.ensureIndexIsVisible(selectedIndex - 1); + list.validate(); + } + } + } + + private class MoveDownItemAction extends UpdateAction { + public MoveDownItemAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Move_Down")); + this.setMnemonic('D'); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/down.png")); + } + + /** + * + */ + public void actionPerformed(ActionEvent evt) { + int selectedIndex = list.getSelectedIndex(); + if (selectedIndex == -1) { + return; + } + + // 下移 + if (selectedIndex == -1) { + return; + } + + if (selectedIndex < list.getModel().getSize() - 1) { + DefaultListModel listModel = (DefaultListModel) list.getModel(); + + Object selecteObj1 = listModel.get(selectedIndex + 1); + listModel.set(selectedIndex + 1, listModel.get(selectedIndex)); + listModel.set(selectedIndex, selecteObj1); + + list.setSelectedIndex(selectedIndex + 1); + list.ensureIndexIsVisible(selectedIndex + 1); + list.validate(); + } + } + } + + public class RemoveAction extends UpdateAction { + public RemoveAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Delete")); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/remove.png")); + } + + /** + * 动作 + * + * @param e 事件 + */ + public void actionPerformed(ActionEvent e) { + int i = list.getSelectedIndex(); + if (i < 0 || !(listModel.getElementAt(i) instanceof ToolBarButton)) { + return; + } + int val = FineJOptionPane.showConfirmDialog(EditToolBar.this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Are_You_Sure_To_Delete_The_Data") + "?", + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION); + if (val != JOptionPane.YES_OPTION) { + return; + } + listModel.removeElementAt(i); + list.validate(); + if (listModel.size() > 0) { + list.setSelectedIndex(0); + } else { + card.show(right, "none"); + } + } + } + + public class ButtonPane extends BasicPane { + private CardLayout card; + private JPanel centerPane; + private UICheckBox icon, text, pdf, excelP, excelO, excelS, image, word, + isPopup, isVerify, failSubmit, isCurSheet, excelImClean, + excelImCover, excelImAppend, excelImCust, + customConsignee, consigneeByDepartment, consigneeByRole; + private UIBasicSpinner count; + private Widget widget; + private UITextField nameField; + private IconDefinePane iconPane; + private UIButton button; + private JavaScriptActionPane javaScriptPane; + private ExportToolBarProvider[] exportToolBarProviders; + + private ActionListener actionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (isVerify.isSelected()) { + failSubmit.setVisible(true); + } else { + failSubmit.setVisible(false); + failSubmit.setSelected(false); + } + } + }; + + public ButtonPane() { + this.initComponents(); + } + + /** + * 初始化元素 + */ + public void initComponents() { + Set set = ExtraDesignClassManager.getInstance().getArray(ExportToolBarProvider.XML_TAG); + exportToolBarProviders = set.toArray(new ExportToolBarProvider[set.size()]); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel north = FRGUIPaneFactory.createBorderLayout_S_Pane(); + icon = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Show_Icon")); + text = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Show_Text")); + + north.add(icon, BorderLayout.NORTH); + north.add(text, BorderLayout.CENTER); + + nameField = new UITextField(8); + iconPane = new IconDefinePane(); + javaScriptPane = JavaScriptActionPane.createDefault(); + + double p = TableLayout.PREFERRED; + double rowSize[] = {p, p}; + double columnSize[] = {p, p}; + + Component[][] coms = new Component[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Printer_Alias") + ":"), nameField}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Icon") + ":"), iconPane}}; + + JPanel nameIconPane = TableLayoutHelper.createTableLayoutPane(coms, rowSize, columnSize); + + north.add(nameIconPane, BorderLayout.SOUTH); + + north.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Form_Button_Property"))); + this.add(north, BorderLayout.NORTH); + JPanel none = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + centerPane = FRGUIPaneFactory.createCardLayout_S_Pane(); + card = new CardLayout(); + centerPane.setLayout(card); + centerPane.add(CUSTOM, getCustomPane()); + centerPane.add(EXPORT, getExport()); + centerPane.add(EMAIL, getEmail()); + centerPane.add(NONE, none); + centerPane.add(getCpane(), APPEND_COUNT); + centerPane.add(getSubmitPane(), SUBMIT); + + Set extraButtonSet = ExtraDesignClassManager.getInstance().getArray(ExtraButtonToolBarProvider.XML_TAG); + for (ExtraButtonToolBarProvider provider : extraButtonSet) { + provider.updateCenterPane(centerPane); + } + + this.add(centerPane, BorderLayout.CENTER); + } + + + private JPanel getCustomPane() { + JPanel customPane = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); + + button = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_User_Defined_Event")); + customPane.add(button); + customPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit") + "JS", null)); + button.addActionListener(l); + return customPane; + } + + private JPanel getExport() { + JPanel export = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); + // export.setLayout(new BoxLayout(export, BoxLayout.Y_AXIS)); + pdf = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_PDF")); + excelP = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Output_Excel_Page")); + excelO = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_Excel_Simple")); + excelS = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_Excel_Sheet")); + word = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_Word")); + image = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Image")); + export.add(pdf); + export.add(Box.createVerticalStrut(2)); + export.add(excelP); + export.add(Box.createVerticalStrut(2)); + export.add(excelO); + export.add(Box.createVerticalStrut(2)); + export.add(excelS); + export.add(Box.createVerticalStrut(2)); + export.add(word); + export.add(Box.createVerticalStrut(2)); + export.add(image); + for (int i = 0; i < ArrayUtils.getLength(exportToolBarProviders); i++) { + export = exportToolBarProviders[i].updateCenterPane(export); + } + + export.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Form_Button_Property"), null)); + return export; + } + + private JPanel getEmail() { + JPanel email = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); + customConsignee = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Custom_Consignee")); + consigneeByDepartment = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Consignee_By_Department")); + consigneeByRole = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Consignee_By_Role")); + email.add(customConsignee); + email.add(Box.createVerticalStrut(2)); + email.add(consigneeByDepartment); + email.add(Box.createVerticalStrut(2)); + email.add(consigneeByRole); + email.add(Box.createVerticalStrut(2)); + + email.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Form_Button_Property"), null)); + return email; + } + + private JPanel getCpane() { + JPanel appendCountPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); + count = new UIBasicSpinner(new SpinnerNumberModel(1, 0, Integer.MAX_VALUE, 1)); + UILabel countLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Add_Row_Column_Numbers") + ":"); + JPanel cpane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + cpane.add(countLabel); + cpane.add(count); + appendCountPane.add(cpane); + return cpane; + } + + + private JPanel getSubmitPane() { + isVerify = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Verify_Data_Verify")); + failSubmit = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Verify_Fail_Still_Submit")); + isCurSheet = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Only_Submit_Current_Sheet")); + JPanel submitPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); + submitPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Form_Button_Property"), null)); + submitPane.add(isVerify); + submitPane.add(failSubmit); + submitPane.add(isCurSheet); + isVerify.addActionListener(actionListener); + return submitPane; + } + + @Override + protected String title4PopupWindow() { + return "Button"; + } + + ActionListener l = new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (!(widget instanceof CustomToolBarButton)) { + return; + } + if (javaScriptPane == null || ((CustomToolBarButton) widget).getJSImpl() == null) { + javaScriptPane = JavaScriptActionPane.createDefault(); + } + javaScriptPane.setResourceInfo(new JavaScriptResourceInfo(JavaScriptResourceInfo.Type.WIDGET, ((Button) widget).getText())); + + javaScriptPane.setPreferredSize(new Dimension(750, 500)); + BasicDialog dialog = javaScriptPane.showWindow(SwingUtilities.getWindowAncestor(ButtonPane.this)); + dialog.addDialogActionListener(new DialogActionAdapter() { + + @Override + public void doCancel() { + javaScriptPane.populateBean(((CustomToolBarButton) widget).getJSImpl()); + } + + @Override + public void doOk() { + ((CustomToolBarButton) widget).setJSImpl(javaScriptPane.updateBean()); + } + }); + dialog.setVisible(true); + } + }; /** * 更新 @@ -557,16 +561,16 @@ public class EditToolBar extends BasicPane { populateEmail(); } - Set extraButtonSet = ExtraDesignClassManager.getInstance().getArray(ExtraButtonToolBarProvider.XML_TAG); - for (ExtraButtonToolBarProvider provider : extraButtonSet) { - provider.populate(widget, card, centerPane); - } - } + Set extraButtonSet = ExtraDesignClassManager.getInstance().getArray(ExtraButtonToolBarProvider.XML_TAG); + for (ExtraButtonToolBarProvider provider : extraButtonSet) { + provider.populate(widget, card, centerPane); + } + } - private void populateAppendColumnRow(){ - card.show(centerPane, "appendcount"); - count.setValue(((AppendColumnRow) widget).getCount()); - } + private void populateAppendColumnRow() { + card.show(centerPane, "appendcount"); + count.setValue(((AppendColumnRow) widget).getCount()); + } private void populateExport(){ card.show(centerPane, "export"); @@ -584,113 +588,116 @@ public class EditToolBar extends BasicPane { } } - private void populateEmail(){ - card.show(centerPane, EMAIL); - Email email = (Email) widget; - this.customConsignee.setSelected(email.isCustomConsignee()); - this.consigneeByDepartment.setSelected(email.isConsigneeByDepartment()); - this.consigneeByRole.setSelected(email.isConsigneeByRole()); - } - - private void populateCustomToolBarButton(){ - card.show(centerPane, "custom"); - CustomToolBarButton customToolBarButton = (CustomToolBarButton) widget; - if (customToolBarButton.getJSImpl() != null) { - this.javaScriptPane.populateBean(customToolBarButton.getJSImpl()); - } - } - - private void populateSubmit(){ - card.show(centerPane, "submit"); - Submit submit = ((Submit) widget); - this.isVerify.setSelected(submit.isVerify()); - if (!submit.isVerify()) { - this.failSubmit.setVisible(false); - } - this.failSubmit.setSelected(submit.isFailVerifySubmit()); - this.isCurSheet.setSelected(submit.isOnlySubmitSelect()); - } - - private void populateDefault(){ - Button button = (Button) widget; - this.icon.setSelected(button.isShowIcon()); - this.text.setSelected(button.isShowText()); - this.nameField.setText(button.getText()); - this.iconPane.populate(((Button) widget).getIconName()); - } - - /** - * 更新 - * - * @return 对应组件 - */ - public Widget update() { - if (widget instanceof Export) { - updateExport(); - } else if (widget instanceof AppendColumnRow) { - ((AppendColumnRow) widget).setCount(((Integer) count.getValue()).intValue()); - } else if (widget instanceof Submit) { - updateSubmit(); - } else if (widget instanceof CustomToolBarButton) { - updateCustomToolBarButton(); - } else if (widget instanceof Email) { - updateEmail(); - } - if (widget instanceof Button) { - updateDefault(); - } - - Set extraButtonSet = ExtraDesignClassManager.getInstance().getArray(ExtraButtonToolBarProvider.XML_TAG); - for (ExtraButtonToolBarProvider provider : extraButtonSet) { - provider.update(widget); - } - - return widget; - } - - private void updateDefault(){ - ((Button) widget).setShowIcon(this.icon.isSelected()); - ((Button) widget).setShowText(this.text.isSelected()); - ((Button) widget).setText(this.nameField.getText()); - ((Button) widget).setIconName(this.iconPane.update()); - } - - private void updateSubmit(){ - Submit submit = ((Submit) widget); - submit.setVerify(this.isVerify.isSelected()); - submit.setFailVerifySubmit(this.failSubmit.isSelected()); - submit.setOnlySubmitSelect(this.isCurSheet.isSelected()); - } - - private void updateExport(){ - Export export = (Export) widget; - export.setPdfAvailable(this.pdf.isSelected()); - export.setExcelPAvailable(this.excelP.isSelected()); - export.setExcelOAvailable(this.excelO.isSelected()); - export.setExcelSAvailable(this.excelS.isSelected()); - export.setWordAvailable(this.word.isSelected()); - export.setImageAvailable(this.image.isSelected()); - if(exportToolBarProviders != null){ - for(int i=0; i extraButtonSet = ExtraDesignClassManager.getInstance().getArray(ExtraButtonToolBarProvider.XML_TAG); + for (ExtraButtonToolBarProvider provider : extraButtonSet) { + provider.update(widget); + } + + return widget; + } + + private void updateDefault() { + ((Button) widget).setShowIcon(this.icon.isSelected()); + ((Button) widget).setShowText(this.text.isSelected()); + ((Button) widget).setText(this.nameField.getText()); + ((Button) widget).setIconName(this.iconPane.update()); + } + + private void updateSubmit() { + Submit submit = ((Submit) widget); + submit.setVerify(this.isVerify.isSelected()); + submit.setFailVerifySubmit(this.failSubmit.isSelected()); + submit.setOnlySubmitSelect(this.isCurSheet.isSelected()); + } + + private void updateExport() { + Export export = (Export) widget; + export.setPdfAvailable(this.pdf.isSelected()); + export.setExcelPAvailable(this.excelP.isSelected()); + export.setExcelOAvailable(this.excelO.isSelected()); + export.setExcelSAvailable(this.excelS.isSelected()); + export.setWordAvailable(this.word.isSelected()); + export.setImageAvailable(this.image.isSelected()); + if (exportToolBarProviders != null) { + for (int i = 0; i < exportToolBarProviders.length; i++) { + exportToolBarProviders[i].update(); + ; + } + } + } + + private void updateEmail() { + Email email = ((Email) widget); + email.setCustomConsignee(this.customConsignee.isSelected()); + email.setConsigneeByDepartment(this.consigneeByDepartment.isSelected()); + email.setConsigneeByRole(this.consigneeByRole.isSelected()); + } + + private void updateCustomToolBarButton() { + CustomToolBarButton customToolBarButton = (CustomToolBarButton) widget; + if (customToolBarButton.getJSImpl() == null) { + this.javaScriptPane = JavaScriptActionPane.createDefault(); + } + javaScriptPane.setResourceInfo(new JavaScriptResourceInfo(JavaScriptResourceInfo.Type.CUSTOM_BUTTON, ((Button) widget).getText())); + + customToolBarButton.setJSImpl(this.javaScriptPane.updateBean()); + } + } } diff --git a/designer-realize/src/main/java/com/fr/design/widget/CellWidgetCardPane.java b/designer-realize/src/main/java/com/fr/design/widget/CellWidgetCardPane.java index 57e87e090d..8928e5fb6f 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/CellWidgetCardPane.java +++ b/designer-realize/src/main/java/com/fr/design/widget/CellWidgetCardPane.java @@ -14,7 +14,6 @@ import com.fr.design.widget.ui.BasicWidgetPropertySettingPane; import com.fr.form.event.Listener; import com.fr.form.ui.Widget; - import javax.swing.BorderFactory; import javax.swing.JPanel; import java.awt.BorderLayout; @@ -166,7 +165,7 @@ public class CellWidgetCardPane extends BasicPane { } widgetPropertyPane.update(widget); - Listener[] listener = eventPane == null ? new Listener[0] : eventPane.updateListeners(); + Listener[] listener = eventPane == null ? new Listener[0] : eventPane.updateListeners(widget); widget.clearListeners(); for (Listener l : listener) { widget.addListener(l); diff --git a/designer-realize/src/main/java/com/fr/design/widget/WidgetEventPane.java b/designer-realize/src/main/java/com/fr/design/widget/WidgetEventPane.java index 936001d702..679915da7d 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/WidgetEventPane.java +++ b/designer-realize/src/main/java/com/fr/design/widget/WidgetEventPane.java @@ -1,29 +1,30 @@ package com.fr.design.widget; -import java.lang.reflect.Constructor; import com.fr.design.beans.BasicBeanPane; -import com.fr.design.gui.controlpane.UIListGroupControlPane; -import com.fr.design.i18n.Toolkit; -import com.fr.design.mainframe.CellWidgetPropertyPane; -import com.fr.design.write.submit.DBManipulationPane; -import com.fr.design.write.submit.SmartInsertDBManipulationInWidgetEventPane; import com.fr.design.gui.controlpane.NameableCreator; +import com.fr.design.gui.controlpane.UIListGroupControlPane; import com.fr.design.gui.frpane.ListenerUpdatePane; +import com.fr.design.i18n.Toolkit; import com.fr.design.javascript.JavaScriptActionPane; +import com.fr.design.mainframe.CellWidgetPropertyPane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.JTemplate; +import com.fr.design.write.submit.DBManipulationPane; +import com.fr.design.write.submit.SmartInsertDBManipulationInWidgetEventPane; import com.fr.form.event.Listener; import com.fr.form.ui.Widget; -import com.fr.grid.selection.Selection; - import com.fr.general.NameObject; import com.fr.grid.selection.CellSelection; +import com.fr.grid.selection.Selection; +import com.fr.js.Commit2DBJavaScript; import com.fr.stable.AssistUtils; import com.fr.stable.Nameable; +import com.fr.write.JavaScriptResourceInfo; -import javax.swing.*; +import javax.swing.BorderFactory; +import java.lang.reflect.Constructor; public class WidgetEventPane extends UIListGroupControlPane { private static final Selection NO_SELECTION = new CellSelection(-1, -1, -1, -1); @@ -32,9 +33,11 @@ public class WidgetEventPane extends UIListGroupControlPane { private ElementCasePane object; + private Widget targetWidget; + public WidgetEventPane(ElementCasePane pane) { this.object = pane; - if(pane != null){ + if (pane != null) { selection = pane.getSelection(); } setBorder(BorderFactory.createEmptyBorder(10, 0, 15, 0)); @@ -125,18 +128,21 @@ public class WidgetEventPane extends UIListGroupControlPane { if (widget == null) { return; } + this.targetWidget = widget; refreshPane(widget, EventCreator.createEventCreator(widget.supportedEvents(), WidgetEventListenerUpdatePane.class)); } - /** - * 更新 - * @return 监听器 - */ - public Listener[] updateListeners() { + /** + * 更新 + * + * @return 监听器 + */ + public Listener[] updateListeners(Widget widget) { + this.targetWidget = widget; Nameable[] res = this.update(); Listener[] res_array = new Listener[res.length]; for (int i = 0, len = res.length; i < len; i++) { - res_array[i] = (Listener) ((NameObject)res[i]).getObject(); + res_array[i] = (Listener) ((NameObject) res[i]).getObject(); } return res_array; } @@ -174,14 +180,22 @@ public class WidgetEventPane extends UIListGroupControlPane { if (constructor != null) { return constructor; } else { - if (AssistUtils.equals(cls.getName(),Object.class.getName())) { + if (AssistUtils.equals(cls.getName(), Object.class.getName())) { return null; } return getConstructor(clazz, cls.getSuperclass()); } } - protected String getWrapperLabelText(){ + @Override + public void wrapperListener(Listener listener) { + if (listener.getAction() instanceof Commit2DBJavaScript) { + Commit2DBJavaScript commit2DBJavaScript = (Commit2DBJavaScript) listener.getAction(); + commit2DBJavaScript.setJsResourceInfo(new JavaScriptResourceInfo(JavaScriptResourceInfo.Type.WIDGET, targetWidget.getWidgetName())); + } + } + + protected String getWrapperLabelText() { return Toolkit.i18nText("Fine-Design_Report_Event"); }