diff --git a/designer/src/com/fr/design/actions/edit/HyperlinkAction.java b/designer/src/com/fr/design/actions/edit/HyperlinkAction.java index 41559e0a06..6c6c4379b6 100644 --- a/designer/src/com/fr/design/actions/edit/HyperlinkAction.java +++ b/designer/src/com/fr/design/actions/edit/HyperlinkAction.java @@ -15,6 +15,7 @@ import com.fr.design.actions.utils.ReportActionUtils.IterAction; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.HyperlinkGroupPaneActionImpl; import com.fr.design.menu.KeySetUtils; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; @@ -55,7 +56,7 @@ public class HyperlinkAction extends ElementCaseAction { final TemplateElementCase report = reportPane.getEditingElementCase(); NameJavaScriptGroup nameHyperlinks = getNameJSGroup(reportPane, report); - final HyperlinkGroupPane pane = DesignerContext.getDesignerFrame().getSelectedJTemplate().getHyperLinkPane(); + final HyperlinkGroupPane pane = DesignerContext.getDesignerFrame().getSelectedJTemplate().getHyperLinkPane(HyperlinkGroupPaneActionImpl.getInstance()); pane.populate(nameHyperlinks); final Selection sel = reportPane.getSelection(); diff --git a/designer/src/com/fr/design/condition/HyperlinkPane.java b/designer/src/com/fr/design/condition/HyperlinkPane.java index 5e24329abd..bbdecf6611 100644 --- a/designer/src/com/fr/design/condition/HyperlinkPane.java +++ b/designer/src/com/fr/design/condition/HyperlinkPane.java @@ -8,6 +8,7 @@ import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.HyperlinkGroupPaneActionImpl; import com.fr.general.Inter; import com.fr.js.*; import com.fr.report.cell.cellattr.highlight.HighlightAction; @@ -36,7 +37,7 @@ public class HyperlinkPane extends ConditionAttrSingleConditionPane { JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); if (editingTemplate != null && !editingTemplate.isUpMode()) { // 模板初始化完成后,才能初始化超级链接面板 - ReportHyperlinkGroupPane.getInstance().populate(ElementCasePaneDelegate.this); +// HyperlinkGroupPane hyperlinkGroupPane = ReportHyperlinkGroupPane.getInstance(HyperlinkGroupPaneActionImpl.getInstance()); + HyperlinkGroupPane hyperlinkGroupPane = DesignerContext.getDesignerFrame().getSelectedJTemplate() + .getHyperLinkPane(HyperlinkGroupPaneActionImpl.getInstance()); + hyperlinkGroupPane.populate(ElementCasePaneDelegate.this); if (((ElementCasePaneDelegate)e.getSource()).getSelection() instanceof FloatSelection) { EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_FLOAT); // EastRegionContainerPane.getInstance().replaceCellAttrPane(CellElementPropertyPane.getInstance()); @@ -69,7 +73,7 @@ public class ElementCasePaneDelegate extends ElementCasePane { EastRegionContainerPane.getInstance().replaceCellAttrPane(CellElementPropertyPane.getInstance()); EastRegionContainerPane.getInstance().replaceCellElementPane(QuickEditorRegion.getInstance()); } - EastRegionContainerPane.getInstance().replaceHyperlinkPane(ReportHyperlinkGroupPane.getInstance()); + EastRegionContainerPane.getInstance().replaceHyperlinkPane(hyperlinkGroupPane); EastRegionContainerPane.getInstance().removeParameterPane(); } } diff --git a/designer/src/com/fr/design/mainframe/HyperlinkGroupPaneActionImpl.java b/designer/src/com/fr/design/mainframe/HyperlinkGroupPaneActionImpl.java new file mode 100644 index 0000000000..6343deabf6 --- /dev/null +++ b/designer/src/com/fr/design/mainframe/HyperlinkGroupPaneActionImpl.java @@ -0,0 +1,91 @@ +package com.fr.design.mainframe; + +import com.fr.base.Style; +import com.fr.design.actions.utils.ReportActionUtils; +import com.fr.design.designer.TargetComponent; +import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.gui.frpane.HyperlinkGroupPane; +import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; +import com.fr.general.FRFont; +import com.fr.grid.selection.CellSelection; +import com.fr.grid.selection.FloatSelection; +import com.fr.grid.selection.Selection; +import com.fr.js.NameJavaScriptGroup; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.FloatElement; +import com.fr.report.elementcase.TemplateElementCase; +import com.fr.stable.Constants; + +import java.awt.*; + +/** + * Created by plough on 2017/7/26. + */ +public class HyperlinkGroupPaneActionImpl implements HyperlinkGroupPaneActionProvider { + private static HyperlinkGroupPaneActionProvider instance; + + private HyperlinkGroupPaneActionImpl() { + } + + public static HyperlinkGroupPaneActionProvider getInstance() { + if (instance == null) { + instance = new HyperlinkGroupPaneActionImpl(); + } + return instance; + } + + @Override + public void populate(HyperlinkGroupPane hyperlinkGroupPane, TargetComponent elementCasePane) { + ElementCasePane reportPane = (ElementCasePane)elementCasePane; + final TemplateElementCase report = reportPane.getEditingElementCase(); + NameJavaScriptGroup nameHyperlinks = getNameJSGroup(reportPane, report); + hyperlinkGroupPane.populate(nameHyperlinks); + } + + private NameJavaScriptGroup getNameJSGroup(ElementCasePane reportPane, final TemplateElementCase report) { + NameJavaScriptGroup nameHyperlinks = null; + final Selection sel = reportPane.getSelection(); + if (sel instanceof FloatSelection) { + FloatElement selectedFloatElement = report.getFloatElement(((FloatSelection)sel).getSelectedFloatName()); + nameHyperlinks = selectedFloatElement.getNameHyperlinkGroup(); + } else { + CellElement editCellElement = report.getCellElement(((CellSelection)sel).getColumn(), ((CellSelection)sel).getRow()); + if (editCellElement != null) { + nameHyperlinks = editCellElement.getNameHyperlinkGroup(); + } + } + return nameHyperlinks; + } + + @Override + public void saveSettings(HyperlinkGroupPane hyperlinkGroupPane) { + TargetComponent tc = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); + if (tc == null) { + return; + } + ElementCasePane reportPane = (ElementCasePane)tc; + final TemplateElementCase report = reportPane.getEditingElementCase(); + final Selection sel = reportPane.getSelection(); + final NameJavaScriptGroup updateNameHyperlinks = hyperlinkGroupPane.updateJSGroup(); + if (sel instanceof FloatSelection) { + FloatElement selectedFloatElement = report.getFloatElement(((FloatSelection)sel).getSelectedFloatName()); + selectedFloatElement.setNameHyperlinkGroup(updateNameHyperlinks); + } else { + ReportActionUtils.actionIterateWithCellSelection((CellSelection)sel, report, new ReportActionUtils.IterAction() { + public void dealWith(CellElement editCellElement) { + Style elementStyle = editCellElement.getStyle(); + FRFont frFont = elementStyle.getFRFont(); + if (updateNameHyperlinks.size() > 0) { + frFont = frFont.applyForeground(Color.blue); + frFont = frFont.applyUnderline(Constants.LINE_THIN); + } else { + frFont = frFont.applyForeground(Color.black); + frFont = frFont.applyUnderline(Constants.LINE_NONE); + } + editCellElement.setStyle(elementStyle.deriveFRFont(frFont)); + editCellElement.setNameHyperlinkGroup(updateNameHyperlinks); + } + }); + } + } +} diff --git a/designer/src/com/fr/design/mainframe/JWorkBook.java b/designer/src/com/fr/design/mainframe/JWorkBook.java index 37f8a3597f..4475481f2e 100644 --- a/designer/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer/src/com/fr/design/mainframe/JWorkBook.java @@ -22,6 +22,7 @@ import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.fun.PreviewProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; +import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIModeControlContainer; import com.fr.design.gui.imenu.UIMenuItem; @@ -113,6 +114,11 @@ public class JWorkBook extends JTemplate { EastRegionContainerPane.getInstance().replaceCellAttrPane(getEastDownPane()); } + @Override + public TargetComponent getCurrentElementCasePane() { + return getEditingElementCasePane(); + } + @Override protected UIModeControlContainer createCenterPane() { parameterPane = ModuleContext.isModuleStarted(Module.FORM_MODULE) ? new ParameterDefinitePane() : null; @@ -825,8 +831,8 @@ public class JWorkBook extends JTemplate { } @Override - public HyperlinkGroupPane getHyperLinkPane() { - return ReportHyperlinkGroupPane.getInstance(); + public HyperlinkGroupPane getHyperLinkPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { + return ReportHyperlinkGroupPane.getInstance(hyperlinkGroupPaneActionProvider); } public void setAuthorityMode(boolean isUpMode) { diff --git a/designer/src/com/fr/design/mainframe/ReportHyperlinkGroupPane.java b/designer/src/com/fr/design/mainframe/ReportHyperlinkGroupPane.java index 84967915fb..b2b018e0be 100644 --- a/designer/src/com/fr/design/mainframe/ReportHyperlinkGroupPane.java +++ b/designer/src/com/fr/design/mainframe/ReportHyperlinkGroupPane.java @@ -4,6 +4,7 @@ import com.fr.base.Style; import com.fr.design.actions.utils.ReportActionUtils; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.frpane.HyperlinkGroupPane; +import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.general.FRFont; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.FloatSelection; @@ -22,13 +23,13 @@ import java.awt.*; public class ReportHyperlinkGroupPane extends HyperlinkGroupPane { private static ReportHyperlinkGroupPane singleton; - private ReportHyperlinkGroupPane() { - super(); + private ReportHyperlinkGroupPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { + super(hyperlinkGroupPaneActionProvider); } - public synchronized static ReportHyperlinkGroupPane getInstance() { + public synchronized static ReportHyperlinkGroupPane getInstance(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { if (singleton == null) { - singleton = new ReportHyperlinkGroupPane(); + singleton = new ReportHyperlinkGroupPane(hyperlinkGroupPaneActionProvider); } singleton.refreshPane(); return singleton; @@ -39,62 +40,6 @@ public class ReportHyperlinkGroupPane extends HyperlinkGroupPane { if (reportPane == null) { return; } -// - final TemplateElementCase report = reportPane.getEditingElementCase(); - NameJavaScriptGroup nameHyperlinks = getNameJSGroup(reportPane, report); - populate(nameHyperlinks); - } - - public void populate(ElementCasePane reportPane) { - final TemplateElementCase report = reportPane.getEditingElementCase(); - NameJavaScriptGroup nameHyperlinks = getNameJSGroup(reportPane, report); - populate(nameHyperlinks); - } - - private NameJavaScriptGroup getNameJSGroup(ElementCasePane reportPane, final TemplateElementCase report) { - NameJavaScriptGroup nameHyperlinks = null; - final Selection sel = reportPane.getSelection(); - if (sel instanceof FloatSelection) { - FloatElement selectedFloatElement = report.getFloatElement(((FloatSelection)sel).getSelectedFloatName()); - nameHyperlinks = selectedFloatElement.getNameHyperlinkGroup(); - } else { - CellElement editCellElement = report.getCellElement(((CellSelection)sel).getColumn(), ((CellSelection)sel).getRow()); - if (editCellElement != null) { - nameHyperlinks = editCellElement.getNameHyperlinkGroup(); - } - } - - return nameHyperlinks; - } - - @Override - public void saveSettings() { - ElementCasePane reportPane = ((JWorkBook)HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()).getEditingElementCasePane(); - if (reportPane == null) { - return; - } - final TemplateElementCase report = reportPane.getEditingElementCase(); - final Selection sel = reportPane.getSelection(); - final NameJavaScriptGroup updateNameHyperlinks = updateJSGroup(); - if (sel instanceof FloatSelection) { - FloatElement selectedFloatElement = report.getFloatElement(((FloatSelection)sel).getSelectedFloatName()); - selectedFloatElement.setNameHyperlinkGroup(updateNameHyperlinks); - } else { - ReportActionUtils.actionIterateWithCellSelection((CellSelection)sel, report, new ReportActionUtils.IterAction() { - public void dealWith(CellElement editCellElement) { - Style elementStyle = editCellElement.getStyle(); - FRFont frFont = elementStyle.getFRFont(); - if (updateNameHyperlinks.size() > 0) { - frFont = frFont.applyForeground(Color.blue); - frFont = frFont.applyUnderline(Constants.LINE_THIN); - } else { - frFont = frFont.applyForeground(Color.black); - frFont = frFont.applyUnderline(Constants.LINE_NONE); - } - editCellElement.setStyle(elementStyle.deriveFRFont(frFont)); - editCellElement.setNameHyperlinkGroup(updateNameHyperlinks); - } - }); - } + populate(reportPane); } } diff --git a/designer/src/com/fr/design/mainframe/form/FormElementCaseDesigner.java b/designer/src/com/fr/design/mainframe/form/FormElementCaseDesigner.java index f01c761106..d1c756e903 100644 --- a/designer/src/com/fr/design/mainframe/form/FormElementCaseDesigner.java +++ b/designer/src/com/fr/design/mainframe/form/FormElementCaseDesigner.java @@ -22,10 +22,7 @@ import com.fr.design.designer.TargetComponent; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.AuthorityEditPane; -import com.fr.design.mainframe.ElementCasePane; -import com.fr.design.mainframe.ElementCasePaneAuthorityEditPane; -import com.fr.design.mainframe.JWorkBook; +import com.fr.design.mainframe.*; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.menu.MenuDef; import com.fr.design.menu.NameSeparator; @@ -225,6 +222,10 @@ public class FormElementCaseDesigner> ex // 刷新右侧属性面板 public abstract void refreshEastPropertiesPane(); + public abstract TargetComponent getCurrentElementCasePane(); + // 为收集模版信息作准备 private void initForCollect() { template.initTemplateID(); // 为新模板设置 templateID 属性 @@ -882,7 +885,7 @@ public abstract class JTemplate> ex * 返回当前支持的超链界面pane * @return 超链连接界面 */ - public abstract HyperlinkGroupPane getHyperLinkPane(); + public abstract HyperlinkGroupPane getHyperLinkPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider); /** * 是否是图表 diff --git a/designer_base/src/com/fr/design/mainframe/form/FormECDesignerProvider.java b/designer_base/src/com/fr/design/mainframe/form/FormECDesignerProvider.java index 579ff46d70..d3a5374dc7 100644 --- a/designer_base/src/com/fr/design/mainframe/form/FormECDesignerProvider.java +++ b/designer_base/src/com/fr/design/mainframe/form/FormECDesignerProvider.java @@ -5,6 +5,7 @@ import java.awt.image.BufferedImage; import javax.swing.JComponent; +import com.fr.design.designer.TargetComponent; import com.fr.design.menu.MenuDef; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; @@ -61,6 +62,18 @@ public interface FormECDesignerProvider { */ public JComponent getEastUpPane(); + /** + * 超级链接面板 + * @return 属性面板 + */ + public JComponent getHyperlinkPane(); + + /** + * 超级链接面板 + * @return 属性面板 + */ + public TargetComponent getEditingElementCasePane(); + /** * 获取当前ElementCase的缩略图 * @param elementCaseContainerSize 缩略图的大小 diff --git a/designer_form/src/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java b/designer_form/src/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java index 4bbd265c50..125f6b751c 100644 --- a/designer_form/src/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java +++ b/designer_form/src/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java @@ -4,6 +4,7 @@ import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.form.javascript.FormEmailPane; +import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.js.EmailJavaScript; @@ -11,13 +12,13 @@ import com.fr.js.EmailJavaScript; public class FormHyperlinkGroupPane extends HyperlinkGroupPane{ private static FormHyperlinkGroupPane singleton; - private FormHyperlinkGroupPane() { - super(); + private FormHyperlinkGroupPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { + super(hyperlinkGroupPaneActionProvider); } - public synchronized static FormHyperlinkGroupPane getInstance() { + public synchronized static FormHyperlinkGroupPane getInstance(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { if (singleton == null) { - singleton = new FormHyperlinkGroupPane(); + singleton = new FormHyperlinkGroupPane(hyperlinkGroupPaneActionProvider); } return singleton; } @@ -38,9 +39,4 @@ public class FormHyperlinkGroupPane extends HyperlinkGroupPane{ } return creators; } - - @Override - public void saveSettings() { - } - } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index 7a3ca7ac4b..cde441c897 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -6,6 +6,7 @@ import com.fr.design.actions.core.WorkBookSupportable; import com.fr.design.actions.file.WebPreviewUtils; import com.fr.design.cell.FloatElementsProvider; import com.fr.design.constants.UIConstants; +import com.fr.design.designer.TargetComponent; import com.fr.design.designer.beans.actions.CopyAction; import com.fr.design.designer.beans.actions.CutAction; import com.fr.design.designer.beans.actions.FormDeleteAction; @@ -17,6 +18,7 @@ import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.gui.frpane.HyperlinkGroupPane; +import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.xpane.FormHyperlinkGroupPane; @@ -92,6 +94,11 @@ public class JForm extends JTemplate implements BaseJForm { public void refreshEastPropertiesPane() { } + @Override + public TargetComponent getCurrentElementCasePane() { + return elementCaseDesign.getEditingElementCasePane(); + } + public int getMenuState() { return DesignState.JFORM; @@ -137,8 +144,8 @@ public class JForm extends JTemplate implements BaseJForm { * * @return 超链连接界面 */ - public HyperlinkGroupPane getHyperLinkPane() { - return FormHyperlinkGroupPane.getInstance(); + public HyperlinkGroupPane getHyperLinkPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { + return FormHyperlinkGroupPane.getInstance(hyperlinkGroupPaneActionProvider); } //表单返回 FORM_TAB or ELEMENTCASE_TAB @@ -653,6 +660,7 @@ public class JForm extends JTemplate implements BaseJForm { EastRegionContainerPane.getInstance().removeParameterPane(); EastRegionContainerPane.getInstance().replaceCellAttrPane(elementCaseDesign.getEastDownPane()); EastRegionContainerPane.getInstance().replaceCellElementPane(elementCaseDesign.getEastUpPane()); + EastRegionContainerPane.getInstance().replaceHyperlinkPane(elementCaseDesign.getHyperlinkPane()); return; } }