From ef12593641aae6e9a9ab652ea441c8ec50422d90 Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 24 Aug 2017 14:28:33 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=E5=8D=95=E5=85=83=E6=A0=BC=E5=85=83?= =?UTF-8?q?=E7=B4=A0=E6=8F=92=E5=85=A5=E5=86=85=E5=AE=B9=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E5=90=8E=E5=8F=98=E4=B8=BA=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E7=AC=AC=E4=B8=80=E4=B8=AA=E8=80=8C=E4=B8=8D=E6=98=AF=E4=B8=8A?= =?UTF-8?q?=E6=AC=A1=E9=80=89=E4=B8=AD=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/quickeditor/CellQuickEditor.java | 35 +++++-------------- .../fr/design/actions/core/ActionFactory.java | 15 ++++---- 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/designer/src/com/fr/quickeditor/CellQuickEditor.java b/designer/src/com/fr/quickeditor/CellQuickEditor.java index b2d66fc25..9f8ab61d2 100644 --- a/designer/src/com/fr/quickeditor/CellQuickEditor.java +++ b/designer/src/com/fr/quickeditor/CellQuickEditor.java @@ -2,6 +2,7 @@ package com.fr.quickeditor; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.core.ActionFactory; +import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.iscrollbar.UIScrollBar; @@ -11,6 +12,7 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.CellElementPropertyPane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.ShortCut; import com.fr.design.selection.QuickEditor; @@ -20,8 +22,6 @@ import com.fr.report.cell.TemplateCellElement; import com.fr.stable.ColumnRow; import javax.swing.*; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; @@ -119,10 +119,10 @@ public abstract class CellQuickEditor extends QuickEditor { cellLabel.setPreferredSize(new Dimension(60, 20)); UILabel insertContentLabel = new UILabel(Inter.getLocText("HF-Insert_Content")); insertContentLabel.setPreferredSize(new Dimension(60, 20)); - UIComboBox cellElementEditButton = initCellElementEditComboBox(); + UIComboBox cellElementEditComboBox = initCellElementEditComboBox(); Component[][] components = new Component[][]{ new Component[]{cellLabel, columnRowTextField = initColumnRowTextField()}, - new Component[]{insertContentLabel, cellElementEditButton}, + new Component[]{insertContentLabel, cellElementEditComboBox}, }; JPanel topContent = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); topContent.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0)); @@ -136,6 +136,10 @@ public abstract class CellQuickEditor extends QuickEditor { * @return UIButton */ private UIComboBox initCellElementEditComboBox() { + JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + if (jTemplate == null) { + return comboBox = new UIComboBox(); + } final String[] items = getDefaultComboBoxItems(); comboBox = new UIComboBox(items); final Object comboBoxSelected = getComboBoxSelected(); @@ -144,31 +148,10 @@ public abstract class CellQuickEditor extends QuickEditor { } else { comboBox.setSelectedIndex(1); } - comboBox.addPopupMenuListener(new PopupMenuListener() { - @Override - public void popupMenuWillBecomeVisible(PopupMenuEvent e) { - if (cellInsertActions == null) { - cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc); - } - // 这边重新获取是因为要根据JTemplate做一个过滤 - ArrayList arrayList = new ArrayList(); - for (UpdateAction action : cellInsertActions) { - arrayList.add(action.getMenuKeySet().getMenuKeySetName()); - } - comboBox.setModel(new DefaultComboBoxModel<>(arrayList.toArray(new String[arrayList.size()]))); - } - - @Override - public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { - } - - @Override - public void popupMenuCanceled(PopupMenuEvent e) { - } - }); comboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { + cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc); selectedIndex = comboBox.getSelectedIndex(); cellInsertActions[selectedIndex].actionPerformed(e); } diff --git a/designer_base/src/com/fr/design/actions/core/ActionFactory.java b/designer_base/src/com/fr/design/actions/core/ActionFactory.java index 01c070899..a8d958533 100644 --- a/designer_base/src/com/fr/design/actions/core/ActionFactory.java +++ b/designer_base/src/com/fr/design/actions/core/ActionFactory.java @@ -73,6 +73,7 @@ public class ActionFactory { /** * 注册图表的 地图资源 + * * @param action 地图资源action */ public static void registerChartMapEditorAction(UpdateAction action) { @@ -229,16 +230,18 @@ public class ActionFactory { public static MenuKeySet[] createCellInsertActionName() { List actionNames = new ArrayList<>(); + JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); for (Class clazz : actionClasses) { if (clazz == null) { continue; } - try { - Constructor c = (Constructor) clazz.getConstructor(); - actionNames.add(c.newInstance().getMenuKeySet()); - - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); + if (jTemplate.acceptToolbarItem(clazz)) { + try { + Constructor c = (Constructor) clazz.getConstructor(); + actionNames.add(c.newInstance().getMenuKeySet()); + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage(), e); + } } } return actionNames.toArray(new MenuKeySet[actionNames.size()]);