From 55a6e1fbeed4ebae57676df72083fadb6772bc6f Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Wed, 28 Nov 2018 17:07:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-11623=20=E6=A8=A1=E6=9D=BF=E5=8A=A0?= =?UTF-8?q?=E5=AF=86=20=E8=AE=BE=E8=AE=A1=E5=99=A8=E6=8B=B7=E8=B4=9D?= =?UTF-8?q?=E5=89=AA=E5=88=87=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/edit/CopyAction.java | 5 +- .../com/fr/design/actions/edit/CutAction.java | 6 +- .../fr/design/actions/edit/PasteAction.java | 19 ++--- .../design/base/mode/DesignModeContext.java | 24 ++++++ .../com/fr/design/designer/DesignerProxy.java | 7 ++ .../fr/design/designer/TargetComponent.java | 80 ------------------- .../com/fr/design/mainframe/JTemplate.java | 3 +- .../designer/beans/actions/CopyAction.java | 5 +- .../designer/beans/actions/CutAction.java | 6 +- .../designer/beans/actions/PasteAction.java | 46 +++++------ .../java/com/fr/design/mainframe/JForm.java | 12 +-- .../fr/design/mainframe/ElementCasePane.java | 17 ++-- .../com/fr/design/mainframe/JWorkBook.java | 12 +-- .../fr/design/mainframe/ReportComponent.java | 7 +- .../design/mainframe/WorkSheetDesigner.java | 19 ++--- .../form/FormElementCaseDesigner.java | 18 ++--- .../main/java/com/fr/poly/PolyDesigner.java | 30 +------ .../java/com/fr/poly/creator/ECBlockPane.java | 39 ++++----- 18 files changed, 118 insertions(+), 237 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/designer/DesignerProxy.java diff --git a/designer-base/src/main/java/com/fr/design/actions/edit/CopyAction.java b/designer-base/src/main/java/com/fr/design/actions/edit/CopyAction.java index 397d6ff2c1..a311773745 100644 --- a/designer-base/src/main/java/com/fr/design/actions/edit/CopyAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/edit/CopyAction.java @@ -29,10 +29,7 @@ public class CopyAction extends TemplateComponentAction { @Override public boolean executeActionReturnUndoRecordNeeded() { - TargetComponent tc = getEditingComponent(); - if (tc != null) { - tc.copy(); - } + DesignModeContext.doCopy(getEditingComponent()); return false; } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/actions/edit/CutAction.java b/designer-base/src/main/java/com/fr/design/actions/edit/CutAction.java index aa4fae62dc..9d8453f1e2 100644 --- a/designer-base/src/main/java/com/fr/design/actions/edit/CutAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/edit/CutAction.java @@ -32,10 +32,6 @@ public class CutAction extends TemplateComponentAction { @Override public boolean executeActionReturnUndoRecordNeeded() { - TargetComponent editPane = getEditingComponent(); - if (editPane == null) { - return false; - } - return editPane.cut(); + return DesignModeContext.doPaste(getEditingComponent()); } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/actions/edit/PasteAction.java b/designer-base/src/main/java/com/fr/design/actions/edit/PasteAction.java index 476516a79c..6c8a9a5150 100644 --- a/designer-base/src/main/java/com/fr/design/actions/edit/PasteAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/edit/PasteAction.java @@ -3,14 +3,13 @@ */ package com.fr.design.actions.edit; -import java.awt.event.KeyEvent; - -import javax.swing.KeyStroke; - import com.fr.base.BaseUtils; import com.fr.design.actions.TemplateComponentAction; +import com.fr.design.base.mode.DesignModeContext; import com.fr.design.designer.TargetComponent; +import javax.swing.KeyStroke; +import java.awt.event.KeyEvent; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; @@ -21,9 +20,9 @@ public class PasteAction extends TemplateComponentAction { /** * Constructor */ - public PasteAction(TargetComponent t) { - super(t); - + public PasteAction(TargetComponent t) { + super(t); + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Edit_Paste")); this.setMnemonic('P'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/paste.png")); @@ -32,10 +31,6 @@ public class PasteAction extends TemplateComponentAction { @Override public boolean executeActionReturnUndoRecordNeeded() { - TargetComponent tc = getEditingComponent(); - if (tc == null) { - return false; - } - return tc.paste(); + return DesignModeContext.doPaste(getEditingComponent()); } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java b/designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java index 843ff4208d..9c43f7f50a 100644 --- a/designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java +++ b/designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java @@ -1,5 +1,7 @@ package com.fr.design.base.mode; +import com.fr.design.designer.TargetComponent; + import static com.fr.design.base.mode.DesignerMode.AUTHORITY; public class DesignModeContext { @@ -39,4 +41,26 @@ public class DesignModeContext { public static boolean isAuthorityEditing() { return mode == AUTHORITY; } + + + public static void doCopy(TargetComponent principal) { + if (isBanCopyAndCut() || principal == null) { + return; + } + principal.copy(); + } + + public static boolean doPaste(TargetComponent principal) { + if (principal == null) { + return false; + } + return principal.paste(); + } + + public static boolean doCut(TargetComponent principal) { + if (isBanCopyAndCut() || principal == null) { + return false; + } + return principal.cut(); + } } diff --git a/designer-base/src/main/java/com/fr/design/designer/DesignerProxy.java b/designer-base/src/main/java/com/fr/design/designer/DesignerProxy.java new file mode 100644 index 0000000000..21aa56b1ee --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/designer/DesignerProxy.java @@ -0,0 +1,7 @@ +package com.fr.design.designer; + +/** + * 暂时是空接口,标记一下模板设计时推出的代理其他 {@link TargetComponent} 的类 + */ +public interface DesignerProxy { +} diff --git a/designer-base/src/main/java/com/fr/design/designer/TargetComponent.java b/designer-base/src/main/java/com/fr/design/designer/TargetComponent.java index 348963881c..5556a66055 100644 --- a/designer-base/src/main/java/com/fr/design/designer/TargetComponent.java +++ b/designer-base/src/main/java/com/fr/design/designer/TargetComponent.java @@ -1,6 +1,5 @@ package com.fr.design.designer; -import com.fr.design.DesignState; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.mainframe.AuthorityEditPane; @@ -8,7 +7,6 @@ import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.menu.MenuDef; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; -import com.fr.stable.StringUtils; import com.fr.third.javax.annotation.Nullable; import javax.swing.JComponent; @@ -115,82 +113,4 @@ public abstract class TargetComponent extends JComponent { public EditingState createEditingState() { return EditingState.NULL; } - - public static final TargetComponent NULLAVOID = new TargetComponent(StringUtils.EMPTY) { - - @Override - public void copy() { - } - - @Override - public boolean paste() { - return false; - } - - @Override - public int getMenuState() { - return DesignState.WORK_SHEET; - } - - @Override - public void cancelFormat() { - return; - } - - @Override - public boolean cut() { - return false; - } - - @Override - public void stopEditing() { - } - - @Override - public AuthorityEditPane createAuthorityEditPane() { - return null; - } - - @Override - public ToolBarMenuDockPlus getToolBarMenuDockPlus() { - return null; - } - - @Override - public ToolBarDef[] toolbars4Target() { - return new ToolBarDef[0]; - } - - @Override - public MenuDef[] menus4Target() { - return new MenuDef[0]; - } - - @Override - public ShortCut[] shortcut4TemplateMenu() { - return new ShortCut[0]; - } - - @Override - public ShortCut[] shortCuts4Authority() { - return new ShortCut[0]; - - } - - @Override - public JComponent[] toolBarButton4Form() { - return new JComponent[0]; - } - - @Override - public JPanel getEastUpPane() { - return new JPanel(); - } - - @Override - public JPanel getEastDownPane() { - return new JPanel(); - } - - }; } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 7880d26872..c2557a5b9c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -19,6 +19,7 @@ import com.fr.design.actions.file.SaveAsTemplateAction; import com.fr.design.actions.file.SaveTemplateAction; import com.fr.design.actions.file.WebPreviewUtils; import com.fr.design.base.mode.DesignModeContext; +import com.fr.design.designer.DesignerProxy; import com.fr.design.designer.TargetComponent; import com.fr.design.dialog.InformationWarnPane; import com.fr.design.file.HistoryTemplateListPane; @@ -71,7 +72,7 @@ import java.util.regex.Pattern; /** * 报表设计和表单设计的编辑区域(设计器编辑的IO文件) */ -public abstract class JTemplate> extends TargetComponent implements ToolBarMenuDockPlus, JTemplateProvider { +public abstract class JTemplate> extends TargetComponent implements ToolBarMenuDockPlus, JTemplateProvider, DesignerProxy { // TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null private static final int PREFIX_NUM = 3000; private FILE editingFILE = null; diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/CopyAction.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/CopyAction.java index a63ede4c15..47f7e3924c 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/actions/CopyAction.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/CopyAction.java @@ -24,10 +24,7 @@ public class CopyAction extends FormWidgetEditAction { @Override public boolean executeActionReturnUndoRecordNeeded() { - FormDesigner tc = getEditingComponent(); - if (tc != null) { - tc.copy(); - } + DesignModeContext.doCopy(getEditingComponent()); return false; } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java index 23788df780..421cae2e6e 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java @@ -24,10 +24,6 @@ public class CutAction extends FormWidgetEditAction { @Override public boolean executeActionReturnUndoRecordNeeded() { - FormDesigner editPane = getEditingComponent(); - if (editPane == null) { - return false; - } - return editPane.cut(); + return DesignModeContext.doCut(getEditingComponent()); } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/PasteAction.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/PasteAction.java index 5bffe9c660..c02295f0f0 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/actions/PasteAction.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/PasteAction.java @@ -1,36 +1,32 @@ package com.fr.design.designer.beans.actions; -import java.awt.event.KeyEvent; - -import javax.swing.KeyStroke; - import com.fr.base.BaseUtils; - +import com.fr.design.base.mode.DesignModeContext; import com.fr.design.mainframe.FormDesigner; +import javax.swing.KeyStroke; +import java.awt.event.KeyEvent; + import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; public class PasteAction extends FormWidgetEditAction { - public PasteAction(FormDesigner t) { - super(t); - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Edit_Paste")); - this.setMnemonic('P'); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/paste.png")); - this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER)); - } - - @Override - public boolean executeActionReturnUndoRecordNeeded() { - FormDesigner tc = getEditingComponent(); - if (tc == null) { - return false; - } - return tc.paste(); - } - @Override - public void update() { - this.setEnabled(true); - } + public PasteAction(FormDesigner t) { + super(t); + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Edit_Paste")); + this.setMnemonic('P'); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/paste.png")); + this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER)); + } + + @Override + public boolean executeActionReturnUndoRecordNeeded() { + return DesignModeContext.doPaste(getEditingComponent()); + } + + @Override + public void update() { + this.setEnabled(true); + } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index bfbe41a72a..ec8020fd21 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -428,10 +428,7 @@ public class JForm extends JTemplate implements BaseJForm { */ @Override public void copy() { - if (DesignModeContext.isBanCopyAndCut()) { - return; - } - this.formDesign.copy(); + DesignModeContext.doCopy(this.formDesign); } @@ -442,7 +439,7 @@ public class JForm extends JTemplate implements BaseJForm { */ @Override public boolean paste() { - return this.formDesign.paste(); + return DesignModeContext.doPaste(this.formDesign); } @@ -453,10 +450,7 @@ public class JForm extends JTemplate implements BaseJForm { */ @Override public boolean cut() { - if (DesignModeContext.isBanCopyAndCut()) { - return false; - } - return this.formDesign.cut(); + return DesignModeContext.doCut(this.formDesign); } // //////////////////////////////////////////////////////////////////// diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java index 96fa44c6d4..c47b142c1c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java @@ -141,7 +141,7 @@ import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_M */ public abstract class ElementCasePane extends TargetComponent implements Selectedable, PageAttributeGetter { - public static enum Clear { + public enum Clear { ALL, FORMATS, CONTENTS, WIDGETS } @@ -174,7 +174,7 @@ public abstract class ElementCasePane extends Tar private CellSelection formatReferencedCell = null; private CellSelection cellNeedTOFormat = null; private FormatBrushAction formatBrushAction; - ActionListener keyListener = new ActionListener() { + private ActionListener keyListener = new ActionListener() { public void actionPerformed(ActionEvent e) { if (!formatBrush.isSelected()) { DesignerContext.setFormatState(DesignerContext.FORMAT_STATE_ONCE); @@ -188,7 +188,7 @@ public abstract class ElementCasePane extends Tar } } }; - ActionListener escKey = new ActionListener() { + private ActionListener escKey = new ActionListener() { public void actionPerformed(ActionEvent e) { cancelFormatBrush(); } @@ -519,10 +519,6 @@ public abstract class ElementCasePane extends Tar } @Override - /** - * 加下面的判断是因为聚合报表>>添加报表聚合块>>选中B1单元格>>再选中该聚合块>>再选中B1单元格,发现属性表右下侧还是现实的聚合块的属性 - * 因为这边判断selection是一个selection,所以不会触发fireSelectionChanged - */ public void setSelection(Selection selection) { if (!ComparatorUtils.equals(this.selection, selection) || !ComparatorUtils.equals(EastRegionContainerPane.getInstance().getCellAttrPane(), CellElementPropertyPane.getInstance())) { @@ -566,7 +562,7 @@ public abstract class ElementCasePane extends Tar } Style style = cellElement.getStyle(); if (style == null) { - style = style.DEFAULT_STYLE; + style = Style.DEFAULT_STYLE; } referencedStyle[i][j] = style; @@ -583,9 +579,6 @@ public abstract class ElementCasePane extends Tar @Override - /** - * - */ public Selection getSelection() { return selection; } @@ -596,7 +589,7 @@ public abstract class ElementCasePane extends Tar * @return 是则返回true */ public boolean isSelectedOneCell() { - return (selection == null) ? false : selection.isSelectedOneCell(this); + return (selection != null) && selection.isSelectedOneCell(this); } /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index df4b27409d..569f02bb6f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -569,10 +569,7 @@ public class JWorkBook extends JTemplate { */ @Override public void copy() { - if (DesignModeContext.isBanCopyAndCut()) { - return; - } - this.delegate4ToolbarMenuAdapter().copy(); + DesignModeContext.doCopy(this.delegate4ToolbarMenuAdapter()); } /** @@ -582,10 +579,7 @@ public class JWorkBook extends JTemplate { */ @Override public boolean cut() { - if (DesignModeContext.isBanCopyAndCut()) { - return false; - } - return this.delegate4ToolbarMenuAdapter().cut(); + return DesignModeContext.doCut(this.delegate4ToolbarMenuAdapter()); } /** @@ -595,7 +589,7 @@ public class JWorkBook extends JTemplate { */ @Override public boolean paste() { - return this.delegate4ToolbarMenuAdapter().paste(); + return DesignModeContext.doPaste(this.delegate4ToolbarMenuAdapter()); } /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponent.java b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponent.java index 1957d68bc8..0fac9c6f73 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponent.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponent.java @@ -3,7 +3,6 @@ */ package com.fr.design.mainframe; -import com.fr.base.BaseUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.actions.AllowAuthorityEditAction; import com.fr.design.actions.ExitAuthorityEditAction; @@ -11,13 +10,11 @@ import com.fr.design.actions.report.ReportBackgroundAction; import com.fr.design.actions.report.ReportFooterAction; import com.fr.design.actions.report.ReportHeaderAction; import com.fr.design.actions.report.ReportPageSetupAction; -import com.fr.design.actions.report.ReportWatermarkAction; import com.fr.design.designer.TargetComponent; import com.fr.design.menu.NameSeparator; import com.fr.design.menu.ShortCut; import com.fr.design.selection.SelectableElement; import com.fr.design.selection.Selectedable; - import com.fr.report.report.TemplateReport; import javax.swing.JScrollBar; @@ -28,9 +25,11 @@ import javax.swing.JScrollBar; */ public abstract class ReportComponent extends TargetComponent implements Selectedable { protected E elementCasePane; + public E getEditingElementCasePane() { return elementCasePane; } + public ReportComponent(T t) { super(t); } @@ -39,6 +38,7 @@ public abstract class ReportComponent { +public class WorkSheetDesigner extends ReportComponent implements DesignerProxy { private static final int HUND = 100; @@ -81,23 +82,17 @@ public class WorkSheetDesigner extends ReportComponent extends TargetComponent implements Selectedable, FormECDesignerProvider { +public class FormElementCaseDesigner + + extends TargetComponent + implements Selectedable, FormECDesignerProvider, DesignerProxy { protected FormElementCasePaneDelegate elementCasePane; @Override @@ -167,10 +171,7 @@ public class FormElementCaseDesigner Date: Wed, 28 Nov 2018 17:11:43 +0800 Subject: [PATCH 2/2] f --- designer-realize/src/main/java/com/fr/poly/PolyDesigner.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java b/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java index 7dcdabf795..91ecf9869d 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java @@ -167,7 +167,7 @@ public class PolyDesigner extends ReportComponent