Browse Source

Merge remote-tracking branch 'origin/feature/10.0' into feature/10.0

research/10.0
alex.sung 6 years ago
parent
commit
f7ee9c20e4
  1. 12
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 15
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  3. 41
      designer-base/src/main/java/com/fr/design/actions/community/FacebookFansAction.java
  4. 21
      designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java
  5. 6
      designer-base/src/main/java/com/fr/design/actions/file/PreferenceAction.java
  6. 54
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  7. 89
      designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java
  8. 15
      designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java
  9. 67
      designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java
  10. 48
      designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java
  11. 91
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java
  12. 10
      designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java
  13. 14
      designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java
  14. 17
      designer-base/src/main/java/com/fr/design/bridge/exec/JSBridge.java
  15. 18
      designer-base/src/main/java/com/fr/design/bridge/exec/JSCallback.java
  16. 2
      designer-base/src/main/java/com/fr/design/bridge/exec/JSExecutor.java
  17. 58
      designer-base/src/main/java/com/fr/design/bridge/exec/JSUtils.java
  18. 39
      designer-base/src/main/java/com/fr/design/constants/DesignerLaunchStatus.java
  19. 1
      designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java
  20. 15
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  21. 5
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java
  22. 27
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java
  23. 6
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  24. 39
      designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseComponent.java
  25. 32
      designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseDialog.java
  26. 36
      designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseOpener.java
  27. 39
      designer-base/src/main/java/com/fr/design/dcm/UniversalDatabasePane.java
  28. 34
      designer-base/src/main/java/com/fr/design/dcm/UniversalDcmBridge.java
  29. 103
      designer-base/src/main/java/com/fr/design/dialog/BasicPane.java
  30. 4
      designer-base/src/main/java/com/fr/design/editor/editor/DateEditor.java
  31. 2
      designer-base/src/main/java/com/fr/design/event/DesignerOpenedListener.java
  32. 42
      designer-base/src/main/java/com/fr/design/extra/PluginJavaFxExecutor.java
  33. 2
      designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java
  34. 2
      designer-base/src/main/java/com/fr/design/extra/PluginUtils.java
  35. 20
      designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java
  36. 1
      designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java
  37. 1
      designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java
  38. 1
      designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java
  39. 1
      designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java
  40. 1
      designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java
  41. 1
      designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java
  42. 16
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  43. 7
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  44. 38
      designer-base/src/main/java/com/fr/design/fun/OemProcessor.java
  45. 25
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractOemProcessor.java
  46. 15
      designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java
  47. 3
      designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java
  48. 4
      designer-base/src/main/java/com/fr/design/gui/date/SingleObjectComboBoxModel.java
  49. 14
      designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java
  50. 3
      designer-base/src/main/java/com/fr/design/gui/frpane/BaseHyperlinkGroup.java
  51. 2
      designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupType.java
  52. 4
      designer-base/src/main/java/com/fr/design/gui/frpane/ImgChooseWrapper.java
  53. 44
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java
  54. 23
      designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java
  55. 9
      designer-base/src/main/java/com/fr/design/icon/BorderIcon.java
  56. 32
      designer-base/src/main/java/com/fr/design/javascript/beautify/JavaScriptFormatHelper.java
  57. 31
      designer-base/src/main/java/com/fr/design/locale/impl/ProductImproveMark.java
  58. 35
      designer-base/src/main/java/com/fr/design/locale/impl/SplashMark.java
  59. 44
      designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java
  60. 36
      designer-base/src/main/java/com/fr/design/locale/impl/UserInfoMark.java
  61. 35
      designer-base/src/main/java/com/fr/design/locale/impl/VideoMark.java
  62. 11
      designer-base/src/main/java/com/fr/design/mainframe/DesignAuthorityEventType.java
  63. 40
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  64. 215
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  65. 5
      designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java
  66. 16
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  67. 2
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java
  68. 2
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java
  69. 45
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  70. 82
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java
  71. 9
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DownMenuStyleDefinePane.java
  72. 40
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java
  73. 50
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  74. 135
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/UpdateActionManager.java
  75. 8
      designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java
  76. 28
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java
  77. 96
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java
  78. 13
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/EditFileVersionDialog.java
  79. 13
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java
  80. 3
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellRender.java
  81. 31
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java
  82. 2
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionFirstRowPanel.java
  83. 5
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java
  84. 4
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java
  85. 37
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsDateEditor.java
  86. 32
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java
  87. 37
      designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java
  88. 4
      designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java
  89. 28
      designer-base/src/main/java/com/fr/design/roleAuthority/ReportAndFSManagePane.java
  90. 2
      designer-base/src/main/java/com/fr/design/style/background/image/ImagePreviewPane.java
  91. 17
      designer-base/src/main/java/com/fr/design/ui/Assistant.java
  92. 61
      designer-base/src/main/java/com/fr/design/ui/EmbProtocolHandler.java
  93. 101
      designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java
  94. 1
      designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateDialog.java
  95. 16
      designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java
  96. 6
      designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java
  97. 46
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java
  98. 468
      designer-base/src/main/java/com/fr/design/upm/UpmBridge.java
  99. 68
      designer-base/src/main/java/com/fr/design/upm/UpmFinder.java
  100. 34
      designer-base/src/main/java/com/fr/design/upm/UpmShowDialog.java
  101. Some files were not shown because too many files have changed in this diff Show More

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

@ -14,6 +14,7 @@ import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.LocalDesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.locale.impl.ProductImproveMark;
import com.fr.design.mainframe.vcs.VcsConfigManager;
import com.fr.design.update.push.DesignerPushUpdateConfigManager;
import com.fr.design.style.color.ColorSelectConfigManager;
@ -23,6 +24,8 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogFormatter;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.general.locale.LocaleCenter;
import com.fr.general.locale.LocaleMark;
import com.fr.general.xml.GeneralXMLTools;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CommonUtils;
@ -146,7 +149,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
/**
* alphafine
*/
private AlphaFineConfigManager alphaFineConfigManager = new AlphaFineConfigManager();
private AlphaFineConfigManager alphaFineConfigManager = AlphaFineConfigManager.getInstance();
private DesignerPushUpdateConfigManager designerPushUpdateConfigManager = DesignerPushUpdateConfigManager.getInstance();
@ -182,6 +185,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
public static DesignerEnvManager getEnvManager(boolean needCheckEnv) {
if (designerEnvManager == null) {
designerEnvManager = new DesignerEnvManager();
//REPORT-15332有一个国际化调用比较早,需要在这边就设置好locale,由于后台GeneralContext默认是China
GeneralContext.setLocale(designerEnvManager.getLanguage());
try {
XMLTools.readFileXML(designerEnvManager, designerEnvManager.getDesignerEnvFile());
} catch (Exception e) {
@ -695,7 +700,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* @return 是否加入产品改良
*/
public boolean isJoinProductImprove() {
return joinProductImprove;
LocaleMark<Boolean> localeMark = LocaleCenter.getMark(ProductImproveMark.class);
return localeMark.getValue() && this.joinProductImprove;
}
/**
@ -1517,7 +1523,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
}
private void readAlphaFineAttr(XMLableReader reader) {
reader.readXMLObject(this.alphaFineConfigManager = new AlphaFineConfigManager());
reader.readXMLObject(this.alphaFineConfigManager = AlphaFineConfigManager.getInstance());
}
private void readHttpsParas(XMLableReader reader) {

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

@ -22,9 +22,9 @@ import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.AuthException;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import com.fr.workspace.engine.exception.WorkspaceAuthException;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
@ -102,11 +102,7 @@ public class EnvChangeEntrance {
return false;
}
//REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
template.refreshToolArea();
}
WorkContext.switchTo(workspace, new WorkContextCallback() {
@Override
public void done() {
@ -119,8 +115,13 @@ public class EnvChangeEntrance {
}
}
});
//REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
template.refreshToolArea();
}
} catch (AuthException | RegistEditionException e) {
} catch (WorkspaceAuthException | RegistEditionException e) {
// String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed");
// String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote");
strategy.showTip(new PopTip() {

41
designer-base/src/main/java/com/fr/design/actions/community/FacebookFansAction.java

@ -0,0 +1,41 @@
package com.fr.design.actions.community;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.utils.BrowseUtils;
import com.fr.general.CloudCenter;
import com.fr.general.IOUtils;
import javax.swing.KeyStroke;
import java.awt.event.ActionEvent;
public class FacebookFansAction extends UpAction {
public FacebookFansAction() {
this.setMenuKeySet(FACEBOOKFANS);
this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/bbs/facebook.png"));
}
@Override
public void actionPerformed(ActionEvent arg0) {
BrowseUtils.browser(CloudCenter.getInstance().acquireUrlByKind("facebook.fans.tw"));
}
public static final MenuKeySet FACEBOOKFANS = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'F';
}
@Override
public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_FaceBook_Fans");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}

21
designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java

@ -1,15 +1,16 @@
package com.fr.design.actions.community;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.locale.impl.VideoMark;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.utils.BrowseUtils;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.general.locale.LocaleCenter;
import com.fr.general.locale.LocaleMark;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.Locale;
public class VideoAction extends UpdateAction
{
@ -19,21 +20,15 @@ public class VideoAction extends UpdateAction
this.setMenuKeySet(VIDEO);
this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/video.png"));
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/bbs/video.png"));
}
@Override
public void actionPerformed(ActionEvent arg0)
{
String url;
if (GeneralContext.getLocale().equals(Locale.US)) {
url = CloudCenter.getInstance().acquireUrlByKind("bbs.video.en");
} else {
url = CloudCenter.getInstance().acquireUrlByKind("bbs.video");
}
BrowseUtils.browser(url);
LocaleMark<String> localeMark = LocaleCenter.getMark(VideoMark.class);
BrowseUtils.browser(localeMark.getValue());
}
public static final MenuKeySet VIDEO = new MenuKeySet() {
@Override

6
designer-base/src/main/java/com/fr/design/actions/file/PreferenceAction.java

@ -4,9 +4,10 @@ import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.KeySetUtils;
@ -38,9 +39,10 @@ public class PreferenceAction extends UpdateAction {
preferencePane.update(DesignerEnvManager.getEnvManager());
DesignerEnvManager.loadLogSetting();
DesignerEnvManager.getEnvManager().saveXMLFile();
JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
jt.refreshToolArea();
preferencePane.showRestartDialog();
DesignerFrameFileDealerPane.getInstance().refreshDockingView();
}
});

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

@ -2,11 +2,13 @@ package com.fr.design.actions.file;
import com.fr.base.BaseUtils;
import com.fr.config.Configuration;
import com.fr.config.ServerPreferenceConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.design.RestartHelper;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.DialogActionListener;
import com.fr.design.editor.editor.IntegerEditor;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.ibutton.UIButton;
@ -30,6 +32,7 @@ import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.general.log.Log4jConfig;
import com.fr.locale.InterProviderFactory;
@ -78,6 +81,7 @@ public class PreferencePane extends BasicPane {
private static final int CACHING_DEFAULT = 5;
private static final int CACHING_GAP = 5;
private static final int MEMORY_TIP_LABEL_MAX_WIDTH = 230;
private static final int OFFSET_HEIGHT = 50;
private static final String TYPE = "pressed";
private static final String DISPLAY_TYPE = "+";
@ -132,10 +136,11 @@ public class PreferencePane extends BasicPane {
private UIComboBox logLevelComboBox, pageLengthComboBox, reportLengthComboBox;
private UIDictionaryComboBox<Locale> languageComboBox;
private IntegerEditor portEditor;
private UITextField jdkHomeTextField;
private UICheckBox oracleSpace;
private UISpinner cachingTemplateSpinner;
private UICheckBox openDebugComboBox;
private UICheckBox useOptimizedUPMCheckbox;
private UICheckBox useUniverseDBMCheckbox;
private UICheckBox joinProductImproveCheckBox;
private UICheckBox autoPushUpdateCheckBox;
@ -190,6 +195,16 @@ public class PreferencePane extends BasicPane {
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"));
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"));
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"));
improvePane.add(joinProductImproveCheckBox);
@ -210,7 +225,7 @@ public class PreferencePane extends BasicPane {
JPanel vcsPane = FRGUIPaneFactory.createVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Vcs_Title"));
generalPane.add(vcsPane);
remindVcsLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Remind"));
remindVcsLabel.setVisible(!VcsHelper.needInit());
remindVcsLabel.setVisible(!VcsHelper.getInstance().needInit());
vcsEnableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Vcs_SaveAuto"));
saveCommitCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Vcs_No_Delete"));
saveIntervalEditor = new IntegerEditor(60);
@ -219,8 +234,8 @@ public class PreferencePane extends BasicPane {
enableVcsPanel.add(vcsEnableCheckBox);
enableVcsPanel.add(remindVcsLabel);
JPanel intervalPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
UILabel everyLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Every"));
UILabel delayLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Delay"));
final UILabel everyLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Every"));
final UILabel delayLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Delay"));
intervalPanel.add(useIntervalCheckBox);
intervalPanel.add(everyLabel);
intervalPanel.add(saveIntervalEditor);
@ -233,10 +248,14 @@ public class PreferencePane extends BasicPane {
saveCommitCheckBox.setEnabled(true);
saveIntervalEditor.setEnabled(true);
useIntervalCheckBox.setEnabled(true);
everyLabel.setEnabled(true);
delayLabel.setEnabled(true);
} else {
saveCommitCheckBox.setEnabled(false);
saveIntervalEditor.setEnabled(false);
useIntervalCheckBox.setEnabled(false);
everyLabel.setEnabled(false);
delayLabel.setEnabled(false);
}
}
});
@ -376,10 +395,10 @@ public class PreferencePane extends BasicPane {
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Pagination_Line_Color"));
gridLineColorTBButton = new UIColorButton(BaseUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"));
gridLineColorTBButton = new UIColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"));
gridLineColorTBButton.setEnabled(this.isEnabled());
paginationLineColorTBButton = new UIColorButton(BaseUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"));
paginationLineColorTBButton = new UIColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"));
paginationLineColorTBButton.setEnabled(this.isEnabled());
JPanel leftPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
@ -595,7 +614,7 @@ public class PreferencePane extends BasicPane {
defaultStringToFormulaBox.setSelected(false);
}
VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager();
if (VcsHelper.needInit()) {
if (VcsHelper.getInstance().needInit()) {
vcsEnableCheckBox.setSelected(vcsConfigManager.isVcsEnable());
} else {
vcsEnableCheckBox.setEnabled(false);
@ -630,6 +649,9 @@ public class PreferencePane extends BasicPane {
this.portEditor.setValue(new Integer(designerEnvManager.getEmbedServerPort()));
openDebugComboBox.setSelected(designerEnvManager.isOpenDebug());
useOptimizedUPMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseOptimizedUPM());
useUniverseDBMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseUniverseDBM());
this.oracleSpace.setSelected(designerEnvManager.isOracleSystemSpace());
this.cachingTemplateSpinner.setValue(designerEnvManager.getCachingTemplateLimit());
@ -725,6 +747,19 @@ public class PreferencePane extends BasicPane {
}
});
Configurations.update(new Worker() {
@Override
public void run() {
ServerPreferenceConfig.getInstance().setUseOptimizedUPM(useOptimizedUPMCheckbox.isSelected());
ServerPreferenceConfig.getInstance().setUseUniverseDBM(useUniverseDBMCheckbox.isSelected());
}
@Override
public Class<? extends Configuration>[] targets() {
return new Class[] {ServerPreferenceConfig.class};
}
});
}
@ -757,4 +792,9 @@ public class PreferencePane extends BasicPane {
}
});
}
@Override
public BasicDialog showWindow(Window window, DialogActionListener l) {
return showWindowWithCustomSize(window, l, new Dimension(BasicDialog.DEFAULT.width, this.getPreferredSize().height + OFFSET_HEIGHT));
}
}

89
designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java

@ -1,7 +1,8 @@
package com.fr.design.actions.file;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.fun.PreviewProvider;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.DesignUtils;
@ -10,41 +11,56 @@ import com.fr.file.FileNodeFILE;
import com.fr.general.GeneralUtils;
import com.fr.general.web.ParameterConstants;
import com.fr.stable.project.ProjectConstants;
import com.fr.web.referrer.DesignSessionReferrer;
import javax.swing.JOptionPane;
import java.util.Collections;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static javax.swing.JOptionPane.OK_CANCEL_OPTION;
import static javax.swing.JOptionPane.OK_OPTION;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
import static javax.swing.JOptionPane.showConfirmDialog;
public final class WebPreviewUtils {
public static void preview(JTemplate<?, ?> jt) {
preview(jt, jt.getPreviewType());
}
@SuppressWarnings("unchecked")
public static void preview(JTemplate<?, ?> jt, PreviewProvider provider) {
String baseRoute = jt.route();
if (provider == null) {
actionPerformed(jt, baseRoute, Collections.EMPTY_MAP, ParameterConstants.VIEWLET);
} else {
actionPerformed(jt, baseRoute, provider.parametersForPreview(), provider.getActionType());
String previewType = ParameterConstants.VIEWLET;
Map<String, Object> paraMap = new HashMap<>(getExtraPara());
if (provider != null) {
Map<String, Object> providerParaMap = provider.parametersForPreview();
if (providerParaMap != null) {
paraMap.putAll(providerParaMap);
}
previewType = provider.getActionType();
}
actionPerformed(jt, baseRoute, paraMap, previewType);
}
private static Map<String, Object> getExtraPara() {
Map<String, Object> extraPara = new HashMap<>();
if (DesignModeContext.isVcsMode()) {
extraPara.put("mode", DesignModeContext.getMode().toString());
}
extraPara.putAll(new DesignSessionReferrer.Builder().referrerMap());
return extraPara;
}
private static void actionPerformed(JTemplate<?, ?> jt, String baseRoute, Map<String, Object> map, String actionType) {
if (jt == null) {
return;
}
if (map == null || map == Collections.EMPTY_MAP) {
map = new HashMap<>();
}
if (DesignerMode.isVcsMode()) {
map.put("mode", DesignerMode.getMode().toString());
}
DesignerContext.getDesignerFrame().refreshToolbar();
jt.stopEditing();
/*
* alex:如果没有保存,先保存到Env
@ -54,17 +70,20 @@ public final class WebPreviewUtils {
if (!jt.isSaved() && !jt.saveTemplate2Env()) {
return;
}
FILE currentTemplate = jt.getEditingFILE();
// carl:是否是保存在运行环境下的模板,不是就不能被预览
if (currentTemplate instanceof FileNodeFILE) {
browseUrl(currentTemplate, baseRoute, map, actionType, jt);
} else {
// 说明模板没有保存在报表运行环境下面,提示用户
int selVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview_Tool_Tips"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
int selVal = showConfirmDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"),
Toolkit.i18nText("Fine-Design_Basic_Preview_Tool_Tips"),
OK_CANCEL_OPTION,
WARNING_MESSAGE);
if (JOptionPane.OK_OPTION == selVal) {
if (OK_OPTION == selVal) {
if (!jt.saveAsTemplate2Env()) {
return;
}
@ -74,7 +93,10 @@ public final class WebPreviewUtils {
}
}
private static void browseUrl(FILE currentTemplate, String baseRoute, Map<String, Object> map, String actionType, JTemplate<?, ?> jt) {
private static void browseUrl(FILE currentTemplate,
String baseRoute,
Map<String, Object> map,
String actionType, JTemplate<?, ?> jt) {
if (!(currentTemplate instanceof FileNodeFILE)) {
return;
}
@ -85,8 +107,8 @@ public final class WebPreviewUtils {
path = path.substring(ProjectConstants.REPORTLETS_NAME.length() + 1);
}
java.util.List<String> parameterNameList = new java.util.ArrayList<String>();
java.util.List<String> parameterValueList = new java.util.ArrayList<String>();
List<String> parameterNameList = new ArrayList<>();
List<String> parameterValueList = new ArrayList<>();
parameterNameList.add(actionType);
parameterValueList.add(path);
@ -96,14 +118,21 @@ public final class WebPreviewUtils {
parameterValueList.add(GeneralUtils.objectToString(map.get(key)));
}
}
DesignUtils.visitEnvServerByParameters(baseRoute, parameterNameList.toArray(new String[parameterNameList.size()]), parameterValueList.toArray(new String[parameterValueList.size()]));
DesignUtils.visitEnvServerByParameters(
baseRoute,
parameterNameList.toArray(new String[0]),
parameterValueList.toArray(new String[0])
);
} else {
int selVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview_Tool_Tips"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
if (JOptionPane.OK_OPTION == selVal) {
if (!jt.saveAsTemplate()) {
return;
}
int selVal = showConfirmDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"),
Toolkit.i18nText("Fine-Design_Basic_Preview_Tool_Tips"),
OK_CANCEL_OPTION,
WARNING_MESSAGE
);
if (OK_OPTION == selVal) {
jt.saveAsTemplate();
}
}
}

15
designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java

@ -1,7 +1,7 @@
package com.fr.design.actions.file.export;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.actions.JTemplateAction;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.gui.iprogressbar.FRProgressBar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
@ -9,6 +9,7 @@ import com.fr.design.mainframe.JTemplate;
import com.fr.exception.RemoteDesignPermissionDeniedException;
import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.file.RenameExportFILE;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.io.exporter.DesignExportType;
import com.fr.io.exporter.ExporterKey;
@ -92,12 +93,17 @@ public abstract class AbstractExportAction<E extends JTemplate<?, ?>> extends JT
int saveValue = fileChooserPane.showSaveDialog(DesignerContext.getDesignerFrame(), "." + this.getDefaultExtension());
if (saveValue == FILEChooserPane.JOPTIONPANE_OK_OPTION || saveValue == FILEChooserPane.OK_OPTION) {
FILE target = fileChooserPane.getSelectedFILE();
//rename 方式导出
target = RenameExportFILE.create(target);
try {
target.mkfile();
} catch (Exception exp) {
FineLoggerFactory.getLogger().error("Error In Make New File", exp);
}
FineLoggerFactory.getLogger().info("\"" + target.getName() + "\"" + Toolkit.i18nText("Fine-Design_Report_Prepare_Export") + "!");
FineLoggerFactory.getLogger().info(
"\"" + RenameExportFILE.recoverFileName(target.getName()) + "\"" +
Toolkit.i18nText("Fine-Design_Report_Prepare_Export") + "!"
);
progressbar = new FRProgressBar(
createExportWork(getSource(), target, para),
@ -124,7 +130,7 @@ public abstract class AbstractExportAction<E extends JTemplate<?, ?>> extends JT
private boolean processNotSaved() {
//当前编辑的模板
E e = getEditingComponent();
if (!e.isALLSaved() && !DesignerMode.isVcsMode()) {
if (!e.isALLSaved() && !DesignModeContext.isVcsMode()) {
e.stopEditing();
int returnVal = JOptionPane.showConfirmDialog(
DesignerContext.getDesignerFrame(),
@ -149,7 +155,7 @@ public abstract class AbstractExportAction<E extends JTemplate<?, ?>> extends JT
private SwingWorker createExportWork(final FILE source, final FILE target, final Map<String, Object> parameterMap) {
final String path = source.getPath();
final String name = target.getName();
final String name = RenameExportFILE.recoverFileName(target.getName());
return new SwingWorker<Void, Void>() {
@ -162,7 +168,6 @@ public abstract class AbstractExportAction<E extends JTemplate<?, ?>> extends JT
dealExporter(outputStream, path, parameterMap);
this.setProgress(80);
outputStream.flush();
outputStream.close();
this.setProgress(100);
FineLoggerFactory.getLogger().info("\"" + name + "\"" + Toolkit.i18nText("Fine-Design_Report_Finish_Export") + "!");

67
designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java

@ -0,0 +1,67 @@
package com.fr.design.actions.help;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.ui.ModernUIPane;
import com.fr.locale.InterProviderFactory;
import com.fr.web.struct.AssembleComponent;
import com.fr.web.struct.Atom;
import com.fr.web.struct.browser.RequestClient;
import com.fr.web.struct.category.ScriptPath;
import com.fr.web.struct.impl.FineUI;
import java.awt.event.ActionEvent;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-03-08
*/
public class FineUIAction extends UpdateAction {
public FineUIAction() {
setName("FineUI");
}
@Override
public void actionPerformed(final ActionEvent e) {
ModernUIPane<?> pane = new ModernUIPane.Builder<>()
// .prepare(new ScriptContextAdapter() {
// @Override
// public void onScriptContextCreated(ScriptContextEvent event) {
// JSValue pool = event.getBrowser().executeJavaScriptAndReturnValue("window.Pool");
// pool.asObject().setProperty("i18n", new I18n());
// }
// })
.withComponent(new AssembleComponent() {
@Override
public ScriptPath script(RequestClient req) {
return ScriptPath.build("/com/fr/design/ui/help/demo.js");
}
@Override
public Atom[] refer() {
return new Atom[] {FineUI.KEY};
}
})
.build();
BasicDialog dialog = pane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
}
});
dialog.setVisible(true);
}
public static class I18n {
public String i18nText(String key) {
return InterProviderFactory.getProvider().getLocText(key);
}
}
}

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

@ -1,18 +1,15 @@
package com.fr.design.actions.help;
import com.fr.base.BaseUtils;
import com.fr.base.Utils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.general.http.HttpToolbox;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CommonUtils;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.os.OperatingSystem;
import com.fr.third.org.apache.http.HttpStatus;
import com.fr.third.org.apache.http.StatusLine;
import com.fr.third.org.apache.http.client.methods.HttpGet;
@ -21,60 +18,37 @@ import javax.swing.KeyStroke;
import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.IOException;
import java.net.URI;
public class TutorialAction extends UpdateAction {
private static final String URL_FOR_TEST_NETWORK = "https://www.baidu.com";
public TutorialAction() {
this.setMenuKeySet(HELP_TUTORIAL);
this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/help.png"));
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/bbs/help.png"));
this.setAccelerator(getMenuKeySet().getKeyStroke());
}
private void nativeExcuteMacInstallHomePrograms(String appName) {
String installHome = StableUtils.getInstallHome();
if(installHome == null) {
FineLoggerFactory.getLogger().error("Can not find the install home, please check it.");
} else {
String appPath = StableUtils.pathJoin(new String[]{installHome, "bin", appName});
if(!(new File(appPath)).exists()) {
FineLoggerFactory.getLogger().error(appPath + " can not be found.");
}
String cmd = "open " + appPath;
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec(cmd);
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
/**
* 动作
* @param evt 事件
*/
@Override
public void actionPerformed(ActionEvent evt) {
String helpURL = CloudCenter.getInstance().acquireUrlByKind(createDocKey());
if (isServerOnline(helpURL)) {
// 用第三方网址去判断是否处在离线状态
if (isServerOnline(URL_FOR_TEST_NETWORK)) {
try {
Desktop.getDesktop().browse(new URI(helpURL));
return;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
if (OperatingSystem.isUnix()) {
nativeExcuteMacInstallHomePrograms("helptutorial.app");
} else {
Utils.nativeExcuteInstallHomePrograms("helptutorial.exe");
}
FineLoggerFactory.getLogger().warn(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Offline_Helptutorial_Msg"));
}
// 生成帮助文档 sitecenter key, help.zh_CN.10
@ -116,4 +90,4 @@ public class TutorialAction extends UpdateAction {
}
};
}
}

91
designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java

@ -1,19 +1,29 @@
package com.fr.design.actions.help.alphafine;
import com.fr.general.ComparatorUtils;
import com.fr.license.function.VT4FR;
import com.fr.stable.OperatingSystem;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLable;
import com.fr.stable.xml.XMLableReader;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* Created by XiaXiang on 2017/4/5.
* AlphaFine配置类
*
* @author XiaXiang
* @date 2017/4/5
*/
public class AlphaFineConfigManager implements XMLable {
private static final long serialVersionUID = -8170289826729582122L;
private static AlphaFineConfigManager alphaFineConfigManager = new AlphaFineConfigManager();
/**
* 是否开启alphafine
@ -56,12 +66,12 @@ public class AlphaFineConfigManager implements XMLable {
*/
private boolean containPlugin = true;
/**
* 分词搜索
*/
* 分词搜索
*/
private boolean needSegmentationCheckbox = true;
/**
* 智能客服
*/
* 智能客服
*/
private boolean needIntelligentCustomerService = true;
/**
* 快捷键
@ -71,24 +81,30 @@ public class AlphaFineConfigManager implements XMLable {
* 是否提醒
*/
private boolean needRemind = true;
private Map<String, String> actionSearchTextCache = new HashMap<>(8);
private String cacheBuildNO;
/**
* 直接操作菜单次数
*/
private int operateCount;
private AlphaFineConfigManager() {
}
public static AlphaFineConfigManager getInstance() {
return alphaFineConfigManager;
}
public static boolean isALPHALicAvailable() {
return VT4FR.AlphaFine.isSupport();
}
@Override
public Object clone() throws CloneNotSupportedException {
AlphaFineConfigManager manager = (AlphaFineConfigManager) super.clone();
return manager;
return super.clone();
}
@Override
@ -107,9 +123,33 @@ public class AlphaFineConfigManager implements XMLable {
this.setShortcuts(reader.getAttrAsString("shortcuts", getDefaultShortCuts()));
this.setNeedRemind(reader.getAttrAsBoolean("isNeedRemind", true));
this.setOperateCount(reader.getAttrAsInt("operateCount", 0));
} else if (reader.isChildNode()) {
if (ComparatorUtils.equals(reader.getTagName(), "ActionSearchTextCache")) {
readActionSearchTextCacheXML(reader);
}
}
}
/**
* 读出搜索缓存
*/
private void readActionSearchTextCacheXML(XMLableReader reader) {
reader.readXMLObject(new XMLReadable() {
@Override
public void readXML(XMLableReader reader) {
if (ComparatorUtils.equals(reader.getTagName(), "ActionSearchTextCache")) {
setCacheBuildNO(reader.getAttrAsString("buildNO", ""));
} else if (ComparatorUtils.equals(reader.getTagName(), "item")) {
String tmpVal = reader.getElementValue();
if (tmpVal != null) {
actionSearchTextCache.put(reader.getAttrAsString("key", ""), tmpVal);
} else {
actionSearchTextCache.put(reader.getAttrAsString("key", ""), StringUtils.EMPTY);
}
}
}
});
}
@Override
@ -128,6 +168,18 @@ public class AlphaFineConfigManager implements XMLable {
.attr("operateCount", this.getOperateCount())
.attr("needSegmentationCheckbox", this.isNeedSegmentationCheckbox())
.attr("needIntelligentCustomerService", this.isNeedIntelligentCustomerService());
writeActionSearchTextCacheXML(writer);
writer.end();
}
/**
* 写入搜索缓存
*/
private void writeActionSearchTextCacheXML(XMLPrintWriter writer) {
writer.startTAG("ActionSearchTextCache").attr("buildNO", cacheBuildNO);
for (Map.Entry<String, String> item : actionSearchTextCache.entrySet()) {
writer.startTAG("item").attr("key", item.getKey()).textNode(item.getValue()).end();
}
writer.end();
}
@ -262,4 +314,25 @@ public class AlphaFineConfigManager implements XMLable {
public void setOperateCount(int operateCount) {
this.operateCount = operateCount;
}
@NotNull
public Map<String, String> getActionSearchTextCache() {
return Collections.unmodifiableMap(actionSearchTextCache);
}
public void setActionSearchTextCache(@NotNull String key, @NotNull String value) {
this.actionSearchTextCache.put(key, value);
}
@NotNull
public String getCacheBuildNO() {
if (cacheBuildNO == null) {
return StringUtils.EMPTY;
}
return cacheBuildNO;
}
public void setCacheBuildNO(@NotNull String cacheBuildNO) {
this.cacheBuildNO = cacheBuildNO;
}
}

10
designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java

@ -1,6 +1,7 @@
package com.fr.design.actions.server;
import com.fr.config.ServerPreferenceConfig;
import com.fr.data.impl.Connection;
import com.fr.design.actions.UpdateAction;
import com.fr.design.data.datapane.connect.ConnectionManagerPane;
@ -12,6 +13,7 @@ import com.fr.design.gui.NameInspector;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.dcm.UniversalDatabaseOpener;
import com.fr.file.ConnectionConfig;
import com.fr.general.IOUtils;
import com.fr.transaction.CallBackAdaptor;
@ -58,6 +60,14 @@ public class ConnectionListAction extends UpdateAction {
* @param evt 事件
*/
public void actionPerformed(ActionEvent evt) {
if (ServerPreferenceConfig.getInstance().isUseUniverseDBM()) {
UniversalDatabaseOpener.showUniverseDatabaseDialog();
} else {
openDesignDatabaseManager();
}
}
private void openDesignDatabaseManager() {
DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
final ConnectionConfig datasourceManager = ConnectionConfig.getInstance();
final ConnectionManagerPane databaseManagerPane = new ConnectionManagerPane() {

14
designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java

@ -1,10 +1,11 @@
package com.fr.design.actions.server;
import com.fr.base.BaseUtils;
import com.fr.config.ServerPreferenceConfig;
import com.fr.design.actions.UpdateAction;
import com.fr.design.extra.WebViewDlgHelper;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.upm.UpmFinder;
import com.fr.general.IOUtils;
import javax.swing.*;
import java.awt.event.ActionEvent;
@ -20,12 +21,17 @@ public class PluginManagerAction extends UpdateAction {
this.setMenuKeySet(PLUGIN_MANAGER);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/server/plugin.png"));
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/server/plugin.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
WebViewDlgHelper.createPluginDialog();
// 可以启用新版本的插件商店(使用JxBrowser作为容器)
if (ServerPreferenceConfig.getInstance().isUseOptimizedUPM()) {
UpmFinder.showUPMDialog();
} else {
WebViewDlgHelper.createPluginDialog();
}
}
public static final MenuKeySet PLUGIN_MANAGER = new MenuKeySet() {

17
designer-base/src/main/java/com/fr/design/bridge/exec/JSBridge.java

@ -0,0 +1,17 @@
package com.fr.design.bridge.exec;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-04-18
* 用于标记一个方法是用于和JS做桥接的避免被误删除
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.SOURCE)
public @interface JSBridge {
}

18
designer-base/src/main/java/com/fr/design/bridge/exec/JSCallback.java

@ -0,0 +1,18 @@
package com.fr.design.bridge.exec;
/**
* Created by ibm on 2017/5/27.
*/
public class JSCallback {
private JSExecutor executeScript;
public JSCallback(JSExecutor jsExecutor) {
this.executeScript = jsExecutor;
}
public void execute(String newValue) {
executeScript.executor(newValue);
}
}

2
designer-base/src/main/java/com/fr/design/extra/exe/callback/JSExecutor.java → designer-base/src/main/java/com/fr/design/bridge/exec/JSExecutor.java

@ -1,4 +1,4 @@
package com.fr.design.extra.exe.callback;
package com.fr.design.bridge.exec;
/**
* Created by ibm on 2017/6/21.

58
designer-base/src/main/java/com/fr/design/extra/exe/callback/JSCallback.java → designer-base/src/main/java/com/fr/design/bridge/exec/JSUtils.java

@ -1,46 +1,20 @@
package com.fr.design.extra.exe.callback;
package com.fr.design.bridge.exec;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import javafx.application.Platform;
import javafx.scene.web.WebEngine;
import netscape.javascript.JSObject;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created by ibm on 2017/5/27.
* @author richie
* @version 10.0
* Created by richie on 2019-04-18
*/
public class JSCallback {
private JSExecutor executeScript;
public JSCallback(final WebEngine webEngine, final JSObject callback) {
init(webEngine, callback);
}
public void init(final WebEngine webEngine, final JSObject callback){
executeScript = new JSExecutor() {
@Override
public void executor(final String newValue) {
Platform.runLater(new Runnable() {
@Override
public void run() {
String fun = "(" + callback + ")(\"" + trimText(newValue) + "\")";
try {
webEngine.executeScript(fun);
} catch (Exception e) {
webEngine.executeScript("alert(\"" + e.getMessage() + "\")");
}
}
});
}
};
}
public void execute(String newValue) {
executeScript.executor(newValue);
}
public class JSUtils {
/**
@ -60,7 +34,7 @@ public class JSCallback {
* @param old 原始字符串
* @return 处理之后的字符串
*/
private String trimText(String old) {
public static String trimText(String old) {
if (StringUtils.isNotBlank(old)) {
String b = filterHtmlTag(old);
return b.replaceAll("\\\\n", StringUtils.EMPTY).replaceAll("\\\\t", StringUtils.EMPTY).replaceAll("\"", "\\\\\"").replaceAll("\'", "\\\\\'").replaceAll("\\\\\\\\", "\\\\\\\\\\\\");
@ -73,7 +47,7 @@ public class JSCallback {
* @param origin 原始字符串
* @return 处理之后的字符串
*/
private String filterHtmlTag(String origin) {
public static String filterHtmlTag(String origin) {
String regHtml = "<[^>]+>";
Pattern patternHtml = Pattern.compile(regHtml, Pattern.CASE_INSENSITIVE);
Matcher matchHtml = patternHtml.matcher(origin);
@ -81,5 +55,15 @@ public class JSCallback {
return origin;
}
public String[] jsObjectToStringArray(JSObject obj) {
if (obj == null) {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
int len = (int) obj.getMember("length");
List<String> list = new ArrayList<>();
for (int i = 0; i < len; i++) {
list.add(obj.getSlot(i).toString());
}
return list.toArray(new String[len]);
}
}

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

@ -0,0 +1,39 @@
package com.fr.design.constants;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Null;
/**
* 设计器启动事件类型
*
* @author vito
* @date 2019-06-18
*/
public enum DesignerLaunchStatus implements Event<Null> {
/**
* 初始化环境完成
*/
WORKSPACE_INIT_COMPLETE,
/**
* 设计器模块启动完成
*/
DESIGNER_INIT_COMPLETE,
/**
* 启动完成
*/
OPEN_LAST_FILE_COMPLETE;
private static DesignerLaunchStatus status;
public static DesignerLaunchStatus getStatus() {
return status;
}
public static void setStatus(DesignerLaunchStatus state) {
status = state;
EventDispatcher.asyncFire(DesignerLaunchStatus.getStatus());
}
}

1
designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java

@ -147,6 +147,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
private boolean isIncludeUnderline(String name) {
return ComparatorUtils.equals(name.indexOf(StoreProcedureAssist.GROUP_MARKER), -1) ? false : true;
}
public abstract void addDataPane(final AbstractTableDataPane<?> uPanel, String paneName);
public abstract TableDataTree getDataTree();

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

@ -41,7 +41,7 @@ import javax.swing.event.ChangeListener;
import java.io.ByteArrayOutputStream;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
@ -123,6 +123,7 @@ public abstract class DesignTableDataManager {
* @param dsNameChangedMap 改变名字的数据集
*/
public static void fireDSChanged(Map<String, String> dsNameChangedMap) {
clearGlobalDs();
if (!dsNameChangedMap.isEmpty()) {
setDsNameChangedMap(dsNameChangedMap);
}
@ -334,15 +335,9 @@ public abstract class DesignTableDataManager {
private static void addStoreProcedureData(java.util.Map<String, TableDataWrapper> resMap) {
ProcedureConfig procedureConfig = ProcedureConfig.getInstance();
String[] namearray = new String[0];
@SuppressWarnings("unchecked")
java.util.Iterator<String> nameIt = procedureConfig.getProcedures().keySet().iterator();
while (nameIt.hasNext()) {
namearray = (String[]) ArrayUtils.add(namearray, nameIt.next());
}
Arrays.sort(namearray, Collator.getInstance(java.util.Locale.CHINA));
for (String name : namearray) {
List<String> names = new ArrayList<>(procedureConfig.getProcedures().keySet());
Collections.sort(names, Collator.getInstance(java.util.Locale.CHINA));
for (String name : names) {
StoreProcedure storeProcedure = procedureConfig.getProcedure(name);
if (globalDsCache.containsKey(name)) {
resMap.put(name, globalDsCache.get(name));

5
designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java

@ -32,6 +32,7 @@ import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.ConnectionConfig;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
@ -331,7 +332,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
DBUtils.refreshDatabase();
String schema = StringUtils.isEmpty(schemaBox.getSelectedItem()) ? null : schemaBox.getSelectedItem();
DataCoreUtils.refreshTables(getConnection(), TableProcedure.TABLE, schema);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh_Successfully") + "!", com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Refresh_Database"),
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh_Successfully") + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh_Database"),
JOptionPane.INFORMATION_MESSAGE);
}
@ -343,7 +344,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
Object userObj = node.getUserObject();
if (userObj instanceof String) {
this.setIcon(BaseUtils.readIcon("com/fr/design/images/m_insert/expandCell.gif"));
this.setIcon(IOUtils.readIcon("com/fr/design/images/m_insert/expandCell.gif"));
} else if (userObj instanceof TableProcedure) {
this.setText(((TableProcedure) userObj).getName());
}

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

@ -324,4 +324,31 @@ public class TableDataTreePane extends BasicTableDataTreePane {
dataTree.refresh();
return Collections.unmodifiableMap(tdNameMap);
}
public void addDataPane(final AbstractTableDataPane<?> uPanel, String paneName) {
final NamePane nPanel = uPanel.asNamePane();
nPanel.setObjectName(paneName);
final String oldName = paneName;
allDSNames = DesignTableDataManager.getAllDSNames(tc.getBook());
DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER);
tc.renameTableData(oldName, nPanel.getObjectName(), false);
TableDataSource tds = tc.getBook();
TableData td = uPanel.updateBean();
if (td instanceof TableDataSourceDependent) {
((TableDataSourceDependent) td).setTableDataSource(tds);
}
String tdName = nPanel.getObjectName();
tds.putTableData(tdName, td);
Map<String, String> map = new HashMap<String, String>();
if (!ComparatorUtils.equals(oldName, tdName)) {
map.put(oldName, tdName);
}
fireDSChanged(map);
tc.fireTargetModified();
tc.parameterChanged();
int[] rows = dataTree.getSelectionRows();
dataTree.refreshChildByName(tdName);
dataTree.setSelectionRows(rows);
}
}

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

@ -29,6 +29,7 @@ import com.fr.design.gui.itableeditorpane.UITableEditorPane;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants;
import com.fr.design.gui.syntax.ui.rtextarea.RTextScrollPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.menu.SeparatorDef;
import com.fr.design.menu.ToolBarDef;
@ -211,10 +212,13 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
isShareCheckBox.setBackground(Color.WHITE);
maxPanel = new MaxMemRowCountPanel();
maxPanel.setBorder(null);
JPanel wrapMaxPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
wrapMaxPanel.add(maxPanel);
wrapMaxPanel.setPreferredSize(new Dimension(250, 20));
UIToolbar editToolBar = ToolBarDef.createJToolBar();
toolBarDef.updateToolBar(editToolBar);
editToolBar.add(isShareCheckBox);
editToolBar.add(maxPanel);
editToolBar.add(wrapMaxPanel);
return editToolBar;
}

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

@ -0,0 +1,39 @@
package com.fr.design.dcm;
import com.fr.web.struct.AssembleComponent;
import com.fr.web.struct.Atom;
import com.fr.web.struct.browser.RequestClient;
import com.fr.web.struct.category.ScriptPath;
import com.fr.web.struct.category.StylePath;
import com.fr.web.struct.impl.FineUI;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-05-16
*/
public class UniversalDatabaseComponent extends AssembleComponent {
public static final UniversalDatabaseComponent KEY = new UniversalDatabaseComponent();
private UniversalDatabaseComponent() {
}
@Override
public ScriptPath script(RequestClient req) {
return ScriptPath.build("/com/fr/design/dcm/index.js");
}
@Override
public StylePath style(RequestClient req) {
return StylePath.build("/com/fr/design/dcm/style.css");
}
@Override
public Atom[] refer() {
return new Atom[]{
FineUI.KEY
};
}
}

32
designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseDialog.java

@ -0,0 +1,32 @@
package com.fr.design.dcm;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.*;
import java.awt.*;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-05-16
*/
public class UniversalDatabaseDialog extends UIDialog {
public UniversalDatabaseDialog(Frame frame, BasicPane pane) {
super(frame);
setUndecorated(true);
JPanel panel = (JPanel) getContentPane();
panel.setLayout(new BorderLayout());
add(pane, BorderLayout.CENTER);
setSize(new Dimension(1000, 600));
GUICoreUtils.centerWindow(this);
setResizable(false);
}
@Override
public void checkValid() throws Exception {
}
}

36
designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseOpener.java

@ -0,0 +1,36 @@
package com.fr.design.dcm;
import com.fr.design.dialog.UIDialog;
import com.fr.design.mainframe.DesignerContext;
import javax.swing.*;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-05-16
*/
public class UniversalDatabaseOpener {
private static UIDialog dialog = null;
public static UIDialog getDialog() {
return dialog;
}
public static void showUniverseDatabaseDialog() {
UniversalDatabasePane upmPane = new UniversalDatabasePane();
if (dialog == null) {
dialog = new UniversalDatabaseDialog(DesignerContext.getDesignerFrame(), upmPane);
}
dialog.setVisible(true);
}
public static void closeWindow() {
if (dialog != null) {
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
dialog.setVisible(false);
dialog = null;
}
}
}

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

@ -0,0 +1,39 @@
package com.fr.design.dcm;
import com.fr.design.dialog.BasicPane;
import com.fr.design.ui.ModernUIPane;
import com.teamdev.jxbrowser.chromium.JSValue;
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter;
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent;
import java.awt.*;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-05-16
*/
public class UniversalDatabasePane extends BasicPane {
private ModernUIPane<Object> modernUIPane;
@Override
protected String title4PopupWindow() {
return "Database";
}
public UniversalDatabasePane() {
setLayout(new BorderLayout());
modernUIPane = new ModernUIPane.Builder<>()
.withComponent(UniversalDatabaseComponent.KEY)
.prepare(new ScriptContextAdapter() {
@Override
public void onScriptContextCreated(ScriptContextEvent event) {
JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window");
window.asObject().setProperty("DcmHelper", UniversalDcmBridge.getBridge(event.getBrowser()));
}
})
.build();
add(modernUIPane, BorderLayout.CENTER);
}
}

34
designer-base/src/main/java/com/fr/design/dcm/UniversalDcmBridge.java

@ -0,0 +1,34 @@
package com.fr.design.dcm;
import com.fr.decision.webservice.bean.BaseBean;
import com.fr.design.bridge.exec.JSBridge;
import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.JSObject;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-05-17
* 桥接Java和JavaScript的类
*/
public class UniversalDcmBridge {
public static UniversalDcmBridge getBridge(Browser browser) {
return new UniversalDcmBridge(browser);
}
private JSObject window;
private UniversalDcmBridge(Browser browser) {
this.window = browser.executeJavaScriptAndReturnValue("window").asObject();
}
/**
* 获取所有的数据连接
* @return 数据连接集合
*/
@JSBridge
public BaseBean getConnections() {
return null;
}
}

103
designer-base/src/main/java/com/fr/design/dialog/BasicPane.java

@ -2,13 +2,18 @@ package com.fr.design.dialog;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.stable.core.PropertyChangeAdapter;
import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*;
import javax.swing.JPanel;
import javax.swing.event.DocumentEvent;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Window;
/*
* _denny: 这里的BasicPane通常会有populate & update方法
@ -35,21 +40,7 @@ public abstract class BasicPane extends JPanel {
* @return 对话框
*/
public BasicDialog showWindow(Window window, DialogActionListener l) {
BasicDialog dg;
if (window instanceof Frame) {
dg = new DIALOG((Frame) window);
} else {
dg = new DIALOG((Dialog) window);
}
if (l != null) {
dg.addDialogActionListener(l);
}
dg.setBasicDialogSize(BasicDialog.DEFAULT);
GUICoreUtils.centerWindow(dg);
dg.setResizable(false);
return dg;
return showWindowWithCustomSize(window, l, BasicDialog.DEFAULT);
}
/**
@ -95,21 +86,7 @@ public abstract class BasicPane extends JPanel {
* @return 对话框
*/
public BasicDialog showWindow4ChartType(Window window, DialogActionListener l) {
BasicDialog dg;
if (window instanceof Frame) {
dg = new DIALOG((Frame) window);
} else {
dg = new DIALOG((Dialog) window);
}
if (l != null) {
dg.addDialogActionListener(l);
}
dg.setBasicDialogSize(BasicDialog.CHART);
GUICoreUtils.centerWindow(dg);
dg.setResizable(false);
return dg;
return showWindowWithCustomSize(window, l, BasicDialog.CHART);
}
/**
@ -120,20 +97,7 @@ public abstract class BasicPane extends JPanel {
* @return 对话框
*/
public BasicDialog showSmallWindow(Window window, DialogActionListener l) {
BasicDialog dg;
if (window instanceof Frame) {
dg = new DIALOG((Frame) window);
} else {
dg = new DIALOG((Dialog) window);
}
if (l != null) {
dg.addDialogActionListener(l);
}
dg.setBasicDialogSize(BasicDialog.SMALL);
GUICoreUtils.centerWindow(dg);
dg.setResizable(false);
return dg;
return showWindowWithCustomSize(window, l, BasicDialog.SMALL);
}
/**
@ -144,20 +108,7 @@ public abstract class BasicPane extends JPanel {
* @return 对话框
*/
public BasicDialog showMediumWindow(Window window, DialogActionListener l) {
BasicDialog dg;
if (window instanceof Frame) {
dg = new DIALOG((Frame) window);
} else {
dg = new DIALOG((Dialog) window);
}
if (l != null) {
dg.addDialogActionListener(l);
}
dg.setBasicDialogSize(BasicDialog.MEDIUM);
GUICoreUtils.centerWindow(dg);
dg.setResizable(false);
return dg;
return showWindowWithCustomSize(window, l, BasicDialog.MEDIUM);
}
/**
@ -168,6 +119,17 @@ public abstract class BasicPane extends JPanel {
* @return 对话框
*/
public BasicDialog showLargeWindow(Window window, DialogActionListener l) {
return showWindowWithCustomSize(window, l, BasicDialog.LARGE);
}
/**
* 以自定义的宽高显示窗口
* @param window 窗口
* @param l 对话框监听器
* @param dimension 自定义尺寸
* @return 对话框
*/
protected BasicDialog showWindowWithCustomSize(Window window, DialogActionListener l, Dimension dimension) {
BasicDialog dg;
if (window instanceof Frame) {
dg = new DIALOG((Frame) window);
@ -178,7 +140,7 @@ public abstract class BasicPane extends JPanel {
if (l != null) {
dg.addDialogActionListener(l);
}
dg.setBasicDialogSize(BasicDialog.LARGE);
dg.setBasicDialogSize(dimension);
GUICoreUtils.centerWindow(dg);
dg.setResizable(false);
return dg;
@ -298,18 +260,20 @@ public abstract class BasicPane extends JPanel {
public void checkValid() throws Exception {
}
public static final class NamePane extends BasicPane {
public static class NamePane extends BasicPane {
private UITextField nameTextField;
private UILabel Name;
private BasicPane centerPane;
private UILabel showfield;
private PropertyChangeAdapter changeListener;
private NamePane(BasicPane bPane) {
public NamePane(BasicPane bPane) {
this.setLayout(new BorderLayout(4, 4));
nameTextField = new UITextField(30);
Name = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Name") + ":");
JPanel northPane = new JPanel(new BorderLayout(4, 4));
northPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Name") + ":"), BorderLayout.WEST);
northPane.add(Name, BorderLayout.WEST);
northPane.add(nameTextField, BorderLayout.CENTER);
northPane.add(showfield = new UILabel(" "), BorderLayout.EAST);
showfield.setForeground(new Color(204, 0, 1));
@ -343,6 +307,12 @@ public abstract class BasicPane extends JPanel {
}
}
@Override
public void setVisible(boolean isVisible) {
this.nameTextField.setVisible(isVisible);
this.Name.setVisible(isVisible);
}
public String getObjectName() {
return this.nameTextField.getText().trim();
}
@ -365,6 +335,7 @@ public abstract class BasicPane extends JPanel {
*
* @throws Exception 异常
*/
@Override
public void checkValid() throws Exception {
super.checkValid();

4
designer-base/src/main/java/com/fr/design/editor/editor/DateEditor.java

@ -153,6 +153,10 @@ public class DateEditor extends Editor<Date> {
this.uiDatePicker.setSelectedItem(new Date());
}
public UIDatePicker getUiDatePicker() {
return uiDatePicker;
}
/**
* Request focus
*/

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

@ -9,5 +9,5 @@ public interface DesignerOpenedListener extends EventListener {
/**
* Invoked when the target of the listener has changed the rpt content.
*/
public void designerOpened();
void designerOpened();
}

42
designer-base/src/main/java/com/fr/design/extra/PluginJavaFxExecutor.java

@ -0,0 +1,42 @@
package com.fr.design.extra;
import com.fr.design.bridge.exec.JSExecutor;
import com.fr.design.bridge.exec.JSUtils;
import javafx.application.Platform;
import javafx.scene.web.WebEngine;
import netscape.javascript.JSObject;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-04-18
*/
public class PluginJavaFxExecutor implements JSExecutor {
public static PluginJavaFxExecutor create(WebEngine webEngine, JSObject callback) {
return new PluginJavaFxExecutor(webEngine, callback);
}
private WebEngine webEngine;
private JSObject callback;
private PluginJavaFxExecutor(WebEngine webEngine, JSObject callback) {
this.webEngine = webEngine;
this.callback = callback;
}
@Override
public void executor(final String newValue) {
Platform.runLater(new Runnable() {
@Override
public void run() {
String fun = "(" + callback + ")(\"" + JSUtils.trimText(newValue) + "\")";
try {
webEngine.executeScript(fun);
} catch (Exception e) {
webEngine.executeScript("alert(\"" + e.getMessage() + "\")");
}
}
});
}
}

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

@ -3,7 +3,7 @@ package com.fr.design.extra;
import com.fr.config.MarketConfig;
import com.fr.design.extra.exe.callback.InstallFromDiskCallback;
import com.fr.design.extra.exe.callback.InstallOnlineCallback;
import com.fr.design.extra.exe.callback.JSCallback;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.extra.exe.callback.ModifyStatusCallback;
import com.fr.design.extra.exe.callback.UninstallPluginCallback;
import com.fr.design.extra.exe.callback.UpdateFromDiskCallback;

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

@ -244,6 +244,8 @@ public class PluginUtils {
jo.put("onTrial", pluginContext.isOnTrial());
jo.put("deadline", getDeadline(pluginContext));
jo.put("registerFailed", pluginContext.isRegisterFailed());
jo.put("selfState", pluginContext.getSelfState());
jo.put("switchedReason", pluginContext.getSwitchedReason());
ja.put(jo);
}
}catch (Exception e){

20
designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java

@ -3,6 +3,7 @@ package com.fr.design.extra;
import com.fr.base.passport.FinePassportManager;
import com.fr.config.MarketConfig;
import com.fr.design.RestartHelper;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.exe.GetInstalledPluginsExecutor;
import com.fr.design.extra.exe.GetPluginCategoriesExecutor;
@ -11,12 +12,9 @@ import com.fr.design.extra.exe.GetPluginPrefixExecutor;
import com.fr.design.extra.exe.PluginLoginExecutor;
import com.fr.design.extra.exe.ReadUpdateOnlineExecutor;
import com.fr.design.extra.exe.SearchOnlineExecutor;
import com.fr.design.extra.exe.callback.JSCallback;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.utils.concurrent.ThreadFactoryBuilder;
import com.fr.general.CloudCenter;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginMarker;
@ -172,7 +170,7 @@ public class PluginWebBridge {
* @param callback 回调函数
*/
public void installPluginOnline(final String pluginInfo, final JSObject callback) {
JSCallback jsCallback = new JSCallback(webEngine, callback);
JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback));
PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo);
PluginOperateUtils.installPluginOnline(pluginMarker, jsCallback);
}
@ -183,7 +181,7 @@ public class PluginWebBridge {
* @param filePath 插件包的路径
*/
public void installPluginFromDisk(final String filePath, final JSObject callback) {
JSCallback jsCallback = new JSCallback(webEngine, callback);
JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback));
File file = new File(filePath);
PluginOperateUtils.installPluginFromDisk(file, jsCallback);
}
@ -194,7 +192,7 @@ public class PluginWebBridge {
* @param pluginInfo 插件信息
*/
public void uninstallPlugin(final String pluginInfo, final boolean isForce, final JSObject callback) {
JSCallback jsCallback = new JSCallback(webEngine, callback);
JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback));
PluginOperateUtils.uninstallPlugin(pluginInfo, isForce, jsCallback);
}
@ -204,7 +202,7 @@ public class PluginWebBridge {
* @param pluginIDs 插件集合
*/
public void updatePluginOnline(JSObject pluginIDs, final JSObject callback) {
JSCallback jsCallback = new JSCallback(webEngine, callback);
JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback));
String[] pluginInfos = jsObjectToStringArray(pluginIDs);
List<PluginMarker> pluginMarkerList = new ArrayList<PluginMarker>();
for (int i = 0; i < pluginInfos.length; i++) {
@ -219,7 +217,7 @@ public class PluginWebBridge {
* @param filePath 插件包的路径
*/
public void updatePluginFromDisk(String filePath, final JSObject callback) {
JSCallback jsCallback = new JSCallback(webEngine, callback);
JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback));
File file = new File(filePath);
PluginOperateUtils.updatePluginFromDisk(file, jsCallback);
}
@ -230,7 +228,7 @@ public class PluginWebBridge {
* @param pluginID 插件ID
*/
public void setPluginActive(String pluginID, final JSObject callback) {
JSCallback jsCallback = new JSCallback(webEngine, callback);
JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback));
PluginOperateUtils.setPluginActive(pluginID, jsCallback);
}
@ -427,7 +425,7 @@ public class PluginWebBridge {
* @param callback
*/
public void registerLoginInfo(final JSObject callback) {
JSCallback jsCallback = new JSCallback(webEngine, callback);
JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback));
PluginOperateUtils.getLoginInfo(jsCallback, uiLabel);
}
@ -559,7 +557,7 @@ public class PluginWebBridge {
}
public void getPackInfo(final JSObject callback){
JSCallback jsCallback = new JSCallback(webEngine, callback);
JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback));
jsCallback.execute(StringUtils.EMPTY);
}

1
designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java

@ -1,5 +1,6 @@
package com.fr.design.extra.exe.callback;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.extra.PluginOperateUtils;
import com.fr.design.extra.PluginUtils;

1
designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java

@ -1,5 +1,6 @@
package com.fr.design.extra.exe.callback;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.extra.PluginOperateUtils;
import com.fr.log.FineLoggerFactory;

1
designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java

@ -1,5 +1,6 @@
package com.fr.design.extra.exe.callback;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.extra.PluginUtils;
import com.fr.plugin.manage.control.PluginTaskCallback;

1
designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java

@ -1,5 +1,6 @@
package com.fr.design.extra.exe.callback;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.extra.PluginUtils;
import com.fr.log.FineLoggerFactory;

1
designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java

@ -1,5 +1,6 @@
package com.fr.design.extra.exe.callback;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.extra.PluginOperateUtils;
import com.fr.design.extra.PluginUtils;

1
designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java

@ -1,5 +1,6 @@
package com.fr.design.extra.exe.callback;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.extra.PluginOperateUtils;
import com.fr.log.FineLoggerFactory;

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

@ -41,17 +41,17 @@ public class HistoryTemplateListCache implements CallbackEvent {
private List<JTemplate<?, ?>> historyList;
private JTemplate<?, ?> editingTemplate;
private static volatile HistoryTemplateListCache THIS;
private static volatile HistoryTemplateListCache instacne;
public static HistoryTemplateListCache getInstance() {
if (THIS == null) {
if (instacne == null) {
synchronized (HistoryTemplateListCache.class) {
if (THIS == null) {
THIS = new HistoryTemplateListCache();
if (instacne == null) {
instacne = new HistoryTemplateListCache();
}
}
}
return THIS;
return instacne;
}
private HistoryTemplateListCache() {
@ -66,8 +66,8 @@ public class HistoryTemplateListCache implements CallbackEvent {
public void closeSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected);
//直接关闭模板的时候退出权限编辑
if (DesignModeContext.isAuthorityEditing()) {
//直接关闭模板的时候(当且仅当设计器tab上只剩一个模板)退出权限编辑
if (DesignModeContext.isAuthorityEditing() && historyList.size() <= 1) {
DesignerContext.getDesignerFrame().closeAuthorityEditing();
}
if (contains(selected) == -1) {
@ -263,9 +263,9 @@ public class HistoryTemplateListCache implements CallbackEvent {
JTemplate<?, ?> template = iterator.next();
String tPath = template.getPath();
if (isDir ? tPath.startsWith(path) : tPath.equals(path)) {
int size = getHistoryCount();
iterator.remove();
int index = iterator.nextIndex();
int size = getHistoryCount();
if (size == index + 1 && index > 0) {
//如果删除的是后一个Tab,则定位到前一个
MutilTempalteTabPane.getInstance().setSelectedIndex(index - 1);

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

@ -751,8 +751,11 @@ public class MutilTempalteTabPane extends JComponent {
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
selectedIndex = HistoryTemplateListCache.getInstance().contains(template);
}
//如果是已后台关闭的模板,则重新打开文件
openedTemplate.get(selectedIndex).activeOldJTemplate();
if (selectedIndex < openedTemplate.size()) {
//如果是已后台关闭的模板,则重新打开文件
openedTemplate.get(selectedIndex).activeOldJTemplate();
}
}
}

38
designer-base/src/main/java/com/fr/design/fun/OemProcessor.java

@ -0,0 +1,38 @@
package com.fr.design.fun;
import com.fr.design.menu.MenuDef;
import com.fr.start.SplashStrategy;
import java.awt.image.BufferedImage;
import java.util.List;
/**
* 设计器Oem接口
*/
public interface OemProcessor {
public static final String MARK_STRING = "OemProcessor";
/**
* 启动动画,如果不替换则返回null
*
* @return
*/
SplashStrategy createSplashStrategy();
/**
* 替换标题图标--DesignerFrame.initTitleIcon
* 如果不替换则返回null
*
* @return
*/
List<BufferedImage> createTitleIcon();
/**
* 处理设计器菜单增删改
*
* @param menuDefs 已加载的菜单
* @return 新的菜单数组
*/
MenuDef[] dealWithMenuDef(MenuDef[] menuDefs);
}

25
designer-base/src/main/java/com/fr/design/fun/impl/AbstractOemProcessor.java

@ -0,0 +1,25 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.OemProcessor;
import com.fr.design.menu.MenuDef;
import com.fr.start.SplashStrategy;
import java.awt.image.BufferedImage;
import java.util.List;
public abstract class AbstractOemProcessor implements OemProcessor{
@Override
public MenuDef[] dealWithMenuDef(MenuDef[] menuDefs) {
return menuDefs;
}
@Override
public List<BufferedImage> createTitleIcon() {
return null;
}
@Override
public SplashStrategy createSplashStrategy() {
return null;
}
}

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

@ -1,12 +1,11 @@
package com.fr.design.gui.chart;
import javax.swing.JComponent;
import com.fr.base.chart.BaseChart;
import com.fr.base.chart.BaseChartCollection;
import com.fr.stable.core.PropertyChangeAdapter;
import com.fr.chartx.attr.ChartProvider;
import com.fr.stable.core.PropertyChangeListener;
import javax.swing.JComponent;
/**
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2013-7-10 上午09:19:36
@ -18,8 +17,8 @@ public abstract class MiddleChartComponent extends JComponent {
public abstract BaseChartCollection update();
public abstract void reset();
public abstract BaseChart getEditingChart();
public abstract void addStopEditingListener(PropertyChangeListener list);
public abstract ChartProvider getEditingChart();
public abstract void addStopEditingListener(PropertyChangeListener list);
}

3
designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java

@ -60,7 +60,8 @@ class JControlUpdatePane extends JPanel {
elEditing = el;
NameableCreator[] creators = listControlPane.creators();
for (int i = 0, len = updatePanes.length; i < len; i++) {
//倒序的原因是为了让一些继承内置连接类的插件实现能够生效REPORT-15409
for (int i = updatePanes.length - 1; i > -1; i--) {
Object ob2Populate = creators[i].acceptObject2Populate(el.wrapper);
if (ob2Populate != null) {
if (updatePanes[i] == null) {

4
designer-base/src/main/java/com/fr/design/gui/date/SingleObjectComboBoxModel.java

@ -1,6 +1,7 @@
package com.fr.design.gui.date;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;
@ -9,7 +10,7 @@ import java.util.Date;
public class SingleObjectComboBoxModel extends AbstractListModel implements ComboBoxModel {
private SimpleDateFormat dateFormat;
private String selectedDate = "";
private String selectedDate = StringUtils.EMPTY;
public SingleObjectComboBoxModel() {
}
@ -28,6 +29,7 @@ public class SingleObjectComboBoxModel extends AbstractListModel implements Comb
public void setSelectedItem(Object anItem) {
if (anItem == null) {
selectedDate = StringUtils.EMPTY;
return;
}
if (anItem instanceof Date) {

14
designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java

@ -6,6 +6,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JComboBox;
@ -157,7 +158,11 @@ public class UIDatePicker extends UIComboBox implements Serializable {
* 设置当前选择的日期
*/
public void setSelectedDate(Date date) throws ParseException {
this.setSelectedItem(dateFormat.format(date));
if (date == null) {
this.setSelectedItem(null);
} else {
this.setSelectedItem(dateFormat.format(date));
}
}
public void setSelectedItem(Object anObject) {
@ -215,8 +220,11 @@ public class UIDatePicker extends UIComboBox implements Serializable {
try {
String strDate = comboBox.getSelectedItem().toString();
synchronized (this) {
Date selectionDate = dateFormat.parse(strDate);
calendarPanel.setSelectedDate(selectionDate);
Date selectionDate = new Date();
if (StringUtils.isNotBlank(strDate)) {
selectionDate = dateFormat.parse(strDate);
}
calendarPanel.setSelectedDate(selectionDate);
calendarPanel.updateHMS();
}
} catch (Exception e) {

3
designer-base/src/main/java/com/fr/design/gui/frpane/BaseHyperlinkGroup.java

@ -4,6 +4,7 @@ import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.module.DesignModuleFactory;
import com.fr.js.JavaScript;
import com.fr.stable.Filter;
import org.jetbrains.annotations.NotNull;
/**
* 基础的超级链接类型, 不包括图表相关超链.
@ -18,6 +19,8 @@ public class BaseHyperlinkGroup implements HyperlinkGroupType {
*
* @return NameableCreator[]
*/
@NotNull
@Override
public NameableCreator[] getHyperlinkCreators() {
return DesignModuleFactory.getCreators4Hyperlink();
}

2
designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupType.java

@ -3,6 +3,7 @@ package com.fr.design.gui.frpane;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.js.JavaScript;
import com.fr.stable.Filter;
import org.jetbrains.annotations.NotNull;
/**
* 超级链接 支持的类型 种类.
@ -17,6 +18,7 @@ public interface HyperlinkGroupType {
*
* @return NameableCreator[]
*/
@NotNull
NameableCreator[] getHyperlinkCreators();

4
designer-base/src/main/java/com/fr/design/gui/frpane/ImgChooseWrapper.java

@ -7,7 +7,6 @@ import com.fr.design.style.background.image.ImageFileChooser;
import com.fr.design.style.background.image.ImagePreviewer;
import com.fr.design.utils.ImageUtils;
import com.fr.general.ImageWithSuffix;
import com.fr.stable.CoreGraphHelper;
import com.fr.stable.StringUtils;
@ -16,6 +15,7 @@ import javax.swing.SwingWorker;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
/**
@ -103,7 +103,7 @@ public class ImgChooseWrapper {
if (imageFileChooser.isCheckSelected()) {
imageWithSuffix = ImageUtils.defaultImageCompWithSuff(selectedFile);
} else {
Image image = BaseUtils.readImage(selectedFile.getPath());
BufferedImage image = BaseUtils.readImage(selectedFile.getPath());
String type = ImageUtils.getImageType(selectedFile);
imageWithSuffix = new ImageWithSuffix(image, type);
}

44
designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java

@ -25,10 +25,13 @@ import com.fr.stable.StringUtils;
* @since 2012-5-11下午4:28:24
*/
public class UIToggleButton extends UIButton implements GlobalNameObserver{
private static final int ICON_COUNT = 2;
private boolean isSelected;
private boolean isEventBannded = false;
private String toggleButtonName = "";
private GlobalNameListener globalNameListener = null;
private Icon[] icons;
public UIToggleButton() {
this(StringUtils.EMPTY);
@ -53,9 +56,9 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{
* @param icons
*/
public UIToggleButton(Icon[] icons) {
super(icons[0], null, icons[1]);
setSelectedIcon(icons[1]);
super(icons[0], null, null);
setExtraPainted(true);
this.icons = icons;
addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
@ -73,10 +76,10 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{
* @param icons
*/
public UIToggleButton(Icon[] icons, boolean needRelease) {
super(icons[0], null, icons[1]);
super(icons[0], null, null);
setBorderPainted(true);
setSelectedIcon(icons[1]);
setExtraPainted(true);
this.icons = icons;
if (!needRelease) {
addActionListener(new AbstractAction() {
@Override
@ -92,6 +95,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{
addMouseListener(getMouseListener());
}
@Override
public void setGlobalName(String name){
toggleButtonName = name ;
}
@ -100,6 +104,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{
*
* @return
*/
@Override
public boolean isSelected() {
return isSelected;
}
@ -115,12 +120,15 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{
super.setSelected(isSelected);
if (this.isSelected != isSelected) {
this.isSelected = isSelected;
repaint();
refresh(isSelected);
}
}
@Override
protected void initListener(){
if(shouldResponseChangeListener()){
this.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (uiObserverListener == null) {
return;
@ -138,10 +146,30 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{
if (this.isSelected != isSelected) {
this.isSelected = isSelected;
fireSelectedChanged();
repaint();
refresh(isSelected);
}
}
private void refresh(final boolean isSelected) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
Icon[] icons = UIToggleButton.this.icons;
if (icons != null && icons.length == ICON_COUNT) {
if (isSelected) {
UIToggleButton.this.setIcon(icons[1]);
} else {
UIToggleButton.this.setIcon(icons[0]);
}
}
UIToggleButton.this.repaint();
}
});
}
protected MouseListener getMouseListener() {
return new MouseAdapter() {
@Override
@ -157,6 +185,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{
this.isEventBannded = ban;
}
@Override
protected void fireStateChanged() {
}
@ -187,6 +216,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{
}
}
@Override
protected void paintOtherBorder(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.setStroke(UIConstants.BS);
@ -200,6 +230,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{
*
* @return 如果需要响应观察者事件则返回true否则返回false
*/
@Override
public boolean shouldResponseChangeListener() {
return true;
}
@ -208,6 +239,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{
*
* @param listener 观察者监听事件
*/
@Override
public void registerNameListener(GlobalNameListener listener) {
globalNameListener = listener;
}

23
designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java

@ -20,8 +20,10 @@ import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.event.EventDispatcher;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.plugin.ExtraClassManager;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.manage.PluginFilter;
@ -94,11 +96,11 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO
imageLayoutComboBox = new UIComboBox(LAYOUT);
initTextRotationCombox();
Icon[][] hAlignmentIconArray = {{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal_white.png")},
{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal_white.png")},
{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal_white.png")},
{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal_white.png")},
{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment_white.png")}};
Icon[][] hAlignmentIconArray = {{IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal_white.png")},
{IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal_white.png")},
{IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal_white.png")},
{IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal_white.png")},
{IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment_white.png")}};
Integer[] hAlignment = new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT, Integer.valueOf(Constants.DISTRIBUTED), Constants.NULL};
hAlignmentPane = new UIButtonGroup<Integer>(hAlignmentIconArray, hAlignment);
hAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Left"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Right"),
@ -106,9 +108,9 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO
hPaneContainer = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
vPaneContainer = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
Icon[][] vAlignmentIconArray = {{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_top_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_top_normal_white.png")},
{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal_white.png")},
{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal_white.png")}};
Icon[][] vAlignmentIconArray = {{IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_top_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_top_normal_white.png")},
{IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal_white.png")},
{IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal_white.png")}};
Integer[] vAlignment = new Integer[]{Constants.TOP, Constants.CENTER, Constants.BOTTOM};
vAlignmentPane = new UIButtonGroup<Integer>(vAlignmentIconArray, vAlignment);
vAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Top"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Bottom")});
@ -210,9 +212,11 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO
private JPanel basicPane() {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
UILabel horizontalLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Pane_Horizontal") + " ", SwingConstants.LEFT);
UIComponentUtils.setLineWrap(horizontalLabel);
Component[][] components = new Component[][]{
new Component[]{null, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Pane_Horizontal") + " ", SwingConstants.LEFT), hPaneContainer},
new Component[]{horizontalLabel, hPaneContainer},
new Component[]{null, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Pane_Vertical") + " ", SwingConstants.RIGHT), vPaneContainer},
new Component[]{null, null}
@ -304,6 +308,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO
*
* @param style the new style.
*/
@Override
public void populateBean(Style style) {
hAlignmentPane.setSelectedItem(BaseUtils.getAlignment4Horizontal(style));
vAlignmentPane.setSelectedItem(style.getVerticalAlignment());

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

@ -22,16 +22,18 @@ public class BorderIcon implements Icon {
this.cellBorderStyle = cellBorderStyle;
}
@Override
public int getIconHeight() {
return height;
}
@Override
public int getIconWidth() {
return width;
}
public static void drawLine(Graphics g, double x1, double y1, double x2,
private void drawLine(Graphics g, double x1, double y1, double x2,
double y2, int lineStyle, Color color) {
g.setColor(color);
x1--;
@ -63,6 +65,7 @@ public class BorderIcon implements Icon {
}
}
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
int defaultWidth = c.getWidth();
int defaultHeight = c.getHeight();
@ -81,9 +84,9 @@ public class BorderIcon implements Icon {
cellBorderStyle.getBottomColor());
drawLine(gr, x1, y1, x1, y2, cellBorderStyle.getLeftStyle(),
cellBorderStyle.getLeftColor());
drawLine(gr, defaultWidth / 2, x1, defaultWidth / 2, x2,
drawLine(gr, defaultWidth / 2, y1, defaultWidth / 2, y2,
cellBorderStyle.getVerticalStyle(), cellBorderStyle.getVerticalColor());
drawLine(gr, y1, defaultHeight / 2, y2, defaultHeight / 2,
drawLine(gr, x1, defaultHeight / 2, x2, defaultHeight / 2,
cellBorderStyle.getHorizontalStyle(), cellBorderStyle.getHorizontalColor());
}

32
designer-base/src/main/java/com/fr/design/javascript/beautify/JavaScriptFormatHelper.java

@ -1,16 +1,16 @@
package com.fr.design.javascript.beautify;
import com.fr.log.FineLoggerFactory;
import com.eclipsesource.v8.V8;
import com.eclipsesource.v8.V8Array;
import com.eclipsesource.v8.V8Object;
import com.eclipsesource.v8.utils.V8ObjectUtils;
import com.fr.general.IOUtils;
import com.fr.script.ScriptFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.EncodeConstants;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
public class JavaScriptFormatHelper {
@ -34,15 +34,21 @@ public class JavaScriptFormatHelper {
*/
public static String beautify(String jsCode, BeautifyOption option) {
InputStream resourceAsStream = IOUtils.readResource("com/fr/design/javascript/beautify/beautify.js");
ScriptEngine scriptEngine = ScriptFactory.newScriptEngine();
String result = jsCode;
V8 v8 = V8.createV8Runtime();
try {
Reader reader = new InputStreamReader(resourceAsStream);
scriptEngine.eval(reader);
Invocable invocable = (Invocable) scriptEngine;
result = (String) invocable.invokeFunction("js_beautify_global", jsCode, option.toFormatArgument());
} catch (ScriptException | NoSuchMethodException e) {
v8.executeVoidScript(IOUtils.inputStream2String(resourceAsStream, EncodeConstants.ENCODING_UTF_8));
V8Array parameters = new V8Array(v8);
parameters.push(jsCode);
V8Object arg = V8ObjectUtils.toV8Object(v8, option.toFormatArgument());
parameters.push(arg);
result = v8.executeStringFunction("js_beautify_global", parameters);
parameters.release();
arg.release();
} catch (UnsupportedEncodingException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
v8.release(true);
}
return result;
}

31
designer-base/src/main/java/com/fr/design/locale/impl/ProductImproveMark.java

@ -0,0 +1,31 @@
package com.fr.design.locale.impl;
import com.fr.general.GeneralContext;
import com.fr.general.locale.LocaleMark;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
* @author Hades
* @date 2019/6/24
*/
public class ProductImproveMark implements LocaleMark<Boolean> {
private Map<Locale, Boolean> map = new HashMap<>();
public ProductImproveMark() {
map.put(Locale.CHINA, true);
map.put(Locale.TAIWAN, false);
map.put(Locale.US, false);
map.put(Locale.KOREA, false);
map.put(Locale.JAPAN, false);
}
@Override
public Boolean getValue() {
Boolean result = map.get(GeneralContext.getLocale());
return result == null ? false : result;
}
}

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

@ -0,0 +1,35 @@
package com.fr.design.locale.impl;
import com.fr.design.DesignerEnvManager;
import com.fr.general.GeneralContext;
import com.fr.general.locale.LocaleMark;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
* @author Hades
* @date 2019/6/24
*/
public class SplashMark implements LocaleMark<String> {
private Map<Locale, String> map = new HashMap<Locale, String>();
private static final String SPLASH_PATH = "/com/fr/design/images/splash_10.gif";
private static final String SPLASH_EN_PATH = "/com/fr/design/images/splash_10_en.gif";
private static final String SPLASH_JP_PATH = "/com/fr/design/images/splash_10_jp.gif";
public SplashMark() {
map.put(Locale.CHINA, SPLASH_PATH);
map.put(Locale.KOREA, SPLASH_EN_PATH);
map.put(Locale.JAPAN, SPLASH_JP_PATH);
map.put(Locale.US, SPLASH_EN_PATH);
map.put(Locale.TAIWAN, SPLASH_EN_PATH);
}
@Override
public String getValue() {
String result = map.get(DesignerEnvManager.getEnvManager().getLanguage());
return result == null ? SPLASH_EN_PATH : result;
}
}

44
designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java

@ -0,0 +1,44 @@
package com.fr.design.locale.impl;
import com.fr.general.locale.SupportLocale;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
/**
* 某些国际化环境支持的操作
* 需要增加/删除支持的语言 统一在这里修改 无须改动业务代码
* 后续有新的不同语言下的差异操作 添加新的枚举
* @author Hades
* @date 2019/6/24
*/
public enum SupportLocaleImpl implements SupportLocale {
/**
* 社区菜单支持的国际化环境
*/
COMMUNITY {
@Override
public Set<Locale> support() {
Set<Locale> set = new HashSet<Locale>();
set.add(Locale.CHINA);
set.add(Locale.TAIWAN);
return set;
}
},
/**
* Facebook支持的国际化环境
*/
FACEBOOK {
@Override
public Set<Locale> support() {
Set<Locale> set = new HashSet<Locale>();
set.add(Locale.TAIWAN);
return set;
}
}
}

36
designer-base/src/main/java/com/fr/design/locale/impl/UserInfoMark.java

@ -0,0 +1,36 @@
package com.fr.design.locale.impl;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.general.locale.LocaleMark;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
* @author Hades
* @date 2019/6/24
*/
public class UserInfoMark implements LocaleMark<String> {
private Map<Locale, String> map = new HashMap<>();
private static final String CN_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.cn");
private static final String EN_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.en");
private static final String TW_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.tw");
private static final String JP_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.jp");
public UserInfoMark() {
map.put(Locale.CHINA, CN_LOGIN_HTML);
map.put(Locale.KOREA, EN_LOGIN_HTML);
map.put(Locale.JAPAN, JP_LOGIN_HTML);
map.put(Locale.US, EN_LOGIN_HTML);
map.put(Locale.TAIWAN, TW_LOGIN_HTML);
}
@Override
public String getValue() {
String result = map.get(GeneralContext.getLocale());
return result == null ? EN_LOGIN_HTML : result;
}
}

35
designer-base/src/main/java/com/fr/design/locale/impl/VideoMark.java

@ -0,0 +1,35 @@
package com.fr.design.locale.impl;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.general.locale.LocaleMark;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
* @author Hades
* @date 2019/6/24
*/
public class VideoMark implements LocaleMark<String> {
private Map<Locale, String> map = new HashMap<>();
private static final String VIDEO_EN = CloudCenter.getInstance().acquireUrlByKind("bbs.video.en");
private static final String VIDEO_CN = CloudCenter.getInstance().acquireUrlByKind("bbs.video");
private static final String VIDEO_TW = CloudCenter.getInstance().acquireUrlByKind("bbs.video.tw");
public VideoMark() {
map.put(Locale.CHINA, VIDEO_CN);
map.put(Locale.KOREA, VIDEO_EN);
map.put(Locale.JAPAN, VIDEO_EN);
map.put(Locale.US, VIDEO_EN);
map.put(Locale.TAIWAN, VIDEO_TW);
}
@Override
public String getValue() {
String result = map.get(GeneralContext.getLocale());
return result == null ? VIDEO_EN : result;
}
}

11
designer-base/src/main/java/com/fr/design/mainframe/DesignAuthorityEventType.java

@ -0,0 +1,11 @@
package com.fr.design.mainframe;
import com.fr.event.Event;
public enum DesignAuthorityEventType implements Event<DesignerFrame> {
// 退出权限编辑
StartEdit,
// 进入权限编辑
StopEdit;
}

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

@ -24,6 +24,7 @@ import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.NewTemplatePane;
import com.fr.design.file.SaveSomeTemplatePane;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.fun.OemProcessor;
import com.fr.design.fun.TitlePlaceProcessor;
import com.fr.design.fun.impl.AbstractTemplateTreeShortCutProvider;
import com.fr.design.gui.ibutton.UIButton;
@ -36,9 +37,11 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.loghandler.LogMessageBar;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.menu.MenuManager;
import com.fr.design.menu.ShortCut;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.event.EventDispatcher;
import com.fr.exception.DecryptTemplateException;
import com.fr.file.FILE;
import com.fr.file.FILEFactory;
@ -56,6 +59,7 @@ import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.image4j.codec.ico.ICODecoder;
import com.fr.stable.project.ProjectConstants;
import com.fr.start.OemHandler;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
@ -304,16 +308,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
}
});
this.addDesignerOpenedListener(new DesignerOpenedListener() {
@Override
public void designerOpened() {
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setComposite();
reCalculateFrameSize();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().doResize();
}
});
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.setVisible(false);
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
@ -322,7 +316,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
initMenuPane();
this.progressDialog = new ProgressDialog(this);
}
public void resizeFrame() {
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setComposite();
reCalculateFrameSize();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().doResize();
}
public void closeAuthorityEditing() {
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL);
WestRegionContainerPane.getInstance().replaceDownPane(
@ -333,6 +334,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
needToAddAuhtorityPaint();
refreshDottedLine();
fireAuthorityStateToNomal();
EventDispatcher.fire(DesignAuthorityEventType.StopEdit, DesignerFrame.this);
}
/**
@ -456,8 +458,19 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
try {
@SuppressWarnings("unchecked")
List<BufferedImage> image = ICODecoder.read(DesignerFrame.class
.getResourceAsStream("/com/fr/base/images/oem/logo.ico"));
OemProcessor oemProcessor = OemHandler.findOem();
List<BufferedImage> image = null;
if (oemProcessor != null) {
try {
image = oemProcessor.createTitleIcon();
} catch (Throwable e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
if (image == null) {
image = ICODecoder.read(DesignerFrame.class
.getResourceAsStream("/com/fr/base/images/oem/logo.ico"));
}
this.setIconImages(image);
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
@ -909,6 +922,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
jt.addJTemplateActionListener(this);
jt.addTargetModifiedListener(this);
jt.addJTemplateActionListener(VcsHelper.getInstance());
centerTemplateCardPane.showJTemplate(jt);
setTitle();
layeredPane.repaint();

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

@ -2,6 +2,7 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.vcs.DesignerMode;
import com.fr.cluster.engine.base.FineClusterConfig;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
@ -26,6 +27,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.mainframe.vcs.ui.FileVersionsPanel;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.ShortCut;
@ -49,7 +51,6 @@ import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.workspace.WorkContext;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
@ -79,6 +80,9 @@ import static javax.swing.JOptionPane.WARNING_MESSAGE;
public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange {
private static final String FILE = "file";
private static volatile DesignerFrameFileDealerPane THIS;
static {
GeneralContext.listenPluginRunningChanged(new PluginEventListener() {
@ -95,10 +99,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
});
}
private static final String FILE = "file";
private static volatile DesignerFrameFileDealerPane THIS;
private List<FileToolbarStateChangeListener> otherToolbarStateChangeListeners = new ArrayList<>();
private FileOperations selectedOperation;
@ -118,25 +118,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private VcsAction vcsAction = new VcsAction();
/**
* 刷新
*/
public void refresh() {
selectedOperation.refresh();
}
public static DesignerFrameFileDealerPane getInstance() {
if (THIS == null) {
synchronized (DesignerFrameFileDealerPane.class) {
if (THIS == null) {
THIS = new DesignerFrameFileDealerPane();
}
}
}
return THIS;
}
private DesignerFrameFileDealerPane() {
setLayout(new BorderLayout());
@ -164,6 +145,24 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
stateChange();
}
public static DesignerFrameFileDealerPane getInstance() {
if (THIS == null) {
synchronized (DesignerFrameFileDealerPane.class) {
if (THIS == null) {
THIS = new DesignerFrameFileDealerPane();
}
}
}
return THIS;
}
/**
* 刷新
*/
public void refresh() {
selectedOperation.refresh();
}
public final void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
@ -202,15 +201,31 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
for (ShortCut shortCut : extraShortCuts) {
toolbarDef.addShortCut(shortCut);
}
if (VcsHelper.needInit()) {
toolbarDef.addShortCut(vcsAction);
}
addVcsAction(toolbarDef);
toolbarDef.updateToolBar(toolBar);
resetActionStatus();
refresh();
}
/**
* 添加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 {
vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_Title"));
}
toolbarDef.addShortCut(vcsAction);
}
}
private void resetActionStatus() {
newFolderAction.setEnabled(false);
@ -255,6 +270,41 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
}
private boolean isCurrentEditing(String path) {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
String editing = jt.getEditingFILE().getPath();
return ComparatorUtils.equals(editing, path);
}
/**
* 按钮状态改变
*/
@Override
public void stateChange() {
int selectedPathNum = TemplateTreePane.getInstance().countSelectedPath();
// 新建文件夹,重命名操作,在explorer中打开三个操作在选中单个文件夹或者文件时可用,其他情况不可用
boolean singleSelected = selectedPathNum == 1;
newFolderAction.setEnabled(singleSelected);
renameAction.setEnabled(singleSelected);
showInExplorerAction.setEnabled(singleSelected);
// 删除操作在至少选中一个时可用
boolean selected = selectedPathNum > 0;
delFileAction.setEnabled(selected);
// 刷新操作始终可用
refreshTreeAction.setEnabled(true);
//触发vcsAction变化
vcsAction.fireVcsActionChange();
// 其他状态
otherStateChange();
}
public FileOperations getSelectedOperation() {
return selectedOperation;
}
/*
* 新建文件夹
*/
@ -287,8 +337,8 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
* 版本管理
*/
private class VcsAction extends UpdateAction {
public VcsAction() {
this.setName(Toolkit.i18nText("Fine-Design_Vcs_Title"));
this.setSmallIcon(VcsHelper.VCS_LIST_PNG);
}
@ -299,15 +349,44 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
boolean isCurrentEditing = isCurrentEditing(path);
// 如果模板正在编辑,保存后再打开版本管理
if (isCurrentEditing) {
saveCurrentEditingTemplate();
}
// 如果模板已经打开了,关掉,避免出现2个同名tab(1个是模板,1个是版本)
closeOpenedTemplate(path, isCurrentEditing);
FileVersionsPanel fileVersionTablePanel = FileVersionsPanel.getInstance();
fileVersionTablePanel.showFileVersionsPane();
stateChange();
}
/**
* 版本管理可用状态的监控
*/
private void fireVcsActionChange() {
if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.getInstance().isUnSelectedTemplate() || FineClusterConfig.getInstance().isCluster()) {
setEnabled(false);
return;
}
if (WorkContext.getCurrent() != null) {
if (!WorkContext.getCurrent().isLocal()) {
//当前环境为远程环境时
FileNode node = TemplateTreePane.getInstance().getTemplateFileTree().getSelectedFileNode();
if (selectedOperation.getFilePath() != null) {
if (node.getLock() != null && !ComparatorUtils.equals(node.getUserID(), node.getLock())) {
setEnabled(false);
} else {
setEnabled(true);
}
} else {
setEnabled(false);
}
} else {
//当前环境为本地环境时
setEnabled(selectedOperation.getFilePath() != null);
}
}
}
private void closeOpenedTemplate(String path, boolean isCurrentEditing) {
@ -326,19 +405,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
private void saveCurrentEditingTemplate() {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
jt.stopEditing();
jt.saveTemplate();
jt.requestFocus();
}
private boolean isCurrentEditing(String path) {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
String editing = jt.getEditingFILE().getPath();
return ComparatorUtils.equals(editing, path);
}
/**
* 在系统资源管理器中打开
*/
@ -436,65 +502,10 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
selectedOperation.deleteFile();
stateChange();
DesignerContext.getDesignerFrame().setTitle();
}
}
/**
* 按钮状态改变
*/
@Override
public void stateChange() {
int selectedPathNum = TemplateTreePane.getInstance().countSelectedPath();
// 新建文件夹,重命名操作,在explorer中打开三个操作在选中单个文件夹或者文件时可用,其他情况不可用
boolean singleSelected = selectedPathNum == 1;
newFolderAction.setEnabled(singleSelected);
renameAction.setEnabled(singleSelected);
showInExplorerAction.setEnabled(singleSelected);
// 删除操作在至少选中一个时可用
boolean selected = selectedPathNum > 0;
delFileAction.setEnabled(selected);
// 刷新操作始终可用
refreshTreeAction.setEnabled(true);
handleVcsAction();
// 其他状态
otherStateChange();
}
private void handleVcsAction() {
if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.isUnSelectedTemplate()) {
vcsAction.setEnabled(false);
return;
}
if (WorkContext.getCurrent() != null) {
if (!WorkContext.getCurrent().isLocal()) {
//当前环境为远程环境时
FileNode node = TemplateTreePane.getInstance().getTemplateFileTree().getSelectedFileNode();
if (selectedOperation.getFilePath() != null) {
if (node.getLock() != null && !ComparatorUtils.equals(node.getUserID(), node.getLock())) {
vcsAction.setEnabled(false);
} else {
vcsAction.setEnabled(true);
}
} else {
vcsAction.setEnabled(false);
}
} else {
//当前环境为本地环境时
vcsAction.setEnabled(selectedOperation.getFilePath() != null);
}
}
}
public FileOperations getSelectedOperation() {
return selectedOperation;
}
/**
* 重命名对话框
* 支持快捷键EnterESC

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

@ -30,7 +30,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
// 判断是否切换设计器状态到禁止拷贝剪切
if (jt.getTarget().getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) {
DesignModeContext.switchTo(DesignerMode.BAN_COPY_AND_CUT);
} else if (!DesignModeContext.isVcsMode()){
} else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing()){
DesignModeContext.switchTo(DesignerMode.NORMAL);
}
DesignerFrameFileDealerPane.getInstance().setCurrentEditingTemplate(jt);
@ -38,7 +38,8 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
component.onLostFocus();
remove(component);
}
add(component = jt, BorderLayout.CENTER);
component = jt;
add(component, BorderLayout.CENTER);
validate();
repaint();
revalidate();

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

@ -12,6 +12,7 @@ import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.AllowAuthorityEditAction;
import com.fr.design.actions.TableDataSourceAction;
import com.fr.design.actions.edit.RedoAction;
import com.fr.design.actions.edit.UndoAction;
@ -39,7 +40,6 @@ import com.fr.design.mainframe.template.info.TemplateProcessInfo;
import com.fr.design.mainframe.template.info.TimeConsumeTimer;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.mainframe.toolbar.VcsScene;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.NameSeparator;
import com.fr.design.menu.ShortCut;
@ -112,7 +112,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
// 判断是否切换设计器状态到禁止拷贝剪切
if (t.getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) {
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.BAN_COPY_AND_CUT);
} else if (!DesignModeContext.isVcsMode()) {
} else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing()) {
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL);
}
this.template = t;
@ -543,9 +543,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return false;
}
collectInfo();
if (DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable()) {
VcsHelper.dealWithVcs(this);
}
return this.saveFile();
}
@ -606,7 +603,11 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
editingFILE = fileChooser.getSelectedFILE();
}
boolean lockedTarget = WorkContext.getCurrent().get(TplOperator.class).saveAs(editingFILE.getPath());
boolean lockedTarget =
// 目标本地文件
!editingFILE.isEnvFile() ||
// 目标远程文件
WorkContext.getCurrent().get(TplOperator.class).saveAs(editingFILE.getPath());
if (lockedTarget) {
boolean saved = saveNewFile(editingFILE, oldName);
// 目标文件保存成功并且源文件不一致的情况下,把源文件锁释放掉
@ -686,7 +687,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
this.saved = true;
this.authoritySaved = true;
DesignerContext.getDesignerFrame().setTitle();
this.fireJTemplateSaved();
return true;
}
@ -827,7 +827,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
// Process the listeners last to first, notifying
// those that are interested in this event
for (int i = listeners.length - 2; i >= 0; i -= 2) {
for (int i = listeners.length - 1; i >= 0; i -= 1) {
if (listeners[i] == JTemplateActionListener.class) {
((JTemplateActionListener) listeners[i + 1]).templateSaved(this);
}

2
designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java

@ -114,7 +114,7 @@ public class ImageBackgroundQuickPane extends BackgroundQuickPane {
@Override
public Background updateBean() {
ImageFileBackground imageBackground = new ImageFileBackground(previewPane.getImage(), suffix);
ImageFileBackground imageBackground = new ImageFileBackground(previewPane.getImageWithSuffix());
imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem());
imageBackground.setLayout(imageStyle.getImageLayout());
return imageBackground;

2
designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java

@ -304,7 +304,7 @@ public class ImagePreviewPane extends JComponent implements Scrollable, ImagePre
@Override
public void setImage(Image image) {
setImageWithSuffix(image == null ? null : new ImageWithSuffix(image));
setImageWithSuffix(ImageWithSuffix.build(image));
}

45
designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java

@ -44,14 +44,6 @@ public class DesignerLogHandler {
private static final SimpleDateFormat LOG_SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static final int INFO_INT = Level.INFO.toInt();
private static final int ERROR_INT = Level.ERROR.toInt();
private static final int WARN_INT = Level.WARN.toInt();
private static final int DEBUG_INT = Level.DEBUG.toInt();
private static final int GAP_X = -150;
private static final int INFO_GAP_Y = -60;
@ -127,12 +119,12 @@ public class DesignerLogHandler {
JPopupMenu jPopupMenu = new JPopupMenu();
int logLevelInt = Log4jConfig.getInstance().getRootLevel().toInt();
if (logLevelInt <= INFO_INT) {
if (logLevelInt <= DesignerLogger.INFO_INT) {
jPopupMenu.add(showInfo);
jPopupMenu.add(showError);
jPopupMenu.add(showServer);
jPopupMenu.show(caption, caption.getWidth() + GAP_X, INFO_GAP_Y);
} else if (logLevelInt == ERROR_INT) {
} else if (logLevelInt == DesignerLogger.ERROR_INT) {
jPopupMenu.add(showError);
jPopupMenu.add(showServer);
jPopupMenu.show(caption, caption.getWidth() + GAP_X, ERRO_GAP_Y);
@ -241,11 +233,11 @@ public class DesignerLogHandler {
int intLevel = event.getLevel().toInt();
Date date = new Date(event.getTimeStamp());
ThrowableInformation information = event.getThrowableInformation();
if (intLevel == INFO_INT && showInfo.isSelected()) {
if (intLevel == DesignerLogger.INFO_INT && showInfo.isSelected()) {
printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable());
} else if (intLevel == ERROR_INT && showError.isSelected()) {
} else if (intLevel == DesignerLogger.ERROR_INT && showError.isSelected()) {
printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable());
} else if (intLevel == WARN_INT && showServer.isSelected()) {
} else if (intLevel == DesignerLogger.WARN_INT && showServer.isSelected()) {
printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable());
}
}
@ -253,11 +245,11 @@ public class DesignerLogHandler {
public void printStackTrace(String message, Level level, Date date) {
int intLevel = level.toInt();
if (intLevel == INFO_INT && showInfo.isSelected()) {
if (intLevel == DesignerLogger.INFO_INT && showInfo.isSelected()) {
printMessage(message, intLevel, date);
} else if (intLevel == ERROR_INT && showError.isSelected()) {
} else if (intLevel == DesignerLogger.ERROR_INT && showError.isSelected()) {
printMessage(message, intLevel, date);
} else if (intLevel == WARN_INT && showServer.isSelected()) {
} else if (intLevel == DesignerLogger.WARN_INT && showServer.isSelected()) {
printMessage(message, intLevel, date);
}
@ -287,13 +279,13 @@ public class DesignerLogHandler {
private void log(String str, int style) {
SimpleAttributeSet attrSet = new SimpleAttributeSet();
if (style == ERROR_INT) {
if (style == DesignerLogger.ERROR_INT) {
StyleConstants.setForeground(attrSet, new Color(247, 148, 29));
StyleConstants.setBold(attrSet, true);
} else if (style == WARN_INT) {
} else if (style == DesignerLogger.WARN_INT) {
StyleConstants.setForeground(attrSet, Color.red);
StyleConstants.setBold(attrSet, true);
} else if (style == INFO_INT) {
} else if (style == DesignerLogger.INFO_INT) {
StyleConstants.setForeground(attrSet, Color.black);
StyleConstants.setBold(attrSet, false);
} else {
@ -310,9 +302,9 @@ public class DesignerLogHandler {
private String appendLocaleMark(String str, int style) {
if (style == ERROR_INT) {
if (style == DesignerLogger.ERROR_INT) {
str = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + ":" + str + "\n";
} else if (style == WARN_INT) {
} else if (style == DesignerLogger.WARN_INT) {
str = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Seriously") + ":" + str + "\n";
} else {
str = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Normal") + ":" + str + "\n";
@ -323,11 +315,11 @@ public class DesignerLogHandler {
private void setMessage(String message, int level) {
LogMessageBar.getInstance().setMessage(message);
if (level == DesignerLogHandler.INFO_INT && showInfo.isSelected()) {
if (level == DesignerLogger.INFO_INT && showInfo.isSelected()) {
caption.infoAdd();
} else if (level == DesignerLogHandler.ERROR_INT && showError.isSelected()) {
} else if (level == DesignerLogger.ERROR_INT && showError.isSelected()) {
caption.errorAdd();
} else if (level == DesignerLogHandler.WARN_INT && showServer.isSelected()) {
} else if (level == DesignerLogger.WARN_INT && showServer.isSelected()) {
caption.serverAdd();
}
}
@ -368,9 +360,4 @@ public class DesignerLogHandler {
};
}
public void printLoggingEvent(LoggingEvent event) {
logHandlerArea.printStackTrace(event);
}
}

82
designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java

@ -0,0 +1,82 @@
package com.fr.design.mainframe.loghandler;
import com.fr.log.FineLoggerFactory;
import com.fr.third.apache.log4j.Level;
import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.third.apache.log4j.spi.ThrowableInformation;
/**
* 设计器日志记录
*/
public class DesignerLogger {
public static final int INFO_INT = Level.INFO.toInt();
public static final int ERROR_INT = Level.ERROR.toInt();
public static final int WARN_INT = Level.WARN.toInt();
/**
* 记录LoggingEvent对象
*
* @param event
*/
public static void log(LoggingEvent event) {
if (event == null) {
return;
}
LogParser.parse(event).log(event);
}
public enum LogParser {
DEFAULT(-1) {
@Override
public void log(LoggingEvent event) {
}
},
INFO(Level.INFO.toInt()) {
@Override
public void log(LoggingEvent event) {
FineLoggerFactory.getLogger().info(event.getRenderedMessage());
}
},
WARN(Level.WARN.toInt()) {
@Override
public void log(LoggingEvent event) {
ThrowableInformation information = event.getThrowableInformation();
FineLoggerFactory.getLogger().warn(event.getRenderedMessage(), information == null ? null : information.getThrowable());
}
},
ERROR(Level.ERROR.toInt()) {
@Override
public void log(LoggingEvent event) {
ThrowableInformation information = event.getThrowableInformation();
FineLoggerFactory.getLogger().error(event.getRenderedMessage(), information == null ? null : information.getThrowable());
}
};
private int level;
LogParser(int level) {
this.level = level;
}
public int getLevel() {
return level;
}
public static LogParser parse(LoggingEvent event) {
int intLevel = event.getLevel().toInt();
for (LogParser logParser : values()) {
if (logParser.getLevel() == intLevel) {
return logParser;
}
}
return DEFAULT;
}
public void log(LoggingEvent event) {
}
}
}

9
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DownMenuStyleDefinePane.java

@ -2,7 +2,6 @@ package com.fr.design.mainframe.mobile.ui;
import com.fr.base.GraphHelper;
import com.fr.base.Icon;
import com.fr.base.IconManager;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.ilable.UILabel;
@ -11,6 +10,7 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.UITitleSplitLine;
import com.fr.design.mainframe.widget.preview.MobileTemplatePreviewPane;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.WidgetInfoConfig;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.FRFont;
import com.fr.general.cardtag.mobile.DownMenuStyle;
@ -40,6 +40,7 @@ public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
super(tagLayout);
}
@Override
protected void createExtraConfPane(JPanel centerPane) {
JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 0);
panel.setBorder(BorderFactory.createEmptyBorder(0, 20, 5, 20));
@ -134,12 +135,13 @@ public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
private static final int GAP = 6;
private static final String PAINT_ICON = "fund_white";
private static final String ICON_PATH = "/com/fr/web/images/fund_white.png";
private LineDescription splitLine;
private transient LineDescription splitLine;
public DownMenuStylePreviewPane() {
this.setBackground(Color.decode("#3888EE"));
}
@Override
public void repaint() {
super.repaint();
}
@ -172,7 +174,7 @@ public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
g2d.setColor(oldColor);
}
Icon icon = new Icon(PAINT_ICON, ICON_PATH);
g2d.drawImage(IconManager.getIconManager().getDefaultIconImage(icon), (eachWidth - ICON_OFFSET) / 2, (panelHeight - ICON_OFFSET - GAP - fontHeight) / 2, null);
g2d.drawImage(WidgetInfoConfig.getInstance().getIconManager().getDefaultIconImage(icon), (eachWidth - ICON_OFFSET) / 2, (panelHeight - ICON_OFFSET - GAP - fontHeight) / 2, null);
g2d.drawString(displayName, (eachWidth - width) / 2, (panelHeight + ICON_OFFSET + GAP - fontHeight) / 2 + ascent);
Stroke oldStroke = g2d.getStroke();
if (splitLine.getLineStyle() != 0) {
@ -187,6 +189,7 @@ public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
}
@Override
public void populateConfig(MobileTemplateStyle templateStyle) {
super.populateConfig(templateStyle);
this.splitLine = ((DownMenuStyle) templateStyle).getSplitLine();

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

@ -1,6 +1,7 @@
package com.fr.design.mainframe.template.info;
import com.fr.base.FRContext;
import com.fr.base.io.XMLReadHelper;
import com.fr.design.DesignerEnvManager;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ProductConstants;
@ -12,12 +13,15 @@ import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.javax.xml.stream.XMLStreamException;
import com.fr.workspace.WorkContext;
import com.fr.third.org.apache.commons.io.FileUtils;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -32,6 +36,7 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter {
private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList";
private static final String XML_FILE_NAME = "tpl.info";
private static TemplateInfoCollector instance;
private static final int MAX_SIZE = 512 * 1024 * 1024;
private Map<String, TemplateInfo> templateInfoMap;
private DesignerOpenHistory designerOpenHistory;
@ -132,13 +137,24 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter {
if (!getInfoFile().exists()) {
return;
}
try {
XMLableReader xmlReader = XMLableReader.createXMLableReader(new FileReader(getInfoFile()));
xmlReader.readXMLObject(this);
} catch (XMLStreamException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
XMLableReader reader = null;
try (InputStream in = new FileInputStream(getInfoFile())) {
// XMLableReader 还是应该考虑实现 Closable 接口的,这样就能使用 try-with 语句了
reader = XMLReadHelper.createXMLableReader(in, XMLPrintWriter.XML_ENCODER);
reader.readXMLObject(this);
} catch (FileNotFoundException e) {
// do nothing
} catch (XMLStreamException | IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (XMLStreamException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
@ -152,7 +168,7 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter {
}
private boolean shouldCollectInfo() {
return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv();
return FileUtils.sizeOf(getInfoFile()) <= MAX_SIZE && DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv();
}
/**
@ -160,8 +176,12 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter {
*/
private void saveInfo() {
try {
FileOutputStream out = new FileOutputStream(getInfoFile());
ByteArrayOutputStream out = new ByteArrayOutputStream();
XMLTools.writeOutputStreamXML(this, out);
out.flush();
out.close();
String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8);
FileUtils.writeStringToFile(getInfoFile(), fileContent, StandardCharsets.UTF_8);
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage());
}

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

@ -6,12 +6,14 @@ package com.fr.design.mainframe.toolbar;
import com.fr.base.FRContext;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.community.BBSAction;
import com.fr.design.actions.community.BugAction;
import com.fr.design.actions.community.CenterAction;
import com.fr.design.actions.community.CusDemandAction;
import com.fr.design.actions.community.FacebookFansAction;
import com.fr.design.actions.community.NeedAction;
import com.fr.design.actions.community.QuestionAction;
import com.fr.design.actions.community.SignAction;
@ -24,6 +26,7 @@ import com.fr.design.actions.file.OpenTemplateAction;
import com.fr.design.actions.file.PreferenceAction;
import com.fr.design.actions.file.SwitchExistEnv;
import com.fr.design.actions.help.AboutAction;
import com.fr.design.actions.help.FineUIAction;
import com.fr.design.actions.help.TutorialAction;
import com.fr.design.actions.help.WebDemoAction;
import com.fr.design.actions.help.alphafine.AlphaFineAction;
@ -36,6 +39,7 @@ import com.fr.design.actions.server.PlatformManagerAction;
import com.fr.design.actions.server.PluginManagerAction;
import com.fr.design.file.NewTemplatePane;
import com.fr.design.fun.MenuHandler;
import com.fr.design.fun.OemProcessor;
import com.fr.design.fun.TableDataPaneProcessor;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
@ -54,6 +58,10 @@ import com.fr.design.remote.action.RemoteDesignAuthManagerAction;
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;
import com.fr.plugin.manage.PluginFilter;
@ -62,6 +70,7 @@ import com.fr.plugin.observer.PluginEventListener;
import com.fr.plugin.observer.PluginEventType;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import com.fr.start.OemHandler;
import com.fr.workspace.WorkContext;
import javax.swing.JComponent;
@ -146,7 +155,6 @@ public abstract class ToolBarMenuDock {
}
};
private static final String FINEREPORT = "FineReport";
private static final int MENUBAR_HEIGHT = 22;
private static final List<PluginEventListener> PLUGIN_LISTENERS = new ArrayList<>();
@ -198,6 +206,18 @@ public abstract class ToolBarMenuDock {
};
this.menus = menus(plus);
try {
OemProcessor oemProcessor = OemHandler.findOem();
if (oemProcessor != null) {
this.menus = oemProcessor.dealWithMenuDef(this.menus);
if (this.menus == null) {
this.menus = menus(plus);
}
}
} catch (Throwable e) {
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();
@ -223,7 +243,7 @@ public abstract class ToolBarMenuDock {
public MenuDef[] menus(final ToolBarMenuDockPlus plus) {
//删除之前创建的插件菜单监听
clearPluginListeners();
java.util.List<MenuDef> menuList = new java.util.ArrayList<MenuDef>();
final java.util.List<MenuDef> menuList = new java.util.ArrayList<MenuDef>();
// 添加文件菜单
menuList.add(createFileMenuDef(plus));
@ -241,10 +261,13 @@ public abstract class ToolBarMenuDock {
// 添加帮助菜单
menuList.add(createHelpMenuDef());
if (GeneralContext.getLocale().equals(Locale.CHINA) || GeneralContext.getLocale().equals(Locale.TAIWAN)) {
// 添加社区菜单
addCommunityMenuDef(menuList);
}
LocaleCenter.buildAction(new LocaleAction() {
@Override
public void execute() {
addCommunityMenuDef(menuList);
}
}, SupportLocaleImpl.COMMUNITY);
// 添加全部UpdateAction到actionmanager中
addAllUpdateActionsToList(menuList);
@ -499,9 +522,14 @@ public abstract class ToolBarMenuDock {
if (AlphaFineConfigManager.isALPHALicAvailable()) {
shortCuts.add(new AlphaFineAction());
}
shortCuts.add(SeparatorDef.DEFAULT);
if (DesignerEnvManager.getEnvManager().isOpenDebug()) {
shortCuts.add(new FineUIAction());
}
shortCuts.add(new AboutAction());
return shortCuts.toArray(new ShortCut[shortCuts.size()]);
return shortCuts.toArray(new ShortCut[0]);
}
/**
@ -510,7 +538,7 @@ public abstract class ToolBarMenuDock {
* @return 社区菜单的子菜单
*/
public ShortCut[] createCommunityShortCuts() {
java.util.List<ShortCut> shortCuts = new ArrayList<ShortCut>();
final java.util.List<ShortCut> shortCuts = new ArrayList<ShortCut>();
shortCuts.add(new BBSAction());
shortCuts.add(new VideoAction());
shortCuts.add(new TutorialAction());
@ -521,6 +549,12 @@ public abstract class ToolBarMenuDock {
shortCuts.add(new CusDemandAction());
shortCuts.add(new CenterAction());
shortCuts.add(new SignAction());
LocaleCenter.buildAction(new LocaleAction() {
@Override
public void execute() {
shortCuts.add(new FacebookFansAction());
}
}, SupportLocaleImpl.FACEBOOK);
return shortCuts.toArray(new ShortCut[shortCuts.size()]);
}

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

@ -1,29 +1,46 @@
package com.fr.design.mainframe.toolbar;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.constants.DesignerLaunchStatus;
import com.fr.design.gui.frpane.LoadingBasicPane;
import com.fr.design.utils.concurrent.ThreadFactoryBuilder;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.event.Null;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import javax.swing.JPanel;
import javax.swing.*;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Created by XiaXiang on 2017/4/13.
* 按钮面板管理类
*
* @author XiaXiang
* @date 2017/4/13
*/
public class UpdateActionManager {
private static UpdateActionManager updateActionManager = null;
private List<UpdateActionModel> updateActions;
private ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
1, 2,
30000L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(),
new ThreadFactoryBuilder().setNameFormat("alphafine-thread-%s").build());//目前测下来一个线程慢慢做处理总共大概也只要两秒,暂时就这样
private Map<String, UpdateAction> updateActionsIndexCache = new HashMap<>(16);
private static boolean isRegisterIndexSearchTextTask = false;
/**
* 限制初始化
*/
private UpdateActionManager() {
}
public synchronized static UpdateActionManager getUpdateActionManager() {
if (updateActionManager == null) {
@ -55,22 +72,92 @@ public class UpdateActionManager {
return null;
}
public synchronized void dealWithSearchText(final String paneClass, final UpdateAction updateAction) {
threadPoolExecutor.allowCoreThreadTimeOut(true);
threadPoolExecutor.execute(new Runnable() {
/**
* 处理action的搜索文本
* 缓存逻辑
* 1.首次索引或缓存失效的时候更新版本会使缓存失效会将索引缓存存到env.xml
* 下次直接加载
* 2.需要重新索引则等待设计器初始化完毕之后单线程运行索引任务
*
* @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 {
updateAction.setSearchText(actionSearchTextCache.get(paneClass));
}
}
/**
* 缓存是否有效
* 注意开发工程版本为不是安装版本
* 索引只会出现在首次启动
*
* @return true有效false失效
*/
private boolean cacheValid() {
return ComparatorUtils.equals(GeneralUtils.readBuildNO(), AlphaFineConfigManager.getInstance().getCacheBuildNO());
}
/**
* 由于是UI线程不考虑并发问题
*/
private void registerIndexSearchTextTask() {
if (isRegisterIndexSearchTextTask) {
return;
}
isRegisterIndexSearchTextTask = true;
// 没有缓存或者缓存失效的时候,等待设计器启动之后开始索引任务
EventDispatcher.listen(DesignerLaunchStatus.OPEN_LAST_FILE_COMPLETE, new Listener<Null>() {
@Override
public void run() {
JPanel panel = null;
try {
panel = (JPanel) StableUtils.classForName(paneClass).newInstance();
if (panel instanceof LoadingBasicPane) {
panel = ((LoadingBasicPane) panel).getAllComponents();
}
updateAction.setSearchText(updateAction.getComponentTexts(panel, "_", new StringBuffer(), new StringBuffer(), new StringBuffer()));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
public void on(Event event, Null param) {
// 使用单线程索引
ExecutorService es = Executors.newSingleThreadExecutor(new NamedThreadFactory("IndexAlphaFineSearchText"));
for (Map.Entry<String, UpdateAction> cache : updateActionsIndexCache.entrySet()) {
es.execute(new IndexTask(cache.getKey(), cache.getValue()));
}
updateActionsIndexCache = null;
es.shutdown();
// 标记一下缓存版本
AlphaFineConfigManager.getInstance().setCacheBuildNO(GeneralUtils.readBuildNO());
}
});
}
/**
* 索引任务
*/
class IndexTask implements Runnable {
private String className;
private UpdateAction updateAction;
IndexTask(String className, UpdateAction updateAction) {
this.className = className;
this.updateAction = updateAction;
}
@Override
public void run() {
JPanel panel;
try {
panel = (JPanel) StableUtils.classForName(className).newInstance();
if (panel instanceof LoadingBasicPane) {
panel = ((LoadingBasicPane) panel).getAllComponents();
}
String componentTexts = updateAction.getComponentTexts(panel, "_", new StringBuffer(), new StringBuffer(), new StringBuffer());
updateAction.setSearchText(componentTexts);
AlphaFineConfigManager.getInstance().setActionSearchTextCache(className, componentTexts);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
}

8
designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java

@ -11,10 +11,10 @@ import com.fr.stable.xml.XMLableReader;
public class VcsConfigManager implements XMLReadable, XMLWriter {
public static final String XML_TAG = "VcsConfigManager";
private static volatile VcsConfigManager instance = new VcsConfigManager();
private boolean vcsEnable;
private boolean saveCommit;
private boolean useInterval;
private int saveInterval;
private boolean vcsEnable = true;
private boolean saveCommit = true;
private boolean useInterval = true;
private int saveInterval = 60;
public static VcsConfigManager getInstance() {
return instance;

28
designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java

@ -6,9 +6,11 @@ import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StableUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.resource.WorkResource;
import com.fr.workspace.resource.WorkResourceOutputStream;
import com.fr.workspace.server.lock.TplOperator;
import com.fr.workspace.server.vcs.filesystem.VcsFileSystem;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
@ -29,19 +31,21 @@ public class VcsCacheFileNodeFile extends FileNodeFILE {
* @throws Exception
*/
@Override
public InputStream asInputStream() {
public InputStream asInputStream() throws Exception {
if (node == null) {
return null;
}
String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath();
String envPath = node.getEnvPath();
// envPath必须以vcs开头
if (!envPath.startsWith(VcsHelper.VCS_CACHE_DIR)) {
// envPath必须以VcsCacheRelativePath开头
if (!envPath.startsWith(vcsCacheDir)) {
return null;
}
InputStream in = WorkContext.getCurrent().get(WorkResource.class)
.openStream(StableUtils.pathJoin(VcsHelper.VCS_CACHE_DIR, envPath.substring(VcsHelper.VCS_CACHE_DIR.length() + 1)));
InputStream in = new ByteArrayInputStream(
WorkContext.getCurrent().get(TplOperator.class).readAndLockFile(
StableUtils.pathJoin(vcsCacheDir, envPath.substring(vcsCacheDir.length() + 1))
)
);
return envPath.endsWith(".cpt") || envPath.endsWith(".frm")
? XMLEncryptUtils.decodeInputStream(in) : in;
@ -59,13 +63,13 @@ public class VcsCacheFileNodeFile extends FileNodeFILE {
if (ComparatorUtils.equals(node, null)) {
return null;
}
String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath();
String envPath = node.getEnvPath();
// envPath必须以reportLets开头
if (!envPath.startsWith(VcsHelper.VCS_CACHE_DIR)) {
// envPath必须以VcsCacheRelativePath开头
if (!envPath.startsWith(vcsCacheDir)) {
return null;
}
return new WorkResourceOutputStream(StableUtils.pathJoin(VcsHelper.VCS_CACHE_DIR, envPath.substring(VcsHelper.VCS_CACHE_DIR.length() + 1)));
return new WorkResourceOutputStream(StableUtils.pathJoin(vcsCacheDir, envPath.substring(vcsCacheDir.length() + 1)));
}
}

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

@ -1,5 +1,6 @@
package com.fr.design.mainframe.vcs.common;
import com.fr.cluster.engine.base.FineClusterConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.TemplateTreePane;
@ -7,6 +8,7 @@ import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JTemplateActionListener;
import com.fr.design.mainframe.vcs.VcsConfigManager;
import com.fr.design.mainframe.vcs.ui.FileVersionTable;
import com.fr.general.IOUtils;
@ -17,6 +19,7 @@ import com.fr.stable.StringUtils;
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 javax.swing.Icon;
import javax.swing.border.EmptyBorder;
@ -28,27 +31,13 @@ import static com.fr.stable.StableUtils.pathJoin;
/**
* Created by XiaXiang on 2019/4/17.
*/
public class VcsHelper {
private final static String VCS_DIR = "vcs";
public final static String VCS_CACHE_DIR = pathJoin(VCS_DIR, "cache");
private static final int MINUTE = 60 * 1000;
private final static String VCS_PLUGIN_ID = "com.fr.plugin.vcs.v10";
public final static String CURRENT_USERNAME = WorkContext.getCurrent().isLocal()
? Toolkit.i18nText("Fine-Design_Vcs_Local_User")
: WorkContext.getCurrent().getConnection().getUserName();
public class VcsHelper implements JTemplateActionListener {
public final static Color TABLE_SELECT_BACKGROUND = new Color(0xD8F2FD);
public final static Color COPY_VERSION_BTN_COLOR = new Color(0x419BF9);
public final static EmptyBorder EMPTY_BORDER = new EmptyBorder(10, 10, 0, 10);
public final static EmptyBorder EMPTY_BORDER_MEDIUM = new EmptyBorder(5, 10, 0, 10);
public final static EmptyBorder EMPTY_BORDER_BOTTOM = new EmptyBorder(10, 10, 10, 10);
public final static Icon VCS_LIST_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/vcs_list.png");
public final static Icon VCS_BACK_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/vcs_back.png");
public final static Icon VCS_FILTER_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/icon_filter@1x.png");
@ -56,8 +45,16 @@ public class VcsHelper {
public final static Icon VCS_DELETE_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/icon_delete.png");
public final static Icon VCS_USER_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/icon_user@1x.png");
public final static Icon VCS_REVERT = IOUtils.readIcon("/com/fr/design/images/vcs/icon_revert.png");
public final static int OFFSET = 2;
private static final int MINUTE = 60 * 1000;
private final static String VCS_PLUGIN_ID = "com.fr.plugin.vcs.v10";
private static final VcsHelper instance = new VcsHelper();
public static VcsHelper getInstance() {
return instance;
}
private static int containsFolderCounts() {
private int containsFolderCounts() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) {
return 0;
@ -71,7 +68,13 @@ public class VcsHelper {
return fileTree.getSelectionPaths().length - fileTree.getSelectedTemplatePaths().length;
}
private static int selectedTemplateCounts() {
public String getCurrentUsername() {
return WorkContext.getCurrent().isLocal()
? Toolkit.i18nText("Fine-Design_Vcs_Local_User")
: WorkContext.getCurrent().getConnection().getUserName();
}
private int selectedTemplateCounts() {
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) {
return 0;
@ -80,17 +83,18 @@ public class VcsHelper {
return fileTree.getSelectedTemplatePaths().length;
}
public static boolean isUnSelectedTemplate() {
return VcsHelper.containsFolderCounts() + VcsHelper.selectedTemplateCounts() != 1;
public boolean isUnSelectedTemplate() {
return containsFolderCounts() + selectedTemplateCounts() != 1;
}
public static String getEditingFilename() {
private String getEditingFilename() {
String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath();
JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
String editingFilePath = jt.getEditingFILE().getPath();
if (editingFilePath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
editingFilePath = editingFilePath.replaceFirst(ProjectConstants.REPORTLETS_NAME, StringUtils.EMPTY);
} else if (editingFilePath.startsWith(VcsHelper.VCS_CACHE_DIR)) {
editingFilePath = editingFilePath.replaceFirst(VcsHelper.VCS_CACHE_DIR, StringUtils.EMPTY);
} else if (editingFilePath.startsWith(vcsCacheDir)) {
editingFilePath = editingFilePath.replaceFirst(vcsCacheDir, StringUtils.EMPTY);
}
if (editingFilePath.startsWith("/")) {
editingFilePath = editingFilePath.substring(1);
@ -98,23 +102,28 @@ public class VcsHelper {
return editingFilePath;
}
public static boolean needDeleteVersion(VcsEntity entity) {
if (entity == null || !DesignerEnvManager.getEnvManager().getVcsConfigManager().isUseInterval()) {
private boolean needDeleteVersion(VcsEntity entity) {
VcsConfigManager configManager = DesignerEnvManager.getEnvManager().getVcsConfigManager();
if (entity == null || !configManager.isUseInterval()) {
return false;
}
if (configManager.isSaveCommit() && StringUtils.isNotBlank(entity.getCommitMsg())) {
return false;
}
return new Date().getTime() - entity.getTime().getTime() < DesignerEnvManager.getEnvManager().getVcsConfigManager().getSaveInterval() * MINUTE && StringUtils.isBlank(entity.getCommitMsg());
return new Date().getTime() - entity.getTime().getTime() < DesignerEnvManager.getEnvManager().getVcsConfigManager().getSaveInterval() * MINUTE;
}
public static boolean needInit() {
public boolean needInit() {
PluginContext context = PluginManager.getContext(VCS_PLUGIN_ID);
return context == null || !context.isActive();
return context == null || !context.isRunning();
}
/**
* 版本控制
*
* @param jt
*/
public static void dealWithVcs(final JTemplate jt) {
public void fireVcs(final JTemplate jt) {
new Thread(new Runnable() {
@Override
public void run() {
@ -127,14 +136,14 @@ public class VcsHelper {
latestFileVersion = entity.getVersion();
}
if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) {
operator.saveVersionFromCache(VcsHelper.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1);
operator.saveVersionFromCache(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1);
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath();
FileVersionTable.getInstance().updateModel(1, WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst("/", "")));
} else {
operator.saveVersion(VcsHelper.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1);
operator.saveVersion(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1);
}
VcsEntity oldEntity = WorkContext.getCurrent().get(VcsOperator.class).getFileVersionByIndex(fileName, 1);
if (VcsHelper.needDeleteVersion(oldEntity)) {
VcsEntity oldEntity = WorkContext.getCurrent().get(VcsOperator.class).getFileVersionByIndexAndUsername(fileName, getCurrentUsername(), 1);
if (needDeleteVersion(oldEntity)) {
operator.deleteVersion(oldEntity.getFilename(), oldEntity.getVersion());
}
@ -144,4 +153,25 @@ public class VcsHelper {
}
@Override
public void templateOpened(JTemplate<?, ?> jt) {
}
/**
* 模板保存时 处理.
*
* @param jt 模板
*/
@Override
public void templateSaved(JTemplate<?, ?> jt) {
if (needInit() && DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() && !FineClusterConfig.getInstance().isCluster()) {
fireVcs(jt);
}
}
@Override
public void templateClosed(JTemplate<?, ?> jt) {
}
}

13
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/EditFileVersionDialog.java

@ -7,17 +7,19 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.locale.InterProviderFactory;
import com.fr.report.ReportContext;
import com.fr.log.FineLoggerFactory;
import com.fr.report.entity.VcsEntity;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ -80,8 +82,11 @@ public class EditFileVersionDialog extends UIDialog {
@Override
public void actionPerformed(ActionEvent e) {
entity.setCommitMsg(msgTestArea.getText());
ReportContext.getInstance().getVcsController().saveOrUpdateFileVersion(entity);
WorkContext.getCurrent().get(VcsOperator.class).updateVersion(entity);
setVisible(false);
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath();
FileVersionTable table = FileVersionTable.getInstance();
table.updateModel(table.getSelectedRow(), WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst("/", StringUtils.EMPTY)));
}
});

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

@ -8,6 +8,7 @@ import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.vcs.common.VcsHelper;
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.StringUtils;
import com.fr.workspace.WorkContext;
@ -53,9 +54,13 @@ public class FileVersionCellEditor extends AbstractCellEditor implements TableCe
//先关闭当前打开的模板版本
JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
jt.stopEditing();
MutilTempalteTabPane.getInstance().setIsCloseCurrent(true);
MutilTempalteTabPane.getInstance().closeFormat(jt);
MutilTempalteTabPane.getInstance().closeSpecifiedTemplate(jt);
//只有模板路径一致时关闭当前模板
if (ComparatorUtils.equals(fileOfVersion, jt.getPath())) {
MutilTempalteTabPane.getInstance().setIsCloseCurrent(true);
MutilTempalteTabPane.getInstance().closeFormat(jt);
MutilTempalteTabPane.getInstance().closeSpecifiedTemplate(jt);
}
//再打开cache中的模板
DesignerContext.getDesignerFrame().openTemplate(new VcsCacheFileNodeFile(new FileNode(fileOfVersion, false)));
@ -63,7 +68,7 @@ public class FileVersionCellEditor extends AbstractCellEditor implements TableCe
double height = editor.getPreferredSize().getHeight();
if (table.getRowHeight(row) != height) {
table.setRowHeight(row, (int) height);
table.setRowHeight(row, (int) height + VcsHelper.OFFSET);
}
return editor;
}

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

@ -1,5 +1,6 @@
package com.fr.design.mainframe.vcs.ui;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.report.entity.VcsEntity;
import javax.swing.JPanel;
@ -34,7 +35,7 @@ public class FileVersionCellRender implements TableCellRenderer {
double height = editor.getPreferredSize().getHeight();
if (table.getRowHeight(row) != height) {
table.setRowHeight(row, (int) height);
table.setRowHeight(row, (int) height + VcsHelper.OFFSET);
}
return editor;
}

31
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe.vcs.ui;
import com.fr.analysis.cloud.DateUtils;
import com.fr.design.dialog.UIDialog;
import com.fr.design.editor.editor.DateEditor;
import com.fr.design.gui.date.UIDatePicker;
@ -14,6 +15,7 @@ import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JPanel;
import java.awt.BorderLayout;
@ -45,7 +47,7 @@ public class FileVersionDialog extends UIDialog {
upBox.setBorder(VcsHelper.EMPTY_BORDER);
upBox.add(new UILabel(Toolkit.i18nText("Fine-Design_Vcs_buildTime") + " "));
upBox.add(Box.createHorizontalGlue());
dateEditor = new DateEditor(new Date(), true, StringUtils.EMPTY, UIDatePicker.STYLE_CN_DATE1);
dateEditor = new VcsDateEditor(new Date(), true, StringUtils.EMPTY, UIDatePicker.STYLE_CN_DATE1);
upBox.add(dateEditor);
Box downBox = Box.createHorizontalBox();
downBox.setBorder(VcsHelper.EMPTY_BORDER);
@ -62,8 +64,10 @@ public class FileVersionDialog extends UIDialog {
@Override
public void actionPerformed(ActionEvent e) {
FileVersionDialog.this.setVisible(false);
Date date = dateEditor.getValue();
List<VcsEntity> vcsEntities = WorkContext.getCurrent().get(VcsOperator.class).getFilterVersions(fileName, date, new Date(date.getTime() + DELAY), textField.getText());
Date editorDate = dateEditor.getValue();
Date start = editorDate == null ? new Date(0) : editorDate;
Date end = editorDate == null ? DateUtils.getLastHour() : new Date(start.getTime() + DELAY);
List<VcsEntity> vcsEntities = WorkContext.getCurrent().get(VcsOperator.class).getFilterVersions(fileName, start, end, textField.getText());
FileVersionTable.getInstance().updateModel(1, vcsEntities);
}
@ -74,16 +78,29 @@ public class FileVersionDialog extends UIDialog {
FileVersionDialog.this.setVisible(false);
}
});
VcsLabel resetLabel = new VcsLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Vcs_resetValue"), VcsHelper.COPY_VERSION_BTN_COLOR);
resetLabel.setBorder(BorderFactory.createEmptyBorder(10, 160, 0, 10));
resetLabel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dateEditor.setValue(null);
textField.setText(null);
FileVersionDialog.this.repaint();
}
});
panel.add(upBox, BorderLayout.NORTH);
panel.add(downBox, BorderLayout.CENTER);
panel.add(buttonPane, BorderLayout.SOUTH);
add(panel);
setSize(new Dimension(230, 105));
centerWindow(this);
JPanel filterPane = new JPanel(new BorderLayout());
filterPane.add(resetLabel, BorderLayout.NORTH);
filterPane.add(panel, BorderLayout.CENTER);
add(filterPane);
setSize(new Dimension(230, 125));
centerWindow(frame);
}
private void centerWindow(Window window) {
window.setLocation(0, 95);
this.setLocation(window.getX(), 95);
}

2
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionFirstRowPanel.java

@ -15,7 +15,7 @@ public class FileVersionFirstRowPanel extends JPanel {
super(new BorderLayout());
Box upPane = Box.createVerticalBox();
upPane.setBorder(new EmptyBorder(5, 10, 5, 10));
upPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Local_User")));
upPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Current")));
add(upPane, BorderLayout.CENTER);
}
}

5
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java

@ -43,13 +43,13 @@ public class FileVersionRowPanel extends JPanel {
// version + username
Box upPane = Box.createHorizontalBox();
upPane.setBorder(VcsHelper.EMPTY_BORDER);
upPane.setBorder(VcsHelper.EMPTY_BORDER_MEDIUM);
upPane.add(versionLabel);
upPane.add(Box.createHorizontalGlue());
// msg
msgLabel.setBorder(VcsHelper.EMPTY_BORDER);
msgLabel.setBorder(VcsHelper.EMPTY_BORDER_MEDIUM);
msgLabel.setOpaque(false);
msgLabel.setBackground(new Color(0, 0, 0, 0));
msgLabel.setEditable(false);
@ -63,6 +63,7 @@ public class FileVersionRowPanel extends JPanel {
public void actionPerformed(ActionEvent evt) {
if (JOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Vcs_Version_Revert_Confirm"), Toolkit.i18nText("Fine-Design_Vcs_Version_Revert_Title"),
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
vcsEntity.setUsername(VcsHelper.getInstance().getCurrentUsername());
WorkContext.getCurrent().get(VcsOperator.class).rollbackTo(vcsEntity);
FileVersionsPanel.getInstance().exitVcs(vcsEntity.getFilename());
}

4
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java

@ -19,7 +19,6 @@ import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.menu.ToolBarDef;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
@ -101,7 +100,8 @@ public class FileVersionsPanel extends BasicPane {
}
private void showFilterPane() {
versionDialog = new FileVersionDialog(DesignerContext.getDesignerFrame(), templatePath);
String savePath = templatePath.startsWith("/") ? templatePath.substring(1) : templatePath;
versionDialog = new FileVersionDialog(DesignerContext.getDesignerFrame(), savePath);
versionDialog.setVisible(true);
}

37
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsDateEditor.java

@ -0,0 +1,37 @@
package com.fr.design.mainframe.vcs.ui;
import com.fr.design.editor.editor.DateEditor;
import com.fr.log.FineLoggerFactory;
import java.text.ParseException;
import java.util.Date;
/**
* Created by XiaXiang on 2019/5/14.
*/
public class VcsDateEditor extends DateEditor {
private Date tempValue;
public VcsDateEditor(Date value, boolean format, String name, int dateFormat) {
super(value, format, name, dateFormat);
this.tempValue = value;
}
@Override
public Date getValue() {
if (tempValue == null) {
return null;
}
return super.getValue();
}
@Override
public void setValue(Date value) {
this.tempValue = value;
try {
getUiDatePicker().setSelectedDate(value);
} catch (ParseException parseException) {
FineLoggerFactory.getLogger().error(parseException.getMessage(), parseException);
}
}
}

32
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java

@ -0,0 +1,32 @@
package com.fr.design.mainframe.vcs.ui;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel;
import java.awt.Color;
import java.awt.Graphics;
/**
* Created by XiaXiang on 2019/5/15.
*/
public class VcsLabel extends ActionLabel {
public VcsLabel(String text, Color color) {
super(text);
this.setForeground(color);
}
public void paintComponent(Graphics g) {
if (ui != null) {
Graphics scratchGraphics = (g == null) ? null : g.create();
try {
ui.update(scratchGraphics, this);
}
finally {
scratchGraphics.dispose();
}
}
}
}

37
designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java

@ -2,25 +2,27 @@ package com.fr.design.menu;
import com.fr.design.gui.itoolbar.UIToolBarUI;
import com.fr.design.gui.itoolbar.UIToolbar;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Define toolbar..
*/
public class ToolBarDef {
public class ToolBarDef {
// item List.
private List<ShortCut> shortcutList = new ArrayList<ShortCut>();
/*
/**
* 一个static的方法生成一个JToolBar
*/
public static UIToolbar createJToolBar(final Color background) {
UIToolbar toolbar = new UIToolbar(FlowLayout.LEFT, new UIToolBarUI(){
UIToolbar toolbar = new UIToolbar(FlowLayout.LEFT, new UIToolBarUI() {
@Override
public void paint(Graphics g, JComponent c) {
Graphics2D g2 = (Graphics2D) g;
@ -33,13 +35,13 @@ public class ToolBarDef {
}
/*
/**
* 一个static的方法生成一个JToolBar
*/
public static UIToolbar createJToolBar() {
UIToolbar toolbar = new UIToolbar(FlowLayout.LEFT);
UIToolbar toolbar = new UIToolbar(FlowLayout.LEFT);
toolbar.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
return toolbar;
return toolbar;
}
public ToolBarDef() {
@ -49,31 +51,34 @@ public class ToolBarDef {
return this.shortcutList.size();
}
@Nullable
public ShortCut getShortCut(int index) {
return this.shortcutList.get(index);
}
// 用可变参数,方便添加数组
/**
* 用可变参数方便添加数组
*/
public void addShortCut(ShortCut... shortcut) {
for(ShortCut i : shortcut){
this.shortcutList.add(i);
}
Collections.addAll(this.shortcutList, shortcut);
}
public void clearShortCuts() {
this.shortcutList.clear();
}
/*
/**
* 根据当前的ToolBarDef,更新toolBar
*/
public void updateToolBar(UIToolbar toolBar) {
toolBar.removeAll();
int actionCount = this.getShortCutCount();
for (int i = 0; i < actionCount; i++) {
ShortCut shortcut = this.getShortCut(i);
shortcut.intoJToolBar(toolBar);
ShortCut shortcut = this.getShortCut(i);
if (shortcut != null) {
shortcut.intoJToolBar(toolBar);
}
}
}

4
designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java

@ -16,6 +16,7 @@ import com.fr.design.parameter.ParameterReader;
import com.fr.form.ui.Widget;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import org.jetbrains.annotations.NotNull;
import java.awt.Dialog;
import java.awt.Frame;
@ -65,8 +66,9 @@ public class DesignModuleFactory {
instance.creators4Hyperlink = nameableCreators;
}
@NotNull
public static NameableCreator[] getCreators4Hyperlink() {
return instance.creators4Hyperlink;
return instance.creators4Hyperlink == null? new NameableCreator[0]:instance.creators4Hyperlink;
}
public static void registerExtraWidgetOptions(WidgetOption[] options) {

28
designer-base/src/main/java/com/fr/design/roleAuthority/ReportAndFSManagePane.java

@ -11,18 +11,29 @@ import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignAuthorityEventType;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.DockingView;
import com.fr.design.menu.ToolBarDef;
import javax.swing.*;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTree;
import javax.swing.ScrollPaneConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.tree.DefaultTreeSelectionModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@ -40,6 +51,15 @@ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSo
private static ReportAndFSManagePane singleton = new ReportAndFSManagePane();
private static RoleTree roleTree;
static {
EventDispatcher.listen(DesignAuthorityEventType.StopEdit, new Listener<DesignerFrame>() {
public void on(Event event, DesignerFrame param) {
DefaultTreeSelectionModel model = roleTree.getCheckBoxTreeSelectionModel();
model.removeSelectionPaths(model.getSelectionPaths());
}
});
}
private RefreshAction refreshAction = new RefreshAction();
private UIHeadGroup buttonGroup;
private RoleSourceOP op;

2
designer-base/src/main/java/com/fr/design/style/background/image/ImagePreviewPane.java

@ -63,7 +63,7 @@ public class ImagePreviewPane extends JComponent implements Scrollable, ImagePre
@Override
public void setImage(Image image) {
setImageWithSuffix(image == null ? null : new ImageWithSuffix(image));
setImageWithSuffix(ImageWithSuffix.build(image));
}

17
designer-base/src/main/java/com/fr/design/ui/Assistant.java

@ -6,8 +6,14 @@ import com.teamdev.jxbrowser.chromium.BrowserContext;
import com.teamdev.jxbrowser.chromium.ProtocolService;
import com.teamdev.jxbrowser.chromium.URLResponse;
import javax.activation.MimetypesFileTypeMap;
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
* @author richie
@ -41,7 +47,15 @@ public class Assistant {
if (path.endsWith(".js")) {
return "text/javascript";
}
return "text/html";
if (path.endsWith(".svg")) {
return "image/svg+xml";
}
Path file = new File(path).toPath();
try {
return Files.probeContentType(file);
} catch (IOException e) {
return "text/html";
}
}
public static void setEmbProtocolHandler(Browser browser, EmbProtocolHandler handler) {
@ -49,5 +63,6 @@ public class Assistant {
ProtocolService protocolService = browserContext.getProtocolService();
// 支持读取jar包中文件的自定义协议————emb:/com/fr/design/images/bbs.png
protocolService.setProtocolHandler("emb", handler);
protocolService.setProtocolHandler("file", handler);
}
}

61
designer-base/src/main/java/com/fr/design/ui/EmbProtocolHandler.java

@ -1,7 +1,13 @@
package com.fr.design.ui;
import com.fr.base.TemplateUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.codec.net.URLCodec;
import com.fr.third.org.apache.commons.io.FileUtils;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.web.struct.AssembleComponent;
import com.fr.web.struct.AtomBuilder;
import com.fr.web.struct.PathGroup;
@ -11,7 +17,15 @@ import com.teamdev.jxbrowser.chromium.ProtocolHandler;
import com.teamdev.jxbrowser.chromium.URLRequest;
import com.teamdev.jxbrowser.chromium.URLResponse;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Map;
/**
* @author richie
@ -21,6 +35,7 @@ import java.io.InputStream;
public class EmbProtocolHandler implements ProtocolHandler {
private AssembleComponent component;
private Map<String, String> map;
public EmbProtocolHandler() {
@ -30,33 +45,58 @@ public class EmbProtocolHandler implements ProtocolHandler {
this.component = component;
}
public EmbProtocolHandler(AssembleComponent component, Map<String, String> map) {
this.component = component;
this.map = map;
}
public EmbProtocolHandler(Map<String, String> map) {
this.map = map;
}
@Override
public URLResponse onRequest(URLRequest req) {
InputStream inputStream = null;
try {
String path = req.getURL();
if (path.startsWith("emb:dynamic")) {
if (path.startsWith("file:")) {
String url = new URLCodec().decode(path);
String filePath = TemplateUtils.renderParameter4Tpl(url, map);
File file = new File(URI.create(filePath).getPath());
inputStream = IOUtils.readResource(file.getAbsolutePath());
String text = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8);
text = TemplateUtils.renderParameter4Tpl(text, map);
return Assistant.inputStream2Response(new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)), path);
} else if (path.startsWith("emb:dynamic")) {
URLResponse response = new URLResponse();
response.setData(htmlText().getBytes());
response.setData(htmlText(map).getBytes());
response.getHeaders().setHeader("Content-Type", "text/html");
return response;
} else {
} else {
int index = path.indexOf("=");
if (index > 0) {
path = path.substring(index + 1);
} else {
path = path.substring(4);
}
InputStream inputStream = IOUtils.readResource(path);
inputStream = IOUtils.readResource(path);
return Assistant.inputStream2Response(inputStream, path);
}
} catch (Exception ignore) {
} catch (Exception e) {
FineLoggerFactory.getLogger().info(e.getMessage());
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
return null;
}
private String htmlText() {
private String htmlText(Map<String, String> map) {
PathGroup pathGroup = AtomBuilder.create().buildAssembleFilePath(ModernRequestClient.KEY, component);
StylePath[] stylePaths = pathGroup.toStylePathGroup();
StringBuilder styleText = new StringBuilder();
@ -78,6 +118,13 @@ public class EmbProtocolHandler implements ProtocolHandler {
}
}
result = result.replaceAll("##script##", scriptText.toString());
if (map != null) {
for (Map.Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
result = result.replaceAll("\\$\\{" + key + "}", value);
}
}
return result;
}
}

101
designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java

@ -2,6 +2,10 @@ package com.fr.design.ui;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.web.struct.AssembleComponent;
import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.BrowserPreferences;
@ -14,8 +18,11 @@ import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent;
import com.teamdev.jxbrowser.chromium.events.ScriptContextListener;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;
import javax.swing.JSplitPane;
import java.awt.BorderLayout;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Map;
/**
* @author richie
@ -39,17 +46,38 @@ public class ModernUIPane<T> extends BasicPane {
setLayout(new BorderLayout());
BrowserPreferences.setChromiumSwitches("--disable-google-traffic");
if (DesignerEnvManager.getEnvManager().isOpenDebug()) {
JSplitPane splitPane = new JSplitPane();
add(splitPane, BorderLayout.CENTER);
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
splitPane.setDividerLocation(500);
UIToolbar toolbar = new UIToolbar();
add(toolbar, BorderLayout.NORTH);
UIButton openDebugButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Open_Debug_Window"));
toolbar.add(openDebugButton);
UIButton reloadButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Reload"));
toolbar.add(reloadButton);
UIButton closeButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Close_Window"));
toolbar.add(closeButton);
openDebugButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
showDebuggerDialog();
}
});
reloadButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
browser.reloadIgnoringCache();
}
});
closeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SwingUtilities.getWindowAncestor(ModernUIPane.this).setVisible(false);
}
});
BrowserPreferences.setChromiumSwitches("--remote-debugging-port=9222");
initializeBrowser();
splitPane.setLeftComponent(new BrowserView(browser));
Browser debugger = new Browser();
debugger.loadURL(browser.getRemoteDebuggingURL());
BrowserView debuggerView = new BrowserView(debugger);
splitPane.setRightComponent(debuggerView);
add(new BrowserView(browser), BorderLayout.CENTER);
} else {
initializeBrowser();
add(new BrowserView(browser), BorderLayout.CENTER);
@ -57,6 +85,18 @@ public class ModernUIPane<T> extends BasicPane {
}
}
private void showDebuggerDialog() {
JDialog dialog = new JDialog(SwingUtilities.getWindowAncestor(this));
Browser debugger = new Browser();
BrowserView debuggerView = new BrowserView(debugger);
dialog.add(debuggerView, BorderLayout.CENTER);
dialog.setSize(new Dimension(800, 400));
GUICoreUtils.centerWindow(dialog);
dialog.setVisible(true);
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
debugger.loadURL(browser.getRemoteDebuggingURL());
}
private void initializeBrowser() {
browser = new Browser();
// 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的
@ -68,6 +108,24 @@ public class ModernUIPane<T> extends BasicPane {
});
}
/**
* 转向一个新的地址相当于重新加载
* @param url 新的地址
*/
public void redirect(String url) {
browser.loadURL(url);
}
/**
* 转向一个新的地址相当于重新加载
* @param url 新的地址
* @param map 初始化参数
*/
public void redirect(String url, Map<String, String> map) {
Assistant.setEmbProtocolHandler(browser, new EmbProtocolHandler(map));
browser.loadURL(url);
}
@Override
protected String title4PopupWindow() {
return "Modern";
@ -126,6 +184,16 @@ public class ModernUIPane<T> extends BasicPane {
return this;
}
/**
* 加载url指向的资源
* @param url 文件的地址
*/
public Builder<T> withURL(final String url, Map<String, String> map) {
Assistant.setEmbProtocolHandler(pane.browser, new EmbProtocolHandler(map));
pane.browser.loadURL(url);
return this;
}
/**
* 加载Atom组件
* @param component Atom组件
@ -136,6 +204,17 @@ public class ModernUIPane<T> extends BasicPane {
return this;
}
/**
* 加载Atom组件
* @param component Atom组件
*/
public Builder<T> withComponent(AssembleComponent component, Map<String, String> map) {
Assistant.setEmbProtocolHandler(pane.browser, new EmbProtocolHandler(component, map));
pane.browser.loadURL("emb:dynamic");
return this;
}
/**
* 加载html文本内容
* @param html 要加载html文本内容

1
designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateDialog.java

@ -37,6 +37,7 @@ class DesignerPushUpdateDialog extends UIDialog {
static void createAndShow(final Frame parent, final DesignerUpdateInfo updateInfo) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
DesignerPushUpdateDialog dialog = new DesignerPushUpdateDialog(parent);
dialog.populate(updateInfo);

16
designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java

@ -1,5 +1,6 @@
package com.fr.design.update.push;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.event.DesignerOpenedListener;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
@ -13,12 +14,17 @@ import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Created by plough on 2019/4/8.
*/
public class DesignerPushUpdateManager {
private static final String SPLIT_CHAR = "-";
private static DesignerPushUpdateManager singleton;
private final ExecutorService checkUpdateService = Executors.newSingleThreadExecutor(new NamedThreadFactory("DesignerCheckUpdate"));
private final ExecutorService updateService = Executors.newSingleThreadExecutor(new NamedThreadFactory("DesignerUpdate"));
private DesignerUpdateInfo updateInfo;
@ -94,7 +100,7 @@ public class DesignerPushUpdateManager {
* 检查更新如果有合适的更新版本则弹窗
*/
private void checkAndPop() {
new Thread() {
checkUpdateService.execute(new Runnable() {
@Override
public void run() {
if (!shouldPopUp()) {
@ -104,7 +110,8 @@ public class DesignerPushUpdateManager {
final DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
DesignerPushUpdateDialog.createAndShow(designerFrame, updateInfo);
}
}.start();
});
checkUpdateService.shutdown();
}
private boolean shouldPopUp() {
@ -146,14 +153,15 @@ public class DesignerPushUpdateManager {
* 跳转到更新升级窗口并自动开始更新
*/
void doUpdate() {
new Thread() {
updateService.execute(new Runnable() {
@Override
public void run() {
UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame());
dialog.setAutoUpdateAfterInit();
dialog.showDialog();
}
}.start();
});
updateService.shutdown();
}
/**

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

@ -1,6 +1,5 @@
package com.fr.design.update.ui.dialog;
import com.fr.base.FRContext;
import com.fr.design.RestartHelper;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
@ -8,6 +7,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.update.domain.UpdateConstants;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
@ -175,8 +175,8 @@ public class RestoreResultDialog extends JDialog {
String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR;
for (String file : files) {
map.put(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, file),
StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, FRContext.getCommonOperator().getAppName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file));
list.add(StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, FRContext.getCommonOperator().getAppName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, 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));
}
}
}

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

@ -1,6 +1,5 @@
package com.fr.design.update.ui.dialog;
import com.fr.base.FRContext;
import com.fr.design.RestartHelper;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.dialog.UIDialog;
@ -23,6 +22,7 @@ import com.fr.design.update.ui.widget.UpdateInfoTableCellRender;
import com.fr.design.update.ui.widget.UpdateInfoTableModel;
import com.fr.design.update.ui.widget.UpdateInfoTextAreaCellRender;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils;
import com.fr.general.DateUtils;
import com.fr.general.GeneralContext;
@ -30,6 +30,7 @@ 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;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
@ -38,6 +39,7 @@ 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;
@ -372,9 +374,7 @@ public class UpdateMainDialog extends UIDialog {
new SwingWorker<JSONObject, Void>() {
@Override
protected JSONObject doInBackground() throws Exception {
HttpClient hc = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("jar10.update"));
hc.setTimeout(UpdateConstants.CONNECTION_TIMEOUT);
return new JSONObject(hc.getResponseText());
return new JSONObject(HttpToolbox.get(CloudCenter.getInstance().acquireUrlByKind("jar10.update")));
}
@Override
@ -621,8 +621,11 @@ public class UpdateMainDialog extends UIDialog {
long downloadSize = jo.optLong("size");
if (ComparatorUtils.equals(category, "server")) {
File currentJAR = new File(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), ProjectConstants.LIB_NAME, downloadName));
if (currentJAR.exists() && ComparatorUtils.equals(currentJAR.length(), downloadSize)) {
//假如大小一样的jar包就不要下载了
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;
}
}
@ -631,6 +634,31 @@ public class UpdateMainDialog extends UIDialog {
}
}
/**
* 获取当前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;
}
/**
* jar包更新按钮监听器
*/
@ -707,7 +735,7 @@ public class UpdateMainDialog extends UIDialog {
for (String file : files) {
try {
IOUtils.copy(
new File(StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, FRContext.getCommonOperator().getAppName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)),
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());
@ -748,8 +776,8 @@ public class UpdateMainDialog extends UIDialog {
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, FRContext.getCommonOperator().getAppName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file));
list.add(StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, FRContext.getCommonOperator().getAppName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, 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));
}
}

468
designer-base/src/main/java/com/fr/design/upm/UpmBridge.java

@ -0,0 +1,468 @@
package com.fr.design.upm;
import com.fr.base.passport.FinePassportManager;
import com.fr.config.MarketConfig;
import com.fr.config.ServerPreferenceConfig;
import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoader;
import com.fr.design.bridge.exec.JSBridge;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.extra.PluginOperateUtils;
import com.fr.design.extra.PluginUtils;
import com.fr.design.extra.exe.GetInstalledPluginsExecutor;
import com.fr.design.extra.exe.GetPluginCategoriesExecutor;
import com.fr.design.extra.exe.GetPluginFromStoreExecutor;
import com.fr.design.extra.exe.GetPluginPrefixExecutor;
import com.fr.design.extra.exe.PluginLoginExecutor;
import com.fr.design.extra.exe.ReadUpdateOnlineExecutor;
import com.fr.design.extra.exe.SearchOnlineExecutor;
import com.fr.design.i18n.Toolkit;
import com.fr.design.upm.event.CertificateEvent;
import com.fr.design.upm.event.DownloadEvent;
import com.fr.design.upm.exec.UpmBrowserExecutor;
import com.fr.design.upm.task.UpmTaskWorker;
import com.fr.event.EventDispatcher;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralUtils;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginMarker;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.JSArray;
import com.teamdev.jxbrowser.chromium.JSFunction;
import com.teamdev.jxbrowser.chromium.JSObject;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.*;
import java.io.File;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
import java.util.concurrent.RunnableFuture;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-04-12
* 桥接Java和JavaScript的类
*/
public class UpmBridge {
public static UpmBridge getBridge(Browser browser) {
return new UpmBridge(browser);
}
private JSObject window;
private UpmBridge(Browser browser) {
this.window = browser.executeJavaScriptAndReturnValue("window").asObject();
}
/**
* 更新插件管理中心资源文件这个方法仅仅是为了语义上的作用更新
* @param callback 安装完成后的回调函数
*/
@JSBridge
public void update(final JSFunction callback) {
callback.invoke(window, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start"));
try {
UpmResourceLoader.INSTANCE.download();
UpmResourceLoader.INSTANCE.install();
callback.invoke(window, "success", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Success"));
EventDispatcher.fire(DownloadEvent.UPDATE, "success");
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
callback.invoke(window, "error", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Error"));
}
}
/**
* 下载并安装插件管理中心的资源文件
* @param callback 安装完成后的回调函数
*/
@JSBridge
public void startDownload(final JSFunction callback) {
callback.invoke(window, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start"));
new SwingWorker<Void, Void>(){
@Override
protected Void doInBackground() throws Exception {
UpmResourceLoader.INSTANCE.download();
UpmResourceLoader.INSTANCE.install();
return null;
}
@Override
protected void done() {
try {
get();
callback.invoke(window, "success", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Success"));
EventDispatcher.fire(DownloadEvent.SUCCESS, "success");
} catch (Exception e) {
callback.invoke(window, "error", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Error"));
FineLoggerFactory.getLogger().error(e.getMessage(), e);
EventDispatcher.fire(DownloadEvent.ERROR, "error");
}
}
}.execute();
}
/**
* 获取upm的版本信息
* @return 版本信息
*/
@JSBridge
public String getVersion() {
return ServerPreferenceConfig.getInstance().getOptimizedUPMVersion();
}
@JSBridge
public String i18nText(String key) {
return Toolkit.i18nText(key);
}
@JSBridge
public void closeWindow() {
UpmFinder.closeWindow();
}
@JSBridge
public boolean isDesigner() {
return true;
}
@JSBridge
public void getPackInfo(final JSFunction callback) {
callback.invoke(window, StringUtils.EMPTY);
}
@JSBridge
public void getPluginPrefix(final JSFunction callback) {
UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new GetPluginPrefixExecutor());
task.execute();
}
/**
* 在线获取插件分类
*
* @param callback 回调函数
*/
@JSBridge
public void getPluginCategories(final JSFunction callback) {
UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new GetPluginCategoriesExecutor());
task.execute();
}
/**
* 根据条件获取在线插件
*
* @param info 插件信息
* @param callback 回调函数
*/
@JSBridge
public void getPluginFromStoreNew(String info, final JSFunction callback) {
UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new GetPluginFromStoreExecutor(new JSONObject(info)));
task.execute();
}
/**
* 已安装插件检查更新
*/
@JSBridge
public void readUpdateOnline(final JSFunction callback) {
UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new ReadUpdateOnlineExecutor());
task.execute();
}
/**
* 获取已经安装的插件的数组
*/
@JSBridge
public void getInstalledPlugins(final JSFunction callback) {
UpmTaskWorker<Void> task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new GetInstalledPluginsExecutor());
task.execute();
}
/**
* 从插件服务器上更新选中的插件
*
* @param pluginIDs 插件集合
*/
@JSBridge
public void updatePluginOnline(Object pluginIDs, final JSFunction callback) {
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback));
List<PluginMarker> pluginMarkerList = new ArrayList<>();
if (pluginIDs instanceof String) {
pluginMarkerList.add(PluginUtils.createPluginMarker(pluginIDs.toString()));
} else if (pluginIDs instanceof JSArray) {
JSArray pluginInfos = (JSArray) pluginIDs;
for (int i = 0, len = pluginInfos.length(); i < len; i++) {
String value = pluginInfos.get(i).asString().getValue();
pluginMarkerList.add(PluginUtils.createPluginMarker(value));
}
}
PluginOperateUtils.updatePluginOnline(pluginMarkerList, jsCallback);
}
/**
* 搜索在线插件
*
* @param keyword 关键字
*/
@JSBridge
public void searchPlugin(String keyword, final JSFunction callback) {
UpmTaskWorker<Void> worker = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new SearchOnlineExecutor(keyword));
worker.execute();
}
/**
* 从磁盘上选择插件安装包进行安装
*
* @param filePath 插件包的路径
*/
@JSBridge
public void installPluginFromDisk(final String filePath, final JSFunction callback) {
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback));
File file = new File(filePath);
PluginOperateUtils.installPluginFromDisk(file, jsCallback);
}
/**
* 卸载当前选中的插件
*
* @param pluginInfo 插件信息
*/
@JSBridge
public void uninstallPlugin(final String pluginInfo, final boolean isForce, final JSFunction callback) {
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback));
PluginOperateUtils.uninstallPlugin(pluginInfo, isForce, jsCallback);
}
/**
* 从插件服务器上安装插件
*
* @param pluginInfo 插件的ID
* @param callback 回调函数
*/
@JSBridge
public void installPluginOnline(final String pluginInfo, final JSFunction callback) {
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback));
PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo);
PluginOperateUtils.installPluginOnline(pluginMarker, jsCallback);
}
/**
* 从磁盘上选择插件安装包进行插件升级
*
* @param filePath 插件包的路径
*/
public void updatePluginFromDisk(String filePath, final JSFunction callback) {
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback));
File file = new File(filePath);
PluginOperateUtils.updatePluginFromDisk(file, jsCallback);
}
/**
* 修改选中的插件的活跃状态
*
* @param pluginID 插件ID
*/
@JSBridge
public void setPluginActive(String pluginID, final JSFunction callback) {
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback));
PluginOperateUtils.setPluginActive(pluginID, jsCallback);
}
/**
* 选择文件对话框
*
* @return 选择的文件的路径
*/
@JSBridge
public String showFileChooser() {
return showFileChooserWithFilter(StringUtils.EMPTY, StringUtils.EMPTY);
}
/**
* 选择文件对话框
*
* @param des 过滤文件描述
* @param filter 文件的后缀
* @return 选择的文件的路径
* 这里换用JFileChooser会卡死,不知道为什么
*/
@JSBridge
public String showFileChooserWithFilter(final String des, final String filter) {
RunnableFuture<String> future = new FutureTask<>(new Callable<String>() {
@Override
public String call() {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
if (StringUtils.isNotEmpty(filter)) {
fileChooser.setFileFilter(new FileNameExtensionFilter(des, UpmUtils.findMatchedExtension(filter)));
}
int result = fileChooser.showOpenDialog(UpmFinder.getDialog());
if (result == JFileChooser.APPROVE_OPTION) {
return fileChooser.getSelectedFile().getAbsolutePath();
}
return null;
}
});
SwingUtilities.invokeLater(future);
try {
return future.get();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return null;
}
/**
* 选择文件对话框
*
* @param des 过滤文件描述
* @param args 文件的后缀
* @return 选择的文件的路径
*/
@JSBridge
public String showFileChooserWithFilters(final String des, final Object args) {
RunnableFuture<String> future = new FutureTask<>(new Callable<String>() {
@Override
public String call() {
JFileChooser fileChooser = new JFileChooser();
List<String> filterList = new ArrayList<>();
if (args instanceof String) {
filterList.add(GeneralUtils.objectToString(args));
} else if (args instanceof JSArray) {
JSArray array = (JSArray)args;
for (int i = 0, len = array.length(); i < len; i ++) {
filterList.add(array.get(i).getStringValue());
}
}
String[] filters = filterList.toArray(new String[0]);
if (ArrayUtils.isNotEmpty(filters)) {
FileNameExtensionFilter filter = new FileNameExtensionFilter(des, UpmUtils.findMatchedExtension(filters));
fileChooser.setFileFilter(filter);
}
int result = fileChooser.showOpenDialog(UpmFinder.getDialog());
if (result == JFileChooser.APPROVE_OPTION) {
return fileChooser.getSelectedFile().getAbsolutePath();
}
return null;
}
});
SwingUtilities.invokeLater(future);
try {
return future.get();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return null;
}
////////登录相关///////
/**
* 获取系统登录的用户名
*/
@JSBridge
public String getLoginInfo(final JSFunction callback) {
registerLoginInfo(callback);
return MarketConfig.getInstance().getBbsUsername();
}
/**
* 系统登录注册
*
* @param callback 回调函数
*/
@JSBridge
public void registerLoginInfo(final JSFunction callback) {
JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback));
String username = MarketConfig.getInstance().getBbsUsername();
if (StringUtils.isEmpty(username)) {
jsCallback.execute(StringUtils.EMPTY);
EventDispatcher.fire(CertificateEvent.LOGOUT, StringUtils.EMPTY);
} else {
jsCallback.execute(username);
EventDispatcher.fire(CertificateEvent.LOGIN, username);
}
}
/**
* 设计器端的用户登录
*
* @param username 用户名
* @param password 密码
* @param callback 回调函数
*/
@JSBridge
public void defaultLogin(String username, String password, final JSFunction callback) {
UpmTaskWorker<Void> worker = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new PluginLoginExecutor(username, password));
worker.execute();
}
/**
* 清除用户信息
*/
public void clearUserInfo() {
MarketConfig.getInstance().setInShowBBsName(StringUtils.EMPTY);
FinePassportManager.getInstance().logout();
EventDispatcher.fire(CertificateEvent.LOGOUT, StringUtils.EMPTY);
}
/**
* 打开论坛消息界面
*/
@JSBridge
public void getPriviteMessage() {
try {
String loginUrl = CloudCenter.getInstance().acquireUrlByKind("bbs.default");
Desktop.getDesktop().browse(new URI(loginUrl));
} catch (Exception exp) {
FineLoggerFactory.getLogger().info(exp.getMessage());
}
}
/**
* 忘记密码
*/
@JSBridge
public void forgetHref() {
try {
Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind("bbs.reset")));
} catch (Exception e) {
FineLoggerFactory.getLogger().info(e.getMessage());
}
}
/**
* 使用系统浏览器打开网页
* @param url 要打开的网页
*/
@JSBridge
public void openShopUrlAtWebBrowser(String url) {
if (Desktop.isDesktopSupported()) {
try {
//创建一个URI实例,注意不是URL
URI uri = URI.create(url);
//获取当前系统桌面扩展
Desktop desktop = Desktop.getDesktop();
//判断系统桌面是否支持要执行的功能
if (desktop.isSupported(Desktop.Action.BROWSE)) {
//获取系统默认浏览器打开链接
desktop.browse(uri);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
}

68
designer-base/src/main/java/com/fr/design/upm/UpmFinder.java

@ -0,0 +1,68 @@
package com.fr.design.upm;
import com.fr.base.FRContext;
import com.fr.design.dialog.UIDialog;
import com.fr.design.mainframe.DesignerContext;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.stable.StableUtils;
import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent;
import javax.swing.*;
import java.io.File;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-04-12
*/
public class UpmFinder {
private static final String UPM_DIR = "/upm";
private static final String MAIN_RESOURCE_PATH = UPM_DIR + "/plugin_design.html";
public static String installHome = FRContext.getCommonOperator().getWebRootPath();
private static UIDialog dialog = null;
static {
EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener<Workspace>() {
@Override
public void on(Event event, Workspace param) {
installHome = FRContext.getCommonOperator().getWebRootPath();
}
});
}
public static boolean checkUPMResourcesExist() {
String mainJsPath = StableUtils.pathJoin(installHome, MAIN_RESOURCE_PATH);
File file = new File(mainJsPath);
return file.exists();
}
public static String getMainResourcePath() {
return "file:///" + StableUtils.pathJoin(installHome, MAIN_RESOURCE_PATH);
}
public static UIDialog getDialog() {
return dialog;
}
public static void showUPMDialog() {
UpmShowPane upmPane = new UpmShowPane();
if (dialog == null) {
dialog = new UpmShowDialog(DesignerContext.getDesignerFrame(), upmPane);
}
dialog.setVisible(true);
}
public static void closeWindow() {
if (dialog != null) {
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
dialog.setVisible(false);
dialog = null;
}
}
}

34
designer-base/src/main/java/com/fr/design/upm/UpmShowDialog.java

@ -0,0 +1,34 @@
package com.fr.design.upm;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StableUtils;
import javax.swing.*;
import java.awt.*;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-04-12
*/
public class UpmShowDialog extends UIDialog {
private static final Dimension DEFAULT_SHOP = new Dimension(900, 700);
public UpmShowDialog(Frame frame, BasicPane pane) {
super(frame);
setUndecorated(true);
JPanel panel = (JPanel) getContentPane();
panel.setLayout(new BorderLayout());
add(pane, BorderLayout.CENTER);
setSize(DEFAULT_SHOP);
GUICoreUtils.centerWindow(this);
setResizable(false);
}
@Override
public void checkValid() throws Exception {
}
}

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

Loading…
Cancel
Save