Browse Source

confilicts

bugfix/11.0
zheng 3 years ago
parent
commit
c98265cb7b
  1. 7
      build.gradle
  2. 2
      designer-base/src/main/java/com/fr/design/DesignModelAdapter.java
  3. 45
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  4. 8
      designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java
  5. 47
      designer-base/src/main/java/com/fr/design/actions/file/BatchCompileAction.java
  6. 29
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  7. 8
      designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java
  8. 4
      designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java
  9. 49
      designer-base/src/main/java/com/fr/design/actions/server/LocalAnalyzerAction.java
  10. 76
      designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java
  11. 12
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  12. 136
      designer-base/src/main/java/com/fr/design/data/StrategyConfigAttrUtils.java
  13. 226
      designer-base/src/main/java/com/fr/design/data/datapane/ESDStrategyConfigPane.java
  14. 735
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java
  15. 10
      designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java
  16. 26
      designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataDictPane.java
  17. 37
      designer-base/src/main/java/com/fr/design/data/tabledata/strategy/StrategyConfigHandler.java
  18. 551
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  19. 3
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java
  20. 33
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/db/StrategyConfigFrom.java
  21. 14
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  22. 26
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  23. 330
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  24. 54
      designer-base/src/main/java/com/fr/design/formula/UnsupportedFormulaScanner.java
  25. 19
      designer-base/src/main/java/com/fr/design/fun/PcFitProvider.java
  26. 9
      designer-base/src/main/java/com/fr/design/fun/PreviewProvider.java
  27. 19
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractPcFitProvider.java
  28. 28
      designer-base/src/main/java/com/fr/design/fun/impl/DesignerStartWithEmptyFile.java
  29. 11
      designer-base/src/main/java/com/fr/design/gui/frpane/JTreeAutoBuildPane.java
  30. 21
      designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java
  31. 19
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java
  32. 36
      designer-base/src/main/java/com/fr/design/gui/ibutton/UINoThemeColorButton.java
  33. 20
      designer-base/src/main/java/com/fr/design/gui/icombobox/ColorSchemeComboBox.java
  34. 22
      designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java
  35. 2
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java
  36. 12
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java
  37. 2
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/ReportletPane.java
  38. 20
      designer-base/src/main/java/com/fr/design/gui/style/AbstractBorderPackerPane.java
  39. 99
      designer-base/src/main/java/com/fr/design/gui/style/AbstractTranslucentBackgroundSpecialPane.java
  40. 8
      designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java
  41. 33
      designer-base/src/main/java/com/fr/design/gui/style/ComponentBodyStylePane.java
  42. 109
      designer-base/src/main/java/com/fr/design/gui/style/ComponentIntegralStylePane.java
  43. 351
      designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java
  44. 138
      designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java
  45. 102
      designer-base/src/main/java/com/fr/design/gui/style/ReportBackgroundSpecialPane.java
  46. 24
      designer-base/src/main/java/com/fr/design/gui/style/TextInsetImageBackgroundSpecialPane.java
  47. 27
      designer-base/src/main/java/com/fr/design/gui/style/TitleTranslucentBackgroundSpecialPane.java
  48. 45
      designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java
  49. 328
      designer-base/src/main/java/com/fr/design/hyperlink/popup/ContentSettingPane.java
  50. 100
      designer-base/src/main/java/com/fr/design/hyperlink/popup/CustomFontPane.java
  51. 22
      designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupConstants.java
  52. 81
      designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupPane.java
  53. 157
      designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupRegularPane.java
  54. 36
      designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupUIUtils.java
  55. 205
      designer-base/src/main/java/com/fr/design/hyperlink/popup/StyleSettingPane.java
  56. 42
      designer-base/src/main/java/com/fr/design/hyperlink/popup/WheelScrollLayerUI.java
  57. 2
      designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java
  58. 21
      designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java
  59. 33
      designer-base/src/main/java/com/fr/design/locale/impl/DoubleSplashMark.java
  60. 4
      designer-base/src/main/java/com/fr/design/locale/impl/SplashMark.java
  61. 15
      designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java
  62. 22
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  63. 27
      designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java
  64. 3
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  65. 142
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  66. 20
      designer-base/src/main/java/com/fr/design/mainframe/authority/DSColumnAuthorityChecker.java
  67. 45
      designer-base/src/main/java/com/fr/design/mainframe/authority/ElementAuthorityChecker.java
  68. 27
      designer-base/src/main/java/com/fr/design/mainframe/authority/FormulaAuthorityChecker.java
  69. 184
      designer-base/src/main/java/com/fr/design/mainframe/authority/JTemplateAuthorityChecker.java
  70. 22
      designer-base/src/main/java/com/fr/design/mainframe/authority/NameDatabaseConnectionAuthorityChecker.java
  71. 19
      designer-base/src/main/java/com/fr/design/mainframe/authority/NameTableDataAuthorityChecker.java
  72. 23
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java
  73. 35
      designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/combo/SimpleComboCheckBoxStyleProvider.java
  74. 35
      designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/combo/SimpleComboStyleProvider.java
  75. 35
      designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/date/NavigationStyleProvider.java
  76. 35
      designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/date/SimpleDateStyleProvider.java
  77. 35
      designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/date/SimpleStyleProvider.java
  78. 35
      designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/radiogroup/CapsuleRadioGroupStyleProvider.java
  79. 35
      designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/radiogroup/ImageRadioGroupStyleProvider.java
  80. 35
      designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/radiogroup/UnitedRadioGroupStyleProvider.java
  81. 25
      designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/topparam/MobileTopParamStyleProvider.java
  82. 6
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileParamSettingPane.java
  83. 304
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/combo/SimpleComboPane.java
  84. 272
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/date/NavigationCustomDefinePane.java
  85. 230
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/date/SimpleCustomDefinePane.java
  86. 267
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/date/SimpleDateCustomDefinePane.java
  87. 310
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/CapsuleCustomDefinePane.java
  88. 195
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/IconConfigPane.java
  89. 242
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/ImageCustomDefinePane.java
  90. 279
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/UnitedCustomDefinePane.java
  91. 44
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java
  92. 57
      designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/DesignerUtils.java
  93. 137
      designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/FontConfigPane.java
  94. 185
      designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/IconConfigPane.java
  95. 41
      designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/MobileStyleProviderManager.java
  96. 8
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java
  97. 53
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java
  98. 13
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ChartPreStylePreView.java
  99. 81
      designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java
  100. 81
      designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java
  101. Some files were not shown because too many files have changed in this diff Show More

7
build.gradle

@ -36,7 +36,7 @@ allprojects {
group 'com.fr.design'
version frDevVersion
sourceCompatibility = languageLevelSetting
targetCompatibility = languageLevelSetting
targetCompatibility = languageLevelSetting
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
@ -49,8 +49,8 @@ allprojects {
idea {
module {
inheritOutputDirs = false
outputDir = file(outputPath +"/classes")
testOutputDir = file(outputPath +"/test-classes")
outputDir = file(outputPath + "/classes")
testOutputDir = file(outputPath + "/test-classes")
languageLevel = new IdeaLanguageLevel(sourceCompatibility)
targetBytecodeVersion = targetCompatibility
}
@ -77,6 +77,7 @@ allprojects {
implementation 'com.fr.decision:fine-decision:' + frVersion
implementation 'com.fr.schedule:fine-schedule:' + frVersion
implementation 'com.fr.report:engine-report:' + frDevVersion
implementation 'com.fr.report:engine-x:' + frDevVersion
implementation 'com.fr.report:engine-chart:' + frDevVersion
implementation 'com.fr.report:engine-i18n:' + frDevVersion
implementation 'com.fr.design:design-i18n:' + frDevVersion

2
designer-base/src/main/java/com/fr/design/DesignModelAdapter.java

@ -302,7 +302,7 @@ public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplate
// 兼容下通过老数据集参数获取
tableDataParameters = getLatestTableDataParameters();
// 处理初始化添加
if (tableDataParametersMap.isEmpty()) {
addTableDataParameters(map, filter);

45
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -17,9 +17,9 @@ import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.locale.impl.ProductImproveMark;
import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo;
import com.fr.design.login.DesignerLoginType;
import com.fr.design.login.config.DesignerLoginConfigManager;
import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo;
import com.fr.design.mainframe.vcs.VcsConfigManager;
import com.fr.design.notification.SnapChatConfig;
import com.fr.design.port.DesignerPortContext;
@ -87,6 +87,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private static final int MAX_SHOW_NUM = 10;
private static final String VERSION_80 = "80";
private static final String VERSION_90 = "90";
private static final String VERSION100 = "100";
private static final int CACHINGTEMPLATE_LIMIT = 5;
private static final String WEB_NAME = "webapps";
/**
@ -157,7 +159,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
//记录当前激活码的在线激活状态.
private int activeKeyStatus = -1;
private boolean joinProductImprove = true;
private boolean startWithEmptyFile = false;
private boolean embedServerLazyStartup = false;
//最近使用的颜色
private ColorSelectConfigManager configManager = new ColorSelectConfigManager();
@ -354,14 +356,21 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
try {
fileWriter = new FileWriter(envFile);
File oldEnvFile = new File(ProductConstants.getEnvHome() + File.separator + ProductConstants.APP_NAME + "6-1" + "Env.xml");
File envFile80 = new File(getEnvHome(VERSION_80) + File.separator + getEnvFile().getName());
if (oldEnvFile.exists()) {
File envFile80 = getOldEnvFile(VERSION_80);
File envFile90 = getOldEnvFile(VERSION_90);
File envFile100 = getOldEnvFile(VERSION100);
// 从10.0往前递进是否存在更老版本的配置文件
if (envFile100.exists()) {
compatibilityPrevVersion(envFile100);
} else if (envFile90.exists()) {
compatibilityPrevVersion(envFile90);
} else if (envFile80.exists()) {
compatibilityPrevVersion(envFile80);
} else if (oldEnvFile.exists()) {
// marks:兼容DesignerEnv6-1.xml
FileReader fileReader = new FileReader(oldEnvFile);
Utils.copyCharTo(fileReader, fileWriter);
fileReader.close();
} else if (envFile80.exists()) {
compatibilityPrevVersion(envFile80);
} else {
// marks:生成一个新的xml文件
StringReader stringReader = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><Env></Env>");
@ -383,6 +392,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
}
}
private File getOldEnvFile(String version) {
return new File(getEnvHome(version) + File.separator + getEnvFile().getName());
}
private static String getEnvHome(String version) {
String userHome = System.getProperty("user.home");
if (userHome == null) {
@ -1349,6 +1362,24 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.maxNumberOrPreviewRow = maxNumberOrPreviewRow;
}
/**
* 启动时是否打开空报表
*
* @return 是否打开空报表
*/
public boolean isStartWithEmptyFile() {
return startWithEmptyFile;
}
/**
* 设置启动时是否打开空报表
*
* @param startWithEmptyFile 是否打开空报表
*/
public void setStartWithEmptyFile(boolean startWithEmptyFile) {
this.startWithEmptyFile = startWithEmptyFile;
}
/**
* 是否展示工程界面
*
@ -1836,6 +1867,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
this.setSupportCellEditorDef(reader.getAttrAsBoolean("supportCellEditorDef", false));
this.setDragPermited(reader.getAttrAsBoolean("isDragPermited", false));
this.setUndoLimit(reader.getAttrAsInt("undoLimit", 5));
this.setStartWithEmptyFile(reader.getAttrAsBoolean("startWithEmptyFile", false));
this.setDefaultStringToFormula(reader.getAttrAsBoolean("defaultStringToFormula", false));
if ((tmpVal = reader.getAttrAsString("gridLineColor", null)) != null) {
this.setGridLineColor(new Color(Integer.parseInt(tmpVal)));
@ -2211,6 +2243,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
.attr("gridLineColor", this.getGridLineColor().getRGB())
.attr("paginationLineColor", this.getPaginationLineColor().getRGB())
.attr("undoLimit", this.getUndoLimit())
.attr("startWithEmptyFile", this.isStartWithEmptyFile())
.end();
}

8
designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java

@ -18,6 +18,7 @@ import com.fr.design.fun.TableDataDefineProvider;
import com.fr.design.fun.ToolbarItemProvider;
import com.fr.design.gui.core.WidgetOption;
import com.fr.design.gui.core.WidgetOptionFactory;
import com.fr.design.mainframe.mobile.utils.MobileStyleProviderManager;
import com.fr.design.menu.ShortCut;
import com.fr.design.widget.Appearance;
import com.fr.design.widget.mobile.WidgetMobilePane;
@ -269,11 +270,10 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement
public MobileWidgetStyleProvider[] getMobileStyleOfWidget(String xType) {
Set<MobileWidgetStyleProvider> set = getArray(MobileWidgetStyleProvider.XML_TAG);
if (set.isEmpty()) {
return new MobileWidgetStyleProvider[0];
}
Set<MobileWidgetStyleProvider> allSet = MobileStyleProviderManager.getArray(MobileWidgetStyleProvider.XML_TAG);
allSet.addAll(set);
List<MobileWidgetStyleProvider> providers = new ArrayList<>();
for (MobileWidgetStyleProvider provider : set) {
for (MobileWidgetStyleProvider provider : allSet) {
if (ComparatorUtils.equalsIgnoreCase(provider.xTypeForWidget(), xType)) {
providers.add(provider);
}

47
designer-base/src/main/java/com/fr/design/actions/file/BatchCompileAction.java

@ -0,0 +1,47 @@
package com.fr.design.actions.file;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet;
import com.fr.locale.InterProviderFactory;
import com.fr.nx.app.designer.transform.ui.BatchTransformPane;
import javax.swing.KeyStroke;
import java.awt.Dialog;
import java.awt.event.ActionEvent;
/**
* Created by kerry on 2019-12-10
*/
public class BatchCompileAction extends UpdateAction {
public BatchCompileAction() {
this.setMenuKeySet(COMPILE);
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/nx/app/designer/transform/batch_transform.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
BatchTransformPane batchTransformPane = new BatchTransformPane();
Dialog dialog = batchTransformPane.showDialog();
dialog.setVisible(true);
}
private static final MenuKeySet COMPILE = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'C';
}
@Override
public String getMenuName() {
return InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Batch_Transform");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}

29
designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java

@ -12,6 +12,7 @@ import com.fr.design.editor.editor.IntegerEditor;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UINoThemeColorButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIDictionaryComboBox;
@ -179,7 +180,7 @@ public class PreferencePane extends BasicPane {
private UICheckBox gcEnableCheckBox;
private UIButton gcButton;
private UILabel remindVcsLabel;
private UICheckBox startWithEmptyFile;
private JDialog gcDialog;
private UILabel gcMessage = new UILabel();
private JPanel gcDialogDownPane = new JPanel();
@ -346,18 +347,23 @@ public class PreferencePane extends BasicPane {
}
private void createFunctionPane(JPanel generalPane) {
JPanel functionPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Function"));
generalPane.add(functionPane);
JPanel topVerticalTitledBorderPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Function"));
JPanel upper = new JPanel(FRGUIPaneFactory.createLeftZeroVgapNormalHgapLayout());
JPanel lower = new JPanel(FRGUIPaneFactory.createLeftZeroVgapNormalHgapLayout());
topVerticalTitledBorderPane.add(upper);
topVerticalTitledBorderPane.add(lower);
generalPane.add(topVerticalTitledBorderPane);
//添加supportUndo选择项
supportUndoCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Preference_Support_Undo"));
functionPane.add(supportUndoCheckBox);
upper.add(supportUndoCheckBox);
//添加maxUndoLimit
//String[] undoTimes = {"最大撤销次数","5次","10次","15次","20次","50次"};
String[] undoTimes = {i18nText("Fine-Design_Basic_Max_Undo_Limit"), MAX_UNDO_LIMIT_5 + i18nText("Fine-Design_Basic_Time(s)"), MAX_UNDO_LIMIT_10 + i18nText("Fine-Design_Basic_Time(s)")
, MAX_UNDO_LIMIT_15 + i18nText("Fine-Design_Basic_Time(s)"), MAX_UNDO_LIMIT_20 + i18nText("Fine-Design_Basic_Time(s)"), MAX_UNDO_LIMIT_50 + i18nText("Fine-Design_Basic_Time(s)")};
maxUndoLimit = new UIComboBox(undoTimes);
functionPane.add(maxUndoLimit);
upper.add(maxUndoLimit);
//不支持撤销则不能选择撤销可缓存,也不能设置最大撤销次数
supportUndoCheckBox.addActionListener(new ActionListener() {
@ -371,12 +377,14 @@ public class PreferencePane extends BasicPane {
//添加supportDefaultParentCalculate选择项
supportDefaultParentCalculateCheckBox = new UICheckBox(
i18nText("Fine-Design_Basic_Preference_Support_Default_Parent_Calculate"));
functionPane.add(supportDefaultParentCalculateCheckBox);
upper.add(supportDefaultParentCalculateCheckBox);
//添加是否展示打开模板提示缺少插件选择项
showTemplateMissingPlugin = new UICheckBox(
i18nText("Fine-Design_Basic_Preference_Show-Template-Missing-Plugin"));
functionPane.add(showTemplateMissingPlugin);
upper.add(showTemplateMissingPlugin);
startWithEmptyFile = new UICheckBox(i18nText("Fine-Design_Basic_Preference_Start_Empty_File"));
lower.add(startWithEmptyFile);
}
private void createEditPane(JPanel generalPane) {
@ -467,10 +475,10 @@ public class PreferencePane extends BasicPane {
JPanel colorSettingPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Setting_Colors"));
generalPane.add(colorSettingPane);
gridLineColorTBButton = new UIColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"));
gridLineColorTBButton = new UINoThemeColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"));
gridLineColorTBButton.setEnabled(this.isEnabled());
paginationLineColorTBButton = new UIColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"));
paginationLineColorTBButton = new UINoThemeColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"));
paginationLineColorTBButton.setEnabled(this.isEnabled());
JPanel leftPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
@ -729,6 +737,7 @@ public class PreferencePane extends BasicPane {
}
this.embedServerLazyStartupCheckBox.setSelected(designerEnvManager.isEmbedServerLazyStartup());
this.startWithEmptyFile.setSelected(designerEnvManager.isStartWithEmptyFile());
this.imageCompressPanelCheckBox.setSelected(designerEnvManager.isImageCompress());
}
@ -815,7 +824,7 @@ public class PreferencePane extends BasicPane {
if (maxUndoLimit.getSelectedIndex() == SELECTED_INDEX_5) {
designerEnvManager.setUndoLimit(MAX_UNDO_LIMIT_50);
}
designerEnvManager.setStartWithEmptyFile(startWithEmptyFile.isSelected());
if (WorkContext.getCurrent().isLocal()) {
Configurations.update(new Worker() {
@Override

8
designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java

@ -31,10 +31,6 @@ public class TutorialAction extends AbstractDesignerSSO {
return CloudCenter.getInstance().acquireUrlByKind(createDocKey(), "http://help.finereport.com");
}
public String getOffLineWarnMessage() {
return Toolkit.i18nText("Fine-Design_Offline_Helptutorial_Msg");
}
// 生成帮助文档 sitecenter key, help.zh_CN.10
protected String createDocKey() {
String locale = GeneralContext.getLocale().toString();
@ -57,6 +53,10 @@ public class TutorialAction extends AbstractDesignerSSO {
}
}
public String getOffLineWarnMessage() {
return Toolkit.i18nText("Fine-Design_Offline_Helptutorial_Msg");
}
public static final MenuKeySet HELP_TUTORIAL = new MenuKeySet() {
@Override
public char getMnemonic() {

4
designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java

@ -20,6 +20,9 @@ import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.menu.MenuKeySet;
import com.fr.esd.event.DSMapping;
import com.fr.esd.event.DsNameTarget;
import com.fr.esd.event.StrategyEventsNotifier;
import com.fr.file.TableDataConfig;
import com.fr.transaction.CallBackAdaptor;
@ -89,6 +92,7 @@ public class GlobalTableDataAction extends UpdateAction implements ResponseDataS
protected void renameConnection(final String oldName, final String newName) {
tableDataConfig.renameTableData(oldName, newName);
StrategyEventsNotifier.modifyDataSet(DSMapping.ofServerDS(new DsNameTarget(oldName)));
}
};
final BasicDialog globalTableDataDialog = globalTableDataPane.showWindowWithCustomSize(designerFrame, null, DEFAULT_DIMENSION);

49
designer-base/src/main/java/com/fr/design/actions/server/LocalAnalyzerAction.java

@ -0,0 +1,49 @@
package com.fr.design.actions.server;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.utils.DesignUtils;
import com.fr.locale.InterProviderFactory;
import com.fr.nx.app.web.URLConstants;
import com.fr.stable.StableUtils;
import javax.swing.KeyStroke;
import java.awt.event.ActionEvent;
/**
* @author Maksim
* Created in 2020/11/5 11:44 上午
*/
public class LocalAnalyzerAction extends UpdateAction {
public LocalAnalyzerAction() {
this.setMenuKeySet(ANALYZER);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/nx/app/designer/transform/analyzer.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
String path = StableUtils.pathJoin("/nx", URLConstants.ANALYZE_VIEW);
DesignUtils.visitEnvServerByParameters(path, new String[]{}, new String[]{});
}
private static final MenuKeySet ANALYZER = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'R';
}
@Override
public String getMenuName() {
return InterProviderFactory.getProvider().getLocText("Fine-Plugin-Engine_Analyzer_Menu_Name");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}

76
designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java

@ -0,0 +1,76 @@
package com.fr.design.cell;
import com.fr.base.NameStyle;
import com.fr.base.ScreenResolution;
import com.fr.base.Style;
import com.fr.general.IOUtils;
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/9/3
*/
public class CellStylePreviewPane extends JPanel {
private static final BufferedImage transparentBackgroundImage = IOUtils.readImage("/com/fr/design/images/transparent_background.png");
private final float transparentBackgroundWidth;
private final float transparentBackgroundHeight;
private String paintText = "Report";
private Style style = Style.DEFAULT_STYLE;
public CellStylePreviewPane() {
transparentBackgroundWidth = transparentBackgroundImage.getWidth(null);
transparentBackgroundHeight = transparentBackgroundImage.getHeight(null);
}
public void setStyle(Style style) {
this.style = style;
if (style instanceof NameStyle) {
paintText = ((NameStyle) style).getName();
}
repaint();
}
@Override
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
int resolution = ScreenResolution.getScreenResolution();
int width = getWidth();
int height = getHeight();
float scaleWidth = 1.0F * getWidth() / transparentBackgroundWidth;
float scaleHeight = 1.0F * getHeight() / transparentBackgroundHeight;
float maxScale = Math.max(scaleWidth, scaleHeight);
if (maxScale <= 1) {
scaleWidth = scaleHeight = 1;
} else {
scaleHeight = scaleWidth = maxScale;
}
g2d.drawImage(transparentBackgroundImage, 0, 0, (int) (transparentBackgroundWidth * scaleWidth), (int) (transparentBackgroundHeight * scaleHeight), null);
if (style == Style.DEFAULT_STYLE) {
// 如果是默认的style,就只写"Report"上去
Style.paintContent(g2d, paintText, style, width, height, resolution);
return;
}
Style.paintBackground(g2d, style, width, height);
Style.paintContent(g2d, paintText, style, width, height, resolution);
Style.paintBorder(g2d, style, width, height);
}
@Override
public Dimension getMinimumSize() {
return getPreferredSize();
}
}

12
designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java

@ -161,10 +161,18 @@ public abstract class DesignTableDataManager {
}
public static String getChangedDsNameByOldDsName(String oldDsName) {
String changeName;
if (isDsNameChanged(oldDsName)) {
return dsNameChangedMap.get(oldDsName);
changeName = dsNameChangedMap.get(oldDsName);
} else {
changeName = StringUtils.EMPTY;
}
if (StringUtils.isNotEmpty(changeName)) {
return getChangedDsNameByOldDsName(changeName);
} else {
return StringUtils.EMPTY;
return oldDsName;
}
}

136
designer-base/src/main/java/com/fr/design/data/StrategyConfigAttrUtils.java

@ -0,0 +1,136 @@
package com.fr.design.data;
import com.fr.base.io.IOFile;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import com.fr.esd.core.strategy.config.StrategyConfig;
import com.fr.esd.core.strategy.config.StrategyConfigHelper;
import com.fr.esd.core.strategy.config.service.StrategyConfigService;
import com.fr.esd.core.strategy.persistence.StrategyConfigsAttr;
import com.fr.esd.event.DSMapping;
import com.fr.esd.event.DsNameTarget;
import com.fr.esd.event.StrategyEventsNotifier;
import com.fr.esd.event.xml.XMLSavedHook;
import com.fr.file.FILE;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* @author rinoux
* @version 10.0
* Created by rinoux on 2020/10/28
*/
public class StrategyConfigAttrUtils {
/**
* 获取当前编辑模版的数据集缓存配置属性
*
* @return
*/
private static StrategyConfigsAttr getStrategyConfigsAttr() {
StrategyConfigsAttr attr;
JTemplate<?, ?> jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jTemplate != null) {
IOFile ioFile = (IOFile) jTemplate.getTarget();
attr = ioFile.getAttrMark(StrategyConfigsAttr.ATTR_MARK);
if (attr == null) {
attr = new StrategyConfigsAttr();
ioFile.addAttrMark(attr);
}
//新建模版此时不存在,不需要注册钩子
if (attr.getXmlSavedHook() == null && WorkContext.getWorkResource().exist(jTemplate.getPath())) {
attr.setXmlSavedHook(new StrategyConfigsAttrSavedHook(jTemplate.getPath(), attr));
}
return attr;
} else {
throw new IllegalStateException("[ESD]No editing template found.");
}
}
/**
* 获取模版数据集配置
*
* @param dsName
* @return
*/
public static StrategyConfig getStrategyConfig(String dsName) {
return getStrategyConfigsAttr().getStrategyConfig(dsName);
}
/**
* 移除模版数据集配置
*
* @param dsName
* @return
*/
public static StrategyConfig removeStrategyConfig(String dsName) {
return getStrategyConfigsAttr().removeStrategyConfig(dsName);
}
/**
* 添加模版数据集配置
*
* @param strategyConfig
*/
public static void addStrategyConfig(StrategyConfig strategyConfig) {
getStrategyConfigsAttr().addStrategyConfig(strategyConfig);
}
private static class StrategyConfigsAttrSavedHook implements XMLSavedHook<StrategyConfigsAttr> {
private static final long serialVersionUID = -8843201977112289321L;
private final String tplPath;
private final Map<String, StrategyConfig> origStrategyConfigs;
public StrategyConfigsAttrSavedHook(String tplPath, StrategyConfigsAttr raw) {
this.tplPath = tplPath;
this.origStrategyConfigs = new HashMap<>();
this.initOrigStrategyConfigs(raw);
}
private void initOrigStrategyConfigs(StrategyConfigsAttr raw) {
origStrategyConfigs.clear();
raw.getStrategyConfigs().forEach((k, v) -> {
try {
origStrategyConfigs.put(k, v.clone());
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
});
}
@Override
public void doAfterSaved(StrategyConfigsAttr saved) {
FineLoggerFactory.getLogger().info("[ESD]Write StrategyConfigsAttr done, now check change.");
Set<String> dsNames = new HashSet<>();
dsNames.addAll(origStrategyConfigs.keySet());
dsNames.addAll(saved.getStrategyConfigs().keySet());
if (StringUtils.isNotEmpty(tplPath)) {
dsNames.forEach(dsName -> {
if (StringUtils.isNotEmpty(dsName)) {
StrategyEventsNotifier.compareAndFireConfigEvents(origStrategyConfigs.get(dsName), saved.getStrategyConfig(dsName), new DSMapping(tplPath, new DsNameTarget(dsName)));
}
});
}
initOrigStrategyConfigs(saved);
}
}
}

226
designer-base/src/main/java/com/fr/design/data/datapane/ESDStrategyConfigPane.java

@ -0,0 +1,226 @@
package com.fr.design.data.datapane;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.esd.common.CacheConstants;
import com.fr.esd.core.strategy.config.StrategyConfig;
import com.fr.esd.core.strategy.config.StrategyConfigHelper;
import com.fr.esd.util.ESDUtils;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import javax.swing.AbstractAction;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author rinoux
* @version 10.0
* Created by rinoux on 2020/7/22
*/
public class ESDStrategyConfigPane extends BasicBeanPane<StrategyConfig> {
private static final String CRON_HELP_URL = "http://help.fanruan.com/finereport/doc-view-693.html";
private UIRadioButton selectAutoUpdate;
private UIRadioButton selectBySchema;
private UICheckBox shouldEvolve;
private UILabel updateIntervalCheckTips;
private UITextField updateInterval;
private UITextField schemaTime;
private ActionLabel actionLabel;
private UILabel schemaTimeCheckTips;
private final boolean global;
private StrategyConfig strategyConfig;
public ESDStrategyConfigPane(boolean global) {
this.global = global;
init();
}
private void init() {
setLayout(FRGUIPaneFactory.createM_BorderLayout());
this.selectAutoUpdate = new UIRadioButton(InterProviderFactory.getDesignI18nProvider().i18nText("Fine-Design_ESD_Every_Interval"));
this.updateInterval = new UITextField(4);
this.shouldEvolve = new UICheckBox(InterProviderFactory.getDesignI18nProvider().i18nText("Fine-Design_ESD_Auto_Evolved_Strategy"), false);
this.shouldEvolve.setEnabled(false);
this.updateIntervalCheckTips = new UILabel(InterProviderFactory.getDesignI18nProvider().i18nText("Fine-Design_ESD_Error_Interval_Format"));
this.updateIntervalCheckTips.setForeground(Color.RED);
this.updateIntervalCheckTips.setVisible(false);
this.selectBySchema = new UIRadioButton(InterProviderFactory.getDesignI18nProvider().i18nText("Fine-Design_ESD_Cron"));
this.schemaTime = new UITextField(10);
this.schemaTimeCheckTips = new UILabel(InterProviderFactory.getDesignI18nProvider().i18nText("Fine-Design_ESD_Error_Time_Format"));
this.schemaTimeCheckTips.setVisible(false);
this.schemaTimeCheckTips.setForeground(Color.RED);
this.selectAutoUpdate.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
ESDStrategyConfigPane.this.selectBySchema.setSelected(!ESDStrategyConfigPane.this.selectAutoUpdate.isSelected());
ESDStrategyConfigPane.this.schemaTime.setEnabled(false);
ESDStrategyConfigPane.this.updateInterval.setEnabled(true);
ESDStrategyConfigPane.this.shouldEvolve.setEnabled(true);
}
});
this.selectBySchema.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
ESDStrategyConfigPane.this.selectAutoUpdate.setSelected(!ESDStrategyConfigPane.this.selectBySchema.isSelected());
ESDStrategyConfigPane.this.schemaTime.setEnabled(true);
ESDStrategyConfigPane.this.updateInterval.setEnabled(false);
ESDStrategyConfigPane.this.shouldEvolve.setEnabled(false);
}
});
JPanel pane = FRGUIPaneFactory.createVerticalTitledBorderPane(InterProviderFactory.getDesignI18nProvider().i18nText("Fine-Design_ESD_Cache_Update_Strategy"));
add(pane, BorderLayout.NORTH);
JPanel row1 = GUICoreUtils.createFlowPane(new Component[]{
this.selectAutoUpdate,
this.updateInterval,
new UILabel(InterProviderFactory.getDesignI18nProvider().i18nText("Fine-Design_ESD_Minute_Update_Cache")),
this.shouldEvolve,
this.updateIntervalCheckTips
}, 0, 5);
pane.add(row1);
ActionLabel actionLabel = new ActionLabel(InterProviderFactory.getDesignI18nProvider().i18nText("Fine-Design_ESD_Cron_Help"));
actionLabel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Desktop.getDesktop().browse(new URI(CRON_HELP_URL));
} catch (Exception exp) {
FineLoggerFactory.getLogger().error(exp.getMessage(), e);
}
}
});
JPanel row2 = GUICoreUtils.createFlowPane(new Component[]{
this.selectBySchema,
this.schemaTime,
actionLabel,
this.schemaTimeCheckTips
}, 0, 5);
pane.add(row2);
}
public void populateBean(StrategyConfig ob) {
if (ob == null && !global) {
ob = StrategyConfigHelper.createStrategyConfig(true, false, true);
}
this.strategyConfig = ob;
this.updateInterval.setText(ob.getUpdateInterval() <= 0 ? "0" : String.valueOf(ob.getUpdateInterval() / (double) CacheConstants.MILLIS_OF_MINUTE));
this.schemaTime.setText(StringUtils.join(",", ob.getUpdateSchema().toArray(new String[0])));
this.shouldEvolve.setSelected(ob.shouldEvolve());
this.selectBySchema.setSelected(ob.isScheduleBySchema());
this.selectAutoUpdate.setSelected(!ob.isScheduleBySchema());
if (global) {
//使用全局配置,禁用面板编辑
disablePane();
} else {
setSchemaEnable(!this.selectAutoUpdate.isSelected());
}
}
private void disablePane() {
this.selectAutoUpdate.setEnabled(false);
this.updateInterval.setEnabled(false);
this.shouldEvolve.setEnabled(false);
this.selectBySchema.setEnabled(false);
this.schemaTime.setEnabled(false);
}
private void setSchemaEnable(boolean enable) {
this.updateInterval.setEnabled(!enable);
this.shouldEvolve.setEnabled(!enable);
this.schemaTime.setEnabled(enable);
}
public StrategyConfig updateBean() {
StrategyConfig config = null;
if (!this.global) {
try {
//这里是new的config
config = this.strategyConfig.clone();
if (this.selectBySchema.isSelected()) {
List<String> schemaTimes = new ArrayList<>();
String text = this.schemaTime.getText();
if (ESDUtils.checkUpdateTimeSchema(text)) {
if (ESDUtils.isCronExpression(text)) {
schemaTimes.add(text);
} else {
Collections.addAll(schemaTimes, text.split(","));
}
} else {
this.schemaTimeCheckTips.setVisible(true);
throw new IllegalArgumentException("[ESD]Update schema time format error.");
}
config.setScheduleBySchema(true);
config.setUpdateSchema(schemaTimes);
} else {
String interval = this.updateInterval.getText();
if (checkUpdateInterval(interval)) {
long intervalMillis = StringUtils.isEmpty(interval) ? 0 : (long) (Double.parseDouble(interval) * CacheConstants.MILLIS_OF_MINUTE);
config.setUpdateInterval(intervalMillis);
} else {
this.updateIntervalCheckTips.setVisible(true);
throw new IllegalArgumentException("[ESD]Error update interval format.");
}
config.setShouldEvolve(this.shouldEvolve.isSelected());
config.setScheduleBySchema(false);
}
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
return config;
}
private boolean checkUpdateInterval(String intervalValue) {
try {
return !StringUtils.isEmpty(intervalValue) && !(Double.parseDouble(intervalValue) <= 0);
} catch (NumberFormatException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return false;
}
protected String title4PopupWindow() {
return InterProviderFactory.getDesignI18nProvider().i18nText("Fine-Design_ESD_Cache_Strategy_Config_Title");
}
}

735
designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java

@ -2,6 +2,7 @@ package com.fr.design.data.datapane;
import com.fr.base.TableData;
import com.fr.data.TableDataSource;
import com.fr.data.impl.DBTableData;
import com.fr.data.impl.TableDataSourceDependent;
import com.fr.design.DesignModelAdapter;
import com.fr.design.ExtraDesignClassManager;
@ -10,52 +11,74 @@ import com.fr.design.constants.UIConstants;
import com.fr.design.data.BasicTableDataTreePane;
import com.fr.design.data.BasicTableDataUtils;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.StrategyConfigAttrUtils;
import com.fr.design.data.tabledata.StoreProcedureWorkerListener;
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.DBTableDataPane;
import com.fr.design.data.tabledata.wrapper.AbstractTableDataWrapper;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fun.TableDataPaneProcessor;
import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.i18n.Toolkit;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.menu.LineSeparator;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef;
import com.fr.design.menu.ToolBarDef;
import com.fr.esd.core.strategy.config.StrategyConfig;
import com.fr.esd.core.strategy.config.StrategyConfigHelper;
import com.fr.esd.event.DSMapping;
import com.fr.esd.event.DsNameTarget;
import com.fr.esd.event.StrategyEventsNotifier;
import com.fr.esd.query.StrategicTableData;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.general.NameObject;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.stable.core.PropertyChangeAdapter;
import org.jetbrains.annotations.NotNull;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.ToolTipManager;
import javax.swing.tree.TreePath;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.dnd.DnDConstants;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
public class TableDataTreePane extends BasicTableDataTreePane {
private static TableDataTreePane singleton = new TableDataTreePane();
private static final TableDataTreePane singleton = new TableDataTreePane();
public static final int PLUGIN_LISTENER_PRIORITY = 1;
@ -77,31 +100,44 @@ public class TableDataTreePane extends BasicTableDataTreePane {
}
private TableDataSourceOP op;
private TableDataTree dataTree;
private TableDataTree tableDataTree;
private EditAction editAction;
private RemoveAction removeAction;
private EsdOnAction esdAction;
private EsdOffAction esdOffAction;
private PreviewTableDataAction previewTableDataAction;
private TableDataTreePane() {
initPane();
}
private void initPane() {
this.setLayout(new BorderLayout(4, 0));
this.setBorder(null);
dataTree = new TableDataTree();
ToolTipManager.sharedInstance().registerComponent(dataTree);
//TableDataTree
tableDataTree = new TableDataTree();
ToolTipManager.sharedInstance().registerComponent(tableDataTree);
ToolTipManager.sharedInstance().setDismissDelay(3000);
ToolTipManager.sharedInstance().setInitialDelay(0);
addMenuDef = new MenuDef(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Action_Add"));
addMenuDef.setIconPath(IconPathConstants.ADD_POPMENU_ICON_PATH);
addMenuDef = new MenuDef(Toolkit.i18nText("Fine-Design_Basic_Action_Add"));
addMenuDef.setIconPath(IconPathConstants.ADD_POPMENU_ICON_PATH);
createAddMenuDef();
// 创建插件监听
createPluginListener();
editAction = new EditAction();
removeAction = new RemoveAction();
previewTableDataAction = new PreviewTableDataAction(dataTree);
previewTableDataAction = new PreviewTableDataAction(tableDataTree);
connectionTableAction = new ConnectionTableAction();
esdAction = new EsdOnAction();
esdOffAction = new EsdOffAction();
toolbarDef = new ToolBarDef();
toolbarDef.addShortCut(addMenuDef, SeparatorDef.DEFAULT, editAction, removeAction, SeparatorDef.DEFAULT, previewTableDataAction, connectionTableAction);
toolbarDef.addShortCut(addMenuDef, SeparatorDef.DEFAULT, editAction, removeAction, SeparatorDef.DEFAULT, previewTableDataAction, connectionTableAction, esdAction, esdOffAction);
UIToolbar toolBar = ToolBarDef.createJToolBar();
toolBar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.TOOLBAR_BORDER_COLOR));
toolBar.setBorderPainted(true);
@ -111,33 +147,32 @@ public class TableDataTreePane extends BasicTableDataTreePane {
toolbarPane.add(toolBar, BorderLayout.CENTER);
this.add(toolbarPane, BorderLayout.NORTH);
UIScrollPane scrollPane = new UIScrollPane(dataTree);
UIScrollPane scrollPane = new UIScrollPane(tableDataTree);
scrollPane.setBorder(null);
initbuttonGroup();
initButtonGroup();
JPanel jPanel = new JPanel(new BorderLayout(0, 0));
JPanel buttonPane = new JPanel(new GridLayout());
buttonPane.add(buttonGroup, BorderLayout.CENTER);
jPanel.add(buttonPane, BorderLayout.NORTH);
jPanel.add(scrollPane, BorderLayout.CENTER);
this.add(jPanel, BorderLayout.CENTER);
dataTree.addMouseListener(new MouseAdapter() {
tableDataTree.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
checkButtonEnabled();
}
});
dataTree.addKeyListener(getTableTreeNodeListener(editAction, previewTableDataAction, removeAction, op, dataTree));
tableDataTree.addKeyListener(getTableTreeNodeListener(editAction, previewTableDataAction, removeAction, op, tableDataTree));
// TreeCellEditor
dataTree.setEditable(true);
TableDataTreeCellEditor treeCellEditor = new TableDataTreeCellEditor(new UITextField(), dataTree, this);
tableDataTree.setEditable(true);
TableDataTreeCellEditor treeCellEditor = new TableDataTreeCellEditor(new UITextField(), tableDataTree, this);
treeCellEditor.addCellEditorListener(treeCellEditor);
dataTree.setCellEditor(treeCellEditor);
new TableDataTreeDragSource(dataTree, DnDConstants.ACTION_COPY);
tableDataTree.setCellEditor(treeCellEditor);
new TableDataTreeDragSource(tableDataTree, DnDConstants.ACTION_COPY);
checkButtonEnabled();
}
private void createPluginListener() {
//菜单栏监听
GeneralContext.listenPluginRunningChanged(new PluginEventListener(PLUGIN_LISTENER_PRIORITY) {
@ -157,69 +192,113 @@ public class TableDataTreePane extends BasicTableDataTreePane {
});
}
protected void checkButtonEnabled() {
super.checkButtonEnabled(editAction, previewTableDataAction, removeAction, op, dataTree);
}
/**
* 刷新
*/
@Override
public void refreshDockingView() {
populate(new TableDataSourceOP(tc));
this.checkButtonEnabled();
}
protected void initbuttonGroup() {
// Icon[] iconArray = {BaseUtils.readIcon("/com/fr/design/images/data/datasource.png"), BaseUtils.readIcon("/com/fr/design/images/data/dock/serverdatabase.png")};
final Integer[] modeArray = {TEMPLATE_TABLE_DATA, SERVER_TABLE_DATA};
String[] textArray = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Source_Type_Template"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Server_TableData")};
buttonGroup = new UIHeadGroup(textArray) {
public void tabChanged(int index) {
if (op != null) {
op.setDataMode(modeArray[buttonGroup.getSelectedIndex()]);
addMenuDef.setEnabled(modeArray[buttonGroup.getSelectedIndex()] == TEMPLATE_TABLE_DATA ? true : false);
refreshDockingView();
}
@Override
public final void createAddMenuDef() {
TableDataNameObjectCreator[] creators = TableDataCreatorProducer.getInstance().createReportTableDataCreator();
for (final TableDataNameObjectCreator creator : creators) {
if (creator.shouldInsertSeparator()) {
addMenuDef.addShortCut(new LineSeparator());
}
};
buttonGroup.setNeedLeftRightOutLine(false);
addMenuDef.addShortCut(new AddAction() {
@Override
protected String getTDName() {
return creator.menuName();
}
@Override
protected Icon getTDIcon() {
return creator.menuIcon();
}
@Override
protected String getNamePrefix() {
return creator.getPrefix();
}
@Override
protected TemplateTableDataWrapper getTableDataInstance() {
TableData tableData = (TableData) creator.createObject();
//11中所有数据集都是StrategicTableData的子类
if (tableData instanceof StrategicTableData) {
StrategicTableData std = (StrategicTableData) tableData;
tableData = StrategicTableData.Binder
.bind(std)
.setDsName(createDsName(creator.getPrefix()))
.setScope(StrategicTableData.Scope.TEMPLATE)
.done();
}
return new TemplateTableDataWrapper(tableData);
}
});
}
}
/**
* 编辑面板
*
* @param uPanel 面板
* @param originalName 原始名字
* @param tableDataPane 面板
* @param originalName 原始名字
*/
public void dgEdit(final AbstractTableDataPane<?> uPanel, String originalName, boolean isUpdate) {
uPanel.addStoreProcedureWorkerListener(new StoreProcedureWorkerListener() {
@Override
public void dgEdit(final AbstractTableDataPane<?> tableDataPane, String originalName, boolean isUpdate) {
tableDataPane.addStoreProcedureWorkerListener(new StoreProcedureWorkerListener() {
public void fireDoneAction() {
if (dataTree.getSelectionPath() == null) {
dataTree.refresh();
if (tableDataTree.getSelectionPath() == null) {
tableDataTree.refresh();
} else {
Object object = dataTree.getSelectionPath().getLastPathComponent();
int[] rows = dataTree.getSelectionRows();
dataTree.refreshChildByName(object.toString());
dataTree.setSelectionRows(rows);
Object object = tableDataTree.getSelectionPath().getLastPathComponent();
int[] rows = tableDataTree.getSelectionRows();
tableDataTree.refreshChildByName(object.toString());
tableDataTree.setSelectionRows(rows);
}
}
});
final BasicPane.NamePane nPanel = uPanel.asNamePane();
nPanel.setObjectName(originalName);
final NamePane tdNamePanel = tableDataPane.asNamePane();
tdNamePanel.setObjectName(originalName);
final String oldName = originalName;
final BasicDialog dg;
allDSNames = DesignTableDataManager.getAllDSNames(tc.getBook());
dg = nPanel.showLargeWindow(SwingUtilities.getWindowAncestor(TableDataTreePane.this), new DialogActionAdapter() {
final BasicDialog dg = tdNamePanel.showLargeWindow(SwingUtilities.getWindowAncestor(TableDataTreePane.this), new DialogActionAdapter() {
@Override
public void doOk() {
DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER);
tc.renameTableData(oldName, nPanel.getObjectName(), false);
tc.renameTableData(oldName, tdNamePanel.getObjectName(), false);
TableDataSource tds = tc.getBook();
TableData td = uPanel.updateBean();
TableData td = tableDataPane.updateBean();
if (td instanceof TableDataSourceDependent) {
((TableDataSourceDependent) td).setTableDataSource(tds);
}
String tdName = nPanel.getObjectName();
String tdName = tdNamePanel.getObjectName();
//模版还没保存的时候不知道后缀,不能设置到策略配置里面
if (tableDataPane instanceof DBTableDataPane) {
StrategyConfig editingConfig = ((DBTableDataPane) tableDataPane).updateStrategyConfig();
if (editingConfig != null) {
editingConfig.setDsName(tdName);
if (!ComparatorUtils.equals(oldName, tdName)) {
//重命名
StrategyConfigAttrUtils.removeStrategyConfig(oldName);
}
StrategyConfigAttrUtils.addStrategyConfig(editingConfig);
}
((DBTableData) td).setDsName(tdName);
}
tds.putTableData(tdName, td);
Map<String, String> map = new HashMap<String, String>();
if (!ComparatorUtils.equals(oldName, tdName)) {
@ -227,83 +306,35 @@ public class TableDataTreePane extends BasicTableDataTreePane {
}
fireDSChanged(map);
tc.fireTargetModified();
tc.tableDataParametersChanged(oldName, tdName, td);
int[] rows = dataTree.getSelectionRows();
dataTree.refreshChildByName(tdName);
dataTree.setSelectionRows(rows);
tc.parameterChanged();
int[] rows = tableDataTree.getSelectionRows();
tableDataTree.refreshChildByName(tdName);
tableDataTree.setSelectionRows(rows);
//单独编辑数据集关闭,修改缓存配置状态,刷新下一键开启/关闭按钮
checkButtonEnabled();
}
@Override
public void doCancel() {
super.doCancel();
}
});
nPanel.addPropertyChangeListener(new PropertyChangeAdapter() {
tdNamePanel.addPropertyChangeListener(new PropertyChangeAdapter() {
@Override
public void propertyChange() {
doPropertyChange(dg, nPanel, oldName);
doPropertyChange(dg, tdNamePanel, oldName);
}
});
dg.setVisible(true);
}
private class EditAction extends UpdateAction {
public EditAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit"));
this.setMnemonic('E');
this.setSmallIcon("/com/fr/design/images/control/edit");
}
public void actionPerformed(ActionEvent e) {
final NameObject selectedNO = dataTree.getSelectedNameObject();
if (selectedNO == null) {
return;
}
DesignTableDataManager.removeSelectedColumnNames(selectedNO.getName());
dgEdit(((AbstractTableDataWrapper) selectedNO.getObject()).creatTableDataPane(), selectedNO.getName(), false);
}
}
private class RemoveAction extends UpdateAction {
public RemoveAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove"));
this.setMnemonic('R');
this.setSmallIcon("/com/fr/design/images/control/remove");
}
@Override
public void actionPerformed(ActionEvent e) {
NameObject selectedNO = dataTree.getSelectedNameObject();
if (selectedNO == null) {
return;
}
int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + ":" + selectedNO.getName() + "?",
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.OK_OPTION) {
// richer:这个地方为什么要在DataSourceTree里面去remove呢?多此一举吧
op.removeAction(selectedNO.getName());
dataTree.refresh();
// Richie:默认最后一行获得焦点.
dataTree.requestFocus();
dataTree.setSelectionRow(dataTree.getRowCount() - 1);
fireDSChanged();
checkButtonEnabled();
DesignTableDataManager.removeSelectedColumnNames(selectedNO.getName());
DesignModelAdapter.getCurrentModelAdapter().removeTableDataParameters(selectedNO.getName());
}
}
}
private void populate(TableDataSourceOP op) {
this.op = op;
dataTree.populate(op);
checkButtonEnabled();
}
/**
* @return
*/
public TableDataTree getDataTree() {
return dataTree;
@Override
public void removeTableData(String sourceName) {
TableDataSource tds = this.tc.getBook();
tds.removeTableData(sourceName);
this.tableDataTree.refresh();
}
/**
@ -312,6 +343,7 @@ public class TableDataTreePane extends BasicTableDataTreePane {
* @param srcName 数据集来源(比如报表块就是报表块的名称)
* @param tableDataSource 数据集
*/
@Override
public Map<String, String> addTableData(String srcName, TableDataSource tableDataSource, boolean isCover) {
Map<String, String> tdNameMap = new HashMap<>();
allDSNames = DesignTableDataManager.getAllDSNames(tc.getBook());
@ -322,39 +354,63 @@ public class TableDataTreePane extends BasicTableDataTreePane {
String tdName = (String) tdIterator.next();
String oldName = tdName;
TableData td = tableDataSource.getTableData(tdName);
boolean isDsNameRepeaded = isDsNameRepeaded(tdName);
tdName = BasicTableDataUtils.getTableDataName(isCover, tds, tdName, srcName, isDsNameRepeaded);
boolean isDsNameRepeated = isDsNameRepeaded(tdName);
tdName = BasicTableDataUtils.getTableDataName(isCover, tds, tdName, srcName, isDsNameRepeated);
tds.putTableData(tdName, td);
if (!ComparatorUtils.equals(oldName, tdName)) {
tdNameMap.put(oldName, tdName);
}
}
tc.parameterChanged();
dataTree.refresh();
tableDataTree.refresh();
return Collections.unmodifiableMap(tdNameMap);
}
/**
* 合并数据集
*
* @param srcName 数据集来源(比如报表块就是报表块的名称)
* @param tableDataSource 数据集
*/
@Override
public void removeTableData(String sourceName) {
public Map<String, String> addTableData(String srcName, TableDataSource tableDataSource) {
Map<String, String> tdNameMap = new HashMap<>();
allDSNames = DesignTableDataManager.getAllDSNames(tc.getBook());
DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER);
TableDataSource tds = tc.getBook();
tds.removeTableData(sourceName);
dataTree.refresh();
Iterator<String> tdIterator = tableDataSource.getTableDataNameIterator();
while (tdIterator.hasNext()) {
String tdName = tdIterator.next();
String oldName = tdName;
TableData td = tableDataSource.getTableData(tdName);
if (tds.getTableData(tdName) != null || isDsNameRepeaded(tdName)) {
//如果有同名的就拼上来源名称
tdName = srcName + tdName;
}
int i = 0;
while (tds.getTableData(tdName) != null) {
i++;//如果拼上名字后依然已经存在就加编号
tdName += i;
}
tds.putTableData(tdName, td);
if (!ComparatorUtils.equals(oldName, tdName)) {
tdNameMap.put(oldName, tdName);
}
}
tc.parameterChanged();
tableDataTree.refresh();
return Collections.unmodifiableMap(tdNameMap);
}
@Override
public void checkEnable() {
this.checkButtonEnabled();
}
public void addDataPane(final AbstractTableDataPane<?> uPanel, String paneName) {
final NamePane nPanel = uPanel.asNamePane();
nPanel.setObjectName(paneName);
final String oldName = paneName;
allDSNames = DesignTableDataManager.getAllDSNames(tc.getBook());
DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER);
tc.renameTableData(oldName, nPanel.getObjectName(), false);
tc.renameTableData(paneName, nPanel.getObjectName(), false);
TableDataSource tds = tc.getBook();
TableData td = uPanel.updateBean();
if (td instanceof TableDataSourceDependent) {
@ -363,14 +419,415 @@ public class TableDataTreePane extends BasicTableDataTreePane {
String tdName = nPanel.getObjectName();
tds.putTableData(tdName, td);
Map<String, String> map = new HashMap<String, String>();
if (!ComparatorUtils.equals(oldName, tdName)) {
map.put(oldName, tdName);
if (!ComparatorUtils.equals(paneName, tdName)) {
map.put(paneName, tdName);
}
fireDSChanged(map);
tc.fireTargetModified();
tc.tableDataParametersChanged(oldName, tdName, td);
int[] rows = dataTree.getSelectionRows();
dataTree.refreshChildByName(tdName);
dataTree.setSelectionRows(rows);
tc.parameterChanged();
int[] rows = tableDataTree.getSelectionRows();
tableDataTree.refreshChildByName(tdName);
tableDataTree.setSelectionRows(rows);
}
@Override
public TableDataTree getDataTree() {
return this.tableDataTree;
}
private void populate(TableDataSourceOP op) {
this.op = op;
tableDataTree.populate(op);
checkButtonEnabled();
}
private void resetAddMenuDef() {
this.addMenuDef.clearShortCuts();
this.createAddMenuDef();
}
private void checkButtonEnabled() {
super.checkButtonEnabled(editAction, previewTableDataAction, removeAction, op, tableDataTree);
this.checkESDComponentsEnabled();
}
private void checkESDComponentsEnabled() {
if (buttonGroup.getSelectedIndex() == 1) {
//切换到服务器数据集的tab,禁用
esdAction.setEnabled(false);
esdOffAction.setEnabled(false);
return;
}
new SwingWorker<ButtonStatus, Void>() {
@Override
protected ButtonStatus doInBackground() throws Exception {
ButtonStatus btnStatus = new ButtonStatus();
Map<DBTableData, ESDStatus> statusMap = checkCanBeEsdBatchEnableStatus();
if (statusMap.size() == 0) {
//没有db数据集
return btnStatus;
} else {
int canTurnOnCount = 0;
int canTurnOffCount = 0;
for (ESDStatus status : statusMap.values()) {
switch (status) {
case GLOBAL_ON:
case GLOBAL_OFF:
case SINGLE_OFF:
canTurnOnCount++;
break;
case SINGLE_ON:
canTurnOffCount++;
break;
default:
break;
}
}
btnStatus.setOnStatus(canTurnOnCount > 0);
btnStatus.setOffStatus(canTurnOffCount > 0);
}
return btnStatus;
}
@Override
protected void done() {
try {
ButtonStatus buttonStatus = get();
esdAction.setEnabled(buttonStatus.isOnStatus());
esdOffAction.setEnabled(buttonStatus.isOffStatus());
} catch (InterruptedException | ExecutionException e) {
FineLoggerFactory.getLogger().error("get esd status of ds error for " + e.getMessage(), e);
}
}
}.execute();
}
private static class ButtonStatus {
private boolean onStatus = false;
private boolean offStatus = false;
public boolean isOnStatus() {
return onStatus;
}
public void setOnStatus(boolean onStatus) {
this.onStatus = onStatus;
}
public boolean isOffStatus() {
return offStatus;
}
public void setOffStatus(boolean offStatus) {
this.offStatus = offStatus;
}
}
//模版数据集
private void initButtonGroup() {
final Integer[] modeArray = {TEMPLATE_TABLE_DATA, SERVER_TABLE_DATA};
String[] textArray = {Toolkit.i18nText("Fine-Design_Basic_Tabledata_Source_Type_Template"), Toolkit.i18nText("Fine-Design_Basic_DS_Server_TableData")};
buttonGroup = new UIHeadGroup(textArray) {
public void tabChanged(int index) {
if (op != null) {
op.setDataMode(modeArray[buttonGroup.getSelectedIndex()]);
addMenuDef.setEnabled(modeArray[buttonGroup.getSelectedIndex()] == TEMPLATE_TABLE_DATA);
refreshDockingView();
}
}
};
buttonGroup.setNeedLeftRightOutLine(false);
}
private TableDataWrapper findTableDataWrapper(TreePath treePath) {
if (treePath != null) {
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) treePath.getLastPathComponent();
Object selectedUserObject = selectedTreeNode.getUserObject();
NameObject nameObject = null;
if (selectedUserObject instanceof NameObject) {
nameObject = (NameObject) selectedUserObject;
} else {
selectedTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getParent();
selectedUserObject = selectedTreeNode.getUserObject();
if (selectedUserObject instanceof NameObject) {
nameObject = (NameObject) selectedUserObject;
}
}
if (nameObject != null && nameObject.getObject() instanceof TableDataWrapper) {
return (TableDataWrapper) nameObject.getObject();
}
}
return null;
}
private String getTplPath() {
return HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getPath();
}
enum ESDStatus {
GLOBAL_ON,
GLOBAL_OFF,
SINGLE_ON,
SINGLE_OFF;
}
private Map<DBTableData, ESDStatus> checkCanBeEsdBatchEnableStatus() {
//<数据集, 是否可以被单独开启>
Map<DBTableData, ESDStatus> result = new HashMap<>();
for (int i = 0; i < tableDataTree.getRowCount(); i++) {
TreePath treePath = tableDataTree.getPathForRow(i);
TableDataWrapper wrapper = findTableDataWrapper(treePath);
if (wrapper.getTableData() instanceof DBTableData) {
DBTableData td = (DBTableData) wrapper.getTableData();
StrategyConfig config = StrategyConfigAttrUtils.getStrategyConfig(wrapper.getTableDataName());
if (config == null) {
result.put(td, td.isShare() ? ESDStatus.SINGLE_ON : ESDStatus.SINGLE_OFF);
} else {
if (config.isUseGlobal()) {
if (StrategyConfigHelper.recommended(getTplPath())) {
result.put(td, ESDStatus.GLOBAL_ON);
} else {
result.put(td, ESDStatus.GLOBAL_OFF);
}
} else {
if (config.enabled()) {
result.put(td, ESDStatus.SINGLE_ON);
} else {
result.put(td, ESDStatus.SINGLE_OFF);
}
}
}
}
}
return result;
}
private class EsdOnAction extends AbstractESDAction {
@Override
public String getName() {
return Toolkit.i18nText("Fine-Design_ESD_Batch_Enable");
}
@Override
public Icon getIcon() {
return IOUtils.readIcon("/com/fr/design/images/control/batch_esd_on.png");
}
@Override
public void doWithTableDataWrapper(TableDataWrapper wrapper) {
String dsName = wrapper.getTableDataName();
if (wrapper.getTableData() instanceof DBTableData) {
StrategyConfig strategyConfig = getOrCreateStrategyConfig(dsName);
strategyConfig.setEnable(true);
strategyConfig.setUseGlobal(false);
StrategyConfigAttrUtils.addStrategyConfig(strategyConfig);
DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified();
}
}
}
private @NotNull StrategyConfig getOrCreateStrategyConfig(String dsName) {
StrategyConfig config = StrategyConfigAttrUtils.getStrategyConfig(dsName);
if (config == null) {
config = StrategyConfigHelper.createStrategyConfig(true);
config.setDsName(dsName);
}
return config;
}
private String createDsName(String prefix) {
int count = 1;
allDSNames = DesignTableDataManager.getAllDSNames(tc.getBook());
while (isDsNameRepeaded(prefix + count)) {
count++;
}
return prefix + count;
}
private class EsdOffAction extends AbstractESDAction {
@Override
public String getName() {
return Toolkit.i18nText("Fine-Design_ESD_Batch_Disable");
}
@Override
public Icon getIcon() {
return IOUtils.readIcon("/com/fr/design/images/control/batch_esd_off.png");
}
@Override
public void doWithTableDataWrapper(TableDataWrapper wrapper) {
String dsName = wrapper.getTableDataName();
if (wrapper.getTableData() instanceof DBTableData) {
((DBTableData) wrapper.getTableData()).setShare(false);
StrategyConfig strategyConfig = getOrCreateStrategyConfig(dsName);
strategyConfig.setEnable(false);
strategyConfig.setUseGlobal(false);
StrategyConfigAttrUtils.addStrategyConfig(strategyConfig);
DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified();
}
}
}
private abstract class AbstractESDAction extends UpdateAction {
public abstract String getName();
public abstract Icon getIcon();
public abstract void doWithTableDataWrapper(TableDataWrapper tableDataWrapper);
public AbstractESDAction() {
this.setName(getName());
this.setMnemonic('R');
this.setSmallIcon(getIcon());
}
@Override
public void actionPerformed(ActionEvent e) {
List<TableDataWrapper> tableDataWrapperList = new ArrayList<>();
for (int i = 0; i < tableDataTree.getRowCount(); i++) {
TreePath treePath = tableDataTree.getPathForRow(i);
TableDataWrapper wrapper = findTableDataWrapper(treePath);
if (wrapper != null) {
tableDataWrapperList.add(wrapper);
}
}
if (tableDataWrapperList.isEmpty()) {
return;
}
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
for (TableDataWrapper tableDataWrapper : tableDataWrapperList) {
doWithTableDataWrapper(tableDataWrapper);
}
return null;
}
@Override
protected void done() {
refreshDockingView();
}
}.execute();
}
}
/**
* 新建数据集
* <p>
* 抽象化支持不同类型数据集创建
*/
private abstract class AddAction extends UpdateAction {
protected abstract String getTDName();
protected abstract Icon getTDIcon();
protected abstract String getNamePrefix();
protected abstract TemplateTableDataWrapper getTableDataInstance();
public AddAction() {
this.setName(this.getTDName());
this.setSmallIcon(this.getTDIcon());
}
@Override
public void actionPerformed(ActionEvent e) {
dgEdit(getTableDataInstance().creatTableDataPane(), createDsName(getNamePrefix()), false);
}
}
private class EditAction extends UpdateAction {
public EditAction() {
this.setName(Toolkit.i18nText("Fine-Design_Basic_Edit"));
this.setMnemonic('E');
this.setSmallIcon(IOUtils.readIcon(IconPathConstants.TD_EDIT_ICON_PATH));
}
@Override
public void actionPerformed(ActionEvent e) {
final NameObject selectedNO = tableDataTree.getSelectedNameObject();
if (selectedNO == null) {
return;
}
String dsName = selectedNO.getName();
DesignTableDataManager.removeSelectedColumnNames(dsName);
AbstractTableDataWrapper wrapper = (AbstractTableDataWrapper) selectedNO.getObject();
AbstractTableDataPane<?> tableDataPane = wrapper.creatTableDataPane();
//下面创建creatTableDataPane后会直接populate,所以populate时不能用后设置的一些参数,比如name
dgEdit(tableDataPane, dsName, false);
}
}
private class RemoveAction extends UpdateAction {
public RemoveAction() {
this.setName(Toolkit.i18nText("Fine-Design_Basic_Remove"));
this.setMnemonic('R');
this.setSmallIcon(IOUtils.readIcon(IconPathConstants.TD_REMOVE_ICON_PATH));
}
@Override
public void actionPerformed(ActionEvent e) {
NameObject selectedNO = tableDataTree.getSelectedNameObject();
if (selectedNO == null) {
return;
}
int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + ":" + selectedNO.getName() + "?",
Toolkit.i18nText("Fine-Design_Basic_Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.OK_OPTION) {
// richer:这个地方为什么要在DataSourceTree里面去remove呢?多此一举吧
op.removeAction(selectedNO.getName());
tableDataTree.refresh();
// Richie:默认最后一行获得焦点.
tableDataTree.requestFocus();
tableDataTree.setSelectionRow(tableDataTree.getRowCount() - 1);
fireDSChanged();
checkButtonEnabled();
//删掉缓存配置
StrategyConfigAttrUtils.removeStrategyConfig(selectedNO.getName());
// 如果一个模版是平台开启,这个数据集的配置不会存xml,预览模版时直接从全局配置copy,这样
// 导致删除的时候StrategyConfigsAttrSavedHook没有通过前后配置比较感知数据集被删除,因此不会发出事件让其失效
// 这里额外发出一次数据集修改事件
StrategyEventsNotifier.modifyDataSet(new DSMapping(getTplPath(), new DsNameTarget(selectedNO.getName())));
DesignTableDataManager.removeSelectedColumnNames(selectedNO.getName());
DesignModelAdapter.getCurrentModelAdapter().removeTableDataParameters(selectedNO.getName());
}
}
}
@Override
public void checkEnable() {
this.checkButtonEnabled();
}
}

10
designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java

@ -9,6 +9,7 @@ import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.file.TableDataConfig;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
@ -80,12 +81,13 @@ public class TreeTableDataComboBox extends UIComboBox {
}
public void setSelectedTableDataByName(String name) {
refresh();
TableDataWrapper tableDataWrapper;
if (res_map.get(name) != null) {
tableDataWrapper = res_map.get(name);
} else {
String changeName = DesignTableDataManager.getChangedDsNameByOldDsName(name);
String changeName = DesignTableDataManager.getChangedDsNameByOldDsName(name);
if (StringUtils.isNotEmpty(changeName)) {
tableDataWrapper = res_map.get(changeName);
} else {
tableDataWrapper = res_map.get(name);
}
this.getModel().setSelectedItem(tableDataWrapper);
}

26
designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataDictPane.java

@ -64,7 +64,7 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
tableFlowPane.add(tableDataNameComboBox);
tableDataNameComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
tdChange();
tdChange(true);
}
});
tableFlowPane.add(new PreviewLabel(this));
@ -73,19 +73,21 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
this.add(centerPane, BorderLayout.CENTER);
parentMarkRadio = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Build_Tree_Accord_Parent_Marked_Filed"), true);
lengthMarkRadio = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Build_Tree_Accord_Marked_Filed_Length"));
parentMarkRadio.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
parentMarkRadio.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (isBuildByParentFiled()) {
makeParentEnable();
tdChange();
tdChange(false);
}
}
});
lengthMarkRadio.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
lengthMarkRadio.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (!isBuildByParentFiled()) {
makeLengthEnable();
tdChange();
tdChange(false);
}
}
});
@ -169,7 +171,7 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
}
private void tdChange() {
private void tdChange(boolean isChangeDS) {
TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem();
if (tableDataWrappe == null) {
return;
@ -186,7 +188,9 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
String[] columnNames = new String[len];
namelist.toArray(columnNames);
for (int i = 0; i < valueEditorPanes.length; i++) {
valueEditorPanes[i].setEditors(new Editor[]{new ColumnNameEditor(columnNames), new ColumnIndexEditor(len)}, columnNames[0]);
if (isChangeDS || isNoSelectedColumnName(valueEditorPanes[i])) {
valueEditorPanes[i].setEditors(new Editor[]{new ColumnNameEditor(columnNames), new ColumnIndexEditor(len)}, columnNames[0]);
}
}
} catch (Exception e) {
for (int i = 0; i < valueEditorPanes.length; i++) {
@ -197,6 +201,10 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable {
}
}
private boolean isNoSelectedColumnName(ValueEditorPane valueEditorPane) {
return (Integer) valueEditorPane.update() == -1;
}
@Override
protected String title4PopupWindow() {
return "TreeTableDataDictionay";

37
designer-base/src/main/java/com/fr/design/data/tabledata/strategy/StrategyConfigHandler.java

@ -0,0 +1,37 @@
package com.fr.design.data.tabledata.strategy;
import com.fr.esd.core.strategy.config.StrategyConfig;
import com.fr.esd.query.StrategicTableData;
/**
* @author rinoux
* @version 10.0
* Created by rinoux on 2021/3/19
*/
public abstract class StrategyConfigHandler<T extends StrategicTableData> {
private final T tableData;
public StrategyConfigHandler(T tableData) {
this.tableData = tableData;
}
protected T getTableData() {
return tableData;
}
/**
* 查找配置
*
* @return 缓存配置
*/
public abstract StrategyConfig find();
/**
* 保存配置
*
* @param config 缓存配置
*/
public abstract void save(T saved, StrategyConfig config);
}

551
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java

@ -1,6 +1,5 @@
package com.fr.design.data.tabledata.tabledatapane;
import com.fr.base.BaseUtils;
import com.fr.base.Parameter;
import com.fr.base.ParameterHelper;
import com.fr.data.core.db.TableProcedure;
@ -13,16 +12,22 @@ import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.StrategyConfigAttrUtils;
import com.fr.design.data.datapane.ESDStrategyConfigPane;
import com.fr.design.data.datapane.connect.ConnectionTableProcedurePane;
import com.fr.design.data.datapane.connect.ConnectionTableProcedurePane.DoubleClickSelectedNodeOnTreeListener;
import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.data.datapane.preview.sql.PreviewPerformedSqlPane;
import com.fr.design.data.datapane.sqlpane.SQLEditPane;
import com.fr.design.data.tabledata.strategy.StrategyConfigHandler;
import com.fr.design.data.tabledata.tabledatapane.db.StrategyConfigFrom;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fun.DBTableDataMenuHandler;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itableeditorpane.ParameterTableModel;
import com.fr.design.gui.itableeditorpane.UITableEditAction;
@ -30,11 +35,20 @@ import com.fr.design.gui.itableeditorpane.UITableEditorPane;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants;
import com.fr.design.gui.syntax.ui.rtextarea.RTextScrollPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.menu.SeparatorDef;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.utils.ParameterUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.esd.core.strategy.config.StrategyConfig;
import com.fr.esd.core.strategy.config.StrategyConfigHelper;
import com.fr.esd.core.strategy.config.service.StrategyConfigService;
import com.fr.esd.data.db.DBTableDataSavedHook;
import com.fr.esd.event.DSMapping;
import com.fr.esd.event.DsNameTarget;
import com.fr.esd.event.StrategyEventsNotifier;
import com.fr.esd.query.StrategicTableData;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.general.sql.SqlUtils;
@ -43,6 +57,7 @@ import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import javax.swing.BorderFactory;
import javax.swing.Box;
@ -57,6 +72,7 @@ import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
@ -64,25 +80,45 @@ import java.awt.event.KeyListener;
import java.util.ArrayList;
import java.util.List;
/**
* @author rinoux
* @version 10.0
* Created by rinoux on 2020/7/22
*/
public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
private static final int BOTTOM = 6;
private static final String PREVIEW_BUTTON = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview");
private static final String REFRESH_BUTTON = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh");
private static final String PREVIEW_BUTTON = Toolkit.i18nText("Fine-Design_Basic_Preview");
private static final String REFRESH_BUTTON = Toolkit.i18nText("Fine-Design_Basic_Refresh");
private ConnectionTableProcedurePane connectionTableProcedurePane;
private UITableEditorPane<ParameterProvider> editorPane;
private DBTableDataMenuHandler dbTableDataMenuHandler;
private SQLEditPane sqlTextPane;
private UICheckBox isShareCheckBox;
private MaxMemRowCountPanel maxPanel;
private String pageQuery = null;
private String pageQuery;
private DBTableData dbTableData;
//ESD
private UILabel esdSettingsLabel;
private UIComboBox esdConfigOption;
private UICheckBox esdEnabled;
private UIButton esdSettingsBtn;
private UILabel barErrorTips;
//配置
private StrategyConfig strategyConfig;
private StrategyConfigHandler<DBTableData> configHandler;
public DBTableDataPane() {
init();
initMainSplitPane();
}
private void init() {
this.setLayout(new BorderLayout(4, 4));
setLayout(new BorderLayout(4, 4));
sqlTextPane = new SQLEditPane();
sqlTextPane.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL);
this.sqlTextPane = new SQLEditPane();
this.sqlTextPane.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL);
ParameterTableModel model = new ParameterTableModel() {
@Override
@ -90,25 +126,27 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
return ArrayUtils.add(super.createDBTableAction(), new RefreshAction());
}
};
editorPane = new UITableEditorPane<ParameterProvider>(model);
editorPane = new UITableEditorPane<>(model);
// 左边的Panel,上面是选择DatabaseConnection的ComboBox,下面DatabaseConnection对应的Table
connectionTableProcedurePane = new ConnectionTableProcedurePane() {
this.connectionTableProcedurePane = new ConnectionTableProcedurePane() {
@Override
protected void filter(Connection connection, String conName, List<String> nameList) {
connection.addConnection(nameList, conName, new Class[]{JDBCDatabaseConnection.class, JNDIDatabaseConnection.class});
connection.addConnection(nameList, conName, new Class[]{
JDBCDatabaseConnection.class,
JNDIDatabaseConnection.class
});
}
@Override
protected void addKeyMonitor() {
searchField.addKeyListener(new KeyListener() {
this.searchField.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
//do nothing
}
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
@ -117,45 +155,44 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
}
}
@Override
public void keyReleased(KeyEvent e) {
//do nothing
}
});
}
};
connectionTableProcedurePane.addDoubleClickListener(new DoubleClickSelectedNodeOnTreeListener() {
this.connectionTableProcedurePane.addDoubleClickListener(new ConnectionTableProcedurePane.DoubleClickSelectedNodeOnTreeListener() {
@Override
public void actionPerformed(TableProcedure target) {
Document document = sqlTextPane.getDocument();
Document document = DBTableDataPane.this.sqlTextPane.getDocument();
try {
document.insertString(sqlTextPane.getCaretPosition(), target.toString(), null);
document.insertString(DBTableDataPane.this.sqlTextPane.getCaretPosition(), target.toString(), null);
} catch (BadLocationException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
// 这里开始作色,本来可以给sqlTextPane添加DocumentListener来实现的,
// 后来发现insertString的时候,锁定了JTextPane,不能调用setXXX来作色,先这样了.
// sqlTextPane.syntaxTexts();
sqlTextPane.requestFocus();
DBTableDataPane.this.sqlTextPane.requestFocus();
}
});
sqlTextPane.addFocusListener(new FocusListener() {
this.sqlTextPane.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// do nothing
barErrorTips.setVisible(false);
}
@Override
public void focusLost(FocusEvent e) {
if (isPreviewOrRefreshButton(e)) {
checkParameter();
if (DBTableDataPane.this.isPreviewOrRefreshButton(e)) {
DBTableDataPane.this.checkParameter();
}
}
});
}
private void initMainSplitPane() {
Box box = new Box(BoxLayout.Y_AXIS);
@ -165,106 +202,189 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
northPane.add(editToolBar, BorderLayout.CENTER);
northPane.setBorder(BorderFactory.createEmptyBorder(0, 0, BOTTOM, 0));
RTextScrollPane sqlTextScrollPane = new RTextScrollPane(sqlTextPane);
RTextScrollPane sqlTextScrollPane = new RTextScrollPane(this.sqlTextPane);
sqlTextScrollPane.setLineNumbersEnabled(true);
sqlTextScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC));
sqlTextScrollPane.setPreferredSize(new Dimension(680, 600));
JPanel paraMeanPane = new JPanel(new BorderLayout());
paraMeanPane.setPreferredSize(new Dimension(680, 90));
UILabel paraMean = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Param_DES"));
UILabel paraMean = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Datasource_Param_DES"));
paraMeanPane.add(paraMean, BorderLayout.CENTER);
box.add(northPane);
box.add(sqlTextScrollPane);
box.add(paraMeanPane);
box.add(editorPane);
box.add(this.editorPane);
JPanel sqlSplitPane = new JPanel(new BorderLayout(4, 4));
sqlSplitPane.add(box, BorderLayout.CENTER);
box.setMinimumSize(new Dimension(300, 400));
// 防止数据连接名过长时影响 split pane 分割效果
// 本界面中给MaxMemRowCountPanel留的空间太小,造成MaxMemRowCountPanel显示异常,这边减小一点最小宽度,拉长MaxMemRowCountPanel
connectionTableProcedurePane.setMinimumSize(new Dimension(230, 400));
connectionTableProcedurePane.setMaximumSize(new Dimension(500, 400));
// 使用SplitPane
JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, connectionTableProcedurePane, sqlSplitPane);
this.connectionTableProcedurePane.setMinimumSize(new Dimension(230, 400));
this.connectionTableProcedurePane.setMaximumSize(new Dimension(500, 400));
JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, this.connectionTableProcedurePane, sqlSplitPane);
mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor()));
mainSplitPane.setOneTouchExpandable(true);
this.add(mainSplitPane, BorderLayout.CENTER);
add(mainSplitPane, BorderLayout.CENTER);
}
public DBTableDataPane() {
init();
initMainSplitPane();
}
private boolean isPreviewOrRefreshButton(FocusEvent e) {
if (e.getOppositeComponent() != null) {
String name = e.getOppositeComponent().getName();
return ComparatorUtils.equals(name, PREVIEW_BUTTON) || ComparatorUtils.equals(name, REFRESH_BUTTON);
return (ComparatorUtils.equals(name, PREVIEW_BUTTON) || ComparatorUtils.equals(name, REFRESH_BUTTON));
}
return false;
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS-Database_Query");
return Toolkit.i18nText("Fine-Design_Basic_DS-Database_Query");
}
private void refresh() {
private void refreshParameters() {
String[] paramTexts = new String[2];
paramTexts[0] = SqlUtils.tryPureSqlText(sqlTextPane.getText());
paramTexts[1] = SqlUtils.tryPureSqlText(pageQuery);
List<ParameterProvider> existParameterList = editorPane.update();
Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[0]);
editorPane.populate(ParameterUtils.analyzeAndUnionParameters(paramTexts, ps));
paramTexts[0] = SqlUtils.tryPureSqlText(this.sqlTextPane.getText());
paramTexts[1] = SqlUtils.tryPureSqlText(this.pageQuery);
List<ParameterProvider> existParameterList = this.editorPane.update();
Parameter[] ps = (existParameterList == null) ? new Parameter[0] : existParameterList.toArray(new Parameter[0]);
this.editorPane.populate(ParameterUtils.analyzeAndUnionParameters(paramTexts, ps));
}
private JToolBar createToolBar() {
// p:工具栏.
ToolBarDef toolBarDef = new ToolBarDef();
toolBarDef.addShortCut(new PreviewAction());
toolBarDef.addShortCut(new PreviewPerformedSQLAction());
toolBarDef.addShortCut(SeparatorDef.DEFAULT);
toolBarDef.addShortCut(new EditPageQueryAction());
dbTableDataMenuHandler = ExtraDesignClassManager.getInstance().getSingle(DBTableDataMenuHandler.MARK_STRING);
if (dbTableDataMenuHandler != null) {
this.dbTableDataMenuHandler = ExtraDesignClassManager.getInstance().getSingle("DBTableDataMenuHandler");
if (this.dbTableDataMenuHandler != null) {
toolBarDef.addShortCut(SeparatorDef.DEFAULT);
toolBarDef.addShortCut(dbTableDataMenuHandler.createQueryAction());
toolBarDef.addShortCut(this.dbTableDataMenuHandler.createQueryAction());
}
isShareCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Is_Share_DBTableData"));
isShareCheckBox.setBackground(Color.WHITE);
maxPanel = new MaxMemRowCountPanel();
maxPanel.setBorder(null);
UIToolbar editToolBar = ToolBarDef.createJToolBar();
toolBarDef.updateToolBar(editToolBar);
editToolBar.add(isShareCheckBox);
editToolBar.add(maxPanel);
//esd相关组件初始化
createToolbarEsdComponents(editToolBar);
return editToolBar;
}
private void createToolbarEsdComponents(final UIToolbar editToolBar) {
this.esdSettingsLabel = new UILabel(Toolkit.i18nText("Fine-Design_ESD_Cache_Settings"));
this.esdConfigOption = new UIComboBox(StrategyConfigFrom.values());
this.esdEnabled = new UICheckBox(Toolkit.i18nText("Fine-Design_ESD_Enable_Cache"));
this.barErrorTips = new UILabel();
this.barErrorTips.setForeground(Color.RED);
this.barErrorTips.setVisible(false);
esdSettingsBtn = new UIButton(Toolkit.i18nText("Fine-Design_ESD_Strategy_Config"));
esdSettingsBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final boolean global = globalOptionSelected();
final ESDStrategyConfigPane strategyConfigPane = new ESDStrategyConfigPane(global);
StrategyConfig populateStrategyConfig;
if (global) {
populateStrategyConfig = StrategyConfigService.getGlobalConfig();
} else {
populateStrategyConfig = strategyConfig;
}
//显示对应的配置
strategyConfigPane.populateBean(populateStrategyConfig);
BasicDialog dlg = strategyConfigPane.showMediumWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
super.doOk();
if (!global) {
//点击策略配置面板的确定,重新设置策略配置
strategyConfig = strategyConfigPane.updateBean();
// TODO: 2021/3/12 这个直接使用不太好
}
}
});
dlg.setAlwaysOnTop(true);
dlg.setVisible(true);
}
});
this.esdConfigOption.setSelectedIndex(StrategyConfigFrom.GLOBAL.getIndex());
this.esdConfigOption.addActionListener(e -> setEsdEnabled());
//工具栏加上esd相关组件
editToolBar.add(this.esdSettingsLabel);
editToolBar.add(this.esdConfigOption);
editToolBar.add(this.esdEnabled);
editToolBar.add(this.esdSettingsBtn);
editToolBar.add(this.barErrorTips);
}
private boolean globalOptionSelected() {
return esdConfigOption.getSelectedIndex() == StrategyConfigFrom.GLOBAL.getIndex();
}
private void setEsdEnableStatus(boolean selected, boolean enabled) {
this.esdEnabled.setSelected(selected);
this.esdEnabled.setEnabled(enabled);
}
private void setEsdEnabled() {
boolean useIndividualConfig = !this.globalOptionSelected();
if (useIndividualConfig) {
if (this.strategyConfig == null) {
//新建的数据集,选择单独时,可用但是不勾选
setEsdEnableStatus(false, true);
} else {
setEsdEnableStatus(!this.strategyConfig.isUseGlobal() && this.strategyConfig.enabled(), true);
}
} else {
//判断是不是模版数据集
switch (this.dbTableData.getScope()) {
case TEMPLATE:
String tplPath = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath();
setEsdEnableStatus(StrategyConfigService.isTemplateEnabled(tplPath), false);
break;
case SERVER:
//不会走到这里
default:
break;
}
}
}
public StrategyConfig updateStrategyConfig() {
return this.strategyConfig;
}
private void checkParameter() {
String[] paramTexts = new String[2];
paramTexts[0] = sqlTextPane.getText();
paramTexts[1] = pageQuery;
paramTexts[0] = this.sqlTextPane.getText();
paramTexts[1] = this.pageQuery;
Parameter[] parameters = ParameterHelper.analyze4Parameters(paramTexts, false);
if (parameters.length < 1 && editorPane.update().size() < 1) {
if (parameters.length < 1 && this.editorPane.update().size() < 1) {
return;
}
boolean isIn = true;
List<ParameterProvider> list = editorPane.update();
List<String> name = new ArrayList<String>();
for (int i = 0; i < list.size(); i++) {
name.add(list.get(i).getName());
List<ParameterProvider> list = this.editorPane.update();
List<String> name = new ArrayList<>();
for (ParameterProvider parameter : list) {
name.add(parameter.getName());
}
for (int i = 0; i < parameters.length; i++) {
if (!name.contains(parameters[i].getName())) {
for (Parameter parameter : parameters) {
if (!name.contains(parameter.getName())) {
isIn = false;
break;
}
@ -272,101 +392,162 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
if (list.size() == parameters.length && isIn) {
return;
}
// bug:34175 删了是否刷新对话框, 均直接刷新
refresh();
refreshParameters();
}
@Override
public void populateBean(DBTableData dbtabledata) {
this.dbTableData = dbtabledata;
if (dbTableDataMenuHandler != null) {
dbTableDataMenuHandler.populate(dbtabledata);
public void populateBean(DBTableData dbTableData) {
this.dbTableData = dbTableData;
if (this.dbTableDataMenuHandler != null) {
this.dbTableDataMenuHandler.populate(dbTableData);
}
ParameterProvider[] parameters = null;
Calculator c = Calculator.createCalculator();
parameters = dbtabledata.getParameters(c);
editorPane.populate(parameters);
ParameterProvider[] parameters = dbTableData.getParameters(c);
this.editorPane.populate(parameters);
com.fr.data.impl.Connection db = null;
String query = null;
boolean isShare = false;
int maxMemeryRow = -1;
db = dbtabledata.getDatabase();
query = dbtabledata.getQuery();
isShare = dbtabledata.isShare();
maxMemeryRow = dbtabledata.getMaxMemRowCount();
this.pageQuery = dbtabledata.getPageQuerySql();
Connection db = dbTableData.getDatabase();
String query = dbTableData.getQuery();
this.pageQuery = dbTableData.getPageQuerySql();
this.connectionTableProcedurePane.setSelectedDatabaseConnection(db);
this.sqlTextPane.setText(query);
this.sqlTextPane.requestFocus();
this.sqlTextPane.moveCaretPosition(this.sqlTextPane.getCaretPosition());
isShareCheckBox.setSelected(isShare);
maxPanel.setValue(maxMemeryRow);
switch (dbTableData.getScope()) {
case TEMPLATE:
this.configHandler = new TemplateStrategyConfigHandler(dbTableData);
break;
case SERVER:
//服务器数据集
default:
//新建服务器数据集
this.configHandler = new ServerStrategyConfigHandler(dbTableData);
break;
}
//设置esd相关组件显示状态
populateESDComponents();
}
private void populateESDComponents() {
//查找映射的配置
this.strategyConfig = configHandler.find();
boolean shouldEnable = false;
StrategyConfigFrom from = StrategyConfigFrom.GLOBAL;
if (this.strategyConfig != null) {
if (this.strategyConfig.enabled()) {
shouldEnable = true;
}
if (!this.strategyConfig.isUseGlobal()) {
from = StrategyConfigFrom.INDIVIDUAL;
}
}
//服务器数据集不允许设置来源,只能单独配置
if (dbTableData.getScope() != StrategicTableData.Scope.TEMPLATE) {
from = StrategyConfigFrom.INDIVIDUAL;
this.esdConfigOption.setEnabled(false);
}
this.esdEnabled.setSelected(shouldEnable);
this.esdConfigOption.setSelectedIndex(from.getIndex());
}
@Override
public DBTableData updateBean() {
updateDBTableData();
internalUpdateStrategyConfig();
return this.dbTableData;
}
private void internalUpdateStrategyConfig() {
//这边只修改enable和useGlobal
boolean global = globalOptionSelected();
boolean enable = this.esdEnabled.isSelected();
//未开启缓存的,如果选择了单独配置,需要创建配置
if (this.strategyConfig == null && !global) {
this.strategyConfig = StrategyConfig.createDefault();
}
//设置配置来源和开启状态
if (this.strategyConfig != null) {
this.strategyConfig.setEnable(enable);
this.strategyConfig.setUseGlobal(global);
}
//保存
this.configHandler.save(this.dbTableData, this.strategyConfig);
}
private void updateDBTableData() {
String dbName = this.connectionTableProcedurePane.getSelectedDatabaseConnnectonName();
if (StringUtils.isBlank(dbName) || StringUtils.isBlank(this.sqlTextPane.getText())) {
try {
throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + ".");
} catch (Exception ignore) {
// JOptionPane.showMessageDialog(DBTableDataPane.this,
// com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + ".");
throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") + ".");
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
// 保存前 刷新下参数列表 保证获取到最新的参数
refresh();
List<ParameterProvider> parameterList = editorPane.update();
Parameter[] parameters = parameterList.toArray(new Parameter[parameterList.size()]);
refreshParameters();
List<ParameterProvider> parameterList = this.editorPane.update();
ParameterProvider[] parameters = parameterList.toArray(new ParameterProvider[0]);
dbTableData.setDatabase(new NameDatabaseConnection(dbName));
// p:必须先设置Parameters数组,因为setQuery里面会自动设置的
dbTableData.setParameters(parameters);
dbTableData.setQuery(this.sqlTextPane.getText());
dbTableData.setQuery(this.sqlTextPane.getText().trim());
dbTableData.setShare(isShareCheckBox.isSelected());
dbTableData.setMaxMemRowCount(maxPanel.getValue());
dbTableData.setPageQuerySql(this.pageQuery);
if (dbTableDataMenuHandler != null) {
dbTableDataMenuHandler.update();
if (this.dbTableDataMenuHandler != null) {
this.dbTableDataMenuHandler.update();
}
return dbTableData;
}
protected class RefreshAction extends UITableEditAction {
public RefreshAction() {
this.setName(REFRESH_BUTTON);
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png"));
setName(REFRESH_BUTTON);
setSmallIcon(IOUtils.readIcon("/com/fr/design/images/control/refresh.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
refresh();
DBTableDataPane.this.refreshParameters();
}
@Override
public void checkEnabled() {
// do nothing
}
}
private class PreviewAction extends UpdateAction {
public PreviewAction() {
this.setName(PREVIEW_BUTTON);
this.setMnemonic('P');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png"));
setName(PREVIEW_BUTTON);
setMnemonic('P');
setSmallIcon(IOUtils.readIcon("/com/fr/design/images/m_file/preview.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
checkParameter();
DBTableDataPane.this.checkParameter();
PreviewTablePane.previewTableData(DBTableDataPane.this.updateBean());
}
}
@ -387,14 +568,14 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
private class EditPageQueryAction extends UpdateAction {
public EditPageQueryAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Page_Query"));
this.setName(Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Page_Query"));
this.setMnemonic('L');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/text.png"));
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/m_file/text.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
final QueryPane pane = new QueryPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Define_Page_Query_SQL"));
final QueryPane pane = new QueryPane(Toolkit.i18nText("Fine-Design_Basic_Layer_Page_Report_Define_Page_Query_SQL"));
pane.populate(pageQuery);
BasicDialog dialog = pane.showWindow(DesignerContext.getDesignerFrame());
dialog.addDialogActionListener(new DialogActionAdapter() {
@ -408,9 +589,9 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
}
}
private class QueryPane extends BasicPane {
private static class QueryPane extends BasicPane {
private SQLEditPane pageQueryPane;
private String title;
private final String title;
public QueryPane(String title) {
this.title = title;
@ -427,21 +608,135 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
if (StringUtils.isBlank(text)) {
return;
}
pageQueryPane.setText(text);
this.pageQueryPane.setText(text);
}
public String update() {
String text = pageQueryPane.getText();
String text = this.pageQueryPane.getText();
if (StringUtils.isBlank(text)) {
return null;
} else {
return text;
}
return text;
}
@Override
protected String title4PopupWindow() {
return title;
return this.title;
}
}
/**
* 服务器数据集配置处理器
*/
private static class ServerStrategyConfigHandler extends StrategyConfigHandler<DBTableData> {
private final String origName;
private final String origConnection;
private final String origQuery;
public ServerStrategyConfigHandler(DBTableData tableData) {
super(tableData);
this.origName = tableData.getDsName();
this.origConnection = tableData.getDatabase().toString();
this.origQuery = tableData.getQuery();
}
@Override
public StrategyConfig find() {
StrategyConfig strategyConfig = null;
if (getTableData() != null) {
strategyConfig = getTableData().getStrategyConfig();
if (strategyConfig == null) {
//共享数据集
if (getTableData().isShare()) {
strategyConfig = StrategyConfigHelper.createStrategyConfig(true, false, true);
}
}
}
return strategyConfig;
}
@Override
public void save(DBTableData saved, StrategyConfig strategyConfig) {
String conn = saved.getDatabase().toString();
String query = saved.getQuery();
//检查数据链接和sql是否修改,如果修改需要触发缓存监听事件
if (!conn.equals(origConnection) || !query.equals(origQuery)) {
if (StringUtils.isNotEmpty(origName)) {
//新建数据集的origName为null,不用触发
StrategyEventsNotifier.modifyDataSet(DSMapping.ofServerDS(new DsNameTarget(origName)));
}
}
//配置变动事件
try {
final StrategyConfig orig = getTableData().getStrategyConfig();
saved.setStrategyConfig(strategyConfig.clone());
StrategyEventsNotifier.compareAndFireConfigEvents(orig, strategyConfig, DSMapping.ofServerDS(new DsNameTarget(saved.getDsName())));
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
/**
* 模版数据集配置处理器
*/
private static class TemplateStrategyConfigHandler extends StrategyConfigHandler<DBTableData> {
public TemplateStrategyConfigHandler(DBTableData tableData) {
super(tableData);
}
@Override
public StrategyConfig find() {
StrategyConfig strategyConfig = null;
String tplPath = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath();
if (getTableData() != null && StringUtils.isNotEmpty(tplPath)) {
//设置保存数据集的事件检查钩子
//新建模版此时不存在,不需要注册钩子
if (getTableData().getXmlSavedHook() == null && WorkContext.getWorkResource().exist(tplPath)) {
getTableData().setXmlSavedHook(new DBTableDataSavedHook(tplPath, getTableData()));
}
//获取当前的缓存配置,没有就创建一份
String dsName = getTableData().getDsName();
//这里为了之前兼容插件创建的配置,缓存配置不在DBTableData,而是从模版attr读取
strategyConfig = StrategyConfigAttrUtils.getStrategyConfig(dsName);
if (useGlobal(getTableData(), strategyConfig)) {
//使用全局配置
strategyConfig = StrategyConfigHelper.createStrategyConfig(true);
} else if (getTableData().isShare()) {
//使用共享数据集兼容配置
strategyConfig = StrategyConfigHelper.createStrategyConfig(true, false, true);
}
}
return strategyConfig;
}
private boolean useGlobal(DBTableData dbTableData, StrategyConfig strategyConfig) {
//非共享且配置为空或者指定使用全局配置时,检查是否全局开启
if (strategyConfig == null) {
return !dbTableData.isShare();
} else {
return strategyConfig.isUseGlobal();
}
}
@Override
public void save(DBTableData saved, StrategyConfig config) {
//DBTableDataSavedHook处理了
}
}
}

3
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java

@ -8,10 +8,12 @@ import com.fr.data.impl.NameDatabaseConnection;
import com.fr.data.impl.storeproc.ProcedureDataModel;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.data.operator.DataOperator;
import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.UpdateAction;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.data.datapane.connect.ConnectionTableProcedurePane;
import com.fr.design.data.datapane.connect.ConnectionTableProcedurePane.DoubleClickSelectedNodeOnTreeListener;
import com.fr.design.data.datapane.sqlpane.SQLEditPane;
@ -291,6 +293,7 @@ public class ProcedureDataPane extends AbstractTableDataPane<StoreProcedure> imp
sp.setCalculating(false);
doAfterProcudureDone();
fireDSChanged();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
}
};

33
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/db/StrategyConfigFrom.java

@ -0,0 +1,33 @@
package com.fr.design.data.tabledata.tabledatapane.db;
import com.fr.design.i18n.Toolkit;
public enum StrategyConfigFrom {
GLOBAL(0, Toolkit.i18nText("Fine-Design_ESD_Use_Global_Settings")),
INDIVIDUAL(1, Toolkit.i18nText("Fine-Design_ESD_Use_Individual_Settings"));
int index;
String displayText;
StrategyConfigFrom(int index, String displayText) {
this.index = index;
this.displayText = displayText;
}
public int getIndex() {
return this.index;
}
public String getDisplayText() {
return this.displayText;
}
public String toString() {
return getDisplayText();
}
}

14
designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java

@ -731,6 +731,16 @@ public class MutilTempalteTabPane extends JComponent {
}
}
/**
* 后台关闭当前编辑模板
*/
public void closeCurrentTpl(){
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
this.setIsCloseCurrent(true);
this.closeFormat(jTemplate);
this.closeSpecifiedTemplate(jTemplate);
}
/**
* 关闭模板
*
@ -765,8 +775,8 @@ public class MutilTempalteTabPane extends JComponent {
// 如果关闭的模板是当前选中的模板,则重新激活当前 selectIndex 的模板;
// selectIndex 没有变化,但是对应的模板已经变成了前一张模板
if (closeIconIndex == selectedIndex || isCloseCurrent) {
// 如果 closeIconIndex 是最后一个被渲染画出的,那么预览上一个,防止数组越界
if (closeIconIndex >= maxPaintIndex) {
// 如果当前关闭的模板在最右侧,那么预览上一个,防止数组越界
if (selectedIndex >= maxPaintIndex) {
// selectIndex 不会 <0 因为如果关闭的是打开的最后一个模板,那么关闭之后 openedTemplate.isEmpty() = true
selectedIndex--;
}

26
designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java

@ -17,6 +17,7 @@ import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.file.filetree.IOFileNodeFilter;
import com.fr.form.fit.web.editpreview.FileLockStateObservable;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
@ -47,6 +48,8 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Objects;
import java.util.Observable;
import java.util.Observer;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
import static javax.swing.JOptionPane.YES_NO_OPTION;
@ -76,6 +79,13 @@ public class TemplateTreePane extends JPanel implements FileOperations {
scrollPane.setBorder(null);
contentPane.add(scrollPane, BorderLayout.CENTER);
FileLockStateObservable.getInstance().addObserver(new Observer() {
@Override
public void update(Observable o, Object arg) {
TemplateTreePane.this.refresh();
}
});
/*
* Tree.MouseAdapter
*/
@ -202,15 +212,13 @@ public class TemplateTreePane extends JPanel implements FileOperations {
@Override
public void openFile() {
// 判断是否是远程设计的锁定文件
if (!WorkContext.getCurrent().isLocal()) {
FileNode node = reportletsTree.getSelectedFileNode();
if (node == null) {
return;
}
String lock = node.getLock();
if (lock != null && !lock.equals(node.getUserID())) {
return;
}
FileNode node = reportletsTree.getSelectedFileNode();
if (node == null) {
return;
}
String lock = node.getLock();
if (lock != null && !lock.equals(node.getUserID())) {
return;
}
String reportPath = reportletsTree.getSelectedTemplatePath();
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath);

330
designer-base/src/main/java/com/fr/design/formula/FormulaPane.java

@ -2,32 +2,78 @@ package com.fr.design.formula;
import com.fr.base.BaseFormula;
import com.fr.base.BaseUtils;
import com.fr.base.Parameter;
import com.fr.base.ParameterMapNameSpace;
import com.fr.base.TableDataNameSpace;
import com.fr.base.Utils;
import com.fr.base.io.IOFile;
import com.fr.data.TableDataSource;
import com.fr.design.actions.UpdateAction;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ilist.QuickList;
import com.fr.design.gui.itableeditorpane.ParameterTableModel;
import com.fr.design.gui.itableeditorpane.UITableEditorPane;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.parameter.ParameterInputPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.FArray;
import com.fr.log.FineLoggerFactory;
import com.fr.parser.ArrayExpression;
import com.fr.parser.BlockIntervalLiteral;
import com.fr.parser.ColumnRowRangeInPage;
import com.fr.parser.FRLexer;
import com.fr.parser.FRParser;
import com.fr.parser.NumberLiteral;
import com.fr.parser.SheetIntervalLiteral;
import com.fr.report.core.namespace.SimpleCellValueNameSpace;
import com.fr.script.Calculator;
import com.fr.script.ScriptConstants;
import com.fr.script.checker.FunctionCheckerDispatcher;
import com.fr.script.checker.exception.ConditionCheckWrongException;
import com.fr.script.checker.exception.FunctionCheckWrongException;
import com.fr.script.rules.FunctionParameterType;
import com.fr.script.rules.FunctionRule;
import com.fr.stable.EncodeConstants;
import com.fr.stable.EssentialUtils;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fr.stable.UtilEvalError;
import com.fr.stable.script.CRAddress;
import com.fr.stable.script.ColumnRowRange;
import com.fr.stable.script.Expression;
import javax.swing.*;
import com.fr.stable.script.Node;
import com.fr.stable.script.Tiny;
import com.fr.stable.script.TinyHunter;
import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTree;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TreeSelectionEvent;
@ -37,7 +83,10 @@ import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.MutableTreeNode;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
@ -52,10 +101,16 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 公式编辑面板
@ -65,6 +120,10 @@ import java.util.List;
*/
public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
public static final String VALID_FORMULA = Toolkit.i18nText("Fine-Design_Basic_FormulaD_Valid_Formula");
public static final String INVALID_FORMULA = Toolkit.i18nText("Fine-Design_Basic_FormulaD_Invalid_Formula");
public static final int DEFUAL_FOMULA_LENGTH = 103;
public static final String ELLIPSIS = "...";
private VariableTreeAndDescriptionArea variableTreeAndDescriptionArea;
private RSyntaxTextArea formulaTextArea;
private UITextField keyWordTextField = new UITextField(18);
@ -78,6 +137,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
private QuickList functionTypeList;
private DefaultListModel functionNameModel;
private JList functionNameList;
private UITableEditorPane<ParameterProvider> editor4CalPane;
public FormulaPane() {
initComponents();
@ -201,6 +261,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
private void initTextPane() {
// text
JPanel textPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(textPane, BorderLayout.CENTER);
JPanel checkBoxandbuttonPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
@ -217,13 +278,19 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
UIButton checkValidButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Check_Valid"));
UIButton calButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Button"));
checkValidButton.addActionListener(checkValidActionListener);
calButton.addActionListener(calculateActionListener);
JPanel checkBoxPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
checkBoxPane.setPreferredSize(new Dimension(450, 30));
checkBoxandbuttonPane.add(checkBoxPane, BorderLayout.WEST);
checkBoxandbuttonPane.add(checkValidButton, BorderLayout.EAST);
checkBoxandbuttonPane.add(calButton, BorderLayout.EAST);
extendCheckBoxPane(checkBoxPane);
ParameterTableModel model = new ParameterTableModel(0);
editor4CalPane = new UITableEditorPane<>(model);
}
@ -585,40 +652,254 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
}
// check valid
private ActionListener checkValidActionListener = new ActionListener() {
private final ActionListener checkValidActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
// Execute Formula default cell element.
String formulaText = formulaTextArea.getText().trim();
String formulaValidMessage = getFormulaValidMessage(formulaText);
FineJOptionPane.showMessageDialog(
FormulaPane.this,
formulaValidMessage + ".",
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
JOptionPane.INFORMATION_MESSAGE);
}
};
if (formulaText != null && formulaText.length() > 0) {
StringReader in = new StringReader(formulaText);
FRLexer lexer = new FRLexer(in);
FRParser parser = new FRParser(lexer);
Expression expression = null;
try {
expression = parser.parse();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
// alex:继续往下面走,expression为null时告知不合法公式
private static String getFormulaValidMessage(String formulaText) {
StringReader in = new StringReader(formulaText);
FRLexer lexer = new FRLexer(in);
FRParser parser = new FRParser(lexer);
try {
Expression expression = parser.parse();
Node node = expression.getConditionalExpression();
return FunctionCheckerDispatcher.getInstance()
.getFunctionChecker(node)
.checkFunction(node) ? VALID_FORMULA : INVALID_FORMULA;
} catch (ConditionCheckWrongException cce) {
String functionName = cce.getFunctionName();
StringBuilder errorMsg = new StringBuilder(functionName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Condition_Tips") + ":");
return errorMsg.toString();
} catch (FunctionCheckWrongException ce) {
List<FunctionRule> rules = ce.getRules();
String functionName = ce.getFunctionName();
StringBuilder errorMsg = new StringBuilder(functionName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Error_Tips") + ":");
for (int i = 0; i < rules.size(); i++) {
errorMsg.append("(");
if (rules.get(i).getParameterList().isEmpty()) {
errorMsg.append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_No_Param"));
}
for (FunctionParameterType functionParameterType : rules.get(i).getParameterList()) {
errorMsg.append(getTypeString(functionParameterType)).append(",");
}
if (",".equals(errorMsg.charAt(errorMsg.length() - 1) + "")) {
errorMsg.deleteCharAt(errorMsg.length() - 1);
}
errorMsg.append(")");
if (i != rules.size() - 1) {
errorMsg.append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_Or"));
}
}
return errorMsg.toString();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return INVALID_FORMULA;
// alex:继续往下面走,expression为null时告知不合法公式
}
}
private static String getTypeString(FunctionParameterType type) {
switch (type) {
case NUMBER:
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Number");
case STRING:
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_String");
case ANY:
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Any");
case DATE:
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Date");
case BOOLEAN:
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Boolean");
case ARRAY:
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Check_ParamType_Array");
}
return "";
}
private final ActionListener calculateActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String formulaText = formulaTextArea.getText().trim();
String formulaValidMessage = getFormulaValidMessage(formulaText);
String unSupportFormula = containsUnsupportedSimulationFormulas(formulaText);
if (unSupportFormula != null) {
FineJOptionPane.showMessageDialog(
FormulaPane.this,
/*
* alex:仅仅只需要根据expression是否为null作合法性判断
* 不需要eval
* TODO 但有个问题,有些函数的参数个数是有规定的,何以判别之
*/
(expression != null ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Valid_Formula") : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Invalid_Formula")) + ".",
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Unsupported_Formulas") + ":" + unSupportFormula,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
JOptionPane.INFORMATION_MESSAGE);
return;
}
String messageTips;
if (formulaValidMessage.equals(INVALID_FORMULA)) {
messageTips = INVALID_FORMULA;
} else {
messageTips = formulaValidMessage.equals(VALID_FORMULA) ? "" : formulaValidMessage + "\n";
Map<String, Object> paramsMap = setParamsIfExist(formulaText);
Calculator calculator = Calculator.createCalculator();
ParameterMapNameSpace parameterMapNameSpace = ParameterMapNameSpace.create(paramsMap);
calculator.pushNameSpace(parameterMapNameSpace);
JTemplate<?, ?> currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (currentEditingTemplate != null) {
IOFile file = (IOFile) currentEditingTemplate.getTarget();
calculator.setAttribute(TableDataSource.KEY, file);
calculator.pushNameSpace(TableDataNameSpace.getInstance());
calculator.pushNameSpace(SimpleCellValueNameSpace.getInstance());
}
BaseFormula baseFormula = BaseFormula.createFormulaBuilder().build(formulaText);
try {
Object value = calculator.evalValue(baseFormula);
String objectToString = EssentialUtils.objectToString(value);
String result = objectToString.length() > DEFUAL_FOMULA_LENGTH ?
objectToString.substring(0, DEFUAL_FOMULA_LENGTH - ELLIPSIS.length()) + ELLIPSIS : objectToString;
messageTips = messageTips +
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Result") + ":" + result;
FineLoggerFactory.getLogger().info("value:{}", value);
} catch (UtilEvalError utilEvalError) {
FineLoggerFactory.getLogger().error("", utilEvalError);
}
}
FineJOptionPane.showMessageDialog(
FormulaPane.this,
messageTips,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
JOptionPane.INFORMATION_MESSAGE);
}
};
private String containsUnsupportedSimulationFormulas(String formulaText) {
try {
Expression expression = Calculator.createCalculator().parse(formulaText);
UnsupportedFormulaScanner scanner = new UnsupportedFormulaScanner();
if (!scanner.travelFormula(expression.getConditionalExpression())) {
return scanner.getUnSupportFormula();
}
UnsupportedSimulationNodeHunter unsupportedSimulationFormulaHunter = new UnsupportedSimulationNodeHunter();
expression.traversal4Tiny(unsupportedSimulationFormulaHunter);
return unsupportedSimulationFormulaHunter.isSupported() ? null : unsupportedSimulationFormulaHunter.getUnSupportedNode();
} catch (Exception e) {
FineLoggerFactory.getLogger().error("", e);
}
return null;
}
private Map<String, Object> setParamsIfExist(String formulaText) {
Map<String, Object> parameterMap = new HashMap<>();
try {
Calculator calculator = Calculator.createCalculator();
Expression expression = calculator.parse(formulaText);
ParameterCellHunter parameterCellHunter = new ParameterCellHunter();
expression.traversal4Tiny(parameterCellHunter);
Parameter[] parameters = parameterCellHunter.getParameterBooty();
if (parameters.length < 1 && editor4CalPane.update().size() < 1) {
return parameterMap;
}
ParameterInputPane pPane = new ParameterInputPane(parameters);
pPane.showSmallWindow(new JFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
parameterMap.putAll(pPane.update());
}
}).setVisible(true);
//过滤出数组参数,如:[1,2]
for (Map.Entry<String, Object> entry : parameterMap.entrySet()) {
if (entry.getValue().toString().startsWith("[") && entry.getValue().toString().endsWith("]")) {
Expression parse = calculator.parse(entry.getValue());
ArrayExpression arrayExpression = (ArrayExpression) parse.getConditionalExpression();
Node[] arrays = arrayExpression.getArrays();
List<Object> arrayList = new ArrayList<>();
for (Node array : arrays) {
if (array instanceof NumberLiteral) {
arrayList.add(NumberFormat.getInstance().parse(array.toString()));
} else {
arrayList.add(array);
}
}
FArray<Object> fArray = new FArray<>(arrayList);
parameterMap.put(entry.getKey(), fArray);
} else if (Utils.isNumeric(entry.getValue().toString())) {
try {
Number number = NumberFormat.getInstance().parse(entry.getValue().toString());
parameterMap.put(entry.getKey(), number);
} catch (Exception e) {
FineLoggerFactory.getLogger().warn("", e);
}
}
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error("", e);
}
return parameterMap;
}
private static class ParameterCellHunter extends TinyHunter {
private final Set<Parameter> parameterList = new HashSet<>();
Parameter[] getParameterBooty() {
return parameterList.toArray(new Parameter[0]);
}
public void hunter4Tiny(Tiny tiny) {
String statement = tiny.getStatement();
if (StringUtils.isNotBlank(statement) && statement.startsWith(ScriptConstants.DETAIL_TAG)) {
if (statement.startsWith(ScriptConstants.SUMMARY_TAG)) {
parameterList.add(new Parameter(statement));
} else {
parameterList.add(new Parameter(statement.substring(1)));
}
} else if (tiny.getClass() == ColumnRowRange.class ||
tiny.getClass() == SheetIntervalLiteral.class || tiny.getClass() == BlockIntervalLiteral.class) {
parameterList.add(new Parameter(tiny.toString()));
}
}
}
private static class UnsupportedSimulationNodeHunter extends TinyHunter {
private boolean supported = true;
private String unSupportedNode;
private String[] curReportVariables;
public UnsupportedSimulationNodeHunter() {
curReportVariables = VariableResolver.DEFAULT.resolveCurReportVariables();
}
public boolean isSupported() {
return supported;
}
public String getUnSupportedNode() {
return unSupportedNode;
}
public void hunter4Tiny(Tiny tiny) {
if (tiny.getClass() == ColumnRowRangeInPage.class || tiny.getClass() == CRAddress.class
|| Arrays.asList(curReportVariables).contains(tiny.toString())) {
supported = false;
unSupportedNode = tiny.toString();
}
}
}
public class VariableTreeAndDescriptionArea extends JPanel {
private JTree variablesTree;
@ -805,13 +1086,13 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode selectedTreeNode = (DefaultMutableTreeNode) variablesTree.getLastSelectedPathComponent();
Object selectedValue = selectedTreeNode.getUserObject();
Object selectedParentValue = ((DefaultMutableTreeNode)selectedTreeNode.getParent()).getUserObject();
Object selectedParentValue = ((DefaultMutableTreeNode) selectedTreeNode.getParent()).getUserObject();
if (selectedValue == null) {
return;
}
if (selectedValue instanceof TextUserObject) {
if (selectedValue instanceof TextUserObject) {
//有公式说明的条件:1.属于TextUserObject 2.parent是系统参数
if (ComparatorUtils.equals(((TextFolderUserObject) selectedParentValue).getText(),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaPane_Variables"))) {
@ -1010,6 +1291,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
/**
* 把以关键词开头的和不以关键词开头的分别按照字母表顺序排序
*
* @param o1 待比较对象1
* @param o2 待比较对象2
* @return 比较结果1表示 o1 > o2, -1表示 o1 < o2, 0表示 o1 = o2

54
designer-base/src/main/java/com/fr/design/formula/UnsupportedFormulaScanner.java

@ -0,0 +1,54 @@
package com.fr.design.formula;
import com.fr.parser.BinaryExpression;
import com.fr.parser.DatasetFunctionCall;
import com.fr.parser.FunctionCall;
import com.fr.stable.script.Node;
import java.util.Arrays;
/**
* @author Hoky
* @date 2021/8/30
*/
public class UnsupportedFormulaScanner {
public final static String[] UNSUPPORTED_FORMULAS = new String[]{"PROPORTION", "TOIMAGE",
"WEBIMAGE", "SORT", "CROSSLAYERTOTAL", "CIRCULAR", "LAYERTOTAL", "MOM", "HIERARCHY",
"FILENAME", "FILESIZE", "FILETYPE", "TREELAYER", "GETUSERDEPARTMENTS", "GETUSERJOBTITLES"};
private String unSupportFormula = "";
public boolean travelFormula(Node node) {
if (node instanceof FunctionCall) {
if (isUnsupportedFomula(((FunctionCall) node).getName())) {
unSupportFormula = ((FunctionCall) node).getName();
return false;
} else {
for (Node argument : ((FunctionCall) node).getArguments()) {
if (!travelFormula(argument)) {
return false;
}
}
}
} else if (node instanceof BinaryExpression) {
for (Node array : ((BinaryExpression) node).getNodes()) {
if (!travelFormula(array)) {
return false;
}
}
} else if (node instanceof DatasetFunctionCall) {
DatasetFunctionCall datasetFunctionCall = (DatasetFunctionCall) node;
unSupportFormula = datasetFunctionCall.getSourceName() + "." + datasetFunctionCall.getFnName() + "()";
return false;
}
return true;
}
public String getUnSupportFormula() {
return unSupportFormula;
}
private static boolean isUnsupportedFomula(String formula) {
return Arrays.asList(UNSUPPORTED_FORMULAS).contains(formula.toUpperCase());
}
}

19
designer-base/src/main/java/com/fr/design/fun/PcFitProvider.java

@ -0,0 +1,19 @@
package com.fr.design.fun;
import com.fr.stable.fun.mark.Mutable;
public interface PcFitProvider extends Mutable {
String XML_TAG = "PcFitProvider";
int CURRENT_LEVEL = 1;
//设计器上看到的选项
String getContentDisplayValue();
//返回给前端的值
int getContentDisplayKey();
//设计器上的提示信息
String getContentDisplayTip();
}

9
designer-base/src/main/java/com/fr/design/fun/PreviewProvider.java

@ -2,6 +2,7 @@ package com.fr.design.fun;
import com.fr.design.mainframe.JTemplate;
import com.fr.stable.Filter;
import com.fr.stable.StringUtils;
import com.fr.stable.fun.mark.Mutable;
import java.util.Map;
@ -62,5 +63,13 @@ public interface PreviewProvider extends Mutable, Filter<JTemplate> {
*/
String getActionType();
/**
* 下拉弹出菜单的提示
* @return 弹出菜单的提示
*/
default String tooltipForPopItem() {
return StringUtils.EMPTY;
}
}

19
designer-base/src/main/java/com/fr/design/fun/impl/AbstractPcFitProvider.java

@ -0,0 +1,19 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.PcFitProvider;
import com.fr.stable.fun.mark.API;
@API(level = PcFitProvider.CURRENT_LEVEL)
public abstract class AbstractPcFitProvider implements PcFitProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public String mark4Provider() {
return getClass().getName();
}
}

28
designer-base/src/main/java/com/fr/design/fun/impl/DesignerStartWithEmptyFile.java

@ -0,0 +1,28 @@
package com.fr.design.fun.impl;
import com.fr.file.FILE;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.record.analyzer.EnableMetrics;
/**
* Created by rinoux on 2016/12/16.
*/
@EnableMetrics
public class DesignerStartWithEmptyFile extends AbstractDesignerStartOpenFileProcessor {
private static final DesignerStartWithEmptyFile INSTANCE = new DesignerStartWithEmptyFile();
private DesignerStartWithEmptyFile() {
}
public static DesignerStartWithEmptyFile getInstance() {
return INSTANCE;
}
@Override
@Focus(id = "com.fr.dzstartemptyfile", text = "Fine_Design_Start_Empty_File", source = Original.REPORT)
public FILE fileToShow() {
return null;
}
}

11
designer-base/src/main/java/com/fr/design/gui/frpane/JTreeAutoBuildPane.java

@ -27,13 +27,16 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.stable.StringUtils;
import java.awt.*;
import javax.swing.JPanel;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.List;
import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
public class JTreeAutoBuildPane extends BasicPane implements PreviewLabel.Previewable, EditOrNewLabel.Editable {
private TreeTableDataComboBox treeTableDataComboBox;

21
designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java

@ -10,6 +10,7 @@ import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.GeneralUtils;
import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils;
@ -27,7 +28,8 @@ import java.math.BigDecimal;
* For input Number.
*/
public abstract class UnitInputPane extends BasicPane {
private static final double NUM_POINT = 0.000001;
private static final double MAX_NUM = 3000.0D;
private static final double NUM_POINT = 0.000001;
private int scale = -1;
String title;
@ -46,7 +48,7 @@ public abstract class UnitInputPane extends BasicPane {
centerPane.add(titleLabel);
// Denny:在对话框中加入JSpinner对象
numberFieldSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, 999, 1));
numberFieldSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, MAX_NUM, 1));
GUICoreUtils.setColumnForSpinner(numberFieldSpinner, 24);
numberFieldSpinner.setPreferredSize(new Dimension(60, 20));
numberFieldSpinner.setMinimumSize(new Dimension(60, 20));
@ -71,17 +73,17 @@ public abstract class UnitInputPane extends BasicPane {
public void populate(float floatValue) {
popValue = floatValue;
numberFieldSpinner.setModel(new SpinnerNumberModel(0.00, 0.00, 999.00, 0.01));
numberFieldSpinner.setModel(new SpinnerNumberModel(0.00, 0.00, MAX_NUM, 0.01));
JFormattedTextField temp = GUICoreUtils.getSpinnerTextField(numberFieldSpinner);
addChangeListener(temp);
BigDecimal de = new BigDecimal(floatValue + "");
BigDecimal de = new BigDecimal(GeneralUtils.objectToString(floatValue));
if (scale > 0) {
floatValue = de.setScale(scale, BigDecimal.ROUND_DOWN).floatValue();
} else {
floatValue = de.floatValue();
}
//选中多列, 并且列宽不完全一致的话, 就不显示值了.
//选中多列, 并且列宽不完全一致的话, 就不显示值了.
temp.setText(AssistUtils.equals(floatValue, 0) ? StringUtils.EMPTY : Utils.convertNumberStringToString(new Float(floatValue)));
// denny:默认应该为选中,方便用户修改
@ -99,8 +101,8 @@ public abstract class UnitInputPane extends BasicPane {
public double update() throws ValueNotChangeException {
// 值没变就不改
if (!changed) {
throw vncExp;
}
throw vncExp;
}
// Denny: get numberFieldSpinner 的 TextField
JFormattedTextField temp = GUICoreUtils.getSpinnerTextField(numberFieldSpinner);
@ -108,7 +110,8 @@ public abstract class UnitInputPane extends BasicPane {
if (temp.getText().length() == 0) {
return 0;
}
BigDecimal de = new BigDecimal(temp.getText());
BigDecimal de = new BigDecimal(GeneralUtils.objectToString(temp.getValue()));
if (scale > 0) {
return de.setScale(scale, BigDecimal.ROUND_DOWN).floatValue();
} else {
@ -176,4 +179,4 @@ public abstract class UnitInputPane extends BasicPane {
// 鼠标按键在组件上单击时
}
};
}
}

19
designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java

@ -136,6 +136,7 @@ public class UIColorButton extends UIButton implements PopupHider, UIObserver, G
}
popupWin = this.getColorControlWindow();
popupWin.setColor(color);
GUICoreUtils.showPopupMenu(popupWin, this, POPUP_MENU_SHIFT, this.getSize().height);
}
@ -154,18 +155,22 @@ public class UIColorButton extends UIButton implements PopupHider, UIObserver, G
protected ColorControlWindow getColorControlWindow() {
//find parant.
if (this.popupWin == null) {
this.popupWin = new ColorControlWindow(UIColorButton.this) {
@Override
protected void colorChanged() {
UIColorButton.this.setColor(this.getColor());
}
};
this.popupWin = initColorControlWindow();
}
return popupWin;
}
protected ColorControlWindow initColorControlWindow(){
return new ColorControlWindow(UIColorButton.this) {
@Override
protected void colorChanged() {
UIColorButton.this.setColor(this.getColor());
}
};
}
/**
* 添加监听
*

36
designer-base/src/main/java/com/fr/design/gui/ibutton/UINoThemeColorButton.java

@ -0,0 +1,36 @@
package com.fr.design.gui.ibutton;
import com.fr.design.gui.ipoppane.PopupHider;
import com.fr.design.style.color.ColorControlWindow;
import javax.swing.Icon;
public class UINoThemeColorButton extends UIColorButton{
public UINoThemeColorButton(Icon icon) {
super(icon);
}
protected ColorControlWindow initColorControlWindow(){
return new NoThemeColorControlWindow(this);
}
private class NoThemeColorControlWindow extends ColorControlWindow{
public NoThemeColorControlWindow(PopupHider popupHider) {
super(popupHider);
}
protected boolean supportThemeColor(){
return false;
}
@Override
protected void colorChanged() {
UINoThemeColorButton.this.setColor(this.getColor());
}
}
}

20
designer-base/src/main/java/com/fr/design/gui/icombobox/ColorSchemeComboBox.java

@ -2,14 +2,18 @@ package com.fr.design.gui.icombobox;
import com.fr.base.ChartColorMatching;
import com.fr.base.ChartPreStyleConfig;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.settings.chart.ThemedChartSeriesColor;
import com.fr.cert.token.lang.Collections;
import com.fr.chart.base.ChartConstants;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.i18n.Toolkit;
import com.fr.general.GeneralUtils;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JLabel;
import javax.swing.JList;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
@ -65,7 +69,21 @@ public class ColorSchemeComboBox extends UIComboBox {
Iterator names = config.names();
if (preDefined) {
colorSchemes.put(Toolkit.i18nText("Fine-Design_Chart_Predefined"), null);
ColorInfo colorInfo = new ColorInfo();
List<Color> list = new ArrayList<>();
colorInfo.setColors(list);
TemplateTheme templateTheme = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplateTheme();
ThemedChartSeriesColor themedChartSeriesColor = templateTheme.getChartStyle().getThemedChartSeriesColor();
if (themedChartSeriesColor.isCombineColor()) {
colorInfo.setGradient(false);
list.addAll(templateTheme.getColorScheme().getColors());
} else {
colorInfo.setGradient(true);
list.add(themedChartSeriesColor.getBeginColor());
list.add(themedChartSeriesColor.getEndColor());
}
colorSchemes.put(Toolkit.i18nText("Fine-Design_Chart_Follow_Theme"), colorInfo);
} else {
//添加默认的方案和第一个方案
String defaultName = config.getCurrentStyle();

22
designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java

@ -2,9 +2,12 @@ package com.fr.design.gui.itoolbar;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import java.awt.Component;
import java.awt.FlowLayout;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JToolBar;
public class UIToolbar extends JToolBar {
@ -35,13 +38,18 @@ public class UIToolbar extends JToolBar {
}
}
public void refreshUIToolBar() {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
for (int i = 0; i < getComponentCount(); i++) {
Component component = getComponents()[i];
component.setEnabled(template.checkEnable());
}
public Map<Component, Boolean> getComponentState() {
Map<Component, Boolean> componentState = new HashMap<>();
for (int i = 0; i < getComponentCount(); i++) {
Component component = getComponent(i);
componentState.put(component, component.isEnabled());
}
return componentState;
}
public static void resetComponentState(Map<Component, Boolean> componentState) {
for (Component component : componentState.keySet()) {
component.setEnabled(componentState.get(component));
}
}
}

2
designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java

@ -67,7 +67,7 @@ public class EnvFileTree extends RefreshableJTree {
String lock = node.getLock();
String name = node.getName();
if (treeNode.hasFullAuthority()) {
if (lock != null && !node.getUserID().equals(lock)) {
if (lock != null && !lock.equals(node.getUserID())) {
name = name + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked", "(", ")");
}
this.setIcon(FileTreeIcon.getIcon(node));

12
designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java

@ -48,6 +48,9 @@ public class FileTreeIcon {
public static final Icon MODERN_CHT_FILE_IMAGE_ICON =
BaseUtils.readIcon("/com/fr/design/images/gui/modern_style_cht_file_icon_16x16.png");
public static final Icon CPTX_ICON = BaseUtils.readIcon("/com/fr/nx/app/designer/cptx_file_icon.png");
public static final Icon CPTX_LOCKED_ICON = BaseUtils.readIcon("/com/fr/nx/app/designer/cptx_file_icon_locked.png");
public static final LockIcon FOLDER_LOCK_ICON =
new LockIcon(BaseUtils.readImage("/com/fr/design/images/gui/fold.png"));
public static final LockIcon FILE_LOCK_ICON =
@ -108,6 +111,7 @@ public class FileTreeIcon {
public final static int CPT_FILE = 11; //.cpt
public final static int FRM_FILE = 12; //.form .frm
public final static int CHT_FILE = 13; //.chart .cht
public final static int CPTX_FILE = 14; //.cptx
public static Icon getIcon(File file) {
return FileTreeIcon.getIcon(file, false);
@ -252,6 +256,12 @@ public class FileTreeIcon {
} else {
return FileTreeIcon.MODERN_CPT_FILE_IMAGE_ICON;
}
} else if (fileType == CPTX_FILE) {
if (isLocked) {
return FileTreeIcon.CPTX_LOCKED_ICON;
} else {
return FileTreeIcon.CPTX_ICON;
}
} else if (fileType == FRM_FILE) { //form frm
if (isLocked) {
return FileTreeIcon.FRM_FILE_LOCK_ICON;
@ -314,6 +324,8 @@ public class FileTreeIcon {
return BMP_FILE;
} else if (fileName.endsWith(".cpt")) {
return CPT_FILE;
} else if (fileName.endsWith(".cptx")) {
return CPTX_FILE;
} else if (fileName.endsWith(".frm") || fileName.endsWith(".form")) {
return FRM_FILE;
} else if (fileName.endsWith(".cht") || fileName.endsWith(".chart")) {

2
designer-base/src/main/java/com/fr/design/gui/itree/filetree/ReportletPane.java

@ -53,7 +53,7 @@ public class ReportletPane extends BasicPane {
centerPane.add(cardPane, BorderLayout.CENTER);
cardPane.setLayout(card = new CardLayout());
templateReportletTree = new TemplateFileTree();
IOFileNodeFilter filter = new IOFileNodeFilter(new String[]{".cpt", ".class", ".frm", ".form"});
IOFileNodeFilter filter = new IOFileNodeFilter(new String[]{".cpt", ".class", ".frm", ".form", ".cptx"});
templateReportletTree.setFileNodeFilter(filter);
cardPane.add(t_panel = new JScrollPane(templateReportletTree), "TEMPLATE");
classReportletTree = new ClassFileTree();

20
designer-base/src/main/java/com/fr/design/gui/style/AbstractBorderPackerPane.java

@ -0,0 +1,20 @@
package com.fr.design.gui.style;
import com.fr.design.dialog.BasicPane;
import com.fr.general.act.BorderPacker;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/8/11
*/
public abstract class AbstractBorderPackerPane extends BasicPane {
public abstract void populateBean(BorderPacker style);
public abstract void updateBean(BorderPacker style);
@Override
protected String title4PopupWindow() {
return null;
}
}

99
designer-base/src/main/java/com/fr/design/gui/style/AbstractTranslucentBackgroundSpecialPane.java

@ -0,0 +1,99 @@
package com.fr.design.gui.style;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.gui.frpane.UIPercentDragPane;
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.backgroundpane.GradientBackgroundQuickPane;
import com.fr.general.Background;
import com.fr.general.act.BackgroundPacker;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/8/11
*/
public abstract class AbstractTranslucentBackgroundSpecialPane<T extends BackgroundPacker> extends BasicPane {
private final int uiLabelWidth;
private final int uiSettingWidth;
// 背景名称:如主题背景 或 标题背景
private final String backgroundName;
// 背景
protected BackgroundSpecialPane backgroundPane = new LayoutBackgroundSpecialPane();
// 背景透明度
protected UIPercentDragPane opacityPane = new UIPercentDragPane();
public AbstractTranslucentBackgroundSpecialPane(int uiLabelWidth, int uiSettingWidth, String backgroundName) {
this.uiLabelWidth = uiLabelWidth;
this.uiSettingWidth = uiSettingWidth;
this.backgroundName = backgroundName;
this.initializePane();
}
private void initializePane() {
setLayout(new BorderLayout(0, 0));
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f};
// 确保BackgroundSpecialPane高度变化时,Label依然保持与其顶部对齐
JPanel backgroundLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
backgroundLabelPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0));
backgroundLabelPane.add(new UILabel(backgroundName), BorderLayout.NORTH);
JPanel backgroundComposedPane = TableLayoutHelper.createGapTableLayoutPane(
new JComponent[][]{
{backgroundLabelPane, backgroundPane}
},
new double[]{p}, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
JPanel opacityComposedPane = TableLayoutHelper.createGapTableLayoutPane(
new JComponent[][]{
{new UILabel(""), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Alpha"))},
{new UILabel(""), opacityPane}
},
new double[]{p, p}, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
opacityComposedPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0));
opacityComposedPane.setVisible(false);
backgroundPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
Background background = backgroundPane.update();
opacityComposedPane.setVisible(background != null);
}
});
add(backgroundComposedPane, BorderLayout.NORTH, 0);
add(opacityComposedPane, BorderLayout.CENTER, 1);
}
@Override
protected String title4PopupWindow() {
return null;
}
public abstract void populateBean(T style);
public abstract void updateBean(T style);
protected static class LayoutBackgroundSpecialPane extends BackgroundSpecialPane {
@Override
protected GradientBackgroundQuickPane createGradientBackgroundQuickPane() {
return new GradientBackgroundQuickPane(140);
}
}
}

8
designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java

@ -95,8 +95,14 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
borderPanel = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Border"), 280, 24, panel);
this.add(borderPanel, BorderLayout.NORTH);
UILabel backgroundFillLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Background_Fill"));
backgroundFillLabel.setPreferredSize(new Dimension(60, 20));
backgroundPane = new BackgroundPane();
backgroundPanel = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"), 280, 24, backgroundPane);
JPanel backgroundContainPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{backgroundFillLabel, backgroundPane}},
TableLayoutHelper.FILL_LASTCOLUMN, LayoutConstants.VGAP_SMALL, LayoutConstants.VGAP_MEDIUM);
backgroundPanel = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"), 280, 24, backgroundContainPane);
this.add(backgroundPanel, BorderLayout.CENTER);
initAllNames();
outerToggleButton.addChangeListener(outerToggleButtonChangeListener);

33
designer-base/src/main/java/com/fr/design/gui/style/ComponentBodyStylePane.java

@ -0,0 +1,33 @@
package com.fr.design.gui.style;
import com.fr.general.act.BorderPacker;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/8/11
*/
public class ComponentBodyStylePane extends AbstractTranslucentBackgroundSpecialPane<BorderPacker> {
public ComponentBodyStylePane(int uiLabelWidth) {
this(uiLabelWidth, -1);
}
public ComponentBodyStylePane(int uiLabelWidth, int uiSettingWidth) {
super(uiLabelWidth, uiSettingWidth, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Fill"));
}
@Override
public void populateBean(BorderPacker style) {
this.backgroundPane.populateBean(style.getBackground());
if (this.opacityPane != null) {
this.opacityPane.populateBean(style.getAlpha());
}
}
@Override
public void updateBean(BorderPacker style) {
style.setBackground(backgroundPane.update());
style.setAlpha((float)opacityPane.updateBean());
}
}

109
designer-base/src/main/java/com/fr/design/gui/style/ComponentIntegralStylePane.java

@ -0,0 +1,109 @@
package com.fr.design.gui.style;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.icombobox.UIComboBox;
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 com.fr.general.act.BorderPacker;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.BorderLayout;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/8/11
*/
public class ComponentIntegralStylePane extends AbstractBorderPackerPane {
public static final 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")
};
//渲染风格:有无阴影
protected UIComboBox borderStyleCombo;
// 含图片类型边框的边框配置面板(图片类型边框 + 阴影时存在默认的阴影颜色)
protected TranslucentBorderSpecialPane borderPane;
//边框圆角或圆角裁剪
protected UISpinner cornerSpinner;
private final int uiLabelWidth;
private final int uiSettingWidth;
private final boolean supportBorderImage;
private final boolean supportCornerRadius;
public ComponentIntegralStylePane(int uiLabelWidth,
boolean supportBorderImage, boolean supportCornerRadius) {
this(uiLabelWidth, -1, supportBorderImage, supportCornerRadius);
}
public ComponentIntegralStylePane(int uiLabelWidth, int uiSettingWidth) {
this(uiLabelWidth, uiSettingWidth, true, true);
}
public ComponentIntegralStylePane(
int uiLabelWidth, int uiSettingWidth,
boolean supportBorderImage, boolean supportCornerRadius) {
this.uiLabelWidth = uiLabelWidth;
this.uiSettingWidth = uiSettingWidth;
this.supportBorderImage = supportBorderImage;
this.supportCornerRadius = supportCornerRadius;
this.initializePane();
}
private void initializeComponents() {
borderStyleCombo = new UIComboBox(BORDER_STYLE);
borderPane = new TranslucentBorderSpecialPane(this.supportBorderImage);
cornerSpinner = new UISpinner(0,1000,1,0);
}
protected void initializePane() {
setLayout(FRGUIPaneFactory.createBorderLayout());
this.initializeComponents();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = supportCornerRadius ? new double[] {p, p, p} : new double[]{p, p};
double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f};
JPanel content = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo},
{this.borderPane, null},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner},
},
rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
this.add(content, BorderLayout.NORTH);
}
@Override
public void populateBean(BorderPacker style) {
if (this.borderStyleCombo != null) {
this.borderStyleCombo.setSelectedIndex(style.getBorderStyle());
}
if (cornerSpinner != null) {
this.cornerSpinner.setValue(style.getBorderRadius());
}
if (this.borderPane != null) {
this.borderPane.populateBean(style);
}
}
@Override
public void updateBean(BorderPacker style) {
if (borderStyleCombo != null) {
style.setBorderStyle(borderStyleCombo.getSelectedIndex());
}
if (cornerSpinner != null) {
style.setBorderRadius((int) cornerSpinner.getValue());
}
if (borderPane != null) {
borderPane.updateBean(style);
}
}
}

351
designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java

@ -0,0 +1,351 @@
package com.fr.design.gui.style;
import com.fr.base.Utils;
import com.fr.base.svg.IconUtils;
import com.fr.design.designer.IntervalConstants;
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.icheckbox.UICheckBox;
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.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.WidgetTitle;
import com.fr.general.FRFont;
import com.fr.general.IOUtils;
import com.fr.general.act.BorderPacker;
import com.fr.general.act.TitlePacker;
import com.fr.stable.Constants;
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.Dimension;
import java.awt.Font;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/8/11
*/
public class ComponentTitleStylePane extends AbstractBorderPackerPane {
private static final Dimension BUTTON_SIZE = new Dimension(20, 20);
public static final TitlePacker DEFAULT_TITLE_PACKER = new WidgetTitle();
// 标题可见
protected UICheckBox visibleCheckbox;
//标题文字内容
protected TinyFormulaPane textContentPane;
//标题字体格式
protected UIComboBox fontFamilyComboBox;
//标题字体大小
protected UIComboBox fontSizeComboBox;
//标题字体颜色
protected UIColorButton fontColorSelectPane;
//标题字体特殊效果:粗体、斜体、下划线
private UIToggleButton fontBoldButton;
private UIToggleButton fontItalicButton;
private UIToggleButton fontUnderlineButton;
// 标题图文混排
protected TextInsetImageBackgroundSpecialPane insetImagePane;
//对齐方式
protected UIButtonGroup alignPane;
//标题整体背景
protected TitleTranslucentBackgroundSpecialPane backgroundPane;
// 是否支持用户编辑这些属性(不支持时: 设置面板总是不可见)
private boolean isSupportTitleVisible = true;
private boolean isSupportTitleContent = true;
private boolean isSupportTitleOtherSetting = true;
// 用于控制各部分设置的可见性
private JPanel titleVisiblePane;
private JPanel titleContentPane;
private JPanel titleOtherSettingPane;
private final int uiLabelWidth;
private final int uiSettingWidth;
public ComponentTitleStylePane(int uiLabelWidth) {
this(uiLabelWidth, -1);
}
public ComponentTitleStylePane(
int uiLabelWidth, int uiSettingWidth) {
this.uiLabelWidth = uiLabelWidth;
this.uiSettingWidth = uiSettingWidth;
this.initializePane();
}
private void initializeComponents() {
visibleCheckbox = new UICheckBox();
textContentPane = new TinyFormulaPane();
fontFamilyComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report());
FRFont frFont = DEFAULT_TITLE_PACKER.getFrFont();
if (frFont != null) {
String fontFamily = frFont.getFamily();
// 使用style中默认的字体初始化titleFontFamilyComboBox,保证UI和数据的一致性
this.fontFamilyComboBox.setSelectedItem(fontFamily);
}
fontFamilyComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Family"));
fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES);
fontSizeComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Size"));
fontColorSelectPane = new UIColorButton();
fontColorSelectPane.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Foreground"));
fontColorSelectPane.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Foreground"));
fontBoldButton = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"));
fontBoldButton.setPreferredSize(BUTTON_SIZE);
fontBoldButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Bold"));
fontBoldButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Bold"));
fontItalicButton = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"));
fontItalicButton.setPreferredSize(BUTTON_SIZE);
fontItalicButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Italic"));
fontItalicButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Italic"));
fontUnderlineButton = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png"));
fontUnderlineButton.setPreferredSize(BUTTON_SIZE);
fontUnderlineButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Underline"));
fontUnderlineButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Underline"));
insetImagePane = new TextInsetImageBackgroundSpecialPane();
alignPane = new UIButtonGroup<>(
new Icon[]{
IconUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"),
IconUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"),
IconUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png")
},
new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT});
alignPane.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")
});
alignPane.setSelectedItem(DEFAULT_TITLE_PACKER.getPosition());
backgroundPane = new TitleTranslucentBackgroundSpecialPane(this.uiLabelWidth, this.uiSettingWidth);
}
private void initializePane() {
this.setLayout(new BorderLayout(0, 0));
this.initializeComponents();
titleVisiblePane = this.createTitleVisiblePane();
titleContentPane = this.createTitleContentPane();
titleOtherSettingPane = this.createTitleOtherSettingPane();
if (isSupportTitleVisible) {
titleVisiblePane.setVisible(true);
}
if (isSupportTitleVisible) {
titleContentPane.setVisible(false);
}
if (isSupportTitleVisible) {
titleOtherSettingPane.setVisible(false);
}
addComponents(titleVisiblePane, titleContentPane, titleOtherSettingPane);
}
private JPanel createTitleVisiblePane() {
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
visibleCheckbox.setSelected(false);
container.add(visibleCheckbox, BorderLayout.WEST);
container.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Visible")), BorderLayout.CENTER);
visibleCheckbox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
boolean visible = visibleCheckbox.isSelected();
if (titleContentPane != null) {
titleContentPane.setVisible(visible && isSupportTitleContent);
}
if (titleOtherSettingPane != null) {
titleOtherSettingPane.setVisible(visible && isSupportTitleOtherSetting);
}
}
});
return container;
}
private JPanel createTitleContentPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p};
double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f};
return TableLayoutHelper.createCommonTableLayoutPane(
new JComponent[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Content")), textContentPane}},
rowSize, columnSize, IntervalConstants.INTERVAL_L1);
}
private JPanel createTitleOtherSettingPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p, p, p, p, p};
double[] columnSize = {this.uiLabelWidth, this.uiSettingWidth > 0 ? this.uiSettingWidth : f};
JComponent[][] components = new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Format")), fontFamilyComboBox},
{null, createTitleFontButtonPane()},
{insetImagePane, null},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Text_Align")), alignPane},
{backgroundPane, null}
};
return TableLayoutHelper.createCommonTableLayoutPane(components, rowSize, columnSize, IntervalConstants.INTERVAL_L1);
}
protected JPanel createTitleFontButtonPane(){
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p};
double[] columnSize = {f, p, p, p, p};
JPanel buttonPane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][] {
{fontSizeComboBox, fontColorSelectPane, fontItalicButton, fontBoldButton, fontUnderlineButton},
}, rowSize, columnSize, IntervalConstants.INTERVAL_W0);
JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
containerPane.add(buttonPane, BorderLayout.NORTH);
return containerPane;
}
@Override
public void populateBean(BorderPacker style) {
TitlePacker widgetTitle = style == null ? new WidgetTitle() : style.getTitle();
widgetTitle = widgetTitle == null ? new WidgetTitle() : widgetTitle;
boolean titleVisible = style != null && style.getType() != LayoutBorderStyle.STANDARD;
visibleCheckbox.setSelected(isSupportTitleVisible && titleVisible);
titleContentPane.setVisible(isSupportTitleContent && titleVisible);
titleOtherSettingPane.setVisible(isSupportTitleOtherSetting && titleVisible);
this.textContentPane.populateBean(widgetTitle.getTextObject().toString());
FRFont frFont = widgetTitle.getFrFont();
this.fontSizeComboBox.setSelectedItem(frFont.getSize());
this.fontFamilyComboBox.setSelectedItem(frFont.getFamily());
this.fontColorSelectPane.setColor(frFont.getForeground());
this.fontColorSelectPane.repaint();
fontBoldButton.setSelected(frFont.isBold());
fontItalicButton.setSelected(frFont.isItalic());
int line = frFont.getUnderline();
if (line == Constants.LINE_NONE) {
fontUnderlineButton.setSelected(false);
} else {
fontUnderlineButton.setSelected(true);
}
alignPane.setSelectedItem(widgetTitle.getPosition());
insetImagePane.populateBean(widgetTitle);
backgroundPane.populateBean(widgetTitle);
}
@Override
public void updateBean(BorderPacker style) {
style.setType(visibleCheckbox != null && visibleCheckbox.isSelected() ? LayoutBorderStyle.TITLE : LayoutBorderStyle.STANDARD);
TitlePacker title = style.getTitle() == null ? new WidgetTitle() : style.getTitle();
title.setTextObject(textContentPane.updateBean());
FRFont frFont = title.getFrFont();
frFont = frFont.applySize((Integer) fontSizeComboBox.getSelectedItem());
frFont = frFont.applyName(fontFamilyComboBox.getSelectedItem().toString());
frFont = frFont.applyForeground(fontColorSelectPane.getColor());
frFont = updateTitleFontItalicBold(frFont);
int line = fontUnderlineButton.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE;
frFont = frFont.applyUnderline(line);
title.setFrFont(frFont);
title.setPosition((Integer) alignPane.getSelectedItem());
insetImagePane.updateBean(title);
backgroundPane.updateBean(title);
style.setTitle(title);
}
private FRFont updateTitleFontItalicBold(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 (fontItalicButton.isSelected() && !isItalic) {
italic_bold += Font.ITALIC;
} else if (!fontItalicButton.isSelected() && isItalic) {
italic_bold -= Font.ITALIC;
}
frFont = frFont.applyStyle(italic_bold);
if (fontBoldButton.isSelected() && !isBold) {
italic_bold += Font.BOLD;
} else if (!fontBoldButton.isSelected() && isBold) {
italic_bold -= Font.BOLD;
}
frFont = frFont.applyStyle(italic_bold);
return frFont;
}
private void addComponents(JComponent... components) {
if (components == null) {
return;
}
JPanel container = this;
for (int i = 0; i < components.length; i++) {
JComponent component = components[i];
if (component != null) {
container.add(component, BorderLayout.NORTH);
component.setBorder(BorderFactory.createEmptyBorder(i == 0 ? 0 : IntervalConstants.INTERVAL_L1, 0, 0, 0));
if (i < components.length - 1) {
JPanel nextContainer = new JPanel(FRGUIPaneFactory.createBorderLayout());
container.add(nextContainer, BorderLayout.CENTER);
container = nextContainer;
}
}
}
}
public void setSupportTitleVisible(boolean supporting) {
isSupportTitleVisible = supporting;
if (titleVisiblePane != null) {
titleVisiblePane.setVisible(supporting);
}
}
public void setSupportTitleContent(boolean supporting) {
isSupportTitleContent = supporting;
if (titleContentPane != null) {
boolean titleVisible = visibleCheckbox.isSelected();
if (isSupportTitleContent) {
titleContentPane.setVisible(titleVisible);
} else {
titleContentPane.setVisible(false);
}
}
}
public void setSupportOtherSetting(boolean supporting) {
isSupportTitleOtherSetting = supporting;
if (titleOtherSettingPane != null) {
boolean titleVisible = visibleCheckbox.isSelected();
if (isSupportTitleOtherSetting) {
titleOtherSettingPane.setVisible(titleVisible);
} else {
titleOtherSettingPane.setVisible(false);
}
}
}
}

138
designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java

@ -0,0 +1,138 @@
package com.fr.design.gui.style;
import com.fr.base.theme.FormTheme;
import com.fr.base.theme.TemplateTheme;
import com.fr.design.dialog.BasicPane;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.JTemplate;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/8/19
*/
public class FollowingThemePane extends BasicPane implements UIObserver {
public static final int SETTING_LABEL_WIDTH = 60;
public static final String[] FOLLOWING_THEME_STRING_ARRAYS = new String[]{
Toolkit.i18nText("Fine-Design_Style_Follow_Theme"),
Toolkit.i18nText("Fine-Design_Style_Not_Follow_Theme"),
};
private final UIButtonGroup<String> followingThemeButtonGroup;
private final List<FollowingThemeActionChangeListener> changeListeners = new ArrayList<>();
private UIObserverListener uiObserverListener;
private JPanel container;
public FollowingThemePane(String name) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS);
followingThemeButtonGroup.setSelectedIndex(1);
followingThemeButtonGroup.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
for (FollowingThemeActionChangeListener changeListener : changeListeners) {
changeListener.onFollowingTheme(isFollowingTheme());
}
invalidate();
// 与主题相关的属性面板更新完毕后,再通知外层更新数据
if (uiObserverListener != null) {
uiObserverListener.doChange();
}
}
});
UILabel followingThemeLabel = new UILabel(name);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
JPanel followingThemePane =
TableLayoutHelper.createGapTableLayoutPane( new Component[][]{new Component[] { followingThemeLabel, followingThemeButtonGroup}},
new double[] { p }, new double[] { SETTING_LABEL_WIDTH, f }, 10, 0);
followingThemePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
followingThemePane.setVisible(false);
add(followingThemePane, BorderLayout.NORTH);
container = FRGUIPaneFactory.createBorderLayout_S_Pane();
add(container, BorderLayout.CENTER);
}
public void addFollowThemePane(JPanel content, FollowingThemeActionChangeListener changeListener) {
if (content != null) {
container.add(content, BorderLayout.NORTH);
changeListeners.add(changeListener);
JPanel nextContainer = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.add(nextContainer, BorderLayout.CENTER);
container = nextContainer;
}
}
@Override
protected String title4PopupWindow() {
return null;
}
@Override
public void registerChangeListener(UIObserverListener uiObserverListener) {
this.uiObserverListener = uiObserverListener;
}
@Override
public boolean shouldResponseChangeListener() {
return true;
}
public interface FollowingThemeActionChangeListener {
void onFollowingTheme(boolean following);
}
public TemplateTheme getUsingTheme() {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
return template.getTemplateTheme();
}
return null;
}
public void supportFollowingTheme(boolean supporting) {
getComponent(0).setVisible(supporting);
if (!supporting) {
setFollowingTheme(false);
}
}
public void setFollowingTheme(boolean following) {
followingThemeButtonGroup.setSelectedIndex(following ? 0 : 1);
for (FollowingThemeActionChangeListener changeListener : changeListeners) {
changeListener.onFollowingTheme(isFollowingTheme());
}
}
public boolean isFollowingTheme() {
return followingThemeButtonGroup.getSelectedIndex() == 0;
}
}

102
designer-base/src/main/java/com/fr/design/gui/style/ReportBackgroundSpecialPane.java

@ -0,0 +1,102 @@
package com.fr.design.gui.style;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.event.UIObserverListener;
import com.fr.design.fun.BackgroundQuickUIProvider;
import com.fr.design.mainframe.backgroundpane.BackgroundQuickPane;
import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane;
import com.fr.design.mainframe.backgroundpane.GradientBackgroundQuickPane;
import com.fr.design.mainframe.backgroundpane.ImageBackgroundQuickPane;
import com.fr.design.mainframe.backgroundpane.NullBackgroundQuickPane;
import com.fr.design.mainframe.backgroundpane.PatternBackgroundQuickPane;
import com.fr.design.mainframe.backgroundpane.TextureBackgroundQuickPane;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/8/19
*/
public class ReportBackgroundSpecialPane extends BackgroundPane {
public ReportBackgroundSpecialPane(){
super();
}
@Override
protected BackgroundQuickPane[] supportKindsOfBackgroundUI() {
NullBackgroundQuickPane nullBackgroundPane = new NullBackgroundQuickPane();
ColorBackgroundQuickPane colorBackgroundPane = new ColorBackgroundQuickPane();
colorBackgroundPane.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
fireStateChanged();
}
});
ImageBackgroundQuickPane imageBackgroundPane = new ImageBackgroundQuickPane();
imageBackgroundPane.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
fireStateChanged();
}
});
GradientBackgroundQuickPane gradientBackgroundPane = createGradientBackgroundQuickPane();
gradientBackgroundPane.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
fireStateChanged();
}
});
TextureBackgroundQuickPane textureBackgroundPane = new TextureBackgroundQuickPane();
textureBackgroundPane.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
fireStateChanged();
}
});
PatternBackgroundQuickPane patternBackgroundPane = new PatternBackgroundQuickPane();
patternBackgroundPane.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
fireStateChanged();
}
});
List<BackgroundQuickPane> kinds = new ArrayList<BackgroundQuickPane>();
kinds.add(nullBackgroundPane);
kinds.add(colorBackgroundPane);
kinds.add(imageBackgroundPane);
kinds.add(gradientBackgroundPane);
kinds.add(textureBackgroundPane);
kinds.add(patternBackgroundPane);
Set<BackgroundQuickUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(BackgroundQuickUIProvider.MARK_STRING);
for (BackgroundQuickUIProvider provider : providers) {
BackgroundQuickPane newTypePane = provider.appearanceForBackground();
newTypePane.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
fireStateChanged();
}
});
kinds.add(newTypePane);
}
return kinds.toArray(new BackgroundQuickPane[kinds.size()]);
}
protected GradientBackgroundQuickPane createGradientBackgroundQuickPane() {
// 使用默认的150宽度构建渐变条
return new GradientBackgroundQuickPane();
}
}

24
designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java → designer-base/src/main/java/com/fr/design/gui/style/TextInsetImageBackgroundSpecialPane.java

@ -1,4 +1,4 @@
package com.fr.design.gui.xpane;
package com.fr.design.gui.style;
import com.fr.base.Style;
import com.fr.base.background.ImageBackground;
@ -18,7 +18,6 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.backgroundpane.ImagePreviewPane;
import com.fr.design.style.background.image.ImageFileChooser;
import com.fr.design.widget.ui.designer.component.UIBoundSpinner;
import com.fr.form.ui.WidgetTitle;
import com.fr.general.Background;
import com.fr.general.IOUtils;
@ -26,11 +25,20 @@ import com.fr.general.ImageWithSuffix;
import com.fr.general.act.TitlePacker;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
@ -42,8 +50,8 @@ import java.awt.geom.RoundRectangle2D;
* @version 10.0.18
* Created by Starryi on 2021/7/3
*/
public class TitleInsetImagePane extends JPanel implements UIObserver {
private final int SETTING_LABEL_WIDTH = LayoutStylePane.SETTING_LABEL_WIDTH;
public class TextInsetImageBackgroundSpecialPane extends JPanel implements UIObserver {
private final int SETTING_LABEL_WIDTH = 60;
private final int DELETE_BUTTON_SIZE = 24;
private final int IMAGE_PREVIEW_SIZE = 145;
private final Color IMAGE_PREVIEW_OVERLAY_COLOR = new Color(255, 255, 255, 51);
@ -62,7 +70,7 @@ public class TitleInsetImagePane extends JPanel implements UIObserver {
private ImageFileChooser imageFileChooser;
public TitleInsetImagePane() {
public TextInsetImageBackgroundSpecialPane() {
this.initComponents();
this.initLayout();
}
@ -198,7 +206,7 @@ public class TitleInsetImagePane extends JPanel implements UIObserver {
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Inset_Relative_Right_Tooltip"),
});
imagePaddingPane = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, WidgetTitle.DEFAULT_INSET_PADDING);
imagePaddingPane = new UISpinner(0, Integer.MAX_VALUE, 1, WidgetTitle.DEFAULT_INSET_PADDING);
imagePaddingPane.setValue(DEFAULT_INSET_PADDING);
}

27
designer-base/src/main/java/com/fr/design/gui/style/TitleTranslucentBackgroundSpecialPane.java

@ -0,0 +1,27 @@
package com.fr.design.gui.style;
import com.fr.general.act.TitlePacker;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/8/11
*/
public class TitleTranslucentBackgroundSpecialPane extends AbstractTranslucentBackgroundSpecialPane<TitlePacker> {
public TitleTranslucentBackgroundSpecialPane(int uiLabelWidth, int uiSettingWidth) {
super(uiLabelWidth, uiSettingWidth, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Background"));
}
@Override
public void populateBean(TitlePacker style) {
backgroundPane.populateBean(style.getBackground());
opacityPane.populateBean(style.getBackgroundOpacity());
}
@Override
public void updateBean(TitlePacker style) {
style.setBackground(backgroundPane.update());
style.setBackgroundOpacity((float)opacityPane.updateBean());
}
}

45
designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java → designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java

@ -1,8 +1,6 @@
package com.fr.design.gui.xpane;
package com.fr.design.gui.style;
import com.fr.base.GraphHelper;
import com.fr.base.Style;
import com.fr.base.Utils;
import com.fr.base.background.ImageBackground;
import com.fr.base.background.ImageFileBackground;
import com.fr.design.border.UIRoundedBorder;
@ -16,8 +14,6 @@ import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.frpane.ImgChooseWrapper;
import com.fr.design.gui.frpane.UIPercentDragPane;
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.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
@ -28,9 +24,9 @@ import com.fr.design.mainframe.backgroundpane.ImagePreviewPane;
import com.fr.design.style.background.image.ImageFileChooser;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.env.utils.DesignerInteractionHistory;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.general.Background;
import com.fr.general.IOUtils;
import com.fr.general.act.BorderPacker;
import com.fr.stable.Constants;
import com.fr.stable.GraphDrawHelper;
import com.fr.stable.ProjectLibrary;
@ -78,8 +74,8 @@ import java.util.Arrays;
*
* 可配置图片类型边框的样式设置面板
*/
public class BorderLineAndImagePane extends JPanel implements UIObserver {
private final int SETTING_LABEL_WIDTH = LayoutStylePane.SETTING_LABEL_WIDTH;
public class TranslucentBorderSpecialPane extends AbstractBorderPackerPane implements UIObserver {
private final int SETTING_LABEL_WIDTH = 60;
private final Style DEFAULT_IMAGE_LAYOUT_STYLE = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_DEFAULT);
private final String TWEAK_NINE_POINT_HELP_URL = "https://help.fanruan.com/finereport/doc-view-4135.html";
@ -98,7 +94,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
private int[] ninePoint = new int[] {-1, -1, -1, -1};
public BorderLineAndImagePane(boolean supportBorderImage) {
public TranslucentBorderSpecialPane(boolean supportBorderImage) {
this.initComponents(supportBorderImage);
this.initLayout();
}
@ -273,7 +269,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
if (imagePreviewPane.getImage() != null) {
tweakPane.previewPane.setNinePoint(ninePoint);
BasicDialog dialog = tweakPane.showWindow(SwingUtilities.getWindowAncestor(BorderLineAndImagePane.this));
BasicDialog dialog = tweakPane.showWindow(SwingUtilities.getWindowAncestor(TranslucentBorderSpecialPane.this));
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
@ -287,7 +283,13 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
});
}
public void populateBean(LayoutBorderStyle style) {
@Override
protected String title4PopupWindow() {
return null;
}
@Override
public void populateBean(BorderPacker style) {
int borderLine = style.getBorder();
Color borderColor = style.getColor();
@ -333,7 +335,8 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
this.borderColorPane.setSelectObject(style.getColor());
}
public void updateBean(LayoutBorderStyle style) {
@Override
public void updateBean(BorderPacker style) {
style.setBorder(this.borderLineCombo.getSelectedLineStyle());
style.setColor(this.borderColorPane.getSelectObject());
@ -366,24 +369,6 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver {
return true;
}
protected UIButtonUI createButtonUI(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);
}
};
}
protected static class BorderLineAndImageComboBox extends LineComboBox {
public static final int LINE_PICTURE = -1;
public final static int[] BORDER_LINE_AND_IMAGE_STYLE_ARRAY = new int[] {

328
designer-base/src/main/java/com/fr/design/hyperlink/popup/ContentSettingPane.java

@ -0,0 +1,328 @@
package com.fr.design.hyperlink.popup;
import com.fr.base.BaseFormula;
import com.fr.base.BaseUtils;
import com.fr.base.Parameter;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.frpane.ReportletParameterViewPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.itableeditorpane.UITableEditAction;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itree.filetree.ReportletPane;
import com.fr.design.hyperlink.AbstractHyperLinkPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.parameter.ParameterReader;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.js.MobilePopupHyperlink;
import com.fr.stable.CommonUtils;
import com.fr.stable.FormulaProvider;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
public class ContentSettingPane extends AbstractHyperLinkPane<MobilePopupHyperlink> {
private JPanel popupTargetPane;
private UIRadioButton templatePopupButton;
private UIRadioButton textPopupButton;
private ButtonGroup popupTargetButtons;
private JPanel templateContentPane;
private UITextField templatePathTextField;
private UICheckBox extendParametersCheckBox;
private JPanel textSettingPanel;
private TinyFormulaPane textContentPane;
private CustomFontPane fontPane;
public ContentSettingPane() {
super();
this.initCompoennt();
}
public void addTargetRadioActionListener(ActionListener listener) {
templatePopupButton.addActionListener(listener);
textPopupButton.addActionListener(listener);
}
public String getTargetType() {
if (templatePopupButton.isSelected()) {
return MobilePopupConstants.Target_Template;
} else {
return MobilePopupConstants.Target_Text;
}
}
private void initCompoennt() {
this.setLayout(FRGUIPaneFactory.createM_BorderLayout());
this.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Content")));
popupTargetPane = this.createPopupTargetPane();
this.add(popupTargetPane, BorderLayout.NORTH);
templateContentPane= this.createTemplateContentPane();
textSettingPanel = this.createTextSettingPane();
}
private JPanel createPopupTargetPane() {
templatePopupButton = new UIRadioButton(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Template"));
templatePopupButton.addActionListener(radioActionListener);
textPopupButton = new UIRadioButton(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Text"));
textPopupButton.addActionListener(radioActionListener);
popupTargetButtons = new ButtonGroup();
popupTargetButtons.add(templatePopupButton);
popupTargetButtons.add(textPopupButton);
JPanel popupButtonsPanel = new JPanel();
popupButtonsPanel.setLayout( new FlowLayout(FlowLayout.LEFT, 10, 0));
popupButtonsPanel.add(templatePopupButton);
popupButtonsPanel.add(textPopupButton);
return MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Target"), popupButtonsPanel);
}
private ActionListener radioActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(templatePopupButton.isSelected()) {
ContentSettingPane.this.add(templateContentPane);
ContentSettingPane.this.remove(textSettingPanel);
} else if (textPopupButton.isSelected()) {
ContentSettingPane.this.add(textSettingPanel);
ContentSettingPane.this.remove(templateContentPane);
}
ContentSettingPane.this.revalidate();
ContentSettingPane.this.repaint();
}
};
private JPanel createTemplateContentPane() {
JPanel templateContentPane = new JPanel();
templateContentPane.setLayout(new BorderLayout(0,8));
templateContentPane.add(this.createTemplateSelectPanel(), BorderLayout.NORTH);
parameterViewPane = this.createReportletParameterViewPane();
templateContentPane.add(parameterViewPane, BorderLayout.CENTER);
extendParametersCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Extends_Report_Parameters"));
templateContentPane.add(GUICoreUtils.createFlowPane(extendParametersCheckBox, FlowLayout.LEFT), BorderLayout.SOUTH);
return templateContentPane;
}
private JPanel createTemplateSelectPanel() {
JPanel templatePanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
// 路径输入框
templatePathTextField = new UITextField(20);
templatePanel.add(templatePathTextField, BorderLayout.CENTER);
// 选择路径按钮
UIButton templateSelectButton = new UIButton(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Select"));
templateSelectButton.setPreferredSize(new Dimension(templateSelectButton.getPreferredSize().width, 20));
templatePanel.add(templateSelectButton, BorderLayout.EAST);
templateSelectButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
final ReportletPane reportletPane = new ReportletPane();
reportletPane.setSelectedReportletPath(templatePathTextField.getText());
BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(ContentSettingPane.this));
reportletDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
templatePathTextField.setText(reportletPane.getSelectedReportletPath());
}
});
reportletDialog.setVisible(true);
}
});
return MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Template"), templatePanel);
}
private ReportletParameterViewPane createReportletParameterViewPane() {
ReportletParameterViewPane templateParameterViewPane = new ReportletParameterViewPane(
new UITableEditAction[]{
new HyperlinkParametersAction()
},
getChartParaType(),
getValueEditorPane(),
getValueEditorPane()
);
templateParameterViewPane.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Parameter"), null));
templateParameterViewPane.setPreferredSize(new Dimension(this.getWidth(), 200));
return templateParameterViewPane;
}
private JPanel createTextSettingPane() {
JPanel textSettingPanel = new JPanel();
textSettingPanel.setLayout(new BorderLayout(0,8));
textContentPane = new TinyFormulaPane();
textContentPane.getUITextField().setColumns(20);
textSettingPanel.add(
MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Text"), textContentPane),
BorderLayout.CENTER);
fontPane = new CustomFontPane();
textSettingPanel.add(
MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Style"), fontPane),
BorderLayout.SOUTH);
return MobilePopupUIUtils.createTitleSplitLineContentPane("", textSettingPanel);
}
private String getReportletName() {
String text = this.templatePathTextField.getText();
return StringUtils.isBlank(text) ? StringUtils.EMPTY : text.substring(1);
}
@Override
public void populateBean(MobilePopupHyperlink link) {
this.populatePopupTargetBean(link.getPopupTarget());
this.populateTemplateContentBean(link);
this.populateTextContentBean(link);
}
@Override
public MobilePopupHyperlink updateBean() {
return null;
}
@Override
public void updateBean(MobilePopupHyperlink link) {
this.updatePopupTargetBean(link);
this.updateTemplateContentBean(link);
this.updateTextContentBean(link);
}
@Override
public String title4PopupWindow() {
return StringUtils.EMPTY;
}
/**
* 自动添加模板参数的按钮操作
*/
private class HyperlinkParametersAction extends UITableEditAction {
public HyperlinkParametersAction() {
this.setName(Toolkit.i18nText("Fine-Design_Basic_Template_Parameter"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/p.gif"));
}
@Override
public void actionPerformed(ActionEvent e) {
String tpl = getReportletName();
if (StringUtils.isBlank(tpl)) {
JOptionPane.showMessageDialog(
ContentSettingPane.this,
Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Please_Select_Reportlet") + ".",
Toolkit.i18nText("Fine-Design_Basic_Message"),
JOptionPane.WARNING_MESSAGE);
return;
}
//根据模板路径返回参数
//与当前模块、当前文件无关
Parameter[] parameters = new Parameter[0];
ParameterReader[] readers = DesignModuleFactory.getParameterReaders();
for (ParameterReader reader : readers) {
Parameter[] ps = reader.readParameterFromPath(tpl);
if (ps != null) {
parameters = ps;
}
}
parameterViewPane.populate(parameters);
}
@Override
public void checkEnabled() {
//do nothing
}
}
private void populatePopupTargetBean(String target) {
if (StringUtils.equals(target, MobilePopupConstants.Target_Text)) {
popupTargetButtons.setSelected(textPopupButton.getModel(), true);
this.remove(templateContentPane);
this.add(textSettingPanel, BorderLayout.CENTER);
} else {
popupTargetButtons.setSelected(templatePopupButton.getModel(), true);
this.remove(textSettingPanel);
this.add(templateContentPane, BorderLayout.CENTER);
}
}
private void updatePopupTargetBean(MobilePopupHyperlink mobilePopupHyperlink) {
if (templatePopupButton.isSelected()) {
mobilePopupHyperlink.setPopupTarget(MobilePopupConstants.Target_Template);
} else if (textPopupButton.isSelected()) {
mobilePopupHyperlink.setPopupTarget(MobilePopupConstants.Target_Text);
}
}
private void populateTemplateContentBean(MobilePopupHyperlink link) {
// 模板路径
templatePathTextField.setText(link.getReportletPath());
// 参数面板
List<ParameterProvider> parameterList = this.parameterViewPane.update();
parameterList.clear();
ParameterProvider[] parameters =link.getParameters();
parameterViewPane.populate(parameters);
// 继承参数
extendParametersCheckBox.setSelected(link.isExtendParameters());
}
private void updateTemplateContentBean(MobilePopupHyperlink link) {
link.setReportletPath(templatePathTextField.getText());
List<ParameterProvider> parameterList = this.parameterViewPane.update();
if (!parameterList.isEmpty()) {
Parameter[] parameters = new Parameter[parameterList.size()];
parameterList.toArray(parameters);
link.setParameters(parameters);
} else {
link.setParameters(null);
}
link.setExtendParameters(extendParametersCheckBox.isSelected());
}
private void populateTextContentBean(MobilePopupHyperlink link) {
Object text = link.getPopupText();
if (text instanceof FormulaProvider) {
textContentPane.populateBean(((FormulaProvider) text).getContent());
} else {
textContentPane.populateBean(text == null ? StringUtils.EMPTY : text.toString());
}
fontPane.populateBean(link.getFRFont());
}
private void updateTextContentBean(MobilePopupHyperlink link) {
link.setPopupText(textContentPane.getUITextField().getText());
String text = textContentPane.updateBean();
if (CommonUtils.maybeFormula(text)) {
link.setPopupText(BaseFormula.createFormulaBuilder().build(textContentPane.updateBean()));
} else {
link.setPopupText(text);
}
link.setFRFont(fontPane.updateBean());
}
}

100
designer-base/src/main/java/com/fr/design/hyperlink/popup/CustomFontPane.java

@ -0,0 +1,100 @@
package com.fr.design.hyperlink.popup;
import com.fr.base.BaseUtils;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont;
import com.fr.stable.Constants;
import javax.swing.*;
import java.awt.*;
import java.util.Vector;
public class CustomFontPane extends JPanel {
private static final int MAX_FONT_SIZE = 100;
private static final Dimension BUTTON_SIZE = new Dimension(20, 18);
public static Vector<Integer> getFontSizes() {
Vector<Integer> FONT_SIZES = new Vector<Integer>();
for (int i = 1; i < MAX_FONT_SIZE; i++) {
FONT_SIZES.add(i);
}
return FONT_SIZES;
}
private UIComboBox fontSizeComboBox;
private UIToggleButton bold;
private UIToggleButton italic;
private UIToggleButton underline;
private UIColorButton colorSelectPane;
public CustomFontPane() {
this.initComponent();
}
private void initComponent() {
fontSizeComboBox = new UIComboBox(getFontSizes());
fontSizeComboBox.setPreferredSize(new Dimension(60, 20));
fontSizeComboBox.setEditable(true);
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"));
this.setButtonsTips();
this.setButtonsSize(BUTTON_SIZE);
Component[] components_font = new Component[]{
fontSizeComboBox, colorSelectPane, bold, underline, italic
};
JPanel buttonPane = new JPanel(new BorderLayout());
buttonPane.add(GUICoreUtils.createFlowPane(components_font, FlowLayout.LEFT, LayoutConstants.HGAP_SMALL));
this.setLayout(new BorderLayout(0,0));
this.add(buttonPane, BorderLayout.CENTER);
}
private void setButtonsTips() {
colorSelectPane.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Foreground"));
italic.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Italic"));
bold.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Bold"));
underline.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Underline"));
}
private void setButtonsSize(Dimension size) {
colorSelectPane.setPreferredSize(size);
bold.setPreferredSize(size);
italic.setPreferredSize(size);
underline.setPreferredSize(size);
}
public void populateBean(FRFont frFont) {
fontSizeComboBox.setSelectedItem(frFont.getSize());
colorSelectPane.setColor(frFont.getForeground());
bold.setSelected(frFont.isBold());
italic.setSelected(frFont.isItalic());
underline.setSelected(frFont.getUnderline() != Constants.LINE_NONE);
}
public FRFont updateBean() {
int style = Font.PLAIN;
style += this.bold.isSelected() ? Font.BOLD : Font.PLAIN;
style += this.italic.isSelected() ? Font.ITALIC : Font.PLAIN;
return FRFont.getInstance(
FRFont.DEFAULT_FONTNAME,
style,
Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()),
colorSelectPane.getColor(),
underline.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE
);
}
}

22
designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupConstants.java

@ -0,0 +1,22 @@
package com.fr.design.hyperlink.popup;
import com.fr.stable.Constants;
public interface MobilePopupConstants {
int[] BORDER_LINE_STYLE_ARRAY = new int[]{
Constants.LINE_NONE,
Constants.LINE_THIN,
Constants.LINE_MEDIUM,
Constants.LINE_THICK,
};
String Target_Template= "template";
String Target_Text = "text";
String Regular_Custom = "custom";
String Regular_Auto_Height = "auto_height";
double Popup_Center_Default_Width = 95;
double Popup_Center_Default_Height = 95;
double Popup_Follow_Default_Width = 40;
double Popup_Follow_Default_Height = 10;
}

81
designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupPane.java

@ -0,0 +1,81 @@
package com.fr.design.hyperlink.popup;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.i18n.Toolkit;
import com.fr.js.MobilePopupHyperlink;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MobilePopupPane extends FurtherBasicBeanPane<MobilePopupHyperlink> {
private ContentSettingPane contentSettingPane;
private StyleSettingPane styleSettingPane;
public MobilePopupPane() {
this.initComponents();
this.setDefaultBean();
}
protected void initComponents() {
this.setLayout(new BorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
JPanel scrollContent = new JPanel();
scrollContent.setLayout(new BorderLayout(10, 10));
contentSettingPane = new ContentSettingPane();
scrollContent.add(contentSettingPane, BorderLayout.NORTH);
styleSettingPane = new StyleSettingPane();
scrollContent.add(styleSettingPane, BorderLayout.CENTER);
contentSettingPane.addTargetRadioActionListener(radioActionListener);
UIScrollPane scrollPane= new UIScrollPane(scrollContent);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
JComponent scrollComponent = new JLayer<UIScrollPane>(scrollPane, new WheelScrollLayerUI());
this.add(scrollComponent, BorderLayout.CENTER);
}
private void setDefaultBean() {
this.populateBean(new MobilePopupHyperlink());
}
private ActionListener radioActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
styleSettingPane.resetPane(contentSettingPane.getTargetType());
}
};
@Override
public void populateBean(MobilePopupHyperlink mobilePopupHyperlink) {
contentSettingPane.populateBean(mobilePopupHyperlink);
styleSettingPane.populateBean(mobilePopupHyperlink);
}
@Override
public MobilePopupHyperlink updateBean() {
MobilePopupHyperlink mobilePopupHyperlink = new MobilePopupHyperlink();
contentSettingPane.updateBean(mobilePopupHyperlink);
styleSettingPane.updateBean(mobilePopupHyperlink);
return mobilePopupHyperlink;
}
@Override
public boolean accept(Object ob) {
return ob instanceof MobilePopupHyperlink;
}
@Override
public String title4PopupWindow() {
return Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup");
}
@Override
public void reset() {
this.setDefaultBean();
}
}

157
designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupRegularPane.java

@ -0,0 +1,157 @@
package com.fr.design.hyperlink.popup;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MobilePopupRegularPane extends BasicPane {
private String label;
private JPanel radiosPane;
private UIRadioButton customRadio;
private UIRadioButton autoRadio;
private ButtonGroup radioButtons;
private JPanel spinnerGroupPane;
private UISpinner widthSpinner;
private JPanel widthSpinnerPane;
private UISpinner heightSpinner;
private JPanel heightSpinnerPane;
public MobilePopupRegularPane(String label) {
this.label = label;
this.initComponent();
}
private void initComponent() {
this.setLayout(new BorderLayout());
this.add(this.createRadioButtonGroupPane(), BorderLayout.NORTH);
spinnerGroupPane = this.createSpinnerPane();
this.add(spinnerGroupPane, BorderLayout.CENTER);
}
private JPanel createRadioButtonGroupPane() {
radiosPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5));
customRadio = new UIRadioButton(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Custom"));
customRadio.addActionListener(radioActionListener);
autoRadio = new UIRadioButton(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Height_Adaptive"));
autoRadio.addActionListener(radioActionListener);
radioButtons = new ButtonGroup();
radioButtons.add(customRadio);
radioButtons.add(autoRadio);
radiosPane.add(customRadio);
radiosPane.add(autoRadio);
return MobilePopupUIUtils.createLeftTileRightContentPanel(this.label, radiosPane);
}
private ActionListener radioActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
resetSpinnerGroupPane(customRadio.isSelected());
}
};
private JPanel createSpinnerPane() {
JPanel spinnerPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 15, 5));
spinnerPane.setBorder(BorderFactory.createEmptyBorder(0, MobilePopupUIUtils.Left_Title_width, 0, 0));
widthSpinner = new UISpinner(0, 100, 1, 95);
widthSpinnerPane = this.createSpinnerLabelPane(widthSpinner, Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Width"));
heightSpinner = new UISpinner(0, 100, 1, 95);
heightSpinnerPane = this.createSpinnerLabelPane(heightSpinner, Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Height"));
spinnerPane.add(widthSpinnerPane);
spinnerPane.add(heightSpinnerPane);
return spinnerPane;
}
private JPanel createSpinnerLabelPane(UISpinner spinner, String labelText) {
JPanel spinnerLabelPane = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 5));
JPanel spinnerPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 2,0));
Dimension dimension = new Dimension(60, 20);
spinner.setPreferredSize(dimension);
UILabel percent = new UILabel("%");
spinnerPane.add(spinner);
spinnerPane.add(percent);
UILabel label = new UILabel(labelText);
label.setPreferredSize(dimension);
label.setHorizontalAlignment(SwingConstants.CENTER);
spinnerLabelPane.add(spinnerPane);
spinnerLabelPane.add(label);
return spinnerLabelPane;
}
private void resetSpinnerGroupPane(boolean showHeightSpinnerPane) {
spinnerGroupPane.removeAll();
spinnerGroupPane.add(widthSpinnerPane);
if(showHeightSpinnerPane) {
spinnerGroupPane.add(heightSpinnerPane);
}
spinnerGroupPane.revalidate();
spinnerGroupPane.repaint();
}
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}
public void setRegularType(String regularType) {
if (StringUtils.equals(regularType, MobilePopupConstants.Regular_Auto_Height)) {
radioButtons.setSelected(autoRadio.getModel(), true);
} else {
radioButtons.setSelected(customRadio.getModel(), true);
}
resetSpinnerGroupPane(customRadio.isSelected());
}
public String getRegularType() {
if (autoRadio.isSelected()) {
return MobilePopupConstants.Regular_Auto_Height;
} else {
return MobilePopupConstants.Regular_Custom;
}
}
public void setWidthSpinnerValue(double width) {
widthSpinner.setValue(width);
}
public double getWidthSpinnerValue() {
return widthSpinner.getValue();
}
public void setHeightSpinnerValue(double height) {
heightSpinner.setValue(height);
}
public double getHeightSpinnerValue() {
return heightSpinner.getValue();
}
public void resetPane(String regularType, double width, double height) {
this.setRegularType(regularType);
this.setWidthSpinnerValue(width);
this.setHeightSpinnerValue(height);
resetSpinnerGroupPane(StringUtils.equals(regularType, MobilePopupConstants.Regular_Custom));
}
}

36
designer-base/src/main/java/com/fr/design/hyperlink/popup/MobilePopupUIUtils.java

@ -0,0 +1,36 @@
package com.fr.design.hyperlink.popup;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.widget.UITitleSplitLine;
import javax.swing.*;
import java.awt.*;
public class MobilePopupUIUtils {
static public int Line_Height = 20;
static public int SplitLineWidth = 520;
static public int Left_Title_width = 80;
static public JPanel createLeftTileRightContentPanel(String title, JComponent contentPanel) {
JPanel jp = new JPanel();
jp.setBorder(BorderFactory.createEmptyBorder(0,0,0, 30));
jp.setLayout(new BorderLayout(10,0));
UILabel titleLabel = new UILabel(title + ":");
titleLabel.setPreferredSize(new Dimension(MobilePopupUIUtils.Left_Title_width, Line_Height));
titleLabel.setHorizontalAlignment(SwingConstants.RIGHT);
jp.add(titleLabel, BorderLayout.WEST);
jp.add(contentPanel, BorderLayout.CENTER);
return jp;
}
static public JPanel createTitleSplitLineContentPane(String title, JComponent contentPanel) {
JPanel jp = new JPanel();
jp.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
jp.setLayout(new BorderLayout(0, 10));
UITitleSplitLine titleLine = new UITitleSplitLine(title, SplitLineWidth);
titleLine.setPreferredSize(new Dimension(SplitLineWidth, Line_Height));
jp.add(titleLine, BorderLayout.NORTH);
jp.add(contentPanel, BorderLayout.CENTER);
return jp;
}
}

205
designer-base/src/main/java/com/fr/design/hyperlink/popup/StyleSettingPane.java

@ -0,0 +1,205 @@
package com.fr.design.hyperlink.popup;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.frpane.UINumberDragPane;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.js.MobilePopupHyperlink;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
public class StyleSettingPane extends BasicBeanPane<MobilePopupHyperlink> {
private double maxNumber = 100;
private double maxBorderRadius = 24;
JPanel typePane;
UILabel popupTypeLabel;
JPanel stylePane;
LineComboBox borderType;
NewColorSelectBox borderColor;
UISpinner borderRadiusSpinner;
NewColorSelectBox bgColor;
//透明度
UINumberDragPane numberDragPane;
MobilePopupRegularPane mobileRegularPane;
MobilePopupRegularPane padRegularPane;
public StyleSettingPane() {
this.initComponent();
}
private void initComponent() {
this.setLayout(new BorderLayout(0, 10));
this.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Style")));
typePane = this.createTypePane();
this.add(typePane, BorderLayout.NORTH);
stylePane = this.createStylePane();
this.add(stylePane, BorderLayout.CENTER);
}
private JPanel createTypePane() {
JPanel typePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
popupTypeLabel = new UILabel("");
typePane.add(popupTypeLabel, BorderLayout.CENTER);
return MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Type"), typePane);
}
private JPanel createStylePane() {
JPanel stylePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
stylePane.add(this.createBorderSettingPane(), BorderLayout.NORTH);
stylePane.add(this.createBackgroundSettingPane(), BorderLayout.CENTER);
stylePane.add(this.createPopupSizePane(), BorderLayout.SOUTH);
return stylePane;
}
private JPanel createBorderSettingPane() {
JPanel borderPane = new JPanel();
VerticalFlowLayout layout = new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 10);
layout.setAlignLeft(true);
borderPane.setLayout(layout);
borderType = new LineComboBox(MobilePopupConstants.BORDER_LINE_STYLE_ARRAY);
borderType.setPreferredSize(new Dimension(115, 20));
borderPane.add(MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Line"), borderType));
borderColor = new NewColorSelectBox(100);
borderPane.add(MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Colors"), borderColor));
borderRadiusSpinner = new UISpinner(0, maxBorderRadius, 1, 20);
borderRadiusSpinner.setPreferredSize(new Dimension(120, 20));
borderPane.add(MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Radius"), borderRadiusSpinner));
return MobilePopupUIUtils.createTitleSplitLineContentPane(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Border"), borderPane);
}
private JPanel createBackgroundSettingPane() {
JPanel bgPane = new JPanel();
VerticalFlowLayout layout = new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 10);
layout.setAlignLeft(true);
bgPane.setLayout(layout);
JPanel colorPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0,0));
bgColor = new NewColorSelectBox(100);
colorPane.add(MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Colors"), bgColor));
bgPane.add(colorPane);
JPanel transparencyPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.numberDragPane = new UINumberDragPane(0,100);
this.numberDragPane.setPreferredSize(new Dimension(140, 20));
transparencyPane.add(numberDragPane, BorderLayout.CENTER);
transparencyPane.add(new UILabel(" %"), BorderLayout.EAST);
bgPane.add(MobilePopupUIUtils.createLeftTileRightContentPanel(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Opacity"), transparencyPane));
return MobilePopupUIUtils.createTitleSplitLineContentPane(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Background"), bgPane);
}
private JPanel createPopupSizePane() {
JPanel sizePane = new JPanel(new BorderLayout());
mobileRegularPane = new MobilePopupRegularPane(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Mobile_Rules"));
padRegularPane = new MobilePopupRegularPane(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Pad_Rules"));
sizePane.add(mobileRegularPane, BorderLayout.NORTH);
sizePane.add(padRegularPane, BorderLayout.CENTER);
return MobilePopupUIUtils.createTitleSplitLineContentPane(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Size"), sizePane);
}
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}
public void resetPane(String popupTargetType) {
if (StringUtils.equals(popupTargetType, MobilePopupConstants.Target_Template)) {
popupTypeLabel.setText(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Center"));
mobileRegularPane.resetPane(MobilePopupConstants.Regular_Custom, MobilePopupConstants.Popup_Center_Default_Width, MobilePopupConstants.Popup_Center_Default_Height);
padRegularPane.resetPane(MobilePopupConstants.Regular_Custom, MobilePopupConstants.Popup_Center_Default_Width, MobilePopupConstants.Popup_Center_Default_Height);
} else {
popupTypeLabel.setText(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Follow"));
mobileRegularPane.resetPane(MobilePopupConstants.Regular_Custom, MobilePopupConstants.Popup_Follow_Default_Width, MobilePopupConstants.Popup_Follow_Default_Height);
padRegularPane.resetPane(MobilePopupConstants.Regular_Custom, MobilePopupConstants.Popup_Follow_Default_Width, MobilePopupConstants.Popup_Follow_Default_Height);
}
}
@Override
public void populateBean(MobilePopupHyperlink link) {
this.populateTypeBean(link);
this.populateBorderSettingBean(link);
this.populateBackgroundSettingBean(link);
this.populatePopupSizeBean(link);
}
@Override
public MobilePopupHyperlink updateBean() {
return null;
}
@Override
public void updateBean(MobilePopupHyperlink link) {
this.updateBorderSettingBean(link);
this.updateBackgroundSettingBean(link);
this.updatePopupSizeBean(link);
}
private void populateTypeBean(MobilePopupHyperlink link) {
if (StringUtils.equals(link.getPopupTarget(), MobilePopupConstants.Target_Text)) {
popupTypeLabel.setText(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Follow"));
} else {
popupTypeLabel.setText(Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Center"));
}
}
private void populateBorderSettingBean(MobilePopupHyperlink link) {
borderType.setSelectedLineStyle(link.getBorderType());
borderColor.setSelectObject(link.getBorderColor());
borderRadiusSpinner.setValue(link.getBorderRadius());
}
private void updateBorderSettingBean(MobilePopupHyperlink link) {
link.setBorderType(borderType.getSelectedLineStyle());
link.setBorderColor(borderColor.getSelectObject());
link.setBorderRadius(borderRadiusSpinner.getValue());
}
private void populateBackgroundSettingBean(MobilePopupHyperlink link) {
bgColor.setSelectObject(link.getBgColor());
numberDragPane.populateBean(link.getBgOpacity() * maxNumber);
}
private void updateBackgroundSettingBean(MobilePopupHyperlink link) {
link.setBgColor(bgColor.getSelectObject());
link.setBgOpacity((float)(numberDragPane.updateBean() / maxNumber));
}
private void populatePopupSizeBean(MobilePopupHyperlink link) {
mobileRegularPane.setRegularType(link.getMobileRegularType());
mobileRegularPane.setWidthSpinnerValue(link.getMobileWidth());
mobileRegularPane.setHeightSpinnerValue(link.getMobileHeight());
padRegularPane.setRegularType(link.getPadRegularType());
padRegularPane.setWidthSpinnerValue(link.getPadWidth());
padRegularPane.setHeightSpinnerValue(link.getPadHeight());
}
private void updatePopupSizeBean(MobilePopupHyperlink link) {
link.setMobileRegularType(mobileRegularPane.getRegularType());
link.setMobileWidth(mobileRegularPane.getWidthSpinnerValue());
link.setMobileHeight(mobileRegularPane.getHeightSpinnerValue());
link.setPadRegularType(padRegularPane.getRegularType());
link.setPadWidth(padRegularPane.getWidthSpinnerValue());
link.setPadHeight(padRegularPane.getHeightSpinnerValue());
}
}

42
designer-base/src/main/java/com/fr/design/hyperlink/popup/WheelScrollLayerUI.java

@ -0,0 +1,42 @@
package com.fr.design.hyperlink.popup;
import com.fr.design.gui.icontainer.UIScrollPane;
import javax.swing.*;
import javax.swing.plaf.LayerUI;
import java.awt.*;
import java.awt.event.MouseWheelEvent;
class WheelScrollLayerUI extends LayerUI<UIScrollPane> {
@Override
public void installUI(JComponent c) {
super.installUI(c);
if (c instanceof JLayer) {
((JLayer) c).setLayerEventMask(AWTEvent.MOUSE_WHEEL_EVENT_MASK);
}
}
@Override
public void uninstallUI(JComponent c) {
if (c instanceof JLayer) {
((JLayer) c).setLayerEventMask(0);
}
super.uninstallUI(c);
}
@Override
protected void processMouseWheelEvent(MouseWheelEvent e, JLayer<? extends UIScrollPane> l) {
Component c = e.getComponent();
int dir = e.getWheelRotation();
JScrollPane main = l.getView();
if (c instanceof JScrollPane && !c.equals(main)) {
JScrollPane child = (JScrollPane) c;
BoundedRangeModel m = child.getVerticalScrollBar().getModel();
int extent = m.getExtent();
int minimum = m.getMinimum();
int maximum = m.getMaximum();
int value = m.getValue();
if (value + extent >= maximum && dir > 0 || value <= minimum && dir < 0) {
main.dispatchEvent(SwingUtilities.convertMouseEvent(c, e, main));
}
}
}
}

2
designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java

@ -7,6 +7,7 @@ import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.fun.JavaScriptActionProvider;
import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.hyperlink.popup.MobilePopupPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.write.submit.DBManipulationPane;
@ -51,6 +52,7 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
if (workbook) {
paneList.add(new ExportJavaScriptPane());
}
paneList.add(new MobilePopupPane());
Set<JavaScriptActionProvider> javaScriptActionProviders = ExtraDesignClassManager.getInstance().getArray(JavaScriptActionProvider.XML_TAG);
if (javaScriptActionProviders != null) {
for (JavaScriptActionProvider jsp : javaScriptActionProviders) {

21
designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java

@ -2,8 +2,8 @@ package com.fr.design.layout;
import com.fr.design.border.UITitledBorder;
import com.fr.design.gui.ilable.UILabel;
import com.fr.stable.AssistUtils;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.Icon;
@ -46,6 +46,16 @@ public class FRGUIPaneFactory {
return new FlowLayout(FlowLayout.LEFT, 0, 0);
}
/**
* 创建一个靠左的布局上下间隔为0左右间隔为常量首间隔为0
*
* @return FlowLayout对象
*/
public static LayoutManager createLeftZeroVgapNormalHgapLayout() {
return new FRLeftFlowLayout(0, 5, 0);
}
/**
* 创建一个靠右的布局
*
@ -581,6 +591,15 @@ public class FRGUIPaneFactory {
return jp;
}
public static JPanel createBorderLayout_NO_Opaque_Pane() {
JPanel jp = new JPanel();
jp.setOpaque(false);
jp.setBackground(null);
jp.setLayout(FRGUIPaneFactory.createBorderLayout());
return jp;
}
/**
* 创建卡片式布局
*

33
designer-base/src/main/java/com/fr/design/locale/impl/DoubleSplashMark.java

@ -0,0 +1,33 @@
package com.fr.design.locale.impl;
import com.fr.design.DesignerEnvManager;
import com.fr.general.locale.LocaleMark;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/9/2
*/
public class DoubleSplashMark implements LocaleMark<String> {
private final Map<Locale, String> map = new HashMap<Locale, String>();
private static final String SPLASH_PATH_X2 = "/com/fr/design/images/splash@2x.png";
private static final String SPLASH_PATH_EN_X2 = "/com/fr/design/images/splash_en@2x.png";
public DoubleSplashMark() {
map.put(Locale.CHINA, SPLASH_PATH_X2);
map.put(Locale.KOREA, SPLASH_PATH_EN_X2);
map.put(Locale.JAPAN, SPLASH_PATH_EN_X2);
map.put(Locale.US, SPLASH_PATH_EN_X2);
map.put(Locale.TAIWAN, SPLASH_PATH_EN_X2);
}
@Override
public String getValue() {
String result = map.get(DesignerEnvManager.getEnvManager().getLanguage());
return result == null ? SPLASH_PATH_EN_X2 : result;
}
}

4
designer-base/src/main/java/com/fr/design/locale/impl/SplashMark.java

@ -15,8 +15,8 @@ import java.util.Map;
public class SplashMark implements LocaleMark<String> {
private Map<Locale, String> map = new HashMap<Locale, String>();
private static final String SPLASH_PATH = "/com/fr/design/images/splash_10.png";
private static final String SPLASH_EN_PATH = "/com/fr/design/images/splash_10_en.png";
private static final String SPLASH_PATH = "/com/fr/design/images/splash.png";
private static final String SPLASH_EN_PATH = "/com/fr/design/images/splash_en.png";
public SplashMark() {
map.put(Locale.CHINA, SPLASH_PATH);

15
designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java

@ -19,10 +19,14 @@ import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.border.MatteBorder;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Insets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/**
* @author shine
@ -96,7 +100,7 @@ public class CenterRegionContainerPane extends JPanel {
}
private ToolBarMenuDock getToolBarMenuDock() {
public ToolBarMenuDock getToolBarMenuDock() {
return DesignerContext.getDesignerFrame().getToolBarMenuDock();
}
@ -267,12 +271,13 @@ public class CenterRegionContainerPane extends JPanel {
return centerTemplateCardPane;
}
protected void refreshUIToolBar() {
public Map<Component, Boolean> getToolbarComponentState() {
Map<Component, Boolean> toolbarComponentState = new HashMap<>();
if (toolbarComponent instanceof UIToolbar) {
((UIToolbar ) toolbarComponent).refreshUIToolBar();
toolbarComponentState.putAll(((UIToolbar) toolbarComponent).getComponentState());
}
combineUp.refreshUIToolBar();
getToolBarMenuDock().updateEnable();
toolbarComponentState.putAll(combineUp.getComponentState());
return toolbarComponentState;
}
}

22
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -136,6 +136,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
//用于判断设计器是否打开了
private boolean designerOpened = false;
private boolean serverConfig = false;
private int contentWidth = (int) (java.awt.Toolkit.getDefaultToolkit().getScreenSize().getWidth());
private int contentHeight = (int) (java.awt.Toolkit.getDefaultToolkit().getScreenSize().getHeight());
@ -365,14 +367,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
public DesktopCardPane getCenterTemplateCardPane() {
return CenterRegionContainerPane.getInstance().getCenterTemplateCardPane();
}
public void refreshUIToolBar() {
CenterRegionContainerPane.getInstance().refreshUIToolBar();
}
/**
* 初始menuPane的方法 方便OEM时修改该组件
*/
@ -1182,4 +1179,19 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
return designerOpened;
}
/**
* 判断是否正在进行服务器配置
* @return boolean
*/
public boolean isServerConfig() {
return serverConfig;
}
/**
* 设置是否正在进行服务器配置
* @param serverConfig
*/
public void setServerConfig(boolean serverConfig) {
this.serverConfig = serverConfig;
}
}

27
designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java

@ -10,11 +10,14 @@ import com.fr.design.data.BasicTableDataTreePane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener;
import com.fr.design.gui.itoolbar.UIToolbar;
import javax.swing.JComponent;
import javax.swing.JLayeredPane;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.HashMap;
import java.util.Map;
/**
@ -33,6 +36,9 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
private TransparentPane transparentPane = new TransparentPane();
private OpenLoadingPane loadingPane = new OpenLoadingPane();
private OpenFailedPane failedPane = new OpenFailedPane();
Map<Component, Boolean> backUpToolbarComponentState = new HashMap<>();
private JLayeredPane layeredPane = new JLayeredPane() {
@Override
public void doLayout() {
@ -103,7 +109,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
}
private void showOpenStatus() {
DesignerContext.getDesignerFrame().refreshUIToolBar();
forbidToolBar();
DesignerFrameFileDealerPane.getInstance().stateChange();
EastRegionContainerPane.getInstance().updateAllPropertyPane();
JComponent downPane = WestRegionContainerPane.getInstance().getDownPane();
@ -120,9 +126,9 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
}
public void showCover() {
forbidToolBar();
transparentPane.start();
layeredPane.moveToFront(transparentPane);
DesignerContext.getDesignerFrame().refreshUIToolBar();
EastRegionContainerPane.getInstance().updateAllPropertyPane();
JComponent downPane = WestRegionContainerPane.getInstance().getDownPane();
if (downPane instanceof BasicTableDataTreePane) {
@ -132,6 +138,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
}
public void hideCover() {
recoverToolBar();
transparentPane.stop();
layeredPane.moveToFront(component);
EastRegionContainerPane.getInstance().updateAllPropertyPane();
@ -142,6 +149,22 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
}
}
private void forbidToolBar() {
CenterRegionContainerPane centerRegionContainerPane = CenterRegionContainerPane.getInstance();
backUpToolbarComponentState = centerRegionContainerPane.getToolbarComponentState();
for (Component component : backUpToolbarComponentState.keySet()) {
component.setEnabled(false);
}
centerRegionContainerPane.getToolBarMenuDock().updateEnable();
}
private void recoverToolBar() {
UIToolbar.resetComponentState(backUpToolbarComponentState);
backUpToolbarComponentState.clear();
CenterRegionContainerPane centerRegionContainerPane = CenterRegionContainerPane.getInstance();
centerRegionContainerPane.getToolBarMenuDock().updateEnable();
}
protected JTemplate<?, ?> getSelectedJTemplate() {
return component;
}

3
designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java

@ -458,6 +458,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
for (PropertyItem item : propertyItemMap.values()) {
item.onResize();
}
super.onResize();
}
public EastRegionContainerPane(JPanel leftPane, JPanel rightPane) {
@ -1006,7 +1007,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
button.setToolTipText(title);
}
public void processSnapChat(){
public void processSnapChat() {
if (snapChat != null && !snapChat.hasRead()) {
snapChat.markRead();
if (promptWindow != null) {

142
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -2,10 +2,16 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.Parameter;
import com.fr.base.extension.FileExtension;
import com.fr.base.io.BaseBook;
import com.fr.base.iofile.attr.DesignBanCopyAttrMark;
import com.fr.base.iofile.attr.TemplateIdAttrMark;
import com.fr.base.iofile.attr.TemplateThemeAttrMark;
import com.fr.base.theme.TemplateThemeCompatible;
import com.fr.base.theme.ThemedTemplate;
import com.fr.base.vcs.DesignerMode;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeConfig;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager;
@ -13,6 +19,7 @@ import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.TableDataSourceAction;
import com.fr.design.actions.edit.RedoAction;
import com.fr.design.actions.edit.UndoAction;
import com.fr.design.actions.file.BatchCompileAction;
import com.fr.design.actions.file.SaveAsTemplateAction;
import com.fr.design.actions.file.SaveTemplateAction;
import com.fr.design.actions.file.WebPreviewUtils;
@ -36,6 +43,7 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.authority.JTemplateAuthorityChecker;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.design.mainframe.check.CheckButton;
import com.fr.design.mainframe.template.info.TemplateProcessInfo;
@ -59,9 +67,12 @@ import com.fr.file.MemFILE;
import com.fr.form.ui.NoneWidget;
import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginRuntime;
import com.fr.nx.app.designer.toolbar.CompileAction;
import com.fr.nx.app.designer.toolbar.TemplateTransformer;
import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
@ -82,22 +93,27 @@ import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.SwingConstants;
import javax.swing.undo.UndoManager;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.util.Set;
import java.util.concurrent.Callable;
/**
* 报表设计和表单设计的编辑区域(设计器编辑的IO文件)
*/
public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>> extends TargetComponent<T> implements ToolBarMenuDockPlus, DesignerProxy, JTemplateSave, TabChangeListener {
public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>> extends TargetComponent<T> implements ToolBarMenuDockPlus, DesignerProxy, JTemplateSave, TabChangeListener, ThemedTemplate {
// TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null
private static final int PREDEFINED_ICON_WIDTH = 27;
private static final int PREFIX_NUM = 3000;
protected FILE editingFILE = null;
// alex:初始状态为saved,这样不管是新建模板,还是打开模板,如果未做任何操作直接关闭,不提示保存
private boolean saved = true;
private boolean authoritySaved = true;
private UIButton templateThemeButton;
private UndoManager undoMananger;
private UndoManager authorityUndoManager;
protected U undoState;
@ -131,9 +147,12 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
private final String runtimeId = UUID.randomUUID().toString();
private PluginEventListener pluginListener;
// 监听全局主题数据更新
private TemplateThemeConfig.ThemeConfigChangeListener themeConfigChangeListener;
public JTemplate() {
initAndStartPlugin();
startListenThemeConfig();
}
public JTemplate(T t, String defaultFileName) {
@ -172,9 +191,14 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
designModel = createDesignModel(parameters);
}
addCenterPane();
if (isNewFile) {
// REPORT-58486: 必须在初始的UndoState创建前设置主题,使得初始的UndoState就包含了主题效果
setUpTheme4NewTemplate();
}
this.undoState = createUndoState();
initAndStartPlugin();
startListenThemeConfig();
}
private void initAndStartPlugin() {
@ -204,6 +228,36 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, this.pluginListener, filter);
}
private void startListenThemeConfig() {
if (themeConfigChangeListener == null) {
themeConfigChangeListener = new TemplateThemeConfig.ThemeConfigChangeListener() {
@Override
public void onThemeConfigChanged(TemplateThemeConfig.ThemeConfigEvent event) {
TemplateTheme usingTheme = getTemplateTheme();
boolean isUsingThemeChanged = StringUtils.equals(event.themName, usingTheme.getName());
if (isUsingThemeChanged && (event.action == TemplateThemeConfig.ThemeConfigAction.REMOVE ||
event.action == TemplateThemeConfig.ThemeConfigAction.UPDATE)) {
checkAndResetTheme();
}
}
};
TemplateThemeConfig<? extends TemplateTheme> config = getUsingTemplateThemeConfig();
if (config != null) {
config.addThemeConfigChangeListener(themeConfigChangeListener);
}
}
}
private void stopListenThemeConfig() {
if (themeConfigChangeListener != null) {
TemplateThemeConfig<? extends TemplateTheme> config = getUsingTemplateThemeConfig();
if (config != null) {
config.removeThemeConfigChangeListener(themeConfigChangeListener);
}
}
}
private void initPluginPane() {
ExtraDesignClassManager classManager = PluginModule.getAgent(PluginModule.ExtraDesign);
@ -217,7 +271,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
public void fireTabChange() {
// do nothing
}
protected <R> void addPane(PropertyItemPaneProvider provider) {
// do nothing
}
@ -367,6 +421,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
public void whenClose() {
// stop的时候 pluginListener 和 PluginFilter 都会移除
PluginListenerRegistration.getInstance().stopListen(this.pluginListener);
stopListenThemeConfig();
}
@ -562,6 +617,8 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
*/
public void undo() {
this.getUndoManager().undo();
// 撤销前模版使用主题可能已经被删除或修改,需要重置模版样式
checkAndResetTheme();
fireSuperTargetModified();
}
@ -570,7 +627,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
*/
public void redo() {
this.getUndoManager().redo();
fireSuperTargetModified();
}
@ -622,6 +678,14 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
super.fireTargetModified();
}
public void fireTargetModified(boolean shouldCreateNewUndoState) {
if (shouldCreateNewUndoState) {
fireTargetModified();
} else {
super.fireTargetModified();
}
}
protected abstract U createUndoState();
protected abstract void applyUndoState(U u);
@ -817,10 +881,12 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
protected boolean saveToNewFile(String oldName) {
boolean result = false;
String path = this.editingFILE.getPath();
Set<ReportSupportedFileUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG);
for (ReportSupportedFileUIProvider provider : providers) {
result = result || provider.saveToNewFile(this.editingFILE.getPath(), this);
result = result || provider.saveToNewFile(path, this);
}
result = result || saveToNewFile4Cptx(path);
if (!result) {
result = this.saveFile();
//更换最近打开
@ -830,6 +896,14 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return result;
}
private boolean saveToNewFile4Cptx(String targetPath) {
if (FileExtension.CPTX.matchExtension(targetPath)) {
TemplateTransformer.TO_CPTX.transform(this);
return true;
}
return false;
}
protected void mkNewFile(FILE file) {
try {
file.mkfile();
@ -895,7 +969,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
} else if (DesignerMode.isAuthorityEditing()) {
return new ShortCut[]{new SaveTemplateAction(this), new UndoAction(this), new RedoAction(this)};
} else {
return new ShortCut[]{new SaveTemplateAction(this), new SaveAsTemplateAction(this), new UndoAction(this), new RedoAction(this)};
return new ShortCut[]{new SaveTemplateAction(this), new SaveAsTemplateAction(this), new BatchCompileAction(), new UndoAction(this), new RedoAction(this)};
}
}
@ -1332,11 +1406,15 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
* @return 按钮组
*/
public UIButton[] createExtraButtons() {
UIButton[] uiButtons = new UIButton[]{
(UIButton) new CompileAction().createToolBarComponent()
};
Set<DesignerFrameUpButtonProvider> providers = ExtraDesignClassManager.getInstance().getArray(DesignerFrameUpButtonProvider.XML_TAG);
UIButton[] uiButtons = new UIButton[0];
for (DesignerFrameUpButtonProvider provider : providers) {
uiButtons = ArrayUtils.addAll(uiButtons, provider.getUpButtons(getMenuState()));
}
templateThemeButton = createTemplateThemeButton();
uiButtons = ArrayUtils.addAll(uiButtons, templateThemeButton);
return uiButtons;
}
@ -1345,6 +1423,23 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return new UIButton[]{new CheckButton()};
}
protected UIButton createTemplateThemeButton() {
UIButton button = new UIButton(IOUtils.readIcon("/com/fr/design/icon/icon_predefined_style.png")) {
@Override
public Dimension getPreferredSize() {
FontMetrics metrics = getFontMetrics(getFont());
int width = Math.min(metrics.stringWidth(getText()) + PREDEFINED_ICON_WIDTH, 100);
return new Dimension(width, 20);
}
};
button.setToolTipText(getTemplateTheme().getName());
button.setText(getTemplateTheme().getName());
button.setAlignmentX(SwingConstants.LEFT);
button.set4ToolbarButton();
button.setEnabled(true);
return button;
}
/**
* 由于老版本的模板没有模板ID当勾选使用参数模板时候就加一个模板ID attr
*
@ -1456,13 +1551,19 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
}
private boolean saveRealFile() throws Exception {
FILE editingFILE = this.getEditingFILE();
if (editingFILE == null || editingFILE instanceof MemFILE) {
JTemplateAuthorityChecker jTemplateAuthorityChecker = new JTemplateAuthorityChecker(this);
if (jTemplateAuthorityChecker.isAuthority()) {
FILE editingFILE = this.getEditingFILE();
if (editingFILE == null || editingFILE instanceof MemFILE) {
return false;
}
this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(editingFILE));
this.editingFILE = editingFILE;
return true;
} else {
jTemplateAuthorityChecker.showAuthorityFailPromptDialog();
return false;
}
this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(editingFILE));
this.editingFILE = editingFILE;
return true;
}
private CallbackSaveWorker saveAs(boolean showLoc) {
@ -1628,4 +1729,23 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
public String getRuntimeId() {
return runtimeId;
}
protected void setUpTheme4NewTemplate() {
TemplateTheme theme = getUsingTemplateThemeConfig().cachedFetchTheme4NewTemplate();
TemplateThemeAttrMark themeAttrMark = template.getAttrMark(TemplateThemeAttrMark.XML_TAG);
if (themeAttrMark == null) {
themeAttrMark = new TemplateThemeAttrMark();
template.addAttrMark(themeAttrMark);
}
themeAttrMark.setName(theme.getName());
themeAttrMark.setDark(theme.isDark());
}
@Override
public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) {
ThemedTemplate.super.setTemplateTheme(newTheme, compatible);
String name = newTheme.getName();
templateThemeButton.setText(name);
templateThemeButton.setToolTipText(name);
}
}

20
designer-base/src/main/java/com/fr/design/mainframe/authority/DSColumnAuthorityChecker.java

@ -0,0 +1,20 @@
package com.fr.design.mainframe.authority;
import com.fr.report.cell.cellattr.core.group.DSColumn;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class DSColumnAuthorityChecker extends ElementAuthorityChecker<DSColumn> {
@Override
@Nullable
Set<String> getNoAuthDatasetNames(DSColumn dsColumn, Set<String> authDatasetNames) {
if (!authDatasetNames.contains(dsColumn.getDSName())) {
return new HashSet<>(Arrays.asList(dsColumn.getDSName()));
}
return null;
}
}

45
designer-base/src/main/java/com/fr/design/mainframe/authority/ElementAuthorityChecker.java

@ -0,0 +1,45 @@
package com.fr.design.mainframe.authority;
import org.jetbrains.annotations.Nullable;
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
import java.lang.reflect.Type;
import java.util.Set;
public abstract class ElementAuthorityChecker<T> {
/**
* @Description 获取越权的数据连接
* @param: t 待检查的对象
* @param: authConnectionNames 有权限的数据连接名
* @return 如果有返回名称没有返回null
*/
@Nullable
Set<String> getNoAuthConnectionNames(T t, Set<String> authConnectionNames) {
return null;
}
/**
* @Description 获取越权的服务器数据集
* @param: t 待检查的对象
* @param: authDatasetNames 有权限的服务器数据集名
* @return 如果有返回名称没有返回null
*/
@Nullable
Set<String> getNoAuthDatasetNames(T t, Set<String> authDatasetNames) {
return null;
}
/**
* @Description 要检查对象的className
* @return className
*/
String getCheckClassName() {
ParameterizedTypeImpl parameterizedType = (ParameterizedTypeImpl) this.getClass().getGenericSuperclass();
Type type = parameterizedType.getActualTypeArguments()[0];
return type.getTypeName();
}
}

27
designer-base/src/main/java/com/fr/design/mainframe/authority/FormulaAuthorityChecker.java

@ -0,0 +1,27 @@
package com.fr.design.mainframe.authority;
import com.fr.base.Formula;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class FormulaAuthorityChecker extends ElementAuthorityChecker<Formula> {
private static final Pattern FORMULA_PATTERN = Pattern.compile("^=SQL\\(\"(.+?)\",");
@Override
@Nullable
public Set<String> getNoAuthConnectionNames(Formula formula, Set<String> authConnectionNames) {
String content = formula.getContent();
Matcher matcher = FORMULA_PATTERN.matcher(content);
if (matcher.find()) {
if (!authConnectionNames.contains(matcher.group(1))) {
return new HashSet<>(Arrays.asList(matcher.group(1)));
}
}
return null;
}
}

184
designer-base/src/main/java/com/fr/design/mainframe/authority/JTemplateAuthorityChecker.java

@ -0,0 +1,184 @@
package com.fr.design.mainframe.authority;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mod.ModClassFilter;
import com.fr.invoke.ClassHelper;
import com.fr.log.FineLoggerFactory;
import com.fr.rpc.ExceptionHandler;
import com.fr.rpc.RPCInvokerExceptionInfo;
import com.fr.stable.Filter;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.authority.user.UserAuthority;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
public class JTemplateAuthorityChecker {
JTemplate<?, ?> jTemplate;
Set<String> authConnectionNames;
Set<String> authDatasetNames;
Map<String, ElementAuthorityChecker> checkerMap = new HashMap<>();
Set<String> authFailConnectionNames = new HashSet<>();
Set<String> authFailDatasetNames = new HashSet<>();
public JTemplateAuthorityChecker(JTemplate<?, ?> jTemplate) {
long s = System.currentTimeMillis();
this.jTemplate = jTemplate;
this.initAuthNames();
this.initChecker();
FineLoggerFactory.getLogger().info("JTemplateAuthorityChecker init time consume:" + (System.currentTimeMillis() - s));
}
private void initAuthNames() {
UserAuthority templateAuthority = WorkContext.getCurrent().get(UserAuthority.class);
Map<String, Set<String>> authNamesMap = templateAuthority.getAuthServerDataSetAndConnectionNames();
if (authNamesMap != null) {
//有权限的数据连接名称
authConnectionNames = authNamesMap.get(UserAuthority.AUTH_CONNECTION_NAMES);
//有权限的数据集名称(模板数据集和服务器数据集)
authDatasetNames = authNamesMap.get(UserAuthority.AUTH_SERVER_DATASET_NAMES);
Iterator<String> iterator = jTemplate.getTarget().getTableDataNameIterator();
while (iterator.hasNext()) {
String datasetName = iterator.next();
authDatasetNames.add(datasetName);
}
}
}
private void initChecker() {
registerChecker(new NameDatabaseConnectionAuthorityChecker());
registerChecker(new DSColumnAuthorityChecker());
registerChecker(new FormulaAuthorityChecker());
registerChecker(new NameTableDataAuthorityChecker());
}
private void registerChecker(ElementAuthorityChecker checker) {
checkerMap.put(checker.getCheckClassName(), checker);
}
public boolean isAuthority() {
long s = System.currentTimeMillis();
//遍历模板对象,根据checkerMap.keySet()把感兴趣的对象找出来
Map<String, Collection<Object>> targetObjects = ClassHelper.searchObject(jTemplate.getTarget(), checkerMap.keySet(), ClassFilter.getInstance());
//找到对应的checker,对对象进行检查
for (String name : targetObjects.keySet()) {
ElementAuthorityChecker checker = checkerMap.get(name);
for (Object object : targetObjects.get(name)) {
if (authConnectionNames != null) {
Set<String> noAuthName = checker.getNoAuthConnectionNames(object, authConnectionNames);
if (noAuthName != null) {
authFailConnectionNames.addAll(noAuthName);
}
}
if (authDatasetNames != null) {
Set<String> noAuthName = checker.getNoAuthDatasetNames(object, authDatasetNames);
if (noAuthName != null) {
authFailDatasetNames.addAll(noAuthName);
}
}
}
}
FineLoggerFactory.getLogger().info("JTemplateAuthorityChecker check time consume:" + (System.currentTimeMillis() - s));
return authFailConnectionNames.size() == 0 && authFailDatasetNames.size() == 0;
}
public void showAuthorityFailPromptDialog() {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(Toolkit.i18nText("Fine-Design-Basic_Save_Failure"));
stringBuffer.append("\n");
stringBuffer.append(getPromptInfo(authFailDatasetNames,
Toolkit.i18nText("Fine-Design_Template_Authority_Check_Server_Dataset_Authority")));
stringBuffer.append(getPromptInfo(authFailConnectionNames,
Toolkit.i18nText("Fine-Design_Template_Authority_Check_Data_Connection_Authority")));
FineJOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
stringBuffer.toString(),
Toolkit.i18nText("Fine-Design_Basic_Alert"),
WARNING_MESSAGE);
}
private String getPromptInfo(Set<String> authFailNames, String message) {
StringBuffer stringBuffer = new StringBuffer();
if (authFailNames.size() > 0) {
stringBuffer.append(Toolkit.i18nText("Fine-Design_Template_Authority_Check_Current_Operator_Miss"));
stringBuffer.append(authFailNames.size());
stringBuffer.append(Toolkit.i18nText("Fine-Design_Report_Ge"));
stringBuffer.append(message);
stringBuffer.append("\n");
stringBuffer.append(getNoAuthNameSequence(authFailNames));
}
return stringBuffer.toString();
}
private String getNoAuthNameSequence(Set<String> names) {
StringBuffer stringBuffer = new StringBuffer();
int showMaxCount = 3;
int count = 0;
for (String name : names) {
if (count == showMaxCount) {
stringBuffer.append(Toolkit.i18nText("Fine-Design_Template_Authority_Check_Etc"));
break;
}
stringBuffer.append(name);
if (count != names.size() - 1 && count != showMaxCount - 1) {
stringBuffer.append(";");
}
count++;
}
stringBuffer.append("\n");
return stringBuffer.toString();
}
static class ClassFilter implements Filter<String> {
private static final Set<String> FILTER_SET = new HashSet<>();
private static final Set<String> START_WITH_SET = new HashSet<>();
private static final Filter<String> INSTANCE = new ModClassFilter();
public static Filter<String> getInstance() {
return INSTANCE;
}
static {
FILTER_SET.add("java.awt.image.BufferedImage");
FILTER_SET.add("sun.awt.AppContext");
FILTER_SET.add("com.fr.poly.creator.ECBlockCreator");
FILTER_SET.add("io.netty.channel.nio.SelectedSelectionKeySet");
FILTER_SET.add("com.fr.form.ui.ElementCaseImage");
FILTER_SET.add("this$0");
START_WITH_SET.add("com.fr.design");
}
@Override
public boolean accept(String s) {
if (FILTER_SET.contains(s)) {
return true;
}
for (String start : START_WITH_SET) {
if (s.startsWith(start)) {
return true;
}
}
return false;
}
}
}

22
designer-base/src/main/java/com/fr/design/mainframe/authority/NameDatabaseConnectionAuthorityChecker.java

@ -0,0 +1,22 @@
package com.fr.design.mainframe.authority;
import com.fr.data.impl.NameDatabaseConnection;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
public class NameDatabaseConnectionAuthorityChecker extends ElementAuthorityChecker<NameDatabaseConnection> {
@Override
@Nullable
Set<String> getNoAuthConnectionNames(NameDatabaseConnection nameDatabaseConnection, Set<String> authConnectionNames) {
String name = nameDatabaseConnection.getName();
if (!authConnectionNames.contains(name)) {
return new HashSet<>(Arrays.asList(name));
}
return null;
}
}

19
designer-base/src/main/java/com/fr/design/mainframe/authority/NameTableDataAuthorityChecker.java

@ -0,0 +1,19 @@
package com.fr.design.mainframe.authority;
import com.fr.data.impl.NameTableData;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class NameTableDataAuthorityChecker extends ElementAuthorityChecker<NameTableData> {
@Override
@Nullable
Set<String> getNoAuthDatasetNames(NameTableData nameTableData, Set<String> authDatasetNames) {
if (!authDatasetNames.contains(nameTableData.getName())) {
return new HashSet<>(Arrays.asList(nameTableData.getName()));
}
return null;
}
}

23
designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java

@ -3,12 +3,8 @@ package com.fr.design.mainframe.backgroundpane;
import com.fr.base.background.ColorBackground;
import com.fr.design.event.UIObserverListener;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.style.color.NewColorSelectPane;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.general.Background;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Color;
@ -18,13 +14,13 @@ import java.awt.Color;
*/
public class ColorBackgroundQuickPane extends BackgroundQuickPane {
private NewColorSelectPane detailColorSelectPane;
private NewColorSelectBox colorSelectBox;
public ColorBackgroundQuickPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
detailColorSelectPane = new NewColorSelectPane();
this.add(detailColorSelectPane, BorderLayout.NORTH);
colorSelectBox = new NewColorSelectBox(100);
this.add(colorSelectBox, BorderLayout.NORTH);
}
public void populateBean(Background background) {
@ -37,12 +33,11 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane {
}
public void populateColor(Color color) {
this.detailColorSelectPane.setColor(color);
this.colorSelectBox.setSelectObject(color);
}
public Color updateColor() {
this.detailColorSelectPane.updateUsedColor();
return this.detailColorSelectPane.getNotNoneColor();
return this.colorSelectBox.getSelectObject();
}
/**
@ -52,7 +47,7 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane {
*/
@Override
public void registerChangeListener(final UIObserverListener listener) {
detailColorSelectPane.addChangeListener(new ChangeListenerImpl(listener));
this.colorSelectBox.addSelectChangeListener(new ChangeListenerImpl(listener));
}
@Override
@ -78,6 +73,6 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane {
@Override
public void reset() {
this.detailColorSelectPane.setColor(null);
this.colorSelectBox.setSelectObject(null);
}
}

35
designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/combo/SimpleComboCheckBoxStyleProvider.java

@ -0,0 +1,35 @@
package com.fr.design.mainframe.mobile.provider.combo;
import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane;
import com.fr.design.mainframe.mobile.ui.combo.SimpleComboPane;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.form.ui.mobile.combo.SimpleComboStyle;
public class SimpleComboCheckBoxStyleProvider extends AbstractMobileWidgetStyleProvider {
@Override
public Class<? extends MobileStyle> classForMobileStyle() {
return SimpleComboStyle.class;
}
@Override
public Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance() {
return SimpleComboPane.class;
}
@Override
public String xTypeForWidget() {
return "tagcombocheckbox";
}
@Override
public String displayName() {
return Toolkit.i18nText("Fine-Plugin-SimpleCombo_SimpleComboStyle");
}
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
}

35
designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/combo/SimpleComboStyleProvider.java

@ -0,0 +1,35 @@
package com.fr.design.mainframe.mobile.provider.combo;
import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane;
import com.fr.design.mainframe.mobile.ui.combo.SimpleComboPane;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.form.ui.mobile.combo.SimpleComboStyle;
public class SimpleComboStyleProvider extends AbstractMobileWidgetStyleProvider{
@Override
public Class<? extends MobileStyle> classForMobileStyle() {
return SimpleComboStyle.class;
}
@Override
public Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance() {
return SimpleComboPane.class;
}
@Override
public String xTypeForWidget() {
return "combo";
}
@Override
public String displayName() {
return Toolkit.i18nText("Fine-Plugin-SimpleCombo_SimpleComboStyle");
}
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
}

35
designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/date/NavigationStyleProvider.java

@ -0,0 +1,35 @@
package com.fr.design.mainframe.mobile.provider.date;
import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane;
import com.fr.design.mainframe.mobile.ui.date.NavigationCustomDefinePane;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.form.ui.mobile.date.NavigationMobileStyle;
public class NavigationStyleProvider extends AbstractMobileWidgetStyleProvider {
@Override
public Class<? extends MobileStyle> classForMobileStyle() {
return NavigationMobileStyle.class;
}
@Override
public Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance() {
return NavigationCustomDefinePane.class;
}
@Override
public String xTypeForWidget() {
return "datetime";
}
@Override
public String displayName() {
return Toolkit.i18nText("Fine-Plugin-Date_Navigation_Calendar");
}
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
}

35
designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/date/SimpleDateStyleProvider.java

@ -0,0 +1,35 @@
package com.fr.design.mainframe.mobile.provider.date;
import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane;
import com.fr.design.mainframe.mobile.ui.date.SimpleDateCustomDefinePane;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.form.ui.mobile.date.SimpleDateMobileStyle;
public class SimpleDateStyleProvider extends AbstractMobileWidgetStyleProvider {
@Override
public Class<? extends MobileStyle> classForMobileStyle() {
return SimpleDateMobileStyle.class;
}
@Override
public Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance() {
return SimpleDateCustomDefinePane.class;
}
@Override
public String xTypeForWidget() {
return "datetime";
}
@Override
public String displayName() {
return Toolkit.i18nText("Fine-Plugin-SimpleDate_Style");
}
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
}

35
designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/date/SimpleStyleProvider.java

@ -0,0 +1,35 @@
package com.fr.design.mainframe.mobile.provider.date;
import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane;
import com.fr.design.mainframe.mobile.ui.date.SimpleCustomDefinePane;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.form.ui.mobile.date.SimpleMobileStyle;
public class SimpleStyleProvider extends AbstractMobileWidgetStyleProvider {
@Override
public Class<? extends MobileStyle> classForMobileStyle() {
return SimpleMobileStyle.class;
}
@Override
public Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance() {
return SimpleCustomDefinePane.class;
}
@Override
public String xTypeForWidget() {
return "datetime";
}
@Override
public String displayName() {
return Toolkit.i18nText("Fine-Plugin-Date_Simple_Calendar");
}
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
}

35
designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/radiogroup/CapsuleRadioGroupStyleProvider.java

@ -0,0 +1,35 @@
package com.fr.design.mainframe.mobile.provider.radiogroup;
import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane;
import com.fr.design.mainframe.mobile.ui.radiogroup.CapsuleCustomDefinePane;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.form.ui.mobile.radiogroup.CapsuleMobileStyle;
public class CapsuleRadioGroupStyleProvider extends AbstractMobileWidgetStyleProvider {
@Override
public Class<? extends MobileStyle> classForMobileStyle() {
return CapsuleMobileStyle.class;
}
@Override
public Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance() {
return CapsuleCustomDefinePane.class;
}
@Override
public String xTypeForWidget() {
return "radiogroup";
}
@Override
public String displayName() {
return Toolkit.i18nText("Fine-Plugin-RadioGroup_Capsule_Button");
}
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
}

35
designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/radiogroup/ImageRadioGroupStyleProvider.java

@ -0,0 +1,35 @@
package com.fr.design.mainframe.mobile.provider.radiogroup;
import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane;
import com.fr.design.mainframe.mobile.ui.radiogroup.ImageCustomDefinePane;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.form.ui.mobile.radiogroup.ImageMobileStyle;
public class ImageRadioGroupStyleProvider extends AbstractMobileWidgetStyleProvider {
@Override
public Class<? extends MobileStyle> classForMobileStyle() {
return ImageMobileStyle.class;
}
@Override
public Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance() {
return ImageCustomDefinePane.class;
}
@Override
public String xTypeForWidget() {
return "radiogroup";
}
@Override
public String displayName() {
return Toolkit.i18nText("Fine-Plugin-RadioGroup_Graphic_Button");
}
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
}

35
designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/radiogroup/UnitedRadioGroupStyleProvider.java

@ -0,0 +1,35 @@
package com.fr.design.mainframe.mobile.provider.radiogroup;
import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane;
import com.fr.design.mainframe.mobile.ui.radiogroup.UnitedCustomDefinePane;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.form.ui.mobile.radiogroup.UnitedMobileStyle;
public class UnitedRadioGroupStyleProvider extends AbstractMobileWidgetStyleProvider {
@Override
public Class<? extends MobileStyle> classForMobileStyle() {
return UnitedMobileStyle.class;
}
@Override
public Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance() {
return UnitedCustomDefinePane.class;
}
@Override
public String xTypeForWidget() {
return "radiogroup";
}
@Override
public String displayName() {
return Toolkit.i18nText("Fine-Plugin-RadioGroup_Linkage_Button");
}
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
}

25
designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/topparam/MobileTopParamStyleProvider.java

@ -0,0 +1,25 @@
package com.fr.design.mainframe.mobile.provider.topparam;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.fun.impl.AbstractMobileParamUIProvider;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.mobile.ui.topparam.MobileTopParamPane;
import com.fr.form.ui.mobile.MobileParamStyle;
import com.fr.form.ui.mobile.impl.MobileTopParamStyle;
public class MobileTopParamStyleProvider extends AbstractMobileParamUIProvider {
@Override
public Class<? extends MobileParamStyle> classForMobileParamStyle() {
return MobileTopParamStyle.class;
}
@Override
public Class<? extends BasicBeanPane<? extends MobileParamStyle>> classForMobileParamAppearance() {
return MobileTopParamPane.class;
}
@Override
public String displayName() {
return Toolkit.i18nText("Fine-Plugin-TopParam_Name");
}
}

6
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileParamSettingPane.java

@ -7,7 +7,7 @@ import com.fr.design.fun.MobileParamUIProvider;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.mobile.provider.DefaultMobileParamUIProvider;
import com.fr.design.mainframe.mobile.provider.EmptyMobileParamUIProvider;
import com.fr.form.ui.container.WParameterLayout;
import com.fr.design.mainframe.mobile.utils.MobileStyleProviderManager;
import com.fr.form.ui.mobile.MobileParamStyle;
import com.fr.general.ComparatorUtils;
import com.fr.report.ExtraReportClassManager;
@ -101,7 +101,7 @@ public class MobileParamSettingPane extends BasicPane {
MobileParamUIProvider[] mobileParamUIProviders = getMobileParamUIProviders();
for (int i = 0; i < mobileParamUIProviders.length; i++) {
MobileParamUIProvider provider = mobileParamUIProviders[i];
if (ComparatorUtils.equals(mobileParamStyle.disPlayName(), provider.displayName())) {
if (ComparatorUtils.equals(mobileParamStyle.displayName(), provider.displayName())) {
String displayName = provider.displayName();
paramStyleList.setSelectedIndex(i);
// 如果是兼容空类型 无须填充面板
@ -136,9 +136,11 @@ public class MobileParamSettingPane extends BasicPane {
private MobileParamUIProvider[] getMobileParamUIProviders() {
Set<MobileParamUIProvider> paramUIProviders = ExtraDesignClassManager.getInstance().getArray(MobileParamUIProvider.XML_TAG);
Set<MobileParamUIProvider> otherParamUIProviders = MobileStyleProviderManager.getArray(MobileParamUIProvider.XML_TAG);
List<MobileParamUIProvider> result = new ArrayList<>();
result.add(new DefaultMobileParamUIProvider());
result.addAll(paramUIProviders);
result.addAll(otherParamUIProviders);
Set<String> nameSets = paramUIProviders.stream().map(MobileParamUIProvider::displayName).collect(Collectors.toSet());
// 兼容老接口
Set<MobileParamStyleProvider> paramStyleProviders = ExtraReportClassManager.getInstance().getArray(MobileParamStyleProvider.MARK_STRING);

304
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/combo/SimpleComboPane.java

@ -0,0 +1,304 @@
package com.fr.design.mainframe.mobile.ui.combo;
import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane;
import com.fr.design.mainframe.mobile.utils.DesignerUtils;
import com.fr.design.mainframe.mobile.utils.FontConfigPane;
import com.fr.design.mainframe.mobile.utils.IconConfigPane;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.form.ui.Widget;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.form.ui.mobile.combo.SimpleComboStyle;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public class SimpleComboPane extends MobileStyleCustomDefinePane {
private JPanel scrollPanel;
private UIComboBox custom;
private JPanel centerPane;
private FontConfigPane labelFontPane;
private FontConfigPane valueFontPane;
private IconConfigPane expandIconPane;
private IconConfigPane unexpandIconPane;
private NewColorSelectBox background;
private LineComboBox borderType;
private NewColorSelectBox borderColor;
private UISpinner borderRadius;
private UIRadioButton fillButton;
private UIRadioButton customButton;
private UISpinner widthSpinner;
private UIRadioButton floatFillButton;
private UIRadioButton floatSameWidthButton;
public SimpleComboPane(Widget widget) {
super(widget);
}
@Override
protected JPanel createPreviewPane() {
return null;
}
@Override
protected void init() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.addScrollPane();
this.addStyleSelectPane();
this.addConfigPane();
}
private void addScrollPane() {
scrollPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
BasicScrollPane basicScrollPane = new AttrScrollPane() {
@Override
protected JPanel createContentPane() {
return scrollPanel;
}
};
this.add(basicScrollPane);
}
private void addStyleSelectPane() {
UILabel buttonStyleLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Control_Style"));
custom = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-SimpleCombo_Style_Default"), Toolkit.i18nText("Fine-Plugin-SimpleCombo_Style_Custom")});
custom.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20));
custom.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean isCustom = custom.getSelectedIndex() == 1;
centerPane.setVisible(isCustom);
}
});
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
JPanel stylePanel = DesignerUtils.createLeftRightComponentsPane(buttonStyleLabel, custom);
panel.add(stylePanel);
scrollPanel.add(panel, BorderLayout.NORTH);
}
private void addConfigPane() {
centerPane = createCenterPane();
centerPane.setVisible(false);
addLabelNamePane();
addValuePane();
addIconPane();
addWidgetSettingPane();
scrollPanel.add(centerPane, BorderLayout.CENTER);
}
private JPanel createCenterPane() {
return FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
}
private void addLabelNamePane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Label_Name")));
labelFontPane = new FontConfigPane();
JPanel fontPanel = createFontPane(labelFontPane);
centerPane.add(fontPanel);
}
private void addValuePane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Control_Value")));
valueFontPane = new FontConfigPane();
JPanel fontPanel = createFontPane(valueFontPane);
valueFontPane.setFontColor(new Color(153, 153, 153));
centerPane.add(fontPanel);
}
private JPanel createFontPane(FontConfigPane fontConfigPane) {
UILabel fontLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Character"));
JPanel fontPanel = DesignerUtils.createLeftRightComponentsPane(fontLabel, fontConfigPane);
return fontPanel;
}
private void addIconPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Arrow")));
UILabel tipLabel = new UILabel();
tipLabel.setFont(new Font(tipLabel.getName(), Font.PLAIN, 10));
tipLabel.setSize(470, 40);
tipLabel.setText(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Tips"));
tipLabel.setForeground(Color.decode("#9B9B9B"));
centerPane.add(tipLabel);
UILabel expandLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Expand_Icon"));
UILabel unexpandLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Collapse_Icon"));
expandIconPane = new IconConfigPane();
unexpandIconPane = new IconConfigPane();
JPanel expandPane = DesignerUtils.createLeftRightComponentsPane(expandLabel, expandIconPane);
centerPane.add(expandPane);
JPanel unexpandPane = DesignerUtils.createLeftRightComponentsPane(unexpandLabel, unexpandIconPane);
centerPane.add(unexpandPane);
}
private void addWidgetSettingPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Control_Region")));
background = DesignerUtils.createNormalColorSelectBox(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
borderType = new LineComboBox(DesignerUtils.BORDER_LINE_STYLE_ARRAY);
borderType.setSelectedLineStyle(Constants.LINE_THIN);
borderType.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20));
borderColor = DesignerUtils.createNormalColorSelectBox(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
borderRadius = new UISpinner(0, Integer.MAX_VALUE, 1, 2);
borderRadius.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20));
JComponent[] controlComponents = new JComponent[]{background, borderType, borderColor, borderRadius};
String[] comboBoxNames = new String[]{
Toolkit.i18nText("Fine-Plugin-SimpleCombo_Control_Background"),
Toolkit.i18nText("Fine-Plugin-SimpleCombo_Control_Border"),
Toolkit.i18nText("Fine-Plugin-SimpleCombo_Border_Color"),
Toolkit.i18nText("Fine-Plugin-SimpleCombo_Radius"),
};
Component[][] components = new Component[4][];
for (int i = 0; i < 4; i++) {
UILabel label = DesignerUtils.createConfigLabel(comboBoxNames[i]);
components[i] = new Component[]{label, controlComponents[i]};
}
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p, p, };
double[] columnSize = {p, p};
JPanel controlPanel = TableLayoutHelper.createCommonTableLayoutPane(components, rowSize, columnSize, 10);
centerPane.add(controlPanel);
fillButton = new UIRadioButton(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Horizontal_Fill"));
fillButton.setSelected(true);
customButton = new UIRadioButton(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Custom_Width"));
ActionListener listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
widthSpinner.setVisible(customButton.isSelected());
}
};
fillButton.addActionListener(listener);
customButton.addActionListener(listener);
ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(fillButton);
buttonGroup.add(customButton);
widthSpinner = new UISpinner(1, Integer.MAX_VALUE, 1, 200);
widthSpinner.setPreferredSize(new Dimension(78, 20));
widthSpinner.setVisible(false);
UILabel widthLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Width"));
JPanel buttonsPane = createButtonPane();
buttonsPane.add(fillButton);
buttonsPane.add(customButton);
JPanel widthSetting = DesignerUtils.createLeftRightComponentsPane(widthLabel, buttonsPane, widthSpinner);
centerPane.add(widthSetting);
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Floating_Layer")));
UILabel floatLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Width"));
floatFillButton = new UIRadioButton(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Horizontal_Fill"));
floatFillButton.setSelected(true);
floatSameWidthButton = new UIRadioButton(Toolkit.i18nText("Fine-Plugin-SimpleCombo_Follow_Control"));
ButtonGroup floatButtonGroup = new ButtonGroup();
floatButtonGroup.add(floatFillButton);
floatButtonGroup.add(floatSameWidthButton);
JPanel floatButtonPane = createButtonPane();
floatButtonPane.add(floatFillButton);
floatButtonPane.add(floatSameWidthButton);
JPanel floatSetting = DesignerUtils.createLeftRightComponentsPane(floatLabel, floatFillButton, floatSameWidthButton);
centerPane.add(floatSetting);
}
private JPanel createButtonPane() {
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new GridLayout(0, 2, 14, 0));
buttonPane.setPreferredSize(new Dimension(220, 20));
return buttonPane;
}
@Override
public void populateBean(MobileStyle ob) {
SimpleComboStyle mobileStyle = (SimpleComboStyle) ob;
custom.setSelectedIndex(mobileStyle.isCustom() ? 1 : 0);
expandIconPane.populate(mobileStyle.getExpandIcon());
unexpandIconPane.populate(mobileStyle.getUnexpandIcon());
if (mobileStyle.getLabelFont() != null) {
labelFontPane.populate(mobileStyle.getLabelFont());
}
if (mobileStyle.getValueFont() != null) {
valueFontPane.populate(mobileStyle.getValueFont());
}
if (mobileStyle.getBackgroundColor() != null) {
background.setSelectObject(mobileStyle.getBackgroundColor());
}
if (mobileStyle.getBorderColor() != null) {
borderColor.setSelectObject(mobileStyle.getBorderColor());
}
borderType.setSelectedLineStyle(mobileStyle.getBorderType());
borderRadius.setValue(mobileStyle.getBorderRadius());
if (mobileStyle.isCustomWidth()) {
fillButton.setSelected(false);
customButton.setSelected(true);
widthSpinner.setVisible(true);
widthSpinner.setValue(mobileStyle.getWidth());
} else {
fillButton.setSelected(true);
customButton.setSelected(false);
widthSpinner.setVisible(false);
}
if (mobileStyle.isFloatWidthFollow()) {
floatFillButton.setSelected(false);
floatSameWidthButton.setSelected(true);
} else {
floatFillButton.setSelected(true);
floatSameWidthButton.setSelected(false);
}
}
@Override
public MobileStyle updateBean() {
SimpleComboStyle mobileStyle = (SimpleComboStyle) this.widget.getMobileStyle();
mobileStyle.setCustom(custom.getSelectedIndex() == 1);
mobileStyle.setExpandIcon(expandIconPane.update());
mobileStyle.setUnexpandIcon(unexpandIconPane.update());
mobileStyle.setLabelFont(labelFontPane.update());
mobileStyle.setValueFont(valueFontPane.update());
mobileStyle.setBackgroundColor(background.getSelectObject());
mobileStyle.setBorderColor(borderColor.getSelectObject());
mobileStyle.setBorderType(borderType.getSelectedLineStyle());
mobileStyle.setBorderRadius(borderRadius.getValue());
mobileStyle.setCustomWidth(customButton.isSelected());
mobileStyle.setWidth(widthSpinner.getValue());
mobileStyle.setFloatWidthFollow(floatSameWidthButton.isSelected());
return mobileStyle;
}
@Override
protected String title4PopupWindow() {
return null;
}
}

272
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/date/NavigationCustomDefinePane.java

@ -0,0 +1,272 @@
package com.fr.design.mainframe.mobile.ui.date;
import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane;
import com.fr.design.mainframe.mobile.utils.DesignerUtils;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.form.ui.Widget;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.form.ui.mobile.date.NavigationMobileStyle;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public class NavigationCustomDefinePane extends MobileStyleCustomDefinePane {
private JPanel scrollPanel;
private UIComboBox custom;
private JPanel centerPane;
private UIComboBox expand;
private UIComboBox dateFontSize;
private NewColorSelectBox buttonColorSelectBox;
private NewColorSelectBox titleSplitLineColorSelectBox;
private UICheckBox showTitleEditor;
private NewColorSelectBox arrowColorSelectBox;
private UIColorButton mainFontColor;
private UIColorButton specialFontColor;
private Color titleSplitLineDisableColor = new Color(234, 234, 234);
private Color titleSplitLineColor;
public NavigationCustomDefinePane(Widget widget) {
super(widget);
}
@Override
protected JPanel createPreviewPane() {
return null;
}
@Override
protected void init() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.addScrollPane();
this.addStyleSelectPane();
this.addConfigPane();
}
private void addScrollPane() {
scrollPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
BasicScrollPane basicScrollPane = new AttrScrollPane() {
@Override
protected JPanel createContentPane() {
return scrollPanel;
}
};
this.add(basicScrollPane);
}
private void addStyleSelectPane() {
JPanel stylePanel = new JPanel();
stylePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
UILabel buttonStyleLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Style"));
custom = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-Date_Style_Default"), Toolkit.i18nText("Fine-Plugin-Date_Style_Custom")});
custom.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20));
custom.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean isCustom = custom.getSelectedIndex() == 1;
centerPane.setVisible(isCustom);
}
});
stylePanel.add(buttonStyleLabel);
stylePanel.add(custom);
scrollPanel.add(stylePanel, BorderLayout.NORTH);
}
private void addConfigPane() {
centerPane = createCenterPane();
centerPane.setVisible(false);
addExpandPane();
addHeaderLinePane();
addButtonColorPane();
addFontColorPane();
addArrowPane();
scrollPanel.add(centerPane, BorderLayout.CENTER);
custom.setSelectedIndex(1);
}
private void addExpandPane() {
UILabel label = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Status"));
expand = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-Date_Status_Collapse"), Toolkit.i18nText("Fine-Plugin-Date_Status_Expand")});
expand.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20));
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
panel.add(label);
panel.add(expand);
centerPane.add(panel);
}
private void addButtonColorPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-Date_Button")));
UILabel label = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Button_Color"));
buttonColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
buttonColorSelectBox.setSelectObject(new Color(31, 173, 229));
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
panel.add(label);
panel.add(buttonColorSelectBox);
centerPane.add(panel);
}
private void addHeaderLinePane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-Date_Title_Line")));
UILabel titleLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_SubTitle_Line"));
showTitleEditor = DesignerUtils.createCheckBox(Toolkit.i18nText("Fine-Plugin-Date_Show_Title_Line"), true);
JPanel headerPanel = new JPanel();
headerPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
headerPanel.add(titleLabel);
headerPanel.add(showTitleEditor);
centerPane.add(headerPanel);
final UILabel splitLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Title_Split_Line_Color"));
titleSplitLineColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if(showTitleEditor.isSelected()) {
titleSplitLineColor = titleSplitLineColorSelectBox.getSelectObject();
}
}
});
titleSplitLineColorSelectBox.setSelectObject(new Color(234, 234, 234));
final JPanel splitLineColorPanel = new JPanel();
splitLineColorPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
splitLineColorPanel.add(splitLabel);
splitLineColorPanel.add(titleSplitLineColorSelectBox);
showTitleEditor.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
if(showTitleEditor.isSelected()) {
titleSplitLineColorSelectBox.setSelectObject(titleSplitLineColor);
} else {
titleSplitLineColorSelectBox.setSelectObject(titleSplitLineDisableColor);
}
titleSplitLineColorSelectBox.setEnabled(showTitleEditor.isSelected());
splitLabel.setEnabled(showTitleEditor.isSelected());
}
});
centerPane.add(splitLineColorPanel);
}
private void addFontColorPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-Date_Font")));
UILabel mainLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Font_Main"));
mainFontColor = new UIColorButton();
mainFontColor.setColor(new Color(51, 51, 51));
mainFontColor.setPreferredSize(new Dimension(20, 20));
UILabel specialLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Font_Special"));
specialFontColor = new UIColorButton();
specialFontColor.setColor(new Color(255, 148, 84));
specialFontColor.setPreferredSize(new Dimension(20, 20));
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p};
double[] columnSize = {p, p};
JPanel panel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][] {
{mainLabel, mainFontColor},
{specialLabel, specialFontColor}
}, rowSize, columnSize, 10);
centerPane.add(panel);
UILabel fontSizeLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Font_Size"));
dateFontSize = new UIComboBox(new Integer[]{12, 13, 14, 15, 16, 17, 18});
dateFontSize.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20));
dateFontSize.setSelectedItem(14);
JPanel fontPanel = new JPanel();
fontPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
fontPanel.add(fontSizeLabel);
fontPanel.add(dateFontSize);
centerPane.add(fontPanel);
}
private void addArrowPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-Date_Arrow")));
UILabel label = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Arrow_Color"));
arrowColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
arrowColorSelectBox.setSelectObject(new Color(234, 234, 234));
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
panel.add(label);
panel.add(arrowColorSelectBox );
centerPane.add(panel);
}
private JPanel createCenterPane() {
return FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
}
@Override
public void populateBean(MobileStyle ob) {
NavigationMobileStyle mobileStyle = (NavigationMobileStyle) ob;
custom.setSelectedIndex(mobileStyle.isCustom() ? 1 : 0);
expand.setSelectedIndex(mobileStyle.isExpand() ? 1 : 0);
buttonColorSelectBox.setSelectObject(mobileStyle.getButtonBackgroundColor());
mainFontColor.setColor(mobileStyle.getMainFontColor());
specialFontColor.setColor(mobileStyle.getSpecialFontColor());
showTitleEditor.setSelected(mobileStyle.isShowTitleLine());
if(mobileStyle.isShowTitleLine()) {
titleSplitLineColorSelectBox.setSelectObject(mobileStyle.getTitleSplitLineColor());
} else {
titleSplitLineColorSelectBox.setSelectObject(titleSplitLineDisableColor);
titleSplitLineColor = mobileStyle.getTitleSplitLineColor();
}
dateFontSize.setSelectedItem(mobileStyle.getDateFontSize());
arrowColorSelectBox.setSelectObject(mobileStyle.getArrowColor());
}
@Override
public MobileStyle updateBean() {
NavigationMobileStyle mobileStyle = (NavigationMobileStyle)this.widget.getMobileStyle();
mobileStyle.setCustom(custom.getSelectedIndex() == 1);
mobileStyle.setExpand(expand.getSelectedIndex() == 1);
mobileStyle.setButtonBackgroundColor(buttonColorSelectBox.getSelectObject());
mobileStyle.setMainFontColor(mainFontColor.getColor());
mobileStyle.setSpecialFontColor(specialFontColor.getColor());
mobileStyle.setShowTitleLine(showTitleEditor.isSelected());
if(showTitleEditor.isSelected()) {
mobileStyle.setTitleSplitLineColor(titleSplitLineColorSelectBox.getSelectObject());
} else {
mobileStyle.setTitleSplitLineColor(titleSplitLineColor);
}
mobileStyle.setDateFontSize(Integer.parseInt(dateFontSize.getSelectedItem().toString()));
mobileStyle.setArrowColor(arrowColorSelectBox.getSelectObject());
return mobileStyle;
}
@Override
protected String title4PopupWindow() {
return null;
}
}

230
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/date/SimpleCustomDefinePane.java

@ -0,0 +1,230 @@
package com.fr.design.mainframe.mobile.ui.date;
import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane;
import com.fr.design.mainframe.mobile.utils.DesignerUtils;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.form.ui.Widget;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.form.ui.mobile.date.SimpleMobileStyle;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public class SimpleCustomDefinePane extends MobileStyleCustomDefinePane {
private JPanel scrollPanel;
private UIComboBox custom;
private JPanel centerPane;
private UIComboBox expand;
private UIComboBox dateFontSize;
private NewColorSelectBox buttonColorSelectBox;
private NewColorSelectBox titleSplitLineColorSelectBox;
private NewColorSelectBox arrowColorSelectBox;
private UIColorButton mainFontColor;
private UIColorButton specialFontColor;
public SimpleCustomDefinePane(Widget widget) {
super(widget);
}
@Override
protected JPanel createPreviewPane() {
return null;
}
@Override
protected void init() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.addScrollPane();
this.addStyleSelectPane();
this.addConfigPane();
}
private void addScrollPane() {
scrollPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
BasicScrollPane basicScrollPane = new AttrScrollPane() {
@Override
protected JPanel createContentPane() {
return scrollPanel;
}
};
this.add(basicScrollPane);
}
private void addStyleSelectPane() {
JPanel stylePanel = new JPanel();
stylePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
UILabel buttonStyleLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Style"));
custom = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-Date_Style_Default"),
Toolkit.i18nText("Fine-Plugin-Date_Style_Custom")});
custom.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20));
custom.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean isCustom = custom.getSelectedIndex() == 1;
centerPane.setVisible(isCustom);
}
});
stylePanel.add(buttonStyleLabel);
stylePanel.add(custom);
scrollPanel.add(stylePanel, BorderLayout.NORTH);
}
private void addConfigPane() {
centerPane = createCenterPane();
centerPane.setVisible(false);
addExpandPane();
addHeaderLinePane();
addButtonColorPane();
addFontColorPane();
addArrowPane();
scrollPanel.add(centerPane, BorderLayout.CENTER);
custom.setSelectedIndex(1);
}
private void addExpandPane() {
UILabel label = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Status"));
expand = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-Date_Status_Collapse"), Toolkit.i18nText("Fine-Plugin-Date_Status_Expand")});
expand.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20));
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
panel.add(label);
panel.add(expand);
centerPane.add(panel);
}
private void addHeaderLinePane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-Date_Title_Line")));
UILabel label = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Title_Split_Line_Color"));
titleSplitLineColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
titleSplitLineColorSelectBox.setSelectObject(new Color(234, 234, 234));
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
panel.add(label);
panel.add(titleSplitLineColorSelectBox);
centerPane.add(panel);
}
private void addButtonColorPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-Date_Button")));
UILabel label = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Button_Color"));
buttonColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
buttonColorSelectBox.setSelectObject(new Color(31, 173, 229));
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
panel.add(label);
panel.add(buttonColorSelectBox);
centerPane.add(panel);
}
private void addFontColorPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-Date_Font")));
UILabel mainLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Font_Main"));
mainFontColor = new UIColorButton();
mainFontColor.setColor(new Color(51, 51, 51));
mainFontColor.setPreferredSize(new Dimension(20, 20));
UILabel specialLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Font_Special"));
specialFontColor = new UIColorButton();
specialFontColor.setColor(new Color(255, 148, 84));
specialFontColor.setPreferredSize(new Dimension(20, 20));
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p};
double[] columnSize = {p, p};
JPanel panel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][] {
{mainLabel, mainFontColor},
{specialLabel, specialFontColor}
}, rowSize, columnSize, 10);
centerPane.add(panel);
UILabel fontSizeLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Font_Size"));
dateFontSize = new UIComboBox(new Integer[]{12, 13, 14, 15, 16, 17, 18});
dateFontSize.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20));
dateFontSize.setSelectedItem(14);
JPanel fontPanel = new JPanel();
fontPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
fontPanel.add(fontSizeLabel);
fontPanel.add(dateFontSize);
centerPane.add(fontPanel);
}
private void addArrowPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-Date_Arrow")));
UILabel label = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-Date_Arrow_Color"));
arrowColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
arrowColorSelectBox.setSelectObject(new Color(234, 234, 234));
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
panel.add(label);
panel.add(arrowColorSelectBox );
centerPane.add(panel);
}
private JPanel createCenterPane() {
return FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
}
@Override
public void populateBean(MobileStyle ob) {
SimpleMobileStyle mobileStyle = (SimpleMobileStyle) ob;
custom.setSelectedIndex(mobileStyle.isCustom() ? 1 : 0);
expand.setSelectedIndex(mobileStyle.isExpand() ? 1 : 0);
buttonColorSelectBox.setSelectObject(mobileStyle.getButtonBackgroundColor());
mainFontColor.setColor(mobileStyle.getMainFontColor());
specialFontColor.setColor(mobileStyle.getSpecialFontColor());
titleSplitLineColorSelectBox.setSelectObject(mobileStyle.getTitleSplitLineColor());
dateFontSize.setSelectedItem(mobileStyle.getDateFontSize());
arrowColorSelectBox.setSelectObject(mobileStyle.getArrowColor());
}
@Override
public MobileStyle updateBean() {
SimpleMobileStyle mobileStyle = (SimpleMobileStyle)this.widget.getMobileStyle();
mobileStyle.setCustom(custom.getSelectedIndex() == 1);
mobileStyle.setExpand(expand.getSelectedIndex() == 1);
mobileStyle.setButtonBackgroundColor(buttonColorSelectBox.getSelectObject());
mobileStyle.setMainFontColor(mainFontColor.getColor());
mobileStyle.setSpecialFontColor(specialFontColor.getColor());
mobileStyle.setTitleSplitLineColor(titleSplitLineColorSelectBox.getSelectObject());
mobileStyle.setDateFontSize(Integer.parseInt(dateFontSize.getSelectedItem().toString()));
mobileStyle.setArrowColor(arrowColorSelectBox.getSelectObject());
return mobileStyle;
}
@Override
protected String title4PopupWindow() {
return null;
}
}

267
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/date/SimpleDateCustomDefinePane.java

@ -0,0 +1,267 @@
package com.fr.design.mainframe.mobile.ui.date;
import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane;
import com.fr.design.mainframe.mobile.utils.DesignerUtils;
import com.fr.design.mainframe.mobile.utils.FontConfigPane;
import com.fr.design.mainframe.mobile.utils.IconConfigPane;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.form.ui.Widget;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.form.ui.mobile.date.ControlStyle;
import com.fr.form.ui.mobile.date.SimpleDateMobileStyle;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public class SimpleDateCustomDefinePane extends MobileStyleCustomDefinePane {
private JPanel scrollPanel;
private UIComboBox custom;
private JPanel centerPane;
private FontConfigPane labelFontConfigPane;
private FontConfigPane controlValueConfigPane;
private NewColorSelectBox controlBackground;
private LineComboBox controlBorder;
private NewColorSelectBox controlBorderColor;
private UISpinner controlWidgetRadius;
private UISpinner widthSpinner;
private UIRadioButton fillButton;
private UIRadioButton customButton;
private IconConfigPane iconConfigPane;
public SimpleDateCustomDefinePane(Widget widget) {
super(widget);
}
@Override
protected JPanel createPreviewPane() {
return null;
}
@Override
protected void init() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.addScrollPane();
this.addStyleSelectPane();
this.addConfigPane();
}
private void addScrollPane() {
scrollPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(new AttrScrollPane() {
@Override
protected JPanel createContentPane() {
return scrollPanel;
}
});
}
private void addStyleSelectPane() {
JPanel stylePanel = new JPanel();
stylePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
UILabel buttonStyleLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-SimpleDate_Control_Style"));
custom = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-SimpleDate_Style_Default"),
Toolkit.i18nText("Fine-Plugin-SimpleDate_Style_Custom")});
custom.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20));
custom.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean isCustom = custom.getSelectedIndex() == 1;
centerPane.setVisible(isCustom);
}
});
stylePanel.add(buttonStyleLabel);
stylePanel.add(custom);
scrollPanel.add(stylePanel, BorderLayout.NORTH);
}
private void addConfigPane() {
centerPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
centerPane.setVisible(false);
addFontConfigPane();
addIconConfigPane();
addControlConfigPane();
scrollPanel.add(centerPane, BorderLayout.CENTER);
}
private void addControlConfigPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-SimpleDate_Control_Region")));
controlBackground = DesignerUtils.createNormalColorSelectBox(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
controlBorder = new LineComboBox(DesignerUtils.BORDER_LINE_STYLE_ARRAY);
controlBorder.setSelectedLineStyle(Constants.LINE_THIN);
controlBorder.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20));
controlBorderColor = DesignerUtils.createNormalColorSelectBox(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
controlWidgetRadius = new UISpinner(0, Integer.MAX_VALUE, 1, 2);
controlWidgetRadius.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20));
JComponent[] controlComponents = new JComponent[]{controlBackground, controlBorder, controlBorderColor, controlWidgetRadius};
String[] comboBoxNames = new String[]{
Toolkit.i18nText("Fine-Plugin-SimpleDate_Control_Background"),
Toolkit.i18nText("Fine-Plugin-SimpleDate_Control_Border"),
Toolkit.i18nText("Fine-Plugin-SimpleDate_Border_Color"),
Toolkit.i18nText("Fine-Plugin-SimpleDate_Radius")
};
Component[][] components = new Component[4][];
for (int i = 0; i < 4; i++) {
UILabel label = DesignerUtils.createConfigLabel(comboBoxNames[i]);
components[i] = new Component[]{label, controlComponents[i]};
}
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p, p};
double[] columnSize = {p, p};
JPanel controlPanel = TableLayoutHelper.createCommonTableLayoutPane(components, rowSize, columnSize, 10);
centerPane.add(controlPanel);
this.fillButton = new UIRadioButton(Toolkit.i18nText("Fine-Plugin-SimpleDate_Horizontal_Fill"));
this.customButton = new UIRadioButton(Toolkit.i18nText("Fine-Plugin-SimpleDate_Width_Custom"));
ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(fillButton);
buttonGroup.add(customButton);
JPanel panel = new JPanel();
panel.add(fillButton);
panel.add(customButton);
panel.setLayout(new GridLayout(0, 2, 14, 0));
panel.setPreferredSize(new Dimension(174, 20));
fillButton.setSelected(true);
ActionListener listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
widthSpinner.setVisible(customButton.isSelected());
}
};
fillButton.addActionListener(listener);
customButton.addActionListener(listener);
UILabel label = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-SimpleDate_Width"));
widthSpinner = new UISpinner(1, Integer.MAX_VALUE, 1, 200);
widthSpinner.setPreferredSize(new Dimension(78, 20));
widthSpinner.setVisible(false);
centerPane.add(DesignerUtils.createLeftRightComponentsPane(label, panel, widthSpinner));
}
private void addFontConfigPane() {
String[] titleSplitLineNames = new String[]{
Toolkit.i18nText("Fine-Plugin-SimpleDate_Label_Name"),
Toolkit.i18nText("Fine-Plugin-SimpleDate_Control_Value")
};
labelFontConfigPane = new FontConfigPane();
controlValueConfigPane = new FontConfigPane();
FontConfigPane[] fontConfigPanes = new FontConfigPane[]{labelFontConfigPane, controlValueConfigPane};
for (int i = 0; i < 2; i++) {
centerPane.add(DesignerUtils.createTitleSplitLine(titleSplitLineNames[i]));
UILabel fontLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-SimpleDate_Character"));
JPanel fontPanel = DesignerUtils.createLeftRightComponentsPane(fontLabel, fontConfigPanes[i]);
centerPane.add(fontPanel);
}
}
private void addIconConfigPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-SimpleDate_Icon")));
UILabel tipLabel = new UILabel();
tipLabel.setFont(new Font(tipLabel.getName(), Font.PLAIN, 10));
tipLabel.setSize(470, 40);
tipLabel.setText(Toolkit.i18nText("Fine-Plugin-SimpleDate_Tip"));
tipLabel.setForeground(Color.decode("#9B9B9B"));
centerPane.add(tipLabel);
JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
iconConfigPane = new IconConfigPane();
centerPane.add(iconConfigPane);
}
@Override
public void populateBean(MobileStyle mobileStyle) {
SimpleDateMobileStyle simpleDateMobileStyle = (SimpleDateMobileStyle) mobileStyle;
custom.setSelectedIndex(simpleDateMobileStyle.isCustom() ? 1 : 0);
iconConfigPane.populate(simpleDateMobileStyle.getIconValue());
labelFontConfigPane.populate(simpleDateMobileStyle.getLabelFontStyle());
controlValueConfigPane.populate(simpleDateMobileStyle.getValueFontStyle());
ControlStyle controlStyle = simpleDateMobileStyle.getControlStyle();
if (controlStyle != null) {
controlBackground.setSelectObject(controlStyle.getBackground());
controlBorderColor.setSelectObject(controlStyle.getBorderColor());
controlBorder.setSelectedLineStyle(controlStyle.getBorderType());
controlWidgetRadius.setValue(controlStyle.getBorderRadius());
if (controlStyle.isCustomWidth()) {
widthSpinner.setVisible(true);
widthSpinner.setValue(controlStyle.getWidth());
customButton.setSelected(true);
fillButton.setSelected(false);
} else {
widthSpinner.setVisible(false);
customButton.setSelected(false);
fillButton.setSelected(true);
}
}
}
@Override
public MobileStyle updateBean() {
SimpleDateMobileStyle simpleDateMobileStyle = (SimpleDateMobileStyle) this.widget.getMobileStyle();
simpleDateMobileStyle.setCustom(custom.getSelectedIndex() == 1);
simpleDateMobileStyle.setIconValue(iconConfigPane.update());
simpleDateMobileStyle.setLabelFontStyle(labelFontConfigPane.update());
simpleDateMobileStyle.setValueFontStyle(controlValueConfigPane.update());
ControlStyle controlStyle = new ControlStyle();
controlStyle.setBackground(controlBackground.getSelectObject());
controlStyle.setBorderColor(controlBorderColor.getSelectObject());
controlStyle.setBorderType(controlBorder.getSelectedLineStyle());
controlStyle.setBorderRadius(controlWidgetRadius.getValue());
controlStyle.setCustomWidth(customButton.isSelected());
controlStyle.setWidth(widthSpinner.getValue());
simpleDateMobileStyle.setControlStyle(controlStyle);
return simpleDateMobileStyle;
}
@Override
protected String title4PopupWindow() {
return null;
}
}

310
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/CapsuleCustomDefinePane.java

@ -0,0 +1,310 @@
package com.fr.design.mainframe.mobile.ui.radiogroup;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.dialog.BasicScrollPane;
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.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane;
import com.fr.design.mainframe.mobile.utils.DesignerUtils;
import com.fr.design.mainframe.mobile.utils.FontConfigPane;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.form.ui.Widget;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.form.ui.mobile.radiogroup.CapsuleMobileStyle;
import com.fr.general.FRFont;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public class CapsuleCustomDefinePane extends MobileStyleCustomDefinePane {
private JPanel scrollPanel;
private UIComboBox custom;
private JPanel centerPane;
private UISpinner leftSpinner;
private UISpinner rightSpinner;
private UISpinner topSpinner;
private UISpinner bottomSpinner;
private JRadioButton leftAlignRadioButton;
private JRadioButton centerAlignRadioButton;
private NewColorSelectBox initialColorSelectBox;
private NewColorSelectBox selectedColorSelectBox;
private LineComboBox borderLineCombo;
private NewColorSelectBox initialBorderColor;
private NewColorSelectBox selectedBorderColor;
private UISpinner borderRadiusSpinner;
private FontConfigPane initialFontConfPane;
private UIColorButton selectedFontColor;
public CapsuleCustomDefinePane(Widget widget) {
super(widget);
}
@Override
protected JPanel createPreviewPane() {
return null;
}
@Override
protected void init() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.addScrollPane();
this.addStyleSelectPane();
this.addConfigPane();
}
private void addScrollPane() {
scrollPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
BasicScrollPane basicScrollPane = new AttrScrollPane() {
@Override
protected JPanel createContentPane() {
return scrollPanel;
}
};
this.add(basicScrollPane);
}
private void addStyleSelectPane() {
JPanel stylePanel = new JPanel();
stylePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
UILabel buttonStyleLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Style"));
custom = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-RadioGroup_Style_Default"),
Toolkit.i18nText("Fine-Plugin-RadioGroup_Style_Custom")});
custom.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20));
custom.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean isCustom = custom.getSelectedIndex() == 1;
centerPane.setVisible(isCustom);
}
});
stylePanel.add(buttonStyleLabel);
stylePanel.add(custom);
scrollPanel.add(stylePanel, BorderLayout.NORTH);
}
private void addConfigPane() {
centerPane = createCenterPane();
centerPane.setVisible(false);
addPaddingPane();
addBackgroundPane();
addBorderPane();
addFontPane();
scrollPanel.add(centerPane, BorderLayout.CENTER);
custom.setSelectedIndex(1);
}
private JPanel createCenterPane() {
return FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
}
private void addPaddingPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Layout")));
UILabel paddingHintLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Button_Padding"));
UILabel emptyHintLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText(""));
UILabel buttonAlignHintLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Alignment"));
UILabel leftLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Left"));
leftSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultHorizontalPadding);
UILabel rightLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Right"));
rightSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultHorizontalPadding);
UILabel topLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Top"));
topSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultVerticalPadding);
UILabel bottomLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Bottom"));
bottomSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultVerticalPadding);
leftAlignRadioButton = new JRadioButton(Toolkit.i18nText("Fine-Plugin-RadioGroup_Alignment_Left"), true);
centerAlignRadioButton = new JRadioButton(Toolkit.i18nText("Fine-Plugin-RadioGroup_Alignment_Center"), false);
JPanel leftSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{leftLabel, leftSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL);
JPanel rightSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{rightLabel, rightSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL);
JPanel topSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{topLabel, topSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL);
JPanel bottomSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{bottomLabel, bottomSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL);
JPanel vPaddingSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{topSpinnerPanel, bottomSpinnerPanel}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, LayoutConstants.VGAP_SMALL);
JPanel hPaddingSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{leftSpinnerPanel, rightSpinnerPanel}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, LayoutConstants.VGAP_SMALL);
JPanel layoutPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{leftAlignRadioButton, centerAlignRadioButton}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, LayoutConstants.VGAP_SMALL);
ButtonGroup layoutRadioButtonGroup = new ButtonGroup();
layoutRadioButtonGroup.add(leftAlignRadioButton);
layoutRadioButtonGroup.add(centerAlignRadioButton);
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p};
double[] columnSize = {p, p};
JPanel paddingPanel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{
{paddingHintLabel, vPaddingSpinnerPanel},
{emptyHintLabel, hPaddingSpinnerPanel},
{buttonAlignHintLabel, layoutPanel},
}, rowSize, columnSize, 10);
centerPane.add(paddingPanel);
}
private void addBackgroundPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Background")));
UILabel initialColorLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Background_Init"));
initialColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
initialColorSelectBox.setSelectObject(new Color(244, 244, 244));
JPanel initialColorSelectPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initialColorLabel, initialColorSelectBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
centerPane.add(initialColorSelectPane);
UILabel selectedColorLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Background_Select"));
selectedColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
selectedColorSelectBox.setSelectObject(new Color(31, 173, 229));
JPanel selectedColorSelectPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectedColorLabel, selectedColorSelectBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
centerPane.add(selectedColorSelectPane);
}
private void addBorderPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border")));
UILabel borderTypeLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border_Line"));
borderLineCombo = new LineComboBox(DesignerUtils.BORDER_LINE_STYLE_ARRAY);
borderLineCombo.setSelectedLineStyle(Constants.LINE_THIN);
UILabel initialColorLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border_Init_Color"));
initialBorderColor = DesignerUtils.createNormalColorSelectBox(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
initialBorderColor.setSelectObject(new Color(244, 244, 244));
UILabel selectedColorLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border_Select_Color"));
selectedBorderColor = DesignerUtils.createNormalColorSelectBox(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
selectedBorderColor.setSelectObject(new Color(31, 173, 229));
UILabel radiusLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border_Radius"));
borderRadiusSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, 20);
borderRadiusSpinner.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20));
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p, p};
double[] columnSize = {p, p};
JPanel borderPanel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{
{borderTypeLabel, borderLineCombo},
{initialColorLabel, initialBorderColor},
{selectedColorLabel, selectedBorderColor},
{radiusLabel, borderRadiusSpinner}
}, rowSize, columnSize, 10);
centerPane.add(borderPanel);
}
private void addFontPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font")));
UILabel initialFontLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font_init"));
initialFontConfPane = new FontConfigPane();
initialFontConfPane.setFontColor(new Color(204, 204, 204));
JPanel fontPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initialFontLabel, initialFontConfPane}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
centerPane.add(fontPanel);
UILabel selectedFontLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font_Select"));
selectedFontColor = new UIColorButton();
selectedFontColor.setColor(Color.WHITE);
selectedFontColor.setPreferredSize(new Dimension(20, 20));
JPanel selectFontColorPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectedFontLabel, selectedFontColor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
centerPane.add(selectFontColorPanel);
}
@Override
public void populateBean(MobileStyle ob) {
CapsuleMobileStyle mobileStyle = (CapsuleMobileStyle) ob;
custom.setSelectedIndex(mobileStyle.isCustom() ? 1 : 0);
leftSpinner.setValue(mobileStyle.getLeftPadding());
rightSpinner.setValue(mobileStyle.getRightPadding());
topSpinner.setValue(mobileStyle.getTopPadding());
bottomSpinner.setValue(mobileStyle.getBottomPadding());
leftAlignRadioButton.setSelected(mobileStyle.getButtonAlign() == DesignerUtils.kAlignLeft);
centerAlignRadioButton.setSelected(mobileStyle.getButtonAlign() == DesignerUtils.kAlignCenter);
initialColorSelectBox.setSelectObject(mobileStyle.getInitialBackgroundColor());
selectedColorSelectBox.setSelectObject(mobileStyle.getSelectedBackgroundColor());
borderLineCombo.setSelectedLineStyle(mobileStyle.getBorderType());
initialBorderColor.setSelectObject(mobileStyle.getInitialBorderColor());
selectedBorderColor.setSelectObject(mobileStyle.getSelectedBorderColor());
borderRadiusSpinner.setValue(mobileStyle.getBorderRadius());
if (mobileStyle.getInitialFont() != null) {
initialFontConfPane.populate(mobileStyle.getInitialFont());
}
if (mobileStyle.getSelectedFont() != null) {
selectedFontColor.setColor(mobileStyle.getSelectedFont().getForeground());
}
}
@Override
public MobileStyle updateBean() {
CapsuleMobileStyle mobileStyle = (CapsuleMobileStyle) this.widget.getMobileStyle();
mobileStyle.setCustom(custom.getSelectedIndex() == 1);
mobileStyle.setLeftPadding(leftSpinner.getValue());
mobileStyle.setRightPadding(rightSpinner.getValue());
mobileStyle.setTopPadding(topSpinner.getValue());
mobileStyle.setBottomPadding(bottomSpinner.getValue());
mobileStyle.setButtonAlign(leftAlignRadioButton.isSelected() ? DesignerUtils.kAlignLeft : DesignerUtils.kAlignCenter);
mobileStyle.setInitialBackgroundColor(initialColorSelectBox.getSelectObject());
mobileStyle.setSelectedBackgroundColor(selectedColorSelectBox.getSelectObject());
mobileStyle.setBorderType(borderLineCombo.getSelectedLineStyle());
mobileStyle.setInitialBorderColor(initialBorderColor.getSelectObject());
mobileStyle.setSelectedBorderColor(selectedBorderColor.getSelectObject());
mobileStyle.setBorderRadius(borderRadiusSpinner.getValue());
FRFont initialFont = initialFontConfPane.updateFont(null, null, null);
FRFont selectedFont = initialFontConfPane.updateFont(selectedFontColor.getColor(), null, null);
mobileStyle.setInitialFont(initialFont);
mobileStyle.setSelectedFont(selectedFont);
return mobileStyle;
}
@Override
protected String title4PopupWindow() {
return null;
}
}

195
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/IconConfigPane.java

@ -0,0 +1,195 @@
package com.fr.design.mainframe.mobile.ui.radiogroup;
import com.fr.base.IconManager;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.DrawRoutines;
import com.fr.design.web.CustomIconPane;
import com.fr.form.ui.WidgetInfoConfig;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
public class IconConfigPane extends JPanel {
private UIButton editIconButton;
private UIButton deleteIconButton;
private String curIconName;
private IconButton selectIconButton;
private ArrayList<IconButton> iconButtons = new ArrayList<IconButton>();
public IconConfigPane(int count) {
initComp(count);
}
public void initComp(int count) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane();
panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
editIconButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Edit"));
editIconButton.setFont(FRFont.getInstance("Helvetica", Font.PLAIN, 12, Color.decode("#3A383A")));
editIconButton.setPreferredSize(new Dimension(62, 20));
panel.add(editIconButton);
editIconButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final CustomIconPane cip = new CustomIconPane(){
protected String createDescriptionText(){
return Toolkit.i18nText("Fine-Design_Mobile_Custom_Icon_Message");
}
};
BasicDialog editDialog = cip.showWindow(DesignerContext.getDesignerFrame());
editDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
curIconName = cip.update();
setShowIconImage();
IconConfigPane.this.repaint();
}
});
editDialog.setVisible(true);
}
});
editIconButton.setEnabled(false);
deleteIconButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Delete"));
deleteIconButton.setFont(FRFont.getInstance("Helvetica", Font.PLAIN, 12, Color.decode("#3A383A")));
deleteIconButton.setPreferredSize(new Dimension(62, 20));
panel.add(deleteIconButton);
deleteIconButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
selectIconButton.setIconName(StringUtils.EMPTY);
IconConfigPane.this.repaint();
}
});
deleteIconButton.setEnabled(false);
this.add(panel, BorderLayout.CENTER);
JPanel northPane = new JPanel();
northPane.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
for (int i = 0; i < count; i++) {
IconButton iconButton = new IconButton("");
northPane.add(iconButton);
iconButtons.add(iconButton);
}
this.add(northPane, BorderLayout.NORTH);
}
public void setShowIconImage() {
selectIconButton.setIconName(curIconName);
}
public void populate(ArrayList<String> iconArr) {
for (int i = 0; i < iconButtons.size(); i++) {
iconButtons.get(i).setIconName(iconArr.get(i));
}
}
public ArrayList<String> update() {
ArrayList<String> iconNames = new ArrayList<String>();
for (int i = 0; i < iconButtons.size(); i++) {
iconNames.add(iconButtons.get(i).getIconName());
}
return iconNames;
}
private class IconButton extends JToggleButton implements ActionListener {
private String iconName;
private Image iconImage = null;
private static final int ICON_BUTTON_SIZE = 20;
private static final int ICON_X = 2;
private static final int ICON_Y = 2;
public IconButton(String name) {
this.iconName = name;
this.addActionListener(this);
this.setBackground(Color.WHITE);
this.setCursor(new Cursor(Cursor.HAND_CURSOR));
this.iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(name);
}
@Override
public void updateUI() {
setUI(new BasicButtonUI() {
public void paint(Graphics g, JComponent c) {
super.paint(g, c);
}
});
}
protected void paintBorder(Graphics g) {
super.paintBorder(g);
if (ComparatorUtils.equals(this, selectIconButton)) {
DrawRoutines.drawRoundedBorder(
g, Color.decode("#419BF9"), 0, 0, 20, 20);
} else {
DrawRoutines.drawRoundedBorder(
g, Color.decode("#D9DADD"), 0, 0, 20, 20);
}
}
public String getIconName() {
return iconName;
}
public void setIconName(String iconName) {
this.iconName = iconName;
this.iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(iconName);
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
// carl:这里缩放显示 16 × 16
if (iconImage != null) {
g2d.drawImage(iconImage, ICON_X, ICON_Y, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null);
}
}
@Override
public Dimension getPreferredSize() {
return new Dimension(ICON_BUTTON_SIZE, ICON_BUTTON_SIZE);
}
public void actionPerformed(ActionEvent evt) {
selectIconButton = this;
editIconButton.setEnabled(true);
if(StringUtils.isNotEmpty(this.iconName)) {
deleteIconButton.setEnabled(true);
} else {
deleteIconButton.setEnabled(false);
}
IconConfigPane.this.repaint();// repaint
}
@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);
}
}
}
}

242
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/ImageCustomDefinePane.java

@ -0,0 +1,242 @@
package com.fr.design.mainframe.mobile.ui.radiogroup;
import com.fr.base.BaseUtils;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane;
import com.fr.design.mainframe.mobile.utils.DesignerUtils;
import com.fr.design.mainframe.mobile.utils.FontConfigPane;
import com.fr.form.ui.Widget;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.form.ui.mobile.radiogroup.ImageMobileStyle;
import com.fr.general.FRFont;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Arrays;
public class ImageCustomDefinePane extends MobileStyleCustomDefinePane {
private static final Icon[] BOLD_ICONS = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold_white.png")};
private JPanel scrollPanel;
private UIComboBox custom;
private JPanel centerPane;
private UISpinner leftSpinner;
private UISpinner rightSpinner;
private UISpinner topSpinner;
private UISpinner bottomSpinner;
private IconConfigPane initialIconConfigPane;
private IconConfigPane selectedIconConfigPane;
private FontConfigPane initialFontConfPane;
private UIColorButton selectedFontColor;
private UIToggleButton selectedFontBold;
public ImageCustomDefinePane(Widget widget) {
super(widget);
}
@Override
protected JPanel createPreviewPane() {
return null;
}
@Override
protected void init() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.addScrollPane();
this.addStyleSelectPane();
this.addConfigPane();
}
private void addScrollPane() {
scrollPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
BasicScrollPane basicScrollPane = new AttrScrollPane() {
@Override
protected JPanel createContentPane() {
return scrollPanel;
}
};
this.add(basicScrollPane);
}
private void addStyleSelectPane() {
JPanel stylePanel = new JPanel();
stylePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
UILabel buttonStyleLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Style"));
custom = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-RadioGroup_Style_Default"),
Toolkit.i18nText("Fine-Plugin-RadioGroup_Style_Custom")});
custom.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20));
custom.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean isCustom = custom.getSelectedIndex() == 1;
centerPane.setVisible(isCustom);
}
});
stylePanel.add(buttonStyleLabel);
stylePanel.add(custom);
scrollPanel.add(stylePanel, BorderLayout.NORTH);
}
private void addConfigPane() {
centerPane = createCenterPane();
centerPane.setVisible(false);
addPaddingPane();
addIconPane();
addFontPane();
scrollPanel.add(centerPane, BorderLayout.CENTER);
custom.setSelectedIndex(1);
}
private JPanel createCenterPane() {
return FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
}
private void addPaddingPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Layout")));
UILabel paddingHintLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Button_Padding"));
UILabel emptyHintLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText(""));
UILabel leftLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Left"));
leftSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultHorizontalPadding);
UILabel rightLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Right"));
rightSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultHorizontalPadding);
UILabel topLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Top"));
topSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultVerticalPadding);
UILabel bottomLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Bottom"));
bottomSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultVerticalPadding);
JPanel leftSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{leftLabel, leftSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL);
JPanel rightSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{rightLabel, rightSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL);
JPanel topSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{topLabel, topSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL);
JPanel bottomSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{bottomLabel, bottomSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL);
JPanel vPaddingSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{topSpinnerPanel, bottomSpinnerPanel}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, LayoutConstants.VGAP_SMALL);
JPanel hPaddingSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{leftSpinnerPanel, rightSpinnerPanel}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, LayoutConstants.VGAP_SMALL);
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p};
double[] columnSize = {p, p};
JPanel paddingPanel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{
{paddingHintLabel, vPaddingSpinnerPanel},
{emptyHintLabel, hPaddingSpinnerPanel},
}, rowSize, columnSize, 10);
centerPane.add(paddingPanel);
}
private void addIconPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Icon")));
UILabel initialLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Icon_Init"));
UILabel selectedLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Icon_Select"));
initialIconConfigPane = new IconConfigPane(8);
selectedIconConfigPane = new IconConfigPane(8);
JPanel container = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 5);
JPanel initialPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
initialPane.add(initialLabel);
initialPane.add(initialIconConfigPane);
container.add(initialPane);
JPanel selectedPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
selectedPane.add(selectedLabel);
selectedPane.add(selectedIconConfigPane);
container.add(selectedPane);
centerPane.add(container);
}
private void addFontPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font")));
UILabel initialFontLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font_init"));
initialFontConfPane = new FontConfigPane();
initialFontConfPane.setFontColor(new Color(204, 204, 204));
JPanel fontPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initialFontLabel, initialFontConfPane}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
centerPane.add(fontPanel);
UILabel selectedFontLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font_Select"));
selectedFontColor = new UIColorButton();
selectedFontColor.setColor(new Color(31, 173, 229));
selectedFontColor.setPreferredSize(new Dimension(20, 20));
selectedFontBold = new UIToggleButton(BOLD_ICONS, true);
selectedFontBold.setPreferredSize(new Dimension(20, 20));
JPanel selectFontColorPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectedFontLabel, selectedFontColor, selectedFontBold}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
centerPane.add(selectFontColorPanel);
}
@Override
public void populateBean(MobileStyle ob) {
ImageMobileStyle mobileStyle = (ImageMobileStyle) ob;
custom.setSelectedIndex(mobileStyle.isCustom() ? 1 : 0);
leftSpinner.setValue(mobileStyle.getLeftPadding());
rightSpinner.setValue(mobileStyle.getRightPadding());
topSpinner.setValue(mobileStyle.getTopPadding());
bottomSpinner.setValue(mobileStyle.getBottomPadding());
initialIconConfigPane.populate(new ArrayList<>(Arrays.asList(mobileStyle.getInitialIconNames())));
selectedIconConfigPane.populate(new ArrayList<>(Arrays.asList(mobileStyle.getSelectedIconNames())));
if(mobileStyle.getInitialFont() != null) {
initialFontConfPane.populate(mobileStyle.getInitialFont());
}
if(mobileStyle.getSelectedFont() != null) {
selectedFontColor.setColor(mobileStyle.getSelectedFont().getForeground());
selectedFontBold.setSelected(mobileStyle.getSelectedFont().isBold());
}
}
@Override
public MobileStyle updateBean() {
ImageMobileStyle mobileStyle = (ImageMobileStyle)this.widget.getMobileStyle();
mobileStyle.setCustom(custom.getSelectedIndex() == 1);
mobileStyle.setLeftPadding(leftSpinner.getValue());
mobileStyle.setRightPadding(rightSpinner.getValue());
mobileStyle.setTopPadding(topSpinner.getValue());
mobileStyle.setBottomPadding(bottomSpinner.getValue());
ArrayList<String> initialIconNamesList = initialIconConfigPane.update();
ArrayList<String> selectedIconNamesList = selectedIconConfigPane.update();
mobileStyle.setInitialIconNames(initialIconNamesList.toArray(new String[initialIconNamesList.size()]));
mobileStyle.setSelectedIconNames(selectedIconNamesList.toArray(new String[selectedIconNamesList.size()]));
FRFont initialFont = initialFontConfPane.updateFont(null, null, null);
FRFont selectedFont = initialFontConfPane.updateFont(selectedFontColor.getColor(), selectedFontBold.isSelected(), null);
mobileStyle.setInitialFont(initialFont);
mobileStyle.setSelectedFont(selectedFont);
return mobileStyle;
}
@Override
protected String title4PopupWindow() {
return null;
}
}

279
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/radiogroup/UnitedCustomDefinePane.java

@ -0,0 +1,279 @@
package com.fr.design.mainframe.mobile.ui.radiogroup;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.dialog.BasicScrollPane;
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.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane;
import com.fr.design.mainframe.mobile.utils.DesignerUtils;
import com.fr.design.mainframe.mobile.utils.FontConfigPane;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.form.ui.Widget;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.form.ui.mobile.radiogroup.UnitedMobileStyle;
import com.fr.general.FRFont;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public class UnitedCustomDefinePane extends MobileStyleCustomDefinePane {
private JPanel scrollPanel;
private UIComboBox custom;
private JPanel centerPane;
private UISpinner leftSpinner;
private UISpinner rightSpinner;
private UISpinner topSpinner;
private UISpinner bottomSpinner;
private NewColorSelectBox initialColorSelectBox;
private NewColorSelectBox selectedColorSelectBox;
private LineComboBox borderLineCombo;
private NewColorSelectBox borderColor;
private UISpinner borderRadiusSpinner;
private FontConfigPane initialFontConfPane;
private UIColorButton selectedFontColor;
public UnitedCustomDefinePane(Widget widget) {
super(widget);
}
@Override
protected JPanel createPreviewPane() {
return null;
}
@Override
protected void init() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.addScrollPane();
this.addStyleSelectPane();
this.addConfigPane();
}
private void addScrollPane() {
scrollPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
BasicScrollPane basicScrollPane = new AttrScrollPane() {
@Override
protected JPanel createContentPane() {
return scrollPanel;
}
};
this.add(basicScrollPane);
}
private void addStyleSelectPane() {
JPanel stylePanel = new JPanel();
stylePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
UILabel buttonStyleLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Style"));
custom = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Plugin-RadioGroup_Style_Default"),
Toolkit.i18nText("Fine-Plugin-RadioGroup_Style_Custom")});
custom.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20));
custom.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean isCustom = custom.getSelectedIndex() == 1;
centerPane.setVisible(isCustom);
}
});
stylePanel.add(buttonStyleLabel);
stylePanel.add(custom);
scrollPanel.add(stylePanel, BorderLayout.NORTH);
}
private void addConfigPane() {
centerPane = createCenterPane();
centerPane.setVisible(false);
addPaddingPane();
addBackgroundPane();
addBorderPane();
addFontPane();
scrollPanel.add(centerPane, BorderLayout.CENTER);
custom.setSelectedIndex(1);
}
private JPanel createCenterPane() {
return FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
}
private void addPaddingPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Layout")));
UILabel paddingHintLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Button_Padding"));
UILabel emptyHintLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText(""));
UILabel leftLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Left"));
leftSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultHorizontalPadding);
UILabel rightLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Right"));
rightSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultHorizontalPadding);
UILabel topLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Top"));
topSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultVerticalPadding);
UILabel bottomLabel = new UILabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Padding_Bottom"));
bottomSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, DesignerUtils.kDefaultVerticalPadding);
JPanel leftSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{leftLabel, leftSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL);
JPanel rightSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{rightLabel, rightSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL);
JPanel topSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{topLabel, topSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL);
JPanel bottomSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{bottomLabel, bottomSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_SMALL);
JPanel vPaddingSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{topSpinnerPanel, bottomSpinnerPanel}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, LayoutConstants.VGAP_SMALL);
JPanel hPaddingSpinnerPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{leftSpinnerPanel, rightSpinnerPanel}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, LayoutConstants.VGAP_SMALL);
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p};
double[] columnSize = {p, p};
JPanel paddingPanel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][]{
{paddingHintLabel, vPaddingSpinnerPanel},
{emptyHintLabel, hPaddingSpinnerPanel},
}, rowSize, columnSize, 10);
centerPane.add(paddingPanel);
}
private void addBackgroundPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Background")));
UILabel initialColorLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Background_Init"));
initialColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
initialColorSelectBox.setSelectObject(Color.WHITE);
JPanel initialColorSelectPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initialColorLabel, initialColorSelectBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
centerPane.add(initialColorSelectPane);
UILabel selectedColorLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Background_Select"));
selectedColorSelectBox = DesignerUtils.createNormalColorSelectBox(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
selectedColorSelectBox.setSelectObject(new Color(31, 173, 229));
JPanel selectedColorSelectPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectedColorLabel, selectedColorSelectBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
centerPane.add(selectedColorSelectPane);
}
private void addBorderPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border")));
UILabel borderTypeLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border_Line"));
borderLineCombo = new LineComboBox(DesignerUtils.BORDER_LINE_STYLE_ARRAY);
borderLineCombo.setSelectedLineStyle(Constants.LINE_THIN);
UILabel colorLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border_Color"));
borderColor = DesignerUtils.createNormalColorSelectBox(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
borderColor.setSelectObject(new Color(31, 173, 229) );
UILabel radiusLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Border_Radius"));
borderRadiusSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, 2);
borderRadiusSpinner.setPreferredSize(new Dimension(DesignerUtils.NORMAL_COMBO_WIDTH, 20));
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p};
double[] columnSize = {p, p};
JPanel borderPanel = TableLayoutHelper.createCommonTableLayoutPane(new Component[][] {
{borderTypeLabel, borderLineCombo},
{colorLabel, borderColor},
{radiusLabel, borderRadiusSpinner}
}, rowSize, columnSize, 10);
centerPane.add(borderPanel);
}
private void addFontPane() {
centerPane.add(DesignerUtils.createTitleSplitLine(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font")));
UILabel initialFontLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font_init"));
initialFontConfPane = new FontConfigPane();
initialFontConfPane.setFontColor(new Color(31, 173, 229));
JPanel fontPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initialFontLabel, initialFontConfPane}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
centerPane.add(fontPanel);
UILabel selectedFontLabel = DesignerUtils.createConfigLabel(Toolkit.i18nText("Fine-Plugin-RadioGroup_Font_Select"));
selectedFontColor = new UIColorButton();
selectedFontColor.setPreferredSize(new Dimension(20, 20));
selectedFontColor.setColor(Color.WHITE);
JPanel selectFontColorPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectedFontLabel, selectedFontColor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
centerPane.add(selectFontColorPanel);
}
@Override
public void populateBean(MobileStyle ob) {
UnitedMobileStyle mobileStyle = (UnitedMobileStyle) ob;
custom.setSelectedIndex(mobileStyle.isCustom() ? 1 : 0);
leftSpinner.setValue(mobileStyle.getLeftPadding());
rightSpinner.setValue(mobileStyle.getRightPadding());
topSpinner.setValue(mobileStyle.getTopPadding());
bottomSpinner.setValue(mobileStyle.getBottomPadding());
initialColorSelectBox.setSelectObject(mobileStyle.getInitialBackgroundColor());
selectedColorSelectBox.setSelectObject(mobileStyle.getSelectedBackgroundColor());
borderLineCombo.setSelectedLineStyle(mobileStyle.getBorderType());
borderColor.setSelectObject(mobileStyle.getBorderColor());
borderRadiusSpinner.setValue(mobileStyle.getBorderRadius());
if(mobileStyle.getInitialFont() != null) {
initialFontConfPane.populate(mobileStyle.getInitialFont());
}
if(mobileStyle.getSelectedFont() != null) {
selectedFontColor.setColor(mobileStyle.getSelectedFont().getForeground());
}
}
@Override
public MobileStyle updateBean() {
UnitedMobileStyle mobileStyle = (UnitedMobileStyle)this.widget.getMobileStyle();
mobileStyle.setCustom(custom.getSelectedIndex() == 1);
mobileStyle.setLeftPadding(leftSpinner.getValue());
mobileStyle.setRightPadding(rightSpinner.getValue());
mobileStyle.setTopPadding(topSpinner.getValue());
mobileStyle.setBottomPadding(bottomSpinner.getValue());
mobileStyle.setInitialBackgroundColor(initialColorSelectBox.getSelectObject());
mobileStyle.setSelectedBackgroundColor(selectedColorSelectBox.getSelectObject());
mobileStyle.setBorderType(borderLineCombo.getSelectedLineStyle());
mobileStyle.setBorderColor(borderColor.getSelectObject());
mobileStyle.setBorderRadius(borderRadiusSpinner.getValue());
FRFont initialFont = initialFontConfPane.updateFont(null, null, null);
FRFont selectedFont = initialFontConfPane.updateFont(selectedFontColor.getColor(), null, null);
selectedFont.setForeground(selectedFontColor.getColor());
mobileStyle.setInitialFont(initialFont);
mobileStyle.setSelectedFont(selectedFont);
return mobileStyle;
}
@Override
protected String title4PopupWindow() {
return null;
}
}

44
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/topparam/MobileTopParamPane.java

@ -0,0 +1,44 @@
package com.fr.design.mainframe.mobile.ui.topparam;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.form.ui.mobile.impl.MobileTopParamStyle;
import javax.swing.*;
import java.awt.*;
public class MobileTopParamPane extends BasicBeanPane<MobileTopParamStyle> {
private UICheckBox autoCommitCheckBox;
public MobileTopParamPane() {
this.init();
}
private void init() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel panel = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Plugin-TopParam_Setting"));
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
autoCommitCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Plugin-TopParam_AutoCommit"), true);
panel.add(autoCommitCheckBox);
this.add(panel, BorderLayout.CENTER);
}
@Override
public void populateBean(MobileTopParamStyle topParamStyle) {
autoCommitCheckBox.setSelected(topParamStyle.isAutoCommit());
}
@Override
public MobileTopParamStyle updateBean() {
MobileTopParamStyle topParamStyle = new MobileTopParamStyle();
topParamStyle.setAutoCommit(autoCommitCheckBox.isSelected());
return topParamStyle;
}
@Override
protected String title4PopupWindow() {
return null;
}
}

57
designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/DesignerUtils.java

@ -0,0 +1,57 @@
package com.fr.design.mainframe.mobile.utils;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.UITitleSplitLine;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import java.awt.*;
public class DesignerUtils {
public static final int NORMAL_COMBO_WIDTH = 152;
public static final int kDefaultHorizontalPadding = 0;
public static final int kDefaultVerticalPadding = 15;
public static final int kAlignLeft = 0;
public static final int kAlignCenter = 1;
public static final int[] BORDER_LINE_STYLE_ARRAY = new int[]{
Constants.LINE_NONE,
Constants.LINE_THIN,
Constants.LINE_MEDIUM,
Constants.LINE_THICK,
};
public static UITitleSplitLine createTitleSplitLine(String title) {
UITitleSplitLine splitLine = new UITitleSplitLine(title, 520);
splitLine.setPreferredSize(new Dimension(520, 20));
return splitLine;
}
public static UILabel createConfigLabel(String title) {
UILabel label = new UILabel(title, UILabel.RIGHT);
label.setPreferredSize(new Dimension(100, 20));
return label;
}
public static NewColorSelectBox createNormalColorSelectBox(ChangeListener changeListener) {
NewColorSelectBox colorSelectBox = new NewColorSelectBox(NORMAL_COMBO_WIDTH);
colorSelectBox.addSelectChangeListener(changeListener);
return colorSelectBox;
}
public static UICheckBox createCheckBox(String text, boolean selected) {
UICheckBox uiCheckBox = new UICheckBox(text, selected);
return uiCheckBox;
}
public static JPanel createLeftRightComponentsPane(Component... components) {
return TableLayoutHelper.createGapTableLayoutPane(new Component[][]{components}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
}
}

137
designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/FontConfigPane.java

@ -0,0 +1,137 @@
package com.fr.design.mainframe.mobile.utils;
import com.fr.base.BaseUtils;
import com.fr.base.Utils;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.general.FRFont;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Vector;
public class FontConfigPane extends JPanel {
private static final Icon[] ITALIC_ICONS = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic_white.png")};
private static final Icon[] BOLD_ICONS = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold_white.png")};
private EventListenerList fontChangeListener = new EventListenerList();
private UIComboBox fontFamily;
private UIComboBox fontSize;
private UIToggleButton bold;
private UIColorButton color;
private UIToggleButton italic;
public FontConfigPane() {
super();
init();
}
private void init() {
this.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
fontFamily = new UIComboBox(Utils.getAvailableFontFamilyNames4Report());
Vector<Integer> integerList = new Vector<>();
for (int i = 1; i < 100; i++) {
integerList.add(i);
}
fontFamily.setPreferredSize(new Dimension(152, 20));
fontSize = new UIComboBox(integerList);
fontSize.setSelectedIndex(14);
color = new UIColorButton();
bold = new UIToggleButton(BOLD_ICONS, true);
italic = new UIToggleButton(ITALIC_ICONS, true);
fontFamily.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
fireFontStateChanged();
}
});
fontSize.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
fireFontStateChanged();
}
});
bold.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
fireFontStateChanged();
}
});
italic.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
fireFontStateChanged();
}
});
color.addColorChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
fireFontStateChanged();
}
});
this.add(fontFamily);
this.add(fontSize);
this.add(color);
this.add(bold);
this.add(italic);
}
public void setFontColor(Color fontColor) {
color.setColor(fontColor);
}
public FRFont updateFont(Color fontColor, Boolean isBold, Boolean isItalic) {
String family = (String) fontFamily.getSelectedItem();
int size = (int) fontSize.getSelectedItem();
int style = Font.PLAIN;
boolean bold = (isBold == null) ? this.bold.isSelected() : isBold;
boolean italic = (isItalic == null) ? this.italic.isSelected() : isItalic;
style += bold ? Font.BOLD : Font.PLAIN;
style += italic ? Font.ITALIC : Font.PLAIN;
FRFont frFont = FRFont.getInstance(family, style, size, fontColor == null ? color.getColor() : fontColor);
return frFont;
}
public FRFont update() {
String family = (String) fontFamily.getSelectedItem();
int size = (int) fontSize.getSelectedItem();
int style = Font.PLAIN;
style += this.bold.isSelected() ? Font.BOLD : Font.PLAIN;
style += this.italic.isSelected() ? Font.ITALIC : Font.PLAIN;
return FRFont.getInstance(family, style, size, color.getColor());
}
public void populate(FRFont frFont) {
fontFamily.setSelectedItem(frFont.getFamily());
fontSize.setSelectedItem(frFont.getSize());
color.setColor(frFont.getForeground());
bold.setSelected(frFont.isBold());
italic.setSelected(frFont.isItalic());
}
/**
* 颜色状态改变
*/
public void fireFontStateChanged() {
Object[] listeners = fontChangeListener.getListenerList();
ChangeEvent e = null;
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == ChangeListener.class) {
if (e == null) {
e = new ChangeEvent(this);
}
((ChangeListener) listeners[i + 1]).stateChanged(e);
}
}
}
}

185
designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/IconConfigPane.java

@ -0,0 +1,185 @@
package com.fr.design.mainframe.mobile.utils;
import com.fr.base.IconManager;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.DrawRoutines;
import com.fr.design.web.CustomIconPane;
import com.fr.form.ui.WidgetInfoConfig;
import com.fr.general.FRFont;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class IconConfigPane extends JPanel {
private UIButton editIconButton;
private UIButton deleteIconButton;
private IconButton iconButton;
public IconConfigPane() {
initComp();
}
public void initComp() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
editIconButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Edit"));
editIconButton.setFont(FRFont.getInstance("Helvetica", Font.PLAIN, 12, Color.decode("#3A383A")));
editIconButton.setPreferredSize(new Dimension(62, 20));
panel.add(editIconButton);
editIconButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final CustomIconPane cip = new CustomIconPane(){
protected String createDescriptionText(){
return Toolkit.i18nText("Fine-Design_Mobile_Custom_Icon_Message");
}
};
BasicDialog editDialog = cip.showWindow(new JFrame());
editDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
IconConfigPane.this.iconButton.setIconName(cip.update());
IconConfigPane.this.deleteIconButton.setEnabled(true);
IconConfigPane.this.repaint();
}
});
editDialog.setVisible(true);
}
});
editIconButton.setEnabled(true);
deleteIconButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Delete"));
deleteIconButton.setFont(FRFont.getInstance("Helvetica", Font.PLAIN, 12, Color.decode("#3A383A")));
deleteIconButton.setPreferredSize(new Dimension(62, 20));
panel.add(deleteIconButton);
deleteIconButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
IconConfigPane.this.iconButton.setIconName(StringUtils.EMPTY);
IconConfigPane.this.deleteIconButton.setEnabled(false);
IconConfigPane.this.repaint();
}
});
deleteIconButton.setEnabled(false);
this.add(panel, BorderLayout.CENTER);
JPanel westPane = new JPanel();
iconButton = new IconButton("");
westPane.add(iconButton);
this.add(westPane, BorderLayout.WEST);
}
public void populate(String iconName) {
if(StringUtils.isNotEmpty(iconName)) {
deleteIconButton.setEnabled(true);
} else {
deleteIconButton.setEnabled(false);
}
iconButton.setIconName(iconName);
}
public String update() {
return iconButton.getIconName();
}
private class IconButton extends JToggleButton implements ActionListener {
private String iconName;
private Image iconImage = null;
private static final int ICON_BUTTON_SIZE = 20;
private static final int ICON_X = 2;
private static final int ICON_Y = 2;
public IconButton(String name) {
this.iconName = name;
this.addActionListener(this);
this.setBackground(Color.WHITE);
this.setCursor(new Cursor(Cursor.HAND_CURSOR));
this.iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(name);
}
@Override
public void updateUI() {
setUI(new BasicButtonUI() {
public void paint(Graphics g, JComponent c) {
super.paint(g, c);
}
});
}
protected void paintBorder(Graphics g) {
super.paintBorder(g);
if (StringUtils.isNotEmpty(iconButton.getIconName())) {
DrawRoutines.drawRoundedBorder(
g, Color.decode("#419BF9"), 0, 0, 20, 20);
} else {
DrawRoutines.drawRoundedBorder(
g, Color.decode("#D9DADD"), 0, 0, 20, 20);
}
}
public String getIconName() {
return iconName;
}
public void setIconName(String iconName) {
this.iconName = iconName;
this.iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(iconName);
this.repaint();
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
// carl:这里缩放显示 16 × 16
if (iconImage != null) {
g2d.drawImage(iconImage, ICON_X, ICON_Y, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null);
}
}
@Override
public Dimension getPreferredSize() {
return new Dimension(ICON_BUTTON_SIZE, ICON_BUTTON_SIZE);
}
public void actionPerformed(ActionEvent evt) {
IconConfigPane.this.repaint();// repaint
}
@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);
}
}
}
}

41
designer-base/src/main/java/com/fr/design/mainframe/mobile/utils/MobileStyleProviderManager.java

@ -0,0 +1,41 @@
package com.fr.design.mainframe.mobile.utils;
import com.fr.design.mainframe.mobile.provider.combo.SimpleComboCheckBoxStyleProvider;
import com.fr.design.mainframe.mobile.provider.combo.SimpleComboStyleProvider;
import com.fr.design.mainframe.mobile.provider.date.NavigationStyleProvider;
import com.fr.design.mainframe.mobile.provider.date.SimpleDateStyleProvider;
import com.fr.design.mainframe.mobile.provider.date.SimpleStyleProvider;
import com.fr.design.mainframe.mobile.provider.radiogroup.CapsuleRadioGroupStyleProvider;
import com.fr.design.mainframe.mobile.provider.radiogroup.ImageRadioGroupStyleProvider;
import com.fr.design.mainframe.mobile.provider.radiogroup.UnitedRadioGroupStyleProvider;
import com.fr.design.mainframe.mobile.provider.topparam.MobileTopParamStyleProvider;
import com.fr.stable.fun.mark.Mutable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class MobileStyleProviderManager {
private static Set<Mutable> mobileWidgetStyleProviderSet = new HashSet<Mutable>() {{
add(new SimpleStyleProvider());
add(new NavigationStyleProvider());
add(new SimpleDateStyleProvider());
add(new SimpleComboStyleProvider());
add(new SimpleComboCheckBoxStyleProvider());
add(new CapsuleRadioGroupStyleProvider());
add(new UnitedRadioGroupStyleProvider());
add(new ImageRadioGroupStyleProvider());
}};
private static Set<Mutable> mobileParamUIProviderSet = new HashSet<Mutable>() {{
add(new MobileTopParamStyleProvider());
}};
private static Map<String, Set<Mutable>> map = new HashMap<String, Set<Mutable>>() {{
put("MobileWidgetStyleProvider", mobileWidgetStyleProviderSet);
put("MobileParamUIProvider", mobileParamUIProviderSet);
}};
public static <T extends Mutable> Set<T> getArray(String mark) {
return (Set<T>) map.get(mark);
}
}

8
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/ColorFillStylePane.java

@ -15,7 +15,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.background.gradient.FixedGradientBar;
import com.fr.design.style.background.gradient.FixedGradientBarNoTheme;
import com.fr.design.style.color.ColorAdjustPane;
import com.fr.stable.StringUtils;
@ -40,7 +40,7 @@ public class ColorFillStylePane extends BasicBeanPane<ColorFillStyle> {
private ColorSchemeComboBox styleSelectBox;
private JPanel customPane;
private JPanel changeColorSetPane;
private FixedGradientBar colorGradient;
private FixedGradientBarNoTheme colorGradient;
private CardLayout cardLayout;
@ -69,8 +69,8 @@ public class ColorFillStylePane extends BasicBeanPane<ColorFillStyle> {
};
changeColorSetPane = new JPanel(cardLayout = new CardLayout());
changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 130), "gradient");
gradientColors = new Color[]{Color.WHITE, FixedGradientBar.NEW_CHARACTER};
changeColorSetPane.add(colorGradient = new FixedGradientBarNoTheme(4, 130), "gradient");
gradientColors = new Color[]{Color.WHITE, FixedGradientBarNoTheme.NEW_CHARACTER};
changeColorSetPane.add(colorAdjustPane = new ColorAdjustPane(), "acc");
accColors = ColorAdjustPane.DEFAULT_COLORS;
cardLayout.show(changeColorSetPane, "acc");

53
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/detail/background/ColorDetailPane.java

@ -3,20 +3,10 @@ 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.color.ColorSelectPane;
import com.fr.design.style.color.NewColorSelectPane;
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
@ -50,48 +40,9 @@ public class ColorDetailPane extends AbstractBackgroundDetailPane<ColorBackgroun
return background instanceof ColorBackground;
}
class ColorBackgroundSelectPane extends ColorSelectPane implements UIObserver {
class ColorBackgroundSelectPane extends NewColorSelectPane 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();
UIButton transpanrentBtn = new UIButton();
transpanrentBtn.setPreferredSize(new Dimension(160, 20));
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Color")),
transpanrentBtn}}, TableLayoutHelper.FILL_NONE, 33, 5);
jPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 10));
return jPanel;
}
protected JPanel createCenterPane() {
// JPanel centerPane = super.createCenterPane();
JPanel centerPane = new JPanel();
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{new Component[]{new UILabel(" "), centerPane}}, TableLayoutHelper.FILL_NONE, 33, 5);
jPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 10));
return jPanel;
}
@Override
public void registerChangeListener(UIObserverListener listener) {
this.uiObserverListener = listener;

13
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ChartPreStylePreView.java

@ -4,17 +4,14 @@ import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.BaseChartPainter;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.base.chart.result.WebChartIDInfo;
import com.fr.chart.base.ChartPreStyleProvider;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.config.predefined.PredefinedStyle;
import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.general.Background;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.script.Calculator;
import com.fr.stable.core.PropertyChangeListener;
import javax.swing.BorderFactory;
import java.util.List;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
@ -79,13 +76,13 @@ public class ChartPreStylePreView extends MiddleChartComponent {
}
public void refresh(PredefinedStyle style) {
VanChart vanChart = chartCollection.getSelectedChartProvider(VanChart.class);
List<ChartPreStyleProvider> chartPreStyleProviders = vanChart.getChartPreStyleProvider();
for (ChartPreStyleProvider chartPreStyleProvider : chartPreStyleProviders) {
chartPreStyleProvider.updatePreDefinedStyle(style);
/*VanChart vanChart = chartCollection.getSelectedChartProvider(VanChart.class);
List<ChartThemeStyleProvider> chartThemeStyleProviders = vanChart.getChartPreStyleProvider();
for (ChartThemeStyleProvider chartThemeStyleProvider : chartThemeStyleProviders) {
chartThemeStyleProvider.updateThemeStyle(style);
}
componentBackground = style.getComponentStyle().getBorderStyle().getBackground();
vanChart.attrChange();
vanChart.attrChange();*/
}
@Override

81
designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java

@ -0,0 +1,81 @@
package com.fr.design.mainframe.theme;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeConfig;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.module.ModuleContext;
import javax.swing.SwingUtilities;
import java.util.concurrent.ExecutorService;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/8/24
*/
public class AsyncThemeFetcher<T extends TemplateTheme> {
private final ExecutorService executorService;
private final TemplateThemeConfig<T> config;
public AsyncThemeFetcher(int threads, TemplateThemeConfig<T> config) {
this.executorService = ModuleContext.getExecutor().newFixedThreadPool(
threads,
new NamedThreadFactory(this.getClass().getName())
);
this.config = config;
}
public void shutdown() {
executorService.shutdown();
}
public boolean isShutdown() {
return executorService.isShutdown();
}
public void submit(String themeName, AsyncThemeFetchCallback<T> callback) {
if (callback != null) {
callback.beforeCachedFetch();
}
executorService.submit(new Runnable() {
@Override
public void run() {
if (executorService.isShutdown()) {
return;
}
T theme = config.cachedFetch(themeName);
if (executorService.isShutdown()) {
return;
}
if (callback != null) {
// 后续任务不要在工作线程中执行,从而确保只在EDT线程操作UI
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
callback.afterCachedFetch(theme);
}
});
}
}
});
}
public interface AsyncThemeFetchCallback<T extends TemplateTheme> {
void beforeCachedFetch();
void afterCachedFetch(T theme);
}
public static class AsyncThemeFetchCallbackAdapter<T extends TemplateTheme> implements AsyncThemeFetchCallback<T> {
@Override
public void beforeCachedFetch() {
}
@Override
public void afterCachedFetch(T theme) {
}
}
}

81
designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java

@ -0,0 +1,81 @@
package com.fr.design.mainframe.theme;
import com.fr.base.theme.FormTheme;
import com.fr.base.theme.TemplateThemeConfig;
import com.fr.base.theme.settings.ThemedComponentStyle;
import com.fr.base.theme.settings.ThemedFormBodyStyle;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.theme.edit.ChartStyleFormEditPane;
import com.fr.design.mainframe.theme.edit.ComponentStyleEditPane;
import com.fr.design.mainframe.theme.edit.FormBodyStyleEditPane;
import com.fr.design.mainframe.theme.preview.FormThemePreviewPane;
import javax.swing.JPanel;
import static com.fr.design.i18n.Toolkit.i18nText;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/8/13
*/
public class FormThemeProfilePane extends TemplateThemeProfilePane<FormTheme> {
public static final int LABEL_WIDTH = 60;
private FormBodyStyleEditPane formBodyStyleSettingPane;
private ComponentStyleEditPane componentStyleSettingPane;
public FormThemeProfilePane(TemplateThemeConfig<FormTheme> config) {
super(config);
}
@Override
public FormThemePreviewPane createThemePreviewPane() {
return new FormThemePreviewPane();
}
@Override
protected JPanel createCustomEditorsPane() {
JPanel container = super.createCustomEditorsPane();
formBodyStyleSettingPane = new FormBodyStyleEditPane();
addCustomEditorPane(i18nText("Fine-Design_Predefined_Template_Background"), formBodyStyleSettingPane);
addCustomEditorPane(i18nText("Fine-Design_Predefined_Cell_Style"), createCellStyleSettingPane());
addCustomEditorPane(i18nText("Fine-Design_Predefined_Chart_Style"), createChartStyleSettingPane());
componentStyleSettingPane = new ComponentStyleEditPane();
addCustomEditorPane(i18nText("Fine-Design_Predefined_Component_Style"), componentStyleSettingPane);
return container;
}
@Override
protected JPanel createChartStyleSettingPane() {
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
chartStyleSettingPane = new ChartStyleFormEditPane();
container.add(chartStyleSettingPane);
return container;
}
@Override
public void populateBean4CustomEditors(FormTheme theme) {
super.populateBean4CustomEditors(theme);
formBodyStyleSettingPane.populateBean(theme.getBodyStyle());
componentStyleSettingPane.populateBean(theme.getComponentStyle());
}
@Override
public void updateBean(FormTheme theme) {
ThemedFormBodyStyle formBodyStyle = formBodyStyleSettingPane.updateBean();
theme.setBodyStyle(formBodyStyle);
ThemedComponentStyle componentStyle = componentStyleSettingPane.updateBean();
theme.setComponentStyle(componentStyle);
}
@Override
public String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Form_Theme_Profile_Dialog_Title");
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save