From ef88a3f1e198c176f607f53f118c4007b2923d38 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 7 Sep 2020 17:22:24 +0800 Subject: [PATCH 01/11] =?UTF-8?q?REPORT-35149=20=E9=A2=84=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=A0=B7=E5=BC=8F=E4=BC=98=E5=8C=96=E5=8F=8A=E4=B8=8E?= =?UTF-8?q?=E5=9B=BE=E8=A1=A8=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/gui/style/AlignmentPane.java | 2 +- .../fr/design/gui/style/BackgroundPane.java | 4 +- .../fr/design/layout/FRGUIPaneFactory.java | 46 ++++ .../com/fr/design/mainframe/JTemplate.java | 52 +++- .../burying/point/AbstractPointCollector.java | 40 +-- .../point/AbstractTemplateInfoCollector.java | 56 ++++ .../burying/point/BasePointCollector.java | 5 - .../chart/info/ChartInfoCollector.java | 4 +- .../mainframe/predefined/PatternStyle.java | 36 +++ .../info/PredefinedStyleInfoCollector.java | 118 ++++++++ .../predefined/ui/PredefinedStyleBlock.java | 141 ++++++++++ .../ui/PredefinedStyleEditPane.java | 219 +++++++++++++++ .../ui/PredefinedStyleSelectPane.java | 102 +++++++ .../ui/PredefinedStyleSettingPane.java | 152 +++++++++++ .../ui/ReportPredefinedStylePane.java | 53 ++++ .../ui/ServerPredefinedStylePane.java | 201 ++++++++++++++ .../ui/detail/CellStyleSettingPane.java | 234 ++++++++++++++++ .../ui/detail/ComponentStyleSettingPane.java | 69 +++++ .../PredefinedBackgroundSettingPane.java | 84 ++++++ .../background/BackgroundSettingPane.java | 167 ++++++++++++ .../ui/detail/background/BackgroundType.java | 99 +++++++ .../BackgroundWithAlphaSettingPane.java | 78 ++++++ .../ui/detail/background/ColorDetailPane.java | 102 +++++++ .../background/EmptyBackgroundPane.java | 27 ++ .../detail/background/GradientDetailPane.java | 147 ++++++++++ .../ui/detail/background/ImageDetailPane.java | 190 +++++++++++++ .../detail/background/PatternDetailPane.java | 93 +++++++ .../background/TextureDetailObservePane.java | 60 +++++ .../cell/CustomPredefinedStylePane.java | 129 +++++++++ .../component/ComponentFrameStylePane.java | 147 ++++++++++ .../component/ComponentMarginStylePane.java | 93 +++++++ .../detail/component/ComponentStylePane.java | 15 ++ .../component/ComponentTitleStylePane.java | 252 ++++++++++++++++++ .../ui/dialog/PredefinedStyleEditDialog.java | 190 +++++++++++++ .../dialog/ReportPredefinedStyleDialog.java | 93 +++++++ .../dialog/ServerPredefinedStyleDialog.java | 69 +++++ .../ui/preview/ComponentPreviewPane.java | 146 ++++++++++ .../ui/preview/ElementCasePreview.java | 98 +++++++ .../preview/PredefinedStylePreviewPane.java | 76 ++++++ .../ui/preview/StyleSettingPreviewPane.java | 17 ++ .../mainframe/template/info/SendHelper.java | 2 +- .../template/info/TemplateInfoCollector.java | 4 +- .../design/style/background/impl/BPane.java | 2 +- .../impl/TextureBackgroundPane.java | 192 ++----------- .../background/texture/TextureDetailPane.java | 208 +++++++++++++++ .../design/style/color/ColorSelectPane.java | 29 +- .../com/fr/design/icon/icon_edit.png | Bin 0 -> 333 bytes .../fr/design/icon/icon_predefined_style.png | Bin 0 -> 269 bytes .../design/mainframe/predefined/previewData | 11 + .../PredefinedStyleInfoCollectorTest.java | 97 +++++++ .../predefined/info/predefinedStyle.info | 2 + .../xpane/FormPredefinedBackgroundPane.java | 101 +++++++ .../PredefinedComponentStyleSettingPane.java | 179 +++++++++++++ .../AccessibleBodyBackgroundEditor.java | 98 +++++++ .../AccessibleBorderStyleEditor.java | 99 +++++++ .../AccessibleWLayoutBorderStyleEditor.java | 83 ++++-- .../layout/BorderStyleWidgetDefinePane.java | 14 +- .../ui/designer/layout/ComponentStyle.java | 35 +++ .../layout/ElementEditorDefinePane.java | 11 - .../FRAbsoluteBodyLayoutDefinePane.java | 23 +- .../layout/FRFitLayoutDefinePane.java | 22 +- .../layout/WTitleLayoutDefinePane.java | 19 +- .../report/ReportBackgroundAction.java | 11 +- .../ServerPredefinedStyleAction.java | 52 ++++ .../mainframe/InformationCollector.java | 4 +- .../com/fr/design/mainframe/JWorkBook.java | 4 + .../cell/settingpane/CellStylePane.java | 87 ++---- .../style/CellPredefinedStyleSettingPane.java | 243 +++++++++++++++++ .../ReportPredefinedBackgroundPane.java | 128 +++++++++ .../src/main/java/com/fr/grid/GridUI.java | 7 + .../main/java/com/fr/start/MainDesigner.java | 4 +- 71 files changed, 5325 insertions(+), 352 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractTemplateInfoCollector.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/PatternStyle.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/info/PredefinedStyleInfoCollector.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleBlock.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSelectPane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSettingPane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ReportPredefinedStylePane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ServerPredefinedStylePane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleSettingPane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ComponentStyleSettingPane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/PredefinedBackgroundSettingPane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundSettingPane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundType.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundWithAlphaSettingPane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/EmptyBackgroundPane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/GradientDetailPane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ImageDetailPane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/PatternDetailPane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/TextureDetailObservePane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/cell/CustomPredefinedStylePane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentFrameStylePane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentMarginStylePane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentStylePane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentTitleStylePane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/PredefinedStyleEditDialog.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/ReportPredefinedStyleDialog.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/ServerPredefinedStyleDialog.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ComponentPreviewPane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ElementCasePreview.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/PredefinedStylePreviewPane.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/StyleSettingPreviewPane.java create mode 100644 designer-base/src/main/java/com/fr/design/style/background/texture/TextureDetailPane.java create mode 100644 designer-base/src/main/resources/com/fr/design/icon/icon_edit.png create mode 100644 designer-base/src/main/resources/com/fr/design/icon/icon_predefined_style.png create mode 100644 designer-base/src/main/resources/com/fr/design/mainframe/predefined/previewData create mode 100644 designer-base/src/test/java/com/fr/design/mainframe/predefined/info/PredefinedStyleInfoCollectorTest.java create mode 100644 designer-base/src/test/resources/com/fr/design/mainframe/predefined/info/predefinedStyle.info create mode 100644 designer-form/src/main/java/com/fr/design/gui/xpane/FormPredefinedBackgroundPane.java create mode 100644 designer-form/src/main/java/com/fr/design/gui/xpane/PredefinedComponentStyleSettingPane.java create mode 100644 designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBodyBackgroundEditor.java create mode 100644 designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBorderStyleEditor.java create mode 100644 designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ComponentStyle.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/server/predefined/ServerPredefinedStyleAction.java create mode 100644 designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CellPredefinedStyleSettingPane.java create mode 100644 designer-realize/src/main/java/com/fr/design/report/ReportPredefinedBackgroundPane.java diff --git a/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java b/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java index b188cb5aa8..50d6448b8d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java @@ -55,7 +55,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO private static final int ANGEL = 90; private static final int GAP = 23; private static final int VERGAP = 3; - private static final Dimension SPINNER_DIMENSION = new Dimension(75, 20); + private static final Dimension SPINNER_DIMENSION = new Dimension(70, 20); private static final String[] TEXT = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Wrap_Text"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Single_Line"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_StyleAlignment_Single_Line(Adjust_Font)"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_StyleAlignment_Multi_Line(Adjust_Font)")}; diff --git a/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java b/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java index 88ee482cb8..22e883c1e9 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java @@ -71,7 +71,7 @@ public class BackgroundPane extends AbstractBasicStylePane { double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Fill") + " ", SwingConstants.LEFT),typeComboBox}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Fill"), SwingConstants.LEFT),typeComboBox}, new Component[]{null, centerPane} }; double[] rowSize = {p, p, p}; @@ -172,4 +172,4 @@ public class BackgroundPane extends AbstractBasicStylePane { return style.deriveBackground(this.update()); } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java index f63d8f576c..da0a2131c6 100644 --- a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java @@ -152,6 +152,20 @@ public class FRGUIPaneFactory { return jp; } + /** + * 创建一个无间隔带标题边框面板 + * + * @param string 边框标题 + * @return JPanel对象 + */ + public static JPanel createTitledBorderNoGapPane(String string) { + JPanel jp = new JPanel(); + UITitledBorder explainBorder = UITitledBorder.createBorderWithTitle(string); + jp.setBorder(explainBorder); + jp.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + return jp; + } + /** * 创建一个带标题边框面板,垂直居左布局 * @@ -304,6 +318,21 @@ public class FRGUIPaneFactory { return jp; } + /** + * 创建一个靠左的水平流式布局 + * @param firstGap 首元素和边框间距 + * @param hgap 水平间距 + * @param vgap 竖直间距 + * @return JPanel对象 + */ + public static JPanel createBoxFlowInnerContainer_S_Pane(int firstGap, int hgap, int vgap) { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + jp.setLayout(new FRLeftFlowLayout(firstGap, hgap, vgap)); + return jp; + } + + /** * 创建一个靠左流式布局,流式内嵌,首元素距离左边0 * @@ -315,6 +344,21 @@ public class FRGUIPaneFactory { return jp; } + /** + * 创建一个靠左的水平流式布局 + * @param hgap 水平间距 + * @param vgap 竖直间距 + * @return JPanel对象 + */ + public static JPanel createBoxFlowInnerContainer_S_Pane(int hgap, int vgap) { + JPanel jp = new JPanel(); + jp.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + jp.setLayout(new FlowLayout(FlowLayout.LEFT, hgap, vgap)); + return jp; + } + + + /** * 创建一个靠右面板 * @@ -469,6 +513,8 @@ public class FRGUIPaneFactory { return jp; } + + /** * 创建垂直流布局面板 * 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 f29e22698c..b898dda3a1 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 @@ -6,6 +6,7 @@ import com.fr.base.Parameter; import com.fr.base.ScreenResolution; import com.fr.base.io.BaseBook; import com.fr.base.iofile.attr.DesignBanCopyAttrMark; +import com.fr.base.iofile.attr.PredefinedStyleAttrMark; import com.fr.base.iofile.attr.TemplateIdAttrMark; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignModelAdapter; @@ -38,6 +39,9 @@ import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.chart.info.ChartInfoCollector; +import com.fr.design.mainframe.predefined.info.PredefinedStyleInfoCollector; +import com.fr.design.mainframe.predefined.ui.ReportPredefinedStylePane; +import com.fr.design.mainframe.predefined.ui.dialog.ReportPredefinedStyleDialog; import com.fr.design.mainframe.template.info.TemplateInfoCollector; import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.design.mainframe.template.info.TimeConsumeTimer; @@ -80,6 +84,8 @@ import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.undo.UndoManager; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Arrays; import java.util.Set; @@ -142,8 +148,14 @@ public abstract class JTemplate> consumeTimer.setEnabled(shouldInitForCollectInfo(isNewFile)); initAndStartPlugin(); + + if (this.template.getAttrMark(PredefinedStyleAttrMark.XML_TAG) == null) { + this.template.addAttrMark(new PredefinedStyleAttrMark()); + } } + + private void initAndStartPlugin() { initPluginPane(); startListenPlugin(); @@ -1296,10 +1308,48 @@ public abstract class JTemplate> for (DesignerFrameUpButtonProvider provider : providers) { uiButtons = ArrayUtils.addAll(uiButtons, provider.getUpButtons(getMenuState())); } - + UIButton predefinedBtn = createPreferenceButton(); + if (predefinedBtn != null) { + uiButtons = ArrayUtils.addAll(uiButtons, new UIButton[]{predefinedBtn}); + } return uiButtons; } + protected UIButton createPreferenceButton(){ + UIButton preferenceButton = new UIButton(BaseUtils.readIcon("/com/fr/design/icon/icon_predefined_style.png")); + preferenceButton.setToolTipText("预定义样式按钮"); + preferenceButton.setText(getTemplatePredefinedStyle()); + preferenceButton.set4ToolbarButton(); + preferenceButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); + ReportPredefinedStylePane stylePane = new ReportPredefinedStylePane(JTemplate.this, preferenceButton); + ReportPredefinedStyleDialog dialog = new ReportPredefinedStyleDialog(designerFrame, stylePane); + PredefinedStyleInfoCollector.getInstance().collectClickNumber(); + dialog.setVisible(true); + + } + }); + return preferenceButton; + } + + public void resetPredefinedStyle(String styleName, UIButton predefinedBtn){ + this.getTarget().resetPreferenceStyle(styleName); + predefinedBtn.setText(getTemplatePredefinedStyle()); + this.fireTargetModified(); + this.repaint(); + } + + public String getTemplatePredefinedStyle(){ + PredefinedStyleAttrMark attrMark = this.getTarget().getAttrMark(PredefinedStyleAttrMark.XML_TAG); + if (attrMark == null){ + attrMark = new PredefinedStyleAttrMark(); + } + return attrMark.getPreferenceStyleName(); + } + + /** * 由于老版本的模板没有模板ID,当勾选使用参数模板时候,就加一个模板ID attr * diff --git a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java index 15291211cb..6ac14505a6 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java @@ -3,7 +3,6 @@ package com.fr.design.mainframe.burying.point; import com.fr.base.FRContext; import com.fr.base.io.XMLReadHelper; import com.fr.design.DesignerEnvManager; -import com.fr.design.mainframe.template.info.SendHelper; import com.fr.log.FineLoggerFactory; import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; @@ -20,25 +19,20 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; /** * @author Bjorn * @version 10.0 * Created by Bjorn on 2020-02-21 */ -public abstract class AbstractPointCollector implements BasePointCollector { +public abstract class AbstractPointCollector implements BasePointCollector { + - protected Map pointInfoMap; private static final int MAX_SIZE = 512 * 1024 * 1024; public AbstractPointCollector() { - pointInfoMap = new ConcurrentHashMap<>(); - loadFromFile(); + } /** @@ -48,34 +42,6 @@ public abstract class AbstractPointCollector implem return FileUtils.sizeOf(getInfoFile()) <= MAX_SIZE && DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); } - @Override - public void sendPointInfo() { - - addIdleDayCount(); - - List removeList = new ArrayList<>(); - List sendList = new ArrayList<>(); - - for (String key : pointInfoMap.keySet()) { - AbstractPointInfo pointInfo = pointInfoMap.get(key); - pointInfo.selectPoint(removeList, sendList); - } - - // 发送记录 - for (String key : sendList) { - if(SendHelper.sendPointInfo(pointInfoMap.get(key))){ - removeList.add(key); - } - } - - // 清空记录 - for (String key : removeList) { - pointInfoMap.remove(key); - } - - saveInfo(); - } - /** * 从文件中读取埋点信息 */ diff --git a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractTemplateInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractTemplateInfoCollector.java new file mode 100644 index 0000000000..34dc5ea2a4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractTemplateInfoCollector.java @@ -0,0 +1,56 @@ +package com.fr.design.mainframe.burying.point; + +import com.fr.design.mainframe.template.info.SendHelper; +import com.fr.design.mainframe.template.info.TemplateProcessInfo; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Created by kerry on 2020-09-04 + */ +public abstract class AbstractTemplateInfoCollector extends AbstractPointCollector { + protected Map pointInfoMap; + + public AbstractTemplateInfoCollector() { + pointInfoMap = new ConcurrentHashMap<>(); + loadFromFile(); + + } + + + /** + * 保存埋点的信息到本地 + */ + public abstract void collectInfo(String templateID, String originID, TemplateProcessInfo processInfo, int timeConsume); + + @Override + public void sendPointInfo() { + + addIdleDayCount(); + + List removeList = new ArrayList<>(); + List sendList = new ArrayList<>(); + + for (String key : pointInfoMap.keySet()) { + BasePointInfo pointInfo = pointInfoMap.get(key); + pointInfo.selectPoint(removeList, sendList); + } + + // 发送记录 + for (String key : sendList) { + if(SendHelper.sendPointInfo(pointInfoMap.get(key))){ + removeList.add(key); + } + } + + // 清空记录 + for (String key : removeList) { + pointInfoMap.remove(key); + } + + saveInfo(); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointCollector.java index f10f1682e0..e2a3c778c9 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointCollector.java @@ -1,6 +1,5 @@ package com.fr.design.mainframe.burying.point; -import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.stable.xml.XMLReadable; import com.fr.stable.xml.XMLWriter; @@ -16,8 +15,4 @@ public interface BasePointCollector extends XMLReadable, XMLWriter { */ public void sendPointInfo(); - /** - * 保存埋点的信息到本地 - */ - public void collectInfo(String templateID, String originID, TemplateProcessInfo processInfo, int timeConsume); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java index cd651fc6b3..428e5625c6 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java @@ -4,7 +4,7 @@ import com.fr.base.io.BaseBook; import com.fr.chartx.attr.ChartProvider; import com.fr.chartx.config.info.AbstractConfig; import com.fr.chartx.config.info.constant.ConfigType; -import com.fr.design.mainframe.burying.point.AbstractPointCollector; +import com.fr.design.mainframe.burying.point.AbstractTemplateInfoCollector; import com.fr.design.mainframe.template.info.TemplateInfo; import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.general.ComparatorUtils; @@ -21,7 +21,7 @@ import java.util.Map; * @version 10.0 * Created by Bjorn on 2020-02-18 */ -public class ChartInfoCollector extends AbstractPointCollector { +public class ChartInfoCollector extends AbstractTemplateInfoCollector { private static final String XML_TAG = "ChartInfoCollector"; private static final String XML_LAST_EDIT_DAY = "lastEditDay"; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/PatternStyle.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/PatternStyle.java new file mode 100644 index 0000000000..372ad10c70 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/PatternStyle.java @@ -0,0 +1,36 @@ +package com.fr.design.mainframe.predefined; + +import com.fr.config.predefined.PredefinedStyle; + + +/** + * Created by kerry on 2020-08-31 + */ +public enum PatternStyle { + DARK_STYLE(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Dark_Pattern")) { + @Override + public PredefinedStyle getPredefinedStyle() { + return new PredefinedStyle(); + } + }, + LIGHT_STYLE(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Light_Pattern")) { + @Override + public PredefinedStyle getPredefinedStyle() { + return new PredefinedStyle(); + } + }; + + + private String name; + + PatternStyle(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public abstract PredefinedStyle getPredefinedStyle(); + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/info/PredefinedStyleInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/info/PredefinedStyleInfoCollector.java new file mode 100644 index 0000000000..2827cbee0b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/info/PredefinedStyleInfoCollector.java @@ -0,0 +1,118 @@ +package com.fr.design.mainframe.predefined.info; + +import com.fr.config.MarketConfig; +import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.burying.point.AbstractPointCollector; +import com.fr.design.mainframe.template.info.SendHelper; +import com.fr.general.CloudCenter; +import com.fr.general.GeneralUtils; +import com.fr.json.JSONObject; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLableReader; +import com.fr.third.joda.time.DateTime; + +/** + * Created by kerry on 2020-09-04 + */ +public class PredefinedStyleInfoCollector extends AbstractPointCollector { + private static final String SIMPLE_DATE_PATTERN = "yyyy-MM-dd"; + private static final String XML_TAG = "PredefinedStyleInfo"; + private static final String XML_FILE_NAME = "predefinedStyle.info"; + private static final String CLOUD_URL = CloudCenter.getInstance().acquireUrlByKind("predefinedInfo.collector") + "/single"; + + private static final String FUNCTION_NAME = "predefinedStyle"; + private static final String FUNCTION_ID = "FR-F7003"; + + private static final String ATTR_FUNCTION_NAME = "functionName"; + private static final String ATTR_FUNCTION_ID = "functionId"; + private static final String ATTR_UUID = "uuid"; + private static final String ATTR_UID = "uid"; + private static final String ATTR_JAR_TIME = "jatTime"; + private static final String ATTR_CLICK_NUMBER = "clickNumber"; + private static final String ATTR_USE_NUMBER = "useNumber"; + private static final String ATTR_TIME = "time"; + + private int clickNumber = 0; + + private int useNumber = 0; + + public int getClickNumber() { + return clickNumber; + } + + public int getUseNumber() { + return useNumber; + } + + private static class Holder { + private static PredefinedStyleInfoCollector collector = new PredefinedStyleInfoCollector(); + } + + private PredefinedStyleInfoCollector() { + loadFromFile(); + } + + public static PredefinedStyleInfoCollector getInstance() { + return Holder.collector; + } + + public void collectClickNumber() { + clickNumber++; + saveInfo(); + } + + public void collectUseNumber() { + useNumber++; + saveInfo(); + } + + @Override + protected String getInfoFilePath() { + return XML_FILE_NAME; + } + + @Override + protected void addIdleDayCount() { + + } + + @Override + public void sendPointInfo() { + String content = generateTotalInfo(); + + SendHelper.sendSinglePointInfo(CLOUD_URL, content); + } + + public String generateTotalInfo() { + + JSONObject jo = JSONObject.create(); + jo.put(ATTR_FUNCTION_NAME, FUNCTION_NAME); + jo.put(ATTR_FUNCTION_ID, FUNCTION_ID); + jo.put(ATTR_UUID, DesignerEnvManager.getEnvManager().getUUID()); + jo.put(ATTR_UID, MarketConfig.getInstance().getBBSAttr().getBbsUid()); + jo.put(ATTR_JAR_TIME, GeneralUtils.readFullVersionNO()); + jo.put(ATTR_CLICK_NUMBER, this.clickNumber); + jo.put(ATTR_USE_NUMBER, this.useNumber); + jo.put(ATTR_TIME, DateTime.now().toString(SIMPLE_DATE_PATTERN)); + return jo.toString(); + } + + + @Override + public void readXML(XMLableReader reader) { + if (reader.isAttr()) { + String name = reader.getTagName(); + if (XML_TAG.equals(name)) { + this.clickNumber = reader.getAttrAsInt(ATTR_CLICK_NUMBER, 0); + this.useNumber = reader.getAttrAsInt(ATTR_USE_NUMBER, 0); + } + } + } + + @Override + public void writeXML(XMLPrintWriter writer) { + writer.startTAG(XML_TAG); + writer.attr(ATTR_CLICK_NUMBER, this.clickNumber).attr(ATTR_USE_NUMBER, this.useNumber); + writer.end(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleBlock.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleBlock.java new file mode 100644 index 0000000000..5fb8f35320 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleBlock.java @@ -0,0 +1,141 @@ +package com.fr.design.mainframe.predefined.ui; + +import com.fr.base.BaseUtils; +import com.fr.base.GraphHelper; +import com.fr.config.predefined.PredefinedStyle; +import com.fr.design.mainframe.predefined.ui.dialog.PredefinedStyleEditDialog; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.predefined.ui.preview.PredefinedStylePreviewPane; +import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; +import com.fr.stable.Constants; + +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +/** + * Created by kerry on 2020-08-25 + */ +public class PredefinedStyleBlock extends JPanel { + private PredefinedStyle previewObject; + private PredefinedStyleSelectPane parentPane; + private Icon markedMode = IOUtils.readIcon("/com/fr/design/form/images/marked.png"); + private static final Color BORDER_COLOR = new Color(141, 194, 249); + + private boolean mouseOver = false; + + private MouseListener mouseListener = new MouseListener() { + @Override + public void mouseClicked(MouseEvent e) { + setSelect(); + } + + @Override + public void mousePressed(MouseEvent e) { + + } + + @Override + public void mouseReleased(MouseEvent e) { + + } + + @Override + public void mouseEntered(MouseEvent e) { + mouseOver = true; + PredefinedStyleBlock.this.repaint(); + } + + @Override + public void mouseExited(MouseEvent e) { + mouseOver = false; + PredefinedStyleBlock.this.repaint(); + } + }; + + + public PredefinedStyleBlock(PredefinedStyle previewObject, PredefinedStyleSelectPane selectPane, boolean supportEdit) { + this.previewObject = previewObject; + this.parentPane = selectPane; + initPane(supportEdit); + this.addMouseListener(mouseListener); + } + + private void setSelect() { + this.parentPane.setSelectedPreviewPane(this); + } + + @Override + public void paint(Graphics g) { + super.paint(g); + boolean isSelected = ComparatorUtils.equals(this, this.parentPane.getSelectedPreviewPane()); + if (ComparatorUtils.equals(this.parentPane.getCurrentApplicateStyle(), this.previewObject.getStyleName())) { + markedMode.paintIcon(this, g, 176, 0); + } + if (isSelected || this.mouseOver) { + g.setColor(BORDER_COLOR); + Rectangle rectangle = new Rectangle(1, 1, this.getWidth() - 2, this.getHeight() - 2); + GraphHelper.draw(g, rectangle, Constants.LINE_LARGE); + } + } + + + private void initPane(boolean supportEdit) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + PredefinedStylePreviewPane content = new PredefinedStylePreviewPane(0.387, 0.384); + content.setPreferredSize(new Dimension(200, 125)); + UILabel label = new UILabel(previewObject.getStyleName()); + label.setPreferredSize(new Dimension(167, 25)); + + + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + panel.setBorder(BorderFactory.createEmptyBorder(0,0,2,2)); + panel.add(label, BorderLayout.WEST); + if (supportEdit) { + addEditButton(panel); + } + + this.add(content, BorderLayout.CENTER); + this.add(panel, BorderLayout.SOUTH); + this.setPreferredSize(new Dimension(200, 150)); + panel.setBackground(Color.WHITE); + this.setBackground(Color.WHITE); + content.refresh(this.previewObject); + + } + + private void addEditButton(JPanel panel) { + UIButton editButton = new UIButton(BaseUtils.readIcon("/com/fr/design/icon/icon_edit.png")); + editButton.setPreferredSize(new Dimension(24, 24)); + editButton.setBorderPainted(false); + editButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + PredefinedStyleEditPane editPane = PredefinedStyleEditPane.createEditPane(parentPane); + PredefinedStyleEditDialog editDialog = new PredefinedStyleEditDialog( + SwingUtilities.getWindowAncestor(PredefinedStyleBlock.this), editPane, previewObject.isBuiltIn()); + editPane.populate(PredefinedStyleBlock.this.previewObject); + editDialog.setVisible(true); + } + }); + panel.add(editButton, BorderLayout.EAST); + + } + + public PredefinedStyle update() { + return this.previewObject; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java new file mode 100644 index 0000000000..78cb3f8e79 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java @@ -0,0 +1,219 @@ +package com.fr.design.mainframe.predefined.ui; + +import com.fr.config.predefined.PredefinedStyle; +import com.fr.config.predefined.PredefinedStyleConfig; +import com.fr.config.ServerPreferenceConfig; +import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.gui.frpane.UITabbedPane; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.predefined.ui.detail.PredefinedBackgroundSettingPane; +import com.fr.design.mainframe.predefined.ui.detail.CellStyleSettingPane; +import com.fr.design.mainframe.predefined.ui.detail.ComponentStyleSettingPane; +import com.fr.design.mainframe.predefined.ui.preview.PredefinedStylePreviewPane; +import com.fr.log.FineLoggerFactory; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Label; + +/** + * Created by kerry on 2020-08-26 + */ +public class PredefinedStyleEditPane extends AbstractAttrNoScrollPane { + private PredefinedStylePreviewPane previewPane; + private UITextField styleNameField; + private PredefinedBackgroundSettingPane backgroundSettingPane; + private CellStyleSettingPane cellStyleSettingPane; + private ComponentStyleSettingPane componentStyleSettingPane; + private PredefinedStyleSelectPane selectPane; + private boolean isPopulating = false; + + @Override + protected JPanel createContentPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + jPanel.add(createLeftPane(), BorderLayout.WEST); + jPanel.add(createRightPane(), BorderLayout.CENTER); + + this.addAttributeChangeListener(new AttributeChangeListener() { + @Override + public void attributeChange() { + if (!isPopulating) { + valueChangeAction(); + } + } + }); + return jPanel; + } + + public void valueChangeAction() { + previewPane.refresh(this.update()); + } + + @Override + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Style_Edit"); + } + + private PredefinedStyleEditPane(PredefinedStyleSelectPane selectPane, boolean newEditPane) { + this.selectPane = selectPane; + this.styleNameField.setEnabled(newEditPane); + } + + public static PredefinedStyleEditPane createEditPane(PredefinedStyleSelectPane selectPane) { + return new PredefinedStyleEditPane(selectPane, false); + } + + public static PredefinedStyleEditPane createNewEditPane(PredefinedStyleSelectPane selectPane) { + return new PredefinedStyleEditPane(selectPane, true); + } + + + private JPanel createLeftPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel titlePane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Overall_Preview")); + previewPane = new PredefinedStylePreviewPane(); + previewPane.setPreferredSize(new Dimension(517, 320)); + + titlePane.add(previewPane); + jPanel.add(titlePane, BorderLayout.CENTER); + return jPanel; + } + + private JPanel createRightPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel styleNamePane = createStyleNamePane(); + jPanel.add(styleNamePane, BorderLayout.NORTH); + + JPanel basicSettingPane = createBasicSettingPane(); + jPanel.add(basicSettingPane, BorderLayout.CENTER); + + JPanel customDetailPane = createCustomDetailPane(); + jPanel.add(customDetailPane, BorderLayout.SOUTH); + return jPanel; + } + + private JPanel createStyleNamePane() { + JPanel jPanel = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(5, 26, 8); + jPanel.add(new Label(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Style_Name"))); + this.styleNameField = new UITextField(); + this.styleNameField.setPreferredSize(new Dimension(160, 20)); + jPanel.add(this.styleNameField); + return jPanel; + } + + private JPanel createBasicSettingPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel titlePane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Basic_Setting")); + JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + titlePane.add(contentPane); + jPanel.add(titlePane, BorderLayout.CENTER); + titlePane.setSize(new Dimension(348, 157)); + return jPanel; + } + + private JPanel createCustomDetailPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel titlePane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Custom_Detail")); + titlePane.setLayout(FRGUIPaneFactory.createLeftZeroLayout()); + jPanel.add(titlePane, BorderLayout.CENTER); + UITabbedPane uiTabbedPane = new UITabbedPane(); + uiTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Template_Background"), createTemplateBackgroundSettingPane()); + uiTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Cell_Style"), createCellStyleSettingPane()); + uiTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Chart_Style"), createChartStyleSettingPane()); + uiTabbedPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Component_Style"), createComponentStyleSettingPane()); + + titlePane.add(uiTabbedPane); + titlePane.setPreferredSize(new Dimension(333, 320)); + return jPanel; + } + + + private JPanel createTemplateBackgroundSettingPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + jPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5)); + this.backgroundSettingPane = new PredefinedBackgroundSettingPane(); + this.backgroundSettingPane.setPreferredSize(new Dimension(313, 265)); + jPanel.add(new UIScrollPane(this.backgroundSettingPane)); + return jPanel; + } + + private JPanel createCellStyleSettingPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + jPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); + this.cellStyleSettingPane = new CellStyleSettingPane(this); + jPanel.add(this.cellStyleSettingPane); + return jPanel; + } + + + private JPanel createChartStyleSettingPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + jPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5)); + jPanel.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Chart_Style"))); + return jPanel; + } + + + private JPanel createComponentStyleSettingPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + jPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5)); + this.componentStyleSettingPane = new ComponentStyleSettingPane(); + jPanel.add(this.componentStyleSettingPane); + return jPanel; + } + + + public void populate(PredefinedStyle previewObject) { + isPopulating = true; + styleNameField.setText(previewObject.getStyleName()); + this.backgroundSettingPane.populateBean(previewObject.getPredefinedBackground()); + this.cellStyleSettingPane.populateBean(previewObject.getCellStyleMap()); + this.componentStyleSettingPane.populateBean(previewObject.getComponentStyle()); + isPopulating = false; + } + + public PredefinedStyle update() { + PredefinedStyle predefinedStyle = new PredefinedStyle(); + predefinedStyle.setStyleName(this.styleNameField.getText()); + predefinedStyle.setCellStyleMap(this.cellStyleSettingPane.updateBean()); + predefinedStyle.setPredefinedBackground(this.backgroundSettingPane.updateBean()); + predefinedStyle.setComponentStyle(this.componentStyleSettingPane.updateBean()); + return predefinedStyle; + } + + public void saveStyle() { + PredefinedStyle previewObject = null; + try { + previewObject = update(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + saveStyle(previewObject); + } + + public void saveStyle(PredefinedStyle previewObject) { + PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig(); + config.put(previewObject.getStyleName(), previewObject); + ServerPreferenceConfig.getInstance().setPreferenceStyleConfig(config); + selectPane.refreshPane(); + } + + public void saveAsNewStyle(String styleName) { + PredefinedStyle previewObject = null; + try { + previewObject = update(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + previewObject.setStyleName(styleName); + saveStyle(previewObject); + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSelectPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSelectPane.java new file mode 100644 index 0000000000..26b92907a9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSelectPane.java @@ -0,0 +1,102 @@ +package com.fr.design.mainframe.predefined.ui; + +import com.fr.config.predefined.PredefinedStyle; +import com.fr.config.ServerPreferenceConfig; +import com.fr.design.dialog.BasicPane; +import com.fr.design.event.ChangeListener; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.layout.FRGUIPaneFactory; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.util.Iterator; + +/** + * Created by kerry on 2020-08-26 + */ +public class PredefinedStyleSelectPane extends BasicPane { + private PredefinedStyleBlock selectedBlock; + private boolean editable; + private JPanel contentPane; + private String currentApplicateStyle; + private ChangeListener changeListener; + + + public PredefinedStyleSelectPane(String currentApplicateStyle, boolean editable) { + this.editable = editable; + this.currentApplicateStyle = currentApplicateStyle; + initPane(); + } + + public void registerChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + + } + + + private void initPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + contentPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(5, 8); + createContentPane(); + UIScrollPane scrollPane = new UIScrollPane(contentPane); + scrollPane.setPreferredSize(new Dimension(630, 480)); + scrollPane.setBorder(BorderFactory.createEmptyBorder()); + this.add(scrollPane, BorderLayout.CENTER); + } + + + public void createContentPane() { + contentPane.removeAll(); + Iterator iterator = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig().getPredefinedStyleIterator(); + int rowCount = (ServerPreferenceConfig.getInstance().getPreferenceStyleConfig().getPredefinedSize() +2)/ 3; + contentPane.setPreferredSize(new Dimension(618, 157 * rowCount)); + while (iterator.hasNext()) { + PredefinedStyle tmpStyle = iterator.next(); + + if (tmpStyle != null) { + PredefinedStyleBlock tmpPanel = + new PredefinedStyleBlock(tmpStyle, this, this.editable); + contentPane.add(tmpPanel); + } + } + } + + + public String getCurrentApplicateStyle() { + return currentApplicateStyle; + } + + public void refreshPane() { + createContentPane(); + this.validate(); + this.repaint(); + } + + @Override + protected String title4PopupWindow() { + return null; + } + + public void setSelectedPreviewPane(PredefinedStyleBlock selectedPreviewPane) { + this.selectedBlock = selectedPreviewPane; + if (changeListener != null) { + changeListener.fireChanged(null); + } + this.repaint(); + } + + public PredefinedStyleBlock getSelectedPreviewPane() { + return selectedBlock; + } + + public PredefinedStyle update() { + if (this.selectedBlock == null){ + return null; + } + return this.selectedBlock.update(); + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSettingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSettingPane.java new file mode 100644 index 0000000000..758f8e0131 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSettingPane.java @@ -0,0 +1,152 @@ +package com.fr.design.mainframe.predefined.ui; + +import com.fr.config.predefined.PredefinedNameStyleProvider; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.predefined.ui.preview.StyleSettingPreviewPane; + +import javax.swing.ButtonGroup; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * Created by kerry on 2020-09-02 + */ +public abstract class PredefinedStyleSettingPane extends AbstractAttrNoScrollPane { + protected StyleSettingPreviewPane previewPane; + protected UIRadioButton predefinedRadioBtn; + private UIRadioButton customRadioBtn; + private JPanel customDetailPane; + private JPanel predefinedSettingPane; + private CardLayout tabbedPane; + private JPanel center; + private boolean isPopulating = false; + + + public void setPopulating(boolean populating) { + isPopulating = populating; + } + + protected void initContentPane() { + leftContentPane = createContentPane(); + this.add(leftContentPane, BorderLayout.CENTER); + } + + @Override + protected JPanel createContentPane() { + JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + previewPane = createPreviewPane(); + JPanel previewTitlePane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview")); + if (previewPane != null) { + previewTitlePane.setPreferredSize(new Dimension(407, 527)); + previewTitlePane.add(previewPane); + contentPane.add(previewTitlePane, BorderLayout.WEST); + } + + customDetailPane = createCustomDetailPane(); + predefinedSettingPane = createPredefinedSettingPane(); + + JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel jPanel = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(10, 20, 10); + jPanel.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style"))); + predefinedRadioBtn = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Predefined")); + customRadioBtn = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom")); + + tabbedPane = new CardLayout(); + center = new JPanel(tabbedPane); + center.add(predefinedSettingPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Predefined")); + center.add(customDetailPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom")); + predefinedRadioBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + tabbedPane.show(center, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Predefined")); + } + }); + customRadioBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + tabbedPane.show(center, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom")); + } + }); + jPanel.add(predefinedRadioBtn); + jPanel.add(customRadioBtn); + + ButtonGroup layoutBG = new ButtonGroup(); + layoutBG.add(predefinedRadioBtn); + layoutBG.add(customRadioBtn); + centerPane.add(jPanel, BorderLayout.NORTH); + centerPane.add(center, BorderLayout.CENTER); + contentPane.add(centerPane, BorderLayout.CENTER); + this.addAttributeChangeListener(new AttributeChangeListener() { + @Override + public void attributeChange() { + if (isPopulating) { + return; + } + if (previewPane != null) { + previewPane.refresh(); + } + } + }); + return contentPane; + } + + + protected abstract StyleSettingPreviewPane createPreviewPane(); + + protected abstract JPanel createCustomDetailPane(); + + protected JPanel createPredefinedSettingPane() { + return new JPanel(); + } + + protected void populate(PredefinedNameStyleProvider nameStyle) { + this.predefinedRadioBtn.setSelected(nameStyle.usePredefinedStyle()); + this.customRadioBtn.setSelected(!nameStyle.usePredefinedStyle()); + if (nameStyle.usePredefinedStyle()) { + tabbedPane.show(center, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Predefined")); + } else { + tabbedPane.show(center, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom")); + } + + } + + protected String getPredefinedStyleName() { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + return template.getTemplatePredefinedStyle(); + } + + /** + * 展示数据 + * + * @param ob 待展示的对象 + */ + public abstract void populateBean(T ob); + + /** + * 保存数据 + * + * @return 待保存的对象 + */ + public abstract T updateBean(); + + /** + * 保存数据 + * + * @param ob 待保存的对象 + */ + public void updateBean(T ob) { + + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ReportPredefinedStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ReportPredefinedStylePane.java new file mode 100644 index 0000000000..4f2c8b6035 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ReportPredefinedStylePane.java @@ -0,0 +1,53 @@ +package com.fr.design.mainframe.predefined.ui; + +import com.fr.config.predefined.PredefinedStyle; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.JTemplate; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.FlowLayout; + +/** + * Created by kerry on 2020-08-28 + */ +public class ReportPredefinedStylePane extends BasicPane { + private PredefinedStyleSelectPane selectPane; + private JTemplate currentTemplate; + private UIButton preferenceBtn; + + public ReportPredefinedStylePane(JTemplate jTemplate, UIButton preferenceButton) { + this.currentTemplate = jTemplate; + this.preferenceBtn = preferenceButton; + initPane(); + } + + private void initPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel jPanel = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Style_Select")); + jPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + JPanel subPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.selectPane = new PredefinedStyleSelectPane(currentTemplate.getTemplatePredefinedStyle(), false); + subPanel.add(this.selectPane, BorderLayout.CENTER); + jPanel.add(subPanel, BorderLayout.CENTER); + this.add(jPanel, BorderLayout.CENTER); + } + + public void update() { + PredefinedStyle style = selectPane.update(); + if (style != null) { + currentTemplate.resetPredefinedStyle(style.getStyleName(), preferenceBtn); + } + } + + public void refresh() { + this.selectPane.refreshPane(); + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Template_Style"); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ServerPredefinedStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ServerPredefinedStylePane.java new file mode 100644 index 0000000000..a8f37ace35 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ServerPredefinedStylePane.java @@ -0,0 +1,201 @@ +package com.fr.design.mainframe.predefined.ui; + + +import com.fr.base.BaseUtils; +import com.fr.config.predefined.PredefinedStyle; +import com.fr.config.predefined.PredefinedStyleConfig; +import com.fr.config.ServerPreferenceConfig; +import com.fr.design.actions.UpdateAction; +import com.fr.design.event.ChangeEvent; +import com.fr.design.event.ChangeListener; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.mainframe.predefined.PatternStyle; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.i18n.Toolkit; +import com.fr.design.icon.IconPathConstants; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.predefined.ui.dialog.PredefinedStyleEditDialog; +import com.fr.design.menu.MenuDef; +import com.fr.design.menu.ToolBarDef; + +import javax.swing.BorderFactory; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JSeparator; +import javax.swing.SwingUtilities; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +/** + * Created by kerry on 2020-08-25 + */ +public class ServerPredefinedStylePane extends BasicPane { + + private static final Color TIP_COLOR = Color.decode("#8F8F92"); + private RemoveAction removeAction; + + private PredefinedStyleSelectPane selectPane; + + + public ServerPredefinedStylePane() { + initPane(); + } + + private void initPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel jPanel = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Style_Manager")); + jPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + jPanel.setLayout(FRGUIPaneFactory.createLeftZeroLayout()); + JPanel subPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + subPanel.add(createControlPane(), BorderLayout.NORTH); + PredefinedStyle style = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig().getDefaultPredefinedStyle(); + this.selectPane = new PredefinedStyleSelectPane(style.getStyleName(), true); + this.selectPane.registerChangeListener(new ChangeListener() { + @Override + public void fireChanged(ChangeEvent event) { + PredefinedStyle selectStyle = selectPane.getSelectedPreviewPane().update(); + removeAction.setEnabled(!selectStyle.isBuiltIn()); + } + }); + this.selectPane.addMouseListener(new MouseListener() { + @Override + public void mouseClicked(MouseEvent e) { + if (selectPane.getSelectedPreviewPane() != null) { + removeAction.setEnabled(true); + } + } + + @Override + public void mousePressed(MouseEvent e) { + + } + + @Override + public void mouseReleased(MouseEvent e) { + + } + + @Override + public void mouseEntered(MouseEvent e) { + + } + + @Override + public void mouseExited(MouseEvent e) { + + } + }); + JSeparator jSeparator = new JSeparator(); + subPanel.add(jSeparator, BorderLayout.CENTER); + subPanel.add(this.selectPane, BorderLayout.SOUTH); + jPanel.add(subPanel); + this.add(jPanel, BorderLayout.CENTER); + this.repaint(); + } + + + private JPanel createControlPane() { + MenuDef addMenuDef = new MenuDef(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Action_Add")); + addMenuDef.setIconPath(IconPathConstants.ADD_POPMENU_ICON_PATH); + createAddMenuDef(addMenuDef); + ToolBarDef toolbarDef = new ToolBarDef(); + removeAction = new RemoveAction(); + removeAction.setEnabled(false); + toolbarDef.addShortCut(addMenuDef, removeAction); + UIToolbar toolBar = ToolBarDef.createJToolBar(); + toolBar.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); + toolbarDef.updateToolBar(toolBar); + JPanel toolbarPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + toolbarPane.add(toolBar, BorderLayout.CENTER); + UILabel tipLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Style_Manager_Tip")); + tipLabel.setForeground(TIP_COLOR); + tipLabel.setHorizontalTextPosition(UILabel.RIGHT); + toolbarPane.add(tipLabel, BorderLayout.EAST); + toolbarPane.setPreferredSize(new Dimension(620, 30)); + return toolbarPane; + } + + private void createAddMenuDef(MenuDef addMenuDef) { + addMenuDef.setRePaint(true); + addMenuDef.addShortCut(new CreateStyleAction(PatternStyle.DARK_STYLE)); + addMenuDef.addShortCut(new CreateStyleAction(PatternStyle.LIGHT_STYLE)); + + } + + + public void update() { + PredefinedStyle style = selectPane.update(); + if (style != null) { + PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig(); + config.setDefaultPredefinedStyle(style.getStyleName()); + ServerPreferenceConfig.getInstance().setPreferenceStyleConfig(config); + } + + } + + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Server_Style"); + } + + private class RemoveAction extends UpdateAction { + + public RemoveAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove")); + this.setMnemonic('R'); + this.setSmallIcon(BaseUtils.readIcon(IconPathConstants.TD_REMOVE_ICON_PATH)); + } + + @Override + public void actionPerformed(ActionEvent e) { + PredefinedStyle previewObject = ServerPredefinedStylePane.this.selectPane.update(); + int selVal = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(ServerPredefinedStylePane.this), + Toolkit.i18nText("Fine-Design_Predefined_Remove_Style_Confirm:" + previewObject.getStyleName()) + " ?", + Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + if (selVal == JOptionPane.YES_OPTION) { + removeStyle(previewObject.getStyleName()); + ServerPredefinedStylePane.this.selectPane.refreshPane(); + } + } + } + + + private class CreateStyleAction extends UpdateAction { + private PatternStyle style; + + public CreateStyleAction(PatternStyle style) { + this.style = style; + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Create_Parttern_Style") + style.getName()); + this.setMnemonic('R'); + } + + @Override + public void actionPerformed(ActionEvent e) { + createNewPatternStylePane(); + } + + private void createNewPatternStylePane() { + PredefinedStyleEditPane editPane = PredefinedStyleEditPane.createNewEditPane(selectPane); + PredefinedStyleEditDialog editDialog = new PredefinedStyleEditDialog( + SwingUtilities.getWindowAncestor(ServerPredefinedStylePane.this), editPane); + editPane.populate(style.getPredefinedStyle()); + editDialog.setVisible(true); + } + } + + + private void removeStyle(String name) { + PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig(); + config.removeStyle(name); + ServerPreferenceConfig.getInstance().setPreferenceStyleConfig(config); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleSettingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleSettingPane.java new file mode 100644 index 0000000000..c25390513c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleSettingPane.java @@ -0,0 +1,234 @@ +package com.fr.design.mainframe.predefined.ui.detail; + +import com.fr.base.BaseUtils; +import com.fr.base.Style; +import com.fr.config.StyleMap; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.AttrScrollPane; +import com.fr.design.dialog.BasicScrollPane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.icon.IconPathConstants; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.predefined.ui.PredefinedStyleEditPane; +import com.fr.design.mainframe.predefined.ui.detail.cell.CustomPredefinedStylePane; +import com.fr.report.cell.DefaultTemplateCellElement; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.core.PaintUtils; +import com.fr.stable.Constants; + +import javax.swing.DefaultListModel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * Created by kerry on 2020-09-01 + */ +public class CellStyleSettingPane extends BasicBeanPane { + + private StyleListPane styleListPane; + private List customStylePaneList = new ArrayList<>(); + private CardLayout cardLayout; + private JPanel centerPane; + private PredefinedStyleEditPane editPane; + private CellStylePreviewPane previewPane; + + public CellStyleSettingPane(PredefinedStyleEditPane editPane) { + this.editPane = editPane; + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.add(createLeftPane(), BorderLayout.WEST); + this.add(createCenterPane(), BorderLayout.CENTER); + } + + private JPanel createLeftPane() { + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + panel.setPreferredSize(new Dimension(80, 267)); + panel.add(createToolPane(), BorderLayout.NORTH); + panel.add(createStyleListPane(), BorderLayout.CENTER); + return panel; + } + + private JPanel createToolPane() { + JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + UIButton addBtn = new UIButton(BaseUtils.readIcon(IconPathConstants.ADD_POPMENU_ICON_PATH)); + addBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + styleListPane.addNewStyle(); + } + }); + addBtn.setBorderPainted(false); + panel.add(addBtn); + UIButton removeBtn = new UIButton(BaseUtils.readIcon(IconPathConstants.TD_REMOVE_ICON_PATH)); + removeBtn.setBorderPainted(false); + removeBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + styleListPane.removeStyle(); + } + }); + panel.add(removeBtn); + return panel; + } + + private JPanel createStyleListPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + jPanel.setPreferredSize(new Dimension(80, 249)); + styleListPane = new StyleListPane(); + jPanel.add(styleListPane); + return jPanel; + } + + private JPanel createCenterPane() { + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + panel.setPreferredSize(new Dimension(230, 267)); + JPanel titlePreviewPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview")); + titlePreviewPane.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); + previewPane = new CellStylePreviewPane(); + previewPane.setPreferredSize(new Dimension(100, 20)); + titlePreviewPane.setPreferredSize(new Dimension(230, 45)); + titlePreviewPane.add(previewPane); + panel.add(titlePreviewPane, BorderLayout.NORTH); + cardLayout = new CardLayout(); + centerPane = new JPanel(cardLayout); + centerPane.setPreferredSize(new Dimension(226, 500)); + BasicScrollPane basicScrollPane = new AttrScrollPane() { + @Override + protected JPanel createContentPane() { + return centerPane; + } + }; + basicScrollPane.setPreferredSize(new Dimension(230, 214)); + panel.add(basicScrollPane, BorderLayout.CENTER); + + return panel; + } + + + @Override + public void populateBean(StyleMap ob) { + styleListPane.populate(ob); + } + + @Override + public StyleMap updateBean() { + return styleListPane.update(); + } + + @Override + protected String title4PopupWindow() { + return null; + } + + class StyleListPane extends JPanel { + private DefaultListModel defaultListModel; + private JList styleList; + + public StyleListPane() { + defaultListModel = new DefaultListModel(); + styleList = new JList(defaultListModel); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.add(styleList, BorderLayout.CENTER); + + styleList.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + int selectIndex = styleList.getSelectedIndex(); + cardLayout.show(centerPane, defaultListModel.get(selectIndex).toString()); + } + }); + } + + public void populate(StyleMap ob) { + Iterator> iterator = ob.getAllStyles().entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + addStyle(entry.getKey(), entry.getValue()); + + } + reset(); + } + + private void reset() { + if (defaultListModel.getSize() > 0) { + styleList.setSelectedIndex(0); + cardLayout.show(centerPane, defaultListModel.get(0).toString()); + centerPane.validate(); + + } + } + + public StyleMap update() { + StyleMap styleMap = new StyleMap(); + for (int i = 0; i < defaultListModel.getSize(); i++) { + String name = defaultListModel.get(i).toString(); + Style style = customStylePaneList.get(i).updateBean(); + styleMap.put(name, style); + } + return styleMap; + } + + public void addNewStyle() { + addStyle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Cell_New_Style"), Style.getInstance()); + } + + public void addStyle(String name, Style style) { + defaultListModel.addElement(name); + CustomPredefinedStylePane customPredefinedStylePane = new CustomPredefinedStylePane(); + customPredefinedStylePane.populateBean(style); + customPredefinedStylePane.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + previewPane.refresh(customPredefinedStylePane.updateBean()); + editPane.valueChangeAction(); + } + }); + centerPane.add(customPredefinedStylePane, name); + customStylePaneList.add(customPredefinedStylePane); + } + + public void removeStyle() { + int selectIndex = styleList.getSelectedIndex(); + defaultListModel.remove(selectIndex); + centerPane.remove(customStylePaneList.get(selectIndex)); + customStylePaneList.remove(selectIndex); + reset(); + } + } + + class CellStylePreviewPane extends JPanel { + private TemplateCellElement ce; + + public CellStylePreviewPane() { + ce = new DefaultTemplateCellElement(); + ce.setValue(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Cell_Test_Word")); + } + + public void refresh(Style style) { + this.ce.setStyle(style); + this.repaint(); + } + + @Override + public void paint(Graphics g) { + Style.paintBackground((Graphics2D) g, ce.getStyle(), this.getWidth(), this.getHeight()); + Style.paintBorder((Graphics2D) g, ce.getStyle(), this.getWidth(), this.getHeight()); + PaintUtils.paintGridCellContent((Graphics2D) g, ce, this.getWidth(), this.getHeight(), Constants.FR_PAINT_RESOLUTION); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ComponentStyleSettingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ComponentStyleSettingPane.java new file mode 100644 index 0000000000..5a7ea8502d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ComponentStyleSettingPane.java @@ -0,0 +1,69 @@ +package com.fr.design.mainframe.predefined.ui.detail; + +import com.fr.config.predefined.PredefinedComponentStyle; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.MultiTabPane; +import com.fr.design.mainframe.predefined.ui.detail.component.ComponentFrameStylePane; +import com.fr.design.mainframe.predefined.ui.detail.component.ComponentMarginStylePane; +import com.fr.design.mainframe.predefined.ui.detail.component.ComponentTitleStylePane; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by kerry on 2020-09-01 + */ +public class ComponentStyleSettingPane extends MultiTabPane { + private ComponentFrameStylePane frameStylePane; + private ComponentTitleStylePane titleStylePane; + private ComponentMarginStylePane marginStylePane; + + public ComponentStyleSettingPane() { + } + + + @Override + protected List initPaneList() { + this.frameStylePane = new ComponentFrameStylePane(); + this.titleStylePane = ComponentTitleStylePane.createPredefinedSettingPane(); + this.marginStylePane = new ComponentMarginStylePane(); + paneList = new ArrayList(); + paneList.add(this.frameStylePane); + paneList.add(this.titleStylePane); + paneList.add(this.marginStylePane); + return paneList; + } + + @Override + public void populateBean(PredefinedComponentStyle ob) { + this.frameStylePane.populate(ob); + this.titleStylePane.populate(ob); + this.marginStylePane.populate(ob); + } + + @Override + public void updateBean(PredefinedComponentStyle ob) { + + } + + + @Override + public PredefinedComponentStyle updateBean() { + PredefinedComponentStyle componentStyle = new PredefinedComponentStyle(); + this.frameStylePane.update(componentStyle); + this.titleStylePane.update(componentStyle); + this.marginStylePane.update(componentStyle); + return componentStyle; + } + + + @Override + public boolean accept(Object ob) { + return false; + } + + @Override + public void reset() { + + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/PredefinedBackgroundSettingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/PredefinedBackgroundSettingPane.java new file mode 100644 index 0000000000..c49f09a5e6 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/PredefinedBackgroundSettingPane.java @@ -0,0 +1,84 @@ +package com.fr.design.mainframe.predefined.ui.detail; + +import com.fr.config.predefined.PredefinedBackground; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.predefined.ui.detail.background.BackgroundSettingPane; +import com.fr.design.mainframe.predefined.ui.detail.background.BackgroundWithAlphaSettingPane; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * Created by kerry on 2020-08-31 + */ +public class PredefinedBackgroundSettingPane extends BasicBeanPane { + private UIButtonGroup buttonGroup; + private BackgroundSettingPane reportBackgroundSettingPane; + private BackgroundWithAlphaSettingPane formBackgroundSettingPane; + + + public PredefinedBackgroundSettingPane() { + initPane(); + } + + private void initPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + reportBackgroundSettingPane = new BackgroundSettingPane(); + UIScrollPane scrollPane = new UIScrollPane(reportBackgroundSettingPane); + scrollPane.setBorder(BorderFactory.createEmptyBorder()); + formBackgroundSettingPane = new BackgroundWithAlphaSettingPane(); + CardLayout tabbedPane = new CardLayout(); + JPanel center = new JPanel(tabbedPane); + center.add(scrollPane, "普通报表"); + center.add(formBackgroundSettingPane, "决策报表"); + center.setPreferredSize(new Dimension(243, 243)); + this.buttonGroup = new UIButtonGroup(new String[]{"普通报表", "决策报表"}); + buttonGroup.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (buttonGroup.getSelectedIndex() == 0) { + tabbedPane.show(center, "普通报表"); + } else { + tabbedPane.show(center, "决策报表"); + } + } + }); + + + this.add(buttonGroup, BorderLayout.NORTH); + + this.add(center, BorderLayout.CENTER); + this.buttonGroup.setSelectedIndex(0); + } + + @Override + public void populateBean(PredefinedBackground predefinedBackground) { + reportBackgroundSettingPane.populateBean(predefinedBackground.getReportBackground()); + formBackgroundSettingPane.populateBean(predefinedBackground.getFormBackground()); + } + + @Override + public PredefinedBackground updateBean() { + PredefinedBackground predefinedBackground = new PredefinedBackground(); + predefinedBackground.setReportBackground(reportBackgroundSettingPane.updateBean()); + predefinedBackground.setFormBackground(formBackgroundSettingPane.updateBean()); + return predefinedBackground; + } + + @Override + protected String title4PopupWindow() { + return "预定义背景设置"; + } + + + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundSettingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundSettingPane.java new file mode 100644 index 0000000000..2a8ee64e6c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundSettingPane.java @@ -0,0 +1,167 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.background.BackgroundDetailPane; +import com.fr.general.Background; +import com.fr.log.FineLoggerFactory; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by kerry on 2020-09-02 + */ +public class BackgroundSettingPane extends BasicBeanPane { + private ChangeListener changeListener = null; + private UIComboBox headCombobox; + private List paneList = new ArrayList<>(); + + public BackgroundSettingPane() { + init(); + } + + private void init() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.add(createComboHeadPane(), BorderLayout.NORTH); + CardLayout tabbedPane = new CardLayout(); + JPanel center = createCenterPane(tabbedPane); + center.setPreferredSize(BackgroundType.EMPTY_BACKGROUND.getDisplayDimension()); + headCombobox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + BackgroundType type = BackgroundType.parse(e.getItem().toString()); + center.setPreferredSize(type.getDisplayDimension()); + tabbedPane.show(center, type.getDisplayName()); + } + }); + this.add(center, BorderLayout.CENTER); + } + + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + + private JPanel createComboHeadPane() { + headCombobox = new UIComboBox(BackgroundType.allTypes()); + headCombobox.setPreferredSize(new Dimension(160, 20)); + JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{new UILabel("填充"), headCombobox}}, TableLayoutHelper.FILL_LASTCOLUMN, 33, 5); + jPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); + return jPanel; + } + + private JPanel createCenterPane(CardLayout tabbedPane) { + JPanel centerPane = new JPanel(tabbedPane); + centerPane.add(createEmptyPane(), BackgroundType.EMPTY_BACKGROUND.getDisplayName()); + centerPane.add(createColorSelectPane(), BackgroundType.COLOR_BACKGROUND.getDisplayName()); + centerPane.add(createTextureSelectPane(), BackgroundType.TEXTURE_BACKGROUND.getDisplayName()); + centerPane.add(createPatternSelectPane(), BackgroundType.PATTERN_BACKGROUND.getDisplayName()); + centerPane.add(createImageSelectPane(), BackgroundType.IMAGE_BACKGROUND.getDisplayName()); + centerPane.add(createGradientSelectPane(), BackgroundType.GRADIENT_BACKGROUND.getDisplayName()); + return centerPane; + } + + private JPanel createEmptyPane() { + EmptyBackgroundPane emptyBackgroundPane = new EmptyBackgroundPane(); + paneList.add(emptyBackgroundPane); + return emptyBackgroundPane; + } + + + private JPanel createColorSelectPane() { + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + ColorDetailPane colorDetailPane = new ColorDetailPane(); + paneList.add(colorDetailPane); + jPanel.add(colorDetailPane, BorderLayout.CENTER); + return jPanel; + } + + private JPanel createTextureSelectPane() { + + + TextureDetailObservePane textureDetailPane = new TextureDetailObservePane(); + textureDetailPane.setPreferredSize(new Dimension(160, 108)); + UILabel label = new UILabel("纹理"); + label.setPreferredSize(new Dimension(24, 108)); + label.setVerticalAlignment(SwingConstants.TOP); + JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{label, textureDetailPane}}, TableLayoutHelper.FILL_LASTCOLUMN, 33, 5); + jPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); + + paneList.add(textureDetailPane); + return jPanel; + } + + private JPanel createPatternSelectPane() { + JPanel jPanel = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(10, 0, 0); + PatternDetailPane patternDetailPane = PatternDetailPane.createPatternDetailPane(6); + jPanel.add(patternDetailPane, BorderLayout.CENTER); + paneList.add(patternDetailPane); + return jPanel; + } + + private JPanel createImageSelectPane() { + JPanel jPanel = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(10, 0, 0); + ImageDetailPane imageDetailPane = new ImageDetailPane(); + imageDetailPane.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (changeListener != null) { + changeListener.stateChanged(e); + } + } + }); + jPanel.add(imageDetailPane); + paneList.add(imageDetailPane); + return jPanel; + } + + private JPanel createGradientSelectPane() { + JPanel jPanel = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(10, 0, 0); + GradientDetailPane gradientDetailPane = new GradientDetailPane(); + jPanel.add(gradientDetailPane); + paneList.add(gradientDetailPane); + return jPanel; + } + + + @Override + public void populateBean(Background background) { + String displayType = BackgroundType.parse(background).getDisplayName(); + this.headCombobox.setSelectedItem(displayType); + int index = this.headCombobox.getSelectedIndex(); + paneList.get(index).populate(background); + } + + @Override + public Background updateBean() { + int selectIndex = this.headCombobox.getSelectedIndex(); + try { + return paneList.get(selectIndex).update(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return null; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundType.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundType.java new file mode 100644 index 0000000000..0efa9eb09c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundType.java @@ -0,0 +1,99 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.general.Background; +import com.fr.general.ComparatorUtils; +import com.fr.stable.StringUtils; + +import java.awt.Dimension; + +/** + * Created by kerry on 2020-08-31 + */ +public enum BackgroundType { + EMPTY_BACKGROUND("NullBackground", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Background_Is_Null")) { + @Override + public Dimension getDisplayDimension() { + return new Dimension(0, 0); + } + }, + COLOR_BACKGROUND("ColorBackground", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Color")) { + @Override + public Dimension getDisplayDimension() { + return new Dimension(242, 187); + } + }, + TEXTURE_BACKGROUND("TextureBackground", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture")) { + @Override + public Dimension getDisplayDimension() { + return new Dimension(242, 155); + } + }, + PATTERN_BACKGROUND("PatternBackground", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Pattern")) { + @Override + public Dimension getDisplayDimension() { + return new Dimension(242, 266); + } + }, + IMAGE_BACKGROUND("ImageBackground", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Image")) { + @Override + public Dimension getDisplayDimension() { + return new Dimension(242, 160); + } + }, + GRADIENT_BACKGROUND("GradientBackground", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Gradient_Color")) { + @Override + public Dimension getDisplayDimension() { + return new Dimension(242, 155); + } + }; + + private String backgroundType; + + private String displayName; + + + BackgroundType(String backgroundType, String displayName) { + this.backgroundType = backgroundType; + this.displayName = displayName; + } + + + public String getDisplayName() { + return displayName; + } + + public abstract Dimension getDisplayDimension(); + + public static String[] allTypes() { + BackgroundType[] backgroundTypes = values(); + String[] backgrounds = new String[backgroundTypes.length]; + for (int i = 0; i < backgroundTypes.length; i++) { + backgrounds[i] = backgroundTypes[i].getDisplayName(); + } + return backgrounds; + } + + public static BackgroundType parse(Background background) { + if (background == null) { + return EMPTY_BACKGROUND; + } + for (BackgroundType type : values()) { + if (ComparatorUtils.equals(background.getBackgroundType(), type.backgroundType)) { + return type; + } + } + return EMPTY_BACKGROUND; + } + + public static BackgroundType parse(String displayName) { + if (StringUtils.isEmpty(displayName)) { + return EMPTY_BACKGROUND; + } + for (BackgroundType type : values()) { + if (ComparatorUtils.equals(displayName, type.displayName)) { + return type; + } + } + return EMPTY_BACKGROUND; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundWithAlphaSettingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundWithAlphaSettingPane.java new file mode 100644 index 0000000000..6c25113540 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundWithAlphaSettingPane.java @@ -0,0 +1,78 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.config.predefined.BackgroundWithAlpha; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.gui.frpane.UINumberDragPane; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; + +/** + * Created by kerry on 2020-09-04 + */ +public class BackgroundWithAlphaSettingPane extends BasicBeanPane { + private BackgroundSettingPane backgroundSettingPane; + //透明度 + private UINumberDragPane numberDragPane; + + private double maxNumber = 100; + + + public BackgroundWithAlphaSettingPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + backgroundSettingPane = new BackgroundSettingPane(); + + JPanel eastpane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(2, 0); + this.numberDragPane = new UINumberDragPane(0, 100); + this.numberDragPane.setPreferredSize(new Dimension(148, 20)); + eastpane.add(numberDragPane); + eastpane.add(new UILabel("%")); + JPanel transparencyPane = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{new UILabel("不透明度"), eastpane}}, TableLayoutHelper.FILL_LASTCOLUMN,18, 5); + transparencyPane.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); + + + Component[][] components = new Component[][]{ + new Component[]{backgroundSettingPane}, + new Component[]{transparencyPane}}; + + JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W2, IntervalConstants.INTERVAL_L1); + UIScrollPane scrollPane = new UIScrollPane(panel); + scrollPane.setBorder(BorderFactory.createEmptyBorder()); + this.add(scrollPane, BorderLayout.CENTER); + } + + + public void addChangeListener(ChangeListener changeListener) { + this.backgroundSettingPane.addChangeListener(changeListener); + } + + + @Override + public void populateBean(BackgroundWithAlpha ob) { + backgroundSettingPane.populateBean(ob.getBackground()); + numberDragPane.populateBean(ob.getAlpha() * maxNumber); + } + + @Override + public BackgroundWithAlpha updateBean() { + BackgroundWithAlpha backgroundWithAlpha = new BackgroundWithAlpha(); + backgroundWithAlpha.setBackground(backgroundSettingPane.updateBean()); + backgroundWithAlpha.setAlpha((float)(numberDragPane.updateBean()/maxNumber)); + return backgroundWithAlpha; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java new file mode 100644 index 0000000000..9d1fc69240 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java @@ -0,0 +1,102 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.base.background.ColorBackground; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.background.BackgroundDetailPane; +import com.fr.design.style.color.ColorSelectPane; +import com.fr.general.Background; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; + +/** + * Created by kerry on 2020-08-31 + */ +public class ColorDetailPane extends BackgroundDetailPane { + private ColorBackgroundSelectPane selectPane; + + + public ColorDetailPane() { + this.selectPane = new ColorBackgroundSelectPane(); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.add(this.selectPane, BorderLayout.CENTER); + } + + @Override + public void populate(Background background) { + if (background instanceof ColorBackground) { + this.selectPane.setColor(((ColorBackground) background).getColor()); + } + } + + @Override + public Background update() { + return ColorBackground.getInstance(selectPane.getColor()); + } + + @Override + public void addChangeListener(ChangeListener changeListener) { + + } + + + class ColorBackgroundSelectPane extends ColorSelectPane implements UIObserver { + protected UIObserverListener uiObserverListener; + + protected void initialCompents(boolean isSupportTransparent) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder()); + if (isSupportTransparent) { + this.add(createNorthPane(), BorderLayout.NORTH); + } + JPanel centerPane = createCenterPane(); + this.add(centerPane, BorderLayout.CENTER); + this.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (uiObserverListener != null) { + uiObserverListener.doChange(); + } + } + }); + } + + private JPanel createNorthPane() { + UIButton transpanrentBtn = createTranspanrentButton(); + transpanrentBtn.setPreferredSize(new Dimension(160, 20)); + JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{new UILabel("颜色"), transpanrentBtn}}, TableLayoutHelper.FILL_LASTCOLUMN, 33, 5); + jPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); + return jPanel; + } + + protected JPanel createCenterPane() { + JPanel centerPane = super.createCenterPane(); + + JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{new UILabel(" "), centerPane}}, TableLayoutHelper.FILL_LASTCOLUMN, 33, 5); + jPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); + return jPanel; + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.uiObserverListener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/EmptyBackgroundPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/EmptyBackgroundPane.java new file mode 100644 index 0000000000..300a1e6e51 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/EmptyBackgroundPane.java @@ -0,0 +1,27 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.design.style.background.BackgroundDetailPane; +import com.fr.general.Background; + +import javax.swing.event.ChangeListener; + +/** + * Created by kerry on 2020-09-01 + */ +public class EmptyBackgroundPane extends BackgroundDetailPane { + + @Override + public void populate(Background background) { + + } + + @Override + public Background update() { + return null; + } + + @Override + public void addChangeListener(ChangeListener changeListener) { + + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/GradientDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/GradientDetailPane.java new file mode 100644 index 0000000000..1a6b60b74a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/GradientDetailPane.java @@ -0,0 +1,147 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.base.background.GradientBackground; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.background.BackgroundDetailPane; +import com.fr.design.style.background.gradient.GradientBar; +import com.fr.general.Background; +import javax.swing.ButtonGroup; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * 渐变色的面板,不是很pp,面板应用显得繁琐,有写可以写成控件类型,比如色彩选择的。。,可以做得花哨点 + * + * @author ben + */ +public class GradientDetailPane extends BackgroundDetailPane implements UIObserver { + private static final long serialVersionUID = -6854603990673031897L; + private UIObserverListener listener; + private UIRadioButton left2right, top2bottom; + private GradientBar gradientBar; + private ChangeListener changeListener = null; + + public GradientDetailPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel gradientPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel blankJp = new JPanel(); + gradientBar = new GradientBar(4, 141); + blankJp.add(gradientBar); + + gradientPanel.add(gradientBar, BorderLayout.SOUTH); + + JPanel jp = new JPanel(new GridLayout(2, 1, 15, 10)); + + + left2right = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Page_Setup_Horizontal")); + jp.add(left2right); + left2right.setSelected(true); + left2right.addActionListener(reviewListener); + + top2bottom = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Page_Setup_Vertical")); + jp.add(top2bottom); + top2bottom.addActionListener(reviewListener); + + ButtonGroup toggle = new ButtonGroup(); + toggle.add(left2right); + toggle.add(top2bottom); + + Component[][] components = new Component[][]{ + new Component[]{new UILabel("渐变色设置"), gradientPanel}, + new Component[]{new UILabel("渐变方向"), jp} + }; + JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W4, IntervalConstants.INTERVAL_L1); + this.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (listener != null) { + listener.doChange(); + } + } + }); + this.add(contentPane); + } + + + public void populate(Background background) { + if (!(background instanceof GradientBackground)) { + return; + } + GradientBackground bg = (GradientBackground) background; + this.gradientBar.getSelectColorPointBtnP1().setColorInner(bg.getStartColor()); + this.gradientBar.getSelectColorPointBtnP2().setColorInner(bg.getEndColor()); + if (bg.getDirection() == GradientBackground.LEFT2RIGHT) { + left2right.setSelected(true); + } else { + top2bottom.setSelected(true); + } + if (bg.isUseCell()) { + return; + } + double startValue = (double) bg.getBeginPlace(); + double endValue = (double) bg.getFinishPlace(); + gradientBar.setStartValue(startValue); + gradientBar.setEndValue(endValue); + this.gradientBar.repaint(); + } + + public GradientBackground update() { + GradientBackground gb = new GradientBackground( + gradientBar.getSelectColorPointBtnP1().getColorInner(), + gradientBar.getSelectColorPointBtnP2().getColorInner()); + if (left2right.isSelected()) { + gb.setDirection(GradientBackground.LEFT2RIGHT); + } else { + gb.setDirection(GradientBackground.TOP2BOTTOM); + } + if (gradientBar.isOriginalPlace()) { + gb.setUseCell(true); + } else { + gb.setUseCell(false); + gb.setBeginPlace((float) gradientBar.getStartValue()); + gb.setFinishPlace((float) gradientBar.getEndValue()); + } + return gb; + } + + + ActionListener reviewListener = new ActionListener() { + public void actionPerformed(ActionEvent e) { + fireChagneListener(); + } + }; + + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + gradientBar.addChangeListener(changeListener); + } + + public void fireChagneListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.listener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ImageDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ImageDetailPane.java new file mode 100644 index 0000000000..7c6f0458d7 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ImageDetailPane.java @@ -0,0 +1,190 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.base.Style; +import com.fr.base.background.ImageBackground; +import com.fr.base.background.ImageFileBackground; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.gui.frpane.ImgChooseWrapper; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.background.BackgroundDetailPane; +import com.fr.design.style.background.image.ImageFileChooser; +import com.fr.design.style.background.image.ImagePreviewPane; +import com.fr.general.Background; +import com.fr.stable.Constants; + +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * Image background pane. + */ +public class ImageDetailPane extends BackgroundDetailPane { + + protected ImagePreviewPane previewPane = null; + private Style imageStyle = null; + private ChangeListener changeListener = null; + private ImageFileChooser imageFileChooser = null; + + private UIRadioButton defaultRadioButton = null; + private UIRadioButton tiledRadioButton = null; + private UIRadioButton extendRadioButton = null; + private UIRadioButton adjustRadioButton = null; + + + public ImageDetailPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.add(initSelectFilePane(), BorderLayout.CENTER); + imageFileChooser = new ImageFileChooser(); + imageFileChooser.setMultiSelectionEnabled(false); + previewPane = new ImagePreviewPane(); + } + + public JPanel initSelectFilePane() { + JPanel selectFilePane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + selectFilePane.setBorder(BorderFactory.createEmptyBorder()); + UIButton selectPictureButton = new UIButton( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Image_Select")); + selectPictureButton.setMnemonic('S'); + selectPictureButton.addActionListener(selectPictureActionListener); + selectPictureButton.setPreferredSize(new Dimension(160, 20)); + //布局 + defaultRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Layout_Default")); + tiledRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Layout_Image_Titled")); + extendRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Layout_Image_Extend")); + adjustRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Layout_Image_Adjust")); + + defaultRadioButton.addActionListener(layoutActionListener); + tiledRadioButton.addActionListener(layoutActionListener); + extendRadioButton.addActionListener(layoutActionListener); + adjustRadioButton.addActionListener(layoutActionListener); + + JPanel jp = new JPanel(new GridLayout(4, 1, 15, 10)); + for (UIRadioButton button : imageLayoutButtons()) { + jp.add(button); + } + + ButtonGroup layoutBG = new ButtonGroup(); + layoutBG.add(defaultRadioButton); + layoutBG.add(tiledRadioButton); + layoutBG.add(extendRadioButton); + layoutBG.add(adjustRadioButton); + + defaultRadioButton.setSelected(true); + + Component[][] components = new Component[][]{ + new Component[]{new UILabel("图片"), selectPictureButton}, + new Component[]{new UILabel("填充方式"), jp} + }; + JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W4, IntervalConstants.INTERVAL_L1); + selectFilePane.add(centerPane, BorderLayout.CENTER); + return selectFilePane; + } + + protected UIRadioButton[] imageLayoutButtons() { + return new UIRadioButton[]{ + defaultRadioButton, + tiledRadioButton, + extendRadioButton, + adjustRadioButton + }; + } + + /** + * Select picture. + */ + ActionListener selectPictureActionListener = new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + int returnVal = imageFileChooser.showOpenDialog(ImageDetailPane.this); + setImageStyle(); + ImgChooseWrapper.getInstance(previewPane, imageFileChooser, imageStyle, changeListener).dealWithImageFile(returnVal); + } + }; + + protected void setImageStyle() { + if (tiledRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED); + } else if (adjustRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST); + } else if (extendRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_EXTEND); + } else { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER); + } + } + + ActionListener layoutActionListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent evt) { + setImageStyle(); + changeImageStyle(); + } + + private void changeImageStyle() { + previewPane.setImageStyle(ImageDetailPane.this.imageStyle); + previewPane.repaint(); + } + }; + + @Override + public void populate(Background background) { + + if (background instanceof ImageBackground) { + ImageBackground imageBackground = (ImageBackground) background; + + if (imageBackground.getLayout() == Constants.IMAGE_CENTER) { + defaultRadioButton.setSelected(true); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER); + } else if (imageBackground.getLayout() == Constants.IMAGE_EXTEND) { + extendRadioButton.setSelected(true); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_EXTEND); + } else if (imageBackground.getLayout() == Constants.IMAGE_ADJUST) { + adjustRadioButton.setSelected(true); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST); + } else { + tiledRadioButton.setSelected(true); + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED); + } + + } else { + tiledRadioButton.setSelected(true); + } + + fireChagneListener(); + } + + @Override + public Background update() { + ImageBackground imageBackground = new ImageFileBackground(previewPane.getImageWithSuffix()); + setImageStyle(); + imageBackground.setLayout(imageStyle.getImageLayout()); + return imageBackground; + } + + @Override + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + private void fireChagneListener() { + if (this.changeListener != null) { + ChangeEvent evt = new ChangeEvent(this); + this.changeListener.stateChanged(evt); + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/PatternDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/PatternDetailPane.java new file mode 100644 index 0000000000..4b79fd4f40 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/PatternDetailPane.java @@ -0,0 +1,93 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.design.designer.IntervalConstants; +import com.fr.design.dialog.AttrScrollPane; +import com.fr.design.dialog.BasicScrollPane; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.style.background.impl.PatternBackgroundPane; +import com.fr.design.style.color.ColorSelectBox; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.GridLayout; +import java.awt.LayoutManager; + +/** + * Created by kerry on 2020-08-31 + */ +public class PatternDetailPane extends PatternBackgroundPane implements UIObserver { + + private UIObserverListener listener; + + private PatternDetailPane(int nColumn) { + super(nColumn); + } + + public static PatternDetailPane createPatternDetailPane(int nColumn) { + return new PatternDetailPane(nColumn); + } + + protected LayoutManager layoutOfTypePane(int nColumn) { + return new GridLayout(0, nColumn, 2, 2); + } + + protected void initComponents(int nColumn) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder()); + JPanel jPanel = new JPanel(); + jPanel.setLayout(layoutOfTypePane(nColumn)); + setChildrenOfTypePane(jPanel); + + foregroundColorPane = new ColorSelectBox(80); + backgroundColorPane = new ColorSelectBox(80); + foregroundColorPane.setSelectObject(Color.lightGray); + backgroundColorPane.setSelectObject(Color.black); + UILabel label = new UILabel("图案"); + label.setVerticalAlignment(SwingConstants.TOP); + Component[][] components = new Component[][]{ + new Component[]{label, jPanel}, + new Component[]{new UILabel("前景颜色"), foregroundColorPane}, + new Component[]{new UILabel("背景颜色"), backgroundColorPane} + }; + JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W4, IntervalConstants.INTERVAL_L1); + JPanel jPanel1 = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + jPanel1.add(centerPane); + BasicScrollPane basicScrollPane = new AttrScrollPane() { + @Override + protected JPanel createContentPane() { + return jPanel1; + } + }; + jPanel1.setBorder(BorderFactory.createEmptyBorder()); + this.add(basicScrollPane, BorderLayout.NORTH); + this.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (listener != null) { + listener.doChange(); + } + } + }); + } + + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.listener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/TextureDetailObservePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/TextureDetailObservePane.java new file mode 100644 index 0000000000..df2879ee62 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/TextureDetailObservePane.java @@ -0,0 +1,60 @@ +package com.fr.design.mainframe.predefined.ui.detail.background; + +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.style.background.BackgroundDetailPane; +import com.fr.design.style.background.texture.TextureDetailPane; +import com.fr.general.Background; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; + +/** + * Created by kerry on 2020-09-02 + */ +public class TextureDetailObservePane extends BackgroundDetailPane implements UIObserver { + private TextureDetailPane detailPane; + + private UIObserverListener listener; + + public TextureDetailObservePane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + detailPane = TextureDetailPane.createMiniTextureDetailPane(6); + detailPane.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + if (listener != null) { + listener.doChange(); + } + } + }); + this.add(detailPane, BorderLayout.CENTER); + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.listener = listener; + + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + @Override + public void populate(Background background) { + this.detailPane.populate(background); + } + + @Override + public Background update() throws Exception { + return this.detailPane.update(); + } + + @Override + public void addChangeListener(ChangeListener changeListener) { + + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/cell/CustomPredefinedStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/cell/CustomPredefinedStylePane.java new file mode 100644 index 0000000000..4e1ea31243 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/cell/CustomPredefinedStylePane.java @@ -0,0 +1,129 @@ +package com.fr.design.mainframe.predefined.ui.detail.cell; + +import com.fr.base.Style; +import com.fr.design.constants.UIConstants; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.MultiTabPane; +import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.gui.style.AbstractBasicStylePane; +import com.fr.design.gui.style.AlignmentPane; +import com.fr.design.gui.style.BorderPane; +import com.fr.design.gui.style.FormatPane; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.util.ArrayList; +import java.util.List; + + +/** + * 哎,复杂的原型图导致复杂的画法。非我所愿也 + * + * @author zhou + * @since 2012-5-24上午10:36:10 + */ +public class CustomPredefinedStylePane extends MultiTabPane