Browse Source

Pull request #2279: REPORT-35149 预定义样式优化及与图表统一

Merge in DESIGN/design from ~KERRY/design_10.0:feature/10.0 to feature/10.0

* commit '46748da53f4db4a3f0a4cf71a73197559ba3e6b9':
  代码修改
  代码修改
  代码修改
  REPORT-35149 预定义样式优化及与图表统一
research/11.0
kerry 4 years ago
parent
commit
95340afe15
  1. 2
      designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java
  2. 4
      designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java
  3. 46
      designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java
  4. 52
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  5. 40
      designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java
  6. 56
      designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractTemplateInfoCollector.java
  7. 5
      designer-base/src/main/java/com/fr/design/mainframe/burying/point/BasePointCollector.java
  8. 4
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java
  9. 36
      designer-base/src/main/java/com/fr/design/mainframe/predefined/PatternStyle.java
  10. 118
      designer-base/src/main/java/com/fr/design/mainframe/predefined/info/PredefinedStyleInfoCollector.java
  11. 141
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleBlock.java
  12. 229
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java
  13. 102
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSelectPane.java
  14. 152
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSettingPane.java
  15. 53
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ReportPredefinedStylePane.java
  16. 201
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/ServerPredefinedStylePane.java
  17. 320
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleSettingPane.java
  18. 69
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ComponentStyleSettingPane.java
  19. 88
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/PredefinedBackgroundSettingPane.java
  20. 167
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundSettingPane.java
  21. 99
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundType.java
  22. 78
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/BackgroundWithAlphaSettingPane.java
  23. 102
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java
  24. 27
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/EmptyBackgroundPane.java
  25. 147
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/GradientDetailPane.java
  26. 190
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ImageDetailPane.java
  27. 93
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/PatternDetailPane.java
  28. 60
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/TextureDetailObservePane.java
  29. 129
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/cell/CustomPredefinedStylePane.java
  30. 147
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentFrameStylePane.java
  31. 93
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentMarginStylePane.java
  32. 15
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentStylePane.java
  33. 252
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentTitleStylePane.java
  34. 190
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/PredefinedStyleEditDialog.java
  35. 93
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/ReportPredefinedStyleDialog.java
  36. 69
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/ServerPredefinedStyleDialog.java
  37. 146
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ComponentPreviewPane.java
  38. 98
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ElementCasePreview.java
  39. 80
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/PredefinedStylePreviewPane.java
  40. 17
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/StyleSettingPreviewPane.java
  41. 2
      designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java
  42. 4
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java
  43. 2
      designer-base/src/main/java/com/fr/design/style/background/impl/BPane.java
  44. 192
      designer-base/src/main/java/com/fr/design/style/background/impl/TextureBackgroundPane.java
  45. 208
      designer-base/src/main/java/com/fr/design/style/background/texture/TextureDetailPane.java
  46. 29
      designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java
  47. BIN
      designer-base/src/main/resources/com/fr/design/icon/icon_edit.png
  48. BIN
      designer-base/src/main/resources/com/fr/design/icon/icon_predefined_style.png
  49. 11
      designer-base/src/main/resources/com/fr/design/mainframe/predefined/previewData
  50. 97
      designer-base/src/test/java/com/fr/design/mainframe/predefined/info/PredefinedStyleInfoCollectorTest.java
  51. 2
      designer-base/src/test/resources/com/fr/design/mainframe/predefined/info/predefinedStyle.info
  52. 101
      designer-form/src/main/java/com/fr/design/gui/xpane/FormPredefinedBackgroundPane.java
  53. 179
      designer-form/src/main/java/com/fr/design/gui/xpane/PredefinedComponentStyleSettingPane.java
  54. 98
      designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBodyBackgroundEditor.java
  55. 99
      designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBorderStyleEditor.java
  56. 83
      designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleWLayoutBorderStyleEditor.java
  57. 14
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/BorderStyleWidgetDefinePane.java
  58. 35
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ComponentStyle.java
  59. 11
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java
  60. 23
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java
  61. 22
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java
  62. 19
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WTitleLayoutDefinePane.java
  63. 11
      designer-realize/src/main/java/com/fr/design/actions/report/ReportBackgroundAction.java
  64. 52
      designer-realize/src/main/java/com/fr/design/actions/server/predefined/ServerPredefinedStyleAction.java
  65. 4
      designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java
  66. 4
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  67. 87
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java
  68. 234
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CellPredefinedStyleSettingPane.java
  69. 128
      designer-realize/src/main/java/com/fr/design/report/ReportPredefinedBackgroundPane.java
  70. 7
      designer-realize/src/main/java/com/fr/grid/GridUI.java
  71. 4
      designer-realize/src/main/java/com/fr/start/MainDesigner.java

2
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)")};

4
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());
}
}
}

46
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;
}
/**
* 创建垂直流布局面板
*

52
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<T extends BaseBook, U extends BaseUndoState<?>>
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<T extends BaseBook, U extends BaseUndoState<?>>
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
*

40
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<T extends AbstractPointInfo> implements BasePointCollector {
public abstract class AbstractPointCollector implements BasePointCollector {
protected Map<String, T> pointInfoMap;
private static final int MAX_SIZE = 512 * 1024 * 1024;
public AbstractPointCollector() {
pointInfoMap = new ConcurrentHashMap<>();
loadFromFile();
}
/**
@ -48,34 +42,6 @@ public abstract class AbstractPointCollector<T extends AbstractPointInfo> implem
return FileUtils.sizeOf(getInfoFile()) <= MAX_SIZE && DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv();
}
@Override
public void sendPointInfo() {
addIdleDayCount();
List<String> removeList = new ArrayList<>();
List<String> 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();
}
/**
* 从文件中读取埋点信息
*/

56
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<T extends AbstractPointInfo> extends AbstractPointCollector {
protected Map<String, T> 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<String> removeList = new ArrayList<>();
List<String> 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();
}
}

5
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);
}

4
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<ChartInfo> {
public class ChartInfoCollector extends AbstractTemplateInfoCollector<ChartInfo> {
private static final String XML_TAG = "ChartInfoCollector";
private static final String XML_LAST_EDIT_DAY = "lastEditDay";

36
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();
}

118
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();
}
}

141
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;
}
}

229
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java

@ -0,0 +1,229 @@
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 javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
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;
private UITabbedPane uiTabbedPane;
@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() {
boolean displayFormBackground = backgroundSettingPane.currentFormBackground() || uiTabbedPane.getSelectedIndex() == 3;
previewPane.refresh(this.update(), displayFormBackground);
}
@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 = 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());
uiTabbedPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
valueChangeAction();
}
});
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());
previewPane.refresh(previewObject);
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);
}
}

102
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<PredefinedStyle> 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();
}
}

152
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<T> 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) {
}
}

53
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");
}
}

201
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);
}
}

320
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/CellStyleSettingPane.java

@ -0,0 +1,320 @@
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.dialog.FineJOptionPane;
import com.fr.design.gui.NameInspector;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilist.JNameEdList;
import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.gui.ilist.ModNameActionListener;
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.PredefinedStyleEditPane;
import com.fr.design.mainframe.predefined.ui.detail.cell.CustomPredefinedStylePane;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.core.PaintUtils;
import com.fr.stable.Constants;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
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.Rectangle;
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.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Created by kerry on 2020-09-01
*/
public class CellStyleSettingPane extends BasicBeanPane<StyleMap> {
private StyleListPane styleListPane;
private List<CustomPredefinedStylePane> 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 JNameEdList styleList;
public StyleListPane() {
defaultListModel = new DefaultListModel();
styleList = new JNameEdList(defaultListModel){
public Rectangle createRect(Rectangle rect, int iconWidth) {
return new Rectangle(rect.x , rect.y, rect.width, rect.height);
}
};
styleList.setEditable(true);
styleList.addModNameActionListener(new ModNameActionListener() {
public void nameModed(int index, String oldName, String newName) {
if (ComparatorUtils.equals(oldName, newName) || ComparatorUtils.equals(newName, NameInspector.ILLEGAL_NAME_HOLDER)) {
return;
}
String[] allNames = styleList.getAllNames();
allNames[index] = StringUtils.EMPTY;
if (StringUtils.isEmpty(newName)) {
showTipDialogAndReset(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Empty_Name"), index);
return;
}
if (isNameRepeated(new List[] {Arrays.asList(allNames)}, newName)) {
showTipDialogAndReset(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Duplicate_Name", newName), index);
styleList.setNameAt("请重新命名", index);
return;
}
styleList.repaint();
}
});
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,styleList.getNameAt(selectIndex));
styleList.stopEditing();
if (e.getClickCount() >= 2
&& SwingUtilities.isLeftMouseButton(e)) {
styleList.editItemAt(styleList.getSelectedIndex());
}
}
});
}
private void showTipDialogAndReset(String content, int index) {
styleList.stopEditing();
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(StyleListPane.this),
content,
Toolkit.i18nText("Fine-Design_Basic_Alert"),
JOptionPane.WARNING_MESSAGE);
}
protected boolean isNameRepeated(java.util.List[] list, String name) {
for (int i = 0; i < list.length; i++) {
if (list[i].contains(name)) {
return true;
}
}
return false;
}
public void populate(StyleMap ob) {
Iterator<Map.Entry<String, Style>> iterator = ob.getAllStyles().entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, Style> entry = iterator.next();
addStyle(entry.getKey(), entry.getValue());
}
reset();
}
private void reset() {
if (defaultListModel.getSize() > 0) {
styleList.setSelectedIndex(0);
cardLayout.show(centerPane, styleList.getNameAt(0));
centerPane.validate();
}
}
public StyleMap update() {
StyleMap styleMap = new StyleMap();
for (int i = 0; i < defaultListModel.getSize(); i++) {
String name = styleList.getNameAt(i);
Style style = customStylePaneList.get(i).updateBean();
styleMap.put(name, style);
}
return styleMap;
}
public void addNewStyle() {
String newStyleName = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Cell_New_Style");
if (isNameRepeated(new List[] {Arrays.asList(styleList.getAllNames())},
newStyleName)){
showTipDialogAndReset(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Duplicate_Name", newStyleName), 0);
return;
}
addStyle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Cell_New_Style"), Style.getInstance());
}
public void addStyle(String name, Style style) {
ListModelElement el = new ListCellStyleModelElement(new NameObject(name, style));
defaultListModel.addElement(el);
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 ListCellStyleModelElement extends com.fr.design.gui.ilist.ListModelElement {
private Nameable nameable;
public ListCellStyleModelElement(Nameable nameable) {
super(nameable);
this.nameable = nameable;
}
@Override
public String toString() {
return this.nameable.getName();
}
}
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);
}
}
}

69
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<PredefinedComponentStyle> {
private ComponentFrameStylePane frameStylePane;
private ComponentTitleStylePane titleStylePane;
private ComponentMarginStylePane marginStylePane;
public ComponentStyleSettingPane() {
}
@Override
protected List<BasicPane> initPaneList() {
this.frameStylePane = new ComponentFrameStylePane();
this.titleStylePane = ComponentTitleStylePane.createPredefinedSettingPane();
this.marginStylePane = new ComponentMarginStylePane();
paneList = new ArrayList<BasicPane>();
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() {
}
}

88
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/PredefinedBackgroundSettingPane.java

@ -0,0 +1,88 @@
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<PredefinedBackground> {
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);
}
public boolean currentFormBackground() {
return buttonGroup.getSelectedIndex() == 1;
}
@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 "预定义背景设置";
}
}

167
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<Background> {
private ChangeListener changeListener = null;
private UIComboBox headCombobox;
private List<BackgroundDetailPane> 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;
}
}

99
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;
}
}

78
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<BackgroundWithAlpha> {
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;
}
}

102
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;
}
}
}

27
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) {
}
}

147
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;
}
}

190
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);
}
}
}

93
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;
}
}

60
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) {
}
}

129
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<Style> {
private Style style;
private ChangeListener changeListener;
public CustomPredefinedStylePane() {
super();
tabPane.setOneLineTab(true);
tabPane.setDrawLine(false);
tabPane.setBorder(BorderFactory.createLineBorder(UIConstants.SHADOW_GREY));
tabPane.setLayout(new GridLayout(1, 3, 0, 0));
}
/**
* @return
*/
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Custom_Style");
}
public void addChangeListener(ChangeListener listener) {
this.changeListener = listener;
}
/**
*
*/
public void reset() {
populateBean(null);
}
@Override
/**
*
*/
public void populateBean(Style ob) {
this.style = ob;
for (int i = 0; i < paneList.size(); i++) {
((AbstractBasicStylePane) paneList.get(i)).populateBean(ob);
}
}
@Override
/**
*
*/
public Style updateBean() {
this.style = ((AbstractBasicStylePane) paneList.get(tabPane.getSelectedIndex())).update(this.style);
return this.style;
}
/**
* @param ob
* @return
*/
public boolean accept(Object ob) {
return ob instanceof Style;
}
@Override
protected List<BasicPane> initPaneList() {
paneList = new ArrayList<BasicPane>();
paneList.add(new FormatPane());
paneList.add(new BorderPane());
paneList.add(new AlignmentPane());
return paneList;
}
protected void initLayout() {
this.setLayout(new BorderLayout(0, 4));
this.add(tabPane, BorderLayout.NORTH);
JPanel attrListenerPane = new AbstractAttrNoScrollPane() {
@Override
protected JPanel createContentPane() {
this.addAttributeChangeListener(new AttributeChangeListener() {
@Override
public void attributeChange() {
if (changeListener != null) {
changeListener.stateChanged(null);
}
}
});
return centerPane;
}
};
this.add(attrListenerPane, BorderLayout.CENTER);
}
@Override
/**
*
*/
public void updateBean(Style ob) {
return;
}
}

147
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentFrameStylePane.java

@ -0,0 +1,147 @@
package com.fr.design.mainframe.predefined.ui.detail.component;
import com.fr.base.GraphHelper;
import com.fr.base.Utils;
import com.fr.config.predefined.PredefinedComponentStyle;
import com.fr.design.gui.frpane.UINumberDragPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.style.BackgroundSpecialPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.act.BorderPacker;
import com.fr.stable.Constants;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.geom.RoundRectangle2D;
/**
* Created by kerry on 2020-09-01
*/
public class ComponentFrameStylePane extends ComponentStylePane {
private final static String[] BORDER_STYLE = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Common"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Shadow")};
private static final double ALPHA_MAX_NUMBER = 100;
private final static int[] BORDER_LINE_STYLE_ARRAY = new int[]{
Constants.LINE_NONE,
Constants.LINE_THIN, //1px
Constants.LINE_MEDIUM, //2px
Constants.LINE_THICK, //3px
};
//渲染风格
private UIComboBox borderStyleCombo;
//边框粗细
private LineComboBox currentLineCombo;
//边框圆角
private UISpinner borderCornerSpinner;
//边框颜色
private UIColorButton currentLineColorPane;
//主体背景
private BackgroundSpecialPane backgroundPane;
//透明度
private UINumberDragPane numberDragPane;
public ComponentFrameStylePane() {
initPane();
}
protected void initPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(6, 0, 0, 0));
this.borderStyleCombo = new UIComboBox(BORDER_STYLE);
this.currentLineCombo = new LineComboBox(BORDER_LINE_STYLE_ARRAY);
this.currentLineColorPane = new UIColorButton(null);
this.borderCornerSpinner = new UISpinner(0, 1000, 1, 0);
currentLineColorPane.setUI(getButtonUI(currentLineColorPane));
currentLineColorPane.set4ToolbarButton();
currentLineColorPane.setPreferredSize(new Dimension(20, 20));
JPanel buttonPane = new JPanel(new BorderLayout());
buttonPane.add(currentLineColorPane, BorderLayout.WEST);
backgroundPane = new BackgroundSpecialPane();
JPanel transparencyPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.numberDragPane = new UINumberDragPane(0, 100);
transparencyPane.add(numberDragPane, BorderLayout.CENTER);
transparencyPane.add(new UILabel(" %"), BorderLayout.EAST);
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p, p, p, p, p, p};
double[] columnSize = {p, 157};
JPanel rightTopContentPane = TableLayoutHelper.createCommonTableLayoutPane(new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Border_Line")), currentLineCombo},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Border_Color")), buttonPane},
getBorderCornerSpinnerComp(),
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Background")), backgroundPane},
{new UILabel(""), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Alpha"))},
{new UILabel(""), transparencyPane},
}, rowSize, columnSize, 10);
UIScrollPane rightTopPane = new UIScrollPane(rightTopContentPane);
rightTopPane.setBorder(BorderFactory.createEmptyBorder());
this.add(rightTopPane, BorderLayout.CENTER);
}
private JComponent[] getBorderCornerSpinnerComp() {
return new JComponent[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius") + ":"), borderCornerSpinner};
}
protected UIButtonUI getButtonUI(final UIColorButton uiColorButton) {
return new UIButtonUI() {
public void paint(Graphics g, JComponent c) {
UIButton b = (UIButton) c;
g.setColor(Color.black);
GraphHelper.draw(g, new RoundRectangle2D.Double(1, 1, b.getWidth() - 2, b.getHeight() - 2, 0, 0), 1);
if (b.getModel().isEnabled()) {
g.setColor(uiColorButton.getColor());
} else {
g.setColor(new Color(Utils.filterRGB(uiColorButton.getColor().getRGB(), 50)));
}
g.fillRect(2, 2, b.getWidth() - 3, b.getHeight() - 3);
}
};
}
@Override
protected String title4PopupWindow() {
return "框架";
}
@Override
public void populate(PredefinedComponentStyle componentStyle) {
BorderPacker borderStyle = componentStyle.getBorderStyle();
this.borderStyleCombo.setSelectedIndex(borderStyle.getBorderStyle());
this.borderCornerSpinner.setValue(borderStyle.getBorderRadius());
this.currentLineCombo.setSelectedLineStyle(borderStyle.getBorder());
this.currentLineColorPane.setColor(borderStyle.getColor());
this.backgroundPane.populateBean(borderStyle.getBackground());
numberDragPane.populateBean(borderStyle.getAlpha() * ALPHA_MAX_NUMBER);
}
@Override
public void update(PredefinedComponentStyle componentStyle) {
BorderPacker style = componentStyle.getBorderStyle();
style.setBorderStyle(borderStyleCombo.getSelectedIndex());
style.setBorderRadius((int) borderCornerSpinner.getValue());
style.setBorder(currentLineCombo.getSelectedLineStyle());
style.setColor(currentLineColorPane.getColor());
style.setBackground(backgroundPane.update());
style.setAlpha((float) (numberDragPane.updateBean() / ALPHA_MAX_NUMBER));
}
}

93
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentMarginStylePane.java

@ -0,0 +1,93 @@
package com.fr.design.mainframe.predefined.ui.detail.component;
import com.fr.config.predefined.PredefinedComponentStyle;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
/**
* Created by kerry on 2020-09-01
*/
public class ComponentMarginStylePane extends ComponentStylePane {
protected UISpinner top;
protected UISpinner bottom;
protected UISpinner left;
protected UISpinner right;
public ComponentMarginStylePane() {
initBoundPane(0, 0, 0, 0);
}
public void initBoundPane(int t, int b, int l, int r) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
top = new UISpinner(0, Integer.MAX_VALUE, 1, t);
bottom = new UISpinner(0, Integer.MAX_VALUE, 1, b);
left = new UISpinner(0, Integer.MAX_VALUE, 1, l);
right = new UISpinner(0, Integer.MAX_VALUE, 1, r);
top.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"));
bottom.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"));
left.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"));
right.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"));
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"));
label.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0));
label.setVerticalAlignment(SwingConstants.TOP);
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{
new Component[]{label, createRightPane()}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W2, IntervalConstants.INTERVAL_L1);
this.add(panel);
}
public JPanel createRightPane() {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p};
double[] columnSize = {f, f};
int[][] rowCount = {{1, 1}, {1, 1}};
Component[][] components1 = new Component[][]{
new Component[]{top, bottom},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Top"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bottom"), SwingConstants.CENTER)}
};
Component[][] components2 = new Component[][]{
new Component[]{left, right},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Left"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Right"), SwingConstants.CENTER)}
};
JPanel northPanel = TableLayoutHelper.createGapTableLayoutPane(components1, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_L6);
northPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, IntervalConstants.INTERVAL_L1, 0));
JPanel centerPanel = TableLayoutHelper.createGapTableLayoutPane(components2, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_L6);
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0));
panel.add(northPanel, BorderLayout.NORTH);
panel.add(centerPanel, BorderLayout.CENTER);
return panel;
}
@Override
protected String title4PopupWindow() {
return "边距";
}
@Override
public void populate(PredefinedComponentStyle componentStyle) {
this.top.setValue(componentStyle.getTop());
this.bottom.setValue(componentStyle.getBottom());
this.left.setValue(componentStyle.getLeft());
this.right.setValue(componentStyle.getRight());
}
@Override
public void update(PredefinedComponentStyle componentStyle) {
componentStyle.setTop((int) this.top.getValue());
componentStyle.setBottom((int) this.bottom.getValue());
componentStyle.setLeft((int) this.left.getValue());
componentStyle.setRight((int) this.right.getValue());
}
}

15
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentStylePane.java

@ -0,0 +1,15 @@
package com.fr.design.mainframe.predefined.ui.detail.component;
import com.fr.config.predefined.PredefinedComponentStyle;
import com.fr.design.dialog.BasicPane;
/**
* Created by kerry on 2020-09-01
*/
public abstract class ComponentStylePane extends BasicPane {
public abstract void populate(PredefinedComponentStyle componentStyle);
public abstract void update(PredefinedComponentStyle componentStyle);
}

252
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/component/ComponentTitleStylePane.java

@ -0,0 +1,252 @@
package com.fr.design.mainframe.predefined.ui.detail.component;
import com.fr.base.BaseUtils;
import com.fr.base.Utils;
import com.fr.config.predefined.PredefinedComponentStyle;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.constants.UIConstants;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.style.BackgroundNoImagePane;
import com.fr.design.gui.style.FRFontPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.WidgetTitle;
import com.fr.general.FRFont;
import com.fr.general.act.BorderPacker;
import com.fr.general.act.TitlePacker;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JComponent;
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.FlowLayout;
import java.awt.Font;
/**
* Created by kerry on 2020-09-01
*/
public class ComponentTitleStylePane extends ComponentStylePane {
private final static Dimension BUTTON_SIZE = new Dimension(24, 20);
//标题内容
private TinyFormulaPane formulaPane;
//标题格式
private UIComboBox fontNameComboBox;
private UIComboBox fontSizeComboBox;
private UIColorButton colorSelectPane;
private UIToggleButton bold;
private UIToggleButton italic;
private UIToggleButton underline;
private LineComboBox underlineCombo;
//对齐方式
private UIButtonGroup hAlignmentPane;
//标题背景
private BackgroundNoImagePane titleBackgroundPane;
public static ComponentTitleStylePane createPredefinedSettingPane(){
return new ComponentTitleStylePane(true);
}
public static ComponentTitleStylePane createStyleSettingPane(){
return new ComponentTitleStylePane(false);
}
private ComponentTitleStylePane(boolean isPredefined) {
initPane(isPredefined);
}
protected void initPane(boolean isPredefined) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(6, 0,0,0));
formulaPane = new TinyFormulaPane();
fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES);
fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report());
fontNameComboBox.setPreferredSize(new Dimension(105 , 20));
JPanel fontSizeTypePane = new JPanel(new BorderLayout(3, 0));
fontSizeTypePane.add(fontSizeComboBox, BorderLayout.CENTER);
fontSizeTypePane.add(fontNameComboBox, BorderLayout.EAST);
Icon[] hAlignmentIconArray = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"),
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"),
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png"),};
Integer[] hAlignment = new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT};
hAlignmentPane = new UIButtonGroup<Integer>(hAlignmentIconArray, hAlignment);
hAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Left")
, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Right")});
JPanel hPaneContainer = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
hPaneContainer.add(hAlignmentPane);
titleBackgroundPane = new BackgroundNoImagePane();
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p, p, p, p, p, p};
double[] columnSize = {p, 157};
JComponent[][] jComponents = new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("字符")), fontSizeTypePane},
{new UILabel(""), initFontButtonPane()},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Alignment-Style")), hAlignmentPane},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Background")), titleBackgroundPane}};
JComponent[][] displayComponents = createDisplayComponentArray(isPredefined, jComponents);
JPanel rightBottomContentPane = TableLayoutHelper.createCommonTableLayoutPane(displayComponents, rowSize, columnSize, 10);
UIScrollPane jPanel = new UIScrollPane(rightBottomContentPane);
jPanel.setBorder(BorderFactory.createEmptyBorder());
this.add(jPanel, BorderLayout.CENTER);
}
private JComponent[][] createDisplayComponentArray(boolean isPredefined, JComponent[][] baseComponents) {
if (isPredefined) {
return baseComponents;
}
JComponent[][] titleComponent = new JComponent[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Content")), formulaPane}};
return ArrayUtils.addAll(titleComponent, baseComponents);
}
protected JPanel initFontButtonPane() {
colorSelectPane = new UIColorButton();
bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"));
italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"));
underline = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png"));
bold.setPreferredSize(BUTTON_SIZE);
italic.setPreferredSize(BUTTON_SIZE);
underline.setPreferredSize(BUTTON_SIZE);
underline.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
underlineCombo.setVisible(underline.isSelected());
}
});
underlineCombo = new LineComboBox(UIConstants.BORDER_LINE_STYLE_ARRAY);
Component[] components_font = new Component[]{
colorSelectPane, italic, bold, underline
};
JPanel buttonPane = new JPanel(new BorderLayout());
buttonPane.add(GUICoreUtils.createFlowPane(components_font, FlowLayout.LEFT, LayoutConstants.HGAP_SMALL));
JPanel combinePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
combinePane.add(buttonPane, BorderLayout.WEST);
combinePane.add(underlineCombo, BorderLayout.CENTER);
initAllNames();
setToolTips();
return combinePane;
}
protected void initAllNames() {
fontNameComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Family"));
fontSizeComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Size"));
colorSelectPane.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Foreground"));
italic.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Italic"));
bold.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Bold"));
underline.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Underline"));
underlineCombo.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Line_Style"));
}
protected void setToolTips() {
colorSelectPane.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Foreground"));
italic.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Italic"));
bold.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Bold"));
underline.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Underline"));
}
@Override
protected String title4PopupWindow() {
return "标题";
}
@Override
public void populate(PredefinedComponentStyle componentStyle) {
BorderPacker borderStyle = componentStyle.getBorderStyle();
TitlePacker widgetTitle = borderStyle == null ? new WidgetTitle() : borderStyle.getTitle();
widgetTitle = widgetTitle == null ? new WidgetTitle() : widgetTitle;
populateFormula(widgetTitle);
populateFont(widgetTitle);
hAlignmentPane.setSelectedItem(widgetTitle.getPosition());
titleBackgroundPane.populateBean(widgetTitle.getBackground());
}
private void populateFormula(TitlePacker widgetTitle) {
this.formulaPane.populateBean(widgetTitle.getTextObject().toString());
}
protected void populateFont(TitlePacker widgetTitle) {
FRFont frFont = widgetTitle.getFrFont();
this.fontSizeComboBox.setSelectedItem(frFont.getSize());
this.fontNameComboBox.setSelectedItem(frFont.getFamily());
this.colorSelectPane.setColor(frFont.getForeground());
this.colorSelectPane.repaint();
bold.setSelected(frFont.isBold());
italic.setSelected(frFont.isItalic());
int line = frFont.getUnderline();
if (line == Constants.LINE_NONE) {
underline.setSelected(false);
underlineCombo.setVisible(false);
} else {
underline.setSelected(true);
underlineCombo.setVisible(true);
this.underlineCombo.setSelectedLineStyle(line);
}
}
@Override
public void update(PredefinedComponentStyle componentStyle) {
BorderPacker style = componentStyle.getBorderStyle();
TitlePacker title = style.getTitle() == null ? new WidgetTitle() : style.getTitle();
String titleText = formulaPane.updateBean();
title.setTextObject(titleText);
style.setType(StringUtils.isEmpty(titleText) ? LayoutBorderStyle.STANDARD : LayoutBorderStyle.TITLE);
FRFont frFont = title.getFrFont();
frFont = frFont.applySize((Integer) fontSizeComboBox.getSelectedItem());
frFont = frFont.applyName(fontNameComboBox.getSelectedItem().toString());
frFont = frFont.applyForeground(colorSelectPane.getColor());
frFont = updateItalicBold(frFont);
int line = underline.isSelected() ? this.underlineCombo.getSelectedLineStyle() : Constants.LINE_NONE;
frFont = frFont.applyUnderline(line);
title.setFrFont(frFont);
title.setPosition((Integer) hAlignmentPane.getSelectedItem());
title.setBackground(titleBackgroundPane.update());
style.setTitle(title);
}
private FRFont updateItalicBold(FRFont frFont) {
int italic_bold = frFont.getStyle();
boolean isItalic = italic_bold == Font.ITALIC || italic_bold == (Font.BOLD + Font.ITALIC);
boolean isBold = italic_bold == Font.BOLD || italic_bold == (Font.BOLD + Font.ITALIC);
if (italic.isSelected() && !isItalic) {
italic_bold += Font.ITALIC;
} else if (!italic.isSelected() && isItalic) {
italic_bold -= Font.ITALIC;
}
frFont = frFont.applyStyle(italic_bold);
if (bold.isSelected() && !isBold) {
italic_bold += Font.BOLD;
} else if (!bold.isSelected() && isBold) {
italic_bold -= Font.BOLD;
}
frFont = frFont.applyStyle(italic_bold);
return frFont;
}
}

190
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/PredefinedStyleEditDialog.java

@ -0,0 +1,190 @@
package com.fr.design.mainframe.predefined.ui.dialog;
import com.fr.config.ServerPreferenceConfig;
import com.fr.config.predefined.PredefinedStyleConfig;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.mainframe.predefined.ui.PredefinedStyleEditPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StringUtils;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
/**
* Created by kerry on 2020-08-26
*/
public class PredefinedStyleEditDialog extends JDialog {
public PredefinedStyleEditDialog(Window parent, PredefinedStyleEditPane contentPane) {
this(parent, contentPane, false);
}
public PredefinedStyleEditDialog(Window parent, PredefinedStyleEditPane contentPane, boolean isBuiltIn) {
super(parent, ModalityType.APPLICATION_MODAL);
this.setTitle("服务器预定义样式");
this.setResizable(false);
JPanel defaultPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
this.setContentPane(defaultPane);
UIButton saveBtn = new UIButton("保存");
saveBtn.setEnabled(!isBuiltIn);
saveBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
contentPane.saveStyle();
dialogExit();
}
});
UIButton saveAsBtn = new UIButton("另存为新样式");
saveAsBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SaveAsNewStyleDialog saveAsNewStyleDialog = new SaveAsNewStyleDialog(PredefinedStyleEditDialog.this, contentPane);
saveAsNewStyleDialog.setVisible(true);
}
});
UIButton cancelBtn = new UIButton(com.fr.design.i18n.Toolkit.i18nText("取消"));
cancelBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialogExit();
}
});
JPanel buttonPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
buttonPanel.add(saveBtn);
buttonPanel.add(saveAsBtn);
buttonPanel.add(cancelBtn);
defaultPane.add(contentPane, BorderLayout.CENTER);
defaultPane.add(buttonPanel, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dialogExit();
}
});
this.setSize(new Dimension(900, 600));
GUICoreUtils.centerWindow(this);
}
public void dialogExit() {
this.dispose();
}
class SaveAsNewStyleDialog extends JDialog {
private UITextField textField;
private UILabel tipLabel;
public SaveAsNewStyleDialog(Window parent, PredefinedStyleEditPane editPane) {
super(parent, ModalityType.APPLICATION_MODAL);
this.setTitle("服务器预定义样式");
this.setResizable(false);
UIButton confirm = new UIButton("确认");
confirm.setEnabled(false);
confirm.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String name = textField.getText();
if (valid(name)) {
editPane.saveAsNewStyle(name);
dialogExit();
PredefinedStyleEditDialog.this.dialogExit();
} else {
tipLabel.setText("该名称已存在");
}
}
});
UIButton cancle = new UIButton("取消");
cancle.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialogExit();
}
});
JPanel defaultPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
JPanel buttonPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
buttonPanel.add(confirm);
buttonPanel.add(cancle);
JPanel panel = createSaveAsPane(confirm);
defaultPane.add(panel, BorderLayout.CENTER);
defaultPane.add(buttonPanel, BorderLayout.SOUTH);
this.setContentPane(defaultPane);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dialogExit();
}
});
this.setSize(new Dimension(300, 120));
GUICoreUtils.centerWindow(this);
}
private JPanel createSaveAsPane(UIButton confirm) {
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel centerPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(20, 5);
centerPane.add(new UILabel("样式名称"));
textField = new UITextField();
textField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
confirm.setEnabled(StringUtils.isNotEmpty(textField.getText()));
}
@Override
public void removeUpdate(DocumentEvent e) {
}
@Override
public void changedUpdate(DocumentEvent e) {
}
});
textField.setPreferredSize(new Dimension(180, 20));
centerPane.add(textField);
panel.add(centerPane, BorderLayout.CENTER);
tipLabel = new UILabel();
tipLabel.setForeground(Color.RED);
panel.add(tipLabel, BorderLayout.SOUTH);
return panel;
}
public void dialogExit() {
this.dispose();
}
private boolean valid(String name) {
PredefinedStyleConfig config = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig();
return !config.containStyle(name);
}
}
}

93
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/ReportPredefinedStyleDialog.java

@ -0,0 +1,93 @@
package com.fr.design.mainframe.predefined.ui.dialog;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.predefined.ui.ReportPredefinedStylePane;
import com.fr.design.mainframe.predefined.ui.ServerPredefinedStylePane;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.JDialog;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
/**
* Created by kerry on 2020-08-26
*/
public class ReportPredefinedStyleDialog extends JDialog {
public ReportPredefinedStyleDialog(Window parent, ReportPredefinedStylePane contentPane) {
super(parent, ModalityType.APPLICATION_MODAL);
this.setTitle("模板预定义样式");
this.setResizable(false);
JPanel defaultPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
this.setContentPane(defaultPane);
UIButton managerBtn = new UIButton("样式管理");
managerBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ServerPredefinedStylePane predefinedStylePane = new ServerPredefinedStylePane();
ServerPredefinedStyleDialog dialog = new ServerPredefinedStyleDialog(ReportPredefinedStyleDialog.this, predefinedStylePane);
dialog.setVisible(true);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
contentPane.refresh();
}
});
}
});
UIButton settingBtn = new UIButton("应用样式");
settingBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
contentPane.update();
dialogExit();
}
});
UIButton cancelBtn = new UIButton(com.fr.design.i18n.Toolkit.i18nText("取消"));
cancelBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialogExit();
}
});
JPanel southPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel buttonPanel1 = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
buttonPanel1.add(managerBtn);
southPane.add(buttonPanel1, BorderLayout.CENTER);
JPanel buttonPanel2 = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
buttonPanel2.add(settingBtn);
buttonPanel2.add(cancelBtn);
southPane.add(buttonPanel2, BorderLayout.EAST);
defaultPane.add(contentPane, BorderLayout.CENTER);
defaultPane.add(southPane, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dialogExit();
}
});
this.setSize(new Dimension(660, 600));
GUICoreUtils.centerWindow(this);
}
public void dialogExit() {
this.dispose();
}
}

69
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/dialog/ServerPredefinedStyleDialog.java

@ -0,0 +1,69 @@
package com.fr.design.mainframe.predefined.ui.dialog;
import com.fr.design.mainframe.predefined.ui.ServerPredefinedStylePane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.JDialog;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
/**
* Created by kerry on 2020-08-26
*/
public class ServerPredefinedStyleDialog extends JDialog {
public ServerPredefinedStyleDialog(Window parent, ServerPredefinedStylePane contentPane) {
super(parent, ModalityType.APPLICATION_MODAL);
;
this.setTitle("服务器预定义样式");
this.setResizable(false);
JPanel defaultPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
this.setContentPane(defaultPane);
UIButton settingBtn = new UIButton("设为默认样式");
settingBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
contentPane.update();
dialogExit();
}
});
UIButton cancelBtn = new UIButton(com.fr.design.i18n.Toolkit.i18nText("取消"));
cancelBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialogExit();
}
});
JPanel buttonPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
buttonPanel.add(settingBtn);
buttonPanel.add(cancelBtn);
defaultPane.add(contentPane, BorderLayout.CENTER);
defaultPane.add(buttonPanel, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dialogExit();
}
});
this.setSize(new Dimension(660, 600));
GUICoreUtils.centerWindow(this);
}
public void dialogExit(){
this.dispose();
}
}

146
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ComponentPreviewPane.java

@ -0,0 +1,146 @@
package com.fr.design.mainframe.predefined.ui.preview;
import com.fr.base.FRContext;
import com.fr.base.GraphHelper;
import com.fr.config.predefined.PredefinedStyle;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.Background;
import com.fr.general.FRFont;
import com.fr.general.act.BorderPacker;
import com.fr.general.act.TitlePacker;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
/**
* Created by kerry on 2020-09-04
*/
public abstract class ComponentPreviewPane extends StyleSettingPreviewPane {
private PredefinedStyle style = new PredefinedStyle();
private static final int SMALL_GAP = 5;
private static final int GAP = 10;
private JPanel contentPane;
private TitlePreviewPane titlePane;
public ComponentPreviewPane() {
this.setBackground(null);
this.setOpaque(false);
this.contentPane = createContentPane();
this.titlePane = new TitlePreviewPane();
this.titlePane.setPreferredSize(new Dimension(484, 35));
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10));
this.add(titlePane, BorderLayout.NORTH);
this.add(contentPane, BorderLayout.CENTER);
}
protected abstract JPanel createContentPane();
public void refresh() {
this.repaint();
}
public void refresh(PredefinedStyle style) {
this.style = style;
}
@Override
public void paint(Graphics g) {
paintContent(g);
}
public void paintContent(Graphics g) {
BorderPacker borderStyle = style.getComponentStyle().getBorderStyle();
updateBorders(g, borderStyle);
paintTitle(g, borderStyle.getTitle());
paintContentPane(g,borderStyle);
}
private void paintContentPane(Graphics g, BorderPacker borderStyle) {
Graphics clipg;
clipg = g.create(10, 40, this.contentPane.getWidth(), this.contentPane.getHeight());
if (borderStyle.getBackground() != null) {
borderStyle.getBackground().paint(clipg, clipg.getClipBounds());
}
this.contentPane.paint(clipg);
clipg.dispose();
}
private void paintTitle(Graphics g, TitlePacker titlePacker) {
FRFont font = titlePacker.getFrFont();
Background background = titlePacker.getBackground();
if (background != null) {
background.paint(g, new Rectangle2D.Double(10, 5, this.titlePane.getWidth(), this.titlePane.getHeight()));
}
titlePane.setFontObject(font);
titlePane.paintComponent(g);
}
private void updateBorders(Graphics g, BorderPacker borderStyle) {
if (borderStyle != null) {
borderStyle.paint(g, new Rectangle2D.Double(SMALL_GAP, SMALL_GAP, getWidth() - GAP, getHeight() - SMALL_GAP - GAP));
}
}
private class TitlePreviewPane extends JPanel {
private FRFont frFont = null;
public TitlePreviewPane() {
this.setBackground(null);
this.setOpaque(false);
frFont = FRContext.getDefaultValues().getFRFont();
}
@Override
public void paint(Graphics g) {
}
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
Dimension d = getSize();
if (frFont == null) {
return;
}
FontMetrics fm = getFontMetrics(frFont);
if (this.isEnabled()) {
g2d.setColor(frFont.getForeground());
} else {
g2d.setColor(new Color(237, 237, 237));
}
g2d.setFont(frFont.applySize(14).applyResolutionNP(96));
int startY = 0;
startY = (d.height + fm.getHeight()) / 2;
drawTabBack(g2d, startY);
}
private void drawTabBack(Graphics2D g2d, int startY) {
String paintText = "各城市目标达成情况";
GraphHelper.drawString(g2d, paintText, GAP, 32);
}
public void setFontObject(FRFont font) {
this.frFont = font;
}
}
}

98
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ElementCasePreview.java

@ -0,0 +1,98 @@
package com.fr.design.mainframe.predefined.ui.preview;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.FRFont;
import com.fr.log.FineLoggerFactory;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
/**
* Created by kerry on 2020-09-04
*/
public class ElementCasePreview extends ComponentPreviewPane {
private static final List<String[]> PREVIEW_DATA_LIST = new ArrayList<>();
private static final String BLANK_CHAR = " ";
static {
readPreviewData();
}
private static void readPreviewData() {
try {
InputStream inputStream = ElementCasePreview.class.getResourceAsStream("/com/fr/design/mainframe/predefined/previewData");
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream,
StandardCharsets.UTF_8));
String lineTxt = null;
while ((lineTxt = br.readLine()) != null) {
String[] data = lineTxt.split(BLANK_CHAR);
PREVIEW_DATA_LIST.add(data);
}
br.close();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
@Override
protected JPanel createContentPane() {
JPanel jPanel = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
jPanel.setOpaque(false);
jPanel.setBackground(null);
FRFont font = FRFont.getInstance();
FRFont titleFont = font.applySize(11).applyForeground(Color.decode("#63B2EE"));
FRFont endFont = font.applyForeground(Color.decode("#1B97FF"));
for (int i = 0; i < PREVIEW_DATA_LIST.size(); i++) {
FRFont frFont = font;
if (i == 0) {
frFont = titleFont;
}
if (i == PREVIEW_DATA_LIST.size() - 1) {
frFont = endFont;
}
jPanel.add(new GridRowPane(frFont, PREVIEW_DATA_LIST.get(i)));
}
return jPanel;
}
class GridRowPane extends JPanel {
public GridRowPane(FRFont frFont, String[] data) {
this.setOpaque(false);
this.setBackground(null);
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel panel = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(4, 20, 10);
panel.setOpaque(false);
panel.setBackground(null);
for (String text : data) {
panel.add(createLabel(text, frFont));
}
this.add(panel, BorderLayout.CENTER);
JSeparator jSeparator = new JSeparator();
jSeparator.setPreferredSize(new Dimension(246, 2));
this.add(jSeparator, BorderLayout.SOUTH);
}
private UILabel createLabel(String text, FRFont frFont) {
UILabel label = new UILabel(text);
label.setFont(frFont);
label.setForeground(frFont.getForeground());
label.setBackground(null);
return label;
}
}
}

80
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/PredefinedStylePreviewPane.java

@ -0,0 +1,80 @@
package com.fr.design.mainframe.predefined.ui.preview;
import com.fr.base.background.ColorBackground;
import com.fr.config.predefined.PredefinedStyle;
import com.fr.design.utils.ComponentUtils;
import com.fr.general.Background;
import javax.swing.JComponent;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
/**
* Created by kerry on 2020-09-06
*/
public class PredefinedStylePreviewPane extends StyleSettingPreviewPane {
private ElementCasePreview elementCasePreview;
private Background background;
private double scaleX = 1.0;
private double scaleY = 1.0;
public PredefinedStylePreviewPane() {
this(1.0, 1.0);
}
public PredefinedStylePreviewPane(double scaleX, double scaleY) {
this.scaleX = scaleX;
this.scaleY = scaleY;
this.setBackground(Color.WHITE);
this.elementCasePreview = new ElementCasePreview();
this.elementCasePreview.setPreferredSize(new Dimension(517, 320));
this.add(this.elementCasePreview);
}
@Override
public void refresh() {
}
@Override
public void paint(Graphics g) {
((Graphics2D) g).scale(scaleX, scaleY);
// 禁止双缓冲
ArrayList<JComponent> dbcomponents = new ArrayList<JComponent>();
ComponentUtils.disableBuffer(this.elementCasePreview, dbcomponents);
if (background == null) {
background = ColorBackground.getInstance(Color.WHITE);
}
background.paint(g, new Rectangle2D.Double(0, 0, 517, 320));
this.elementCasePreview.paintContent(g);
// 恢复双缓冲
ComponentUtils.resetBuffer(dbcomponents);
}
@Override
public void paintComponents(Graphics g) {
super.paintComponents(g);
if (background != null) {
background.paint(g, new Rectangle2D.Double(0, 0, this.getWidth(), this.getHeight()));
}
}
public void refresh(PredefinedStyle style) {
refresh(style, false);
}
public void refresh(PredefinedStyle style, boolean displayFormBackground) {
elementCasePreview.refresh(style);
background = displayFormBackground ? style.getFormBackground().getBackground() : style.getReportBackground();
this.repaint();
}
}

17
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/StyleSettingPreviewPane.java

@ -0,0 +1,17 @@
package com.fr.design.mainframe.predefined.ui.preview;
import javax.swing.JPanel;
/**
* Created by kerry on 2020-08-31
*/
public abstract class StyleSettingPreviewPane extends JPanel {
public StyleSettingPreviewPane() {
}
public abstract void refresh();
}

2
designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java

@ -27,7 +27,7 @@ public class SendHelper {
return success;
}
private static boolean sendSinglePointInfo(String url, String content) {
public static boolean sendSinglePointInfo(String url, String content) {
Map<String, Object> para = new HashMap<>();
para.put("token", SiteCenterToken.generateToken());
para.put("content", content);

4
designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java

@ -1,7 +1,7 @@
package com.fr.design.mainframe.template.info;
import com.fr.design.mainframe.burying.point.AbstractPointCollector;
import com.fr.design.mainframe.burying.point.AbstractPointInfo;
import com.fr.design.mainframe.burying.point.AbstractTemplateInfoCollector;
import com.fr.json.JSON;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject;
@ -18,7 +18,7 @@ import java.util.concurrent.ConcurrentHashMap;
* 做模板的过程和耗时收集辅助类
* Created by plough on 2017/2/21.
*/
public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo> {
public class TemplateInfoCollector extends AbstractTemplateInfoCollector<TemplateInfo> {
private static final String XML_TAG = "TplInfo";
private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList";
private static final String XML_FILE_NAME = "tpl.info";

2
designer-base/src/main/java/com/fr/design/style/background/impl/BPane.java

@ -15,7 +15,7 @@ public abstract class BPane extends BackgroundDetailPane {
this.initComponents(nColumn);
}
private void initComponents(int nColumn) {
protected void initComponents(int nColumn) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

192
designer-base/src/main/java/com/fr/design/style/background/impl/TextureBackgroundPane.java

@ -1,197 +1,59 @@
package com.fr.design.style.background.impl;
import com.fr.base.GraphHelper;
import com.fr.base.background.TextureBackground;
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 com.fr.general.ComparatorUtils;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Rectangle2D;
import java.awt.BorderLayout;
/**
* Texture background pane. TODO kunsnat: 拆出去. 真特么的长..
*/
public class TextureBackgroundPane extends BPane {
private static final TexturePaint[] EMBED_TEXTURE_PAINT_ARRAY = new TexturePaint[]{
TextureBackground.NEWSPRINT_TEXTURE_PAINT,
TextureBackground.RECYCLED_PAPER_TEXTURE_PAINT,
TextureBackground.PARCHMENT_TEXTURE_PAINT,
TextureBackground.STATIONERY_TEXTURE_PAINT,
TextureBackground.GREEN_MARBLE_TEXTURE_PAINT,
TextureBackground.WHITE_MARBLE_TEXTURE_PAINT,
TextureBackground.BROWN_MARBLE_TEXTURE_PAINT,
TextureBackground.GRANITE_TEXTURE_PAINT,
TextureBackground.BLUE_TISSUE_PAPER_TEXTURE_PAINT,
TextureBackground.PINK_TISSUE_PAPER_TEXTURE_PAINT,
TextureBackground.PURPLE_MESH_TEXTURE_PAINT,
TextureBackground.BOUQUET_TEXTURE_PAINT,
TextureBackground.PAPYRUS_TEXTURE_PAINT,
TextureBackground.CANVAS_TEXTURE_PAINT,
TextureBackground.DENIM_TEXTURE_PAINT,
TextureBackground.WOVEN_MAT_TEXTURE_PAINT,
TextureBackground.WATER_DROPLETS_TEXTURE_PAINT,
TextureBackground.PAPER_BAG_TEXTURE_PAINT,
TextureBackground.FISH_FOSSIL_TEXTURE_PAINT,
TextureBackground.SAND_TEXTURE_PAINT,
TextureBackground.CORK_TEXTURE_PAINT,
TextureBackground.WALNUT_TEXTURE_PAINT,
TextureBackground.OAK_TEXTURE_PAINT,
TextureBackground.MEDIUM_WOOD_TEXTURE_PAINT};
private static final String[] EMBED_TEXTURE_PAINT_DES_ARRAY = new String[]{
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Newsprint"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Recycled_Paper"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Parchment"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Stationery"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Green_Marble"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_White_Marble"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Brown_Marble"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Granite"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Blue_Tissue_Paper"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Pink_Tissue_Paper"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Purple_Mesh"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Bouquet"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Papyrus"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Canvas"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Denim"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Woven_Mat"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Water_Droplets"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_PaperBag"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_FishFossil"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Sand"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Cork"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Walnut"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Oak"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Medium_Wood")
};
private TexturePaint texturePaint;
private TextureButton[] textureButtonArray;
public class TextureBackgroundPane extends BackgroundDetailPane {
private TextureDetailPane detailPane;
public TextureBackgroundPane() {
super(8);// 默认的.
this(8);// 默认的.
}
public TextureBackgroundPane(int colum) {
super(colum);// 自定义的.
}
public TextureBackgroundPane(int column) {
this.detailPane = TextureDetailPane.createNormalTextureDetailPane(column);
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
protected LayoutManager layoutOfTypePane(int nColumn) {
return FRGUIPaneFactory.createNColumnGridLayout(nColumn);
JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
this.add(contentPane, BorderLayout.NORTH);
JPanel typePane = FRGUIPaneFactory.createTitledBorderPane(titleOfTypePane());
contentPane.add(typePane);
typePane.add(this.detailPane);
}
protected String titleOfTypePane() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture");
}
protected void setChildrenOfTypePane(JPanel typePane2) {
ButtonGroup patternButtonGroup = new ButtonGroup();
textureButtonArray = new TextureButton[EMBED_TEXTURE_PAINT_ARRAY.length];
for (int i = 0; i < EMBED_TEXTURE_PAINT_ARRAY.length; i++) {
textureButtonArray[i] = new TextureButton(
EMBED_TEXTURE_PAINT_ARRAY[i], EMBED_TEXTURE_PAINT_DES_ARRAY[i]);
patternButtonGroup.add(textureButtonArray[i]);
typePane2.add(textureButtonArray[i]);
}
}
public void populate(Background background) {
if (background instanceof TextureBackground) {
TextureBackground textureBackground = (TextureBackground) background;
this.texturePaint = textureBackground.getTexturePaint();
for (int i = 0; i < textureButtonArray.length; i++) {
if (ComparatorUtils.equals(textureButtonArray[i].getTexturePaint(), this.texturePaint)) {
textureButtonArray[i].setSelected(true);
break;
}
}
} else {
this.textureButtonArray[0].setSelected(true);
this.texturePaint = textureButtonArray[0].getTexturePaint();
}
this.detailPane.populate(background);
}
public Background update() throws Exception {
return new TextureBackground(this.texturePaint);
return this.detailPane.update();
}
@Override
public void addChangeListener(ChangeListener changeListener) {
for (int i = 0; i < this.textureButtonArray.length; i++) {
this.textureButtonArray[i].addChangeListener(changeListener);
}
this.detailPane.addChangeListener(changeListener);
}
/**
* Texture type button.
*/
class TextureButton extends JToggleButton implements ActionListener {
private TexturePaint buttonTexturePaint;
public TextureButton(TexturePaint buttonTexturePaint, String tooltip) {
this.buttonTexturePaint = buttonTexturePaint;
this.setToolTipText(tooltip);
this.setCursor(new Cursor(Cursor.HAND_CURSOR));
this.addActionListener(this);
this.setBorder(null);
}
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
Dimension d = getSize();
g2d.setPaint(this.buttonTexturePaint);
GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, d.width - 1d,
d.height - 1d));
if (ComparatorUtils.equals(texturePaint, this.buttonTexturePaint)) {// it's
// selected.
g2d.setPaint(Color.black);
} else {
g2d.setPaint(Color.gray);
}
GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1d,
d.height - 1d));
}
public Dimension getPreferredSize() {
return new Dimension(36, 32);
}
public TexturePaint getTexturePaint() {
return this.buttonTexturePaint;
}
/**
* set Pattern setIndex.
*/
public void actionPerformed(ActionEvent evt) {
TextureBackgroundPane.this.texturePaint = this.getTexturePaint();
fireChagneListener();
TextureBackgroundPane.this.repaint(); // repaint.
}
public void addChangeListener(ChangeListener changeListener) {
this.changeListener = changeListener;
}
private void fireChagneListener() {
if (this.changeListener != null) {
ChangeEvent evt = new ChangeEvent(this);
this.changeListener.stateChanged(evt);
}
}
}
}

208
designer-base/src/main/java/com/fr/design/style/background/texture/TextureDetailPane.java

@ -0,0 +1,208 @@
package com.fr.design.style.background.texture;
import com.fr.base.GraphHelper;
import com.fr.base.background.TextureBackground;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.style.background.BackgroundDetailPane;
import com.fr.general.Background;
import com.fr.general.ComparatorUtils;
import javax.swing.ButtonGroup;
import javax.swing.JToggleButton;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.LayoutManager;
import java.awt.TexturePaint;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Rectangle2D;
/**
* Created by kerry on 2020-08-31
*/
public class TextureDetailPane extends BackgroundDetailPane {
private static final TexturePaint[] EMBED_TEXTURE_PAINT_ARRAY = new TexturePaint[]{
TextureBackground.NEWSPRINT_TEXTURE_PAINT,
TextureBackground.RECYCLED_PAPER_TEXTURE_PAINT,
TextureBackground.PARCHMENT_TEXTURE_PAINT,
TextureBackground.STATIONERY_TEXTURE_PAINT,
TextureBackground.GREEN_MARBLE_TEXTURE_PAINT,
TextureBackground.WHITE_MARBLE_TEXTURE_PAINT,
TextureBackground.BROWN_MARBLE_TEXTURE_PAINT,
TextureBackground.GRANITE_TEXTURE_PAINT,
TextureBackground.BLUE_TISSUE_PAPER_TEXTURE_PAINT,
TextureBackground.PINK_TISSUE_PAPER_TEXTURE_PAINT,
TextureBackground.PURPLE_MESH_TEXTURE_PAINT,
TextureBackground.BOUQUET_TEXTURE_PAINT,
TextureBackground.PAPYRUS_TEXTURE_PAINT,
TextureBackground.CANVAS_TEXTURE_PAINT,
TextureBackground.DENIM_TEXTURE_PAINT,
TextureBackground.WOVEN_MAT_TEXTURE_PAINT,
TextureBackground.WATER_DROPLETS_TEXTURE_PAINT,
TextureBackground.PAPER_BAG_TEXTURE_PAINT,
TextureBackground.FISH_FOSSIL_TEXTURE_PAINT,
TextureBackground.SAND_TEXTURE_PAINT,
TextureBackground.CORK_TEXTURE_PAINT,
TextureBackground.WALNUT_TEXTURE_PAINT,
TextureBackground.OAK_TEXTURE_PAINT,
TextureBackground.MEDIUM_WOOD_TEXTURE_PAINT};
private static final String[] EMBED_TEXTURE_PAINT_DES_ARRAY = new String[]{
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Newsprint"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Recycled_Paper"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Parchment"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Stationery"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Green_Marble"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_White_Marble"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Brown_Marble"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Granite"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Blue_Tissue_Paper"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Pink_Tissue_Paper"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Purple_Mesh"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Bouquet"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Papyrus"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Canvas"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Denim"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Woven_Mat"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Water_Droplets"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_PaperBag"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_FishFossil"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Sand"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Cork"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Walnut"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Oak"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Medium_Wood")
};
private TexturePaint texturePaint;
private TextureButton[] textureButtonArray;
private TextureDetailPane(LayoutManager layoutManager, Dimension perTextureBtnSize) {
// this.setForeground(Color.WHITE);
// this.setBackground(Color.WHITE);
this.setLayout(layoutManager);
this.setChildrenOfTypePane(perTextureBtnSize);
}
public static TextureDetailPane createNormalTextureDetailPane(int nColumn) {
return new TextureDetailPane(FRGUIPaneFactory.createNColumnGridLayout(nColumn), new Dimension(36, 32));
}
public static TextureDetailPane createMiniTextureDetailPane(int nColumn) {
return new TextureDetailPane(new GridLayout(0, nColumn, 2, 2), new Dimension(23, 23));
}
protected void setChildrenOfTypePane(Dimension dimension) {
ButtonGroup patternButtonGroup = new ButtonGroup();
textureButtonArray = new TextureButton[EMBED_TEXTURE_PAINT_ARRAY.length];
for (int i = 0; i < EMBED_TEXTURE_PAINT_ARRAY.length; i++) {
textureButtonArray[i] = new TextureButton(
EMBED_TEXTURE_PAINT_ARRAY[i], EMBED_TEXTURE_PAINT_DES_ARRAY[i]);
textureButtonArray[i].setPreferredSize(dimension);
patternButtonGroup.add(textureButtonArray[i]);
this.add(textureButtonArray[i]);
}
}
public void populate(Background background) {
if (background instanceof TextureBackground) {
TextureBackground textureBackground = (TextureBackground) background;
this.texturePaint = textureBackground.getTexturePaint();
for (int i = 0; i < textureButtonArray.length; i++) {
if (ComparatorUtils.equals(textureButtonArray[i].getTexturePaint(), this.texturePaint)) {
textureButtonArray[i].setSelected(true);
break;
}
}
} else {
this.textureButtonArray[0].setSelected(true);
this.texturePaint = textureButtonArray[0].getTexturePaint();
}
}
public Background update() throws Exception {
return new TextureBackground(this.texturePaint);
}
public void addChangeListener(ChangeListener changeListener) {
for (int i = 0; i < this.textureButtonArray.length; i++) {
this.textureButtonArray[i].addChangeListener(changeListener);
}
}
/**
* Texture type button.
*/
class TextureButton extends JToggleButton implements ActionListener {
private TexturePaint buttonTexturePaint;
public TextureButton(TexturePaint buttonTexturePaint, String tooltip) {
this.buttonTexturePaint = buttonTexturePaint;
this.setToolTipText(tooltip);
this.setCursor(new Cursor(Cursor.HAND_CURSOR));
this.addActionListener(this);
this.setBorder(null);
}
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
Dimension d = getSize();
g2d.setPaint(this.buttonTexturePaint);
GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, d.width - 1d,
d.height - 1d));
if (ComparatorUtils.equals(texturePaint, this.buttonTexturePaint)) {// it's
// selected.
g2d.setPaint(Color.black);
} else {
g2d.setPaint(Color.gray);
}
GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1d,
d.height - 1d));
}
public Dimension getPreferredSize() {
return new Dimension(36, 32);
}
public TexturePaint getTexturePaint() {
return this.buttonTexturePaint;
}
/**
* set Pattern setIndex.
*/
public void actionPerformed(ActionEvent evt) {
TextureDetailPane.this.texturePaint = this.getTexturePaint();
fireChagneListener();
TextureDetailPane.this.repaint(); // repaint.
}
public void addChangeListener(ChangeListener changeListener) {
this.changeListener = changeListener;
}
private void fireChagneListener() {
if (this.changeListener != null) {
ChangeEvent evt = new ChangeEvent(this);
this.changeListener.stateChanged(evt);
}
}
}
}

29
designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java

@ -53,25 +53,19 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable
initialCompents(isSupportTransparent);
}
private void initialCompents(boolean isSupportTransparent) {
protected void initialCompents(boolean isSupportTransparent) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
if (isSupportTransparent) {
UIButton transpanrentButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency"));
this.add(transpanrentButton, BorderLayout.NORTH);
transpanrentButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
doTransparent();
}
});
this.add(createTranspanrentButton(), BorderLayout.NORTH);
}
this.add(createCenterPane(), BorderLayout.CENTER);
}
protected JPanel createCenterPane(){
// center
JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
this.add(centerPane, BorderLayout.CENTER);
centerPane.add(getRow1Pane());
@ -98,6 +92,19 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable
centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 8, 8));
centerPane1.add(customButton, BorderLayout.NORTH);
centerPane.add(centerPane1);
return centerPane;
}
protected UIButton createTranspanrentButton(){
UIButton transpanrentButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency"));
transpanrentButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
doTransparent();
}
});
return transpanrentButton;
}
protected JPanel getMenuColorPane() {

BIN
designer-base/src/main/resources/com/fr/design/icon/icon_edit.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

BIN
designer-base/src/main/resources/com/fr/design/icon/icon_predefined_style.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

11
designer-base/src/main/resources/com/fr/design/mainframe/predefined/previewData

@ -0,0 +1,11 @@
城市 当月目标 当月实际完成 月度完成率
南通市 324,646 324,646 105%
合肥市 248,938 348,938 103%
邵阳市 248,938 348,938 103%
九江市 248,938 348,938 103%
武汉市 248,938 348,938 103%
郑州市 248,938 348,938 103%
无锡市 248,938 348,938 103%
南京市 248,938 348,938 103%
苏州市 248,938 348,938 103%
合计 3200,425 2900,300 95%

97
designer-base/src/test/java/com/fr/design/mainframe/predefined/info/PredefinedStyleInfoCollectorTest.java

@ -0,0 +1,97 @@
package com.fr.design.mainframe.predefined.info;
import com.fr.config.BBSAttr;
import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.general.GeneralUtils;
import com.fr.json.JSON;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants;
import com.fr.third.org.apache.commons.io.FileUtils;
import org.easymock.EasyMock;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
import java.io.File;
import java.io.IOException;
/**
* Created by kerry on 2020-09-05
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({ProductConstants.class, MarketConfig.class, DesignerEnvManager.class, GeneralUtils.class})
@SuppressStaticInitializationFor({"com.fr.jvm.assist.FineAssist"})
public class PredefinedStyleInfoCollectorTest {
private String filePath;
private String initialFileContent;
@Before
public void setUp() throws IOException {
PowerMock.mockStatic(ProductConstants.class);
filePath = getClass().getResource("predefinedStyle.info").getPath();
String dirPath = filePath.substring(0, filePath.indexOf("predefinedStyle.info"));
EasyMock.expect(ProductConstants.getEnvHome()).andReturn(dirPath).anyTimes();
EasyMock.replay();
PowerMock.replayAll();
initialFileContent = FileUtils.readFileToString(new File(filePath), "utf-8");
}
@After
public void tearDown() throws IOException {
FileUtils.writeStringToFile(new File(filePath), initialFileContent, "utf-8");
}
@Test
public void testCollectClickNumber() {
PredefinedStyleInfoCollector.getInstance().collectClickNumber();
Assert.assertEquals(1, PredefinedStyleInfoCollector.getInstance().getClickNumber());
}
@Test
public void testCollectUseNumber() {
PredefinedStyleInfoCollector.getInstance().collectUseNumber();
Assert.assertEquals(1, PredefinedStyleInfoCollector.getInstance().getUseNumber());
}
@Test
public void testGenerateTotalInfo() {
PowerMock.mockStatic(DesignerEnvManager.class);
PowerMock.mockStatic(MarketConfig.class);
PowerMock.mockStatic(GeneralUtils.class);
DesignerEnvManager envManager = EasyMock.mock(DesignerEnvManager.class);
EasyMock.expect(envManager.getUUID()).andReturn("xxxxx-12345-xxxxx").once();
EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(envManager).once();
MarketConfig marketConfig = EasyMock.mock(MarketConfig.class);
BBSAttr bbsAttr = new BBSAttr();
bbsAttr.setBbsUid(12345);
EasyMock.expect(marketConfig.getBBSAttr()).andReturn(bbsAttr).once();
EasyMock.expect(MarketConfig.getInstance()).andReturn(marketConfig).once();
EasyMock.expect(GeneralUtils.readFullVersionNO()).andReturn("10.0.9.2020.0817.final");
EasyMock.replay(envManager, marketConfig);
PowerMock.replayAll();
String content = PredefinedStyleInfoCollector.getInstance().generateTotalInfo();
JSONObject jsonObject = JSONFactory.createJSON(JSON.OBJECT, content);
Assert.assertEquals("predefinedStyle", jsonObject.getString("functionName"));
Assert.assertEquals("FR-F7003", jsonObject.getString("functionId"));
Assert.assertEquals("xxxxx-12345-xxxxx", jsonObject.getString("uuid"));
Assert.assertEquals(12345, jsonObject.getInt("uid"));
Assert.assertEquals("10.0.9.2020.0817.final", jsonObject.getString("jatTime"));
}
}

2
designer-base/src/test/resources/com/fr/design/mainframe/predefined/info/predefinedStyle.info

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<PredefinedStyleInfo xmlVersion="20170720" releaseVersion="10.0.0" clickNumber="0" useNumber="0"/>

101
designer-form/src/main/java/com/fr/design/gui/xpane/FormPredefinedBackgroundPane.java

@ -0,0 +1,101 @@
package com.fr.design.gui.xpane;
import com.fr.config.predefined.BackgroundWithAlpha;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.predefined.ui.PredefinedStyleSettingPane;
import com.fr.design.mainframe.predefined.ui.detail.background.BackgroundWithAlphaSettingPane;
import com.fr.design.mainframe.predefined.ui.preview.StyleSettingPreviewPane;
import com.fr.form.ui.NameFormBackground;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.geom.Rectangle2D;
/**
* Created by kerry on 2020-09-02
*/
public class FormPredefinedBackgroundPane extends PredefinedStyleSettingPane<NameFormBackground> {
private BackgroundWithAlphaSettingPane backgroundPane;
@Override
protected StyleSettingPreviewPane createPreviewPane() {
return new PreviewPane();
}
@Override
protected JPanel createCustomDetailPane() {
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
backgroundPane = new BackgroundWithAlphaSettingPane();
backgroundPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
previewPane.refresh();
}
});
panel.add(backgroundPane, BorderLayout.CENTER);
return panel;
}
@Override
public void populateBean(NameFormBackground ob) {
this.setPopulating(true);
super.populate(ob);
this.backgroundPane.populateBean(ob.createRealStyle());
this.previewPane.refresh();
this.setPopulating(false);
}
@Override
public NameFormBackground updateBean() {
if (this.predefinedRadioBtn.isSelected()) {
return NameFormBackground.createPredefinedStyle(getPredefinedStyleName());
} else {
return NameFormBackground.createCustomStyle(this.backgroundPane.updateBean());
}
}
private BackgroundWithAlpha getCurrentValue() {
if (this.predefinedRadioBtn.isSelected()) {
NameFormBackground nameFormBackground = NameFormBackground.createPredefinedStyle(getPredefinedStyleName());
return nameFormBackground.createRealStyle();
} else {
return this.backgroundPane.updateBean();
}
}
@Override
public String title4PopupWindow() {
return null;
}
class PreviewPane extends StyleSettingPreviewPane {
private BackgroundWithAlpha background;
public PreviewPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setPreferredSize(new Dimension(390, 511));
this.setBackground(Color.WHITE);
}
public void refresh() {
background = getCurrentValue();
this.repaint();
}
@Override
public void paint(Graphics g) {
super.paint(g);
if (background != null && background.getBackground() != null) {
background.getBackground().paint(g, new Rectangle2D.Double(0, 0, this.getWidth(), this.getHeight()));
}
}
}
}

179
designer-form/src/main/java/com/fr/design/gui/xpane/PredefinedComponentStyleSettingPane.java

@ -0,0 +1,179 @@
package com.fr.design.gui.xpane;
import com.fr.config.predefined.PredefinedComponentStyle;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.predefined.ui.PredefinedStyleSettingPane;
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 com.fr.design.mainframe.predefined.ui.preview.StyleSettingPreviewPane;
import com.fr.design.widget.ui.designer.layout.ComponentStyle;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.NameLayoutBorderStyle;
import com.fr.form.ui.NamePaddingMargin;
import com.fr.form.ui.PaddingMargin;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
/**
* Created by kerry on 2020-09-02
*/
public class PredefinedComponentStyleSettingPane extends PredefinedStyleSettingPane<ComponentStyle> {
private StyleSettingPane styleSettingPane;
private TinyFormulaPane formulaPane;
@Override
protected StyleSettingPreviewPane createPreviewPane() {
return new PreviewPane();
}
protected JPanel createPredefinedSettingPane() {
JPanel jPanel = new JPanel();
jPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
jPanel.add(new UILabel("标题内容"));
formulaPane = new TinyFormulaPane();
formulaPane.setPreferredSize(new Dimension(158, 30));
jPanel.add(formulaPane);
return jPanel;
}
@Override
protected JPanel createCustomDetailPane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
styleSettingPane = new StyleSettingPane();
jPanel.add(styleSettingPane, BorderLayout.CENTER);
return jPanel;
}
@Override
public void populateBean(ComponentStyle ob) {
this.setPopulating(true);
NameLayoutBorderStyle layoutBorderStyle = ob.getNameLayoutBorderStyle();
super.populate(layoutBorderStyle);
this.formulaPane.populateBean(layoutBorderStyle.getTitleText().toString());
styleSettingPane.populateBean(ob);
this.previewPane.refresh();
this.setPopulating(false);
}
@Override
public ComponentStyle updateBean() {
if (predefinedRadioBtn.isSelected()) {
NameLayoutBorderStyle layoutBorderStyle = NameLayoutBorderStyle.createPredefinedStyle(getPredefinedStyleName());
layoutBorderStyle.setTitleText(formulaPane.updateBean());
return new ComponentStyle(layoutBorderStyle,
NamePaddingMargin.createPredefinedStyle(getPredefinedStyleName()));
}
return styleSettingPane.updateBean();
}
@Override
public String title4PopupWindow() {
return null;
}
class StyleSettingPane extends BasicBeanPane<ComponentStyle> {
private ComponentFrameStylePane frameStylePane;
private ComponentTitleStylePane titleStylePane;
private ComponentMarginStylePane marginStylePane;
public StyleSettingPane() {
initPane();
}
private void initPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel frame = FRGUIPaneFactory.createTitledBorderNoGapPane("框架");
frameStylePane = new ComponentFrameStylePane();
frame.add(createEmptyBorderScrollPane(frameStylePane, new Dimension(233, 183)));
JPanel title = FRGUIPaneFactory.createTitledBorderNoGapPane("标题");
titleStylePane = ComponentTitleStylePane.createStyleSettingPane();
title.add(createEmptyBorderScrollPane(titleStylePane, new Dimension(233, 140)));
JPanel margin = FRGUIPaneFactory.createTitledBorderNoGapPane("边距");
marginStylePane = new ComponentMarginStylePane();
marginStylePane.setPreferredSize(new Dimension(233, 100));
margin.add(marginStylePane);
this.add(frame, BorderLayout.NORTH);
this.add(title, BorderLayout.CENTER);
this.add(margin, BorderLayout.SOUTH);
}
private UIScrollPane createEmptyBorderScrollPane(JPanel panel, Dimension dimension) {
UIScrollPane scrollPane = new UIScrollPane(panel);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
scrollPane.setPreferredSize(dimension);
return scrollPane;
}
@Override
public void populateBean(ComponentStyle ob) {
PredefinedComponentStyle componentStyle = new PredefinedComponentStyle();
componentStyle.setBorderStyle(ob.getNameLayoutBorderStyle().createRealStyle());
PaddingMargin margin = ob.getNamePaddingMargin().createRealStyle();
componentStyle.setTop(margin.getTop());
componentStyle.setBottom(margin.getBottom());
componentStyle.setLeft(margin.getLeft());
componentStyle.setRight(margin.getRight());
frameStylePane.populate(componentStyle);
titleStylePane.populate(componentStyle);
marginStylePane.populate(componentStyle);
}
@Override
public ComponentStyle updateBean() {
PredefinedComponentStyle componentStyle = update();
NameLayoutBorderStyle nameLayoutBorderStyle = NameLayoutBorderStyle.createCustomStyle(componentStyle.getBorderStyle());
NamePaddingMargin namePaddingMargin = NamePaddingMargin.createCustomStyle(
new PaddingMargin(componentStyle.getTop(), componentStyle.getLeft(), componentStyle.getBottom(), componentStyle.getRight()));
return new ComponentStyle(nameLayoutBorderStyle, namePaddingMargin);
}
public PredefinedComponentStyle update() {
PredefinedComponentStyle componentStyle = new PredefinedComponentStyle();
frameStylePane.update(componentStyle);
titleStylePane.update(componentStyle);
marginStylePane.update(componentStyle);
return componentStyle;
}
@Override
protected String title4PopupWindow() {
return null;
}
}
class PreviewPane extends StyleSettingPreviewPane {
private LayoutBorderPreviewPane layoutBorderPreviewPane;
public PreviewPane() {
this.setPreferredSize(new Dimension(390, 511));
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.layoutBorderPreviewPane = new LayoutBorderPreviewPane(new LayoutBorderStyle());
this.add(this.layoutBorderPreviewPane, BorderLayout.CENTER);
}
public void refresh() {
ComponentStyle componentStyle = PredefinedComponentStyleSettingPane.this.updateBean();
NameLayoutBorderStyle borderStyle = componentStyle.getNameLayoutBorderStyle();
this.layoutBorderPreviewPane.repaint((LayoutBorderStyle) borderStyle.createRealStyle());
}
}
}

98
designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBodyBackgroundEditor.java

@ -0,0 +1,98 @@
package com.fr.design.mainframe.widget.accessibles;
import com.fr.design.Exception.ValidationException;
import com.fr.design.designer.properties.Decoder;
import com.fr.design.designer.properties.Encoder;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.xpane.FormPredefinedBackgroundPane;
import com.fr.design.mainframe.widget.editors.ITextComponent;
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer;
import com.fr.form.ui.NameFormBackground;
import javax.swing.SwingUtilities;
import java.awt.Dimension;
/**
* Created by kerry on 2020-09-02
*/
public class AccessibleBodyBackgroundEditor extends UneditableAccessibleEditor {
private FormPredefinedBackgroundPane backgroundPane;
public AccessibleBodyBackgroundEditor() {
super(new BackgroundStyleWrapper());
}
@Override
protected ITextComponent createTextField() {
return new RendererField(new BackgroundStyleRender());
}
@Override
protected void showEditorPane() {
if (backgroundPane == null) {
backgroundPane = new FormPredefinedBackgroundPane();
backgroundPane.setPreferredSize(new Dimension(600, 400));
}
BasicDialog dlg = backgroundPane.showWindow(SwingUtilities.getWindowAncestor(this));
dlg.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
setValue(backgroundPane.updateBean());
fireStateChanged();
}
});
backgroundPane.populateBean((NameFormBackground) getValue());
dlg.setVisible(true);
}
private static class BackgroundStyleWrapper implements Encoder, Decoder {
public BackgroundStyleWrapper() {
}
/**
* 将属性转化成字符串
*
* @param v 属性对象
* @return 字符串
*/
public String encode(Object v) {
if (v == null) {
return null;
}
NameFormBackground style = (NameFormBackground) v;
return style.isPredefinedStyle() ? "预定义" : "自定义";
}
/**
* 将字符串转化成属性
*
* @param txt 字符串
* @return 属性对象
*/
public Object decode(String txt) {
return null;
}
/**
* 符合规则
*
* @param txt 字符串
* @throws ValidationException 抛错
*/
public void validate(String txt) throws ValidationException {
}
}
private static class BackgroundStyleRender extends EncoderCellRenderer {
public BackgroundStyleRender() {
super(new BackgroundStyleWrapper());
}
}
}

99
designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleBorderStyleEditor.java

@ -0,0 +1,99 @@
package com.fr.design.mainframe.widget.accessibles;
import com.fr.design.Exception.ValidationException;
import com.fr.design.designer.properties.Decoder;
import com.fr.design.designer.properties.Encoder;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.xpane.PredefinedComponentStyleSettingPane;
import com.fr.design.mainframe.widget.editors.ITextComponent;
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer;
import com.fr.design.widget.ui.designer.layout.ComponentStyle;
import javax.swing.SwingUtilities;
import java.awt.Dimension;
/**
* Created by kerry on 2020-09-07
*/
public class AccessibleBorderStyleEditor extends UneditableAccessibleEditor {
private PredefinedComponentStyleSettingPane borderPane;
public AccessibleBorderStyleEditor() {
super(new ComponentStyleWrapper());
}
@Override
protected ITextComponent createTextField() {
return new RendererField(new ComponentStyleRenderer());
}
@Override
protected void showEditorPane() {
if (borderPane == null) {
borderPane = new PredefinedComponentStyleSettingPane();
borderPane.setPreferredSize(new Dimension(600, 400));
}
BasicDialog dlg = borderPane.showWindow(SwingUtilities.getWindowAncestor(this));
dlg.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
setValue(borderPane.updateBean());
fireStateChanged();
}
});
borderPane.populateBean((ComponentStyle) getValue());
dlg.setVisible(true);
}
private static class ComponentStyleWrapper implements Encoder, Decoder {
public ComponentStyleWrapper() {
}
/**
* 将属性转化成字符串
*
* @param v 属性对象
* @return 字符串
*/
public String encode(Object v) {
if (v == null) {
return null;
}
ComponentStyle style = (ComponentStyle) v;
return style.isPredefinedStyle() ? "预定义" : "自定义";
}
/**
* 将字符串转化成属性
*
* @param txt 字符串
* @return 属性对象
*/
public Object decode(String txt) {
return null;
}
/**
* 符合规则
*
* @param txt 字符串
* @throws ValidationException 抛错
*/
public void validate(String txt) throws ValidationException {
}
}
private static class ComponentStyleRenderer extends EncoderCellRenderer {
public ComponentStyleRenderer() {
super(new ComponentStyleWrapper());
}
}
}

83
designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleWLayoutBorderStyleEditor.java

@ -4,33 +4,35 @@
package com.fr.design.mainframe.widget.accessibles;
import com.fr.design.Exception.ValidationException;
import com.fr.design.designer.properties.Decoder;
import com.fr.design.designer.properties.Encoder;
import com.fr.design.gui.xpane.PredefinedComponentStyleSettingPane;
import com.fr.design.mainframe.widget.editors.ITextComponent;
import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer;
import com.fr.design.mainframe.widget.wrappers.LayoutBorderStyleWrapper;
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.xpane.LayoutBorderPane;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.design.widget.ui.designer.layout.ComponentStyle;
import javax.swing.*;
import java.awt.*;
import javax.swing.SwingUtilities;
import java.awt.Dimension;
public class AccessibleWLayoutBorderStyleEditor extends UneditableAccessibleEditor {
private LayoutBorderPane borderPane;
private PredefinedComponentStyleSettingPane borderPane;
public AccessibleWLayoutBorderStyleEditor() {
super(new LayoutBorderStyleWrapper());
super(new ComponentStyleWrapper());
}
@Override
protected ITextComponent createTextField() {
return new RendererField(new LayoutBorderStyleRenderer());
return new RendererField(new ComponentStyleRenderer());
}
@Override
protected void showEditorPane() {
if (borderPane == null) {
borderPane = new LayoutBorderPane();
borderPane = new PredefinedComponentStyleSettingPane();
borderPane.setPreferredSize(new Dimension(600, 400));
}
BasicDialog dlg = borderPane.showWindow(SwingUtilities.getWindowAncestor(this));
@ -38,11 +40,62 @@ public class AccessibleWLayoutBorderStyleEditor extends UneditableAccessibleEdit
@Override
public void doOk() {
setValue(borderPane.update());
setValue(borderPane.updateBean());
fireStateChanged();
}
});
borderPane.populate((LayoutBorderStyle)getValue());
borderPane.populateBean((ComponentStyle) getValue());
dlg.setVisible(true);
}
}
private static class ComponentStyleWrapper implements Encoder, Decoder {
public ComponentStyleWrapper() {
}
/**
* 将属性转化成字符串
*
* @param v 属性对象
* @return 字符串
*/
public String encode(Object v) {
if (v == null) {
return null;
}
ComponentStyle style = (ComponentStyle) v;
//todo
return "标准";
}
/**
* 将字符串转化成属性
*
* @param txt 字符串
* @return 属性对象
*/
public Object decode(String txt) {
return null;
}
/**
* 符合规则
*
* @param txt 字符串
* @throws ValidationException 抛错
*/
public void validate(String txt) throws ValidationException {
}
}
private static class ComponentStyleRenderer extends EncoderCellRenderer {
public ComponentStyleRenderer() {
super(new ComponentStyleWrapper());
}
}
}

14
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/BorderStyleWidgetDefinePane.java

@ -7,10 +7,9 @@ import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor;
import com.fr.design.mainframe.widget.accessibles.AccessibleBorderStyleEditor;
import com.fr.design.widget.ui.designer.AbstractDataModify;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.LayoutBorderStyle;
import javax.swing.*;
@ -20,7 +19,7 @@ import java.awt.*;
* Created by kerry on 2017/8/29.
*/
public class BorderStyleWidgetDefinePane extends AbstractDataModify<AbstractBorderStyleWidget> {
private AccessibleWLayoutBorderStyleEditor borderStyleEditor;
private AccessibleBorderStyleEditor borderStyleEditor;
public BorderStyleWidgetDefinePane(XCreator xCreator) {
super(xCreator);
@ -29,7 +28,7 @@ public class BorderStyleWidgetDefinePane extends AbstractDataModify<AbstractBord
public void initComponent() {
borderStyleEditor = new AccessibleWLayoutBorderStyleEditor();
borderStyleEditor = new AccessibleBorderStyleEditor();
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel advancePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{
@ -50,14 +49,17 @@ public class BorderStyleWidgetDefinePane extends AbstractDataModify<AbstractBord
@Override
public void populateBean(AbstractBorderStyleWidget ob) {
borderStyleEditor.setValue(ob.getBorderStyle());
ComponentStyle componentStyle = new ComponentStyle(ob.getNameBorderStyle(), ob.getNameMargin());
borderStyleEditor.setValue(componentStyle);
}
@Override
public AbstractBorderStyleWidget updateBean() {
AbstractBorderStyleWidget abstractBorderStyleWidget = (AbstractBorderStyleWidget)creator.toData();
abstractBorderStyleWidget.setBorderStyle((LayoutBorderStyle) borderStyleEditor.getValue());
ComponentStyle componentStyle = (ComponentStyle) borderStyleEditor.getValue();
abstractBorderStyleWidget.setNameBorderStyle(componentStyle.getNameLayoutBorderStyle());
abstractBorderStyleWidget.setNameMargin(componentStyle.getNamePaddingMargin());
return abstractBorderStyleWidget;
}

35
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ComponentStyle.java

@ -0,0 +1,35 @@
package com.fr.design.widget.ui.designer.layout;
import com.fr.config.AbstractPredefinedNameStyleProvider;
import com.fr.form.ui.NameLayoutBorderStyle;
import com.fr.form.ui.NamePaddingMargin;
/**
* Created by kerry on 2020-09-02
*/
public class ComponentStyle extends AbstractPredefinedNameStyleProvider {
private NamePaddingMargin namePaddingMargin;
private NameLayoutBorderStyle nameLayoutBorderStyle;
public ComponentStyle(NameLayoutBorderStyle nameLayoutBorderStyle, NamePaddingMargin namePaddingMargin) {
this.nameLayoutBorderStyle = nameLayoutBorderStyle;
this.namePaddingMargin = namePaddingMargin;
}
public NamePaddingMargin getNamePaddingMargin() {
return namePaddingMargin;
}
public NameLayoutBorderStyle getNameLayoutBorderStyle() {
return nameLayoutBorderStyle;
}
public boolean isPredefinedStyle() {
return this.nameLayoutBorderStyle.isPredefinedStyle();
}
}

11
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java

@ -6,12 +6,8 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.accessibles.AccessibleElementCaseToolBarEditor;
import com.fr.design.widget.ui.designer.component.PaddingBoundPane;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.web.FormToolBarManager;
import com.fr.general.ComparatorUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
@ -21,7 +17,6 @@ import java.awt.Component;
* Created by ibm on 2017/8/7.
*/
public class ElementEditorDefinePane extends WTitleLayoutDefinePane<ElementCaseEditor> {
private PaddingBoundPane paddingBoundPane;
private AccessibleElementCaseToolBarEditor elementCaseToolBarEditor;
private PropertyGroupPane extraPropertyGroupPane;
@ -32,10 +27,8 @@ public class ElementEditorDefinePane extends WTitleLayoutDefinePane<ElementCaseE
protected JPanel createCenterPane() {
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
paddingBoundPane = new PaddingBoundPane();
elementCaseToolBarEditor = new AccessibleElementCaseToolBarEditor();
Component[][] components = new Component[][]{
new Component[]{paddingBoundPane, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_EC_Toolbar")), elementCaseToolBarEditor},
};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1);
@ -49,16 +42,12 @@ public class ElementEditorDefinePane extends WTitleLayoutDefinePane<ElementCaseE
protected ElementCaseEditor updateSubBean() {
ElementCaseEditor elementCaseEditor = (ElementCaseEditor) creator.toData();
if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) {
paddingBoundPane.update(elementCaseEditor);
}
elementCaseEditor.setToolBars((FormToolBarManager[]) elementCaseToolBarEditor.getValue());
return elementCaseEditor;
}
protected void populateSubBean(ElementCaseEditor ob) {
paddingBoundPane.populate(ob);
elementCaseToolBarEditor.setValue(ob.getToolBars());
extraPropertyGroupPane.populate(ob);
}

23
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java

@ -15,12 +15,13 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.accessibles.AccessibleBodyBackgroundEditor;
import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor;
import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor;
import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.design.widget.ui.designer.component.WidgetBoundPane;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.NameFormBackground;
import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WBodyLayoutType;
@ -38,7 +39,7 @@ import java.awt.Component;
public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
private static final int MAX_LABEL_WIDTH = 80;
private AccessibleWLayoutBorderStyleEditor borderStyleEditor;
private AccessibleBodyBackgroundEditor backgroundEditor;
private AccessibleBodyWatermarkEditor watermarkEditor;
private WidgetBoundPane boundPane;
@ -55,11 +56,11 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
boundPane = new WidgetBoundPane(creator);
centerPane.add(boundPane, BorderLayout.CENTER);
borderStyleEditor = new AccessibleWLayoutBorderStyleEditor();
backgroundEditor = new AccessibleBodyBackgroundEditor();
watermarkEditor = new AccessibleBodyWatermarkEditor();
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style")), borderStyleEditor},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style")), backgroundEditor},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor}
}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1);
JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -113,7 +114,10 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
public void populateSubPane(WAbsoluteLayout ob) {
layoutCombox.setSelectedIndex(1);
borderStyleEditor.setValue(ob.getBorderStyle());
NameFormBackground formBackground = ob.getNameBackground();
formBackground.setBackgroundAlphaValue(ob.getBorderStyle().getAlpha());
backgroundEditor.setValue(formBackground);
boundPane.populate();
watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile()));
}
@ -136,7 +140,14 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
copyLayoutAttr(layout, xwFitLayout.toData());
}
}
layout.setBorderStyle((LayoutBorderStyle) borderStyleEditor.getValue());
LayoutBorderStyle borderStyle = new LayoutBorderStyle();
NameFormBackground background = (NameFormBackground) backgroundEditor.getValue();
if (background != null) {
borderStyle.setBackground(background.createRealStyle().getBackground());
borderStyle.setAlpha(background.createRealStyle().getAlpha());
}
layout.setBorderStyle(borderStyle);
layout.setNameBackground(background);
updateWatermark();
return layout;
}

22
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java

@ -22,12 +22,13 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.accessibles.AccessibleBodyBackgroundEditor;
import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor;
import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor;
import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.design.widget.ui.designer.component.PaddingBoundPane;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.NameFormBackground;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteBodyLayout;
import com.fr.form.ui.container.WAbsoluteLayout;
@ -55,7 +56,7 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
private UIComboBox adaptComboBox;
private UISpinner componentIntervel;
private PaddingBoundPane paddingBound;
private AccessibleWLayoutBorderStyleEditor stylePane;
private AccessibleBodyBackgroundEditor stylePane;
private AccessibleBodyWatermarkEditor watermarkEditor;
public FRFitLayoutDefinePane(XCreator xCreator) {
@ -77,7 +78,7 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
public JPanel createAdvancePane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
stylePane = new AccessibleWLayoutBorderStyleEditor();
stylePane = new AccessibleBodyBackgroundEditor();
watermarkEditor = new AccessibleBodyWatermarkEditor();
paddingBound = new PaddingBoundPane();
JPanel jp2 = TableLayoutHelper.createGapTableLayoutPane(
@ -154,7 +155,9 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
layoutComboBox.setSelectedIndex(ob.getBodyLayoutType().getTypeValue());
adaptComboBox.setSelectedIndex(ob.getCompState());
componentIntervel.setValue(ob.getCompInterval());
stylePane.setValue(ob.getBorderStyle());
NameFormBackground formBackground = ob.getNameBackground();
formBackground.setBackgroundAlphaValue(ob.getBorderStyle().getAlpha());
stylePane.setValue(formBackground);
watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile()));
}
@ -173,10 +176,15 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) {
paddingBound.update(layout);
}
LayoutBorderStyle borderStyle = (LayoutBorderStyle) stylePane.getValue();
if (borderStyle != null) {
layout.setBorderStyle(borderStyle);
LayoutBorderStyle borderStyle = new LayoutBorderStyle();
NameFormBackground background = (NameFormBackground) stylePane.getValue();
if (background != null) {
borderStyle.setBackground(background.createRealStyle().getBackground());
borderStyle.setAlpha(background.createRealStyle().getAlpha());
}
layout.setBorderStyle(borderStyle);
layout.setNameBackground(background);
updateWatermark();
Item item = (Item) layoutComboBox.getSelectedItem();
Object value = item.getValue();

19
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WTitleLayoutDefinePane.java

@ -7,13 +7,9 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor;
import com.fr.design.mainframe.widget.accessibles.AccessibleBorderStyleEditor;
import com.fr.design.widget.ui.designer.AbstractDataModify;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.general.ComparatorUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
@ -24,7 +20,7 @@ import java.awt.Component;
* Created by ibm on 2017/8/3.
*/
public abstract class WTitleLayoutDefinePane<T extends AbstractBorderStyleWidget> extends AbstractDataModify<T> {
private AccessibleWLayoutBorderStyleEditor borderStyleEditor;
private AccessibleBorderStyleEditor borderStyleEditor;
public WTitleLayoutDefinePane(XCreator xCreator) {
super(xCreator);
@ -34,7 +30,7 @@ public abstract class WTitleLayoutDefinePane<T extends AbstractBorderStyleWidget
public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel advancePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
borderStyleEditor = new AccessibleWLayoutBorderStyleEditor();
borderStyleEditor = new AccessibleBorderStyleEditor();
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p};
@ -69,16 +65,17 @@ public abstract class WTitleLayoutDefinePane<T extends AbstractBorderStyleWidget
@Override
public void populateBean(T ob) {
populateSubBean(ob);
borderStyleEditor.setValue(ob.getBorderStyle());
ComponentStyle componentStyle = new ComponentStyle(ob.getNameBorderStyle(), ob.getNameMargin());
borderStyleEditor.setValue(componentStyle);
}
@Override
public T updateBean() {
T e = updateSubBean();
if(!ComparatorUtils.equals(borderStyleEditor.getValue(), e.getBorderStyle())){
e.setBorderStyle((LayoutBorderStyle) borderStyleEditor.getValue());
}
ComponentStyle componentStyle = (ComponentStyle) borderStyleEditor.getValue();
e.setNameBorderStyle(componentStyle.getNameLayoutBorderStyle());
e.setNameMargin(componentStyle.getNamePaddingMargin());
return e;
}

11
designer-realize/src/main/java/com/fr/design/actions/report/ReportBackgroundAction.java

@ -5,12 +5,11 @@ package com.fr.design.actions.report;
import com.fr.base.BaseUtils;
import com.fr.design.actions.ReportComponentAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ReportComponent;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.report.ReportBackgroundPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.report.ReportPredefinedBackgroundPane;
import com.fr.report.core.ReportUtils;
/**
@ -35,16 +34,16 @@ public class ReportBackgroundAction extends ReportComponentAction<ReportComponen
if (reportPane == null) {
return false;
}
final ReportBackgroundPane bPane = new ReportBackgroundPane();
bPane.populate(ReportUtils.getReportSettings(reportPane.getTemplateReport()));
final ReportPredefinedBackgroundPane bPane = new ReportPredefinedBackgroundPane();
bPane.populateBean(ReportUtils.getReportSettings(reportPane.getTemplateReport()));
bPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
bPane.update(reportPane.getTemplateReport().getReportSettings());
bPane.updateBean(reportPane.getTemplateReport().getReportSettings());
reportPane.fireTargetModified();
}
}).setVisible(true);
return false;
}
}
}

52
designer-realize/src/main/java/com/fr/design/actions/server/predefined/ServerPredefinedStyleAction.java

@ -0,0 +1,52 @@
package com.fr.design.actions.server.predefined;
import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.server.StyleManagerPane;
import com.fr.design.mainframe.predefined.ui.dialog.ServerPredefinedStyleDialog;
import com.fr.design.mainframe.predefined.ui.ServerPredefinedStylePane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.IOUtils;
import javax.swing.KeyStroke;
import java.awt.event.ActionEvent;
/**
* Created by kerry on 2020-08-26
*/
public class ServerPredefinedStyleAction extends UpdateAction {
public ServerPredefinedStyleAction() {
this.setMenuKeySet(PREDEFINED_STYLES);
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/m_web/style.png"));
this.generateAndSetSearchText(StyleManagerPane.class.getName());
}
@Override
public void actionPerformed(ActionEvent e) {
DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
ServerPredefinedStylePane predefinedStylePane = new ServerPredefinedStylePane();
ServerPredefinedStyleDialog dialog = new ServerPredefinedStyleDialog(designerFrame, predefinedStylePane);
dialog.setVisible(true);
}
public static final MenuKeySet PREDEFINED_STYLES = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'K';
}
@Override
public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("服务器预定义样式");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}

4
designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java

@ -11,6 +11,7 @@ import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.design.mainframe.errorinfo.ErrorInfoUploader;
import com.fr.design.mainframe.messagecollect.impl.FocusPointMessageUploader;
import com.fr.design.mainframe.messagecollect.solid.SolidCollector;
import com.fr.design.mainframe.predefined.info.PredefinedStyleInfoCollector;
import com.fr.design.mainframe.template.info.TemplateInfoCollector;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils;
@ -241,6 +242,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
TemplateInfoCollector.getInstance().sendPointInfo();
ChartInfoCollector.getInstance().sendPointInfo();
ErrorInfoUploader.getInstance().sendErrorInfo();
PredefinedStyleInfoCollector.getInstance().sendPointInfo();
}
}, SEND_DELAY, TimeUnit.MILLISECONDS);
service.shutdown();
@ -404,4 +406,4 @@ public class InformationCollector implements XMLReadable, XMLWriter {
}
}
}
}

4
designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java

@ -153,6 +153,10 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
populateReportParameterAttr();
}
public void resetPreferenceStyle(){
}
@Override
protected void addPane(PropertyItemPaneProvider provider) {
PaneHolder<JWorkBook> holder = provider.getPaneHolder(JWorkBook.class);

87
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java

@ -1,8 +1,9 @@
package com.fr.design.mainframe.cell.settingpane;
import com.fr.base.NameStyle;
import com.fr.base.Style;
import com.fr.design.constants.UIConstants;
import com.fr.design.mainframe.cell.settingpane.style.StylePane;
import com.fr.design.mainframe.cell.settingpane.style.CellPredefinedStyleSettingPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.report.cell.DefaultTemplateCellElement;
@ -10,8 +11,6 @@ import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.TemplateElementCase;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
/**
@ -19,26 +18,15 @@ import java.awt.*;
* @since 2012-5-11下午3:59:39
*/
public class CellStylePane extends AbstractCellAttrPane {
private StylePane stylePane;
private CellPredefinedStyleSettingPane stylePane;
@Override
public JPanel createContentPane() {
JPanel content = new JPanel(new BorderLayout());
stylePane = new StylePane();
content.setBorder(BorderFactory.createEmptyBorder());
stylePane = new CellPredefinedStyleSettingPane();
content.add(stylePane, BorderLayout.CENTER);
stylePane.setBorder(UIConstants.CELL_ATTR_PRESENTBORDER);
stylePane.addPredefinedChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
attributeChanged();
}
});
stylePane.addCustomTabChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
adjustValues();// 里面的Tab切换后要及时调整滚动条,因为一些界面可能不需要滚动条
}
});
return content;
}
@ -67,56 +55,36 @@ public class CellStylePane extends AbstractCellAttrPane {
@Override
public void updateBeans() {
if (stylePane.getSelectedIndex() == 1) {
Style s = stylePane.updateBean();
TemplateElementCase elementCase = elementCasePane.getEditingElementCase();
int cellRectangleCount = cs.getCellRectangleCount();
for (int rect = 0; rect < cellRectangleCount; rect++) {
Rectangle cellRectangle = cs.getCellRectangle(rect);
for (int j = 0; j < cellRectangle.height; j++) {
for (int i = 0; i < cellRectangle.width; i++) {
int column = i + cellRectangle.x;
int row = j + cellRectangle.y;
TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row);
if (cellElement == null) {
cellElement = new DefaultTemplateCellElement(column, row);
elementCase.addCellElement(cellElement);
}
cellElement.setStyle(s);
}
}
}
} else {
TemplateElementCase elementCase = elementCasePane.getEditingElementCase();
int cellRectangleCount = cs.getCellRectangleCount();
for (int rect = 0; rect < cellRectangleCount; rect++) {
Rectangle cellRectangle = cs.getCellRectangle(rect);
for (int j = 0; j < cellRectangle.height; j++) {
for (int i = 0; i < cellRectangle.width; i++) {
int column = i + cellRectangle.x;
int row = j + cellRectangle.y;
TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row);
if (cellElement == null) {
cellElement = new DefaultTemplateCellElement(column, row);
elementCase.addCellElement(cellElement);
}
Style style = cellElement.getStyle();
if (style == null) {
style = Style.DEFAULT_STYLE;
}
style = stylePane.updateStyle(style);
cellElement.setStyle(style);
NameStyle s = stylePane.updateBean();
TemplateElementCase elementCase = elementCasePane.getEditingElementCase();
int cellRectangleCount = cs.getCellRectangleCount();
for (int rect = 0; rect < cellRectangleCount; rect++) {
Rectangle cellRectangle = cs.getCellRectangle(rect);
for (int j = 0; j < cellRectangle.height; j++) {
for (int i = 0; i < cellRectangle.width; i++) {
int column = i + cellRectangle.x;
int row = j + cellRectangle.y;
TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row);
if (cellElement == null) {
cellElement = new DefaultTemplateCellElement(column, row);
elementCase.addCellElement(cellElement);
}
cellElement.setStyle(s);
}
}
stylePane.updateBorder();// border必须特别处理
}
stylePane.updateBorder();// border必须特别处理
}
@Override
protected void populateBean() {
stylePane.populateBean(cellElement.getStyle());
Style style = cellElement.getStyle();
if (style instanceof NameStyle) {
stylePane.populateBean((NameStyle) style);
} else {
//说明是未经过转换的
stylePane.populateBean(NameStyle.createCustomStyle(cellElement.getStyle()));
}
stylePane.dealWithBorder(elementCasePane);
}
@ -126,7 +94,6 @@ public class CellStylePane extends AbstractCellAttrPane {
}
public void setSelectedByIds(int level, String... id) {
stylePane.setSelctedByName(id[level]);
}
}

234
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CellPredefinedStyleSettingPane.java

@ -0,0 +1,234 @@
package com.fr.design.mainframe.cell.settingpane.style;
import com.fr.base.CellBorderStyle;
import com.fr.base.NameStyle;
import com.fr.base.Style;
import com.fr.config.predefined.PredefinedStyle;
import com.fr.config.ServerPreferenceConfig;
import com.fr.config.StyleMap;
import com.fr.design.actions.utils.ReportActionUtils;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.MultiTabPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.style.AbstractBasicStylePane;
import com.fr.design.gui.style.AlignmentPane;
import com.fr.design.gui.style.BackgroundPane;
import com.fr.design.gui.style.BorderPane;
import com.fr.design.gui.style.FormatPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.predefined.ui.PredefinedStyleSettingPane;
import com.fr.design.mainframe.predefined.ui.preview.StyleSettingPreviewPane;
import com.fr.design.style.BorderUtils;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Created by kerry on 2020-09-02
*/
public class CellPredefinedStyleSettingPane extends PredefinedStyleSettingPane<NameStyle> {
private CustomStylePane customPredefinedStylePane;
private UIComboBox applicationFormat;
@Override
protected StyleSettingPreviewPane createPreviewPane() {
return null;
}
@Override
protected JPanel createCustomDetailPane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
customPredefinedStylePane = new CustomStylePane();
jPanel.add(customPredefinedStylePane, BorderLayout.CENTER);
return jPanel;
}
protected JPanel createPredefinedSettingPane() {
JPanel jPanel = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(10, 44, 10);
jPanel.add(new UILabel("应用格式"));
applicationFormat = new UIComboBox();
applicationFormat.setPreferredSize(new Dimension(80, 30));
jPanel.add(applicationFormat);
return jPanel;
}
@Override
public String title4PopupWindow() {
return null;
}
@Override
public void populateBean(NameStyle ob) {
this.setPopulating(true);
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
super.populate(ob);
PredefinedStyle predefinedStyle = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig().getStyle(template.getTemplatePredefinedStyle());
StyleMap map = predefinedStyle.getCellStyleMap();
Map<String, Style> allStyle = map.getAllStyles();
this.applicationFormat.clearBoxItems();
for (String name : allStyle.keySet()) {
this.applicationFormat.addItem(name);
}
if (allStyle.containsKey(ob.getName())) {
this.applicationFormat.setSelectedItem(ob.getName());
}
this.customPredefinedStylePane.populateBean(ob);
this.setPopulating(false);
}
public void dealWithBorder(ElementCasePane ePane) {
this.customPredefinedStylePane.dealWithBorder(ePane);
}
public void updateBorder() {
this.customPredefinedStylePane.updateBorder();
}
@Override
public NameStyle updateBean() {
NameStyle nameStyle = null;
if (this.predefinedRadioBtn.isSelected()) {
Object selectItem = this.applicationFormat.getSelectedItem();
nameStyle = NameStyle.createPredefinedStyle(getPredefinedStyleName(), selectItem == null ? StringUtils.EMPTY : selectItem.toString(), Style.getInstance());
} else {
Style style = this.customPredefinedStylePane.updateBean();
if (!(style instanceof NameStyle)) {
nameStyle = NameStyle.createCustomStyle(style);
}
}
return nameStyle;
}
class CustomStylePane extends MultiTabPane<Style> {
private static final int LENGTH_FOUR = 4;
private static final int THREE_INDEX = 3;
private static final int ONE_INDEX = 1;
private ElementCasePane reportPane;
private BackgroundPane backgroundPane = null;
public CustomStylePane() {
super();
tabPane.setOneLineTab(true);
tabPane.setDrawLine(false);
tabPane.setBorder(BorderFactory.createLineBorder(UIConstants.SHADOW_GREY));
tabPane.setLayout(new GridLayout(1, 3, 0, 0));
}
/**
* @return
*/
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Custom_Style");
}
/**
*
*/
public void reset() {
populateBean(null);
}
@Override
/**
*
*/
public void populateBean(Style ob) {
for (int i = 0; i < paneList.size(); i++) {
((AbstractBasicStylePane) paneList.get(i)).populateBean(ob);
}
}
@Override
/**
*
*/
public Style updateBean() {
return updateStyle(ReportActionUtils.getCurrentStyle(reportPane));
}
/**
* @param style
* @return
*/
public Style updateStyle(Style style) {
return ((AbstractBasicStylePane) paneList.get(tabPane.getSelectedIndex())).update(style);//只更新当前选中面板的样式
}
public boolean isBorderPaneSelected() {
return tabPane.getSelectedIndex() == ONE_INDEX;
}
/**
* @param ePane
*/
public void dealWithBorder(ElementCasePane ePane) {
this.reportPane = ePane;
Object[] fourObjectArray = BorderUtils.createCellBorderObject(reportPane);
if (fourObjectArray != null && fourObjectArray.length % LENGTH_FOUR == 0) {
if (fourObjectArray.length == LENGTH_FOUR) {
((BorderPane) paneList.get(ONE_INDEX)).populateBean((CellBorderStyle) fourObjectArray[0], ((Boolean) fourObjectArray[1]).booleanValue(), ((Integer) fourObjectArray[2]).intValue(),
(Color) fourObjectArray[THREE_INDEX]);
} else {
((BorderPane) paneList.get(ONE_INDEX)).populateBean(new CellBorderStyle(), Boolean.TRUE, Constants.LINE_NONE,
(Color) fourObjectArray[THREE_INDEX]);
}
}
}
/**
*
*/
public void updateBorder() {
BorderUtils.update(reportPane, ((BorderPane) paneList.get(ONE_INDEX)).update());
}
/**
* @param ob
* @return
*/
public boolean accept(Object ob) {
return ob instanceof Style && !(ob instanceof NameStyle);
}
@Override
protected List<BasicPane> initPaneList() {
paneList = new ArrayList<BasicPane>();
paneList.add(new FormatPane());
paneList.add(new BorderPane());
paneList.add(new AlignmentPane());
return paneList;
}
@Override
/**
*
*/
public void updateBean(Style ob) {
return;
}
}
}

128
designer-realize/src/main/java/com/fr/design/report/ReportPredefinedBackgroundPane.java

@ -0,0 +1,128 @@
package com.fr.design.report;
import com.fr.base.NameBackground;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.predefined.ui.PredefinedStyleSettingPane;
import com.fr.design.mainframe.predefined.ui.detail.background.BackgroundSettingPane;
import com.fr.design.mainframe.predefined.ui.preview.StyleSettingPreviewPane;
import com.fr.general.Background;
import com.fr.page.ReportSettingsProvider;
import com.fr.report.stable.ReportSettings;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.geom.Rectangle2D;
/**
* Created by kerry on 2020-09-02
*/
public class ReportPredefinedBackgroundPane extends PredefinedStyleSettingPane<ReportSettingsProvider> {
private UICheckBox isPrintBackgroundCheckBox;
private UICheckBox isExportBackgroundCheckBox;
private BackgroundSettingPane backgroundPane;
public ReportPredefinedBackgroundPane() {
super();
JPanel sourth = new JPanel();
isPrintBackgroundCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Print_Background"));
isExportBackgroundCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Export_Background"));
sourth.add(isExportBackgroundCheckBox);
sourth.add(isPrintBackgroundCheckBox);
this.add(sourth, BorderLayout.SOUTH);
}
@Override
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Background");
}
@Override
protected StyleSettingPreviewPane createPreviewPane() {
return new PreviewPane();
}
@Override
protected JPanel createCustomDetailPane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
backgroundPane = new BackgroundSettingPane();
backgroundPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
previewPane.refresh();
}
});
jPanel.add(backgroundPane, BorderLayout.CENTER);
return jPanel;
}
@Override
public void populateBean(ReportSettingsProvider reportSettings) {
this.setPopulating(true);
NameBackground nameBackground = reportSettings.getNameBackground();
super.populate(nameBackground);
this.backgroundPane.populateBean(reportSettings.getBackground());
this.isPrintBackgroundCheckBox.setSelected(reportSettings.isPrintBackground());
this.isExportBackgroundCheckBox.setSelected(reportSettings.isExportBackground());
this.previewPane.refresh();
this.setPopulating(false);
}
@Override
public ReportSettingsProvider updateBean() {
return null;
}
public void updateBean(ReportSettingsProvider reportSettings) {
if (this.predefinedRadioBtn.isSelected()) {
((ReportSettings) reportSettings).setNameBackground(NameBackground.createPredefinedStyle(getPredefinedStyleName()));
} else {
reportSettings.setBackground(this.backgroundPane.updateBean());
}
reportSettings.setPrintBackground(this.isPrintBackgroundCheckBox.isSelected());
reportSettings.setExportBackground(this.isExportBackgroundCheckBox.isSelected());
}
private Background getCurrentValue() {
if (this.predefinedRadioBtn.isSelected()) {
NameBackground nameReportBackground = NameBackground.createPredefinedStyle(getPredefinedStyleName());
return nameReportBackground.createRealStyle();
} else {
return this.backgroundPane.updateBean();
}
}
class PreviewPane extends StyleSettingPreviewPane {
private Background background;
public PreviewPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setPreferredSize(new Dimension(390, 478));
this.setBackground(Color.WHITE);
}
public void refresh() {
background = getCurrentValue();
this.repaint();
}
@Override
public void paint(Graphics g) {
super.paint(g);
if (background != null) {
background.paint(g, new Rectangle2D.Double(0, 0, this.getWidth(), this.getHeight()));
}
}
}
}

7
designer-realize/src/main/java/com/fr/grid/GridUI.java

@ -11,6 +11,7 @@ import com.fr.base.background.ImageFileBackground;
import com.fr.base.iofile.attr.WatermarkAttr;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.constants.UIConstants;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ElementCasePane;
@ -166,6 +167,8 @@ public class GridUI extends ComponentUI {
- reportSettings.getFooterHeight().toPixD(resolution);
}
//绘制背景之前需要先将全局预定义样式名称刷新到报表配置中
reportSettings.getNameBackground().resetPreferenceStyle(getGlobalPredefinedStyleName());
// denny:画背景.Background
Background background = reportSettings.getBackground();
@ -180,6 +183,10 @@ public class GridUI extends ComponentUI {
}
}
private String getGlobalPredefinedStyleName(){
return HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplatePredefinedStyle();
}
private void clearBackground(Graphics2D g2d, Grid grid) {
if (grid.isEnabled()) {
g2d.setPaint(Color.WHITE);

4
designer-realize/src/main/java/com/fr/start/MainDesigner.java

@ -7,6 +7,7 @@ import com.fr.design.actions.file.WebPreviewUtils;
import com.fr.design.actions.file.newReport.NewPolyReportAction;
import com.fr.design.actions.file.newReport.NewWorkBookAction;
import com.fr.design.actions.server.ServerConfigManagerAction;
import com.fr.design.actions.server.predefined.ServerPredefinedStyleAction;
import com.fr.design.actions.server.StyleListAction;
import com.fr.design.actions.server.WidgetManagerAction;
import com.fr.design.base.mode.DesignModeContext;
@ -161,7 +162,8 @@ public class MainDesigner extends BaseDesigner {
menuDef.addShortCut(SeparatorDef.DEFAULT);
if (WorkContext.getCurrent().isRoot()) {
menuDef.addShortCut(new ServerConfigManagerAction(), new StyleListAction(), new WidgetManagerAction());
menuDef.addShortCut(new ServerConfigManagerAction(), new ServerPredefinedStyleAction(),
new WidgetManagerAction());
menuDef.addShortCut(new ChartPreStyleAction(), new ChartEmptyDataStyleAction(),new ChartMapEditorAction());
}

Loading…
Cancel
Save