From 9bdc72ad64a2150a377a8af4638a79f67b809064 Mon Sep 17 00:00:00 2001 From: vito Date: Tue, 8 Aug 2017 18:36:08 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-3564=209.0=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=A0=BC=E5=85=83=E7=B4=A0=E6=8F=92=E5=85=A5?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=8E=A7=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/CellSelectionAction.java | 55 ++++++----- .../fr/design/actions/ElementCaseAction.java | 16 ++- .../actions/SelectionListenerAction.java | 5 +- .../insert/cell/AbstractCellAction.java | 38 +++---- .../actions/insert/cell/BiasCellAction.java | 17 +++- .../actions/insert/cell/ChartCellAction.java | 14 ++- .../insert/cell/DSColumnCellAction.java | 16 ++- .../insert/cell/FormulaCellAction.java | 16 ++- .../insert/cell/GeneralCellAction.java | 16 ++- .../actions/insert/cell/ImageCellAction.java | 16 ++- .../insert/cell/RichTextCellAction.java | 93 +++++++++-------- .../insert/cell/SubReportCellAction.java | 99 ++++++++++--------- .../com/fr/quickeditor/CellQuickEditor.java | 78 ++++++++++++--- .../cellquick/CellBiasTextPainterEditor.java | 7 ++ .../cellquick/CellDSColumnEditor.java | 7 ++ .../cellquick/CellImageQuickEditor.java | 6 ++ .../cellquick/CellRichTextEditor.java | 6 ++ .../cellquick/CellStringQuickEditor.java | 10 ++ .../cellquick/CellSubReportEditor.java | 6 ++ .../actions/TemplateComponentAction.java | 42 ++++---- .../fr/design/actions/core/ActionFactory.java | 34 ++++++- 21 files changed, 400 insertions(+), 197 deletions(-) diff --git a/designer/src/com/fr/design/actions/CellSelectionAction.java b/designer/src/com/fr/design/actions/CellSelectionAction.java index 8ca67feafc..16bf089c55 100644 --- a/designer/src/com/fr/design/actions/CellSelectionAction.java +++ b/designer/src/com/fr/design/actions/CellSelectionAction.java @@ -5,30 +5,33 @@ import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.Selection; public abstract class CellSelectionAction extends ElementCaseAction { - protected CellSelectionAction(ElementCasePane t) { - super(t); - } - - @Override - public boolean executeActionReturnUndoRecordNeeded() { - ElementCasePane ePane = this.getEditingComponent(); - Selection s = ePane.getSelection(); - - // TODO ALEX_SEP instanceof i hate it - if (s instanceof CellSelection) { - return executeActionReturnUndoRecordNeededWithCellSelection((CellSelection)s); - } - - return false; - } - - protected abstract boolean executeActionReturnUndoRecordNeededWithCellSelection(CellSelection cs); - - @Override - public void update() { - super.update(); - if (this.isEnabled()) { - this.setEnabled(this.getEditingComponent().getSelection() instanceof CellSelection); - } - } + protected CellSelectionAction() { + } + + protected CellSelectionAction(ElementCasePane t) { + super(t); + } + + @Override + public boolean executeActionReturnUndoRecordNeeded() { + ElementCasePane ePane = this.getEditingComponent(); + Selection s = ePane.getSelection(); + + // TODO ALEX_SEP instanceof i hate it + if (s instanceof CellSelection) { + return executeActionReturnUndoRecordNeededWithCellSelection((CellSelection) s); + } + + return false; + } + + protected abstract boolean executeActionReturnUndoRecordNeededWithCellSelection(CellSelection cs); + + @Override + public void update() { + super.update(); + if (this.isEnabled()) { + this.setEnabled(this.getEditingComponent().getSelection() instanceof CellSelection); + } + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/ElementCaseAction.java b/designer/src/com/fr/design/actions/ElementCaseAction.java index bfc0c8b4e5..09b7848306 100644 --- a/designer/src/com/fr/design/actions/ElementCaseAction.java +++ b/designer/src/com/fr/design/actions/ElementCaseAction.java @@ -3,17 +3,15 @@ package com.fr.design.actions; //ElementCaseAction应该有GridSelectionChangeListener,就从悬浮元素和单元格来讲,就必须有了,用来判断这些ElementCaseAction是否可以编辑,当然还可以做些其他事情 // -import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; -import com.fr.grid.selection.CellSelection; -import com.fr.grid.selection.Selection; -import com.fr.design.selection.SelectionEvent; -import com.fr.design.selection.SelectionListener; public abstract class ElementCaseAction extends SelectionListenerAction { - protected ElementCaseAction(ElementCasePane t) { - super(t); - t.addSelectionChangeListener(createSelectionListener()); - } + protected ElementCaseAction() { + } + + protected ElementCaseAction(ElementCasePane t) { + super(t); + t.addSelectionChangeListener(createSelectionListener()); + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/SelectionListenerAction.java b/designer/src/com/fr/design/actions/SelectionListenerAction.java index 48cd2d4f9a..d150460ec7 100644 --- a/designer/src/com/fr/design/actions/SelectionListenerAction.java +++ b/designer/src/com/fr/design/actions/SelectionListenerAction.java @@ -12,11 +12,14 @@ import com.fr.grid.selection.Selection; */ public abstract class SelectionListenerAction extends TemplateComponentAction { + protected SelectionListenerAction() { + } + protected SelectionListenerAction(ElementCasePane elementCasePane) { super(elementCasePane); } - protected SelectionListener createSelectionListener () { + protected SelectionListener createSelectionListener() { return new SelectionListener() { @Override diff --git a/designer/src/com/fr/design/actions/insert/cell/AbstractCellAction.java b/designer/src/com/fr/design/actions/insert/cell/AbstractCellAction.java index a8c9ab80fe..1127acf538 100644 --- a/designer/src/com/fr/design/actions/insert/cell/AbstractCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/AbstractCellAction.java @@ -13,12 +13,15 @@ import com.fr.report.elementcase.TemplateElementCase; * Cell. */ public abstract class AbstractCellAction extends CellSelectionAction { - protected AbstractCellAction(ElementCasePane t) { - super(t); - } - + protected AbstractCellAction() { + } + + protected AbstractCellAction(ElementCasePane t) { + super(t); + } + public abstract Class getCellValueClass(); - + /* * TODO ALEX_SEP 这里的返回boolean量表示模板是否改变,导致很多很多的方法的boolean返回值都是这个意思 * @@ -26,8 +29,8 @@ public abstract class AbstractCellAction extends CellSelectionAction { */ @Override protected boolean executeActionReturnUndoRecordNeededWithCellSelection( - CellSelection cs) { - ElementCasePane ePane = this.getEditingComponent(); + CellSelection cs) { + ElementCasePane ePane = this.getEditingComponent(); //got simple cell element from column and row. TemplateElementCase report = ePane.getEditingElementCase(); @@ -35,17 +38,18 @@ public abstract class AbstractCellAction extends CellSelectionAction { if (report != null && this instanceof DSColumnCellAction) { SheetUtils.calculateDefaultParent(report); } - + return ePane.getGrid().startCellEditingAt_DEC( - cs.getColumn(), - cs.getRow(), - this.getCellValueClass(), false + cs.getColumn(), + cs.getRow(), + this.getCellValueClass(), false ); } - @Override - public void update() { - super.update(); - ElementCasePane ePane = this.getEditingComponent(); - this.setEnabled(ePane.isSelectedOneCell()); - } + + @Override + public void update() { + super.update(); + ElementCasePane ePane = this.getEditingComponent(); + this.setEnabled(ePane.isSelectedOneCell()); + } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/insert/cell/BiasCellAction.java b/designer/src/com/fr/design/actions/insert/cell/BiasCellAction.java index e3821f299d..9fc6162881 100644 --- a/designer/src/com/fr/design/actions/insert/cell/BiasCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/BiasCellAction.java @@ -3,8 +3,6 @@ */ package com.fr.design.actions.insert.cell; -import javax.swing.KeyStroke; - import com.fr.base.BaseUtils; import com.fr.design.actions.core.WorkBookSupportable; import com.fr.design.mainframe.ElementCasePane; @@ -12,12 +10,23 @@ import com.fr.design.menu.MenuKeySet; import com.fr.general.Inter; import com.fr.report.cell.painter.BiasTextPainter; +import javax.swing.KeyStroke; + /** * Bias */ public class BiasCellAction extends AbstractCellAction implements WorkBookSupportable { - public BiasCellAction(ElementCasePane t) { - super(t); + + public BiasCellAction() { + initAction(); + } + + public BiasCellAction(ElementCasePane t) { + super(t); + initAction(); + } + + private void initAction() { this.setMenuKeySet(INSERT_SLOPE_LINE); this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); diff --git a/designer/src/com/fr/design/actions/insert/cell/ChartCellAction.java b/designer/src/com/fr/design/actions/insert/cell/ChartCellAction.java index 8f12d287b2..83d8f238ee 100644 --- a/designer/src/com/fr/design/actions/insert/cell/ChartCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/ChartCellAction.java @@ -16,11 +16,19 @@ import javax.swing.*; * . */ public class ChartCellAction extends AbstractCellAction implements WorkBookSupportable { + public ChartCellAction(){ + initAction(); + } + public ChartCellAction(ElementCasePane t) { super(t); - this.setMenuKeySet(INSERT_CHART); - this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); - this.setMnemonic(getMenuKeySet().getMnemonic()); + initAction(); + } + + private void initAction() { + this.setMenuKeySet(INSERT_CHART); + this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); + this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/chart.png")); } diff --git a/designer/src/com/fr/design/actions/insert/cell/DSColumnCellAction.java b/designer/src/com/fr/design/actions/insert/cell/DSColumnCellAction.java index 90d0ccb8bc..7afd7b4ef7 100644 --- a/designer/src/com/fr/design/actions/insert/cell/DSColumnCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/DSColumnCellAction.java @@ -8,13 +8,21 @@ import com.fr.general.IOUtils; import com.fr.report.cell.cellattr.core.group.DSColumn; public class DSColumnCellAction extends AbstractCellAction implements WorkBookSupportable { - public DSColumnCellAction(ElementCasePane t) { - super(t); + public DSColumnCellAction() { + initAction(); + } + + public DSColumnCellAction(ElementCasePane t) { + super(t); + initAction(); + this.setSearchText(new DSColumnPane()); + } + + private void initAction() { this.setMenuKeySet(KeySetUtils.INSERT_DATA_COLUMN); - this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/m_insert/bindColumn.png")); - this.setSearchText(new DSColumnPane()); } @Override diff --git a/designer/src/com/fr/design/actions/insert/cell/FormulaCellAction.java b/designer/src/com/fr/design/actions/insert/cell/FormulaCellAction.java index 92757d88e0..499b9119df 100644 --- a/designer/src/com/fr/design/actions/insert/cell/FormulaCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/FormulaCellAction.java @@ -13,10 +13,18 @@ import com.fr.general.Inter; import javax.swing.*; public class FormulaCellAction extends AbstractCellAction implements WorkBookSupportable { - public FormulaCellAction(ElementCasePane t) { - super(t); + public FormulaCellAction() { + initAction(); + } + + public FormulaCellAction(ElementCasePane t) { + super(t); + initAction(); + } + + private void initAction() { this.setMenuKeySet(INSERT_FORMULA); - this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); } @@ -39,7 +47,7 @@ public class FormulaCellAction extends AbstractCellAction implements WorkBookSup }; @Override - public Class getCellValueClass() { + public Class getCellValueClass() { return Formula.class; } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/insert/cell/GeneralCellAction.java b/designer/src/com/fr/design/actions/insert/cell/GeneralCellAction.java index 7146924673..40aef3198c 100644 --- a/designer/src/com/fr/design/actions/insert/cell/GeneralCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/GeneralCellAction.java @@ -15,10 +15,18 @@ import javax.swing.*; * */ public class GeneralCellAction extends AbstractCellAction implements WorkBookSupportable { - public GeneralCellAction(ElementCasePane t) { - super(t); + public GeneralCellAction() { + initAction(); + } + + public GeneralCellAction(ElementCasePane t) { + super(t); + initAction(); + } + + private void initAction() { this.setMenuKeySet(INSERT_TEXT); - this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/text.png")); } @@ -41,7 +49,7 @@ public class GeneralCellAction extends AbstractCellAction implements WorkBookSup }; @Override - public Class getCellValueClass() { + public Class getCellValueClass() { return String.class; } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/insert/cell/ImageCellAction.java b/designer/src/com/fr/design/actions/insert/cell/ImageCellAction.java index 594cb771be..e3761909a9 100644 --- a/designer/src/com/fr/design/actions/insert/cell/ImageCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/ImageCellAction.java @@ -16,10 +16,18 @@ import java.awt.*; * Image */ public class ImageCellAction extends AbstractCellAction implements WorkBookSupportable { - public ImageCellAction(ElementCasePane t) { - super(t); + public ImageCellAction() { + initAction(); + } + + public ImageCellAction(ElementCasePane t) { + super(t); + initAction(); + } + + private void initAction() { this.setMenuKeySet(INSERT_IMAGE); - this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/image.png")); } @@ -42,7 +50,7 @@ public class ImageCellAction extends AbstractCellAction implements WorkBookSuppo }; @Override - public Class getCellValueClass() { + public Class getCellValueClass() { return Image.class; } } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/insert/cell/RichTextCellAction.java b/designer/src/com/fr/design/actions/insert/cell/RichTextCellAction.java index c8017099f4..c9df15162b 100644 --- a/designer/src/com/fr/design/actions/insert/cell/RichTextCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/RichTextCellAction.java @@ -1,7 +1,5 @@ package com.fr.design.actions.insert.cell; -import javax.swing.KeyStroke; - import com.fr.base.BaseUtils; import com.fr.design.actions.core.WorkBookSupportable; import com.fr.design.mainframe.ElementCasePane; @@ -10,53 +8,64 @@ import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.report.cell.cellattr.core.RichText; +import javax.swing.KeyStroke; + public class RichTextCellAction extends AbstractCellAction implements WorkBookSupportable { - public RichTextCellAction(ElementCasePane t) { - super(t); + public RichTextCellAction() { + initAction(); + } + + public RichTextCellAction(ElementCasePane t) { + super(t); + initAction(); + } + + private void initAction() { this.setMenuKeySet(INSERT_RICHTEXT); - this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon( "/com/fr/design/images/m_insert/richtext.png")); - } - - @Override - public Class getCellValueClass() { - return RichText.class; - } - - /** - * equals 比较 - * @param object - * @return true false - */ - @Override - public boolean equals(Object object) { - if (this == object){ - return true; - } - if (!(object instanceof RichTextCellAction)){ - return false; - } - - return ComparatorUtils.equals(this.getEditingComponent(),((RichTextCellAction)object).getEditingComponent()); - } + } + + @Override + public Class getCellValueClass() { + return RichText.class; + } + + /** + * equals 比较 + * + * @param object + * @return true false + */ + @Override + public boolean equals(Object object) { + if (this == object) { + return true; + } + if (!(object instanceof RichTextCellAction)) { + return false; + } + + return ComparatorUtils.equals(this.getEditingComponent(), ((RichTextCellAction) object).getEditingComponent()); + } private static final MenuKeySet INSERT_RICHTEXT = new MenuKeySet() { - @Override - public char getMnemonic() { - return 'R'; - } - - @Override - public String getMenuName() { - return Inter.getLocText("FR-Designer_RichText"); - } - - @Override - public KeyStroke getKeyStroke() { - return null; - } + @Override + public char getMnemonic() { + return 'R'; + } + + @Override + public String getMenuName() { + return Inter.getLocText("FR-Designer_RichText"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } }; } \ No newline at end of file diff --git a/designer/src/com/fr/design/actions/insert/cell/SubReportCellAction.java b/designer/src/com/fr/design/actions/insert/cell/SubReportCellAction.java index 79dc6c6421..a055bcd0d0 100644 --- a/designer/src/com/fr/design/actions/insert/cell/SubReportCellAction.java +++ b/designer/src/com/fr/design/actions/insert/cell/SubReportCellAction.java @@ -1,7 +1,5 @@ package com.fr.design.actions.insert.cell; -import javax.swing.KeyStroke; - import com.fr.base.BaseUtils; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.menu.MenuKeySet; @@ -9,54 +7,65 @@ import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.report.cell.cellattr.core.SubReport; +import javax.swing.KeyStroke; + public class SubReportCellAction extends AbstractCellAction { - public SubReportCellAction(ElementCasePane t) { - super(t); + public SubReportCellAction() { + initAction(); + } + + public SubReportCellAction(ElementCasePane t) { + super(t); + initAction(); + } + + private void initAction() { this.setMenuKeySet(INSERT_SUB_REPORT); - this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon( "/com/fr/design/images/m_insert/subReport.png")); - } - - public static final MenuKeySet INSERT_SUB_REPORT = new MenuKeySet() { - @Override - public char getMnemonic() { - return 'S'; - } - - @Override - public String getMenuName() { - return Inter.getLocText("M_Insert-Sub_Report"); - } - - @Override - public KeyStroke getKeyStroke() { - return null; - } - }; - - /** - * equals 比较 - * @param object - * @return true false - */ - @Override - public boolean equals(Object object) { - if (this == object){ - return true; - } - if (!(object instanceof SubReportCellAction)){ - return false; - } - - return ComparatorUtils.equals(this.getEditingComponent(),((SubReportCellAction)object).getEditingComponent()); - } - - @Override - public Class getCellValueClass() { - return SubReport.class; - } + } + + public static final MenuKeySet INSERT_SUB_REPORT = new MenuKeySet() { + @Override + public char getMnemonic() { + return 'S'; + } + + @Override + public String getMenuName() { + return Inter.getLocText("M_Insert-Sub_Report"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; + + /** + * equals 比较 + * + * @param object + * @return true false + */ + @Override + public boolean equals(Object object) { + if (this == object) { + return true; + } + if (!(object instanceof SubReportCellAction)) { + return false; + } + + return ComparatorUtils.equals(this.getEditingComponent(), ((SubReportCellAction) object).getEditingComponent()); + } + + @Override + public Class getCellValueClass() { + return SubReport.class; + } } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/CellQuickEditor.java b/designer/src/com/fr/quickeditor/CellQuickEditor.java index 7ae3dbba36..588a5fec32 100644 --- a/designer/src/com/fr/quickeditor/CellQuickEditor.java +++ b/designer/src/com/fr/quickeditor/CellQuickEditor.java @@ -1,27 +1,30 @@ package com.fr.quickeditor; -import com.fr.base.BaseUtils; -import com.fr.design.actions.utils.DeprecatedActionManager; +import com.fr.design.actions.UpdateAction; +import com.fr.design.actions.core.ActionFactory; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.menu.MenuKeySet; +import com.fr.design.menu.ShortCut; import com.fr.design.selection.QuickEditor; -import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.Inter; import com.fr.grid.selection.CellSelection; 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.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; +import java.util.ArrayList; /** * @author zhou @@ -32,6 +35,10 @@ public abstract class CellQuickEditor extends QuickEditor { protected UITextField columnRowTextField; private UIButton cellElementEditButton; protected TemplateCellElement cellElement; + protected UIComboBox comboBox; + private UpdateAction[] cellInsertActions; + private MenuKeySet[] cellInsertActionNames; + private int selectedIndex; public CellQuickEditor() { double p = TableLayout.PREFERRED; @@ -40,7 +47,7 @@ public abstract class CellQuickEditor extends QuickEditor { double[] rowSize = {p, p, p}; Component[][] components = new Component[][]{ new Component[]{new UILabel(" " + Inter.getLocText("Cell")), columnRowTextField = initColumnRowTextField()}, - new Component[]{new UILabel(Inter.getLocText("HF-Insert_Content") + " "), cellElementEditButton = initCellElementEditButton()}, + new Component[]{new UILabel(Inter.getLocText("HF-Insert_Content") + " "), initCellElementEditComboBox()}, new Component[]{createCenterBody(), null} }; JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); @@ -51,20 +58,57 @@ public abstract class CellQuickEditor extends QuickEditor { /** * 初始化添加按钮 - * TODO 9.0 换成下拉菜单后原来的快捷键不好处理,先跳过。 * * @return UIButton */ - private UIButton initCellElementEditButton() { - final UIButton cellElementEditButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); - cellElementEditButton.addMouseListener(new MouseAdapter() { + private UIComboBox initCellElementEditComboBox() { + final String[] items = getDefaultComboBoxItems(); + comboBox = new UIComboBox(items); + final Object comboBoxSelected = getComboBoxSelected(); + if (comboBoxSelected != null) { + comboBox.setSelectedItem(((ShortCut) comboBoxSelected).getMenuKeySet().getMenuKeySetName()); + } 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 mousePressed(MouseEvent evt) { - GUICoreUtils.showPopMenuWithParentWidth(DeprecatedActionManager.getCellMenu(tc).createJPopupMenu(), cellElementEditButton, 0, cellElementEditButton.getY() - 6); + public void popupMenuCanceled(PopupMenuEvent e) { } }); - return cellElementEditButton; + comboBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + selectedIndex = comboBox.getSelectedIndex(); + cellInsertActions[selectedIndex].actionPerformed(e); + } + }); + return comboBox; + } + + private String[] getDefaultComboBoxItems() { + cellInsertActionNames = ActionFactory.createCellInsertActionName(); + ArrayList names = new ArrayList<>(); + for (MenuKeySet cellInsertActionName : cellInsertActionNames) { + names.add(cellInsertActionName.getMenuKeySetName()); + } + return names.toArray(new String[names.size()]); } /** @@ -110,6 +154,14 @@ public abstract class CellQuickEditor extends QuickEditor { */ public abstract JComponent createCenterBody(); + + /** + * 初始化下拉框中的类型 + * + * @return JComponent 待显示的详细信息面板 + */ + public abstract Object getComboBoxSelected(); + /** * 刷新 */ diff --git a/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java index fcb36c8cb0..058d137d20 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java @@ -1,6 +1,8 @@ package com.fr.quickeditor.cellquick; import com.fr.base.BaseUtils; +import com.fr.design.actions.core.ActionFactory; +import com.fr.design.actions.insert.cell.BiasCellAction; import com.fr.design.cell.editor.BiasTextPainterCellEditor.BiasTextPainterPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.ibutton.UIButton; @@ -36,6 +38,11 @@ public class CellBiasTextPainterEditor extends CellQuickEditor { return editbutton; } + @Override + public Object getComboBoxSelected() { + return ActionFactory.createAction(BiasCellAction.class); + } + private void showEditingDialog() { final BiasTextPainter oldbiasTextPainter = (BiasTextPainter) cellElement.getValue(); final BiasTextPainterPane biasTextPainterPane = new BiasTextPainterPane(); diff --git a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index 321da63fb5..860de67305 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -1,6 +1,8 @@ package com.fr.quickeditor.cellquick; import com.fr.design.actions.columnrow.DSColumnConditionAction; +import com.fr.design.actions.core.ActionFactory; +import com.fr.design.actions.insert.cell.DSColumnCellAction; import com.fr.design.dscolumn.DSColumnAdvancedEditorPane; import com.fr.design.dscolumn.DSColumnBasicEditorPane; import com.fr.design.dscolumn.ResultSetGroupDockingPane; @@ -198,4 +200,9 @@ public class CellDSColumnEditor extends CellQuickEditor { /*高级设置面板*/ paneList.add(new DSColumnAdvancedEditorPane()); } + + @Override + public Object getComboBoxSelected() { + return ActionFactory.createAction(DSColumnCellAction.class); + } } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java index b39514ef65..d53aff244d 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java @@ -2,6 +2,8 @@ package com.fr.quickeditor.cellquick; import com.fr.base.BaseUtils; import com.fr.base.Style; +import com.fr.design.actions.core.ActionFactory; +import com.fr.design.actions.insert.cell.ImageCellAction; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.DesignerContext; @@ -74,4 +76,8 @@ public class CellImageQuickEditor extends CellQuickEditor { } + @Override + public Object getComboBoxSelected() { + return ActionFactory.createAction(ImageCellAction.class); + } } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java index 41596ddba5..4d48539d7e 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java @@ -1,5 +1,6 @@ package com.fr.quickeditor.cellquick; +import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.insert.cell.RichTextCellAction; import com.fr.design.gui.ibutton.UIButton; import com.fr.general.Inter; @@ -40,6 +41,11 @@ public class CellRichTextEditor extends CellQuickEditor { return subReportButton; } + @Override + public Object getComboBoxSelected() { + return ActionFactory.createAction(RichTextCellAction.class); + } + @Override protected void refreshDetails() { RichTextCellAction subReportCellAction = new RichTextCellAction(tc); diff --git a/designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java index 01d3c7d6e0..a196f9fd1c 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java @@ -3,6 +3,8 @@ package com.fr.quickeditor.cellquick; import com.fr.base.Formula; import com.fr.base.Style; import com.fr.base.TextFormat; +import com.fr.design.actions.core.ActionFactory; +import com.fr.design.actions.insert.cell.FormulaCellAction; import com.fr.design.gui.itextfield.UITextField; import com.fr.grid.selection.CellSelection; import com.fr.quickeditor.CellQuickEditor; @@ -21,6 +23,7 @@ import java.awt.event.KeyEvent; * */ public class CellStringQuickEditor extends CellQuickEditor { + private Object selectedItem; //instance private static CellStringQuickEditor THIS; //文本域 @@ -99,6 +102,7 @@ public class CellStringQuickEditor extends CellQuickEditor { textFormula.setReserveInResult(reserveInResult); textFormula.setReserveOnWriteOrAnaly(reserveOnWriteOrAnaly); cellElement.setValue(textFormula); + selectedItem = ActionFactory.createAction(FormulaCellAction.class); } else { Style style = cellElement.getStyle(); if (style != null && style.getFormat() != null && style.getFormat() == TextFormat.getInstance()) { @@ -106,6 +110,7 @@ public class CellStringQuickEditor extends CellQuickEditor { } else { cellElement.setValue(ReportHelper.convertGeneralStringAccordingToExcel(tmpText)); } + selectedItem = null; } fireTargetModified(); stringTextField.requestFocus(); @@ -152,4 +157,9 @@ public class CellStringQuickEditor extends CellQuickEditor { stringTextField.getDocument().addDocumentListener(documentListener); } + @Override + public Object getComboBoxSelected() { + return selectedItem; + } + } \ No newline at end of file diff --git a/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java index de755f1df7..353622d7ad 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java @@ -1,5 +1,6 @@ package com.fr.quickeditor.cellquick; +import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.insert.cell.SubReportCellAction; import com.fr.design.gui.ibutton.UIButton; import com.fr.general.Inter; @@ -42,4 +43,9 @@ public class CellSubReportEditor extends CellQuickEditor { subReportButton.setAction(subReportCellAction); } + @Override + public Object getComboBoxSelected() { + return ActionFactory.createAction(SubReportCellAction.class); + } + } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/actions/TemplateComponentAction.java b/designer_base/src/com/fr/design/actions/TemplateComponentAction.java index a8bfe8fb61..2194c7a791 100644 --- a/designer_base/src/com/fr/design/actions/TemplateComponentAction.java +++ b/designer_base/src/com/fr/design/actions/TemplateComponentAction.java @@ -4,30 +4,34 @@ package com.fr.design.actions; import com.fr.design.designer.TargetComponent; public abstract class TemplateComponentAction extends UndoableAction implements TemplateComponentActionInterface { - private T t; - protected TemplateComponentAction(T t) { - this.t = t; - } - - protected void setEditingComponent(T t) { - this.t = t; - } - - @Override - public T getEditingComponent() { - return t; - } - - @Override - public void prepare4Undo() { - this.getEditingComponent().fireTargetModified(); + private T t; + + protected TemplateComponentAction() { + } + + protected TemplateComponentAction(T t) { + this.t = t; + } + + protected void setEditingComponent(T t) { + this.t = t; + } + + @Override + public T getEditingComponent() { + return t; + } + + @Override + public void prepare4Undo() { + this.getEditingComponent().fireTargetModified(); T component = getEditingComponent(); if (component == null) { return; } component.requestFocus(); - } + } /** * update enable @@ -35,6 +39,6 @@ public abstract class TemplateComponentAction extends */ @Override public void update() { - this.setEnabled(this.getEditingComponent() != null); + this.setEnabled(this.getEditingComponent() != null); } } \ No newline at end of file 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 55a72002f4..b1e2f1a65e 100644 --- a/designer_base/src/com/fr/design/actions/core/ActionFactory.java +++ b/designer_base/src/com/fr/design/actions/core/ActionFactory.java @@ -5,6 +5,7 @@ import com.fr.base.Utils; import com.fr.design.actions.UpdateAction; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.JTemplate; +import com.fr.design.menu.MenuKeySet; import com.fr.design.selection.QuickEditor; import javax.swing.*; @@ -132,6 +133,17 @@ public class ActionFactory { return createEditor(clazz, cellEditor); } + public static UpdateAction createAction(Class clazz) { + try { + Constructor c = clazz.getDeclaredConstructor(); + c.setAccessible(true); + return c.newInstance(); + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage(), e); + } + return null; + } + /** * peter:从Action来产生ToolTipText. * @@ -190,7 +202,7 @@ public class ActionFactory { } if (jTemplate.acceptToolbarItem(clazz)) { try { - Constructor c = (Constructor)clazz.getConstructor(cls); + Constructor c = (Constructor) clazz.getConstructor(cls); actions.add(c.newInstance(obj)); } catch (Exception e) { FRContext.getLogger().error(e.getMessage(), e); @@ -200,6 +212,24 @@ public class ActionFactory { return actions.toArray(new UpdateAction[actions.size()]); } + + public static MenuKeySet[] createCellInsertActionName() { + List actionNames = new ArrayList<>(); + 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); + } + } + return actionNames.toArray(new MenuKeySet[actionNames.size()]); + } + /** * 登记悬浮元素插入类型 * @@ -225,7 +255,7 @@ public class ActionFactory { continue; } try { - Constructor c = (Constructor)clazz.getConstructor(cls); + Constructor c = (Constructor) clazz.getConstructor(cls); actions.add(c.newInstance(obj)); } catch (Exception e) { FRContext.getLogger().error(e.getMessage(), e);