Browse Source

解决冲突

research/11.0
shine 5 years ago
parent
commit
1802485b2b
  1. 2
      designer-base/src/main/java/com/fr/design/DesignState.java
  2. 39
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  3. 33
      designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java
  4. 65
      designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java
  5. 436
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  6. 3
      designer-base/src/main/java/com/fr/design/border/UIRoundedBorder.java
  7. 9
      designer-base/src/main/java/com/fr/design/constants/DesignerLaunchStatus.java
  8. 7
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionTableProcedurePane.java
  9. 26
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  10. 3
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MaxMemRowCountPanel.java
  11. 2
      designer-base/src/main/java/com/fr/design/dialog/JWizardPanel.java
  12. 2
      designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java
  13. 2
      designer-base/src/main/java/com/fr/design/extra/QQLoginWebPane.java
  14. 8
      designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java
  15. 12
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  16. 17
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  17. 10
      designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java
  18. 12
      designer-base/src/main/java/com/fr/design/fun/ToolbarItemProvider.java
  19. 12
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractToolbarItem.java
  20. 14
      designer-base/src/main/java/com/fr/design/gui/borders/UIFrameBorder.java
  21. 3
      designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java
  22. 6
      designer-base/src/main/java/com/fr/design/gui/frpane/CommitTabbedPane.java
  23. 6
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIBasicButtonUI.java
  24. 2
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java
  25. 2
      designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButton.java
  26. 2
      designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButtonUI.java
  27. 12
      designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java
  28. 4
      designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java
  29. 6
      designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java
  30. 43
      designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java
  31. 26
      designer-base/src/main/java/com/fr/design/gui/itextfield/UIIntNumberField.java
  32. 8
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxTextArea.java
  33. 15
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/Style.java
  34. 21
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxScheme.java
  35. 2
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/folding/HtmlFoldParser.java
  36. 3657
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/FormulaTokenMaker.java
  37. 11
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/MakefileTokenMaker.java
  38. 36
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaBase.java
  39. 3
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/SearchEngine.java
  40. 5
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/VolatileImageBackgroundPainterStrategy.java
  41. 9
      designer-base/src/main/java/com/fr/design/icon/BorderIcon.java
  42. 2
      designer-base/src/main/java/com/fr/design/icon/LockIcon.java
  43. 2
      designer-base/src/main/java/com/fr/design/icon/WarningIcon.java
  44. 5
      designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java
  45. 82
      designer-base/src/main/java/com/fr/design/layout/TableLayout.java
  46. 98
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  47. 14
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  48. 39
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  49. 66
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/UpdateActionManager.java
  50. 19
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/UpdateActionModel.java
  51. 4
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java
  52. 3
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java
  53. 3
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellRender.java
  54. 16
      designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthManagerAction.java
  55. 14
      designer-base/src/main/java/com/fr/design/remote/constants/MemberIcon.java
  56. 64
      designer-base/src/main/java/com/fr/design/remote/ui/AbstractListControlPane.java
  57. 440
      designer-base/src/main/java/com/fr/design/remote/ui/AbstractManagerPane.java
  58. 6
      designer-base/src/main/java/com/fr/design/remote/ui/AuthorityEditorPane.java
  59. 38
      designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListCustomRolePane.java
  60. 38
      designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListUserPane.java
  61. 39
      designer-base/src/main/java/com/fr/design/remote/ui/AuthorityManagerPane.java
  62. 83
      designer-base/src/main/java/com/fr/design/remote/ui/CustomRoleManagerPane.java
  63. 425
      designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java
  64. 21
      designer-base/src/main/java/com/fr/design/remote/ui/list/AddedMemberList.java
  65. 12
      designer-base/src/main/java/com/fr/design/remote/ui/list/AddedMemberListCellRender.java
  66. 21
      designer-base/src/main/java/com/fr/design/remote/ui/list/AddingMemberList.java
  67. 14
      designer-base/src/main/java/com/fr/design/remote/ui/list/AddingMemberListCellRender.java
  68. 12
      designer-base/src/main/java/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java
  69. 25
      designer-base/src/main/java/com/fr/design/remote/ui/list/cell/AddedCustomRoleListCellRender.java
  70. 25
      designer-base/src/main/java/com/fr/design/remote/ui/list/cell/AddedUserListCellRender.java
  71. 25
      designer-base/src/main/java/com/fr/design/remote/ui/list/cell/AddingCustomRoleListCellRender.java
  72. 25
      designer-base/src/main/java/com/fr/design/remote/ui/list/cell/AddingUserListCellRender.java
  73. 25
      designer-base/src/main/java/com/fr/design/remote/ui/list/cell/AuthorityCustomRoleListCellRender.java
  74. 25
      designer-base/src/main/java/com/fr/design/remote/ui/list/cell/AuthorityUserListCellRender.java
  75. 4
      designer-base/src/main/java/com/fr/design/report/WatermarkPane.java
  76. 3
      designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java
  77. 49
      designer-base/src/main/java/com/fr/design/ui/util/EdtInvocationManager.java
  78. 77
      designer-base/src/main/java/com/fr/design/ui/util/GraphicsConfig.java
  79. 55
      designer-base/src/main/java/com/fr/design/ui/util/UIUtil.java
  80. 118
      designer-base/src/main/java/com/fr/design/update/actions/FileDownloader.java
  81. 55
      designer-base/src/main/java/com/fr/design/update/actions/FileProcess.java
  82. 102
      designer-base/src/main/java/com/fr/design/update/domain/DownloadItem.java
  83. 1
      designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java
  84. 195
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java
  85. 15
      designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java
  86. 5
      designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java
  87. 5
      designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java
  88. 54
      designer-base/src/main/java/com/fr/start/BaseDesigner.java
  89. 4
      designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java
  90. 55
      designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java
  91. 13
      designer-base/src/main/java/com/fr/start/server/ServerManageFrame.java
  92. 12
      designer-base/src/main/java/com/fr/start/server/ServerTray.java
  93. 8
      designer-base/src/main/resources/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/FormulaTokenMaker.flex
  94. BIN
      designer-base/src/main/resources/com/fr/design/remote/images/icon_Custom_Role_normal@1x.png
  95. BIN
      designer-base/src/main/resources/com/fr/design/remote/images/icon_Custom_Role_normal@2x.png
  96. 70
      designer-base/src/test/java/com/fr/design/ExtraDesignClassManagerTest.java
  97. 391
      designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java
  98. 3
      designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java
  99. 46
      designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java
  100. 141
      designer-chart/src/main/java/com/fr/design/chart/fun/ChartTypeUIProvider.java
  101. Some files were not shown because too many files have changed in this diff Show More

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

@ -1,9 +1,7 @@
package com.fr.design;
import com.fr.base.BaseUtils;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.workspace.WorkContext;
/**
* Created by IntelliJ IDEA.

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

@ -24,6 +24,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogFormatter;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.general.SupportLocale;
import com.fr.general.locale.LocaleCenter;
import com.fr.general.locale.LocaleMark;
import com.fr.general.xml.GeneralXMLTools;
@ -116,7 +117,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private Color paginationLineColor = Color.black; // line color of paper
private boolean supportCellEditorDef = false;
private boolean isDragPermited = false;
private Locale language = Locale.getDefault();
private Locale language = checkLocale(Locale.getDefault());
//2014-8-26默认显示全部, 因为以前的版本, 虽然是false, 实际上是显示所有表, 因此这边要兼容
private boolean useOracleSystemSpace = true;
private int cachingTemplateLimit = CACHINGTEMPLATE_LIMIT;
@ -144,6 +145,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
//记录当前激活码的在线激活状态.
private int activeKeyStatus = -1;
private boolean joinProductImprove = true;
private boolean embedServerLazyStartup = false;
//最近使用的颜色
private ColorSelectConfigManager configManager = new ColorSelectConfigManager();
/**
@ -717,6 +720,24 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
designerPushUpdateConfigManager.setAutoPushUpdateEnabled(autoPushUpdateEnabled);
}
/**
* 内置服务器是否使用时启动
*
* @return 结果
*/
public boolean isEmbedServerLazyStartup() {
return embedServerLazyStartup;
}
/**
* 设置内置服务器使用时启动
*
* @param embedServerLazyStartup 使用时启动
*/
public void setEmbedServerLazyStartup(boolean embedServerLazyStartup) {
this.embedServerLazyStartup = embedServerLazyStartup;
}
/**
* 是否磁盘空间参数
*
@ -1323,7 +1344,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
String tmpVal;
if ((tmpVal = reader.getElementValue()) != null) {
if (!CommonUtils.isNumber(tmpVal)) {
setLanguage(CommonUtils.stringToLocale(tmpVal));
setLanguage(checkLocale(CommonUtils.stringToLocale(tmpVal)));
} else {
// 用于兼容10.0之前的版本
int value = Integer.parseInt(tmpVal);
@ -1372,6 +1393,16 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
}
}
/**
* 对国际化进行校验
* 非简繁英日韩的默认环境 设计器全部默认为英文版本
* @param locale
* @return
*/
private Locale checkLocale(Locale locale) {
return SupportLocale.getInstance().isSupport(locale) ? locale : Locale.US;
}
private void readReportLengthUnit(XMLableReader reader) {
String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
@ -1604,6 +1635,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if ((tmpVal = reader.getAttrAsString("recentSelectedConnection", null)) != null) {
this.setRecentSelectedConnection(tmpVal);
}
this.setEmbedServerLazyStartup(reader.getAttrAsBoolean("embedServerLazyStartup", false));
}
private void readReportPaneAttributions(XMLableReader reader) {
@ -1848,6 +1880,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (this.isTemplateTreePaneExpanded()) {
writer.attr("templateTreePaneExpanded", this.isTemplateTreePaneExpanded());
}
if (this.isEmbedServerLazyStartup()) {
writer.attr("embedServerLazyStartup", this.isEmbedServerLazyStartup());
}
writer.end();
}

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

@ -20,6 +20,7 @@ import com.fr.plugin.AbstractExtraClassManager;
import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.injectable.PluginSingleInjection;
import com.fr.plugin.solution.closeable.CloseableContainedSet;
import com.fr.stable.Filter;
import com.fr.stable.plugin.ExtraDesignClassManagerProvider;
import java.util.ArrayList;
@ -111,26 +112,39 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement
return result.toArray(new WidgetOption[result.size()]);
}
public WidgetOption[] getWebWidgetOptions() {
return getWebWidgetOptions(new Filter<ToolbarItemProvider>() {
@Override
public boolean accept(ToolbarItemProvider toolbarItemProvider) {
return true;
}
});
}
public WidgetOption[] getWebWidgetOptions(Filter<ToolbarItemProvider> filter) {
Set<ToolbarItemProvider> set = getArray(ToolbarItemProvider.XML_TAG);
if (set.isEmpty()) {
return getWebWidgetOptions(set, filter);
}
public WidgetOption[] getWebWidgetOptions(Set<ToolbarItemProvider> set, Filter<ToolbarItemProvider> filter) {
if (set == null || set.isEmpty()) {
return new WidgetOption[0];
}
List<WidgetOption> list = new ArrayList<>();
for (ToolbarItemProvider provider : set) {
WidgetOption option = WidgetOptionFactory.createByWidgetClass(
provider.nameForWidget(),
IOUtils.readIcon(provider.iconPathForWidget()),
provider.classForWidget()
);
list.add(option);
if (filter != null && filter.accept(provider)) {
WidgetOption option = WidgetOptionFactory.createByWidgetClass(
provider.nameForWidget(),
IOUtils.readIcon(provider.iconPathForWidget()),
provider.classForWidget()
);
list.add(option);
}
}
return list.toArray(new WidgetOption[list.size()]);
}
public Map<Class<? extends Widget>, Class<?>> getFormWidgetOptionsMap() {
Set<FormWidgetOptionProvider> set = getArray(FormWidgetOptionProvider.XML_TAG);
Map<Class<? extends Widget>, Class<?>> map = new HashMap<>();
@ -168,7 +182,6 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement
}
public WidgetOption[] getCellWidgetOptions() {
Set<CellWidgetOptionProvider> set = getArray(CellWidgetOptionProvider.XML_TAG);
if (set.isEmpty()) {

65
designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java

@ -10,38 +10,37 @@ import javax.swing.*;
import java.awt.event.ActionEvent;
public class QuestionAction extends UpdateAction
{
public QuestionAction()
{ this.setMenuKeySet(QUESTIONS);
this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/question.png"));
}
@Override
public void actionPerformed(ActionEvent arg0)
{
String url = CloudCenter.getInstance().acquireUrlByKind("bbs.questions");
BrowseUtils.browser(url);
}
public static final MenuKeySet QUESTIONS = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'Q';
}
@Override
public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_Questions");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
public class QuestionAction extends UpdateAction {
public QuestionAction() {
this.setMenuKeySet(QUESTIONS);
this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/question.png"));
}
@Override
public void actionPerformed(ActionEvent arg0) {
String url = CloudCenter.getInstance().acquireUrlByKind("bbs.questions");
BrowseUtils.browser(url);
}
public static final MenuKeySet QUESTIONS = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'Q';
}
@Override
public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_Questions");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}

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

@ -1,6 +1,6 @@
package com.fr.design.actions.file;
import com.fr.base.BaseUtils;
import com.fr.cluster.engine.base.FineClusterConfig;
import com.fr.config.Configuration;
import com.fr.config.ServerPreferenceConfig;
import com.fr.design.DesignerEnvManager;
@ -18,12 +18,13 @@ import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIDictionaryComboBox;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iprogressbar.UIProgressBarUI;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UITextField;
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.layout.VerticalFlowLayout;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.vcs.VcsConfigManager;
import com.fr.design.mainframe.vcs.common.VcsHelper;
@ -36,32 +37,26 @@ import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.general.log.Log4jConfig;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants;
import com.fr.third.apache.log4j.Level;
import com.fr.transaction.Configurations;
import com.fr.transaction.Worker;
import javax.swing.BorderFactory;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.workspace.server.vcs.git.config.GcConfig;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.text.DecimalFormat;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import static com.fr.design.i18n.Toolkit.i18nText;
/**
* 选项对话框
@ -143,14 +138,23 @@ public class PreferencePane extends BasicPane {
private UICheckBox useUniverseDBMCheckbox;
private UICheckBox joinProductImproveCheckBox;
private UICheckBox autoPushUpdateCheckBox;
private UICheckBox embedServerLazyStartupCheckBox;
private UICheckBox vcsEnableCheckBox;
private UICheckBox saveCommitCheckBox;
private UICheckBox useIntervalCheckBox;
private IntegerEditor saveIntervalEditor;
private UICheckBox gcEnableCheckBox;
private UIButton gcButton;
private UILabel remindVcsLabel;
private JDialog gcDialog;
private UILabel gcMessage = new UILabel();
private JPanel gcDialogDownPane = new JPanel();
private JPanel gcProgressBarPanel = new JPanel();
private JProgressBar gcProgressBar;
private Timer gcProgressTimer;
private UIButton gcOkButton = new UIButton(i18nText("Fine-Design_Report_OK"));
public PreferencePane() {
this.initComponents();
@ -163,9 +167,9 @@ public class PreferencePane extends BasicPane {
UITabbedPane jtabPane = new UITabbedPane();
JPanel generalPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
jtabPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_General"), generalPane);
jtabPane.addTab(i18nText("Fine-Design_Basic_General"), generalPane);
JPanel advancePane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
jtabPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Advanced"), advancePane);
jtabPane.addTab(i18nText("Fine-Design_Basic_Advanced"), advancePane);
contentPane.add(jtabPane, BorderLayout.NORTH);
createFunctionPane(generalPane);
@ -186,31 +190,31 @@ public class PreferencePane extends BasicPane {
createServerPane(advancePane);
JPanel oraclePane = FRGUIPaneFactory.createTitledBorderPane("Oracle" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Oracle_All_Tables"));
oracleSpace = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Show_All_Oracle_Tables"));
JPanel oraclePane = FRGUIPaneFactory.createTitledBorderPane("Oracle" + i18nText("Fine-Design_Basic_Oracle_All_Tables"));
oracleSpace = new UICheckBox(i18nText("Fine-Design_Basic_Show_All_Oracle_Tables"));
oraclePane.add(oracleSpace);
JPanel debuggerPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Basic_Develop_Tools"));
openDebugComboBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Open_Debug_Window"));
JPanel debuggerPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Develop_Tools"));
openDebugComboBox = new UICheckBox(i18nText("Fine-Design_Basic_Open_Debug_Window"));
debuggerPane.add(openDebugComboBox, BorderLayout.CENTER);
advancePane.add(debuggerPane);
JPanel upmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager"));
useOptimizedUPMCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Use_New_Update_Plugin_Manager"));
JPanel upmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Update_Plugin_Manager"));
useOptimizedUPMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_New_Update_Plugin_Manager"));
upmSelectorPane.add(useOptimizedUPMCheckbox);
advancePane.add(upmSelectorPane);
JPanel dbmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Manager"));
useUniverseDBMCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Use_Universe_Database_Manager"));
JPanel dbmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Database_Manager"));
useUniverseDBMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_Universe_Database_Manager"));
dbmSelectorPane.add(useUniverseDBMCheckbox);
advancePane.add(dbmSelectorPane);
JPanel improvePane = FRGUIPaneFactory.createVerticalTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Product_Improve"));
joinProductImproveCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Join_Product_Improve"));
JPanel improvePane = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Basic_Product_Improve"));
joinProductImproveCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Join_Product_Improve"));
improvePane.add(joinProductImproveCheckBox);
if (DesignerPushUpdateManager.getInstance().isAutoPushUpdateSupported()) {
autoPushUpdateCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Automatic_Push_Update"));
autoPushUpdateCheckBox = new UICheckBox(i18nText("Fine-Design_Automatic_Push_Update"));
improvePane.add(autoPushUpdateCheckBox);
}
@ -219,23 +223,33 @@ public class PreferencePane extends BasicPane {
spaceUpPane.add(createMemoryPane(), BorderLayout.CENTER);
spaceUpPane.add(improvePane, BorderLayout.SOUTH);
advancePane.add(spaceUpPane);
JPanel embedServerPanel = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Embed_Server"));
embedServerLazyStartupCheckBox = new UICheckBox(i18nText("Fine-Design_Startup_When_Needed"));
embedServerPanel.add(embedServerLazyStartupCheckBox);
advancePane.add(embedServerPanel);
}
private void createVcsSettingPane(JPanel generalPane) {
JPanel vcsPane = FRGUIPaneFactory.createVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Vcs_Title"));
JPanel vcsPane = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Title"));
generalPane.add(vcsPane);
remindVcsLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Remind"));
remindVcsLabel = new UILabel(i18nText("Fine-Design_Vcs_Remind"));
remindVcsLabel.setVisible(!VcsHelper.getInstance().needInit());
vcsEnableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Vcs_SaveAuto"));
saveCommitCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Vcs_No_Delete"));
vcsEnableCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_SaveAuto"));
saveCommitCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_No_Delete"));
saveIntervalEditor = new IntegerEditor(60);
useIntervalCheckBox = new UICheckBox();
//gc面板
JPanel gcControlPane = createGcControlPane();
JPanel enableVcsPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
enableVcsPanel.add(vcsEnableCheckBox);
enableVcsPanel.add(remindVcsLabel);
JPanel intervalPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
final UILabel everyLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Every"));
final UILabel delayLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Delay"));
final UILabel everyLabel = new UILabel(i18nText("Fine-Design_Vcs_Every"));
final UILabel delayLabel = new UILabel(i18nText("Fine-Design_Vcs_Delay"));
intervalPanel.add(useIntervalCheckBox);
intervalPanel.add(everyLabel);
intervalPanel.add(saveIntervalEditor);
@ -262,24 +276,61 @@ public class PreferencePane extends BasicPane {
vcsPane.add(enableVcsPanel);
vcsPane.add(intervalPanel);
vcsPane.add(saveCommitCheckBox);
vcsPane.add(gcControlPane);
}
/**
* 模创建板版本gc 配置操作面板
*
* @return 面板
*/
private JPanel createGcControlPane() {
//gc面板
JPanel gcControlPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
JPanel gcButtonPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 40, 0));
gcEnableCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_Storage_Optimization"));
gcButton = initGcButton();
gcButtonPane.add(gcButton);
gcControlPane.add(gcEnableCheckBox);
gcControlPane.add(gcButtonPane);
gcButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
tryGc();
}
});
gcEnableCheckBox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
gcButton.setEnabled(gcEnableCheckBox.isSelected());
}
});
//集群下禁用
if (FineClusterConfig.getInstance().isCluster()) {
gcEnableCheckBox.setEnabled(false);
gcButton.setEnabled(false);
}
return gcControlPane;
}
private void createFunctionPane(JPanel generalPane) {
JPanel functionPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Function"));
JPanel functionPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Function"));
generalPane.add(functionPane);
//添加supportUndo选择项
supportUndoCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Support_Undo"));
supportUndoCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Preference_Support_Undo"));
functionPane.add(supportUndoCheckBox);
//添加maxUndoLimit
//String[] undoTimes = {"最大撤销次数","5次","10次","15次","20次","50次"};
String[] undoTimes = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Max_Undo_Limit"), MAX_UNDO_LIMIT_5 + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Time(s)"), MAX_UNDO_LIMIT_10 + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Time(s)")
, MAX_UNDO_LIMIT_15 + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Time(s)"), MAX_UNDO_LIMIT_20 + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Time(s)"), MAX_UNDO_LIMIT_50 + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Time(s)")};
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);
//不支持撤销则不能选择撤销可缓存,也不能设置最大撤销次数
supportUndoCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
maxUndoLimit.setEnabled(supportUndoCheckBox.isSelected());
}
@ -288,31 +339,32 @@ public class PreferencePane extends BasicPane {
//添加supportDefaultParentCalculate选择项
supportDefaultParentCalculateCheckBox = new UICheckBox(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Support_Default_Parent_Calculate"));
i18nText("Fine-Design_Basic_Preference_Support_Default_Parent_Calculate"));
functionPane.add(supportDefaultParentCalculateCheckBox);
}
private void createEditPane(JPanel generalPane) {
//samuel:编辑器设置
JPanel editPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Editor_Preference"));
JPanel editPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Editor_Preference"));
generalPane.add(editPane);
//设置是否支持将字符串编辑为公式
supportStringToFormulaBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Support_String_To_Formula"));
supportStringToFormulaBox = new UICheckBox(i18nText("Fine-Design_Report_Support_String_To_Formula"));
editPane.add(supportStringToFormulaBox);
//是否默认转化
defaultStringToFormulaBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Always"));
defaultStringToFormulaBox = new UICheckBox(i18nText("Fine-Design_Basic_Always"));
editPane.add(defaultStringToFormulaBox);
//不支持转化则不能默认执行
supportStringToFormulaBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
defaultStringToFormulaBox.setEnabled(supportStringToFormulaBox.isSelected());
}
});
JPanel keyStrokePane = new JPanel(new BorderLayout());
keyStrokePane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Support_Auto_Complete_Shortcut") + ":"), BorderLayout.WEST);
keyStrokePane.add(new UILabel(i18nText("Fine-Design_Basic_Support_Auto_Complete_Shortcut") + ":"), BorderLayout.WEST);
shortCutLabel = new UILabel();
keyStrokePane.add(shortCutLabel, BorderLayout.CENTER);
editPane.add(keyStrokePane);
@ -342,7 +394,7 @@ public class PreferencePane extends BasicPane {
requestFocusInWindow();
label = new UILabel(text);
add(GUICoreUtils.createBorderLayoutPane(
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Support_Current_Auto_Complete_Shortcut") + ":"),
new UILabel(i18nText("Fine-Design_Basic_Support_Current_Auto_Complete_Shortcut") + ":"),
BorderLayout.WEST,
label,
BorderLayout.CENTER),
@ -376,24 +428,24 @@ public class PreferencePane extends BasicPane {
private void createGuiOfGridPane(JPanel generalPane) {
// GridPane
JPanel guiOfGridPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Setting_Grid"));
JPanel guiOfGridPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Setting_Grid"));
generalPane.add(guiOfGridPane);
supportCellEditorDefCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Support_Cell_Editor_Definition"));
supportCellEditorDefCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Preference_Support_Cell_Editor_Definition"));
guiOfGridPane.add(supportCellEditorDefCheckBox);
isDragPermitedCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Is_Drag_Permited"));
isDragPermitedCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Preference_Is_Drag_Permited"));
guiOfGridPane.add(isDragPermitedCheckBox);
}
private void createColorSettingPane(JPanel generalPane) {
// Color Setting Pane
JPanel colorSettingPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Setting_Colors"));
JPanel colorSettingPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Setting_Colors"));
generalPane.add(colorSettingPane);
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Grid_Line_Color"));
new UILabel(i18nText("Fine-Design_Basic_Preference_Grid_Line_Color"));
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Pagination_Line_Color"));
new UILabel(i18nText("Fine-Design_Basic_Preference_Pagination_Line_Color"));
gridLineColorTBButton = new UIColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"));
gridLineColorTBButton.setEnabled(this.isEnabled());
@ -402,10 +454,10 @@ public class PreferencePane extends BasicPane {
paginationLineColorTBButton.setEnabled(this.isEnabled());
JPanel leftPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
leftPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Grid_Line_Color") + ":"));
leftPane.add(new UILabel(i18nText("Fine-Design_Basic_Preference_Grid_Line_Color") + ":"));
leftPane.add(gridLineColorTBButton);
JPanel rightPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
rightPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Pagination_Line_Color") + ":"));
rightPane.add(new UILabel(i18nText("Fine-Design_Basic_Preference_Pagination_Line_Color") + ":"));
rightPane.add(paginationLineColorTBButton);
colorSettingPane.add(leftPane);
colorSettingPane.add(rightPane);
@ -415,9 +467,9 @@ public class PreferencePane extends BasicPane {
//richer:选择导出log文件的目录.
JPanel logPane = FRGUIPaneFactory.createX_AXISBoxInnerContainer_S_Pane();
advancePane.add(logPane);
JPanel logExportPane = FRGUIPaneFactory.createTitledBorderPane("log" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Export_Setting"));
JPanel logExportPane = FRGUIPaneFactory.createTitledBorderPane("log" + i18nText("Fine-Design_Basic_Export_Setting"));
logPane.add(logExportPane);
UILabel logLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_Export_Log_Directory") + ":");
UILabel logLabel = new UILabel(i18nText("Fine-Design_Basic_Select_Export_Log_Directory") + ":");
logExportPane.add(logLabel, BorderLayout.WEST);
logExportDirectoryField = new UITextField(24);
logExportPane.add(logExportDirectoryField, BorderLayout.CENTER);
@ -425,6 +477,7 @@ public class PreferencePane extends BasicPane {
logExportPane.add(chooseDirBtn, BorderLayout.EAST);
chooseDirBtn.setPreferredSize(new Dimension(25, 25));
chooseDirBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
@ -436,11 +489,12 @@ public class PreferencePane extends BasicPane {
}
});
JPanel logLevelPane = FRGUIPaneFactory.createTitledBorderPane("log" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Level_Setting"));
JPanel logLevelPane = FRGUIPaneFactory.createTitledBorderPane("log" + i18nText("Fine-Design_Basic_Level_Setting"));
logPane.add(logLevelPane);
logLevelComboBox = new UIComboBox(LOG);
logLevelPane.add(logLevelComboBox);
logLevelComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Configurations.update(new Worker() {
@Override
@ -460,13 +514,13 @@ public class PreferencePane extends BasicPane {
private void createLanPane(JPanel generalPane) {
// ben:选择版本语言;
JPanel languageAndDashBoard_pane = FRGUIPaneFactory.createX_AXISBoxInnerContainer_S_Pane();
JPanel LanguagePane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_Language"));
JPanel LanguagePane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Choose_Language"));
generalPane.add(languageAndDashBoard_pane);
languageAndDashBoard_pane.add(LanguagePane);
languageComboBox = createLanguageComboBox();
ActionLabel languageLabel = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Designer_Language"));
ActionLabel languageLabel = new ActionLabel(i18nText("Fine-Design_Basic_Designer_Language"));
languageLabel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@ -480,7 +534,7 @@ public class PreferencePane extends BasicPane {
dlg.setVisible(true);
}
});
UILabel noticeLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Work_After_Restart_Designer"));//sail:提示重启后生效
UILabel noticeLabel = new UILabel(i18nText("Fine-Design_Basic_Work_After_Restart_Designer"));//sail:提示重启后生效
double p = TableLayout.PREFERRED;
double rowSize[] = {p};
double columnSize[] = {p, p, p};
@ -526,16 +580,16 @@ public class PreferencePane extends BasicPane {
double rowSize[] = {p};
// 长度单位选择
JPanel lengthPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Setting_Ruler_Units"));
JPanel lengthPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Setting_Ruler_Units"));
advancePane.add(lengthPane);
pageLengthComboBox = new UIComboBox(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Page_Setup_MM"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_CM"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_INCH")});
pageLengthComboBox = new UIComboBox(new String[]{i18nText("Fine-Design_Basic_Page_Setup_MM"), i18nText("Fine-Design_Report_Unit_CM"), i18nText("Fine-Design_Report_Unit_INCH")});
pageLengthComboBox.setPreferredSize(new Dimension(80, 20));
pageLengthComboBox.setMinimumSize(new Dimension(80, 20));
reportLengthComboBox = new UIComboBox(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Page_Setup_MM"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_CM"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_INCH"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_PT_Duplicate")});
reportLengthComboBox = new UIComboBox(new String[]{i18nText("Fine-Design_Basic_Page_Setup_MM"), i18nText("Fine-Design_Report_Unit_CM"), i18nText("Fine-Design_Report_Unit_INCH"), i18nText("Fine-Design_Report_Unit_PT_Duplicate")});
reportLengthComboBox.setPreferredSize(new Dimension(80, 20));
reportLengthComboBox.setMinimumSize(new Dimension(80, 20));
UILabel pagelengthLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Page_Setup_Scale_Units") + ":");
UILabel reportLengthLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Report_Design_Ruler_Units") + ":");
UILabel pagelengthLabel = new UILabel(i18nText("Fine-Design_Basic_Page_Setup_Scale_Units") + ":");
UILabel reportLengthLabel = new UILabel(i18nText("Fine-Design_Basic_Report_Design_Ruler_Units") + ":");
Component[][] lengthComponents = {
{pagelengthLabel, pageLengthComboBox, reportLengthLabel, reportLengthComboBox},
};
@ -548,13 +602,13 @@ public class PreferencePane extends BasicPane {
double rowSize[] = {p};
double columnSize[] = {p, p, p};
JPanel serverPortPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Port_Setting"));
JPanel serverPortPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Web_Preview_Port_Setting"));
advancePane.add(serverPortPane);
portEditor = new IntegerEditor();
portEditor.setPreferredSize(new Dimension(80, 20));
portEditor.setMinimumSize(new Dimension(80, 20));
UILabel notiJlabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Work_After_Restart_Designer"));
UILabel serverPortLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Port") + ":");
UILabel notiJlabel = new UILabel(i18nText("Fine-Design_Basic_Work_After_Restart_Designer"));
UILabel serverPortLabel = new UILabel(i18nText("Fine-Design_Basic_Web_Preview_Port") + ":");
Component[][] portComponents = {
{serverPortLabel, portEditor, notiJlabel},
};
@ -563,10 +617,10 @@ public class PreferencePane extends BasicPane {
}
private JPanel createMemoryPane() {
JPanel memoryPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Caching_Template"));
UILabel memoryLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Max_Caching_Template"));
JPanel memoryPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Caching_Template"));
UILabel memoryLabel = new UILabel(i18nText("Fine-Design_Basic_Preference_Max_Caching_Template"));
UILabel memoryTipLabel = FRWidgetFactory.createLineWrapLabel(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Caching_Template_Tip"), MEMORY_TIP_LABEL_MAX_WIDTH);
i18nText("Fine-Design_Basic_Preference_Caching_Template_Tip"), MEMORY_TIP_LABEL_MAX_WIDTH);
memoryTipLabel.setBorder(BorderFactory.createEmptyBorder(0, CACHING_GAP, 0, 0));
cachingTemplateSpinner = new UISpinner(0, CACHING_MAX, 1, CACHING_DEFAULT);
JPanel memorySpace = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
@ -579,7 +633,7 @@ public class PreferencePane extends BasicPane {
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Window_Preference");
return i18nText("Fine-Design_Basic_M_Window_Preference");
}
/**
@ -629,7 +683,8 @@ public class PreferencePane extends BasicPane {
saveIntervalEditor.setValue(vcsConfigManager.getSaveInterval());
saveCommitCheckBox.setSelected(vcsConfigManager.isSaveCommit());
useIntervalCheckBox.setSelected(vcsConfigManager.isUseInterval());
gcEnableCheckBox.setSelected(GcConfig.getInstance().isGcEnable());
gcButton.setEnabled(gcEnableCheckBox.isSelected());
supportCellEditorDefCheckBox.setSelected(designerEnvManager.isSupportCellEditorDef());
isDragPermitedCheckBox.setSelected(designerEnvManager.isDragPermited());
@ -660,6 +715,8 @@ public class PreferencePane extends BasicPane {
if (this.autoPushUpdateCheckBox != null) {
this.autoPushUpdateCheckBox.setSelected(designerEnvManager.isAutoPushUpdateEnabled());
}
this.embedServerLazyStartupCheckBox.setSelected(designerEnvManager.isEmbedServerLazyStartup());
}
private int chooseCase(int sign) {
@ -721,11 +778,24 @@ public class PreferencePane extends BasicPane {
designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected());
designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue());
designerEnvManager.setJoinProductImprove(this.joinProductImproveCheckBox.isSelected());
designerEnvManager.setEmbedServerLazyStartup(this.embedServerLazyStartupCheckBox.isSelected());
VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager();
vcsConfigManager.setSaveInterval(this.saveIntervalEditor.getValue());
vcsConfigManager.setVcsEnable(this.vcsEnableCheckBox.isSelected());
vcsConfigManager.setSaveCommit(this.saveCommitCheckBox.isSelected());
vcsConfigManager.setUseInterval(this.useIntervalCheckBox.isSelected());
Configurations.update(new Worker() {
@Override
public void run() {
GcConfig.getInstance().setGcEnable(gcEnableCheckBox.isSelected());
}
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{GcConfig.class};
}
});
if (this.autoPushUpdateCheckBox != null) {
designerEnvManager.setAutoPushUpdateEnabled(this.autoPushUpdateCheckBox.isSelected());
}
@ -756,13 +826,12 @@ public class PreferencePane extends BasicPane {
@Override
public Class<? extends Configuration>[] targets() {
return new Class[] {ServerPreferenceConfig.class};
return new Class[]{ServerPreferenceConfig.class};
}
});
}
// 如果语言设置改变了,则显示重启对话框
public void showRestartDialog() {
if (!languageChanged) {
@ -770,12 +839,12 @@ public class PreferencePane extends BasicPane {
}
int rv = JOptionPane.showOptionDialog(
null,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Language_Change_Successful"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"),
i18nText("Fine-Design_Basic_Language_Change_Successful"),
i18nText("Fine-Design_Basic_Plugin_Warning"),
JOptionPane.YES_NO_OPTION,
JOptionPane.INFORMATION_MESSAGE,
null,
new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Restart_Designer"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Restart_Designer_Later")},
new String[]{i18nText("Fine-Design_Basic_Restart_Designer"), i18nText("Fine-Design_Basic_Restart_Designer_Later")},
null
);
if (rv == JOptionPane.OK_OPTION) {
@ -797,4 +866,203 @@ public class PreferencePane extends BasicPane {
public BasicDialog showWindow(Window window, DialogActionListener l) {
return showWindowWithCustomSize(window, l, new Dimension(BasicDialog.DEFAULT.width, this.getPreferredSize().height + OFFSET_HEIGHT));
}
private void tryGc() {
final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
private long size = 0;
@Override
protected Boolean doInBackground() {
size = WorkContext.getCurrent().get(VcsOperator.class).immediatelyGc();
return true;
}
@Override
protected void done() {
try {
get();
} catch (ExecutionException e) {
updateGcDialogPanelInfo(i18nText("Fine-Design_Vcs_Need_Update_Remote_Server_Jar"));
return;
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
updateGcDialogPanelInfo(i18nText("Fine-Design_Vcs_Reduce_File_Size") + fileSizeConvert(size));
gcDialogDownPane.revalidate();
gcDialogDownPane.repaint();
gcDialogDownPane.add(gcOkButton);
}
};
worker.execute();
initGcDialog();
gcOkButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gcDialog.dispose();
}
});
gcDialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
stopGcProgressTimer();
worker.cancel(true);
}
});
gcDialog.setVisible(true);
gcDialog.dispose();
}
/**
* gc 后更新进度条面板信息
*
* @param message
*/
private void updateGcDialogPanelInfo(String message) {
stopGcProgressTimer();
gcMessage.setText(message);
if (null != gcProgressBar) {
gcProgressBarPanel.remove(gcProgressBar);
}
if (null != gcDialog) {
gcDialog.setTitle(i18nText("Fine-Design_Form_Joption_News"));
}
}
/**
* 初始化 gc 对话框
*/
private void initGcDialog() {
gcDialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(PreferencePane.this), i18nText("Fine-Design_Vcs_Clean_Progress") + "...", true);
gcDialog.setSize(new Dimension(340, 140));
JPanel jp = new JPanel();
//中上
JPanel gcUpPane = new JPanel();
gcUpPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
gcUpPane.add(new UILabel(UIManager.getIcon("OptionPane.informationIcon")));
gcProgressBarPanel = createProgressBarPane();
gcUpPane.add(gcProgressBarPanel);
//中下
gcDialogDownPane = new JPanel();
gcDialogDownPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0));
jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS));
jp.add(gcUpPane);
jp.add(gcDialogDownPane);
gcDialog.add(jp);
gcDialog.setResizable(false);
gcDialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(PreferencePane.this));
}
/**
* gc 进度条面板
*
* @return
*/
private JPanel createProgressBarPane() {
JPanel jp = new JPanel();
VerticalFlowLayout layout = new VerticalFlowLayout();
layout.setAlignLeft(true);
jp.setLayout(layout);
//提示
gcMessage = new UILabel(i18nText("Fine-Design_Vcs_Cleaning"));
// 创建一个进度条
gcProgressBar = createGcProgressBar(0, 30, 240, 15, Color.GREEN);
gcProgressTimer = createGcProgressTimer(500, gcProgressBar);
gcProgressTimer.start();
jp.add(gcMessage);
jp.add(gcProgressBar);
return jp;
}
/**
* 创建 gc 进度条
*
* @param min 最小值
* @param max 最大值
* @param width 宽度
* @param height 高度
* @param color 填充的图片颜色
* @return
*/
private JProgressBar createGcProgressBar(int min, int max, int width, int height, Color color) {
// 创建一个进度条
JProgressBar progressBar = new JProgressBar(min, max);
UIProgressBarUI progressBarUI = new UIProgressBarUI();
progressBar.setUI(progressBarUI);
//颜色(进度条里的小方块)
progressBar.setForeground(color);
progressBar.setOpaque(false);
progressBar.setPreferredSize(new Dimension(width, height));
return progressBar;
}
/**
* @param delay 每隔 delay 毫秒更新进度
* @param progressBar 要更新的进度条
* @return
*/
private Timer createGcProgressTimer(int delay, final JProgressBar progressBar) {
if (null == progressBar) {
return null;
}
// 模拟延时操作进度, 每隔 delay / 1000 秒更新进度
Timer timer = new Timer(delay, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int currentProgress = progressBar.getValue() + 1;
if (currentProgress > progressBar.getMaximum()) {
currentProgress = progressBar.getMinimum();
}
progressBar.setValue(currentProgress);
}
});
return timer;
}
/**
* 停止进度条模拟计时器
*/
private void stopGcProgressTimer() {
if (null == gcProgressTimer) {
return;
}
gcProgressTimer.stop();
}
/**
* 将字节转换成 KB or MB or GB 保留两位小数
*
* @param size
* @return
*/
private String fileSizeConvert(long size) {
DecimalFormat df = new DecimalFormat("0.00");
double n = 1024d;
if (size > Math.pow(n, 3)) {
return df.format(size / Math.pow(n, 3)) + "GB";
}
if (size > Math.pow(n, 2)) {
return df.format(size / Math.pow(n, 2)) + "MB";
}
return new StringBuilder().append(df.format(size / n)).append("KB").toString();
}
/**
* 立即清理的Button
*
* @return
*/
private UIButton initGcButton() {
UIButton gcButton = new UIButton(i18nText("Fine-Design_Vcs_Clean"));
gcButton.setPreferredSize(new Dimension(100, 15));
gcButton.setRoundBorder(true, Constants.LEFT);
return gcButton;
}
}

3
designer-base/src/main/java/com/fr/design/border/UIRoundedBorder.java

@ -44,13 +44,14 @@ public class UIRoundedBorder extends LineBorder {
return lineStyle;
}
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height){
Color oldColor = g.getColor();
Graphics2D g2d = (Graphics2D)g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(lineColor);
GraphHelper.draw(g2d, new RoundRectangle2D.Double(x, y, width - 1, height-1, roundedCorner, roundedCorner),lineStyle);
GraphHelper.draw(g2d, new RoundRectangle2D.Double(x, y, width - 1.0D, height - 1.0D, roundedCorner, roundedCorner), lineStyle);
g2d.setColor(oldColor);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}

9
designer-base/src/main/java/com/fr/design/constants/DesignerLaunchStatus.java

@ -21,10 +21,15 @@ public enum DesignerLaunchStatus implements Event<Null> {
*/
DESIGNER_INIT_COMPLETE,
/**
* 打开模板完成
*/
OPEN_LAST_FILE_COMPLETE,
/**
* 启动完成
*/
OPEN_LAST_FILE_COMPLETE;
STARTUP_COMPLETE;
private static DesignerLaunchStatus status;
@ -34,6 +39,6 @@ public enum DesignerLaunchStatus implements Event<Null> {
public static void setStatus(DesignerLaunchStatus state) {
status = state;
EventDispatcher.asyncFire(DesignerLaunchStatus.getStatus());
EventDispatcher.fire(DesignerLaunchStatus.getStatus());
}
}

7
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionTableProcedurePane.java

@ -35,7 +35,7 @@ public class ConnectionTableProcedurePane extends BasicPane {
private ConnectionComboBoxPanel connectionComboBox;
private UICheckBox tableCheckBox;
private UICheckBox viewCheckBox;
private UITextField searchField;
protected UITextField searchField;
private TableViewList tableViewList;
private java.util.List<DoubleClickSelectedNodeOnTreeListener> listeners = new java.util.ArrayList<DoubleClickSelectedNodeOnTreeListener>();
@ -90,12 +90,17 @@ public class ConnectionTableProcedurePane extends BasicPane {
this.add(tableViewListPane, BorderLayout.CENTER);
this.add(filterPane, BorderLayout.SOUTH);
this.setPreferredSize(new Dimension(WIDTH, getPreferredSize().height));
addKeyMonitor();
}
protected void filter(Connection connection, String conName, List<String> nameList) {
connection.addConnection(nameList, conName, new Class[]{AbstractDatabaseConnection.class});
}
protected void addKeyMonitor() {
}
protected JPanel createCheckBoxgroupPane() {
JPanel checkBoxgroupPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(2);
JPanel first = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();

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

@ -57,6 +57,8 @@ import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import java.util.List;
@ -95,6 +97,30 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
connection.addConnection(nameList, conName, new Class[]{JDBCDatabaseConnection.class, JNDIDatabaseConnection.class});
}
@Override
protected void addKeyMonitor() {
searchField.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
e.setKeyCode(KeyEvent.VK_UP);
DBTableDataPane.this.connectionTableProcedurePane.requestFocus();
}
}
@Override
public void keyReleased(KeyEvent e) {
}
});
}
};
connectionTableProcedurePane.addDoubleClickListener(new DoubleClickSelectedNodeOnTreeListener() {

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

@ -41,6 +41,7 @@ public class MaxMemRowCountPanel extends UIToolbar {
}
};
@Override
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
dim.width = 340;
@ -81,7 +82,7 @@ public class MaxMemRowCountPanel extends UIToolbar {
public void setValue(int value) {
if (value >= 0) {
showMaxPanel();
numberSpinner.setValue(Integer.valueOf(value));
numberSpinner.setValue(value);
} else {
showAllPanel();
}

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

@ -168,7 +168,7 @@ public class JWizardPanel extends BasicPane {
public void addNotify() {
if (firstNotify) {
Font font = stepTitleLabel.getFont();
font = font.deriveFont(Font.BOLD, font.getSize() * 14 / 10);
font = font.deriveFont(Font.BOLD, font.getSize() * 14 / 10.0F);
stepTitleLabel.setFont(font);
firstNotify = false;
}

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

@ -96,7 +96,7 @@ public class PluginOperateUtils {
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Confirmed"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE
JOptionPane.WARNING_MESSAGE
);
if (rv == JOptionPane.OK_OPTION) {
PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo);

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

@ -163,7 +163,7 @@ public class QQLoginWebPane extends JFXPanel {
final BooleanProperty confirmationResult = new SimpleBooleanProperty();
// initialize the confirmation dialog
final Stage dialog = new Stage(StageStyle.UTILITY);
dialog.setX(Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - DEFAULT_CONFIRM_WIDTH / 2 + DEFAULT_OFFEST);
dialog.setX(Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - DEFAULT_CONFIRM_WIDTH / 2.0D + DEFAULT_OFFEST);
dialog.setY(Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 + DEFAULT_OFFEST);
dialog.setHeight(DEFAULT_CONFIRM_HEIGHT);
dialog.setWidth(DEFAULT_CONFIRM_WIDTH);

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

@ -11,6 +11,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.general.http.HttpClient;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.PluginStoreConstants;
@ -293,10 +294,9 @@ public class WebViewDlgHelper {
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
HttpClient httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind("shop.plugin.update") + "?" + PluginUtils.FR_VERSION + "=" + ProductConstants.VERSION + "&version=" + PluginStoreConstants.getInstance().getProps("VERSION"));
httpClient.asGet();
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
String text = httpClient.getResponseText();
String url = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.update");
if (url != null) {
String text = HttpToolbox.get(url + "?" + PluginUtils.FR_VERSION + "=" + ProductConstants.VERSION + "&version=" + PluginStoreConstants.getInstance().getProps("VERSION"));
JSONObject resultJSONObject = new JSONObject(text);
String isLatest = resultJSONObject.optString("result");
if (!ComparatorUtils.equals(isLatest, LATEST)) {

12
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java

@ -264,11 +264,6 @@ public class HistoryTemplateListCache implements CallbackEvent {
if (size == index + 1 && index > 0) {
//如果删除的是后一个Tab,则定位到前一个
MutilTempalteTabPane.getInstance().setSelectedIndex(index - 1);
JTemplate selectedFile = MutilTempalteTabPane.getInstance().getSelectedFile();
if (!isCurrentEditingFile(selectedFile.getPath())) {
//如果此时面板上的实时刷新的selectedIndex得到的和历史的不一样
DesignerContext.getDesignerFrame().activateJTemplate(selectedFile);
}
}
}
}
@ -277,6 +272,13 @@ public class HistoryTemplateListCache implements CallbackEvent {
if (openFileCount == 0) {
DesignerContext.getDesignerFrame().addAndActivateJTemplate();
}
JTemplate selectedFile = MutilTempalteTabPane.getInstance().getSelectedFile();
if (!isCurrentEditingFile(selectedFile.getPath())) {
//如果此时面板上的实时刷新的selectedIndex得到的和历史的不一样
DesignerContext.getDesignerFrame().activateJTemplate(selectedFile);
}
MutilTempalteTabPane.getInstance().repaint();
}

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

@ -156,6 +156,9 @@ public class MutilTempalteTabPane extends JComponent {
}
public JTemplate getSelectedFile() {
if (openedTemplate.size() == selectedIndex) {
selectedIndex = Math.max(--selectedIndex, 0);
}
return openedTemplate.get(selectedIndex);
}
@ -322,7 +325,7 @@ public class MutilTempalteTabPane extends JComponent {
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
double maxWidth = getWidth() - LIST_BUTTON_WIDTH; //最大宽度
double maxWidth = getWidth() - LIST_BUTTON_WIDTH * 1.0D; //最大宽度
Graphics2D g2d = (Graphics2D) g;
paintBackgroundAndLine(g2d, maxWidth);
}
@ -395,8 +398,8 @@ public class MutilTempalteTabPane extends JComponent {
//画下面的那条线
if (templateStartX < maxWidth) {
GeneralPath generalPath = new GeneralPath(Path2D.WIND_EVEN_ODD, 2);
generalPath.moveTo((float) templateStartX, getHeight() - 1);
generalPath.lineTo((float) maxWidth, getHeight() - 1);
generalPath.moveTo((float) templateStartX, getHeight() - 1.0F);
generalPath.lineTo((float) maxWidth, getHeight() - 1.0F);
g2d.fill(generalPath);
//TODO hzzz delete
// g2d.setPaint(UIConstants.LINE_COLOR);
@ -406,7 +409,7 @@ public class MutilTempalteTabPane extends JComponent {
private void paintDefaultBackground(Graphics2D g2d) {
//画默认背景
g2d.setPaint(new GradientPaint(1, 1, UIConstants.TEMPLATE_TAB_PANE_BACKGROUND, 1, getHeight() - 1, UIConstants.TEMPLATE_TAB_PANE_BACKGROUND));
g2d.setPaint(new GradientPaint(1, 1, UIConstants.TEMPLATE_TAB_PANE_BACKGROUND, 1, getHeight() - 1.0F, UIConstants.TEMPLATE_TAB_PANE_BACKGROUND));
g2d.fillRect(0, 0, getWidth(), getHeight());
}
@ -532,7 +535,7 @@ public class MutilTempalteTabPane extends JComponent {
double[] x = {templateStartX, templateStartX, templateStartX + realWidth, templateStartX + realWidth, templateStartX};
double[] y = {1, getHeight() + 1, getHeight() + 1, 1, 1};
RoundRectangle2D.Double rect1 = new RoundRectangle2D.Double(templateStartX, 1, this.getWidth(), this.getHeight(), 7, 7);
g2d.setPaint(new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, getHeight() - 1, UIConstants.SELECT_TAB));
g2d.setPaint(new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, getHeight() - 1.0F, UIConstants.SELECT_TAB));
//选了30度和60度的特殊角度的x,y作为经过的两个点的坐标
double specialLocation1 = 2.5;
double specialLocation2 = 4.330127;
@ -587,9 +590,9 @@ public class MutilTempalteTabPane extends JComponent {
double[] x = {templateStartX, templateStartX, templateStartX + realWidth, templateStartX + realWidth, templateStartX};
double[] y = {-1, getHeight() - 1, getHeight() - 1, -1, -1};
if (selfIndex == mouseOveredIndex) {
g2d.setPaint(new GradientPaint(1, 1, UIConstants.HOVER_BLUE, 1, getHeight() - 1, UIConstants.HOVER_BLUE));
g2d.setPaint(new GradientPaint(1, 1, UIConstants.HOVER_BLUE, 1, getHeight() - 1.0F, UIConstants.HOVER_BLUE));
} else {
g2d.setPaint(new GradientPaint(1, 1, UIConstants.SHADOW_GREY, 1, getHeight() - 1, UIConstants.SHADOW_GREY));
g2d.setPaint(new GradientPaint(1, 1, UIConstants.SHADOW_GREY, 1, getHeight() - 1.0F, UIConstants.SHADOW_GREY));
}

10
designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java

@ -11,6 +11,7 @@ import com.fr.stable.CoreConstants;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.authority.AuthorityOperator;
import com.fr.workspace.server.authority.decision.DecisionOperator;
import java.util.ArrayList;
@ -39,14 +40,15 @@ public class NodeAuthProcessor {
authPaths.clear();
if (!WorkContext.getCurrent().isLocal()) {
try {
String username = WorkContext.getCurrent().getConnection().getUserName();
// 远程设计获取全部设计成员的权限列表
DesignAuthority[] authorities = WorkContext.getCurrent().get(AuthorityOperator.class).getAuthorities();
String userName = WorkContext.getCurrent().getConnection().getUserName();
String userId = WorkContext.getCurrent().get(DecisionOperator.class).getUserIdByName(userName);
// 远程设计获取设计成员的权限列表
DesignAuthority[] authorities = WorkContext.getCurrent().get(AuthorityOperator.class).getAuthorities(userId);
DesignAuthority authority = null;
if (authorities != null) {
for (DesignAuthority designAuthority : authorities) {
if (ComparatorUtils.equals(designAuthority.getUsername(), username)) {
if (ComparatorUtils.equals(designAuthority.getUsername(), userName)) {
authority = designAuthority;
}
}

12
designer-base/src/main/java/com/fr/design/fun/ToolbarItemProvider.java

@ -1,6 +1,8 @@
package com.fr.design.fun;
import com.fr.design.mainframe.JTemplate;
import com.fr.form.ui.Widget;
import com.fr.stable.Filter;
import com.fr.stable.fun.mark.Mutable;
/**
@ -8,7 +10,7 @@ import com.fr.stable.fun.mark.Mutable;
* @since : 8.0
* 自定义web工具栏菜单
*/
public interface ToolbarItemProvider extends Mutable {
public interface ToolbarItemProvider extends Mutable, Filter<JTemplate> {
String XML_TAG = "ToolbarItemProvider";
@ -36,4 +38,12 @@ public interface ToolbarItemProvider extends Mutable {
*/
String nameForWidget();
/**
* 模板决策报表 or cpt是否支持此工具栏按钮
* JTemplate 模板
* @return 支持返回true, 否则false
*/
@Override
boolean accept(JTemplate template);
}

12
designer-base/src/main/java/com/fr/design/fun/impl/AbstractToolbarItem.java

@ -1,6 +1,9 @@
package com.fr.design.fun.impl;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fun.ToolbarItemProvider;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API;
@ -10,6 +13,7 @@ import com.fr.stable.fun.mark.API;
@API(level = ToolbarItemProvider.CURRENT_LEVEL)
public abstract class AbstractToolbarItem extends AbstractProvider implements ToolbarItemProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@ -18,4 +22,12 @@ public abstract class AbstractToolbarItem extends AbstractProvider implements To
public String mark4Provider() {
return getClass().getName();
}
@Override
public boolean accept(JTemplate jTemplate) {
if (jTemplate == null) {
jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
}
return jTemplate == null || jTemplate.isJWorkBook() || jTemplate instanceof JVirtualTemplate;
}
}

14
designer-base/src/main/java/com/fr/design/gui/borders/UIFrameBorder.java

@ -141,8 +141,8 @@ public class UIFrameBorder extends AbstractBorder implements UIResource {
int spread1 = ThemeUtils.FRAME_SPREAD_DARK_DISABLED;
int spread2 = ThemeUtils.FRAME_SPREAD_LIGHT_DISABLED;
int y2 = y;
Color borderColor = null;
drawFirstCaption(g, borderColor, spread1, spread2, x, y2, w);
Color borderColor = isActive ? ThemeUtils.FRAME_BORDER_COLOR : ThemeUtils.FRAME_BORDER_DISABLED_COLOR;
drawFirstCaption(g, borderColor, x, y2, w);
Color c2 = ColorRoutines.darken(c, 4 * spread1);
drawSecondCaption(g, c2, c, spread2, x, y2, w);
c2 = ColorRoutines.darken(c, 6 * spread1);
@ -257,14 +257,8 @@ public class UIFrameBorder extends AbstractBorder implements UIResource {
g.drawLine(x + w - 4, y2, x + w - 4, y2);
}
private void drawFirstCaption(Graphics g, Color borderColor, int spread1, int spread2, int x, int y2, int w) {
if (isActive) {
borderColor = ThemeUtils.FRAME_BORDER_COLOR;
spread1 = ThemeUtils.FRAME_SPREAD_DARK;
spread2 = ThemeUtils.FRAME_SPREAD_LIGHT;
} else {
borderColor = ThemeUtils.FRAME_BORDER_DISABLED_COLOR;
}
private void drawFirstCaption(Graphics g, Color borderColor, int x, int y2, int w) {
// always paint the semi-transparent parts
// 1
// blend

3
designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java

@ -1,7 +1,6 @@
package com.fr.design.gui.chart;
import com.fr.base.chart.BaseChartCollection;
import com.fr.chartx.attr.ChartProvider;
import com.fr.stable.core.PropertyChangeListener;
import javax.swing.JComponent;
@ -18,7 +17,5 @@ public abstract class MiddleChartComponent extends JComponent {
public abstract void reset();
public abstract ChartProvider getEditingChart();
public abstract void addStopEditingListener(PropertyChangeListener list);
}

6
designer-base/src/main/java/com/fr/design/gui/frpane/CommitTabbedPane.java

@ -296,7 +296,7 @@ public class CommitTabbedPane extends JComponent implements MouseListener, Mous
double[] x = {startX, startX, startX + tabWidth, startX + tabWidth, startX};
double[] y = {-1, getHeight(), getHeight(), -1, -1};
RoundRectangle2D.Double rect1 = new RoundRectangle2D.Double(startX, 1, this.getWidth(), this.getHeight(), 7, 7);
g2d.setPaint(new GradientPaint(1, 1, new Color(255, 255, 255), 1, getHeight() - 1, UIConstants.NORMAL_BACKGROUND));
g2d.setPaint(new GradientPaint(1, 1, new Color(255, 255, 255), 1, getHeight() - 1f, UIConstants.NORMAL_BACKGROUND));
GeneralPath generalPath = new GeneralPath(Path2D.WIND_EVEN_ODD, x.length);
generalPath.moveTo((float) x[0] + CORNOR_RADIUS, (float) y[0]);
@ -345,9 +345,9 @@ public class CommitTabbedPane extends JComponent implements MouseListener, Mous
double[] x = {startX, startX, startX + tabWidth, startX + tabWidth, startX};
double[] y = {-1, getHeight() - 1, getHeight() - 1, -1, -1};
if (selfIndex == mouseOveredIndex) {
g2d.setPaint(new GradientPaint(1, 1, new Color(255, 255, 255), 1, getHeight() - 1, UIConstants.NORMAL_BACKGROUND));
g2d.setPaint(new GradientPaint(1, 1, new Color(255, 255, 255), 1, getHeight() - 1f, UIConstants.NORMAL_BACKGROUND));
} else {
g2d.setPaint(new GradientPaint(1, 1, UIConstants.NORMAL_BACKGROUND, 1, getHeight() - 1, UIConstants.NORMAL_BACKGROUND));
g2d.setPaint(new GradientPaint(1, 1, UIConstants.NORMAL_BACKGROUND, 1, getHeight() - 1f, UIConstants.NORMAL_BACKGROUND));
}

6
designer-base/src/main/java/com/fr/design/gui/ibutton/UIBasicButtonUI.java

@ -321,9 +321,9 @@ public class UIBasicButtonUI extends MetalButtonUI {
//harry: 画带有高光的按钮。
private void drawHighLightButton(Graphics2D g2, Color color1, Color color2, int w, int h) {
GradientPaint buttonPaint = new GradientPaint(0, 0, color1, 0, h - 1, color2);
GradientPaint buttonHighLightPaint = new GradientPaint(0, 0, new Color(1.0f, 1.0f, 1.0f, 0.6f), 0, h / 2, new Color(1.0f, 1.0f, 1.0f, 0.2f));
GradientPaint buttonHighLightLinePaint = new GradientPaint(1, 1, new Color(1.0f, 1.0f, 1.0f, 0.8f), 0, h / 2, new Color(1.0f, 1.0f, 1.0f, 0.4f));
GradientPaint buttonPaint = new GradientPaint(0, 0, color1, 0, h - 1f, color2);
GradientPaint buttonHighLightPaint = new GradientPaint(0, 0, new Color(1.0f, 1.0f, 1.0f, 0.6f), 0, h / 2f, new Color(1.0f, 1.0f, 1.0f, 0.2f));
GradientPaint buttonHighLightLinePaint = new GradientPaint(1, 1, new Color(1.0f, 1.0f, 1.0f, 0.8f), 0, h / 2f, new Color(1.0f, 1.0f, 1.0f, 0.4f));
g2.setPaint(buttonPaint);
g2.fillRoundRect(0, 0, w - 1, h - 1, 3, 3);
g2.setPaint(buttonHighLightLinePaint);//按钮内侧高光线(内发光,0%阻塞)

2
designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java

@ -251,7 +251,7 @@ public class UIButton extends JButton implements UIObserver, UITextComponent {
protected void paintOtherBorder(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.setStroke(borderStroke);
Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1, getHeight() - 1, UIConstants.ARC, UIConstants.ARC);
Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1f, getHeight() - 1f, UIConstants.ARC, UIConstants.ARC);
g2d.setColor(borderColor);
g2d.draw(shape);
}

2
designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButton.java

@ -232,7 +232,7 @@ public class UISliderButton extends JButton implements UIObserver {
protected void paintOtherBorder(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.setStroke(borderStroke);
Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1, getHeight() - 1, UIConstants.ARC, UIConstants.ARC);
Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1f, getHeight() - 1f, UIConstants.ARC, UIConstants.ARC);
g2d.setColor(borderColor);
g2d.draw(shape);
}

2
designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButtonUI.java

@ -176,7 +176,7 @@ public class UISliderButtonUI extends BasicButtonUI {
private void fillNormal(Graphics2D g2d, int x, int y, int width, int height, boolean isRound, int rectDirection, boolean isAuthorityEdited, boolean isPressedPainted) {
GradientPaint gp;
if (DesignerMode.isAuthorityEditing() && isAuthorityEdited) {
gp = new GradientPaint(1, 1, UIConstants.AUTHORITY_BLUE, 1, height - 1, UIConstants.AUTHORITY_DARK_BLUE);
gp = new GradientPaint(1, 1, UIConstants.AUTHORITY_BLUE, 1, height - 1f, UIConstants.AUTHORITY_DARK_BLUE);
} else if (isPressedPainted) {
gp = new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, height - 1, UIConstants.SELECT_TAB);
}else{

12
designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java

@ -6,7 +6,6 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
@ -47,6 +46,7 @@ public class ProgressDialog extends UIDialog {
progressBar.setBorderPainted(false);
progressBar.setOpaque(false);
progressBar.setBorder(null);
progressBar.setMaximum(1000);
panel.add(progressBar, BorderLayout.CENTER);
text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Project"), JLabel.CENTER);
FRFont font = FRFont.getInstance().applySize(14).applyForeground(new ColorUIResource(333334));
@ -54,7 +54,6 @@ public class ProgressDialog extends UIDialog {
panel.add(text, BorderLayout.SOUTH);
panel.setVisible(true);
centerDialog.getContentPane().add(panel);
}
@Override
@ -72,11 +71,20 @@ public class ProgressDialog extends UIDialog {
progressBar.setValue(value);
}
public void setProgressMaximum(int value) {
progressBar.setMaximum(value);
}
public int getProgressMaximum() {
return progressBar.getMaximum();
}
@Override
public void dispose() {
centerDialog.dispose();
super.dispose();
}
public void updateLoadingText(String text) {
this.text.setText(text);
}

4
designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java

@ -1326,9 +1326,9 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
newModel.addChangeListener(modelListener);
scrollbar.repaint();
scrollbar.revalidate();
} else if ("orientation" == propertyName) {
} else if (StringUtils.equals("orientation", propertyName)) {
updateButtonDirections();
} else if ("componentOrientation" == propertyName) {
} else if (StringUtils.equals("componentOrientation", propertyName)) {
updateButtonDirections();
InputMap inputMap = getInputMap(JComponent.WHEN_FOCUSED);
SwingUtilities.replaceUIInputMap(scrollbar, JComponent.WHEN_FOCUSED, inputMap);

6
designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java

@ -9,9 +9,11 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.stable.CommonUtils;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import com.fr.stable.collections.utils.MathUtils;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@ -109,7 +111,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
}
value = value < minValue ? minValue : value;
value = value > maxValue ? maxValue : value;
if (value == this.value) {
if (CommonUtils.equals(value, this.value)) {
return;
}
this.value = value;
@ -132,7 +134,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
value = value < minValue ? minValue : value;
value = value > maxValue ? maxValue : value;
if (value == this.value) {
if (CommonUtils.equals(value, this.value)) {
return;
}
this.value = value;

43
designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java

@ -3,6 +3,9 @@ package com.fr.design.gui.ispinner;
import com.fr.design.gui.itextfield.UIIntNumberField;
import com.fr.design.gui.itextfield.UINumberField;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
/**
* Created by IntelliJ IDEA.
* Author : Hugh.C
@ -11,21 +14,59 @@ import com.fr.design.gui.itextfield.UINumberField;
*/
public class UnsignedIntUISpinner extends UISpinner {
private double minValue;
private double maxValue;
public UnsignedIntUISpinner(double minValue, double maxValue, double dierta) {
super(minValue, maxValue, dierta);
this.minValue = minValue;
this.maxValue = maxValue;
}
public UnsignedIntUISpinner(double minValue, double maxValue, double dierta, double defaultValue) {
super(minValue, maxValue, dierta, defaultValue);
this.minValue = minValue;
this.maxValue = maxValue;
}
@Override
protected UINumberField initNumberField() {
return new UIIntNumberField() {
final UIIntNumberField numberField = new UIIntNumberField() {
public boolean shouldResponseChangeListener() {
return false;
}
public NumberDocument createNumberDocument() {
return new NumberDocument() {
public boolean isContinueInsertWhenOverMaxOrMinValue() {
return true;
}
};
}
};
numberField.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
/**
* 失去焦点后再做范围限制不然最小值为 100 输个 1 都不让....
* @param e
*/
@Override
public void focusLost(FocusEvent e) {
double value = numberField.getValue();
if (!isOverMaxOrMinValue(value)) {
return;
}
numberField.setValue(value < minValue ? minValue : maxValue);
}
private boolean isOverMaxOrMinValue(double value) {
return value < minValue || value > maxValue;
}
});
return numberField;
}
}

26
designer-base/src/main/java/com/fr/design/gui/itextfield/UIIntNumberField.java

@ -1,11 +1,10 @@
package com.fr.design.gui.itextfield;
import com.fr.design.gui.itextfield.UINumberField;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
import java.awt.*;
import java.awt.Toolkit;
/**
* Created with IntelliJ IDEA.
@ -15,11 +14,11 @@ import java.awt.*;
* To change this template use File | Settings | File Templates.
*/
public class UIIntNumberField extends UINumberField {
public void setFieldDocument(){
setDocument(new NumberDocument());
public void setFieldDocument() {
setDocument(createNumberDocument());
}
class NumberDocument extends PlainDocument {
public class NumberDocument extends PlainDocument {
public NumberDocument() {
}
@ -33,17 +32,30 @@ public class UIIntNumberField extends UINumberField {
String strNew = str.substring(0, offset) + s + str.substring(offset, getLength());
if (isOverMaxOrMinValue(strNew)) {
if (isOverMaxOrMinValue(strNew) && !isContinueInsertWhenOverMaxOrMinValue()) {
Toolkit.getDefaultToolkit().beep();
return;
}
setisContentChanged(true);
setisContentChanged(true);
super.insertString(offset, s, a);
}
/**
* 是否继续插入输入的字符 - 当超出范围时
*
* @return true : 继续插入输入的字符
*/
public boolean isContinueInsertWhenOverMaxOrMinValue() {
return false;
}
private boolean isOverMaxOrMinValue( String strNew) {
return (Double.parseDouble(strNew)<getMinValue() || Double.parseDouble(strNew)>getMaxValue());
}
}
public NumberDocument createNumberDocument() {
return new NumberDocument();
}
}

8
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxTextArea.java

@ -3016,11 +3016,6 @@ private boolean fractionalFontMetricsEnabled;
return he;
}
private final boolean equal(LinkGeneratorResult e1,
LinkGeneratorResult e2) {
return e1.getSourceOffset()==e2.getSourceOffset();
}
@Override
public void mouseClicked(MouseEvent e) {
if (getHyperlinksEnabled() && isScanningForLinks &&
@ -3080,8 +3075,7 @@ private boolean fractionalFontMetricsEnabled;
isLinkAtOffset(RSyntaxTextArea.this, offs);
if (newResult!=null) {
// Repaint if we're at a new link now.
if (linkGeneratorResult==null ||
!equal(newResult, linkGeneratorResult)) {
if (linkGeneratorResult==null || newResult.getSourceOffset() != linkGeneratorResult.getSourceOffset()) {
repaint();
}
linkGeneratorResult = newResult;

15
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/Style.java

@ -9,6 +9,7 @@
*/
package com.fr.design.gui.syntax.ui.rsyntaxtextarea;
import com.fr.log.FineLoggerFactory;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
@ -123,15 +124,15 @@ public class Style implements Cloneable {
Style clone = null;
try {
clone = (Style)super.clone();
clone.foreground = foreground;
clone.background = background;
clone.font = font;
clone.underline = underline;
clone.fontMetrics = fontMetrics;
} catch (CloneNotSupportedException cnse) { // Never happens
cnse.printStackTrace();
return null;
FineLoggerFactory.getLogger().error(cnse.getMessage(), cnse);
clone = null;
}
clone.foreground = foreground;
clone.background = background;
clone.font = font;
clone.underline = underline;
clone.fontMetrics = fontMetrics;
return clone;
}

21
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxScheme.java

@ -9,6 +9,7 @@
*/
package com.fr.design.gui.syntax.ui.rsyntaxtextarea;
import com.fr.log.FineLoggerFactory;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
@ -121,17 +122,17 @@ public class SyntaxScheme implements Cloneable, TokenTypes {
public Object clone() {
SyntaxScheme shcs = null;
try {
shcs = (SyntaxScheme)super.clone();
} catch (CloneNotSupportedException cnse) { // Never happens
cnse.printStackTrace();
return null;
}
shcs.styles = new Style[styles.length];
for (int i=0; i<styles.length; i++) {
Style s = styles[i];
if (s!=null) {
shcs.styles[i] = (Style)s.clone();
shcs = (SyntaxScheme) super.clone();
shcs.styles = new Style[styles.length];
for (int i = 0; i < styles.length; i++) {
Style s = styles[i];
if (s != null) {
shcs.styles[i] = (Style) s.clone();
}
}
} catch (CloneNotSupportedException cnse) { // Never happens
FineLoggerFactory.getLogger().error(cnse.getMessage(), cnse);
shcs = null;
}
return shcs;
}

2
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/folding/HtmlFoldParser.java

@ -149,7 +149,7 @@ public class HtmlFoldParser implements FoldParser {
}
// ?> or %>
else if (t.startsWith(LANG_END[language])) {
else if (currentFold != null && t.startsWith(LANG_END[language])) {
int phpEnd = t.getEndOffset() - 1;
currentFold.setEndOffset(phpEnd);
Fold parentFold = currentFold.getParent();

3657
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/FormulaTokenMaker.java

File diff suppressed because it is too large Load Diff

11
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/MakefileTokenMaker.java

@ -10,12 +10,13 @@
*/
package com.fr.design.gui.syntax.ui.rsyntaxtextarea.modes;
import java.io.*;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.AbstractJFlexTokenMaker;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.Token;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.TokenImpl;
import java.io.IOException;
import java.util.Stack;
import javax.swing.text.Segment;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.*;
/**
* Scanner for makefiles.<p>
@ -763,7 +764,7 @@ public final void yybegin(int newState) {
}
case 25: break;
case 12:
{ if (!varDepths.empty() && varDepths.peek()==Boolean.TRUE) {
{ if (!varDepths.empty() && Boolean.TRUE.equals(varDepths.peek())) {
varDepths.pop();
if (varDepths.empty()) {
addToken(start,zzStartRead, Token.VARIABLE); yybegin(YYINITIAL);
@ -772,7 +773,7 @@ public final void yybegin(int newState) {
}
case 26: break;
case 11:
{ if (!varDepths.empty() && varDepths.peek()==Boolean.FALSE) {
{ if (!varDepths.empty() && Boolean.FALSE.equals(varDepths.peek())) {
varDepths.pop();
if (varDepths.empty()) {
addToken(start,zzStartRead, Token.VARIABLE); yybegin(YYINITIAL);

36
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaBase.java

@ -723,37 +723,13 @@ int currentCaretY; // Used to know when to rehighlight current line.
// If we're wrapping lines we need to check the actual y-coordinate
// of the caret, not just the line number, since a single logical
// line can span multiple physical lines.
if (getLineWrap()) {
try {
Rectangle temp = modelToView(dot);
if (temp!=null) {
currentCaretY = temp.y;
}
} catch (BadLocationException ble) {
ble.printStackTrace(); // Should never happen.
try {
Rectangle temp = modelToView(dot);
if (temp != null) {
currentCaretY = temp.y;
}
}
// No line wrap - we can simply check the line number (quicker).
else {
// Document doc = getDocument();
// if (doc!=null) {
// Element map = doc.getDefaultRootElement();
// int caretLine = map.getElementIndex(dot);
// Rectangle alloc = ((RTextAreaUI)getUI()).
// getVisibleEditorRect();
// if (alloc!=null)
// currentCaretY = alloc.y + caretLine*lineHeight;
// }
// Modified for code folding requirements
try {
Rectangle temp = modelToView(dot);
if (temp!=null) {
currentCaretY = temp.y;
}
} catch (BadLocationException ble) {
ble.printStackTrace(); // Should never happen.
}
} catch (BadLocationException ble) {
ble.printStackTrace(); // Should never happen.
}
// Repaint current line (to fill in entire highlight), and old line

3
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/SearchEngine.java

@ -25,6 +25,7 @@ import javax.swing.text.Caret;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.DocumentRange;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager;
import org.jetbrains.annotations.NotNull;
/**
@ -174,6 +175,7 @@ public class SearchEngine {
* @param forward Whether we're searching forward or backward.
* @return The character sequence.
*/
@NotNull
private static CharSequence getFindInCharSequence(RTextArea textArea,
int start, boolean forward) {
RDocument doc = (RDocument)textArea.getDocument();
@ -752,7 +754,6 @@ public class SearchEngine {
int start = makeMarkAndDotEqual(textArea, forward);
CharSequence findIn = getFindInCharSequence(textArea, start, forward);
if (findIn==null) return new SearchResult();
int markAllCount = 0;
if (context.getMarkAll()) {

5
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/VolatileImageBackgroundPainterStrategy.java

@ -103,6 +103,9 @@ public class VolatileImageBackgroundPainterStrategy
} finally {
tracker.removeImage(i, 1);
}
if(bgImage == null) {
continue;
}
bgImage.getGraphics().drawImage(i, 0,0, null);
tracker.addImage(bgImage, 0);
try {
@ -114,7 +117,7 @@ public class VolatileImageBackgroundPainterStrategy
} finally {
tracker.removeImage(bgImage, 0);
}
} while (bgImage.contentsLost());
} while (bgImage != null && bgImage.contentsLost());
} // End of if (master!=null).
else {
bgImage = null;

9
designer-base/src/main/java/com/fr/design/icon/BorderIcon.java

@ -1,5 +1,6 @@
package com.fr.design.icon;
import com.fr.stable.AssistUtils;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
@ -43,13 +44,13 @@ public class BorderIcon implements Icon {
if (lineStyle == Constants.LINE_MEDIUM
|| lineStyle == Constants.LINE_THICK) {
lineStyle = Constants.LINE_MEDIUM;
if (x1 == x2) {
if (x1 == y1) {
if (AssistUtils.equals(x1, x2)) {
if (AssistUtils.equals(x1, y1)) {
GraphHelper.drawLine(g, x1, y1 - 1, x2, y2 + 1, lineStyle);
} else {
GraphHelper.drawLine(g, x1, y1, x2, y2 + 1, lineStyle);
}
} else if (y1 == y2) {
} else if (AssistUtils.equals(y1, y2)) {
GraphHelper.drawLine(g, x1, y1, x2 + 1, y2, lineStyle);
}
} else if (lineStyle == Constants.LINE_THIN
@ -57,7 +58,7 @@ public class BorderIcon implements Icon {
GraphHelper.drawLine(g, x1, y1, x2, y2, lineStyle);
} else {
lineStyle = Constants.LINE_DOT;
if (y1 == x2 && x2 == y2) {
if (AssistUtils.equals(y1, x2) && AssistUtils.equals(x2, y2)) {
GraphHelper.drawLine(g, x1, y1, x2 + 1, y2, lineStyle);
} else {
GraphHelper.drawLine(g, x1, y1, x2, y2, lineStyle);

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

@ -35,7 +35,7 @@ public class LockIcon extends ImageIcon {
}
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
if (mainImage != null) {
g.drawImage(mainImage, x, y, c);
}

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

@ -37,7 +37,7 @@ public class WarningIcon extends ImageIcon {
}
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
public synchronized void paintIcon(Component c, Graphics g, int x, int y) {
if (mainImage != null) {
g.drawImage(mainImage, x, y, c);
}

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

@ -3,6 +3,7 @@ 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;
@ -562,9 +563,9 @@ public class FRGUIPaneFactory {
float i = Math.abs((((int) m + (int) (m + 1)) / WIDTHABS_PARA_F) - m);
float j = Math.abs((((int) n + (int) (n + 1)) / WIDTHABS_PARA_F) - n);
float x = i > j ? i : j;
if (x == i) {
if (AssistUtils.equals(x, i)) {
w = Math.round(m) * WIDTH_PARA_INT - WIDTH_OFFSET_M;
} else if (x == j) {
} else if (AssistUtils.equals(x, j)) {
w = Math.round(n) * WIDTH_PARA_INT - WIDTH_OFFSET_N;
}
return w;

82
designer-base/src/main/java/com/fr/design/layout/TableLayout.java

@ -1,6 +1,9 @@
package com.fr.design.layout;
import com.fr.stable.AssistUtils;
import com.fr.general.GeneralUtils;
import com.fr.stable.CommonUtils;
import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.Container;
@ -12,8 +15,6 @@ import java.lang.reflect.Method;
import java.util.LinkedList;
import java.util.ListIterator;
import com.fr.general.GeneralUtils;
/**
* <p>TableLayout is a layout manager that is more powerful than GridBagLayout
@ -322,7 +323,6 @@ public class TableLayout implements LayoutManager2, Serializable {
public static final double MINIMUM = -3.0;
//******************************************************************************
//** Constructors ***
//******************************************************************************
@ -399,17 +399,17 @@ public class TableLayout implements LayoutManager2, Serializable {
// Make sure rows and columns are valid
for (int counter = 0; counter < crSpec[C].length; counter++)
if ((crSpec[C][counter] < 0.0) &&
(crSpec[C][counter] != FILL) &&
(crSpec[C][counter] != PREFERRED) &&
(crSpec[C][counter] != MINIMUM)) {
!AssistUtils.equals(crSpec[C][counter], FILL) &&
!AssistUtils.equals(crSpec[C][counter], PREFERRED) &&
!AssistUtils.equals(crSpec[C][counter], MINIMUM)) {
crSpec[C][counter] = 0.0;
}
for (int counter = 0; counter < crSpec[R].length; counter++)
if ((crSpec[R][counter] < 0.0) &&
(crSpec[R][counter] != FILL) &&
(crSpec[R][counter] != PREFERRED) &&
(crSpec[R][counter] != MINIMUM)) {
!AssistUtils.equals(crSpec[R][counter], FILL) &&
!AssistUtils.equals(crSpec[R][counter], PREFERRED) &&
!AssistUtils.equals(crSpec[R][counter], MINIMUM)) {
crSpec[R][counter] = 0.0;
}
@ -556,9 +556,9 @@ public class TableLayout implements LayoutManager2, Serializable {
// Make sure rows are valid
for (int counter = 0; counter < crSpec[z].length; counter++)
if ((crSpec[z][counter] < 0.0) &&
(crSpec[z][counter] != FILL) &&
(crSpec[z][counter] != PREFERRED) &&
(crSpec[z][counter] != MINIMUM)) {
!AssistUtils.equals(crSpec[z][counter], FILL) &&
!AssistUtils.equals(crSpec[z][counter], PREFERRED) &&
!AssistUtils.equals(crSpec[z][counter], MINIMUM)) {
crSpec[z][counter] = 0.0;
}
@ -641,9 +641,9 @@ public class TableLayout implements LayoutManager2, Serializable {
protected void setCr(int z, int i, double size) {
// Make sure size is valid
if ((size < 0.0) &&
(size != FILL) &&
(size != PREFERRED) &&
(size != MINIMUM)) {
!AssistUtils.equals(size, FILL) &&
!AssistUtils.equals(size, PREFERRED) &&
!AssistUtils.equals(size, MINIMUM)) {
size = 0.0;
}
@ -853,9 +853,9 @@ public class TableLayout implements LayoutManager2, Serializable {
// Make sure row size is valid
if ((size < 0.0) &&
(size != FILL) &&
(size != PREFERRED) &&
(size != MINIMUM)) {
(!CommonUtils.equals(size, FILL)) &&
(!CommonUtils.equals(size, PREFERRED)) &&
(!CommonUtils.equals(size, MINIMUM))) {
size = 0.0;
}
@ -1177,7 +1177,7 @@ public class TableLayout implements LayoutManager2, Serializable {
int numCr = crSpec[z].length;
for (int counter = 0; counter < numCr; counter++)
if ((crSpec[z][counter] >= 1.0) || (crSpec[z][counter] == 0.0)) {
if ((crSpec[z][counter] >= 1.0) || CommonUtils.equals(crSpec[z][counter], 0.0)) {
crSize[z][counter] = (int) (crSpec[z][counter] + 0.5);
availableSize -= crSize[z][counter];
}
@ -1229,7 +1229,7 @@ public class TableLayout implements LayoutManager2, Serializable {
int numCr = crSpec[z].length;
for (int counter = 0; counter < numCr; counter++)
if (crSpec[z][counter] == FILL)
if (CommonUtils.equals(crSpec[z][counter], FILL))
numFillSize++;
// If numFillSize is zero, the if statement below will always evaluate to
@ -1241,7 +1241,7 @@ public class TableLayout implements LayoutManager2, Serializable {
// Assign "fill" cells equal amounts of the remaining space
for (int counter = 0; counter < numCr; counter++)
if (crSpec[z][counter] == FILL) {
if (CommonUtils.equals(crSpec[z][counter], FILL)) {
crSize[z][counter] = availableSize / numFillSize;
slackSize -= crSize[z][counter];
}
@ -1249,7 +1249,7 @@ public class TableLayout implements LayoutManager2, Serializable {
// Assign one pixel of slack to each FILL cr, starting at the last one,
// until all slack has been consumed
for (int counter = numCr - 1; (counter >= 0) && (slackSize > 0); counter--) {
if (crSpec[z][counter] == FILL) {
if (CommonUtils.equals(crSpec[z][counter], FILL)) {
crSize[z][counter]++;
slackSize--;
}
@ -1299,7 +1299,7 @@ public class TableLayout implements LayoutManager2, Serializable {
// Address every cr
for (int counter = 0; counter < numCr; counter++)
// Is the current cr a preferred/minimum (based on typeOfSize) size
if (crSpec[z][counter] == typeOfSize) {
if (CommonUtils.equals(crSpec[z][counter], typeOfSize)) {
// Assume a maximum width of zero
int maxSize = 0;
@ -1319,7 +1319,7 @@ public class TableLayout implements LayoutManager2, Serializable {
// the current component occupies
if ((entry.cr1[z] <= counter) && (entry.cr2[z] >= counter)) {
// Setup size and number of adjustable crs
Dimension p = (typeOfSize == PREFERRED) ?
Dimension p = CommonUtils.equals(typeOfSize, PREFERRED) ?
entry.component.getPreferredSize() :
entry.component.getMinimumSize();
@ -1328,23 +1328,23 @@ public class TableLayout implements LayoutManager2, Serializable {
int numAdjustable = 0;
// Calculate for preferred size
if (typeOfSize == PREFERRED)
if (CommonUtils.equals(typeOfSize, PREFERRED))
// Consider all crs this component occupies
for (int entryCr = entry.cr1[z];
entryCr <= entry.cr2[z]; entryCr++) {
// Subtract absolute, relative, and minumum cr
// sizes, which have already been calculated
if ((crSpec[z][entryCr] >= 0.0) ||
(crSpec[z][entryCr] == MINIMUM)) {
CommonUtils.equals(crSpec[z][entryCr], MINIMUM)) {
size -= crSize[z][entryCr];
}
// Count preferred/min width columns
else if (crSpec[z][entryCr] == PREFERRED)
else if (CommonUtils.equals(crSpec[z][entryCr], PREFERRED))
numAdjustable++;
// Skip any component that occupies a fill cr
// because the fill should fulfill the size
// requirements
else if (crSpec[z][entryCr] == FILL)
// Skip any component that occupies a fill cr
// because the fill should fulfill the size
// requirements
else if (CommonUtils.equals(crSpec[z][entryCr], FILL))
continue nextComponent;
}
// Calculate for minimum size
@ -1357,14 +1357,14 @@ public class TableLayout implements LayoutManager2, Serializable {
if (crSpec[z][entryCr] >= 0.0)
size -= crSize[z][entryCr];
// Count preferred/min width columns
else if ((crSpec[z][entryCr] == PREFERRED) ||
(crSpec[z][entryCr] == MINIMUM)) {
else if (CommonUtils.equals(crSpec[z][entryCr], PREFERRED) ||
CommonUtils.equals(crSpec[z][entryCr], MINIMUM)) {
numAdjustable++;
}
// Skip any component that occupies a fill cr
// because the fill should fulfill the size
// requirements
else if (crSpec[z][entryCr] == FILL)
else if (CommonUtils.equals(crSpec[z][entryCr], FILL))
continue nextComponent;
}
@ -1692,7 +1692,7 @@ public class TableLayout implements LayoutManager2, Serializable {
Dimension prefMinSize[] = new Dimension[numEntry];
for (int i = 0; i < numEntry; i++)
prefMinSize[i] = (typeOfSize == PREFERRED) ?
prefMinSize[i] = CommonUtils.equals(typeOfSize, PREFERRED) ?
entryList[i].component.getPreferredSize() :
entryList[i].component.getMinimumSize();
@ -1807,8 +1807,8 @@ public class TableLayout implements LayoutManager2, Serializable {
for (counter = entry.cr1[z]; counter <= entry.cr2[z]; counter++)
if (crSpec[z][counter] >= 1.0)
scalableSize -= crSpec[z][counter];
else if ((crSpec[z][counter] == PREFERRED) ||
(crSpec[z][counter] == MINIMUM)) {
else if (AssistUtils.equals(crSpec[z][counter], PREFERRED) ||
AssistUtils.equals(crSpec[z][counter], MINIMUM)) {
scalableSize -= crPrefMin[counter];
}
@ -1824,13 +1824,13 @@ public class TableLayout implements LayoutManager2, Serializable {
// Add scaled size to relativeWidth
relativeSize += crSpec[z][counter];
// Cr is fill
else if ((crSpec[z][counter] == FILL) && (fillSizeRatio != 0.0))
else if (AssistUtils.equals(crSpec[z][counter], FILL) && !AssistUtils.equals(fillSizeRatio, 0.0))
// Add fill size to relativeWidth
relativeSize += fillSizeRatio;
}
// Determine the total scaled size as estimated by this component
if (relativeSize == 0)
if (AssistUtils.equals(relativeSize, 0))
temp = 0;
else
temp = (int) (scalableSize / relativeSize + 0.5);
@ -1851,8 +1851,8 @@ public class TableLayout implements LayoutManager2, Serializable {
if (crSpec[z][counter] >= 1.0)
totalSize += (int) (crSpec[z][counter] + 0.5);
// Is the current cr a preferred/minimum size
else if ((crSpec[z][counter] == PREFERRED) ||
(crSpec[z][counter] == MINIMUM)) {
else if (AssistUtils.equals(crSpec[z][counter], PREFERRED) ||
AssistUtils.equals(crSpec[z][counter], MINIMUM)) {
// Add preferred/minimum width
totalSize += crPrefMin[counter];
}

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

@ -63,6 +63,7 @@ import com.fr.start.OemHandler;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import org.jetbrains.annotations.Nullable;
import javax.swing.Icon;
import javax.swing.JComponent;
@ -169,6 +170,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private WindowAdapter windowAdapter = new WindowAdapter() {
@Override
public void windowOpened(WindowEvent e) {
}
@ -194,6 +196,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private JComponent closeButton = new JComponent() {
@Override
protected void paintComponent(Graphics g) {
g.setColor(UIConstants.NORMAL_BACKGROUND);
@ -205,6 +208,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private MouseListener closeMouseListener = new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
closeMode = UIConstants.CLOSE_PRESS_AUTHORITY;
@ -212,6 +216,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
closeButton.repaint();
}
@Override
public void mouseExited(MouseEvent e) {
closeMode = UIConstants.CLOSE_OF_AUTHORITY;
@ -219,6 +224,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
closeButton.repaint();
}
@Override
public void mouseMoved(MouseEvent e) {
closeMode = UIConstants.CLOSE_OVER_AUTHORITY;
@ -226,12 +232,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
closeButton.repaint();
}
@Override
public void mouseReleased(MouseEvent e) {
if (DesignModeContext.isAuthorityEditing()) {
closeAuthorityEditing();
}
}
@Override
public void mouseEntered(MouseEvent e) {
closeMode = UIConstants.CLOSE_OVER_AUTHORITY;
@ -255,6 +263,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
basePane.setLayout(new BorderLayout());
toolbarPane = new JPanel() {
@Override
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
@ -266,7 +275,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
JPanel eastPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
eastPane.add(ad.createLargeToolbar(), BorderLayout.WEST);
eastCenterPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
eastCenterPane.add(combineUp = combineUpTooBar(null), BorderLayout.NORTH);
combineUpTooBar();
eastCenterPane.add(combineUp, BorderLayout.NORTH);
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.add(newWorkBookPane = ad.getNewTemplatePane(), BorderLayout.WEST);
panel.add(MutilTempalteTabPane.getInstance(), BorderLayout.CENTER);
@ -300,6 +310,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
this.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
reCalculateFrameSize();
@ -333,7 +344,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getToolBarMenuDockPlus());
needToAddAuhtorityPaint();
refreshDottedLine();
fireAuthorityStateToNomal();
fireAuthorityStateToNormal();
EventDispatcher.fire(DesignAuthorityEventType.StopEdit, DesignerFrame.this);
}
@ -603,13 +614,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
/**
* 退出权限编辑时将所有的做过权限编辑的状态作为一个状态赋给报报表主体
*/
private void fireAuthorityStateToNomal() {
private void fireAuthorityStateToNormal() {
java.util.List<JTemplate<?, ?>> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList();
for (int i = 0; i < opendedTemplate.size(); i++) {
for (JTemplate<?, ?> jTemplate : opendedTemplate) {
// 如果在权限编辑时做过操作,则将做过的操作作为一个整体状态赋给正在报表
if (opendedTemplate.get(i).isDoSomethingInAuthority()) {
opendedTemplate.get(i).fireAuthorityStateToNomal();
if (jTemplate.isDoSomethingInAuthority()) {
jTemplate.fireAuthorityStateToNomal();
}
}
}
@ -619,31 +630,47 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
this.closeMode = closeMode;
}
private UIToolbar combineUpTooBar(JComponent[] toolbar4Form) {
/**
* 创建上工具栏
*/
private void combineUpTooBar() {
combineUp = new UIToolbar(FlowLayout.LEFT);
combineUp.setBorder(new MatteBorder(new Insets(0, LEFT_ALIGN_GAP, 1, 0), UIConstants.LINE_COLOR));
combineUp.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 2));
setUpUpToolBar(null);
}
/**
* 重置上工具栏
*/
private void resetCombineUpTooBar(JComponent[] toolbar4Form) {
combineUp.removeAll();
setUpUpToolBar(toolbar4Form);
}
/**
* 填充上工具栏的中的工具
*
* @param toolbar4Form 目标组件
*/
private void setUpUpToolBar(@Nullable JComponent[] toolbar4Form) {
UIButton[] fixButtons = ad.createUp();
for (int i = 0; i < fixButtons.length; i++) {
combineUp.add(fixButtons[i]);
for (UIButton fixButton : fixButtons) {
combineUp.add(fixButton);
}
if (!DesignerMode.isAuthorityEditing()) {
combineUp.addSeparator(new Dimension(2, 16));
if (toolbar4Form != null) {
for (int i = 0; i < toolbar4Form.length; i++) {
combineUp.add(toolbar4Form[i]);
for (JComponent jComponent : toolbar4Form) {
combineUp.add(jComponent);
}
}
}
//添加分享按钮
addShareButton();
//添加插件中的按钮
addExtraButtons();
return combineUp;
}
private void addExtraButtons() {
@ -655,8 +682,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
UIButton[] extraButtons = jt.createExtraButtons();
for (int i = 0; i < extraButtons.length; i++) {
combineUp.add(extraButtons[i]);
for (UIButton extraButton : extraButtons) {
combineUp.add(extraButton);
}
if (extraButtons.length > 0) {
combineUp.addSeparator(new Dimension(2, 16));
@ -672,8 +699,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
combineUp.addSeparator(new Dimension(2, 16));
UIButton[] shareButtons = jt.createShareButton();
for (int i = 0; i < shareButtons.length; i++) {
combineUp.add(shareButtons[i]);
for (UIButton shareButton : shareButtons) {
combineUp.add(shareButton);
}
}
@ -710,25 +737,20 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
DesignState designState = new DesignState(plus);
MenuManager.getInstance().setMenus4Designer(designState);
if (menuBar != null) {
menuPane.remove(menuBar);
}
menuPane.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER);
if (combineUp != null) {
eastCenterPane.remove(combineUp);
combineUp = null;
if (menuBar == null) {
menuPane.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER);
} else {
ad.resetJMenuBar(menuBar, plus);
}
// 保存撤销那些按钮的面板
eastCenterPane.add(combineUp = combineUpTooBar(ad.resetUpToolBar(plus)), BorderLayout.NORTH);
if (toolbarComponent != null) {
toolbarPane.remove(toolbarComponent);
}
resetCombineUpTooBar(ad.resetUpToolBar(plus));
// 颜色,字体那些按钮的工具栏
toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER);
if (toolbarComponent == null) {
toolbarPane.add(toolbarComponent = ad.resetToolBar(null, plus), BorderLayout.CENTER);
} else {
ad.resetToolBar(toolbarComponent, plus);
}
this.checkToolbarMenuEnable();
this.validate();
@ -751,7 +773,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts();
for (ShortCut shortCut : extraShortCuts) {
if (shortCut instanceof AbstractTemplateTreeShortCutProvider) {
((AbstractTemplateTreeShortCutProvider) shortCut).notifyFromAuhtorityChange(DesignerMode.isAuthorityEditing());
shortCut.notifyFromAuhtorityChange(DesignerMode.isAuthorityEditing());
}
}
}
@ -949,6 +971,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*
* @param e 事件
*/
@Override
public void targetModified(TargetModifiedEvent e) {
this.checkToolbarMenuEnable();
@ -959,6 +982,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*
* @param jt 模板
*/
@Override
public void templateClosed(JTemplate<?, ?> jt) {
}
@ -968,6 +992,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*
* @param jt 模板
*/
@Override
public void templateOpened(JTemplate<?, ?> jt) {
}
@ -977,6 +1002,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*
* @param jt 模板
*/
@Override
public void templateSaved(JTemplate<?, ?> jt) {
this.checkToolbarMenuEnable();

14
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -210,15 +210,17 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
/**
* 添加VcsAction
*
* @param toolbarDef
*/
private void addVcsAction(ToolBarDef toolbarDef) {
if (VcsHelper.getInstance().needInit()) {
vcsAction = new VcsAction();
if (FineClusterConfig.getInstance().isCluster()) {
vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_NotSupportRemote"));
} else {
if (WorkContext.getCurrent().isLocal()) {
vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_Title"));
} else {
vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_NotSupportRemote"));
}
toolbarDef.addShortCut(vcsAction);
@ -367,8 +369,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
if (WorkContext.getCurrent() != null) {
if (!WorkContext.getCurrent().isLocal()) {
//当前环境为远程环境时
@ -532,7 +532,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
String oldName = fnf.getName();
String suffix = fnf.isDirectory() ? StringUtils.EMPTY : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replace(suffix, StringUtils.EMPTY);
oldName = StringUtils.replaceLast(oldName, suffix, StringUtils.EMPTY);
this.setLayout(new BorderLayout());
this.setModal(true);
@ -651,7 +651,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
String oldName = fnf.getName();
String suffix = fnf.isDirectory() ? StringUtils.EMPTY : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, StringUtils.EMPTY);
oldName = StringUtils.replaceLast(oldName, suffix, StringUtils.EMPTY);
// 输入为空或者没有修改
if (ComparatorUtils.equals(userInput, oldName)) {

39
designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -47,20 +47,20 @@ import com.fr.design.gui.imenu.UIMenu;
import com.fr.design.gui.imenu.UIMenuBar;
import com.fr.design.gui.itoolbar.UILargeToolbar;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.locale.impl.SupportLocaleImpl;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.ToolBarNewTemplatePane;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.update.actions.SoftwareUpdateAction;
import com.fr.design.remote.action.RemoteDesignAuthManagerAction;
import com.fr.design.update.actions.SoftwareUpdateAction;
import com.fr.design.utils.ThemeUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.general.locale.LocaleAction;
import com.fr.general.locale.LocaleCenter;
import com.fr.design.locale.impl.SupportLocaleImpl;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginRuntime;
@ -72,6 +72,7 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import com.fr.start.OemHandler;
import com.fr.workspace.WorkContext;
import org.jetbrains.annotations.Nullable;
import javax.swing.JComponent;
import javax.swing.JMenuBar;
@ -197,14 +198,30 @@ public abstract class ToolBarMenuDock {
*/
public final JMenuBar createJMenuBar(ToolBarMenuDockPlus plus) {
UIMenuBar jMenuBar = new UIMenuBar() {
private Dimension dim;
@Override
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
dim.height = MENUBAR_HEIGHT;
if (dim == null) {
dim = super.getPreferredSize();
dim.height = MENUBAR_HEIGHT;
}
return dim;
}
};
resetJMenuBar(jMenuBar, plus);
return jMenuBar;
}
/**
* 重置菜单栏
*
* @param jMenuBar 当前菜单栏
* @param plus 对象
*/
public final void resetJMenuBar(JMenuBar jMenuBar, ToolBarMenuDockPlus plus) {
jMenuBar.removeAll();
this.menus = menus(plus);
try {
OemProcessor oemProcessor = OemHandler.findOem();
@ -218,13 +235,12 @@ public abstract class ToolBarMenuDock {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
this.menus = menus(plus);
}
for (int i = 0; i < menus.length; i++) {
menus[i].setHasRecMenu(true);
UIMenu subMenu = menus[i].createJMenu();
for (MenuDef menu : menus) {
menu.setHasRecMenu(true);
UIMenu subMenu = menu.createJMenu();
jMenuBar.add(subMenu);
menus[i].updateMenu();
menu.updateMenu();
}
return jMenuBar;
}
//////////////////////////////////////////////////////////////////////////////////////////
@ -585,7 +601,7 @@ public abstract class ToolBarMenuDock {
* @param plus 对象
* @return 工具栏
*/
public JComponent resetToolBar(JComponent toolbarComponent, ToolBarMenuDockPlus plus) {
public JComponent resetToolBar(@Nullable JComponent toolbarComponent, ToolBarMenuDockPlus plus) {
ToolBarDef[] plusToolBarDefs = plus.toolbars4Target();
UIToolbar toolBar;
if (toolbarComponent instanceof UIToolbar) {
@ -599,8 +615,7 @@ public abstract class ToolBarMenuDock {
toolBarDef = new ToolBarDef();
if (plusToolBarDefs != null) {
for (int i = 0; i < plusToolBarDefs.length; i++) {
ToolBarDef def = plusToolBarDefs[i];
for (ToolBarDef def : plusToolBarDefs) {
for (int di = 0, dlen = def.getShortCutCount(); di < dlen; di++) {
toolBarDef.addShortCut(def.getShortCut(di));
}

66
designer-base/src/main/java/com/fr/design/mainframe/toolbar/UpdateActionManager.java

@ -13,6 +13,8 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import com.fr.value.NotNullLazyValue;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.HashMap;
@ -36,6 +38,22 @@ public class UpdateActionManager {
private static boolean isRegisterIndexSearchTextTask = false;
private boolean afterStartup = false;
private NotNullLazyValue<Boolean> isCacheValid = new NotNullLazyValue<Boolean>() {
@NotNull
@Override
protected Boolean compute() {
// 缓存是否有效。
// 注意:开发工程版本为不是安装版本,
// 索引只会出现在首次启动。
return ComparatorUtils.equals(GeneralUtils.readBuildNO(), AlphaFineConfigManager.getInstance().getCacheBuildNO());
}
};
private ExecutorService searchPool = Executors
.newSingleThreadExecutor(new NamedThreadFactory("IndexAlphaFineSearchText", true));
/**
* 限制初始化
*/
@ -78,35 +96,27 @@ public class UpdateActionManager {
* 1.首次索引或缓存失效的时候更新版本会使缓存失效会将索引缓存存到env.xml
* 下次直接加载
* 2.需要重新索引则等待设计器初始化完毕之后单线程运行索引任务
* 3.集中索引结束之后每次添加为增量索引
*
* @param paneClass 面板类名
* @param updateAction 待处理的updateAction
*/
public void dealWithSearchText(String paneClass, UpdateAction updateAction) {
Map<String, String> actionSearchTextCache = AlphaFineConfigManager.getInstance().getActionSearchTextCache();
if (!cacheValid()
|| actionSearchTextCache.isEmpty()
|| !actionSearchTextCache.containsKey(paneClass)) {
if (!updateActionsIndexCache.containsKey(paneClass)) {
updateActionsIndexCache.put(paneClass, updateAction);
}
registerIndexSearchTextTask();
} else {
if (isCacheValid.getValue() && actionSearchTextCache.containsKey(paneClass)) {
updateAction.setSearchText(actionSearchTextCache.get(paneClass));
} else {
if (afterStartup) {
incrementIndexSearchTextTask(paneClass, updateAction);
} else {
if (!updateActionsIndexCache.containsKey(paneClass)) {
updateActionsIndexCache.put(paneClass, updateAction);
}
registerIndexSearchTextTask();
}
}
}
/**
* 缓存是否有效
* 注意开发工程版本为不是安装版本
* 索引只会出现在首次启动
*
* @return true有效false失效
*/
private boolean cacheValid() {
return ComparatorUtils.equals(GeneralUtils.readBuildNO(), AlphaFineConfigManager.getInstance().getCacheBuildNO());
}
/**
* 由于是UI线程不考虑并发问题
*/
@ -116,26 +126,30 @@ public class UpdateActionManager {
}
isRegisterIndexSearchTextTask = true;
// 没有缓存或者缓存失效的时候,等待设计器启动之后开始索引任务
EventDispatcher.listen(DesignerLaunchStatus.OPEN_LAST_FILE_COMPLETE, new Listener<Null>() {
EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener<Null>() {
@Override
public void on(Event event, Null param) {
// 使用单线程索引
ExecutorService es = Executors.newSingleThreadExecutor(new NamedThreadFactory("IndexAlphaFineSearchText"));
afterStartup = true;
for (Map.Entry<String, UpdateAction> cache : updateActionsIndexCache.entrySet()) {
es.execute(new IndexTask(cache.getKey(), cache.getValue()));
searchPool.execute(new IndexTask(cache.getKey(), cache.getValue()));
}
updateActionsIndexCache = null;
es.shutdown();
updateActionsIndexCache.clear();
// 标记一下缓存版本
AlphaFineConfigManager.getInstance().setCacheBuildNO(GeneralUtils.readBuildNO());
}
});
}
private void incrementIndexSearchTextTask(String key, UpdateAction action) {
searchPool.execute(new IndexTask(key, action));
// 标记一下缓存版本
AlphaFineConfigManager.getInstance().setCacheBuildNO(GeneralUtils.readBuildNO());
}
/**
* 索引任务
*/
class IndexTask implements Runnable {
static class IndexTask implements Runnable {
private String className;
private UpdateAction updateAction;

19
designer-base/src/main/java/com/fr/design/mainframe/toolbar/UpdateActionModel.java

@ -32,15 +32,22 @@ public class UpdateActionModel {
* @param action
*/
private void setSearchKey(String parentName, UpdateAction action) {
StringBuffer buffer = new StringBuffer();
if (actionName == null) {
return;
}
buffer.append(parentName).append(SEPARATOR).append(PinyinHelper.convertToPinyinString(parentName, "", PinyinFormat.WITHOUT_TONE))
.append(SEPARATOR).append(PinyinHelper.getShortPinyin(parentName)).append(SEPARATOR)
.append(actionName).append(SEPARATOR).append(PinyinHelper.convertToPinyinString(actionName, "", PinyinFormat.WITHOUT_TONE))
.append(SEPARATOR).append(PinyinHelper.getShortPinyin(actionName)).append(action.getSearchText());
this.searchKey = buffer.toString().toLowerCase();
String buffer = parentName +
SEPARATOR +
PinyinHelper.convertToPinyinString(parentName, "", PinyinFormat.WITHOUT_TONE) +
SEPARATOR +
PinyinHelper.getShortPinyin(parentName) +
SEPARATOR +
actionName +
SEPARATOR +
PinyinHelper.convertToPinyinString(actionName, "", PinyinFormat.WITHOUT_TONE) +
SEPARATOR +
PinyinHelper.getShortPinyin(actionName) +
action.getSearchText();
this.searchKey = buffer.toLowerCase();
}
/**

4
designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java

@ -20,6 +20,7 @@ import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.workspace.server.vcs.filesystem.VcsFileSystem;
import com.fr.workspace.server.vcs.git.config.GcConfig;
import javax.swing.Icon;
import javax.swing.border.EmptyBorder;
@ -146,6 +147,9 @@ public class VcsHelper implements JTemplateActionListener {
if (needDeleteVersion(oldEntity)) {
operator.deleteVersion(oldEntity.getFilename(), oldEntity.getVersion());
}
if (GcConfig.getInstance().isGcEnable()) {
operator.gc();
}
}
}).start();

3
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java

@ -10,6 +10,7 @@ import com.fr.design.mainframe.vcs.common.VcsCacheFileNodeFile;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.report.entity.VcsEntity;
import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator;
@ -67,7 +68,7 @@ public class FileVersionCellEditor extends AbstractCellEditor implements TableCe
}
double height = editor.getPreferredSize().getHeight();
if (table.getRowHeight(row) != height) {
if (!AssistUtils.equals(table.getRowHeight(row), height)) {
table.setRowHeight(row, (int) height + VcsHelper.OFFSET);
}
return editor;

3
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellRender.java

@ -2,6 +2,7 @@ package com.fr.design.mainframe.vcs.ui;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.report.entity.VcsEntity;
import com.fr.stable.AssistUtils;
import javax.swing.JPanel;
import javax.swing.JTable;
@ -34,7 +35,7 @@ public class FileVersionCellRender implements TableCellRenderer {
editor.setBackground(isSelected ? TABLE_SELECT_BACKGROUND : TREE_BACKGROUND);
double height = editor.getPreferredSize().getHeight();
if (table.getRowHeight(row) != height) {
if (!AssistUtils.equals(table.getRowHeight(row), height)) {
table.setRowHeight(row, (int) height + VcsHelper.OFFSET);
}
return editor;

16
designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthManagerAction.java

@ -9,6 +9,7 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.remote.ui.AuthorityManagerPane;
import com.fr.log.FineLoggerFactory;
import com.fr.report.DesignAuthority;
import com.fr.stable.ArrayUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.authority.AuthorityOperator;
@ -22,6 +23,7 @@ public class RemoteDesignAuthManagerAction extends UpdateAction {
public RemoteDesignAuthManagerAction() {
this.setName(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Authority_Manager"));
// 远程设计权限管理
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remote_Design_Auth_Manager_normal@1x.png"));
}
@ -36,9 +38,13 @@ public class RemoteDesignAuthManagerAction extends UpdateAction {
if (!WorkContext.getCurrent().isLocal()) {
try {
// 远程设计获取全部设计成员的权限列表
DesignAuthority[] authorities = WorkContext.getCurrent().get(AuthorityOperator.class).getAuthorities();
if (authorities != null && authorities.length != 0) {
managerPane.populate(authorities);
DesignAuthority[] userAuthorities = WorkContext.getCurrent().get(AuthorityOperator.class).getUserAuthorities();
DesignAuthority[] customAuthorities = WorkContext.getCurrent().get(AuthorityOperator.class).getCustomRoleAuthorities();
if (userAuthorities != null && userAuthorities.length != 0) {
managerPane.populateByUser(userAuthorities);
}
if (customAuthorities != null && customAuthorities.length != 0) {
managerPane.populateByCustom(customAuthorities);
}
} catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
@ -49,7 +55,9 @@ public class RemoteDesignAuthManagerAction extends UpdateAction {
@Override
public void doOk() {
DesignAuthority[] authorities = managerPane.update();
DesignAuthority[] userAuthorities = managerPane.updateByUser();
DesignAuthority[] customRoleAuthorities = managerPane.updateByCustom();
DesignAuthority[] authorities = ArrayUtils.addAll(userAuthorities, customRoleAuthorities);
if (!WorkContext.getCurrent().isLocal()) {
boolean success = false;
try {

14
designer-base/src/main/java/com/fr/design/remote/constants/MemberIcon.java

@ -0,0 +1,14 @@
package com.fr.design.remote.constants;
/**
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2019/9/23
*/
public class MemberIcon {
public static final String CUSTOM_ROLE_ICON = "com/fr/design/remote/images/icon_Custom_Role_normal@1x.png";
public static final String USER_ICON = "com/fr/design/remote/images/icon_Member_normal@1x.png";
}

64
designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListControlPane.java → designer-base/src/main/java/com/fr/design/remote/ui/AbstractListControlPane.java

@ -40,10 +40,15 @@ import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List;
public class AuthorityListControlPane extends BasicPane {
/**
* 左侧面板的基类
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2019/9/19
*/
public abstract class AbstractListControlPane extends BasicPane {
private static final String LIST_NAME = "AuthorityListControlPaneList";
private static final String LIST_NAME = "AbstractListControlPane";
private static final String UNSELECTED_EDITOR_NAME = "UNSELECTED";
private static final String SELECTED_EDITOR_NAME = "SELECTED";
@ -68,7 +73,7 @@ public class AuthorityListControlPane extends BasicPane {
private UIToolbar toolBar;
public AuthorityListControlPane() {
public AbstractListControlPane() {
super();
initComponentPane();
}
@ -76,13 +81,8 @@ public class AuthorityListControlPane extends BasicPane {
private void initComponentPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.authorityCreators = new RemoteDesignAuthorityCreator[]{
new RemoteDesignAuthorityCreator(
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_User"),
BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"),
DesignAuthority.class,
AuthorityEditorPane.class)
};
this.authorityCreators = getAuthorityCreators();
editorCtrl = new ListEditorControlPane();
// 左侧列表面板
@ -107,6 +107,7 @@ public class AuthorityListControlPane extends BasicPane {
checkButtonEnabled();
}
protected abstract RemoteDesignAuthorityCreator[] getAuthorityCreators();
private void initLeftToolbar(JPanel leftPane) {
shortCuts = createShortcuts();
@ -139,17 +140,19 @@ public class AuthorityListControlPane extends BasicPane {
if (hasInvalid()) {
return;
}
AuthorityListControlPane.this.editorCtrl.update();
AuthorityListControlPane.this.editorCtrl.populate();
AuthorityListControlPane.this.checkButtonEnabled();
AbstractListControlPane.this.editorCtrl.update();
AbstractListControlPane.this.editorCtrl.populate();
AbstractListControlPane.this.checkButtonEnabled();
}
}
});
}
protected abstract AuthorityListCellRenderer getAuthorityListCellRender();
private AuthorityList createList() {
AuthorityList list = new AuthorityList(new DefaultListModel<DesignAuthority>());
list.setCellRenderer(new AuthorityListCellRenderer());
list.setCellRenderer(getAuthorityListCellRender());
return list;
}
@ -168,7 +171,9 @@ public class AuthorityListControlPane extends BasicPane {
this.editorCtrl.update();
DefaultListModel listModel = (DefaultListModel) this.authorityList.getModel();
for (int i = 0, len = listModel.getSize(); i < len; i++) {
res.add((DesignAuthority) listModel.getElementAt(i));
DesignAuthority authority = (DesignAuthority) listModel.getElementAt(i);
// authority.setRoleType(RoleType.USER);
res.add(authority);
}
return res.toArray(new DesignAuthority[res.size()]);
}
@ -315,7 +320,7 @@ public class AuthorityListControlPane extends BasicPane {
public void checkEnable() {
this.shortCut.setEnabled(authorityList.getModel()
.getSize() > 0
&& AuthorityListControlPane.this.authorityList.getSelectedIndex() != -1);
&& AbstractListControlPane.this.authorityList.getSelectedIndex() != -1);
}
}
@ -356,13 +361,13 @@ public class AuthorityListControlPane extends BasicPane {
}
private boolean hasInvalid() {
int idx = AuthorityListControlPane.this.getInValidIndex();
int idx = AbstractListControlPane.this.getInValidIndex();
if (authorityList.getSelectedIndex() != idx) {
try {
checkValid();
} catch (Exception exp) {
FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
JOptionPane.showMessageDialog(AuthorityListControlPane.this, exp.getMessage());
JOptionPane.showMessageDialog(AbstractListControlPane.this, exp.getMessage());
authorityList.setSelectedIndex(idx);
return true;
}
@ -442,7 +447,7 @@ public class AuthorityListControlPane extends BasicPane {
}
public void populate() {
authority = AuthorityListControlPane.this.authorityList.getSelectedValue();
authority = AbstractListControlPane.this.authorityList.getSelectedValue();
if (authority == null) {
return;
@ -485,6 +490,10 @@ public class AuthorityListControlPane extends BasicPane {
}
}
protected abstract AbstractManagerPane getManagerPane();
protected abstract String getKey();
/**
* 选择按钮
*/
@ -498,17 +507,17 @@ public class AuthorityListControlPane extends BasicPane {
@Override
public void actionPerformed(ActionEvent e) {
final UserManagerPane userManagerPane = new UserManagerPane();
BasicDialog dialog = userManagerPane.showWindow(SwingUtilities.getWindowAncestor(AuthorityListControlPane.this));
final AbstractManagerPane managerPane = getManagerPane();
BasicDialog dialog = managerPane.showWindow(SwingUtilities.getWindowAncestor(AbstractListControlPane.this));
// 刷新用户管理面板展示信息
final DesignAuthority[] authorities = AuthorityListControlPane.this.update();
final DesignAuthority[] authorities = AbstractListControlPane.this.update();
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
// 获取添加的用户到权限编辑面板
List<RemoteDesignMember> members = userManagerPane.update();
List<RemoteDesignMember> members = managerPane.update();
List<DesignAuthority> oldAuthorities = new ArrayList<>();
@ -529,6 +538,7 @@ public class AuthorityListControlPane extends BasicPane {
authority.setUsername(member.getUsername());
authority.setUserId(member.getUserId());
authority.setRealName(member.getRealName());
authority.setRoleType(member.getRoleType());
addAuthority(authority, getModel().getSize());
}
@ -543,9 +553,11 @@ public class AuthorityListControlPane extends BasicPane {
m.setUserId(authority.getUserId());
m.setRealName(authority.getRealName());
m.setSelected(true);
m.setRoleType(authority.getRoleType());
m.setAuthority(true);
members.add(m);
}
userManagerPane.populate(members);
managerPane.populate(members);
dialog.setModal(true);
dialog.setVisible(true);
@ -567,7 +579,7 @@ public class AuthorityListControlPane extends BasicPane {
public void actionPerformed(ActionEvent evt) {
doBeforeRemove();
if (GUICoreUtils.removeJListSelectedNodes(SwingUtilities
.getWindowAncestor(AuthorityListControlPane.this), authorityList)) {
.getWindowAncestor(AbstractListControlPane.this), authorityList, getKey())) {
checkButtonEnabled();
doAfterRemove();
}

440
designer-base/src/main/java/com/fr/design/remote/ui/AbstractManagerPane.java

@ -0,0 +1,440 @@
package com.fr.design.remote.ui;
import com.fr.base.BaseUtils;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.dialog.BasicPane;
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.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.remote.ui.list.AddedMemberList;
import com.fr.design.remote.ui.list.AddedMemberListCellRender;
import com.fr.design.remote.ui.list.AddingMemberList;
import com.fr.design.remote.ui.list.AddingMemberListCellRender;
import com.fr.design.remote.ui.list.MemberListSelectedChangeListener;
import com.fr.stable.StringUtils;
import com.fr.third.guava.collect.ImmutableList;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.authority.RemoteDesignMember;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.JPanel;
import javax.swing.JViewport;
import javax.swing.ListSelectionModel;
import javax.swing.SwingWorker;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
/**
* 选择设计角色用户面板的基类
* @author yaohwu
*/
public abstract class AbstractManagerPane extends BasicPane {
/**
* 每页个数
*/
private static final int DEFAULT_NUM_EACH_PAGE = 50;
/**
* 获取的决策平台用户
*/
private final List<RemoteDesignMember> addingMembers = new ArrayList<>();
/**
* 添加到设计的决策平台用户
*/
private List<RemoteDesignMember> addedMembers = new ArrayList<>();
/**
* 决策平台用户列表model
*/
private DefaultListModel<RemoteDesignMember> addingListModel = new DefaultListModel<>();
/**
* 搜索输入框
*/
private UITextField keyField = new UITextField();
/**
* 搜索按钮
*/
private UIButton keyButton = new UIButton();
/**
* 搜索按钮绑定事件
*/
private ActionListener keyButtonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
searchAddingMembers(keyWord);
}
};
/**
* 输入框绑定事件
*/
private KeyAdapter keyFieldKeyListener = new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
// 判断按下的键是否是回车键
// 对话框回车键绑定的是对话框的确定按钮
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
searchAddingMembers(keyWord);
// has been processed
e.consume();
}
}
};
/**
* 添加到设计的决策用户计数标签
*/
private UILabel countLabel = new UILabel();
/**
* 添加到设计的决策用户计数标签
*/
private DefaultListModel<RemoteDesignMember> addedListModel;
/**
* 左侧列表变动事件
*/
private MemberListSelectedChangeListener addingListChangeListener = new MemberListSelectedChangeListener() {
@Override
public void selectedChange() {
sync2AddedMembersFromAdding();
// 刷新右侧列表显示
addToAddedMemberList();
}
};
/**
* 右侧列表变动事件
*/
private MemberListSelectedChangeListener addedListChangeListener = new MemberListSelectedChangeListener() {
@Override
public void selectedChange() {
addingList.revalidate();
addingList.repaint();
resetAddedMembers();
sync2AddedMembersFormAdded();
// 不需要重复更新右侧列表显示 但是更新一下计数显示
countLabel.setText(
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Selected_Member_Count",
String.valueOf(addedMembers.size())
)
);
// 刷新左侧列表显示
addToMemberList();
}
};
/**
* 已经添加的用户列表
*/
private AddedMemberList addedList;
/**
* 待添加的用户列表
*/
private AddingMemberList addingList;
/**
* 搜索关键字
*/
private String keyWord;
/**
* 搜索关键词变更监听
*/
private transient DocumentListener documentListener = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
keyWord = keyField.getText();
}
@Override
public void removeUpdate(DocumentEvent e) {
keyWord = keyField.getText();
}
@Override
public void changedUpdate(DocumentEvent e) {
keyWord = keyField.getText();
}
};
/**
* 当前分页计数
*/
private int pageNum = 1;
public AbstractManagerPane() {
this.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4));
this.setLayout(new BorderLayout());
this.add(
TableLayoutHelper.createCommonTableLayoutPane(
new Component[][]{
new Component[]{createLeftPanel(), createRightPanel()}
},
new double[]{TableLayout.FILL},
new double[]{TableLayout.FILL, TableLayout.FILL},
LayoutConstants.VGAP_LARGE
),
BorderLayout.CENTER);
}
public void populate(List<RemoteDesignMember> addedMembers) {
// 已选信息
resetAddedMembers();
this.addedMembers.addAll(addedMembers);
// 刷新右侧面板
addToAddedMemberList();
// 刷新左侧展示信息
addToMemberList();
}
@Override
protected String title4PopupWindow() {
// 选择设计用户
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Choose_User");
}
protected abstract JPanel leftPanel();
private JPanel createLeftPanel() {
JPanel content = leftPanel();
// 搜索
JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5));
searchPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
keyField.setPreferredSize(new Dimension(270, 20));
keyField.requestFocus();
keyField.addKeyListener(keyFieldKeyListener);
keyField.getDocument().addDocumentListener(documentListener);
keyButton.setIcon(BaseUtils.readIcon("com/fr/design/images/buttonicon/user_search_normal.png"));
keyButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Search"));
keyButton.addActionListener(keyButtonActionListener);
searchPanel.add(keyField);
searchPanel.add(keyButton);
// 内容列表
addingListModel = new DefaultListModel<>();
addingList = new AddingMemberList(addingListModel);
addingList.setCellRenderer(getAddingMemberListCellRender());
addingList.addSelectedChangeListener(addingListChangeListener);
resetMembers();
addToMemberList();
searchAddingMembers(StringUtils.EMPTY);
final UIScrollPane listPane = new UIScrollPane(addingList);
listPane.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
JViewport vp = listPane.getViewport();
if (vp.getView().getHeight() <= vp.getHeight() + vp.getViewPosition().y) {
loadMoreAddingMembers(keyWord, DEFAULT_NUM_EACH_PAGE);
}
}
});
listPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
JViewport vp = listPane.getViewport();
if (vp.getView().getHeight() <= vp.getHeight() + vp.getViewPosition().y && e.getValueIsAdjusting()) {
loadMoreAddingMembers(keyWord, DEFAULT_NUM_EACH_PAGE);
}
}
});
listPane.setBorder(BorderFactory.createEmptyBorder());
content.add(searchPanel, BorderLayout.NORTH);
content.add(listPane, BorderLayout.CENTER);
return content;
}
protected abstract AddingMemberListCellRender getAddingMemberListCellRender();
protected abstract AddedMemberListCellRender getAddedMemberListCellRender();
protected abstract JPanel rightPanel();
private JPanel createRightPanel() {
JPanel content = rightPanel();
// 计数
countLabel.setText(
// 已选择{}人
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Selected_Member_Count",
String.valueOf(addedMembers.size()))
);
countLabel.setBorder(BorderFactory.createEmptyBorder(7, 12, 8, 0));
countLabel.setForeground(new Color(0x8F8F92));
addedListModel = new DefaultListModel<>();
addedList = new AddedMemberList(addedListModel);
addedList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
addedList.setCellRenderer(getAddedMemberListCellRender());
addedList.addSelectedChangeListener(addedListChangeListener);
resetAddedMembers();
addToAddedMemberList();
UIScrollPane listPane = new UIScrollPane(addedList);
listPane.setBorder(BorderFactory.createEmptyBorder());
content.add(countLabel, BorderLayout.NORTH);
content.add(listPane, BorderLayout.CENTER);
return content;
}
private void addToMemberList() {
addingListModel.clear();
for (RemoteDesignMember member : addingMembers) {
// 如果包含在右侧列表中,那么左侧列表默认选中
if (addedMembers.contains(member)) {
member.setAuthority(true);
member.setSelected(true);
} else {
member.setAuthority(false);
member.setSelected(false);
}
addingListModel.addElement(member);
}
addingList.revalidate();
addingList.repaint();
}
private void addToAddedMemberList() {
addedListModel.clear();
for (RemoteDesignMember member : addedMembers) {
addedListModel.addElement(member);
}
addedList.revalidate();
addedList.repaint();
countLabel.setText(
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Selected_Member_Count",
String.valueOf(addedMembers.size())
));
}
private void resetMembers() {
addingMembers.clear();
addingMembers.add(RemoteDesignMember.DEFAULT_MEMBER);
}
private void resetAddedMembers() {
addedMembers.clear();
}
protected abstract Collection<RemoteDesignMember> getMembers(String userName, String keyWord);
protected abstract Collection<RemoteDesignMember> getMembers(String userName, String keyWord, int pageNum, int count);
private void searchAddingMembers(final String keyword) {
final SwingWorker getMemberWorker = new SwingWorker<List<RemoteDesignMember>, Void>() {
@Override
protected List<RemoteDesignMember> doInBackground() {
String username = WorkContext.getCurrent().getConnection().getUserName();
synchronized (addingMembers) {
addingMembers.clear();
Collection<RemoteDesignMember> more = getMembers(username, keyword);
pageNum = 1;
if (!more.isEmpty()) {
addingMembers.addAll(more);
if (more.size() >= DEFAULT_NUM_EACH_PAGE) {
addingMembers.add(RemoteDesignMember.DEFAULT_MEMBER);
}
}
}
return addingMembers;
}
@Override
protected void done() {
addToMemberList();
}
};
getMemberWorker.execute();
}
private void loadMoreAddingMembers(final String keyword, final int count) {
final SwingWorker loadMoreWorker = new SwingWorker<List<RemoteDesignMember>, Void>() {
@Override
protected List<RemoteDesignMember> doInBackground() {
String username = WorkContext.getCurrent().getConnection().getUserName();
synchronized (addingMembers) {
addingMembers.remove(RemoteDesignMember.DEFAULT_MEMBER);
Collection<RemoteDesignMember> more = getMembers(username, keyword, pageNum + 1, count);
if (!more.isEmpty()) {
pageNum += 1;
addingMembers.addAll(more);
addingMembers.add(RemoteDesignMember.DEFAULT_MEMBER);
}
}
return addingMembers;
}
@Override
protected void done() {
addToMemberList();
}
};
loadMoreWorker.execute();
}
private void sync2AddedMembersFromAdding() {
RemoteDesignMember[] members = new RemoteDesignMember[addingListModel.getSize()];
// shallow copy
addingListModel.copyInto(members);
for (RemoteDesignMember member : members) {
if (!member.isSelected()) {
addedMembers.remove(member);
}
if (member.isSelected() && !addedMembers.contains(member)) {
addedMembers.add(member);
}
}
}
private void sync2AddedMembersFormAdded() {
RemoteDesignMember[] members = new RemoteDesignMember[addedListModel.getSize()];
// shallow copy
addedListModel.copyInto(members);
addedMembers.addAll(Arrays.asList(members));
}
public ImmutableList<RemoteDesignMember> update() {
return ImmutableList.copyOf(addedMembers);
}
}

6
designer-base/src/main/java/com/fr/design/remote/ui/AuthorityEditorPane.java

@ -19,12 +19,15 @@ import java.awt.BorderLayout;
import java.util.ArrayList;
import java.util.List;
/**
* 右面板
*/
public class AuthorityEditorPane extends BasicBeanPane<DesignAuthority> {
private FileAuthorityTree tree = new FileAuthorityTree();
// 模板设计权限配置
public AuthorityEditorPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(
@ -47,6 +50,7 @@ public class AuthorityEditorPane extends BasicBeanPane<DesignAuthority> {
@Override
protected String title4PopupWindow() {
// 编辑文件权限
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Configure_Authority");
}

38
designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListCustomRolePane.java

@ -0,0 +1,38 @@
package com.fr.design.remote.ui;
import com.fr.base.BaseUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.design.remote.RemoteDesignAuthorityCreator;
import com.fr.design.remote.ui.list.AuthorityListCellRenderer;
import com.fr.design.remote.ui.list.cell.AuthorityCustomRoleListCellRender;
import com.fr.report.DesignAuthority;
public class AuthorityListCustomRolePane extends AbstractListControlPane {
@Override
protected RemoteDesignAuthorityCreator[] getAuthorityCreators() {
return new RemoteDesignAuthorityCreator[]{
new RemoteDesignAuthorityCreator(
// 远程设计用户
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Custom"),
BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"),
DesignAuthority.class,
AuthorityEditorPane.class)
};
}
@Override
protected AuthorityListCellRenderer getAuthorityListCellRender() {
return new AuthorityCustomRoleListCellRender();
}
@Override
protected AbstractManagerPane getManagerPane() {
return new CustomRoleManagerPane();
}
@Override
protected String getKey() {
return "Fine-Design_Basic_Utils_Are_You_Sure_To_Delete_The_Role_And_Its_Design_Authorities";
}
}

38
designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListUserPane.java

@ -0,0 +1,38 @@
package com.fr.design.remote.ui;
import com.fr.base.BaseUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.design.remote.RemoteDesignAuthorityCreator;
import com.fr.design.remote.ui.list.AuthorityListCellRenderer;
import com.fr.design.remote.ui.list.cell.AuthorityUserListCellRender;
import com.fr.report.DesignAuthority;
public class AuthorityListUserPane extends AbstractListControlPane {
@Override
protected RemoteDesignAuthorityCreator[] getAuthorityCreators() {
return new RemoteDesignAuthorityCreator[]{
new RemoteDesignAuthorityCreator(
// 远程设计用户
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_User"),
BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"),
DesignAuthority.class,
AuthorityEditorPane.class)
};
}
@Override
protected AuthorityListCellRenderer getAuthorityListCellRender() {
return new AuthorityUserListCellRender();
}
@Override
protected AbstractManagerPane getManagerPane() {
return new UserManagerPane();
}
@Override
protected String getKey() {
return "Fine-Design_Basic_Utils_Are_You_Sure_To_Delete_The_User_And_Its_Design_Authorities";
}
}

39
designer-base/src/main/java/com/fr/design/remote/ui/AuthorityManagerPane.java

@ -1,36 +1,51 @@
package com.fr.design.remote.ui;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.report.DesignAuthority;
import javax.swing.BorderFactory;
import java.awt.BorderLayout;
public class AuthorityManagerPane extends BasicPane {
private AuthorityListControlPane list;
private AuthorityListUserPane userList = new AuthorityListUserPane();
private AuthorityListCustomRolePane roleList = new AuthorityListCustomRolePane();
public AuthorityManagerPane() {
this.setLayout(new BorderLayout());
this.setBorder(BorderFactory.createEmptyBorder());
list = new AuthorityListControlPane();
this.add(list, BorderLayout.CENTER);
}
this.setLayout(FRGUIPaneFactory.createBorderLayout());
//Tabbed Pane
UITabbedPane tabbedPane = new UITabbedPane();
this.add(tabbedPane, BorderLayout.CENTER);
tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Basic_User"), userList);
tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Basic_Role"), roleList);
}
@Override
protected String title4PopupWindow() {
// 远程设计权限管理
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Authority_Manager");
}
public void populate(DesignAuthority[] authorities) {
list.populate(authorities);
public void populateByUser(DesignAuthority[] authorities) {
userList.populate(authorities);
}
public DesignAuthority[] update() {
return list.update();
public void populateByCustom(DesignAuthority[] authorities) {
roleList.populate(authorities);
}
public DesignAuthority[] updateByUser() {
return userList.update();
}
public DesignAuthority[] updateByCustom() {
return roleList.update();
}
}

83
designer-base/src/main/java/com/fr/design/remote/ui/CustomRoleManagerPane.java

@ -0,0 +1,83 @@
package com.fr.design.remote.ui;
import com.fr.design.border.UITitledBorder;
import com.fr.design.i18n.Toolkit;
import com.fr.design.remote.ui.list.AddedMemberListCellRender;
import com.fr.design.remote.ui.list.AddingMemberListCellRender;
import com.fr.design.remote.ui.list.cell.AddedCustomRoleListCellRender;
import com.fr.design.remote.ui.list.cell.AddingCustomRoleListCellRender;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.authority.RemoteDesignMember;
import com.fr.workspace.server.authority.decision.DecisionOperator;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.BorderLayout;
import java.util.Collection;
/**
* 选择设计角色
*/
public class CustomRoleManagerPane extends AbstractManagerPane {
@Override
protected String title4PopupWindow() {
// 选择设计角色
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Choose_Custom");
}
@Override
protected JPanel rightPanel(){
JPanel content = new JPanel(new BorderLayout());
content.setBorder(
BorderFactory.createCompoundBorder(
new EmptyBorder(6, 0, 0, 0),
UITitledBorder.createBorderWithTitle(
// 已选择的设计角色
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Selected_Custom"),
4
)
)
);
return content;
}
@Override
protected JPanel leftPanel(){
JPanel content = new JPanel(new BorderLayout());
content.setBorder(
BorderFactory.createCompoundBorder(
new EmptyBorder(6, 0, 0, 0),
UITitledBorder.createBorderWithTitle(
// 决策系统角色
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Decision_Custom"),
4)
)
);
return content;
}
@Override
protected AddingMemberListCellRender getAddingMemberListCellRender() {
return new AddingCustomRoleListCellRender();
}
@Override
protected AddedMemberListCellRender getAddedMemberListCellRender() {
return new AddedCustomRoleListCellRender();
}
@Override
protected Collection<RemoteDesignMember> getMembers(String userName, String keyWord){
return WorkContext.getCurrent().get(DecisionOperator.class).getCustoms(userName, keyWord);
}
@Override
protected Collection<RemoteDesignMember> getMembers(String userName, String keyWord, int pageNum, int count){
return WorkContext.getCurrent().get(DecisionOperator.class).getCustoms(userName, keyWord, pageNum, count);
}
}

425
designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java

@ -1,450 +1,83 @@
package com.fr.design.remote.ui;
import com.fr.base.BaseUtils;
import com.fr.design.border.UITitledBorder;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.dialog.BasicPane;
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.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.remote.ui.list.AddedMemberList;
import com.fr.design.remote.ui.list.AddedMemberListCellRender;
import com.fr.design.remote.ui.list.AddingMemberList;
import com.fr.design.remote.ui.list.AddingMemberListCellRender;
import com.fr.design.remote.ui.list.MemberListSelectedChangeListener;
import com.fr.stable.StringUtils;
import com.fr.third.guava.collect.ImmutableList;
import com.fr.design.remote.ui.list.cell.AddedUserListCellRender;
import com.fr.design.remote.ui.list.cell.AddingUserListCellRender;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.authority.RemoteDesignMember;
import com.fr.workspace.server.authority.decision.DecisionOperator;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.JPanel;
import javax.swing.JViewport;
import javax.swing.ListSelectionModel;
import javax.swing.SwingWorker;
import javax.swing.border.EmptyBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
/**
* @author yaohwu
* 选择设计用户
*/
public class UserManagerPane extends BasicPane {
/**
* 每页个数
*/
private static final int DEFAULT_NUM_EACH_PAGE = 50;
/**
* 获取的决策平台成员
*/
private final List<RemoteDesignMember> addingMembers = new ArrayList<>();
/**
* 添加到设计的决策平台成员
*/
private List<RemoteDesignMember> addedMembers = new ArrayList<>();
/**
* 决策平台成员列表model
*/
private DefaultListModel<RemoteDesignMember> addingListModel = new DefaultListModel<>();
/**
* 搜索输入框
*/
private UITextField keyField = new UITextField();
/**
* 搜索按钮
*/
private UIButton keyButton = new UIButton();
/**
* 搜索按钮绑定事件
*/
private ActionListener keyButtonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
searchAddingMembers(keyWord);
}
};
/**
* 输入框绑定事件
*/
private KeyAdapter keyFieldKeyListener = new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
// 判断按下的键是否是回车键
// 对话框回车键绑定的是对话框的确定按钮
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
searchAddingMembers(keyWord);
// has been processed
e.consume();
}
}
};
/**
* 添加到设计的决策成员计数标签
*/
private UILabel countLabel = new UILabel();
/**
* 添加到设计的决策成员计数标签
*/
private DefaultListModel<RemoteDesignMember> addedListModel;
/**
* 左侧列表变动事件
*/
private MemberListSelectedChangeListener addingListChangeListener = new MemberListSelectedChangeListener() {
@Override
public void selectedChange() {
// 右侧列表发生变化后,将右侧列表中选中但是在左侧列表中没有的成员添加进来,同时移除取消选中的
sync2AddedMembersFromAdding();
// 刷新右侧列表显示
addToAddedMemberList();
}
};
/**
* 右侧列表变动事件
*/
private MemberListSelectedChangeListener addedListChangeListener = new MemberListSelectedChangeListener() {
@Override
public void selectedChange() {
addingList.revalidate();
addingList.repaint();
resetAddedMembers();
sync2AddedMembersFormAdded();
// 不需要重复更新右侧列表显示 但是更新一下计数显示
countLabel.setText(
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Selected_Member_Count",
String.valueOf(addedMembers.size())
)
);
// 刷新左侧列表显示
addToMemberList();
}
};
/**
* 已经添加的成员列表
*/
private AddedMemberList addedList;
/**
* 待添加的成员列表
*/
private AddingMemberList addingList;
/**
* 搜索关键字
*/
private String keyWord;
/**
* 搜索关键词变更监听
*/
private transient DocumentListener documentListener = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
keyWord = keyField.getText();
}
@Override
public void removeUpdate(DocumentEvent e) {
keyWord = keyField.getText();
}
@Override
public void changedUpdate(DocumentEvent e) {
keyWord = keyField.getText();
}
};
/**
* 当前分页计数
*/
private int pageNum = 1;
public UserManagerPane() {
this.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4));
this.setLayout(new BorderLayout());
this.add(
TableLayoutHelper.createCommonTableLayoutPane(
new Component[][]{
new Component[]{createLeftPanel(), createRightPanel()}
},
new double[]{TableLayout.FILL},
new double[]{TableLayout.FILL, TableLayout.FILL},
LayoutConstants.VGAP_LARGE
),
BorderLayout.CENTER);
}
public void populate(List<RemoteDesignMember> addedMembers) {
// 已选信息
resetAddedMembers();
this.addedMembers.addAll(addedMembers);
// 刷新右侧面板
addToAddedMemberList();
// 刷新左侧展示信息
addToMemberList();
}
public class UserManagerPane extends AbstractManagerPane {
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Choose_Member");
// 选择设计用户
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Choose_User");
}
private JPanel createLeftPanel() {
@Override
protected JPanel rightPanel(){
JPanel content = new JPanel(new BorderLayout());
content.setBorder(
BorderFactory.createCompoundBorder(
new EmptyBorder(6, 0, 0, 0),
UITitledBorder.createBorderWithTitle(
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Decision_Member"),
4)
// 已选择的设计用户
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Selected_User"),
4
)
)
);
// 搜索
JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5));
searchPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
keyField.setPreferredSize(new Dimension(270, 20));
keyField.requestFocus();
keyField.addKeyListener(keyFieldKeyListener);
keyField.getDocument().addDocumentListener(documentListener);
keyButton.setIcon(BaseUtils.readIcon("com/fr/design/images/buttonicon/user_search_normal.png"));
keyButton.setToolTipText(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Search"));
keyButton.addActionListener(keyButtonActionListener);
searchPanel.add(keyField);
searchPanel.add(keyButton);
// 内容列表
addingListModel = new DefaultListModel<>();
addingList = new AddingMemberList(addingListModel);
addingList.setCellRenderer(new AddingMemberListCellRender());
addingList.addSelectedChangeListener(addingListChangeListener);
resetMembers();
addToMemberList();
searchAddingMembers(StringUtils.EMPTY);
final UIScrollPane listPane = new UIScrollPane(addingList);
listPane.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
JViewport vp = listPane.getViewport();
if (vp.getView().getHeight() <= vp.getHeight() + vp.getViewPosition().y) {
loadMoreAddingMembers(keyWord, DEFAULT_NUM_EACH_PAGE);
}
}
});
listPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
JViewport vp = listPane.getViewport();
if (vp.getView().getHeight() <= vp.getHeight() + vp.getViewPosition().y && e.getValueIsAdjusting()) {
loadMoreAddingMembers(keyWord, DEFAULT_NUM_EACH_PAGE);
}
}
});
listPane.setBorder(BorderFactory.createEmptyBorder());
content.add(searchPanel, BorderLayout.NORTH);
content.add(listPane, BorderLayout.CENTER);
return content;
}
private JPanel createRightPanel() {
@Override
protected JPanel leftPanel(){
JPanel content = new JPanel(new BorderLayout());
content.setBorder(
BorderFactory.createCompoundBorder(
new EmptyBorder(6, 0, 0, 0),
UITitledBorder.createBorderWithTitle(
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Selected_Member"),
4
)
// 决策系统用户
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Decision_User"),
4)
)
);
// 计数
countLabel.setText(
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Selected_Member_Count",
String.valueOf(addedMembers.size()))
);
countLabel.setBorder(BorderFactory.createEmptyBorder(7, 12, 8, 0));
countLabel.setForeground(new Color(0x8F8F92));
addedListModel = new DefaultListModel<>();
addedList = new AddedMemberList(addedListModel);
addedList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
addedList.setCellRenderer(new AddedMemberListCellRender());
addedList.addSelectedChangeListener(addedListChangeListener);
resetAddedMembers();
addToAddedMemberList();
UIScrollPane listPane = new UIScrollPane(addedList);
listPane.setBorder(BorderFactory.createEmptyBorder());
content.add(countLabel, BorderLayout.NORTH);
content.add(listPane, BorderLayout.CENTER);
return content;
}
private void addToMemberList() {
addingListModel.clear();
for (RemoteDesignMember member : addingMembers) {
// 如果包含在右侧列表中,那么左侧列表默认选中
if (addedMembers.contains(member)) {
member.setSelected(true);
} else {
member.setSelected(false);
}
addingListModel.addElement(member);
}
addingList.revalidate();
addingList.repaint();
}
private void addToAddedMemberList() {
addedListModel.clear();
for (RemoteDesignMember member : addedMembers) {
addedListModel.addElement(member);
}
addedList.revalidate();
addedList.repaint();
countLabel.setText(
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Selected_Member_Count",
String.valueOf(addedMembers.size())
));
}
private void resetMembers() {
addingMembers.clear();
addingMembers.add(RemoteDesignMember.DEFAULT_MEMBER);
}
private void resetAddedMembers() {
addedMembers.clear();
}
private void searchAddingMembers(final String keyword) {
final SwingWorker getMemberWorker = new SwingWorker<List<RemoteDesignMember>, Void>() {
@Override
protected List<RemoteDesignMember> doInBackground() {
String username = WorkContext.getCurrent().getConnection().getUserName();
synchronized (addingMembers) {
addingMembers.clear();
Collection<RemoteDesignMember> more = WorkContext.getCurrent().get(DecisionOperator.class).getMembers(username, keyword);
pageNum = 1;
if (!more.isEmpty()) {
addingMembers.addAll(more);
if (more.size() >= DEFAULT_NUM_EACH_PAGE) {
addingMembers.add(RemoteDesignMember.DEFAULT_MEMBER);
}
}
}
return addingMembers;
}
@Override
protected void done() {
addToMemberList();
}
};
getMemberWorker.execute();
}
private void loadMoreAddingMembers(final String keyword, final int count) {
final SwingWorker loadMoreWorker = new SwingWorker<List<RemoteDesignMember>, Void>() {
@Override
protected List<RemoteDesignMember> doInBackground() {
String username = WorkContext.getCurrent().getConnection().getUserName();
synchronized (addingMembers) {
addingMembers.remove(RemoteDesignMember.DEFAULT_MEMBER);
Collection<RemoteDesignMember> more =
WorkContext.getCurrent().get(DecisionOperator.class).getMembers(username, keyword, pageNum + 1, count);
if (!more.isEmpty()) {
pageNum += 1;
addingMembers.addAll(more);
addingMembers.add(RemoteDesignMember.DEFAULT_MEMBER);
}
}
return addingMembers;
}
@Override
protected void done() {
addToMemberList();
}
};
loadMoreWorker.execute();
@Override
protected AddingMemberListCellRender getAddingMemberListCellRender() {
return new AddingUserListCellRender();
}
private void sync2AddedMembersFromAdding() {
RemoteDesignMember[] members = new RemoteDesignMember[addingListModel.getSize()];
// shallow copy
addingListModel.copyInto(members);
for (RemoteDesignMember member : members) {
if (!member.isSelected()) {
addedMembers.remove(member);
}
if (member.isSelected() && !addedMembers.contains(member)) {
addedMembers.add(member);
}
}
@Override
protected AddedMemberListCellRender getAddedMemberListCellRender() {
return new AddedUserListCellRender();
}
private void sync2AddedMembersFormAdded() {
RemoteDesignMember[] members = new RemoteDesignMember[addedListModel.getSize()];
// shallow copy
addedListModel.copyInto(members);
addedMembers.addAll(Arrays.asList(members));
@Override
protected Collection<RemoteDesignMember> getMembers(String userName, String keyWord){
return WorkContext.getCurrent().get(DecisionOperator.class).getMembers(userName, keyWord);
}
public ImmutableList<RemoteDesignMember> update() {
return ImmutableList.copyOf(addedMembers);
@Override
protected Collection<RemoteDesignMember> getMembers(String userName, String keyWord, int pageNum, int count){
return WorkContext.getCurrent().get(DecisionOperator.class).getMembers(userName, keyWord, pageNum, count);
}
}

21
designer-base/src/main/java/com/fr/design/remote/ui/list/AddedMemberList.java

@ -1,8 +1,12 @@
package com.fr.design.remote.ui.list;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.report.constant.RoleType;
import com.fr.workspace.server.authority.RemoteDesignMember;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import java.util.Vector;
public class AddedMemberList extends MemberList {
@ -27,8 +31,21 @@ public class AddedMemberList extends MemberList {
protected void displaySelected() {
RemoteDesignMember member = getSelectedValue();
if (member != null) {
member.setSelected(!member.isSelected());
((DefaultListModel<RemoteDesignMember>) getModel()).removeElement(member);
String keyTitle = member.getRoleType() == RoleType.CUSTOM ?
"Fine-Design_Basic_Utils_Are_You_Sure_To_Delete_The_Role_And_Its_Design_Authorities" :
"Fine-Design_Basic_Utils_Are_You_Sure_To_Delete_The_User_And_Its_Design_Authorities";
if (member.isSelected() && member.hasAuthority()){
int val = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText(keyTitle),
Toolkit.i18nText("Fine-Design_Basic_Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (val == JOptionPane.OK_OPTION) {
member.setSelected(!member.isSelected());
((DefaultListModel<RemoteDesignMember>) getModel()).removeElement(member);
}
}
else {
member.setSelected(!member.isSelected());
((DefaultListModel<RemoteDesignMember>) getModel()).removeElement(member);
}
}
revalidate();
repaint();

12
designer-base/src/main/java/com/fr/design/remote/ui/list/AddedMemberListCellRender.java

@ -1,11 +1,11 @@
package com.fr.design.remote.ui.list;
import com.fr.base.BaseUtils;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.remote.button.IconButton;
import com.fr.workspace.server.authority.RemoteDesignMember;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
@ -13,7 +13,7 @@ import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
public class AddedMemberListCellRender extends JPanel implements ListCellRenderer<RemoteDesignMember> {
public abstract class AddedMemberListCellRender extends JPanel implements ListCellRenderer<RemoteDesignMember> {
private UILabel label;
@ -25,7 +25,7 @@ public class AddedMemberListCellRender extends JPanel implements ListCellRendere
label = new UILabel();
label.setPreferredSize(new Dimension(264, 20));
this.setPreferredSize(new Dimension(this.getPreferredSize().width, 25));
label.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"));
label.setIcon(getMemberIcon());
this.add(label);
this.add(new IconButton());
@ -33,7 +33,7 @@ public class AddedMemberListCellRender extends JPanel implements ListCellRendere
@Override
public Component getListCellRendererComponent(JList<? extends RemoteDesignMember> list, RemoteDesignMember member, int index, boolean isSelected, boolean cellHasFocus) {
this.setLabelText(member.getRealName() + "(" + member.getUsername() + ")");
this.setLabelText(getMemberName(member));
return this;
}
@ -41,4 +41,8 @@ public class AddedMemberListCellRender extends JPanel implements ListCellRendere
label.setText(name);
}
protected abstract Icon getMemberIcon();
protected abstract String getMemberName(RemoteDesignMember member);
}

21
designer-base/src/main/java/com/fr/design/remote/ui/list/AddingMemberList.java

@ -1,13 +1,16 @@
package com.fr.design.remote.ui.list;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.report.constant.RoleType;
import com.fr.workspace.server.authority.RemoteDesignMember;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import java.util.Vector;
public class AddingMemberList extends MemberList {
public AddingMemberList() {
super();
}
@ -29,7 +32,21 @@ public class AddingMemberList extends MemberList {
@Override
protected void displaySelected() {
RemoteDesignMember member = getSelectedValue();
member.setSelected(!member.isSelected());
if (member != null) {
String keyTitle = member.getRoleType() == RoleType.CUSTOM ?
"Fine-Design_Basic_Utils_Are_You_Sure_To_Delete_The_Role_And_Its_Design_Authorities" :
"Fine-Design_Basic_Utils_Are_You_Sure_To_Delete_The_User_And_Its_Design_Authorities";
if (member.isSelected() && member.hasAuthority()){
int val = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText(keyTitle),
Toolkit.i18nText("Fine-Design_Basic_Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (val == JOptionPane.OK_OPTION) {
member.setSelected(!member.isSelected());
}
}
else {
member.setSelected(!member.isSelected());
}
}
revalidate();
repaint();
fireSelectedChange();

14
designer-base/src/main/java/com/fr/design/remote/ui/list/AddingMemberListCellRender.java

@ -1,11 +1,11 @@
package com.fr.design.remote.ui.list;
import com.fr.base.BaseUtils;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.workspace.server.authority.RemoteDesignMember;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
@ -14,7 +14,7 @@ import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
public class AddingMemberListCellRender extends JPanel implements ListCellRenderer<RemoteDesignMember> {
public abstract class AddingMemberListCellRender extends JPanel implements ListCellRenderer<RemoteDesignMember> {
private UILabel label;
private UICheckBox check;
@ -27,7 +27,7 @@ public class AddingMemberListCellRender extends JPanel implements ListCellRender
label = new UILabel();
label.setPreferredSize(new Dimension(260, 20));
this.setPreferredSize(new Dimension(this.getPreferredSize().width, 25));
label.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"));
label.setIcon(getMemberIcon());
check = new UICheckBox();
check.setSelected(false);
@ -46,7 +46,7 @@ public class AddingMemberListCellRender extends JPanel implements ListCellRender
check.setVisible(false);
fixLoadingDisplay();
} else {
this.setLabelText(member.getRealName() + "(" + member.getUsername() + ")");
this.setLabelText(getMemberName(member));
check.setVisible(true);
check.setSelected(member.isSelected());
recoveryCommonDisplay();
@ -64,7 +64,11 @@ public class AddingMemberListCellRender extends JPanel implements ListCellRender
}
private void recoveryCommonDisplay() {
label.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"));
label.setIcon(getMemberIcon());
label.setHorizontalAlignment(SwingConstants.LEFT);
}
protected abstract Icon getMemberIcon();
protected abstract String getMemberName(RemoteDesignMember member);
}

12
designer-base/src/main/java/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java

@ -1,9 +1,9 @@
package com.fr.design.remote.ui.list;
import com.fr.base.BaseUtils;
import com.fr.report.DesignAuthority;
import sun.swing.DefaultLookup;
import javax.swing.Icon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
@ -12,7 +12,7 @@ import javax.swing.border.EmptyBorder;
import java.awt.Color;
import java.awt.Component;
public class AuthorityListCellRenderer extends
public abstract class AuthorityListCellRenderer extends
JLabel implements ListCellRenderer<DesignAuthority> {
/**
@ -81,8 +81,8 @@ public class AuthorityListCellRenderer extends
}
setBorder(border);
this.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"));
this.setText(authority.getRealName() + "(" + authority.getUsername() + ")");
this.setIcon(getMemberIcon());
this.setText(getMemberName(authority));
return this;
}
@ -126,4 +126,8 @@ public class AuthorityListCellRenderer extends
p.isOpaque();
return !colorMatch && super.isOpaque();
}
protected abstract Icon getMemberIcon();
protected abstract String getMemberName(DesignAuthority authority);
}

25
designer-base/src/main/java/com/fr/design/remote/ui/list/cell/AddedCustomRoleListCellRender.java

@ -0,0 +1,25 @@
package com.fr.design.remote.ui.list.cell;
import com.fr.base.BaseUtils;
import com.fr.design.remote.constants.MemberIcon;
import com.fr.design.remote.ui.list.AddedMemberListCellRender;
import com.fr.workspace.server.authority.RemoteDesignMember;
import javax.swing.Icon;
/**
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2019/9/19
*/
public class AddedCustomRoleListCellRender extends AddedMemberListCellRender {
@Override
protected Icon getMemberIcon() {
return BaseUtils.readIcon(MemberIcon.CUSTOM_ROLE_ICON);
}
@Override
protected String getMemberName(RemoteDesignMember member) {
return member.getUsername();
}
}

25
designer-base/src/main/java/com/fr/design/remote/ui/list/cell/AddedUserListCellRender.java

@ -0,0 +1,25 @@
package com.fr.design.remote.ui.list.cell;
import com.fr.base.BaseUtils;
import com.fr.design.remote.constants.MemberIcon;
import com.fr.design.remote.ui.list.AddedMemberListCellRender;
import com.fr.workspace.server.authority.RemoteDesignMember;
import javax.swing.Icon;
/**
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2019/9/19
*/
public class AddedUserListCellRender extends AddedMemberListCellRender {
@Override
protected Icon getMemberIcon() {
return BaseUtils.readIcon(MemberIcon.USER_ICON);
}
@Override
protected String getMemberName(RemoteDesignMember member) {
return member.getRealName() + "(" + member.getUsername() + ")";
}
}

25
designer-base/src/main/java/com/fr/design/remote/ui/list/cell/AddingCustomRoleListCellRender.java

@ -0,0 +1,25 @@
package com.fr.design.remote.ui.list.cell;
import com.fr.base.BaseUtils;
import com.fr.design.remote.constants.MemberIcon;
import com.fr.design.remote.ui.list.AddingMemberListCellRender;
import com.fr.workspace.server.authority.RemoteDesignMember;
import javax.swing.Icon;
/**
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2019/9/19
*/
public class AddingCustomRoleListCellRender extends AddingMemberListCellRender {
@Override
protected Icon getMemberIcon() {
return BaseUtils.readIcon(MemberIcon.CUSTOM_ROLE_ICON);
}
@Override
protected String getMemberName(RemoteDesignMember member) {
return member.getUsername();
}
}

25
designer-base/src/main/java/com/fr/design/remote/ui/list/cell/AddingUserListCellRender.java

@ -0,0 +1,25 @@
package com.fr.design.remote.ui.list.cell;
import com.fr.base.BaseUtils;
import com.fr.design.remote.constants.MemberIcon;
import com.fr.design.remote.ui.list.AddingMemberListCellRender;
import com.fr.workspace.server.authority.RemoteDesignMember;
import javax.swing.Icon;
/**
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2019/9/19
*/
public class AddingUserListCellRender extends AddingMemberListCellRender {
@Override
protected Icon getMemberIcon() {
return BaseUtils.readIcon(MemberIcon.USER_ICON);
}
@Override
protected String getMemberName(RemoteDesignMember member) {
return member.getRealName() + "(" + member.getUsername() + ")";
}
}

25
designer-base/src/main/java/com/fr/design/remote/ui/list/cell/AuthorityCustomRoleListCellRender.java

@ -0,0 +1,25 @@
package com.fr.design.remote.ui.list.cell;
import com.fr.base.BaseUtils;
import com.fr.design.remote.constants.MemberIcon;
import com.fr.design.remote.ui.list.AuthorityListCellRenderer;
import com.fr.report.DesignAuthority;
import javax.swing.Icon;
/**
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2019/9/19
*/
public class AuthorityCustomRoleListCellRender extends AuthorityListCellRenderer {
@Override
protected Icon getMemberIcon() {
return BaseUtils.readIcon(MemberIcon.CUSTOM_ROLE_ICON);
}
@Override
protected String getMemberName(DesignAuthority authority) {
return authority.getUsername();
}
}

25
designer-base/src/main/java/com/fr/design/remote/ui/list/cell/AuthorityUserListCellRender.java

@ -0,0 +1,25 @@
package com.fr.design.remote.ui.list.cell;
import com.fr.base.BaseUtils;
import com.fr.design.remote.constants.MemberIcon;
import com.fr.design.remote.ui.list.AuthorityListCellRenderer;
import com.fr.report.DesignAuthority;
import javax.swing.Icon;
/**
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2019/9/19
*/
public class AuthorityUserListCellRender extends AuthorityListCellRenderer {
@Override
protected Icon getMemberIcon() {
return BaseUtils.readIcon(MemberIcon.USER_ICON);
}
@Override
protected String getMemberName(DesignAuthority authority) {
return authority.getRealName() + "(" + authority.getUsername() + ")";
}
}

4
designer-base/src/main/java/com/fr/design/report/WatermarkPane.java

@ -113,8 +113,8 @@ public class WatermarkPane extends BasicPane {
formulaPane = new TinyFormulaPane();
fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES);
fontSizeComboBox.setEditable(true);
horizontalGapSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, 200);
verticalGapSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, 100);
horizontalGapSpinner = new UnsignedIntUISpinner(100, Integer.MAX_VALUE, 1, 200);
verticalGapSpinner = new UnsignedIntUISpinner(50, Integer.MAX_VALUE, 1, 100);
horizontalGapSpinner.setPreferredSize(SPINNER_DIMENSION);
verticalGapSpinner.setPreferredSize(SPINNER_DIMENSION);
JPanel fontSizeTypePane = new JPanel(new BorderLayout(10,0));

3
designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java

@ -29,6 +29,7 @@ import com.fr.design.style.color.ColorSelectConfigManager;
import com.fr.design.style.color.ColorSelectDetailPane;
import com.fr.design.style.color.ColorSelectDialog;
import com.fr.design.style.color.ColorSelectable;
import com.fr.stable.AssistUtils;
/**
* TODO:面板缩放的功能没有考虑就是尾值过大导致超过界面显示的情况原来的那个实现完全是个BUG要缩放的情况也比较少就干脆以后弄吧
@ -217,7 +218,7 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl
* @return 同上
*/
public boolean isOriginalPlace() {
return startLabel.getValue() == min && endLabel.getValue() == max;
return AssistUtils.equals(startLabel.getValue(), min) && AssistUtils.equals(endLabel.getValue(), max);
}
/**

49
designer-base/src/main/java/com/fr/design/ui/util/EdtInvocationManager.java

@ -0,0 +1,49 @@
package com.fr.design.ui.util;
import org.jetbrains.annotations.NotNull;
import javax.swing.SwingUtilities;
import java.lang.reflect.InvocationTargetException;
/**
* 事件分发线程管理器用于管理用户线程
*
* @author vito
* @version 10.0
* Created by vito on 2019/9/16
*/
public abstract class EdtInvocationManager {
@NotNull
private static EdtInvocationManager ourInstance = new SwingEdtInvocationManager();
public abstract boolean isEventDispatchThread();
public abstract void invokeLater(@NotNull Runnable task);
public abstract void invokeAndWait(@NotNull Runnable task) throws InvocationTargetException, InterruptedException;
@NotNull
public static EdtInvocationManager getInstance() {
return ourInstance;
}
/**
* The default {@link EdtInvocationManager} implementation which works with the EDT via SwingUtilities.
*/
private static class SwingEdtInvocationManager extends EdtInvocationManager {
@Override
public boolean isEventDispatchThread() {
return SwingUtilities.isEventDispatchThread();
}
@Override
public void invokeLater(@NotNull Runnable task) {
SwingUtilities.invokeLater(task);
}
@Override
public void invokeAndWait(@NotNull Runnable task) throws InvocationTargetException, InterruptedException {
SwingUtilities.invokeAndWait(task);
}
}
}

77
designer-base/src/main/java/com/fr/design/ui/util/GraphicsConfig.java

@ -0,0 +1,77 @@
package com.fr.design.ui.util;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
import java.util.Map;
/**
* 图形渲染配置
*
* @author vito
* @version 10.0
* Created by vito on 2019/9/18
*/
public class GraphicsConfig {
private final Graphics2D myG;
private final Map myHints;
private final Composite myComposite;
private final Stroke myStroke;
public GraphicsConfig(@NotNull Graphics g) {
myG = (Graphics2D) g;
myHints = (Map) myG.getRenderingHints().clone();
myComposite = myG.getComposite();
myStroke = myG.getStroke();
}
public GraphicsConfig setAntialiasing(boolean on) {
myG.setRenderingHint(RenderingHints.KEY_ANTIALIASING, on ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF);
return this;
}
public GraphicsConfig setAlpha(float alpha) {
myG.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
return this;
}
public GraphicsConfig setRenderingHint(RenderingHints.Key hintKey, Object hintValue) {
myG.setRenderingHint(hintKey, hintValue);
return this;
}
public Graphics2D getG() {
return myG;
}
public GraphicsConfig setComposite(Composite composite) {
myG.setComposite(composite);
return this;
}
public GraphicsConfig setStroke(Stroke stroke) {
myG.setStroke(stroke);
return this;
}
public GraphicsConfig setupAAPainting() {
return setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)
.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
}
public GraphicsConfig disableAAPainting() {
return setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF)
.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
}
public GraphicsConfig paintWithAlpha(float alpha) {
assert 0.0f <= alpha && alpha <= 1.0f : "alpha should be in range 0.0f .. 1.0f";
return setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
}
public void restore() {
myG.setRenderingHints(myHints);
myG.setComposite(myComposite);
myG.setStroke(myStroke);
}
}

55
designer-base/src/main/java/com/fr/design/ui/util/UIUtil.java

@ -0,0 +1,55 @@
package com.fr.design.ui.util;
import com.fr.log.FineLoggerFactory;
import org.jetbrains.annotations.NotNull;
import javax.swing.SwingUtilities;
/**
* 一些常用的 GUI 工具
* <p>
* 为什么提供 invokeLaterIfNeeded invokeAndWaitIfNeeded这样的方法
* 因为 swing 渲染 UI 是单线程的如果直接使用
* {@link SwingUtilities#invokeLater(Runnable)} invokeLater 方法
* 嵌套的时候Runnable 会被放到事件循环队列的末尾从而变成异步而非立即执行
* 这是一处坑点invokeLaterIfNeeded 的行为当处于事件分发线程EDT
* 则直接运行当处于其他线程则使用 EDT 来执行
* <p>
* 方法{@link SwingUtilities#invokeAndWait(Runnable)}也有一个注意点
* 不允许在事件分发线程EDT中调用否则抛错所以也有必要加上判断 EDT 的逻辑
*
* @author vito
* @version 10.0
* Created by vito on 2019/9/16
*/
public class UIUtil {
/**
* AWT 线程上立即调用runnable否则使用 {@link SwingUtilities#invokeLater(Runnable)} 代替
*
* @param runnable 等待调用的 runnable
*/
public static void invokeLaterIfNeeded(@NotNull Runnable runnable) {
if (EdtInvocationManager.getInstance().isEventDispatchThread()) {
runnable.run();
} else {
EdtInvocationManager.getInstance().invokeLater(runnable);
}
}
/**
* AWT 线程上立即调用runnable否则使用 {@link SwingUtilities#invokeAndWait(Runnable)} 代替
*
* @param runnable 等待调用的 runnable
*/
public static void invokeAndWaitIfNeeded(@NotNull Runnable runnable) {
if (EdtInvocationManager.getInstance().isEventDispatchThread()) {
runnable.run();
} else {
try {
EdtInvocationManager.getInstance().invokeAndWait(runnable);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
}

118
designer-base/src/main/java/com/fr/design/update/actions/FileDownloader.java

@ -1,118 +0,0 @@
package com.fr.design.update.actions;
import com.fr.design.update.domain.UpdateConstants;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.design.update.domain.DownloadItem;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StableUtils;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.concurrent.ExecutionException;
/**
* Created by XINZAI on 2018/8/21.
*/
public abstract class FileDownloader extends SwingWorker<Boolean, DownloadItem> {
private static final int REPEAT_DOWNLOAD_TIMES = 3;
private DownloadItem[] files;
private String saveDir;
//已经完成的大小
private long completeSize;
public FileDownloader(DownloadItem[] files, String saveDir) {
this.files = files;
this.saveDir = saveDir;
}
@Override
protected Boolean doInBackground() throws Exception {
if (ArrayUtils.isNotEmpty(files)) {
setCompleteSize(0L);
for (DownloadItem item : files) {
for (int i = 0; i < REPEAT_DOWNLOAD_TIMES; i++) {
item.setTotalLength(0);
item.setDownloadLength(0);
download(item);
if (item.getTotalLength() == item.getDownloadLength()) {
break;
}
}
if (item.getTotalLength() != item.getDownloadLength()) {
JOptionPane.showMessageDialog(null,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Download_Failed"),
InterProviderFactory.getProvider().getLocText("Fine-Design_Updater_Alert"), JOptionPane.ERROR_MESSAGE);
return false;
} else {
item.setDownloadLength(0);
completeSize += item.getTotalLength();
}
}
}
return true;
}
@Override
protected void done() {
boolean success = false;
try {
success = get();
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (success) {
onDownloadSuccess();
} else {
onDownloadFailed();
}
}
private void download(DownloadItem item) throws Exception {
URL url = new URL(item.getUrl());
URLConnection connection = url.openConnection();
int total = connection.getContentLength();
item.setTotalLength(total);
File tempFile = new File(StableUtils.pathJoin(saveDir, item.getName()));
StableUtils.makesureFileExist(tempFile);
try ( InputStream reader = connection.getInputStream();
FileOutputStream writer = new FileOutputStream(tempFile)) {
byte[] buffer = new byte[UpdateConstants.BYTE];
int bytesRead = 0;
int totalBytesRead = 0;
while ((bytesRead = reader.read(buffer)) != -1) {
writer.write(buffer, 0, bytesRead);
buffer = new byte[UpdateConstants.BYTE];
totalBytesRead += bytesRead;
item.setDownloadLength(totalBytesRead);
publish(item);
}
}
}
/**
* 下载成功
*/
public abstract void onDownloadSuccess();
/**
* 下载失败
*/
public abstract void onDownloadFailed();
public long getCompleteSize() {
return completeSize;
}
public void setCompleteSize(long completeSize) {
this.completeSize = completeSize;
}
}

55
designer-base/src/main/java/com/fr/design/update/actions/FileProcess.java

@ -0,0 +1,55 @@
package com.fr.design.update.actions;
import com.fr.decision.update.info.UpdateCallBack;
import com.fr.decision.update.UpdateExecutor;
import com.fr.log.FineLoggerFactory;
import javax.swing.*;
import java.util.concurrent.ExecutionException;
/**
* @author Bryant
* @version 10.0
* Created by Bryant on 2019-09-12
*/
public abstract class FileProcess extends SwingWorker<Boolean, Void> {
private UpdateCallBack callBack;
public FileProcess(UpdateCallBack callBack) {
this.callBack = callBack;
}
@Override
protected Boolean doInBackground() throws Exception {
return UpdateExecutor.getInstance().execute(callBack);
}
@Override
protected void done() {
boolean success = false;
try {
success = get();
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (success) {
onDownloadSuccess();
} else {
onDownloadFailed();
}
}
/**
* 下载成功
*/
public abstract void onDownloadSuccess();
/**
* 下载失败
*/
public abstract void onDownloadFailed();
}

102
designer-base/src/main/java/com/fr/design/update/domain/DownloadItem.java

@ -1,102 +0,0 @@
package com.fr.design.update.domain;
import com.fr.general.ComparatorUtils;
import com.fr.json.JSONObject;
import java.util.Date;
/**
* Created by XINZAI on 2018/8/21.
*/
public class DownloadItem {
//显示为百分比
private static final int PERCENTAGE_RATIO = 100;
//显示kB
private static final int BYTETOKB_RATIO = 1000;
private String name;
private String url;
private long size;
private int totalLength;
private int downloadLength;
public DownloadItem(JSONObject json) {
this(json.optString("name"), json.optString("url"), json.optLong("size"));
}
public DownloadItem(String name, String url, long size) {
this.name = name;
this.url = url;
this.size = size;
}
public String getName() {
return name;
}
public String getUrl() {
return url + "?v=" + new Date().getTime();
}
public long getSize() {
return size;
}
public void setSize(long size) {
this.size = size;
}
public int getTotalLength() {
return totalLength;
}
public int getDownloadLength() {
return downloadLength;
}
public void setTotalLength(int totalLength) {
this.totalLength = totalLength;
}
public void setDownloadLength(int downloadLength) {
this.downloadLength = downloadLength;
}
public int getProgressValue() {
return (int) ((downloadLength / (double) totalLength) * PERCENTAGE_RATIO);
}
public String getProgressString() {
return downloadLength / BYTETOKB_RATIO + "KB/" + totalLength / BYTETOKB_RATIO + "KB";
}
/**
* 转化为字符串
*
* @return 字符串
*/
@Override
public String toString() {
return "name:" + name + ";download:" + getProgressString();
}
@Override
public boolean equals(Object obj) {
return obj instanceof DownloadItem
&& ComparatorUtils.equals(((DownloadItem) obj).name, name)
&& ComparatorUtils.equals(((DownloadItem) obj).url, url);
}
/**
* 返回一个hash码
*
* @return hash码
*/
@Override
public int hashCode() {
return name.hashCode();
}
}

1
designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java

@ -12,6 +12,7 @@ import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.JDialog;

195
designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java

@ -1,5 +1,7 @@
package com.fr.design.update.ui.dialog;
import com.fr.decision.update.info.UpdateCallBack;
import com.fr.decision.update.info.UpdateProgressCallBack;
import com.fr.design.RestartHelper;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.dialog.UIDialog;
@ -10,8 +12,7 @@ import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.update.actions.FileDownloader;
import com.fr.design.update.domain.DownloadItem;
import com.fr.design.update.actions.FileProcess;
import com.fr.design.update.domain.UpdateConstants;
import com.fr.design.update.domain.UpdateInfoCachePropertyManager;
import com.fr.design.update.factory.DirectoryOperationFactory;
@ -27,7 +28,6 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.DateUtils;
import com.fr.general.GeneralContext;
import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils;
import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient;
import com.fr.general.http.HttpToolbox;
@ -39,18 +39,10 @@ import com.fr.stable.EncodeConstants;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.third.org.apache.commons.codec.digest.DigestUtils;
import com.fr.workspace.WorkContext;
import com.sun.java.swing.plaf.motif.MotifProgressBarUI;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.RowSorter;
import javax.swing.SortOrder;
import javax.swing.SwingConstants;
import javax.swing.SwingWorker;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.table.TableRowSorter;
@ -67,19 +59,14 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
/**
@ -107,7 +94,6 @@ public class UpdateMainDialog extends UIDialog {
private static final SimpleDateFormat CHANGELOG_FORMAT = new SimpleDateFormat("M/d/y, h:m:s a", Locale.ENGLISH);
private static final SimpleDateFormat UPDATE_INFO_TABLE_FORMAT = new SimpleDateFormat("yyyy.MM.dd");
private Set<DownloadItem> downloadItems = new HashSet<DownloadItem>();
private JSONObject downloadFileConfig;
//最新版本标签
private LoadingLabel loadingLabel;
@ -166,14 +152,12 @@ public class UpdateMainDialog extends UIDialog {
public void setAutoUpdateAfterInit() {
autoUpdateAfterInit = true;
}
private void initUpdateActionPane() {
double[] rowUpdateSubContentPaneSize = {UPDATE_CONTENT_PANE_ROW_SIZE, TableLayout.PREFERRED, UPDATE_CONTENT_PANE_ROW_SIZE};
double[] rowUpdateContentPaneSize = {TableLayout.PREFERRED};
double[] columnUpdateSubContentPaneProgressSize = {TableLayout.FILL, TableLayout.PREFERRED};
double[] columnUpdateSubContentPaneSize = {UPDATE_CONTENT_PANE_COLUMN_SIZE, TableLayout.FILL, TableLayout.PREFERRED};
JPanel progressBarPane = new JPanel(new BorderLayout());
progressBar = new JProgressBar();
progressBar.setUI(new MotifProgressBarUI());
progressBar.setForeground(UpdateConstants.BAR_COLOR);
@ -601,62 +585,6 @@ public class UpdateMainDialog extends UIDialog {
}
break;
}
initMapWithInfo(downloadFileConfig);
}
public void initMapWithInfo(JSONObject result) {
addJarNameToMap(result, "designer");
addJarNameToMap(result, "server");
}
private void addJarNameToMap(JSONObject result, String category) {
JSONArray jsonArray = result.optJSONArray(category);
if (jsonArray != null) {
for (int i = 0, len = jsonArray.length(); i < len; i++) {
JSONObject jo = jsonArray.optJSONObject(i);
String downloadName = jo.optString("name");
String downloadUrl = jo.optString("url");
long downloadSize = jo.optLong("size");
if (ComparatorUtils.equals(category, "server")) {
File currentJAR = new File(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), ProjectConstants.LIB_NAME, downloadName));
String currentMD5 = getCurrentJarMD5(currentJAR);
String downloadMD5 = jo.optString("md5");
boolean exist = currentJAR.exists() && ComparatorUtils.equals(currentJAR.length(), downloadSize) && ComparatorUtils.equals(currentMD5, downloadMD5);
if (exist) {
// 如果jar包存在且MD5值和大小与oss上的一致 不下载
continue;
}
}
downloadItems.add(new DownloadItem(downloadName, downloadUrl, downloadSize));
}
}
}
/**
* 获取当前jar的md5
*
* @param currentJAR
* @return
*/
private String getCurrentJarMD5(File currentJAR) {
String md5 = StringUtils.EMPTY;
FileInputStream input = null;
try {
input = new FileInputStream(currentJAR);
md5 = DigestUtils.md5Hex(input);
} catch (Exception ignore) {
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
return md5;
}
/**
@ -669,31 +597,19 @@ public class UpdateMainDialog extends UIDialog {
if (updateSuccessful) {
RestartHelper.restart();
} else {
progressBar.setVisible(true);
UpdateCallBack callBack = new UpdateProgressCallBack(progressBar);
deletePreviousPropertyFile();
updateButton.setEnabled(false);
progressBar.setVisible(true);
updateLabel.setVisible(false);
new FileDownloader(
downloadItems.toArray(new DownloadItem[downloadItems.size()]),
StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DOWNLOAD_DIR)) {
@Override
protected void process(java.util.List<DownloadItem> chunks) {
DownloadItem fileInfo = chunks.get(chunks.size() - 1);
progressBar.setString(fileInfo.getName() + " " + fileInfo.getProgressString());
progressBar.setValue(fileInfo.getProgressValue());
}
new FileProcess(callBack) {
@Override
public void onDownloadSuccess() {
updateButton.setEnabled(true);
progressBar.setVisible(false);
backup();
putNewFiles();
updateSuccessful = true;
updateButton.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Restart_Designer"));
}
@Override
public void onDownloadFailed() {
progressBar.setVisible(false);
@ -719,109 +635,12 @@ public class UpdateMainDialog extends UIDialog {
}
}
/**
* JAR包更新的时候备份老的jar包包括设计器相关的和服务器相关的几个
*/
private void backup() {
String installHome = StableUtils.getInstallHome();
//jar包备份文件的目录为"backup/"+jar包当前版本号
String todayBackupDir = StableUtils.pathJoin(installHome, getBackupDirectory(), (GeneralUtils.readBuildNO()));
backupFilesFromInstallEnv(installHome, todayBackupDir, getJARList4Server());
backupFilesFromInstallLib(installHome, todayBackupDir, getJARList4Designer());
jarCurrentLabel.setText(downloadFileConfig.optString("buildNO"));
}
private void backupFilesFromInstallEnv(String installHome, String todayBackupDir, List<String> files) {
for (String file : files) {
try {
IOUtils.copy(
new File(StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)),
new File(StableUtils.pathJoin(todayBackupDir)));
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
}
}
private void backupFilesFromInstallLib(String installHome, String todayBackupDir, List<String> files) {
for (String file : files) {
try {
IOUtils.copy(
new File(StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file)),
new File(StableUtils.pathJoin(todayBackupDir)));
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
}
}
private void putNewFiles() {
Map<String, String> map = new HashMap<String, String>();
java.util.List<String> list = new ArrayList<String>();
String installHome = StableUtils.getInstallHome();
putNewFilesToInstallLib(installHome, getDownLoadJAR4Designer(), map, list);
putNewFilesToInstallEnv(installHome, getDownLoadJAR4Server(), map, list);
RestartHelper.saveFilesWhichToMove(map);
RestartHelper.saveFilesWhichToDelete(list.toArray(new String[list.size()]));
}
private void putNewFilesToInstallLib(String installHome, String[] files, Map<String, String> map, java.util.List<String> list) {
for (String file : files) {
map.put(StableUtils.pathJoin(installHome, UpdateConstants.DOWNLOAD_DIR, file),
StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file));
list.add(StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file));
}
}
private void putNewFilesToInstallEnv(String installHome, String[] files, Map<String, String> map, java.util.List<String> list) {
for (String file : files) {
map.put(StableUtils.pathJoin(installHome, UpdateConstants.DOWNLOAD_DIR, file),
StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file));
list.add(StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file));
}
}
//获取备份目录
private String getBackupDirectory() {
return UpdateConstants.DESIGNER_BACKUP_DIR;
}
//获取服务器jar包列表
private List<String> getJARList4Server() {
return UpdateConstants.JARS_FOR_SERVER_X;
}
//获取设计器jar包列表
private List<String> getJARList4Designer() {
return UpdateConstants.JARS_FOR_DESIGNER_X;
}
//获取服务器jar包下载列表
private String[] getDownLoadJAR4Server() {
ArrayList<String> jarList = new ArrayList<String>();
List<String> serverItems = getJARList4Server();
for (DownloadItem downloadItem : downloadItems) {
String downloadItemName = downloadItem.getName();
if (serverItems.contains(downloadItemName)) {
jarList.add(downloadItemName);
}
}
return jarList.toArray(new String[jarList.size()]);
}
//获取设计器jar包下载列表
private String[] getDownLoadJAR4Designer() {
ArrayList<String> jarList = new ArrayList<String>();
List<String> designerJarItems = getJARList4Designer();
for (DownloadItem downloadItem : downloadItems) {
String downloadItemName = downloadItem.getName();
if (designerJarItems.contains(downloadItemName)) {
jarList.add(downloadItemName);
}
}
return jarList.toArray(new String[jarList.size()]);
}
//获取更新日志缓存配置文件名
private String getUpdateCacheConfig() {
return UpdateConstants.UPDATE_CACHE_CONFIG_X;

15
designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java

@ -31,6 +31,7 @@ import com.fr.design.style.color.ColorFactory;
import com.fr.design.style.color.ColorSelectBox;
import com.fr.design.style.color.ColorSelectable;
import com.fr.general.FRFont;
import com.fr.stable.AssistUtils;
import com.fr.stable.Constants;
import com.fr.stable.OperatingSystem;
import com.fr.stable.StringUtils;
@ -728,12 +729,16 @@ public final class GUICoreUtils {
* @return 布尔值
*/
public static boolean removeJListSelectedNodes(Window ancestorWindow, JList nodeList) {
return removeJListSelectedNodes(ancestorWindow, nodeList, "Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item");
}
public static boolean removeJListSelectedNodes(Window ancestorWindow, JList nodeList, String key) {
int selectedIndex = nodeList.getSelectedIndex();
if (selectedIndex == -1) {
return false;
}
int returnVal = JOptionPane.showConfirmDialog(ancestorWindow, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove"),
int returnVal = JOptionPane.showConfirmDialog(ancestorWindow, com.fr.design.i18n.Toolkit.i18nText(key), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove"),
JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.OK_OPTION) {
int minSelectedIndex = nodeList.getMinSelectionIndex();
@ -890,10 +895,10 @@ public final class GUICoreUtils {
* @return 同上
*/
public static boolean isTheSameRect(Rectangle oneRect, Rectangle otherRect) {
return oneRect.getX() == otherRect.getX()
&& oneRect.getY() == otherRect.getY()
&& oneRect.getWidth() == otherRect.getWidth()
&& oneRect.getHeight() == otherRect.getHeight();
return AssistUtils.equals(oneRect.getX(), otherRect.getX())
&& AssistUtils.equals(oneRect.getY(), otherRect.getY())
&& AssistUtils.equals(oneRect.getWidth(), otherRect.getWidth())
&& AssistUtils.equals(oneRect.getHeight(), otherRect.getHeight());
}
/**

5
designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java

@ -9,6 +9,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.form.ui.NumberEditor;
import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
@ -226,7 +227,7 @@ public class NumberEditorValidatePane extends JPanel {
}
allowNegativeCheckBox.setSelected(e.isAllowNegative());
if (e.getMaxValue() == Double.MAX_VALUE) {
if (AssistUtils.equals(e.getMaxValue(),Double.MAX_VALUE)) {
setMaxValueCheckBox.setSelected(false);
maxValueSpinner.setValue(Double.MAX_VALUE);
maxValueSpinner.setEnabled(false);
@ -236,7 +237,7 @@ public class NumberEditorValidatePane extends JPanel {
maxValueSpinner.setValue(e.getMaxValue());
}
if (e.getMinValue() == -Double.MAX_VALUE) {
if (AssistUtils.equals(e.getMinValue(),-Double.MAX_VALUE)) {
setMinValueCheckBox.setSelected(false);
minValueSpinner.setValue(-Double.MAX_VALUE);
minValueSpinner.setEnabled(false);

5
designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java

@ -633,9 +633,6 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
for (int i = 0; i < len; i++) {
currentColumnNames[i] = new ColumnName(colNames[i]);
}
if (currentColumnNames == null) {
currentColumnNames = new ColumnName[0];
}
return currentColumnNames;
}
@ -701,7 +698,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
} else {
dmlConfigComboBox.setSelectedIndex(0);
}
jobs = new NameSubmitJob[dmlConfig == null ? 0 : dmlConfig.getSubmitJobCount()];
jobs = new NameSubmitJob[dmlConfig.getSubmitJobCount()];
for (int i = 0; i < jobs.length; i++) {
jobs[i] = dmlConfig.getSubmitJob(i);
}

54
designer-base/src/main/java/com/fr/start/BaseDesigner.java

@ -5,25 +5,28 @@ package com.fr.start;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.constants.DesignerLaunchStatus;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.fun.DesignerStartOpenFileProcessor;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.DesignUtils;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.event.Null;
import com.fr.file.FILE;
import com.fr.file.FILEFactory;
import com.fr.file.FileFILE;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.module.ModuleEvent;
import com.fr.stable.OperatingSystem;
import java.awt.Window;
import java.awt.*;
import java.io.File;
import java.lang.reflect.Method;
@ -43,6 +46,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
}
private void init() {
prepare();
// 初始化look and feel.这个在预加载之前执行是因为lookAndFeel里的东西,预加载时也要用到
DesignUtils.initLookAndFeel();
// 初始化Log Handler
@ -50,26 +54,53 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
createDesignerFrame();
}
/**
* 准备一些订阅
*/
private void prepare() {
EventDispatcher.listen(DesignerLaunchStatus.DESIGNER_INIT_COMPLETE, new Listener<Null>() {
@Override
public void on(Event event, Null param) {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
// 打开上次的文件
showDesignerFrame(false);
DesignerLaunchStatus.setStatus(DesignerLaunchStatus.OPEN_LAST_FILE_COMPLETE);
}
});
}
});
EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener<Null>() {
@Override
public void on(Event event, Null param) {
collectUserInformation();
}
});
}
public void show() {
collectUserInformation();
showDesignerFrame(false);
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
refreshTemplateTree();
}
});
}
private void refreshTemplateTree() {
//TODO: 2019-06-14 这里有啥作用?
DesignerContext.getDesignerFrame().refreshEnv();
for (int i = 0; !TemplateTreePane.getInstance().getTemplateFileTree().isTemplateShowing() && i < LOAD_TREE_MAXNUM; i++) {
TemplateTreePane.getInstance().getTemplateFileTree().refresh();
}
DesignerContext.getDesignerFrame().setVisible(true);
DesignerContext.getDesignerFrame().resizeFrame();
}
private void createDesignerFrame() {
new DesignerFrame(this);
}
private void showDesignerFrame(boolean isException) {
try {
FILE file = null;
@ -94,8 +125,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
}
}
} else {
file = FILEFactory.createFILE(FILEFactory.ENV_PREFIX
+ DesignerEnvManager.getEnvManager().getLastOpenFile());
file = FILEFactory.createFILE(FILEFactory.ENV_PREFIX + DesignerEnvManager.getEnvManager().getLastOpenFile());
}
DesignerFrame df = DesignerContext.getDesignerFrame();
isException = openFile(df, isException, file);

4
designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java

@ -38,7 +38,7 @@ public class FineEmbedServerActivator extends Activator {
} catch (LifecycleException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}finally {
} finally {
FineEmbedServerMonitor.getInstance().setComplete();
}
}
@ -86,7 +86,7 @@ public class FineEmbedServerActivator extends Activator {
private void stopSpring() {
AnnotationConfigWebApplicationContext context = ModuleRole.ServerRoot.getSingleton(AnnotationConfigWebApplicationContext.class);
AnnotationConfigWebApplicationContext context = ModuleRole.ServerRoot.findSingleton(AnnotationConfigWebApplicationContext.class);
if (context != null) {
context.stop();
context.destroy();

55
designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java

@ -1,25 +1,32 @@
package com.fr.start.server;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.gui.iprogressbar.ProgressDialog;
import com.fr.design.mainframe.DesignerContext;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.event.Null;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* 内置服务器启动监视器
* Created by zack on 2018/8/21.
*
* @author zack
* @date 2018/8/21
*/
public class FineEmbedServerMonitor {
private int progress;
private static final int COMPLETE = 100;//启动完成
private static final int STEP = 5;//随便设置一个假的进度条
private static final int STEP_HEARTBEAT = 2000;//2秒更新进度
private static final int STEP = 1;
/**
* 40ms更新进度
*/
private static final int STEP_HEARTBEAT = 40;
private static volatile FineEmbedServerMonitor monitor;
private static ProgressDialog progressBar = DesignerContext.getDesignerFrame().getProgressDialog();
private FineEmbedServerMonitor() {
}
@ -46,7 +53,7 @@ public class FineEmbedServerMonitor {
}
public int getProgress() {
if (progress == COMPLETE) {
if (progress == progressBar.getProgressMaximum()) {
return progress;
} else {
progress += STEP;
@ -55,7 +62,7 @@ public class FineEmbedServerMonitor {
}
public void setComplete() {
this.progress = COMPLETE;
this.progress = progressBar.getProgressMaximum();
}
public void reset() {
@ -63,30 +70,28 @@ public class FineEmbedServerMonitor {
}
public boolean isComplete() {
return this.progress == COMPLETE;
return this.progress >= progressBar.getProgressMaximum();
}
public void monitor() {
ExecutorService service = Executors.newSingleThreadExecutor(new NamedThreadFactory("FineEmbedServerMonitor"));
service.submit(new Runnable() {
final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1,
new NamedThreadFactory("FineEmbedServerMonitor"));
scheduler.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
while (!isComplete()) {
if (!DesignerContext.getDesignerFrame().getProgressDialog().isVisible()) {
DesignerContext.getDesignerFrame().showProgressDialog();
DesignerContext.getDesignerFrame().getProgressDialog().updateLoadingText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Embed_Server"));
}
DesignerContext.getDesignerFrame().updateProgress(getProgress());
try {
Thread.sleep(STEP_HEARTBEAT);
} catch (InterruptedException ignore) {
Thread.currentThread().interrupt();
}
if (isComplete()) {
scheduler.shutdown();
DesignerContext.getDesignerFrame().hideProgressDialog();
return;
}
DesignerContext.getDesignerFrame().hideProgressDialog();
if (!DesignerContext.getDesignerFrame().getProgressDialog().isVisible()) {
DesignerContext.getDesignerFrame().showProgressDialog();
DesignerContext.getDesignerFrame().getProgressDialog()
.updateLoadingText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Embed_Server"));
}
DesignerContext.getDesignerFrame().updateProgress(getProgress());
}
});
service.shutdown();
}, 0, STEP_HEARTBEAT, TimeUnit.MILLISECONDS);
}
}

13
designer-base/src/main/java/com/fr/start/server/ServerManageFrame.java

@ -5,18 +5,12 @@ import com.fr.design.gui.ibutton.UIButton;
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.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.log.FineLoggerFactory;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
* 内置Tomcat服务器管理界面
@ -46,7 +40,6 @@ public class ServerManageFrame extends JFrame {
private ServerManageFrame() {
DesignUtils.initLookAndFeel();
this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/trayStarted.png"));
JPanel contentPane = (JPanel) this.getContentPane();

12
designer-base/src/main/java/com/fr/start/server/ServerTray.java

@ -1,6 +1,7 @@
package com.fr.start.server;
import com.fr.base.BaseUtils;
import com.fr.design.ui.util.UIUtil;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.ListenerAdaptor;
@ -85,6 +86,7 @@ public class ServerTray {
//创建退出菜单监听器
ActionListener exitListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
exit();
@ -177,7 +179,13 @@ public class ServerTray {
}
public static void init() {
if (INSTANCE == null)
INSTANCE = new ServerTray();
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
if (INSTANCE == null) {
INSTANCE = new ServerTray();
}
}
});
}
}

8
designer-base/src/main/resources/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/FormulaTokenMaker.flex

@ -578,7 +578,13 @@ FunctionNames = "ABS"|
"YEAR"|
"year"|
"YEARDELTA"|
"yeardelta"
"yeardelta"|
"SUMPRECISE"|
"sumprecise"|
"QUERY"|
"query"|
"WEBIMAGE"|
"webimage"
%state MLC

BIN
designer-base/src/main/resources/com/fr/design/remote/images/icon_Custom_Role_normal@1x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 B

BIN
designer-base/src/main/resources/com/fr/design/remote/images/icon_Custom_Role_normal@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

70
designer-base/src/test/java/com/fr/design/ExtraDesignClassManagerTest.java

@ -0,0 +1,70 @@
package com.fr.design;
import com.fr.config.dao.DaoContext;
import com.fr.config.dao.impl.LocalClassHelperDao;
import com.fr.config.dao.impl.LocalEntityDao;
import com.fr.config.dao.impl.LocalXmlEntityDao;
import com.fr.design.fun.ToolbarItemProvider;
import com.fr.design.gui.core.WidgetOption;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.general.ModuleContext;
import com.fr.log.FineLoggerFactory;
import com.fr.report.restriction.CellCountRestriction;
import com.fr.report.restriction.ReportRestrictionScene;
import com.fr.restriction.Restrictions;
import com.fr.stable.Filter;
import com.fr.stable.module.Module;
import junit.framework.TestCase;
import org.easymock.EasyMock;
import org.junit.Assert;
import java.util.HashSet;
import java.util.Set;
/**
* @author zack
* @version 10.0
* Created by zack on 2019/9/17
*/
public class ExtraDesignClassManagerTest extends TestCase {
@Override
protected void setUp() throws Exception {
DaoContext.setEntityDao(new LocalEntityDao());
DaoContext.setClassHelperDao(new LocalClassHelperDao());
DaoContext.setXmlEntityDao(new LocalXmlEntityDao());
ModuleContext.startModule(Module.PAGE_MODULE);
Restrictions.register(ReportRestrictionScene.CELL_COUNT, new CellCountRestriction());
}
public void testGetWebOption() {
try {
final JTemplate jTemplate = new JVirtualTemplate(null);
ToolbarItemProvider item = EasyMock.mock(ToolbarItemProvider.class);
ToolbarItemProvider item1 = EasyMock.mock(ToolbarItemProvider.class);
EasyMock.expect(item.accept(jTemplate)).andReturn(false).anyTimes();
EasyMock.expect(item.classForWidget()).andReturn(null).anyTimes();
EasyMock.expect(item.iconPathForWidget()).andReturn("").anyTimes();
EasyMock.expect(item.nameForWidget()).andReturn("1").anyTimes();
EasyMock.expect(item1.accept(jTemplate)).andReturn(true).anyTimes();
EasyMock.expect(item1.classForWidget()).andReturn(null).anyTimes();
EasyMock.expect(item1.iconPathForWidget()).andReturn("").anyTimes();
EasyMock.expect(item1.nameForWidget()).andReturn("2").anyTimes();
EasyMock.replay(item);
EasyMock.replay(item1);
Set<ToolbarItemProvider> set = new HashSet<>();
set.add(item);
set.add(item1);
WidgetOption[] widgetOptions = ExtraDesignClassManager.getInstance().getWebWidgetOptions(set, new Filter<ToolbarItemProvider>() {
@Override
public boolean accept(ToolbarItemProvider toolbarItemProvider) {
return toolbarItemProvider.accept(jTemplate);
}
});
Assert.assertEquals(1, widgetOptions.length);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}

391
designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java

@ -1,31 +1,33 @@
package com.fr.design;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.base.ChartInternationalNameContentBean;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.chart.fun.ChartTypeProvider;
import com.fr.chartx.attr.ChartProvider;
import com.fr.common.annotations.Compatible;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.chart.fun.IndependentChartUIProvider;
import com.fr.design.chart.fun.ChartTypeUIProvider;
import com.fr.design.chart.gui.ChartWidgetOption;
import com.fr.design.chartinterface.AreaIndependentChartInterface;
import com.fr.design.chartinterface.BarIndependentChartInterface;
import com.fr.design.chartinterface.BubbleIndependentChartInterface;
import com.fr.design.chartinterface.ColumnIndependentChartInterface;
import com.fr.design.chartinterface.CustomIndependentChartInterface;
import com.fr.design.chartinterface.DonutIndependentChartInterface;
import com.fr.design.chartinterface.FunnelIndependentChartInterface;
import com.fr.design.chartinterface.GanttIndependentChartInterface;
import com.fr.design.chartinterface.GisMapIndependentChartInterface;
import com.fr.design.chartinterface.LineIndependentChartInterface;
import com.fr.design.chartinterface.MapIndependentChartInterface;
import com.fr.design.chartinterface.MeterIndependentChartInterface;
import com.fr.design.chartinterface.PieIndependentChartInterface;
import com.fr.design.chartinterface.RadarIndependentChartInterface;
import com.fr.design.chartinterface.RangeIndependentChartInterface;
import com.fr.design.chartinterface.StockIndependentChartInterface;
import com.fr.design.chartinterface.XYScatterIndependentChartInterface;
import com.fr.design.type.ui.AreaChartTypeUI;
import com.fr.design.type.ui.BarChartTypeUI;
import com.fr.design.type.ui.BubbleChartTypeUI;
import com.fr.design.type.ui.ColumnChartTypeUI;
import com.fr.design.type.ui.CustomChartTypeUI;
import com.fr.design.type.ui.DonutChartTypeUI;
import com.fr.design.type.ui.FunnelChartTypeUI;
import com.fr.design.type.ui.GanttChartTypeUI;
import com.fr.design.type.ui.GisMapChartTypeUI;
import com.fr.design.type.ui.LineChartTypeUI;
import com.fr.design.type.ui.MapChartTypeUI;
import com.fr.design.type.ui.MeterChartTypeUI;
import com.fr.design.type.ui.PieChartTypeUI;
import com.fr.design.type.ui.RadarChartTypeUI;
import com.fr.design.type.ui.RangeChartTypeUI;
import com.fr.design.type.ui.StockChartTypeUI;
import com.fr.design.type.ui.XYScatterChartTypeUI;
import com.fr.design.condition.ConditionAttributesPane;
import com.fr.design.gui.core.WidgetOption;
import com.fr.design.gui.frpane.AttributeChangeListener;
@ -38,10 +40,13 @@ import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPa
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.extended.chart.AbstractChart;
import com.fr.form.ui.ChartEditor;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.invoke.Reflect;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.PiePlot4VanChart;
import com.fr.plugin.chart.area.VanChartAreaPlot;
import com.fr.plugin.chart.bubble.VanChartBubblePlot;
@ -112,8 +117,8 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
private static ChartTypeInterfaceManager classManager = new ChartTypeInterfaceManager();
private static LinkedHashMap<String, CloseableContainedMap<String, IndependentChartUIProvider, LinkedHashMap>> chartTypeInterfaces =
new LinkedHashMap<String, CloseableContainedMap<String, IndependentChartUIProvider, LinkedHashMap>>();
private static LinkedHashMap<String, CloseableContainedMap<String, ChartTypeUIProvider, LinkedHashMap>> chartTypeInterfaces =
new LinkedHashMap<String, CloseableContainedMap<String, ChartTypeUIProvider, LinkedHashMap>>();
private static Map<String, String> idAndPriorityMap = new HashMap<String, String>();
@ -156,18 +161,18 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
public static WidgetOption[] initWidgetOption() {
ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames();
ChartWidgetOption[] child = new ChartWidgetOption[typeName.length];
String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDs();
ChartWidgetOption[] child = new ChartWidgetOption[chartIDs.length];
int index = 0;
for (ChartInternationalNameContentBean bean : typeName) {
String plotID = bean.getChartID();
ChartProvider[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID);
if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(plotID)) {
for (String chartID : chartIDs) {
ChartProvider[] rowChart = ChartTypeManager.getInstance().getChartTypes(chartID);
if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(chartID)) {
continue;
}
String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(plotID);
String name = ChartTypeInterfaceManager.getInstance().getName(chartID);
String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(chartID);
Icon icon = IOUtils.readIcon(iconPath);
child[index] = new ChartWidgetOption(InterProviderFactory.getProvider().getLocText(bean.getName()), icon, ChartEditor.class, plotID);
child[index] = new ChartWidgetOption(name, icon, ChartEditor.class, chartID);
index++;
}
@ -200,36 +205,36 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
private static void readDefault() {
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.COLUMN_CHART, new ColumnIndependentChartInterface());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.LINE_CHART, new LineIndependentChartInterface());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.BAR_CHART, new BarIndependentChartInterface());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.PIE_CHART, new PieIndependentChartInterface());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.AREA_CHART, new AreaIndependentChartInterface());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.SCATTER_CHART, new XYScatterIndependentChartInterface());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.BUBBLE_CHART, new BubbleIndependentChartInterface());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.RADAR_CHART, new RadarIndependentChartInterface());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.STOCK_CHART, new StockIndependentChartInterface());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.METER_CHART, new MeterIndependentChartInterface());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.RANGE_CHART, new RangeIndependentChartInterface());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.CUSTOM_CHART, new CustomIndependentChartInterface());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.GANTT_CHART, new GanttIndependentChartInterface());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.DONUT_CHART, new DonutIndependentChartInterface());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.MAP_CHART, new MapIndependentChartInterface());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.GIS_CHAER, new GisMapIndependentChartInterface());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.FUNNEL_CHART, new FunnelIndependentChartInterface());
}
private static void addChartTypeInterface(String priority, String plotID, IndependentChartUIProvider provider) {
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.COLUMN_CHART, new ColumnChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.LINE_CHART, new LineChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.BAR_CHART, new BarChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.PIE_CHART, new PieChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.AREA_CHART, new AreaChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.SCATTER_CHART, new XYScatterChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.BUBBLE_CHART, new BubbleChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.RADAR_CHART, new RadarChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.STOCK_CHART, new StockChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.METER_CHART, new MeterChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.RANGE_CHART, new RangeChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.CUSTOM_CHART, new CustomChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.GANTT_CHART, new GanttChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.DONUT_CHART, new DonutChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.MAP_CHART, new MapChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.GIS_CHAER, new GisMapChartTypeUI());
addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.FUNNEL_CHART, new FunnelChartTypeUI());
}
private static void addChartTypeInterface(String priority, String plotID, ChartTypeUIProvider provider) {
if (chartTypeInterfaces != null) {
if (!chartTypeInterfaces.containsKey(priority)) {
//新建一个具体图表列表
CloseableContainedMap<String, IndependentChartUIProvider, LinkedHashMap> chartUIList
= new CloseableContainedMap<String, IndependentChartUIProvider, LinkedHashMap>(LinkedHashMap.class);
CloseableContainedMap<String, ChartTypeUIProvider, LinkedHashMap> chartUIList
= new CloseableContainedMap<String, ChartTypeUIProvider, LinkedHashMap>(LinkedHashMap.class);
chartUIList.put(plotID, provider);
chartTypeInterfaces.put(priority, chartUIList);
} else {
Map<String, IndependentChartUIProvider> chartUIList = chartTypeInterfaces.get(priority);
Map<String, ChartTypeUIProvider> chartUIList = chartTypeInterfaces.get(priority);
if (!chartUIList.containsKey(plotID)) {
chartUIList.put(plotID, provider);
}
@ -238,7 +243,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
}
}
private IndependentChartUIProvider getChartTypeInterface(String plotID) {
private ChartTypeUIProvider getChartTypeInterface(String plotID) {
if (idAndPriorityMap.containsKey(plotID)) {
String priority = idAndPriorityMap.get(plotID);
if (chartTypeInterfaces.containsKey(priority)) {
@ -267,95 +272,205 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority)) {
Map<String, IndependentChartUIProvider> chartUIList = chartTypeInterfaces.get(priority);
Map<String, ChartTypeUIProvider> chartUIList = chartTypeInterfaces.get(priority);
Iterator<Map.Entry<String, IndependentChartUIProvider>> iterator = chartUIList.entrySet().iterator();
Iterator<Map.Entry<String, ChartTypeUIProvider>> iterator = chartUIList.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, IndependentChartUIProvider> entry = iterator.next();
String plotID = entry.getKey();
AbstractChartTypePane pane = entry.getValue().getPlotTypePane();
if (AssistUtils.equals(pane.title4PopupWindow(), TYPE_PANE_DEFAULT_TITLE)) {
continue;
try {
Map.Entry<String, ChartTypeUIProvider> entry = iterator.next();
String plotID = entry.getKey();
AbstractChartTypePane pane = entry.getValue().getPlotTypePane();
if (AssistUtils.equals(pane.title4PopupWindow(), TYPE_PANE_DEFAULT_TITLE)) {
continue;
}
pane.reLayout(plotID);
paneList.add(pane);
if (allChartTypePane.get(priority) == null) {
allChartTypePane.put(priority, new LinkedHashMap<String, FurtherBasicBeanPane<? extends ChartProvider>>());
}
allChartTypePane.get(priority).put(plotID, pane);
} catch (Throwable e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
pane.setPlotID(plotID);
paneList.add(pane);
if (allChartTypePane.get(priority) == null) {
allChartTypePane.put(priority, new LinkedHashMap<String, FurtherBasicBeanPane<? extends ChartProvider>>());
}
allChartTypePane.get(priority).put(plotID, pane);
}
}
}
private String getChartName(String plotID, IndependentChartUIProvider provider) {
String name = provider.getPlotTypeTitle4PopupWindow();
if (StringUtils.isEmpty(name)) {
name = ChartTypeManager.getInstance().getChartName(plotID);
}
return name;
@Compatible
public String getTitle4PopupWindow(String plotID) {
return getName(plotID);
}
public String getTitle4PopupWindow(String plotID) {
IndependentChartUIProvider provider = getChartTypeInterface(plotID);
if (provider != null) {
return provider.getPlotTypeTitle4PopupWindow();
private List<Integer> getPriorityInOrder() {
List<Integer> priorityList = new ArrayList<Integer>();
if (chartTypeInterfaces != null) {
Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry) iterator.next();
String priority = (String) entry.getKey();
priorityList.add(Integer.valueOf(priority));
}
}
return StringUtils.EMPTY;
return ChartTypeManager.orderInPriority(priorityList);
}
/**
* 获取指定图表的标题
*/
public String getTitle4PopupWindow(String priority, String plotID) {
public String getIconPath(String plotID) {
if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority) && chartTypeInterfaces.get(priority).containsKey(plotID)) {
IndependentChartUIProvider provider = chartTypeInterfaces.get(priority).get(plotID);
return getChartName(plotID, provider);
if (chartTypeInterfaces != null) {
ChartTypeUIProvider provider = getChartTypeInterface(plotID);
if (provider != null) {
return provider.getIconPath();
}
}
return StringUtils.EMPTY;
}
public String[] getDemoImagePath(String chartID) {
//兼容老的插件
if (chartTypeInterfaces != null) {
Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry) iterator.next();
String defaultPriority = (String) entry.getKey();
if (chartTypeInterfaces.get(defaultPriority).containsKey(plotID)) {
return getChartName(plotID, chartTypeInterfaces.get(defaultPriority).get(plotID));
ChartTypeUIProvider provider = getChartTypeInterface(chartID);
if (provider != null) {
String[] result = null;
try {
result = provider.getDemoImagePath();
} catch (Throwable e) {
//do nothing
}
return ArrayUtils.isEmpty(result) ? getCompatibleDemoImagePath(chartID) : result;
}
}
return StringUtils.EMPTY;
return new String[0];
}
private List<Integer> getPriorityInOrder() {
private String[] getCompatibleDemoImagePath(String chartID) {
String[] result = null;
try {
//AbstractIndependentChartsProvider
ChartTypeProvider chartTypeProvider = Reflect.on(ChartTypeManager.getInstanceWithCheck()).call("getChartType", chartID).get();
result = new String[]{
Reflect.on(chartTypeProvider).call("getChartImagePath").get()
};
if (ArrayUtils.isNotEmpty(result)) {
return result;
}
} catch (Exception e) {
//do nothing
}
List<Integer> priorityList = new ArrayList<Integer>();
try {
//兼容 图表类型选择界面会调到这边
ChartProvider[] charts = ChartTypeManager.getInstanceWithCheck().getChartTypes(chartID);
result = new String[charts.length];
for (int i = 0; i < charts.length; i++) {
//Chart && AbstractChart
ChartProvider chart = charts[i];
if (!(chart instanceof AbstractChart)) {//扩展图表
chart = Reflect.on(chart).field("subChart").get();
}
result[i] = Reflect.on(chart).call("demoImagePath").get();
}
if (ArrayUtils.isNotEmpty(result)) {
return result;
}
} catch (Exception e) {
//do nothing
}
return new String[]{getIconPath(chartID)};
}
public String[] getSubName(String chartID) {
if (chartTypeInterfaces != null) {
Iterator iterator = chartTypeInterfaces.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry) iterator.next();
String priority = (String) entry.getKey();
priorityList.add(Integer.valueOf(priority));
ChartTypeUIProvider provider = getChartTypeInterface(chartID);
if (provider != null) {
String[] subNames = null;
try {
subNames = provider.getSubName();
} catch (Throwable throwable) {
//do nothing
}
return ArrayUtils.isEmpty(subNames) ? getCompatibleSubName(chartID, provider) : subNames;
}
}
return ChartTypeManager.orderInPriority(priorityList);
return new String[0];
}
public String getIconPath(String plotID) {
//兼容
private String[] getCompatibleSubName(String chartID, ChartTypeUIProvider provider) {
ChartProvider[] chartProviders = ChartTypeManager.getInstanceWithCheck().getChartTypes(chartID);
if (chartProviders.length == 1) {
return new String[]{getName(chartID)};
}
String[] result = new String[chartProviders.length];
for (int i = 0; i < chartProviders.length; i++) {
if (chartProviders[i] instanceof Chart) {
//Chart && AbstractChart
result[i] = ((Chart) chartProviders[i]).getChartName();
}
}
return result;
}
public String getName(String chartID) {
if (chartTypeInterfaces != null) {
IndependentChartUIProvider provider = getChartTypeInterface(plotID);
ChartTypeUIProvider provider = getChartTypeInterface(chartID);
if (provider != null) {
return provider.getIconPath();
String name = null;
try {
name = provider.getName();
} catch (Throwable throwable) {
//do nothing
}
return StringUtils.isEmpty(name) ? getCompatibleName(chartID, provider) : name;
}
}
return StringUtils.EMPTY;
}
//兼容
private static String getCompatibleName(String chartID, ChartTypeUIProvider provider) {
String result = null;
try {
//AbstractIndependentChartsProvider
ChartTypeProvider chartTypeProvider = Reflect.on(ChartTypeManager.getInstanceWithCheck()).call("getChartType", chartID).get();
result = Reflect.on(chartTypeProvider).call("getChartName").get();//国际化的key
result = InterProviderFactory.getProvider().getLocText(result);
if (StringUtils.isNotEmpty(result)) {
return result;
}
} catch (Exception e) {
//do nothing
}
try {
ChartProvider chartProvider = ChartTypeManager.getInstanceWithCheck().getChartTypes(chartID)[0];
if (chartProvider instanceof Chart) {
//AbstractExtendedChartUIProvider
result = ((Chart) chartProvider).getChartName();
}
if (StringUtils.isNotEmpty(result) && !"Charts".equals(result)) {
return result;
}
} catch (Exception e) {
//do nothing
}
return provider.getPlotTypePane().title4PopupWindow();
}
public ChartDataPane getChartDataPane(String plotID, AttributeChangeListener listener) {
IndependentChartUIProvider provider = getChartTypeInterface(plotID);
ChartTypeUIProvider provider = getChartTypeInterface(plotID);
if (provider != null) {
return provider.getChartDataPane(listener);
}
@ -363,20 +478,8 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
return new ChartDataPane(listener);
}
/**
* 获取对应ID的图表数量
*
*/
private int getChartSize(String key) {
if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(key)) {
return chartTypeInterfaces.get(key).size();
}
return 0;
}
public AbstractChartAttrPane[] getAttrPaneArray(String plotID, AttributeChangeListener listener) {
IndependentChartUIProvider provider = getChartTypeInterface(plotID);
ChartTypeUIProvider provider = getChartTypeInterface(plotID);
if (provider != null) {
return provider.getAttrPaneArray(listener);
}
@ -387,7 +490,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) {
IndependentChartUIProvider provider = getChartTypeInterface(plot.getPlotID());
ChartTypeUIProvider provider = getChartTypeInterface(plot.getPlotID());
if (provider != null) {
return provider.getTableDataSourcePane(plot, parent);
}
@ -397,7 +500,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) {
IndependentChartUIProvider provider = getChartTypeInterface(plot.getPlotID());
ChartTypeUIProvider provider = getChartTypeInterface(plot.getPlotID());
if (provider != null) {
return provider.getReportDataSourcePane(plot, parent);
}
@ -405,17 +508,9 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
return null;
}
private boolean plotInChart(String plotID, String priority) {
return chartTypeInterfaces != null
&& chartTypeInterfaces.containsKey(priority)
&& chartTypeInterfaces.get(priority).containsKey(plotID);
}
public ConditionAttributesPane getPlotConditionPane(Plot plot) {
IndependentChartUIProvider provider = getChartTypeInterface(plot.getPlotID());
ChartTypeUIProvider provider = getChartTypeInterface(plot.getPlotID());
if (provider != null) {
return provider.getPlotConditionPane(plot);
}
@ -425,7 +520,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
public BasicBeanPane<Plot> getPlotSeriesPane(ChartStylePane parent, Plot plot) {
IndependentChartUIProvider provider = getChartTypeInterface(plot.getPlotID());
ChartTypeUIProvider provider = getChartTypeInterface(plot.getPlotID());
if (provider != null) {
return provider.getPlotSeriesPane(parent, plot);
}
@ -441,7 +536,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
*/
public boolean isUseDefaultPane(String plotID) {
IndependentChartUIProvider provider = getChartTypeInterface(plotID);
ChartTypeUIProvider provider = getChartTypeInterface(plotID);
if (provider != null) {
return provider.isUseDefaultPane();
}
@ -452,7 +547,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
public boolean needChartChangePane(ChartProvider chart) {
if (chart != null) {
String chartID = chart.getID();
IndependentChartUIProvider provider = getChartTypeInterface(chartID);
ChartTypeUIProvider provider = getChartTypeInterface(chartID);
if (provider != null) {
return provider.needChartChangePane();
}
@ -464,11 +559,14 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
@Override
public void mount(PluginSingleInjection injection) {
if (isIndependentChartUIProvider(injection)) {
if (isChartTypeUIProvider(injection)) {
String id = injection.getAttribute("chartID");
if (StringUtils.isEmpty(id)) {
id = injection.getAttribute("plotID");
}
String priority = injection.getAttribute("priority", DEFAULT_PRIORITY);
String plotID = injection.getAttribute("plotID");
IndependentChartUIProvider instance = (IndependentChartUIProvider) injection.getObject();
addChartTypeInterface(priority, plotID, instance);
ChartTypeUIProvider instance = (ChartTypeUIProvider) injection.getObject();
addChartTypeInterface(priority, id, instance);
}
}
@ -476,10 +574,13 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
@Override
public void demount(PluginSingleInjection injection) {
if (isIndependentChartUIProvider(injection)) {
if (isChartTypeUIProvider(injection)) {
String priority = injection.getAttribute("priority", DEFAULT_PRIORITY);
String plotID = injection.getAttribute("plotID");
removeChartTypeInterface(priority, plotID);
String id = injection.getAttribute("chartID");
if (StringUtils.isEmpty(id)) {
id = injection.getAttribute("plotID");
}
removeChartTypeInterface(priority, id);
}
}
@ -487,21 +588,21 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
if (chartTypeInterfaces != null) {
if (chartTypeInterfaces.containsKey(priority)) {
Map<String, IndependentChartUIProvider> chartUIList = chartTypeInterfaces.get(priority);
Map<String, ChartTypeUIProvider> chartUIList = chartTypeInterfaces.get(priority);
chartUIList.remove(plotID);
}
}
}
private boolean isIndependentChartUIProvider(PluginSingleInjection injection) {
private boolean isChartTypeUIProvider(PluginSingleInjection injection) {
return !(injection == null || injection.getObject() == null) && IndependentChartUIProvider.XML_TAG.equals(injection.getName()) && injection.getObject() instanceof IndependentChartUIProvider;
return !(injection == null || injection.getObject() == null) && (ChartTypeUIProvider.XML_TAG.equals(injection.getName()) || ChartTypeUIProvider.OLD_TAG.equals(injection.getName())) && injection.getObject() instanceof ChartTypeUIProvider;
}
public ChartEditPane getChartEditPane(String plotID) {
IndependentChartUIProvider provider = getChartTypeInterface(plotID);
ChartTypeUIProvider provider = getChartTypeInterface(plotID);
if (provider != null) {
return provider.getChartEditPane(plotID);
}
@ -509,7 +610,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
}
public ChartsConfigPane getChartConfigPane(String plotID) {
IndependentChartUIProvider provider = getChartTypeInterface(plotID);
ChartTypeUIProvider provider = getChartTypeInterface(plotID);
if (provider != null) {
return provider.getChartConfigPane(plotID);
}

3
designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java

@ -4,7 +4,6 @@ import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.actions.core.ActionFactory;
import com.fr.design.chart.gui.ChartComponent;
import com.fr.design.constants.DesignerLaunchStatus;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.ChartPropertyPane;
import com.fr.design.module.ChartEmptyDataStyleAction;
@ -54,8 +53,6 @@ public class ChartDesignerActivator extends Activator implements Prepare {
DesignImageEvent.registerDefaultCallbackEvent(HistoryTemplateListPane.getInstance());
DesignImageEvent.registerDownloadSourcesEvent(new DownloadOnlineSourcesHelper());
DesignerLaunchStatus.setStatus(DesignerLaunchStatus.DESIGNER_INIT_COMPLETE);
ChartTypeInterfaceManager.addPluginChangedListener();
}

46
designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java

@ -3,15 +3,15 @@ package com.fr.design.chart;
* the Pane of the Chart
*/
import com.fr.chart.base.ChartInternationalNameContentBean;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer;
@ -28,29 +28,7 @@ import java.awt.Component;
public class ChartTypePane extends ChartCommonWizardPane {
private static final long serialVersionUID = -1175602484968520546L;
private ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstanceWithCheck().getAllChartBaseNames();
private ChartProvider[][] charts4Icon = null;
{
charts4Icon = new ChartProvider[this.typeName.length][];
for (int i = 0; i < this.typeName.length; i++) {
ChartProvider[] rowCharts = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.typeName[i].getChartID());
int rowChartsCount = rowCharts.length;
charts4Icon[i] = new ChartProvider[rowChartsCount];
for (int j = 0; j < rowChartsCount; j++) {
try {
charts4Icon[i][j] = (ChartProvider) rowCharts[j].clone();
//todo@shinerefactor 老图表也是提供一张图片 这边就不用setTitle(null) 然后实时去画
// charts4Icon[i][j].setTitle(null);
// if(charts4Icon[i][j].getPlot() != null){
// charts4Icon[i][j].getPlot().setLegend(null);
// }
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
}
private String[] chartIDs = ChartTypeManager.getInstanceWithCheck().getAllChartIDs();
private JList mainTypeList = null;
private JList iconViewList = null;
@ -61,8 +39,8 @@ public class ChartTypePane extends ChartCommonWizardPane {
DefaultListModel defaultListModel = new DefaultListModel();
mainTypeList = new JList(defaultListModel);
for (int i = 0; i < typeName.length; i++) {
defaultListModel.insertElementAt(InterProviderFactory.getProvider().getLocText(typeName[i].getName()), i);
for (int i = 0; i < chartIDs.length; i++) {
defaultListModel.insertElementAt(ChartTypeInterfaceManager.getInstance().getName(chartIDs[i]), i);
}
mainTypeList.addListSelectionListener(listSelectionListener);
@ -115,11 +93,15 @@ public class ChartTypePane extends ChartCommonWizardPane {
protected ListSelectionListener listSelectionListener = new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
int main_index = mainTypeList.getSelectedIndex();
ChartProvider[] sub_charts = ChartTypePane.this.charts4Icon[main_index];
String id = ChartTypePane.this.chartIDs[main_index];
String[] demoImagePath = ChartTypeInterfaceManager.getInstance().getDemoImagePath(id);
String[] subName = ChartTypeInterfaceManager.getInstance().getSubName(id);
ChartTypePane.this.iconListModel.clear();
for (int i = 0; i < sub_charts.length; i++) {
String ImagePath = sub_charts[i].demoImagePath();
String chartName = sub_charts[i].getChartName();
for (int i = 0, len = subName.length; i < len; i++) {
String ImagePath = demoImagePath.length > i ? demoImagePath[i] : StringUtils.EMPTY;
String chartName = subName[i];
ChartTypePane.this.iconListModel.addElement(new ChartIcon(ImagePath, chartName));
}
iconViewList.setSelectedIndex(0);
@ -143,7 +125,7 @@ public class ChartTypePane extends ChartCommonWizardPane {
ChartProvider chart4Update = cc.getSelectedChartProvider();
if (chart4Update == null) {
String plotID = typeName[mainTypeList.getSelectedIndex()].getChartID();
String plotID = this.chartIDs[mainTypeList.getSelectedIndex()];
ChartProvider chart = ChartTypeManager.getInstance().getChartTypes(plotID)[iconViewList.getSelectedIndex()];
try {
chart4Update = (ChartProvider) chart.clone();

141
designer-chart/src/main/java/com/fr/design/chart/fun/ChartTypeUIProvider.java

@ -0,0 +1,141 @@
package com.fr.design.chart.fun;
import com.fr.chart.chartattr.Plot;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.condition.ConditionAttributesPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.ChartsConfigPane;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.plugin.injectable.SpecialLevel;
import com.fr.stable.fun.Level;
/**
* Created by eason on 14/12/29.
*
* @since 8.0
* 自定义 图表类型 界面接口
*/
public interface ChartTypeUIProvider extends Level {
String XML_TAG = "ChartTypeUIProvider";
String OLD_TAG = SpecialLevel.IndependentChartUIProvider.getTagName();
int CURRENT_API_LEVEL = 3;
/**
* 图表 类型定义界面类型就是属性表的第一个界面
* 可以返回null 代表没有 图表类型切换界面
*
* @return 图表的类型定义界面类型
*/
AbstractChartTypePane getPlotTypePane();
/**
* 图表 数据配置界面 即属性表的第二个界面
* 可以返回null 代表没有数据配置界面
*/
ChartDataPane getChartDataPane(AttributeChangeListener listener);
/**
* 图表 属性界面数组 其他样式界面数组
* 可以返回空数组 代表没有其他样式界面
*
* @return 属性界面
*/
AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener);
/**
* 图表 名称
* eg:柱形图
*
* @return 图表 名称
*/
String getName();
/**
* 图表 名称
* 柱形图 堆积柱形图
*
* @return 图表 名称
*/
String[] getSubName();
/**
* 图表 demo图片路径
* 400*225
* 1.图表选择界面的图的路径 原样渲染
* 2.图表属性第一个界面 类型界面 缩放渲染
*
* @return demo图片路径
*/
String[] getDemoImagePath();
/**
* 小图标路径
* 表单 工具栏 图表小图标
* 16*16
*
* @return 图标路径
*/
String getIconPath();
//todo:把下面这些接口删除
@Deprecated
boolean needChartChangePane();
/**
* 数据集数据源的界面
*
* @return 数据集数据源的界面
*/
@Deprecated
AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent);
/**
* 单元格数据源的界面
*
* @return 单元格数据源的界面
*/
@Deprecated
AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent);
/**
* 条件属性界面
*
* @return 条件属性界面
*/
@Deprecated
ConditionAttributesPane getPlotConditionPane(Plot plot);
/**
* 系列界面
*
* @return 系列界面
*/
@Deprecated
BasicBeanPane<Plot> getPlotSeriesPane(ChartStylePane parent, Plot plot);
/**
* 是否使用默认的界面为了避免界面来回切换
*
* @return 是否使用默认的界面
*/
@Deprecated
boolean isUseDefaultPane();
@Deprecated
ChartEditPane getChartEditPane(String plotID);
@Deprecated
ChartsConfigPane getChartConfigPane(String plotID);
}

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

Loading…
Cancel
Save