Browse Source

Merge branch 'feature/big-screen' of ssh://code.fineres.com:7999/~zheng/C-design into feature/big-screen

feature/10.0
shine 3 years ago
parent
commit
6b6a790aee
  1. 8
      build.gradle
  2. 97
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  3. 18
      designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java
  4. 2
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  5. 448
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java
  6. 116
      designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java
  7. 12
      designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java
  8. 251
      designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java
  9. 2
      designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java
  10. 15
      designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java
  11. 13
      designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java
  12. 7
      designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java
  13. 3
      designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneProvider.java
  14. 7
      designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java
  15. 7
      designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java
  16. 87
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java
  17. 1
      designer-base/src/main/java/com/fr/design/gui/itextfield/UIIntNumberField.java
  18. 104
      designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java
  19. 453
      designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java
  20. 19
      designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java
  21. 8
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  22. 4
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  23. 14
      designer-base/src/main/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfo.java
  24. 15
      designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java
  25. 9
      designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java
  26. 44
      designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java
  27. 16
      designer-base/src/main/java/com/fr/design/ui/compatible/NxComplexInterceptRequestCallback.java
  28. 34
      designer-base/src/main/java/com/fr/design/ui/compatible/NxInterceptRequestCallback.java
  29. 3
      designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java
  30. 30
      designer-base/src/main/java/com/fr/env/HelpLink.java
  31. 36
      designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java
  32. 48
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  33. 16
      designer-base/src/main/java/com/fr/env/handler/Handler.java
  34. 28
      designer-base/src/main/java/com/fr/env/handler/RefWrapper.java
  35. 90
      designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java
  36. 30
      designer-base/src/main/java/com/fr/env/handler/ResultWrapper.java
  37. 22
      designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java
  38. 52
      designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java
  39. 23
      designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java
  40. 26
      designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java
  41. 1
      designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties
  42. 1
      designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties
  43. 1
      designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties
  44. 1
      designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties
  45. 1
      designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties
  46. 21
      designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java
  47. 204
      designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java
  48. 10
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java
  49. 17
      designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java
  50. 4
      designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java
  51. 7
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  52. 3
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  53. 65
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  54. 41
      designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java
  55. 7
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  56. 60
      designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java
  57. 14
      designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java
  58. 27
      designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/AbstractMultiSelectionArrangementButton.java
  59. 1
      designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/BottomAlignButton.java
  60. 1
      designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalCenterButton.java
  61. 1
      designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalDistributionButton.java
  62. 1
      designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/LeftAlignButton.java
  63. 4
      designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/MultiSelectionArrangementButton.java
  64. 1
      designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/RightAlignButton.java
  65. 1
      designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/TopAlignButton.java
  66. 1
      designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalCenterButton.java
  67. 1
      designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalDistributionButton.java
  68. 86
      designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java
  69. 948
      designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java
  70. 26
      designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java
  71. 10
      designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java
  72. 8
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  73. 13
      designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java
  74. 1175
      designer-realize/src/main/java/com/fr/design/webattr/EditToolBar.java
  75. 3
      designer-realize/src/main/java/com/fr/design/widget/CellWidgetCardPane.java
  76. 50
      designer-realize/src/main/java/com/fr/design/widget/WidgetEventPane.java
  77. 17
      designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java

8
build.gradle

@ -60,10 +60,10 @@ allprojects {
implementation 'com.fr.third:jxbrowser:6.23' implementation 'com.fr.third:jxbrowser:6.23'
implementation 'com.fr.third:jxbrowser-mac:6.23' implementation 'com.fr.third:jxbrowser-mac:6.23'
implementation 'com.fr.third:jxbrowser-win64:6.23' implementation 'com.fr.third:jxbrowser-win64:6.23'
implementation 'com.fr.third:jxbrowser-v7:7.7' implementation 'com.fr.third:jxbrowser-v7:7.15'
implementation 'com.fr.third:jxbrowser-mac-v7:7.7' implementation 'com.fr.third:jxbrowser-mac-v7:7.15'
implementation 'com.fr.third:jxbrowser-win64-v7:7.7' implementation 'com.fr.third:jxbrowser-win64-v7:7.15'
implementation 'com.fr.third:jxbrowser-swing-v7:7.7' implementation 'com.fr.third:jxbrowser-swing-v7:7.15'
implementation 'com.fr.third.server:servlet-api:3.0' implementation 'com.fr.third.server:servlet-api:3.0'
implementation 'org.swingexplorer:swexpl:2.0.1' implementation 'org.swingexplorer:swexpl:2.0.1'
implementation 'org.swingexplorer:swag:1.0' implementation 'org.swingexplorer:swag:1.0'

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

@ -6,7 +6,6 @@ import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.DesignerWorkspaceType;
@ -21,14 +20,11 @@ import com.fr.design.notification.NotificationCenter;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.design.versioncheck.VersionCheckUtils;
import com.fr.env.EnvListPane; import com.fr.env.EnvListPane;
import com.fr.env.RemoteWorkspaceURL; import com.fr.env.handler.RemoteDesignExceptionHandler;
import com.fr.env.TestConnectionResult;
import com.fr.exit.DesignerExiter; import com.fr.exit.DesignerExiter;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.license.exception.RegistEditionException;
import com.fr.locale.InterProviderFactory; import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.process.ProcessEventPipe; import com.fr.process.ProcessEventPipe;
@ -46,8 +42,6 @@ import com.fr.workspace.base.WorkspaceAPI;
import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.base.FineObjectPool; import com.fr.workspace.engine.base.FineObjectPool;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import com.fr.workspace.engine.exception.WorkspaceAuthException;
import com.fr.workspace.engine.exception.WorkspaceCheckException;
import com.fr.workspace.engine.exception.WorkspaceConnectionException; import com.fr.workspace.engine.exception.WorkspaceConnectionException;
import com.fr.workspace.engine.rpc.WorkspaceProxyPool; import com.fr.workspace.engine.rpc.WorkspaceProxyPool;
@ -66,7 +60,6 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.HashSet; import java.util.HashSet;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
import static javax.swing.JOptionPane.QUESTION_MESSAGE; import static javax.swing.JOptionPane.QUESTION_MESSAGE;
public class EnvChangeEntrance { public class EnvChangeEntrance {
@ -79,6 +72,8 @@ public class EnvChangeEntrance {
private static EnvChangeEntrance singleton = new EnvChangeEntrance(); private static EnvChangeEntrance singleton = new EnvChangeEntrance();
} }
private BasicDialog dialog;
private EnvChangeEntrance() { private EnvChangeEntrance() {
@ -116,13 +111,6 @@ public class EnvChangeEntrance {
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
boolean checkValid = workspace != null && selectedEnv.checkValid(); boolean checkValid = workspace != null && selectedEnv.checkValid();
if (!checkValid) { if (!checkValid) {
strategy.showTip(new PopTip() {
@Override
public void show() {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon"));
}
});
return false; return false;
} }
@ -149,34 +137,9 @@ public class EnvChangeEntrance {
template.refreshToolArea(); template.refreshToolArea();
} }
pluginErrorRemind(); pluginErrorRemind();
} 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() {
@Override
public void show() {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
}
});
return false;
} catch (WorkspaceCheckException e) {
handleWorkspaceCheckException(e, strategy, connectionInfo);
return false;
} catch (Exception exception) { } catch (Exception exception) {
if (exception.getCause() instanceof WorkspaceCheckException) { // 失败的处理
handleWorkspaceCheckException((WorkspaceCheckException) exception.getCause(), strategy, connectionInfo); RemoteDesignExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv);
} else {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")));
}
return false; return false;
} }
TemplateTreePane.getInstance().refreshDockingView(); TemplateTreePane.getInstance().refreshDockingView();
@ -188,29 +151,6 @@ public class EnvChangeEntrance {
return true; return true;
} }
public void handleWorkspaceCheckException(WorkspaceCheckException e, PopTipStrategy strategy, WorkspaceConnectionInfo info) {
TestConnectionResult result = TestConnectionResult.parseByException(e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
if (ComparatorUtils.equals(result, TestConnectionResult.AUTH_FAILED)) {
strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")));
} else {
if (result.isVerifyResult()) {
FineLoggerFactory.getLogger().error(result.getText().replaceAll(TestConnectionResult.WRAP, StringUtils.EMPTY) + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"));
}
strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
result.isVerifyResult()
? new MessageWithLink(result.getText(), Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"), info.getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH)
: result.getText(),
Toolkit.i18nText("Fine-Design_Basic_Error"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")));
}
}
/** /**
* 这个功能留着可能会加回来先做注释处理 * 这个功能留着可能会加回来先做注释处理
* 切换远程环境之前进行版本检测当版本不一致的时候提示 * 切换远程环境之前进行版本检测当版本不一致的时候提示
@ -440,7 +380,7 @@ public class EnvChangeEntrance {
public void chooseEnv(final String envName) { public void chooseEnv(final String envName) {
final EnvListPane envListPane = new EnvListPane(); final EnvListPane envListPane = new EnvListPane();
final BasicDialog envListDialog = envListPane.showWindow(DesignerContext.getDesignerFrame()); final BasicDialog envListDialog = envListPane.showWindow(DesignerContext.getDesignerFrame());
dialog = envListDialog;
envListPane.populateEnvManager(envName); envListPane.populateEnvManager(envName);
envListDialog.addDialogActionListener(new DialogActionAdapter() { envListDialog.addDialogActionListener(new DialogActionAdapter() {
@ -450,13 +390,14 @@ public class EnvChangeEntrance {
// 切换完成后清理密码 // 切换完成后清理密码
updateNotRememberPwdEnv(); updateNotRememberPwdEnv();
if (changeResult) { if (changeResult) {
VersionCheckUtils.showVersionCheckDialog(envListPane.updateEnvManager()); VersionCheckUtils.showVersionCheckDialog(envListPane.getSelectedName());
} }
} }
@Override @Override
public void doCancel() { public void doCancel() {
envListDialog.dispose(); envListDialog.dispose();
dialog = null;
// todo 断开了但是没选择新的环境,那么尝试重连旧环境,等接口 // todo 断开了但是没选择新的环境,那么尝试重连旧环境,等接口
} }
}); });
@ -466,7 +407,7 @@ public class EnvChangeEntrance {
/** /**
* 处理异常 * 处理异常
*/ */
public void dealEvnExceptionWhenStartDesigner() { public void dealEvnExceptionWhenStartDesigner(Throwable e, DesignerWorkspaceInfo workspaceInfo) {
ProcessEventPipe eventPipe = FineProcessContext.getParentPipe(); ProcessEventPipe eventPipe = FineProcessContext.getParentPipe();
if (eventPipe != null) { if (eventPipe != null) {
eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue())); eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue()));
@ -474,6 +415,7 @@ public class EnvChangeEntrance {
final EnvListPane envListPane = new EnvListPane(); final EnvListPane envListPane = new EnvListPane();
envListPane.populateEnvManager(DesignerEnvManager.getEnvManager().getCurEnvName()); envListPane.populateEnvManager(DesignerEnvManager.getEnvManager().getCurEnvName());
BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
dialog = envListDialog;
envListDialog.addDialogActionListener(new DialogActionAdapter() { envListDialog.addDialogActionListener(new DialogActionAdapter() {
@Override @Override
@ -483,15 +425,19 @@ public class EnvChangeEntrance {
DesignerExiter.getInstance().execute(); DesignerExiter.getInstance().execute();
} else { } else {
updateNotRememberPwdEnv(); updateNotRememberPwdEnv();
VersionCheckUtils.showVersionCheckDialog(envListPane.updateEnvManager()); VersionCheckUtils.showVersionCheckDialog(envListPane.getSelectedName());
} }
} }
@Override @Override
public void doCancel() { public void doCancel() {
dialog = null;
DesignerExiter.getInstance().execute(); DesignerExiter.getInstance().execute();
} }
}); });
if (e != null) {
RemoteDesignExceptionHandler.getInstance().handleInStart(e, workspaceInfo);
}
envListDialog.setVisible(true); envListDialog.setVisible(true);
} }
@ -523,6 +469,9 @@ public class EnvChangeEntrance {
return false; return false;
} }
public BasicDialog getDialog() {
return dialog;
}
/** /**
* 提示显示策略 * 提示显示策略
@ -559,14 +508,4 @@ public class EnvChangeEntrance {
interface PopTip { interface PopTip {
void show(); void show();
} }
private static class SuccessPopTip implements PopTip {
@Override
public void show() {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Success"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
FineJOptionPane.INFORMATION_MESSAGE);
}
}
} }

18
designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java

@ -4,6 +4,8 @@ import com.fr.design.constants.DesignerLaunchStatus;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fun.HyperlinkProvider; import com.fr.design.fun.HyperlinkProvider;
import com.fr.design.fun.TableDataDefineProvider; import com.fr.design.fun.TableDataDefineProvider;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.ui.util.UIUtil;
import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener; import com.fr.plugin.observer.PluginEventListener;
import com.fr.plugin.observer.PluginEventType; import com.fr.plugin.observer.PluginEventType;
@ -28,7 +30,7 @@ public class PluginClassRefreshManager {
@Override @Override
public void on(PluginEvent event) { public void on(PluginEvent event) {
// 重载模版之前 触发下hide // 重载模版之前 触发下hide
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange(); fireTabChange();
// 兼容之前版本特性 // 兼容之前版本特性
for (String tag : context) { for (String tag : context) {
if (event.getContext().contain(tag)) { if (event.getContext().contain(tag)) {
@ -53,12 +55,24 @@ public class PluginClassRefreshManager {
public void on(PluginEvent event) { public void on(PluginEvent event) {
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, pluginAfterRunEventListener); PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, pluginAfterRunEventListener);
if (DesignerLaunchStatus.getStatus() != DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE) { if (DesignerLaunchStatus.getStatus() != DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE) {
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange(); fireTabChange();
HistoryTemplateListCache.getInstance().reloadAllEditingTemplate(); HistoryTemplateListCache.getInstance().reloadAllEditingTemplate();
} }
} }
}; };
public void fireTabChange() {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
template.fireTabChange();
}
});
}
}
public static PluginClassRefreshManager getInstance() { public static PluginClassRefreshManager getInstance() {
return INSTANCE; return INSTANCE;

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

@ -503,7 +503,7 @@ public class PreferencePane extends BasicPane {
new JavaFxNativeFileChooser.Builder(). new JavaFxNativeFileChooser.Builder().
fileSelectionMode(FileSelectionMode.DIR). fileSelectionMode(FileSelectionMode.DIR).
build(); build();
int saveValue = fileChooserProvider.showDialog(null); int saveValue = fileChooserProvider.showDialog(chooseDirBtn);
if (saveValue == JFileChooser.APPROVE_OPTION) { if (saveValue == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooserProvider.getSelectedFile(); File selectedFile = fileChooserProvider.getSelectedFile();
logExportDirectoryField.setText(selectedFile.getAbsolutePath()); logExportDirectoryField.setText(selectedFile.getAbsolutePath());

448
designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java

@ -1,6 +1,8 @@
package com.fr.design.data.datapane.connect; package com.fr.design.data.datapane.connect;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
import com.fr.data.driver.DriverLoader;
import com.fr.data.driver.config.DriverLoaderConfig;
import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.design.border.UITitledBorder; import com.fr.design.border.UITitledBorder;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
@ -21,6 +23,8 @@ import com.fr.general.ComparatorUtils;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.guava.collect.HashBiMap;
import com.fr.workspace.WorkContext;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
@ -45,6 +49,7 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -97,12 +102,161 @@ public class JDBCDefPane extends JPanel {
private Component[][] partComponents; private Component[][] partComponents;
// 请不要改动dbtype,只应该最后添加 // 请不要改动dbtype,只应该最后添加
private final String[] dbtype = {"Oracle", "DB2", "SQL Server", "MySQL", "Sybase", "Access", "Derby", "Postgre", "SQLite", "Inceptor", OTHER_DB}; private final String[] dbtype = {"Oracle", "DB2", "SQL Server", "MySQL", "Sybase", "Access", "Derby", "Postgre", "SQLite", "Inceptor", OTHER_DB};
private JDBCDatabaseConnection jdbcDatabase; private JDBCDatabaseConnection jdbcDatabase;
private boolean needRefresh = true; private boolean needRefresh = true;
private UIComboBox driverManageBox;
private ActionLabel driverManageLabel;
private UIComboBox driverLoaderBox;
private HashBiMap<String, String> nameAndRepresent;
ActionListener driverListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (driverComboBox.getSelectedItem() == null || ComparatorUtils.equals(driverComboBox.getSelectedItem(), StringUtils.EMPTY)) {
return;
}
odbcTipsLink.setVisible(ComparatorUtils.equals("sun.jdbc.odbc.JdbcOdbcDriver", driverComboBox.getSelectedItem())); // 选择的如果是ODBC就显示提示
Iterator<Entry<String, DriverURLName[]>> jdbc = jdbcMap.entrySet().iterator();
while (jdbc.hasNext()) {
Entry<String, DriverURLName[]> entry = jdbc.next();
DriverURLName[] dus = entry.getValue();
for (int i = 0, len = dus.length; i < len; i++) {
if (ComparatorUtils.equals(dus[i].getDriver(), (driverComboBox.getSelectedItem()))) {
urlTextField.setText(dus[i].getURL());
return;
}
}
}
}
};
ActionListener dbtypeButtonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), StringUtils.EMPTY)) {
return;
}
DriverURLName[] dus = jdbcMap.get(dbtypeComboBox.getSelectedItem());
for (int i = 0, len = dus.length; i < len; i++) {
if (ComparatorUtils.equals(driverComboBox.getSelectedItem(), (dus[i].getDriver()))) {
urlTextField.setText(dus[i].getURL());
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), ("Access"))) {
// ben:这个能不能换种处理方案- -
JFileChooser filechooser = new JFileChooser();
filechooser.setDialogTitle(Toolkit.i18nText("Fine-Design_Basic_Open"));
filechooser.setMultiSelectionEnabled(false);
filechooser.addChoosableFileFilter(new ChooseFileFilter(new String[]{"accdb", "mdb"}, "Microsoft Office Access"));
int result = filechooser.showOpenDialog(DesignerContext.getDesignerFrame());
File selectedfile = null;
if (result == JFileChooser.APPROVE_OPTION) {
selectedfile = filechooser.getSelectedFile();
if (selectedfile != null) {
String selectedName = selectedfile.getPath().substring(selectedfile.getPath().lastIndexOf('.') + 1);
if (selectedName.equalsIgnoreCase("mdb") || selectedName.equalsIgnoreCase("accdb")) {
urlTextField.setText(urlTextField.getText() + selectedfile.getPath());
}
}
}
}
break;
}
}
}
};
KeyListener portKeyListener = new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
String port = portTextField.getText();
if (isPortValid(port)) {
updateURL();
} else {
portTextField.setText(port.replaceAll(getCharNeedReplace(e.getKeyChar()), ""));
if (!isPortValid(portTextField.getText())) {
portTextField.setText(StringUtils.EMPTY);
updateURL();
}
}
}
};
ActionListener driverManageListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean selectSelfDefine = isSelfDefine();
driverManageLabel.setVisible(selectSelfDefine);
driverLoaderBox.setVisible(selectSelfDefine);
driverComboBox.setVisible(!selectSelfDefine);
}
};
ActionListener dbtypeActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
urlTextField.setText(StringUtils.EMPTY);
driverComboBox.removeAllItems();
driverManageBox.setSelectedItem(Toolkit.i18nText("Fine-Design_Driver_Manage_Default"));
if (driverLoaderBox.getItemCount() > 0) {
driverLoaderBox.setSelectedIndex(0);
}
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), StringUtils.EMPTY)) {
driverComboBox.setSelectedItem(StringUtils.EMPTY);
return;
}
DriverURLName[] dus = jdbcMap.get(dbtypeComboBox.getSelectedItem());
for (int i = 0, len = dus.length; i < len; i++) {
driverComboBox.addItem(dus[i].getDriver());
if (i == 0) {
driverComboBox.setSelectedItem(dus[i].getDriver());
urlTextField.setText(dus[i].getURL());
}
}
// 更改数据库类型后 数据库名称置空和之前逻辑保持一致
if (needRefresh) {
jdbcDatabase.setDatabase(StringUtils.EMPTY);
}
changePane(dbtypeComboBox.getSelectedItem());
JDBCConnectionDef.getInstance().setConnection((String) dbtypeComboBox.getSelectedItem(), jdbcDatabase);
DatabaseConnectionPane.JDBC.getAdvancedAttrPane().populate(jdbcDatabase);
}
};
InputMethodListener portInputMethodListener = new InputMethodListener() {
@Override
public void inputMethodTextChanged(InputMethodEvent event) {
if (null == event.getText()) {
return;
}
char ch = event.getText().current();
if (!(ch >= '0' && ch <= '9')) {
event.consume();
}
}
@Override
public void caretPositionChanged(InputMethodEvent event) {
}
};
DocumentListener updateParaListener = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
updatePara();
}
@Override
public void removeUpdate(DocumentEvent e) {
updatePara();
}
@Override
public void changedUpdate(DocumentEvent e) {
updatePara();
}
};
public JDBCDefPane() { public JDBCDefPane() {
initMap();
this.setBorder(UITitledBorder.createBorderWithTitle("JDBC" + ":")); this.setBorder(UITitledBorder.createBorderWithTitle("JDBC" + ":"));
this.setLayout(FRGUIPaneFactory.createLabelFlowLayout()); this.setLayout(FRGUIPaneFactory.createLabelFlowLayout());
JPanel innerthis = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); JPanel innerthis = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
@ -115,7 +269,14 @@ public class JDBCDefPane extends JPanel {
} }
dbtypeComboBox.addActionListener(dbtypeActionListener); dbtypeComboBox.addActionListener(dbtypeActionListener);
dbtypeComboBox.setMaximumRowCount(10); dbtypeComboBox.setMaximumRowCount(10);
driverLoaderBox = new UIComboBox();
refreshDriverLoader();
driverLoaderBox.setEditable(false);
driverManageBox = new UIComboBox();
refreshDriverManage(true);
driverManageBox.setEditable(false);
driverManageBox.addActionListener(driverManageListener);
driverLoaderBox.setVisible(isSelfDefine());
driverComboBox = new UIComboBox(); driverComboBox = new UIComboBox();
driverComboBox.setEditable(true); driverComboBox.setEditable(true);
driverComboBox.addActionListener(driverListener); driverComboBox.addActionListener(driverListener);
@ -155,17 +316,39 @@ public class JDBCDefPane extends JPanel {
_gfx.drawLine(0, this.getHeight() - 1, GraphHelper.getWidth(this.getText()), this.getHeight() - 1); _gfx.drawLine(0, this.getHeight() - 1, GraphHelper.getWidth(this.getText()), this.getHeight() - 1);
} }
}; };
odbcTipsPane.add(odbcTipsLink);
odbcTipsLink.setPreferredSize(new Dimension(GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Basic_Odbc_Tips")), odbcTipsLink.getPreferredSize().height)); odbcTipsLink.setPreferredSize(new Dimension(GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Basic_Odbc_Tips")), odbcTipsLink.getPreferredSize().height));
odbcTipsLink.addActionListener(new ActionListener() { odbcTipsLink.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
String url = CloudCenter.getInstance().acquireUrlByKind("odbc.help"); String url = CloudCenter.getInstance().acquireUrlByKind("odbc.help");
BrowseUtils.browser(url); BrowseUtils.browser(url);
} }
}); });
driverManageLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Driver_Manage_Add_Driver")) {
@Override
public void paintComponent(Graphics _gfx) {
super.paintComponent(_gfx);
_gfx.setColor(Color.blue);
_gfx.drawLine(0, this.getHeight() - 1, GraphHelper.getWidth(this.getText()), this.getHeight() - 1);
}
};
driverManageLabel.setPreferredSize(new Dimension(GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Driver_Manage_Add_Driver")), driverManageLabel.getPreferredSize().height));
driverManageLabel.setVisible(isSelfDefine());
driverManageLabel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
String url = CloudCenter.getInstance().acquireUrlByKind("driver.add.help");
BrowseUtils.browser(url);
}
});
odbcTipsPane.add(driverManageLabel);
odbcTipsPane.add(odbcTipsLink);
JPanel driverComboBoxAndTips = new JPanel(new BorderLayout()); JPanel driverComboBoxAndTips = new JPanel(new BorderLayout());
driverComboBoxAndTips.add(driverComboBox, BorderLayout.WEST); JPanel normalFlowInnerContainer_s_pane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
normalFlowInnerContainer_s_pane.add(driverManageBox);
normalFlowInnerContainer_s_pane.add(driverComboBox);
normalFlowInnerContainer_s_pane.add(driverLoaderBox);
driverComboBoxAndTips.add(normalFlowInnerContainer_s_pane, BorderLayout.WEST);
driverComboBoxAndTips.add(odbcTipsPane, BorderLayout.CENTER); driverComboBoxAndTips.add(odbcTipsPane, BorderLayout.CENTER);
JPanel hostPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); JPanel hostPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
@ -225,7 +408,70 @@ public class JDBCDefPane extends JPanel {
innerthis.add(centerPanel); innerthis.add(centerPanel);
} }
private void initMap() {
Map<String, DriverLoader> driverLoaders = DriverLoaderConfig.getInstance().getDriverLoaders();
nameAndRepresent = getDriverLoaderAndRepresent(driverLoaders);
}
private HashBiMap<String, String> getDriverLoaderAndRepresent(Map<String, DriverLoader> driverLoaders) {
HashBiMap<String, String> driverHashBiMap = HashBiMap.create();
if (WorkContext.getCurrent().isWarDeploy()) {
return driverHashBiMap;
}
// name 是唯一的,name+driver自然也是唯一的
for (DriverLoader driverLoader : driverLoaders.values()) {
driverHashBiMap.put(driverLoader.getName(), getRepresent(driverLoader.getDriverClass(), driverLoader.getName()));
}
return driverHashBiMap;
}
protected JDBCDatabaseConnection getJDBCDatabase() {
return this.jdbcDatabase;
}
private void changePane(Object dbType) {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f, 22};
if (ComparatorUtils.equals(dbType, OTHER_DB) || ComparatorUtils.equals(dbType, "Access") || ComparatorUtils.equals(dbType, "SQLite")) {
if (this.centerPanel.getComponentCount() != partComponents.length * 2) {
centerPanel.removeAll();
TableLayoutHelper.addComponent2ResultPane(partComponents, new double[]{p, p, p, p, p}, columnSize, centerPanel);
}
} else if (this.centerPanel.getComponentCount() != allComponents.length * 2) {
centerPanel.removeAll();
TableLayoutHelper.addComponent2ResultPane(allComponents, new double[]{p, p, p, p, p, p, p, p}, columnSize, centerPanel);
}
}
private String getRepresent(String driverClass, String driverName) {
return driverClass + "(" + driverName + ")";
}
private boolean isSelfDefine() {
return ComparatorUtils.equals(Toolkit.i18nText("Fine-Design_Driver_Manage_Self_Define"), driverManageBox.getSelectedItem());
}
private void refreshDriverLoader() {
Set<String> representSet = nameAndRepresent.values();
driverLoaderBox.clearBoxItems();
for (String represent : representSet) {
driverLoaderBox.addItem(represent);
}
}
private void refreshDriverManage(boolean addSelfDefine) {
driverManageBox.clearBoxItems();
driverManageBox.addItem(Toolkit.i18nText("Fine-Design_Driver_Manage_Default"));
if (addSelfDefine) {
driverManageBox.addItem(Toolkit.i18nText("Fine-Design_Driver_Manage_Self_Define"));
}
}
public void populate(JDBCDatabaseConnection jdbcDatabase) { public void populate(JDBCDatabaseConnection jdbcDatabase) {
// 单例对象,重新打开的时候并不会新建,但是由于driverloaderbox里面需要是动态内容,因此需要进行刷新动作
initMap();
refreshDriverLoader();
needRefresh = false; needRefresh = false;
if (jdbcDatabase == null) { if (jdbcDatabase == null) {
jdbcDatabase = new JDBCDatabaseConnection(); jdbcDatabase = new JDBCDatabaseConnection();
@ -256,7 +502,23 @@ public class JDBCDefPane extends JPanel {
} }
} }
this.jdbcDatabase.setIdentity(jdbcDatabase.getIdentity()); this.jdbcDatabase.setIdentity(jdbcDatabase.getIdentity());
this.driverComboBox.setSelectedItem(jdbcDatabase.getDriver()); // jdbcDatabase.getDriverSource() 只会是空或者是有值,但是为了保险起见,还是应该做个处理
String driverSource = jdbcDatabase.getDriverSource();
if (driverSource == null) {
driverSource = StringUtils.EMPTY;
}
if (driverSource.isEmpty()) {
refreshDriverManage(!nameAndRepresent.isEmpty());
this.driverManageBox.setSelectedItem(Toolkit.i18nText("Fine-Design_Driver_Manage_Default"));
this.driverComboBox.setSelectedItem(jdbcDatabase.getDriver());
} else {
refreshDriverManage(true);
this.driverManageBox.setSelectedItem(Toolkit.i18nText("Fine-Design_Driver_Manage_Self_Define"));
String represent = getRepresent(jdbcDatabase.getDriver(), jdbcDatabase.getDriverSource());
this.driverLoaderBox.removeItem(represent);
this.driverLoaderBox.addItem(represent);
this.driverLoaderBox.setSelectedItem(represent);
}
this.urlTextField.setText(jdbcDatabase.getURL()); this.urlTextField.setText(jdbcDatabase.getURL());
this.userNameTextField.setText(jdbcDatabase.getUser()); this.userNameTextField.setText(jdbcDatabase.getUser());
this.passwordTextField.setText(jdbcDatabase.getPassword()); this.passwordTextField.setText(jdbcDatabase.getPassword());
@ -269,31 +531,10 @@ public class JDBCDefPane extends JPanel {
needRefresh = false; needRefresh = false;
} }
protected JDBCDatabaseConnection getJDBCDatabase() {
return this.jdbcDatabase;
}
private void changePane(Object dbType) {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f, 22};
if (ComparatorUtils.equals(dbType, OTHER_DB) || ComparatorUtils.equals(dbType, "Access") || ComparatorUtils.equals(dbType, "SQLite")) {
if (this.centerPanel.getComponentCount() != partComponents.length * 2) {
centerPanel.removeAll();
TableLayoutHelper.addComponent2ResultPane(partComponents, new double[]{p, p, p, p, p}, columnSize, centerPanel);
}
} else if (this.centerPanel.getComponentCount() != allComponents.length * 2) {
centerPanel.removeAll();
TableLayoutHelper.addComponent2ResultPane(allComponents, new double[]{p, p, p, p, p, p, p, p}, columnSize, centerPanel);
}
}
public JDBCDatabaseConnection update() { public JDBCDatabaseConnection update() {
if (jdbcDatabase == null) { if (jdbcDatabase == null) {
jdbcDatabase = new JDBCDatabaseConnection(); jdbcDatabase = new JDBCDatabaseConnection();
} }
Object driveItem = this.driverComboBox.getSelectedItem();
jdbcDatabase.setDriver(driveItem == null ? null : driveItem.toString().trim());
jdbcDatabase.setURL(this.urlTextField.getText().trim()); jdbcDatabase.setURL(this.urlTextField.getText().trim());
jdbcDatabase.setUser(this.userNameTextField.getText().trim()); jdbcDatabase.setUser(this.userNameTextField.getText().trim());
jdbcDatabase.setPassword(new String(this.passwordTextField.getPassword()).trim()); jdbcDatabase.setPassword(new String(this.passwordTextField.getPassword()).trim());
@ -305,126 +546,30 @@ public class JDBCDefPane extends JPanel {
jdbcDatabase.setNewCharsetName(EncodeConstants.ENCODING_GBK); jdbcDatabase.setNewCharsetName(EncodeConstants.ENCODING_GBK);
jdbcDatabase.setOriginalCharsetName(((String) this.charSetComboBox.getSelectedItem())); jdbcDatabase.setOriginalCharsetName(((String) this.charSetComboBox.getSelectedItem()));
} }
return jdbcDatabase; String driverLoader = (String) this.driverLoaderBox.getSelectedItem();
} if (driverLoader == null) {
driverLoader = StringUtils.EMPTY;
ActionListener dbtypeActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
urlTextField.setText(StringUtils.EMPTY);
driverComboBox.removeAllItems();
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), StringUtils.EMPTY)) {
driverComboBox.setSelectedItem(StringUtils.EMPTY);
return;
}
DriverURLName[] dus = jdbcMap.get(dbtypeComboBox.getSelectedItem());
for (int i = 0, len = dus.length; i < len; i++) {
driverComboBox.addItem(dus[i].getDriver());
if (i == 0) {
driverComboBox.setSelectedItem(dus[i].getDriver());
urlTextField.setText(dus[i].getURL());
}
}
// 更改数据库类型后 数据库名称置空和之前逻辑保持一致
if (needRefresh) {
jdbcDatabase.setDatabase(StringUtils.EMPTY);
}
changePane(dbtypeComboBox.getSelectedItem());
JDBCConnectionDef.getInstance().setConnection((String) dbtypeComboBox.getSelectedItem(), jdbcDatabase);
DatabaseConnectionPane.JDBC.getAdvancedAttrPane().populate(jdbcDatabase);
}
};
ActionListener driverListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (driverComboBox.getSelectedItem() == null || ComparatorUtils.equals(driverComboBox.getSelectedItem(), StringUtils.EMPTY)) {
return;
}
odbcTipsLink.setVisible(ComparatorUtils.equals("sun.jdbc.odbc.JdbcOdbcDriver", driverComboBox.getSelectedItem())); // 选择的如果是ODBC就显示提示
Iterator<Entry<String, DriverURLName[]>> jdbc = jdbcMap.entrySet().iterator();
while (jdbc.hasNext()) {
Entry<String, DriverURLName[]> entry = jdbc.next();
DriverURLName[] dus = entry.getValue();
for (int i = 0, len = dus.length; i < len; i++) {
if (ComparatorUtils.equals(dus[i].getDriver(), (driverComboBox.getSelectedItem()))) {
urlTextField.setText(dus[i].getURL());
return;
}
}
}
} }
if (isSelfDefine()) {
}; String[] split = driverLoader.split("\\(");
if (split.length > 1) {
ActionListener dbtypeButtonActionListener = new ActionListener() { String name = split[1];
public void actionPerformed(ActionEvent evt) { if (name.length() > 0) {
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), StringUtils.EMPTY)) { jdbcDatabase.setDriverSource(name.substring(0, name.length() - 1));
return; } else {
} jdbcDatabase.setDriverSource(StringUtils.EMPTY);
DriverURLName[] dus = jdbcMap.get(dbtypeComboBox.getSelectedItem());
for (int i = 0, len = dus.length; i < len; i++) {
if (ComparatorUtils.equals(driverComboBox.getSelectedItem(), (dus[i].getDriver()))) {
urlTextField.setText(dus[i].getURL());
if (ComparatorUtils.equals(dbtypeComboBox.getSelectedItem(), ("Access"))) {
// ben:这个能不能换种处理方案- -
JFileChooser filechooser = new JFileChooser();
filechooser.setDialogTitle(Toolkit.i18nText("Fine-Design_Basic_Open"));
filechooser.setMultiSelectionEnabled(false);
filechooser.addChoosableFileFilter(new ChooseFileFilter(new String[]{"accdb", "mdb"}, "Microsoft Office Access"));
int result = filechooser.showOpenDialog(DesignerContext.getDesignerFrame());
File selectedfile = null;
if (result == JFileChooser.APPROVE_OPTION) {
selectedfile = filechooser.getSelectedFile();
if (selectedfile != null) {
String selectedName = selectedfile.getPath().substring(selectedfile.getPath().lastIndexOf('.') + 1);
if (selectedName.equalsIgnoreCase("mdb") || selectedName.equalsIgnoreCase("accdb")) {
urlTextField.setText(urlTextField.getText() + selectedfile.getPath());
}
}
}
}
break;
} }
} else {
jdbcDatabase.setDriverSource(StringUtils.EMPTY);
} }
jdbcDatabase.setDriver(split[0]);
} else {
Object driveItem = this.driverComboBox.getSelectedItem();
jdbcDatabase.setDriver(driveItem == null ? null : driveItem.toString().trim());
jdbcDatabase.setDriverSource(StringUtils.EMPTY);
} }
}; return jdbcDatabase;
}
InputMethodListener portInputMethodListener = new InputMethodListener() {
@Override
public void inputMethodTextChanged(InputMethodEvent event) {
if (null == event.getText()) {
return;
}
char ch = event.getText().current();
if (!(ch >= '0' && ch <= '9')) {
event.consume();
}
}
@Override
public void caretPositionChanged(InputMethodEvent event) {
}
};
DocumentListener updateParaListener = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
updatePara();
}
@Override
public void removeUpdate(DocumentEvent e) {
updatePara();
}
@Override
public void changedUpdate(DocumentEvent e) {
updatePara();
}
};
private void updatePara() { private void updatePara() {
String dbType = dbtypeComboBox.getSelectedItem().toString(); String dbType = dbtypeComboBox.getSelectedItem().toString();
@ -489,21 +634,6 @@ public class JDBCDefPane extends JPanel {
this.hostTextField.getDocument().removeDocumentListener(updateURLListener); this.hostTextField.getDocument().removeDocumentListener(updateURLListener);
} }
KeyListener portKeyListener = new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
String port = portTextField.getText();
if (isPortValid(port)) {
updateURL();
} else {
portTextField.setText(port.replaceAll(getCharNeedReplace(e.getKeyChar()) , ""));
if (!isPortValid(portTextField.getText())) {
portTextField.setText(StringUtils.EMPTY);
updateURL();
}
}
}
};
private boolean isPortValid(String port) { private boolean isPortValid(String port) {
return PORT.matcher(port).find(); return PORT.matcher(port).find();

116
designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java

@ -6,7 +6,11 @@ import com.fr.design.gui.itable.TableSorter;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.OperatingSystem;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer; import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import java.awt.*; import java.awt.*;
import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.StringSelection;
@ -40,27 +44,104 @@ public class CopyableJTable extends SortableJTable {
int commandKeyCode = 157; int commandKeyCode = 157;
//选中单元格的背景色 //选中单元格的背景色
Color selectBackGround = new Color(54, 133, 242, 63); Color selectBackGround = new Color(54, 133, 242, 63);
Color headerBackGround = new Color(229, 229, 229);
boolean mouseDrag = false;
boolean headerSelect = false;
DefaultTableCellRenderer tableHeaderCellRenderer = new DefaultTableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (isChoose(row, column)) {
comp.setBackground(selectBackGround);
} else {
comp.setBackground(headerBackGround);
}
return comp;
}
};
public CopyableJTable(TableSorter tableModel) { public CopyableJTable(TableSorter tableModel) {
super(tableModel); super(tableModel);
initListener(); initListener();
this.getTableHeader().setDefaultRenderer(tableHeaderCellRenderer);
} }
private void initListener() { private void initListener() {
CopyableJTable self = this; CopyableJTable self = this;
this.getTableHeader().addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
if (mouseDrag) {
headerSelect = true;
int column = getColumn(e);
self.updateEndPoint(-1, column);
self.getTableHeader().repaint();
}
}
@Override
public void mouseExited(MouseEvent e) {
if (mouseDrag) {
headerSelect = false;
}
}
@Override
public void mouseClicked(MouseEvent e) {
headerSelect = true;
int column = getColumn(e);
if (column != -1) {
self.clearPoint();
self.addPoint(-1, column);
self.updateStartPoint(-1, column);
self.updateEndPoint(-1, column);
self.refreshTable();
}
}
private int getColumn(MouseEvent e) {
JTableHeader h = (JTableHeader) e.getSource();
TableColumnModel columnModel = h.getColumnModel();
int viewColumn = columnModel.getColumnIndexAtX(e.getX());
return viewColumn;
}
});
this.getTableHeader().addMouseMotionListener(new MouseAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
mouseDrag = false;
}
@Override
public void mouseDragged(MouseEvent e) {
self.clearPoint();
self.updateStartPoint(-1, -1);
self.updateEndPoint(-1, -1);
self.refreshTable();
}
});
this.addMouseMotionListener(new java.awt.event.MouseAdapter() { this.addMouseMotionListener(new java.awt.event.MouseAdapter() {
@Override @Override
public void mouseDragged(MouseEvent evt) { public void mouseDragged(MouseEvent evt) {
mouseDrag = true;
int row = self.rowAtPoint(evt.getPoint()); int row = self.rowAtPoint(evt.getPoint());
int col = self.columnAtPoint(evt.getPoint()); int col = self.columnAtPoint(evt.getPoint());
if (self.updateEndPoint(row, col)) { if (self.updateEndPoint(row, col)) {
self.repaint(); self.refreshTable();
} }
} }
public void mouseMoved(MouseEvent e) {
mouseDrag = false;
}
}); });
this.addMouseListener(new MouseAdapter() { this.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
headerSelect = false;
int row = self.rowAtPoint(e.getPoint()); int row = self.rowAtPoint(e.getPoint());
int col = self.columnAtPoint(e.getPoint()); int col = self.columnAtPoint(e.getPoint());
if (!self.isControlDown) { if (!self.isControlDown) {
@ -74,7 +155,7 @@ public class CopyableJTable extends SortableJTable {
self.addPoint(row, col); self.addPoint(row, col);
self.updateEndPoint(row, col); self.updateEndPoint(row, col);
self.repaint(); self.refreshTable();
} }
}); });
@ -129,6 +210,8 @@ public class CopyableJTable extends SortableJTable {
private boolean updateEndPoint(int row, int col) { private boolean updateEndPoint(int row, int col) {
if (headerSelect && row != -1)
return false;
if (endRow != row || endCol != col) { if (endRow != row || endCol != col) {
endRow = row; endRow = row;
endCol = col; endCol = col;
@ -157,13 +240,12 @@ public class CopyableJTable extends SortableJTable {
private void copy() { private void copy() {
FineLoggerFactory.getLogger().info("copy cell value"); FineLoggerFactory.getLogger().info("copy cell value");
java.util.List<java.util.List<Object>> table = new ArrayList<>(); java.util.List<java.util.List<Object>> table = new ArrayList<>();
if ((startRow != endRow || startCol != endCol) && if ((startRow != endRow || startCol != endCol) && Math.min(startCol, endCol) > -1) {
Math.min(startRow, endRow) > -1 && Math.min(startCol, endCol) > -1) {
for (int i = Math.min(startRow, endRow); i <= Math.max(startRow, endRow); i++) { for (int i = Math.min(startRow, endRow); i <= Math.max(startRow, endRow); i++) {
table.add(new ArrayList<>()); table.add(new ArrayList<>());
for (int j = Math.min(startCol, endCol); j <= Math.max(startCol, endCol); j++) { for (int j = Math.min(startCol, endCol); j <= Math.max(startCol, endCol); j++) {
Object text = this.getValueAt(i, j); Object text = this.getTableValue(i, j);
table.get(i - Math.min(startRow, endRow)).add(text); table.get(table.size() - 1).add(text);
} }
} }
} else if (pointList.size() > 0) { } else if (pointList.size() > 0) {
@ -176,8 +258,8 @@ public class CopyableJTable extends SortableJTable {
table.add(new ArrayList<>()); table.add(new ArrayList<>());
currentRow++; currentRow++;
} }
Object text = this.getValueAt(point.x, point.y); Object text = this.getTableValue(point.x, point.y);
table.get(currentRow - startRow).add(text); table.get(table.size() - 1).add(text);
} }
} }
@ -186,6 +268,24 @@ public class CopyableJTable extends SortableJTable {
clip.setContents(tText, null); clip.setContents(tText, null);
} }
private Object getTableValue(int row, int col) {
Object value = null;
if (col > -1) {
if (row > -1) {
value = this.getValueAt(row, col);
} else if (row == -1) {
col = columnModel.getColumn(col).getModelIndex();
value = this.getModel().getColumnName(col);
}
}
return value;
}
private void refreshTable() {
this.repaint();
this.getTableHeader().repaint();
}
private boolean isChoose(int row, int col) { private boolean isChoose(int row, int col) {
if (row >= Math.min(startRow, endRow) && row <= Math.max(startRow, endRow)) { if (row >= Math.min(startRow, endRow) && row <= Math.max(startRow, endRow)) {
if (col >= Math.min(startCol, endCol) && col <= Math.max(startCol, endCol)) { if (col >= Math.min(startCol, endCol) && col <= Math.max(startCol, endCol)) {

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

@ -3,6 +3,7 @@ package com.fr.design.dialog;
import com.fr.concurrent.NamedThreadFactory; import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.DesignSizeI18nManager;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
@ -10,6 +11,7 @@ import com.fr.design.notification.Notification;
import com.fr.design.notification.NotificationCenter; import com.fr.design.notification.NotificationCenter;
import com.fr.module.ModuleContext; import com.fr.module.ModuleContext;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
@ -40,9 +42,17 @@ public class NotificationDialog extends JDialog {
private UILabel messageText; private UILabel messageText;
private NotificationDialogAction notificationDialogAction; private NotificationDialogAction notificationDialogAction;
private ScheduledExecutorService TIMER; private ScheduledExecutorService TIMER;
private Dimension dialogSize = new Dimension(230, 95);
public NotificationDialog(Frame owner, String title, boolean isModal, int messageType, String message, NotificationDialogAction action) { public NotificationDialog(Frame owner, String title, boolean isModal, int messageType, String message, NotificationDialogAction action) {
this(owner, title, isModal, messageType, message, action, null);
}
public NotificationDialog(Frame owner, String title, boolean isModal, int messageType, String message, NotificationDialogAction action, Dimension dimension) {
super(owner); super(owner);
if (dimension != null) {
this.dialogSize = dimension;
}
setTitle(title); setTitle(title);
initComponents(StringUtils.EMPTY, messageType, message, isModal, action); initComponents(StringUtils.EMPTY, messageType, message, isModal, action);
} }
@ -77,7 +87,7 @@ public class NotificationDialog extends JDialog {
JScrollPane jScrollPane = new JScrollPane(messageText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); JScrollPane jScrollPane = new JScrollPane(messageText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPane.setBorder(BorderFactory.createEmptyBorder()); jScrollPane.setBorder(BorderFactory.createEmptyBorder());
centerPanel.add(jScrollPane, BorderLayout.CENTER); centerPanel.add(jScrollPane, BorderLayout.CENTER);
centerPanel.setPreferredSize(new Dimension(230, 95)); centerPanel.setPreferredSize(dialogSize);
body.add(centerPanel, BorderLayout.CENTER); body.add(centerPanel, BorderLayout.CENTER);
//查看详情 //查看详情

251
designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java

@ -0,0 +1,251 @@
package com.fr.design.dialog;
import com.fr.base.GraphHelper;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.IOUtils;
import com.fr.stable.StringUtils;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Point;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.PrintWriter;
import java.io.StringWriter;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
/**
* 带链接的错误详情弹窗
*
* @author hades
* @version 10.0
* Created by hades on 2021/8/2
*/
public class UIDetailErrorLinkDialog extends UIDialog {
private static final Color LINK_COLOR = new Color(51, 152, 253);
private static final int GAP_5 = 5;
private static final int GAP_10 = 10;
private static final String TAG_A_START = "<a>";
private static final String TAG_A_END = "</a>";
private static final double SCALE = 1.2;
private final Dimension dimension = new Dimension(300, 180);
public static Builder newBuilder() {
return new Builder();
}
private UIDetailErrorLinkDialog(Frame parent, Builder builder) {
super(parent);
init(builder);
}
private UIDetailErrorLinkDialog(Dialog parent, Builder builder) {
super(parent);
init(builder);
}
private void init(Builder builder) {
this.setTitle(builder.title);
// 顶部 图标和提示
UILabel errorIcon = new UILabel(IOUtils.readIcon("com/fr/design/images/lookandfeel/Information_Icon_Error_32x32.png"));
UILabel errorInfo= new UILabel(builder.reason);
JPanel topPane = new JPanel(new FlowLayout(FlowLayout.LEFT, GAP_10, GAP_5));
topPane.add(errorIcon);
topPane.add(errorInfo);
// 中部 详细内容
JPanel contentPane = new JPanel(new BorderLayout());
contentPane.setBorder(BorderFactory.createEmptyBorder(0, GAP_5,0,0));
UILabel errorCodeLabel = new UILabel(Toolkit.i18nText("Fine_Design_Basic_Error_Code", builder.errorCode));
UILabel link = new UILabel(Toolkit.i18nText("Fine_Design_Basic_Show_Error_Stack"));
link.setForeground(LINK_COLOR);
link.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
StringWriter stackTraceWriter = new StringWriter();
builder.throwable.printStackTrace(new PrintWriter(stackTraceWriter));
StackPane stackPane = new StackPane(stackTraceWriter.toString());
BasicDialog dialog = stackPane.showLargeWindow(UIDetailErrorLinkDialog.this, null);
dialog.setVisible(true);
}
});
contentPane.add(errorCodeLabel, BorderLayout.NORTH);
contentPane.add(createComponent(builder), BorderLayout.CENTER);
contentPane.add(link, BorderLayout.SOUTH);
// 确定 + 取消
JPanel actionPane = new JPanel(new FlowLayout(FlowLayout.RIGHT, GAP_10, GAP_10));
actionPane.add(createButton(Toolkit.i18nText("Fine-Design_Report_OK")));
actionPane.add(createButton(Toolkit.i18nText("Fine-Design_Basic_Cancel")));
this.getContentPane().add(topPane, BorderLayout.NORTH);
this.getContentPane().add(contentPane, BorderLayout.CENTER);
this.getContentPane().add(actionPane, BorderLayout.SOUTH);
this.setSize(dimension);
this.setResizable(false);
this.setModal(true);
GUICoreUtils.centerWindow(this);
}
private UIButton createButton(String content) {
UIButton button = new UIButton(content);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
UIDetailErrorLinkDialog.this.dispose();
}
});
return button;
}
private JComponent createComponent(Builder builder) {
JPanel panel = new JPanel(new BorderLayout());
boolean existDetailReason = StringUtils.isNotEmpty(builder.detailReason);
int maxWidth = dimension.width;
if (existDetailReason) {
String message = Toolkit.i18nText("Fine_Design_Basic_Detail_Error_Info", builder.detailReason);
UILabel label = new UILabel(message);
maxWidth = Math.max(maxWidth, GraphHelper.getWidth(message, label.getFont()));
panel.add(label, BorderLayout.NORTH);
}
String solution = existDetailReason ? builder.solution : Toolkit.i18nText("Fine_Design_Basic_Detail_Error_Info", builder.solution);
if (builder.solution.contains(TAG_A_START)) {
String[] solutionP1 = solution.split(TAG_A_START);
String[] solutionP2 = solutionP1[1].split(TAG_A_END);
MessageWithLink messageWithLink;
if (solutionP2.length == 2) {
messageWithLink = new MessageWithLink(solutionP1[0], solutionP2[0], builder.link, solutionP2[1]);
} else {
messageWithLink = new MessageWithLink(solutionP1[0], solutionP2[0], builder.link);
}
panel.add(messageWithLink, BorderLayout.CENTER);
} else {
UILabel solutionLabel = new UILabel(solution);
panel.add(solutionLabel, BorderLayout.CENTER);
}
dimension.width = getMaxDimensionWidth(maxWidth, solution);
return panel;
}
private int getMaxDimensionWidth(int width, String solution) {
int maxWidth = GraphHelper.getWidth(solution, DesignUtils.getDefaultGUIFont());
if (maxWidth >= width) {
maxWidth = (int) (SCALE * maxWidth);
} else {
maxWidth = width;
}
return maxWidth;
}
@Override
public void checkValid() throws Exception {
// do nothing
}
class StackPane extends BasicPane {
public StackPane(String stack) {
setLayout(new BorderLayout());
UITextArea textArea = new UITextArea();
textArea.setEditable(false);
textArea.setText(stack);
UIScrollPane scrollPane = new UIScrollPane(textArea);
add(scrollPane);
// 滚动条默认在顶部
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
scrollPane.getViewport().setViewPosition(new Point(0, 0));
}
});
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine_Design_Basic_Error_Stack");
}
}
public static class Builder {
private Window window;
private String title;
private String reason;
private String errorCode;
private String detailReason;
private String solution;
private String link;
private Throwable throwable;
private Builder() {
}
public Builder setTitle(String title) {
this.title = title;
return this;
}
public Builder setReason(String reason) {
this.reason = reason;
return this;
}
public Builder setErrorCode(String errorCode) {
this.errorCode = errorCode;
return this;
}
public Builder setSolution(String solution) {
this.solution = solution;
return this;
}
public Builder setDetailReason(String detailReason) {
this.detailReason = detailReason;
return this;
}
public Builder setThrowable(Throwable throwable) {
this.throwable = throwable;
return this;
}
public Builder setWindow(Window window) {
this.window = window;
return this;
}
public Builder setLink(String link) {
this.link = link;
return this;
}
public UIDetailErrorLinkDialog build() {
if (this.window instanceof Frame) {
return new UIDetailErrorLinkDialog((Frame) window, this);
} else {
return new UIDetailErrorLinkDialog((Dialog) window, this);
}
}
}
}

2
designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java vendored

@ -15,5 +15,5 @@ public interface DesignerWorkspaceInfo extends XMLable {
WorkspaceConnectionInfo getConnection(); WorkspaceConnectionInfo getConnection();
boolean checkValid(); boolean checkValid() throws Exception;
} }

15
designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java vendored

@ -168,8 +168,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
@Override @Override
public boolean checkValid() { public boolean checkValid() throws Exception {
boolean result = false;
String newPort = Integer.toString(DesignerEnvManager.getEnvManager().getEmbedServerPort()); String newPort = Integer.toString(DesignerEnvManager.getEnvManager().getEmbedServerPort());
if (!ComparatorUtils.equals(port, newPort)) { if (!ComparatorUtils.equals(port, newPort)) {
// 使用过程中 更改了内置服务器端口 重新初始化下 // 使用过程中 更改了内置服务器端口 重新初始化下
@ -177,15 +176,9 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
} }
if (FILTER_SET.contains(connection.getUrl())) { if (FILTER_SET.contains(connection.getUrl())) {
FineLoggerFactory.getLogger().error("url is same with local designer"); FineLoggerFactory.getLogger().error("url is same with local designer");
return result; return false;
} }
try { WorkContext.getConnector().validateVT(connection);
WorkContext.getConnector().validateVT(connection); return true;
result = true;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return result;
}
return result;
} }
} }

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

@ -10,6 +10,7 @@ import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.form.event.Listener;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -76,9 +77,12 @@ class JControlUpdatePane extends JPanel {
cardPane.add(updatePanes[i], String.valueOf(i)); cardPane.add(updatePanes[i], String.valueOf(i));
} }
card.show(cardPane, String.valueOf(i)); card.show(cardPane, String.valueOf(i));
try{ try {
if (ob2Populate instanceof Listener) {
listControlPane.wrapperListener((Listener) ob2Populate);
}
updatePanes[i].populateBean(ob2Populate); updatePanes[i].populateBean(ob2Populate);
}catch (Exception e){ } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
break; break;
@ -103,12 +107,15 @@ class JControlUpdatePane extends JPanel {
if (pane != null && pane.isVisible()) { if (pane != null && pane.isVisible()) {
Object bean = pane.updateBean(); Object bean = pane.updateBean();
try { try {
if (bean instanceof Listener) {
listControlPane.wrapperListener((Listener) bean);
}
if (bean instanceof RemoteDesignerWorkspaceInfo) { if (bean instanceof RemoteDesignerWorkspaceInfo) {
DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(elEditing.wrapper.getName()); DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(elEditing.wrapper.getName());
String remindTime = info.getRemindTime(); String remindTime = info.getRemindTime();
((RemoteDesignerWorkspaceInfo) bean).setRemindTime(remindTime); ((RemoteDesignerWorkspaceInfo) bean).setRemindTime(remindTime);
} }
}catch (Exception e){ } catch (Exception e) {
FineLoggerFactory.getLogger().info("remindTime is not exist"); FineLoggerFactory.getLogger().info("remindTime is not exist");
} }
if (i < creators.length) { if (i < creators.length) {

7
designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java

@ -6,6 +6,7 @@ import com.fr.design.gui.ilist.JNameEdList;
import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.gui.ilist.ModNameActionListener; import com.fr.design.gui.ilist.ModNameActionListener;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.event.Listener;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
@ -417,4 +418,10 @@ public abstract class JListControlPane extends JControlPane implements ListContr
public JControlUpdatePane getControlUpdatePane() { public JControlUpdatePane getControlUpdatePane() {
return (JControlUpdatePane) controlUpdatePane; return (JControlUpdatePane) controlUpdatePane;
} }
@Override
public void wrapperListener(Listener listener){
}
} }

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

@ -3,6 +3,7 @@ package com.fr.design.gui.controlpane;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.JNameEdList;
import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ListModelElement;
import com.fr.form.event.Listener;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;
@ -32,4 +33,6 @@ public interface ListControlPaneProvider extends UnrepeatedNameHelper {
void showSelectPane(); void showSelectPane();
void showEditPane(); void showEditPane();
ShortCut4JControlPane[] getShorts(); ShortCut4JControlPane[] getShorts();
void wrapperListener(Listener listener);
} }

7
designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java

@ -6,6 +6,7 @@ import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.JNameEdList;
import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.gui.ilist.UINameEdList; import com.fr.design.gui.ilist.UINameEdList;
import com.fr.form.event.Listener;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
@ -314,4 +315,10 @@ public abstract class UIListControlPane extends UIControlPane implements ListCon
public JNameEdList getNameableList() { public JNameEdList getNameableList() {
return nameableList; return nameableList;
} }
@Override
public void wrapperListener(Listener listener){
}
} }

7
designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java

@ -391,7 +391,7 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li
@Override @Override
public Nameable[] update() { public Nameable[] update() {
java.util.List<Nameable> res = new java.util.ArrayList<Nameable>(); List<Nameable> res = new ArrayList<Nameable>();
getControlUpdatePane().update(); getControlUpdatePane().update();
Iterator<Map.Entry<String, ListWrapperPane>> iterator = nameEdListMap.entrySet().iterator(); Iterator<Map.Entry<String, ListWrapperPane>> iterator = nameEdListMap.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -516,6 +516,11 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
@Override
public void wrapperListener(Listener listener){
}
private class ListWrapperPane extends JPanel { private class ListWrapperPane extends JPanel {
private UINameEdList nameEdList; private UINameEdList nameEdList;

87
designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java

@ -2,16 +2,22 @@ package com.fr.design.gui.ifilechooser;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.upm.UpmUtils; import com.fr.design.mainframe.DesignerContext;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.sun.javafx.application.PlatformImpl; import com.sun.javafx.application.PlatformImpl;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.paint.Color;
import javafx.stage.DirectoryChooser; import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser; import javafx.stage.FileChooser;
import javafx.stage.Window; import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javax.swing.*; import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.*; import java.awt.*;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
@ -40,9 +46,17 @@ public class JavaFxNativeFileChooser implements FileChooserProvider {
@Override @Override
public int showDialog(Component parent) { public int showDialog(Component parent) {
final CountDownLatch latch = new CountDownLatch(1); final CountDownLatch latch = new CountDownLatch(1);
PlatformImpl.startup(new Runnable() { PlatformImpl.startup(() -> {
});
Platform.setImplicitExit(false);
Platform.runLater(new Runnable() {
@Override @Override
public void run() { public void run() {
Component fileChooserParent = parent;
if (fileChooserParent == null) {
fileChooserParent = DesignerContext.getDesignerFrame();
}
Stage stage = showCoverStage(fileChooserParent);
try { try {
if (fileSelectionMode == FileSelectionMode.FILE || fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) { if (fileSelectionMode == FileSelectionMode.FILE || fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) {
FileChooser fileChooser = new FileChooser(); FileChooser fileChooser = new FileChooser();
@ -50,12 +64,12 @@ public class JavaFxNativeFileChooser implements FileChooserProvider {
fileChooser.getExtensionFilters().addAll(filters); fileChooser.getExtensionFilters().addAll(filters);
fileChooser.setInitialDirectory(currentDirectory); fileChooser.setInitialDirectory(currentDirectory);
if (fileSelectionMode == FileSelectionMode.FILE) { if (fileSelectionMode == FileSelectionMode.FILE) {
File file = fileChooser.showOpenDialog(null); File file = fileChooser.showOpenDialog(stage);
if (file != null) { if (file != null) {
selectedFiles = new File[]{file}; selectedFiles = new File[]{file};
} }
} else if (fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) { } else if (fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) {
List<File> fileList = fileChooser.showOpenMultipleDialog(null); List<File> fileList = fileChooser.showOpenMultipleDialog(stage);
if (fileList != null) { if (fileList != null) {
selectedFiles = new File[fileList.size()]; selectedFiles = new File[fileList.size()];
fileList.toArray(selectedFiles); fileList.toArray(selectedFiles);
@ -65,17 +79,70 @@ public class JavaFxNativeFileChooser implements FileChooserProvider {
DirectoryChooser directoryChooser = new DirectoryChooser(); DirectoryChooser directoryChooser = new DirectoryChooser();
directoryChooser.setTitle(title); directoryChooser.setTitle(title);
directoryChooser.setInitialDirectory(currentDirectory); directoryChooser.setInitialDirectory(currentDirectory);
File folder = directoryChooser.showDialog(null); File folder = directoryChooser.showDialog(stage);
if (folder != null) { if (folder != null) {
selectedFiles = new File[]{folder}; selectedFiles = new File[]{folder};
} }
System.out.println(folder);
} }
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage()); FineLoggerFactory.getLogger().error(e, e.getMessage());
} finally { } finally {
latch.countDown(); latch.countDown();
closeCoverStage(stage);
}
}
private void closeCoverStage(Stage stage) {
if (stage != null) {
stage.close();
closeCoverStage((Stage) stage.getOwner());
}
}
private Stage showCoverStage(Component component) {
try {
if (component == null)
return null;
Stage parentStage = showCoverStage(component.getParent());
if (component instanceof JDialog || component instanceof JFrame) {
return createStage(component.getX(), component.getY(), component.getWidth(), component.getHeight(), parentStage);
} else {
return parentStage;
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
return null;
}
}
private Stage createStage(double x, double y, double w, double h, Stage parentStage) {
try {
Stage stage = new Stage();
stage.setX(x);
stage.setY(y);
stage.setWidth(w);
stage.setHeight(h);
stage.setOpacity(0.2);
stage.setResizable(false);
stage.initStyle(StageStyle.UNDECORATED);
Label label = new Label();
label.setBackground(
new Background(new BackgroundFill(Color.color(0.78, 0.78, 0.80, 0.5), null, null)));
stage.setScene(new Scene(label));
if (parentStage != null) {
stage.initOwner(parentStage);
stage.initModality(Modality.WINDOW_MODAL);
}
stage.show();
return stage;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
return null;
} }
} }
}); });

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

@ -12,6 +12,7 @@ import java.awt.Toolkit;
* Date: 13-3-29 * Date: 13-3-29
* Time: 下午12:02 * Time: 下午12:02
* To change this template use File | Settings | File Templates. * To change this template use File | Settings | File Templates.
* fanglei: 这个类名字虽然叫整数输入框但是里面的业务仅支持输入正整数由于被引用的地方太多无法更改知道就行
*/ */
public class UIIntNumberField extends UINumberField { public class UIIntNumberField extends UINumberField {
public void setFieldDocument() { public void setFieldDocument() {

104
designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java

@ -1,16 +1,17 @@
package com.fr.design.javascript; package com.fr.design.javascript;
import com.fr.design.write.submit.DBManipulationPane;
import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.gui.frpane.CommitTabbedPane; import com.fr.design.gui.frpane.CommitTabbedPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.write.submit.DBManipulationPane;
import com.fr.js.Commit2DBJavaScript; import com.fr.js.Commit2DBJavaScript;
import com.fr.write.DBManipulation; import com.fr.write.DBManipulation;
import javax.swing.*; import javax.swing.JPanel;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -25,63 +26,64 @@ public class Commit2DBJavaScriptPane extends FurtherBasicBeanPane<Commit2DBJavaS
/** /**
* 构造函数控件事件的提交入库面板 * 构造函数控件事件的提交入库面板
* @param javaScriptActionPane JS提交面板对象 *
* @param javaScriptActionPane JS提交面板对象
* @param dbManipulationPaneList 提交入库的提交面板列表 * @param dbManipulationPaneList 提交入库的提交面板列表
*/ */
public Commit2DBJavaScriptPane(final JavaScriptActionPane javaScriptActionPane, List dbManipulationPaneList) { public Commit2DBJavaScriptPane(final JavaScriptActionPane javaScriptActionPane, List dbManipulationPaneList) {
this.dbmPaneList=dbManipulationPaneList; this.dbmPaneList = dbManipulationPaneList;
this.javaScriptActionPane = javaScriptActionPane; this.javaScriptActionPane = javaScriptActionPane;
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
commitTabbedPane = new CommitTabbedPane(this,dbmPaneList); commitTabbedPane = new CommitTabbedPane(this, dbmPaneList);
commitTabbedPane.setPreferredSize(new Dimension(commitTabbedPane.getWidth(),20)); commitTabbedPane.setPreferredSize(new Dimension(commitTabbedPane.getWidth(), 20));
this.add(commitTabbedPane, BorderLayout.NORTH) ; this.add(commitTabbedPane, BorderLayout.NORTH);
cardPane = new JPanel(new CardLayout()); cardPane = new JPanel(new CardLayout());
cardNames = new String[dbmPaneList.size()] ; cardNames = new String[dbmPaneList.size()];
for (int i = 0; i < this.dbmPaneList.size(); i++) { for (int i = 0; i < this.dbmPaneList.size(); i++) {
if(((DBManipulationPane) this.dbmPaneList.get(i)).getSubMitName() == null){ if (((DBManipulationPane) this.dbmPaneList.get(i)).getSubMitName() == null) {
cardNames[i] = ""; cardNames[i] = "";
} else{ } else {
cardNames[i] =((DBManipulationPane) this.dbmPaneList.get(i)).getSubMitName(); cardNames[i] = ((DBManipulationPane) this.dbmPaneList.get(i)).getSubMitName();
} }
cardPane.add((DBManipulationPane)this.dbmPaneList.get(i),cardNames[i]); cardPane.add((DBManipulationPane) this.dbmPaneList.get(i), cardNames[i]);
} }
this.add(cardPane, BorderLayout.CENTER); this.add(cardPane, BorderLayout.CENTER);
JPanel btPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); JPanel btPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
this.add(btPane, BorderLayout.SOUTH); this.add(btPane, BorderLayout.SOUTH);
addCallbackButton = javaScriptActionPane.createCallButton();
btPane.add(addCallbackButton);
}
addCallbackButton = javaScriptActionPane.createCallButton();
btPane.add(addCallbackButton);
}
/** /**
* 更新DBManipulationPane * 更新DBManipulationPane
*/ */
public void updateCardPane(){ public void updateCardPane() {
cardNames = new String[dbmPaneList.size()] ; cardNames = new String[dbmPaneList.size()];
for (int i = 0; i < this.dbmPaneList.size(); i++) { for (int i = 0; i < this.dbmPaneList.size(); i++) {
if(((DBManipulationPane) this.dbmPaneList.get(i)).getSubMitName() == null){ if (((DBManipulationPane) this.dbmPaneList.get(i)).getSubMitName() == null) {
cardNames[i] = ""; cardNames[i] = "";
} else{ } else {
cardNames[i] =((DBManipulationPane) this.dbmPaneList.get(i)).getSubMitName(); cardNames[i] = ((DBManipulationPane) this.dbmPaneList.get(i)).getSubMitName();
} }
cardPane.add((DBManipulationPane)this.dbmPaneList.get(i),cardNames[i]); cardPane.add((DBManipulationPane) this.dbmPaneList.get(i), cardNames[i]);
} }
CardLayout cardLayout = (CardLayout)cardPane.getLayout(); CardLayout cardLayout = (CardLayout) cardPane.getLayout();
cardLayout.show(cardPane,cardNames[commitTabbedPane.getSelectedIndex()]); cardLayout.show(cardPane, cardNames[commitTabbedPane.getSelectedIndex()]);
} }
public void setList(List list){ public void setList(List list) {
this.dbmPaneList = list; this.dbmPaneList = list;
} }
/** /**
* 新建DBManipulationPane * 新建DBManipulationPane
* @return 新建的DBManipulationPane *
* @return 新建的DBManipulationPane
*/ */
public DBManipulationPane createDBManipulationPane(){ public DBManipulationPane createDBManipulationPane() {
DBManipulationPane db = javaScriptActionPane.createDBManipulationPane(); DBManipulationPane db = javaScriptActionPane.createDBManipulationPane();
db.populateBean(null); db.populateBean(null);
dbmPaneList.add(db); dbmPaneList.add(db);
@ -91,25 +93,26 @@ public class Commit2DBJavaScriptPane extends FurtherBasicBeanPane<Commit2DBJavaS
/** /**
* 窗口名称 * 窗口名称
*
* @return 返回窗口名称 * @return 返回窗口名称
*/ */
public String title4PopupWindow() { public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_JavaScript_Commit_To_Database"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_JavaScript_Commit_To_Database");
} }
/** /**
* 界面重置 * 界面重置
*/ */
public void reset() { public void reset() {
this.javaScriptActionPane.setCall(null); this.javaScriptActionPane.setCall(null);
//重置后只保留,只留第一个tab //重置后只保留,只留第一个tab
while (dbmPaneList.size() > 1){ while (dbmPaneList.size() > 1) {
dbmPaneList.remove(1); dbmPaneList.remove(1);
} }
((DBManipulationPane)dbmPaneList.get(0)).populateBean(null); ((DBManipulationPane) dbmPaneList.get(0)).populateBean(null);
} }
@Override @Override
/** /**
* 将JavaBean内的数据输出至界面上 * 将JavaBean内的数据输出至界面上
*/ */
@ -131,11 +134,15 @@ public class Commit2DBJavaScriptPane extends FurtherBasicBeanPane<Commit2DBJavaS
/** /**
* 更新数据层JavaBean * 更新数据层JavaBean
*
* @return 返回JavaBean * @return 返回JavaBean
*/ */
public Commit2DBJavaScript updateBean() { public Commit2DBJavaScript updateBean() {
Commit2DBJavaScript commit2dbJavaScript = new Commit2DBJavaScript(); Commit2DBJavaScript commit2dbJavaScript = new Commit2DBJavaScript();
if (javaScriptActionPane.getResourceInfo() != null) {
commit2dbJavaScript.setJsResourceInfo(javaScriptActionPane.getResourceInfo());
}
List dbmaniList = new ArrayList(); List dbmaniList = new ArrayList();
for(int i = 0; i < this.dbmPaneList.size(); i++){ for(int i = 0; i < this.dbmPaneList.size(); i++){
DBManipulationPane dbmpane =(DBManipulationPane)this.dbmPaneList.get(i); DBManipulationPane dbmpane =(DBManipulationPane)this.dbmPaneList.get(i);
@ -154,11 +161,12 @@ public class Commit2DBJavaScriptPane extends FurtherBasicBeanPane<Commit2DBJavaS
/** /**
* 判断是否是能接受的数据类型 * 判断是否是能接受的数据类型
*
* @param ob 对象 * @param ob 对象
* @return 返回是否是能接受的数据类型 * @return 返回是否是能接受的数据类型
*/ */
public boolean accept(Object ob) { public boolean accept(Object ob) {
return ob instanceof Commit2DBJavaScript; return ob instanceof Commit2DBJavaScript;
} }
} }

453
designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java

@ -0,0 +1,453 @@
package com.fr.design.javascript;
import com.fr.base.BaseFormula;
import com.fr.base.Parameter;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.editor.editor.FormulaEditor;
import com.fr.design.gui.frpane.ReportletParameterViewPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.hyperlink.AbstractHyperLinkPane;
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.DesignerContext;
import com.fr.design.scrollruler.ModLineBorder;
import com.fr.file.filetree.IOFileNodeFilter;
import com.fr.general.GeneralUtils;
import com.fr.js.ExportJavaScript;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import javax.swing.AbstractButton;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript> {
private ExportRadioGroup templateRadioGroup;
private UIRadioButton currentTemplateRadio;
private UIRadioButton otherTemplateRadio;
private UITextField reportPathTextField;
private UIButton browserButton;
private UIComboBox exportTypeComboBox;
private ExportRadioGroup fileNameRadioGroup;
private UIRadioButton defaultNameRadio;
private UIRadioButton customNameRadio;
private FormulaEditor fileNameFormulaEditor;
private UICheckBox extendParametersCheckBox;
private ReportletParameterViewPane parameterViewPane;
private static final double p = TableLayout.PREFERRED;
private static final Map<String, String> EXPORT_TYPES_MAP = new HashMap<>();
private static final String CURRENT_TEMPLATE = "current";
private static final String DEFAULT_FILENAME = "default";
static {
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_PDF, Toolkit.i18nText("Fine-Design_Basic_Export_JS_PDF"));
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_PAGE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Page"));
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_SIMPLE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Simple"));
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_SHEET, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Sheet"));
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_WORD, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Word"));
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_IMAGE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Image"));
}
public ExportJavaScriptPane() {
initComponents();
}
private void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Toolkit.i18nText("Fine-Design_Basic_Export_JS_Setting")));
//导出模板+导出方式+导出文件名
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
//导出模板
JPanel chooseTemplatePane = initChooseTemplatePane();
northPane.add(chooseTemplatePane, BorderLayout.NORTH);
//导出方式
JPanel exportTypePane = initExportTypePane();
northPane.add(exportTypePane, BorderLayout.CENTER);
//导出文件名
JPanel fileNamePane = initFileNamePane();
northPane.add(fileNamePane, BorderLayout.SOUTH);
//参数
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel paramsPane = initParamsPane();
centerPane.add(paramsPane);
this.add(northPane, BorderLayout.NORTH);
this.add(centerPane, BorderLayout.CENTER);
}
private JPanel initParamsPane() {
extendParametersCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Extends_Report_Parameters"));
parameterViewPane = new ReportletParameterViewPane(getChartParaType(), getValueEditorPane(), getValueEditorPane());
parameterViewPane.addTableEditorListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) {
List<ParameterProvider> list = parameterViewPane.update();
HashSet<String> tempSet = new HashSet<>();
for (int i = 0; i < list.size(); i++) {
if (StringUtils.isEmpty(list.get(i).getName())) {
continue;
}
if (tempSet.contains(list.get(i).toString())) {
list.remove(i);
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Duplicate_Name") + "!");
return;
}
tempSet.add(list.get(i).toString());
}
}
});
extendParametersCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
parameterViewPane.setVisible(e.getStateChange() == ItemEvent.DESELECTED);
}
});
JPanel paramsPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
paramsPane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Toolkit.i18nText("Fine-Design_Basic_Parameters")));
paramsPane.add(extendParametersCheckBox, BorderLayout.NORTH);
JPanel dynamicPaneWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane();
dynamicPaneWrapper.add(parameterViewPane);
paramsPane.add(dynamicPaneWrapper, BorderLayout.CENTER);
return paramsPane;
}
private JPanel initFileNamePane() {
UILabel nameLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename") + ":");
fileNameRadioGroup = new ExportRadioGroup();
defaultNameRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Default"));
defaultNameRadio.setSelected(true);
customNameRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Custom"));
addRadioToGroup(fileNameRadioGroup, defaultNameRadio, customNameRadio);
fileNameFormulaEditor = new FormulaEditor(Toolkit.i18nText("Fine-Design_Report_Parameter_Formula"));
fileNameRadioGroup.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (defaultNameRadio.isSelected()) {
fileNameFormulaEditor.setEnabled(false);
} else {
fileNameFormulaEditor.setEnabled(true);
}
}
});
Component[][] components = new Component[][]{{nameLabel, defaultNameRadio, customNameRadio, fileNameFormulaEditor}};
JPanel fileNameRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p, p});
JPanel fileNameTipPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
UILabel fileNameTipLabel = new UILabel("<html><body style=\"color:red\">" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Front") + "\\/:*?\"<>|" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Back") + "</html>");
fileNameTipPane.add(fileNameTipLabel);
JPanel fileNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
fileNamePane.add(fileNameRadioPane, BorderLayout.NORTH);
fileNamePane.add(fileNameTipPane, BorderLayout.CENTER);
fileNameTipPane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2));
fileNamePane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2));
return fileNamePane;
}
private JPanel initExportTypePane() {
UILabel typeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Type") + ":");
exportTypeComboBox = new UIComboBox(new DefaultComboBoxModel<String>());
DefaultComboBoxModel<String> comboBoxModel = (DefaultComboBoxModel<String>) exportTypeComboBox.getModel();
String[] allExportTypes = new String[]{ExportJavaScript.EXPORT_PDF, ExportJavaScript.EXPORT_EXCEL_PAGE, ExportJavaScript.EXPORT_EXCEL_SIMPLE, ExportJavaScript.EXPORT_EXCEL_SHEET, ExportJavaScript.EXPORT_WORD, ExportJavaScript.EXPORT_IMAGE};
for (int i = 0; i < allExportTypes.length; i++) {
comboBoxModel.addElement(allExportTypes[i]);
}
this.exportTypeComboBox.setRenderer(new UIComboBoxRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof String) {
this.setText(EXPORT_TYPES_MAP.get(value));
}
return this;
}
});
Component[][] components = new Component[][]{{typeLabel, exportTypeComboBox}};
JPanel exportTypePane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p});
exportTypePane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2));
return exportTypePane;
}
private JPanel initChooseTemplatePane() {
UILabel templateLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template") + ":");
templateRadioGroup = new ExportRadioGroup();
currentTemplateRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current"));
currentTemplateRadio.setSelected(true);
otherTemplateRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Other"));
addRadioToGroup(templateRadioGroup, currentTemplateRadio, otherTemplateRadio);
templateRadioGroup.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (currentTemplateRadio.isSelected()) {
reportPathTextField.setEnabled(false);
browserButton.setEnabled(false);
} else {
reportPathTextField.setEnabled(true);
browserButton.setEnabled(true);
}
}
});
Component[][] components = new Component[][]{{templateLabel, currentTemplateRadio, otherTemplateRadio}};
JPanel reportletRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p});
JPanel reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
// 路径输入框
reportPathTextField = new UITextField(20);
reportletNamePane.add(reportPathTextField, BorderLayout.CENTER);
// 选择路径按钮
browserButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Select"));
browserButton.setPreferredSize(new Dimension(browserButton.getPreferredSize().width, 20));
reportletNamePane.add(browserButton, BorderLayout.EAST);
browserButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
final ReportletPane reportletPane = new ReportletPane();
reportletPane.setSelectedReportletPath(reportPathTextField.getText());
BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(ExportJavaScriptPane.this));
reportletDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
reportPathTextField.setText(reportletPane.getSelectedReportletPath());
}
});
reportletDialog.setVisible(true);
}
});
JPanel chooseTemplatePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
chooseTemplatePane.add(reportletRadioPane, BorderLayout.NORTH);
chooseTemplatePane.add(reportletNamePane, BorderLayout.CENTER);
chooseTemplatePane.setBorder(BorderFactory.createEmptyBorder(0,2,5,2));
return chooseTemplatePane;
}
@Override
public void populateBean(ExportJavaScript ob) {
if (ob == null) {
ob = new ExportJavaScript();
}
this.templateRadioGroup.selectIndexButton(ob.isCurrentTemplate() ? 0 : 1);
if (ob.isCurrentTemplate()) {
this.reportPathTextField.setEnabled(false);
this.browserButton.setEnabled(false);
} else {
this.reportPathTextField.setEnabled(true);
this.browserButton.setEnabled(true);
this.reportPathTextField.setText(ob.getTemplatePath());
}
this.exportTypeComboBox.setSelectedItem(ob.getExportType());
this.fileNameRadioGroup.selectIndexButton(ob.isDefaultFileName() ? 0 : 1);
if (ob.isDefaultFileName()) {
this.fileNameFormulaEditor.setEnabled(false);
} else {
this.fileNameFormulaEditor.setEnabled(true);
this.fileNameFormulaEditor.setValue(BaseFormula.createFormulaBuilder().build(ob.getFileName()));
}
if (ob.isExtendParameters()) {
this.extendParametersCheckBox.setSelected(true);
} else {
this.extendParametersCheckBox.setSelected(false);
List<ParameterProvider> parameterList = this.parameterViewPane.update();
parameterList.clear();
ParameterProvider[] parameters = ob.getParameters();
this.parameterViewPane.populate(parameters);
}
}
@Override
public ExportJavaScript updateBean() {
ExportJavaScript exportJavaScript = new ExportJavaScript();
updateBean(exportJavaScript);
return exportJavaScript;
}
@Override
public void updateBean(ExportJavaScript exportJavaScript) {
exportJavaScript.setCurrentTemplate(this.currentTemplateRadio.isSelected());
exportJavaScript.setTemplatePath(getTemplatePath());
exportJavaScript.setExportType(GeneralUtils.objectToString(this.exportTypeComboBox.getSelectedItem()));
exportJavaScript.setDefaultFileName(this.defaultNameRadio.isSelected());
exportJavaScript.setFileName(getFileName());
exportJavaScript.setExtendParameters(this.extendParametersCheckBox.isSelected());
if (extendParametersCheckBox.isSelected()) {
exportJavaScript.setParameters(null);
} else {
List<ParameterProvider> parameterList = this.parameterViewPane.update();
if (!parameterList.isEmpty()) {
Parameter[] parameters = new Parameter[parameterList.size()];
parameterList.toArray(parameters);
exportJavaScript.setParameters(parameters);
}
}
}
private String getTemplatePath() {
return currentTemplateRadio.isSelected() ? CURRENT_TEMPLATE : reportPathTextField.getText();
}
private String getFileName() {
return defaultNameRadio.isSelected() ? DEFAULT_FILENAME : fileNameFormulaEditor.getUITextField().getText();
}
@Override
public boolean accept(Object ob) {
return ob instanceof ExportJavaScript;
}
@Override
public void reset() {
populateBean(null);
}
@Override
public java.lang.String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Event");
}
private void addRadioToGroup(ButtonGroup buttonGroup, UIRadioButton... radios) {
for (UIRadioButton radio : radios) {
buttonGroup.add(radio);
}
}
class ExportRadioGroup extends ButtonGroup {
private List<UIRadioButton> radioButtons = new ArrayList<>();
@Override
public void add(AbstractButton button) {
super.add(button);
UIRadioButton radioButton = (UIRadioButton) button;
radioButtons.add(radioButton);
}
public void selectIndexButton(int index) {
if (index < 0 || index > radioButtons.size() - 1) {
return;
}
UIRadioButton button = radioButtons.get(index);
button.setSelected(true);
}
public void addActionListener(ActionListener actionListener) {
for (UIRadioButton radioButton : radioButtons) {
radioButton.addActionListener(actionListener);
}
}
}
class ReportletPane extends BasicPane {
private TemplateFileTree templateReportletTree;
private JScrollPane t_panel;
private JPanel cardPane;
public ReportletPane() {
this.setLayout(FRGUIPaneFactory.createM_BorderLayout());
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(centerPane, BorderLayout.CENTER);
cardPane = FRGUIPaneFactory.createCardLayout_S_Pane();
centerPane.add(cardPane, BorderLayout.CENTER);
cardPane.setLayout(new CardLayout());
templateReportletTree = new TemplateFileTree();
IOFileNodeFilter filter = new IOFileNodeFilter(new String[]{".cpt"});
templateReportletTree.setFileNodeFilter(filter);
cardPane.add(t_panel = new JScrollPane(templateReportletTree), "TEMPLATE");
this.refreshEnv();
}
/**
* 检查是否符合规范
*
* @throws Exception 抛错
*/
@Override
public void checkValid() throws Exception {
String path = this.getSelectedReportletPath();
if (path == null) {
throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Function_The_Selected_File_Cannot_Be_Null"));
}
}
/**
* 刷新Env
*/
public void refreshEnv() {
this.templateReportletTree.refreshEnv();
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Event");
}
/*
* 返回选中的Reportlet的路径
*/
public String getSelectedReportletPath() {
if (t_panel.isVisible()) {
return templateReportletTree.getSelectedTemplatePath();
}
return null;
}
/*
* 选中某Reportlet
*/
public void setSelectedReportletPath(String reportletPath) {
if (reportletPath == null) {
return;
}
templateReportletTree.setSelectedTemplatePath(reportletPath);
}
}
}

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

@ -12,6 +12,7 @@ import com.fr.design.mainframe.JTemplate;
import com.fr.design.write.submit.DBManipulationPane; import com.fr.design.write.submit.DBManipulationPane;
import com.fr.form.ui.WebContentUtils; import com.fr.form.ui.WebContentUtils;
import com.fr.js.JavaScript; import com.fr.js.JavaScript;
import com.fr.write.JavaScriptResourceInfo;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -29,6 +30,8 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
private List contentDBManiPane; private List contentDBManiPane;
private JavaScriptResourceInfo resourceInfo;
private JavaScript call = null; private JavaScript call = null;
public JavaScriptActionPane() { public JavaScriptActionPane() {
@ -44,6 +47,10 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
contentDBManiPane.add(createDBManipulationPane()); contentDBManiPane.add(createDBManipulationPane());
paneList.add(new Commit2DBJavaScriptPane(this, contentDBManiPane)); paneList.add(new Commit2DBJavaScriptPane(this, contentDBManiPane));
paneList.add(initEmaiPane()); paneList.add(initEmaiPane());
boolean workbook = DesignerContext.getDesignerFrame().getSelectedJTemplate().isJWorkBook();
if (workbook) {
paneList.add(new ExportJavaScriptPane());
}
Set<JavaScriptActionProvider> javaScriptActionProviders = ExtraDesignClassManager.getInstance().getArray(JavaScriptActionProvider.XML_TAG); Set<JavaScriptActionProvider> javaScriptActionProviders = ExtraDesignClassManager.getInstance().getArray(JavaScriptActionProvider.XML_TAG);
if (javaScriptActionProviders != null) { if (javaScriptActionProviders != null) {
for (JavaScriptActionProvider jsp : javaScriptActionProviders) { for (JavaScriptActionProvider jsp : javaScriptActionProviders) {
@ -71,6 +78,14 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
} }
public JavaScriptResourceInfo getResourceInfo() {
return resourceInfo;
}
public void setResourceInfo(JavaScriptResourceInfo resourceInfo) {
this.resourceInfo = resourceInfo;
}
/** /**
* 生成回调函数的按钮 * 生成回调函数的按钮
* *
@ -178,8 +193,8 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
* @return 返回生成的面板 * @return 返回生成的面板
*/ */
public static JavaScriptActionPane createDefault() { public static JavaScriptActionPane createDefault() {
return new JavaScriptActionPane() { return new JavaScriptActionPane() {
@Override @Override
public DBManipulationPane createDBManipulationPane() { public DBManipulationPane createDBManipulationPane() {
return new DBManipulationPane(); return new DBManipulationPane();

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

@ -275,6 +275,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
//刷新FixedPopupPane的位置 //刷新FixedPopupPane的位置
EastRegionContainerPane.getInstance().freshCurrentPopupPane(); EastRegionContainerPane.getInstance().freshCurrentPopupPane();
} }
@Override
public void componentMoved(ComponentEvent e) {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
template.refreshFormDesigner();
}
}
}); });
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.setVisible(false); this.setVisible(false);

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

@ -221,6 +221,10 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
// do nothing // do nothing
} }
public void refreshFormDesigner() {
// do nothing
}
/** /**
* @deprecated move to cloud ops pluginleft only for compatible * @deprecated move to cloud ops pluginleft only for compatible

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

@ -25,6 +25,8 @@ public class ComponentReuseNotificationInfo implements XMLable {
private long lastGuidePopUpTime = 0; private long lastGuidePopUpTime = 0;
private String historyCreatedReuses = "[]";
public long getLastNotifyTime() { public long getLastNotifyTime() {
return lastNotifyTime; return lastNotifyTime;
} }
@ -62,12 +64,21 @@ public class ComponentReuseNotificationInfo implements XMLable {
DesignerEnvManager.getEnvManager().saveXMLFile(); DesignerEnvManager.getEnvManager().saveXMLFile();
} }
public String getHistoryCreatedReuses() {
return historyCreatedReuses;
}
public void setHistoryCreatedReuses(String historyCreatedReuses) {
this.historyCreatedReuses = historyCreatedReuses;
}
@Override @Override
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
this.setLastNotifyTime(reader.getAttrAsLong("lastNotifyTime", 0L)); this.setLastNotifyTime(reader.getAttrAsLong("lastNotifyTime", 0L));
this.setNotifiedNumber(reader.getAttrAsInt("notifiedNumber", 0)); this.setNotifiedNumber(reader.getAttrAsInt("notifiedNumber", 0));
this.setClickedWidgetLib(reader.getAttrAsBoolean("clickedWidgetLib", false)); this.setClickedWidgetLib(reader.getAttrAsBoolean("clickedWidgetLib", false));
this.setLastGuidePopUpTime(reader.getAttrAsLong("lastGuidePopUpTime", 0L)); this.setLastGuidePopUpTime(reader.getAttrAsLong("lastGuidePopUpTime", 0L));
this.setHistoryCreatedReuses(reader.getAttrAsString("historyCreatedReuses", "[]"));
} }
@Override @Override
@ -76,7 +87,8 @@ public class ComponentReuseNotificationInfo implements XMLable {
writer.attr("lastNotifyTime", this.lastNotifyTime) writer.attr("lastNotifyTime", this.lastNotifyTime)
.attr("notifiedNumber", this.notifiedNumber) .attr("notifiedNumber", this.notifiedNumber)
.attr("clickedWidgetLib", this.clickedWidgetLib) .attr("clickedWidgetLib", this.clickedWidgetLib)
.attr("lastGuidePopUpTime", this.lastGuidePopUpTime); .attr("lastGuidePopUpTime", this.lastGuidePopUpTime)
.attr("historyCreatedReuses", this.historyCreatedReuses);;
writer.end(); writer.end();
} }

15
designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java

@ -32,11 +32,7 @@ public class ImageFileChooser {
new JavaFxNativeFileChooser.Builder(). new JavaFxNativeFileChooser.Builder().
fileSelectionMode(FileSelectionMode.FILE). fileSelectionMode(FileSelectionMode.FILE).
title(Toolkit.i18nText("Fine-Design_Basic_Open")). title(Toolkit.i18nText("Fine-Design_Basic_Open")).
filters(new FileChooser.ExtensionFilter[]{ filter(Toolkit.i18nText("Fine-Design_Basic_Image_Image_Files"), "*.jpg", "*.gif", "*.png", "*.bmp").
new FileChooser.ExtensionFilter("jpg", "*.jpg"),
new FileChooser.ExtensionFilter("gif", "*.gif"),
new FileChooser.ExtensionFilter("png", "*.png"),
new FileChooser.ExtensionFilter("bmp", "*.bmp")}).
build(); build();
} }
@ -72,8 +68,13 @@ public class ImageFileChooser {
private void showImageCompressMoveTip() { private void showImageCompressMoveTip() {
if (DesignerEnvManager.getEnvManager().isShowImageCompressMoveTip()) { if (DesignerEnvManager.getEnvManager().isShowImageCompressMoveTip()) {
DesignerToastMsgUtil.toastWarning(Toolkit.i18nText("Fine-Design_Image_Compress_Move_Tip")); SwingUtilities.invokeLater(new Runnable() {
DesignerEnvManager.getEnvManager().setShowImageCompressMoveTip(false); @Override
public void run() {
DesignerToastMsgUtil.toastWarning(Toolkit.i18nText("Fine-Design_Image_Compress_Move_Tip"));
DesignerEnvManager.getEnvManager().setShowImageCompressMoveTip(false);
}
});
} }
} }
} }

9
designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java

@ -11,7 +11,14 @@ import com.fr.stable.os.OperatingSystem;
public class ModernUIPaneFactory { public class ModernUIPaneFactory {
public static <T> ModernUIPane.Builder<T> modernUIPaneBuilder() { public static <T> ModernUIPane.Builder<T> modernUIPaneBuilder() {
if (OperatingSystem.isWindows()) { // 7.15的class不存在时 走老版本
boolean hasJxBrowserV7_15 = true;
try {
Class.forName("com.teamdev.jxbrowser.net.Scheme");
} catch (ClassNotFoundException e) {
hasJxBrowserV7_15 = false;
}
if (OperatingSystem.isWindows() && hasJxBrowserV7_15) {
return new NewModernUIPane.Builder<>(); return new NewModernUIPane.Builder<>();
} else { } else {
return new ModernUIPane.Builder<>(); return new ModernUIPane.Builder<>();

44
designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java

@ -16,15 +16,14 @@ import com.teamdev.jxbrowser.engine.Engine;
import com.teamdev.jxbrowser.engine.EngineOptions; import com.teamdev.jxbrowser.engine.EngineOptions;
import com.teamdev.jxbrowser.engine.RenderingMode; import com.teamdev.jxbrowser.engine.RenderingMode;
import com.teamdev.jxbrowser.js.JsObject; import com.teamdev.jxbrowser.js.JsObject;
import com.teamdev.jxbrowser.net.Network; import com.teamdev.jxbrowser.net.Scheme;
import com.teamdev.jxbrowser.net.callback.InterceptRequestCallback;
import com.teamdev.jxbrowser.view.swing.BrowserView; import com.teamdev.jxbrowser.view.swing.BrowserView;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Dimension; import java.awt.Dimension;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
@ -43,6 +42,8 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
private String namespace = "Pool"; private String namespace = "Pool";
private String variable = "data"; private String variable = "data";
private String expression = "update()"; private String expression = "update()";
private Scheme scheme;
private NxInterceptRequestCallback requestCallback;
private NewModernUIPane() { private NewModernUIPane() {
super(); super();
@ -96,7 +97,13 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
} }
private void initializeBrowser() { private void initializeBrowser() {
Engine engine = Engine.newInstance(EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").build()); EngineOptions options;
if (scheme != null && requestCallback != null) {
options = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").addScheme(scheme, requestCallback).build();
} else {
options = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").build();
}
Engine engine = Engine.newInstance(options);
browser = engine.newBrowser(); browser = engine.newBrowser();
// 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的 // 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的
@ -124,8 +131,9 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
*/ */
@Override @Override
public void redirect(String url, Map<String, String> map) { public void redirect(String url, Map<String, String> map) {
Network network = browser.engine().network(); if (requestCallback != null) {
network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network, map)); requestCallback.setMap(map);
}
browser.navigation().loadUrl(url); browser.navigation().loadUrl(url);
} }
@ -169,8 +177,8 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
*/ */
@Override @Override
public NewModernUIPane.Builder<T> withEMB(final String path) { public NewModernUIPane.Builder<T> withEMB(final String path) {
Network network = pane.browser.engine().network(); pane.scheme = Scheme.of("emb");
network.set(InterceptRequestCallback.class, new NxComplexInterceptRequestCallback(network, null)); pane.requestCallback = new NxComplexInterceptRequestCallback(null);
pane.browser.navigation().loadUrl("emb:" + path); pane.browser.navigation().loadUrl("emb:" + path);
return this; return this;
} }
@ -182,8 +190,8 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
*/ */
@Override @Override
public NewModernUIPane.Builder<T> withURL(final String url) { public NewModernUIPane.Builder<T> withURL(final String url) {
Network network = pane.browser.engine().network(); pane.scheme = Scheme.of("file");
network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network)); pane.requestCallback = new NxComplexInterceptRequestCallback(null);
pane.browser.navigation().loadUrl(url); pane.browser.navigation().loadUrl(url);
return this; return this;
} }
@ -195,8 +203,8 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
*/ */
@Override @Override
public NewModernUIPane.Builder<T> withURL(final String url, Map<String, String> map) { public NewModernUIPane.Builder<T> withURL(final String url, Map<String, String> map) {
Network network = pane.browser.engine().network(); pane.scheme = Scheme.of("file");
network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network, map)); pane.requestCallback = new NxInterceptRequestCallback(map);
pane.browser.navigation().loadUrl(url); pane.browser.navigation().loadUrl(url);
return this; return this;
} }
@ -208,8 +216,8 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
*/ */
@Override @Override
public NewModernUIPane.Builder<T> withComponent(AssembleComponent component) { public NewModernUIPane.Builder<T> withComponent(AssembleComponent component) {
Network network = pane.browser.engine().network(); pane.scheme = Scheme.of("emb");
network.set(InterceptRequestCallback.class, new NxComplexInterceptRequestCallback(network, component)); pane.requestCallback = new NxComplexInterceptRequestCallback(component);
pane.browser.navigation().loadUrl("emb:dynamic"); pane.browser.navigation().loadUrl("emb:dynamic");
return this; return this;
} }
@ -221,8 +229,8 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
*/ */
@Override @Override
public NewModernUIPane.Builder<T> withComponent(AssembleComponent component, Map<String, String> map) { public NewModernUIPane.Builder<T> withComponent(AssembleComponent component, Map<String, String> map) {
Network network = pane.browser.engine().network(); pane.scheme = Scheme.of("emb");
network.set(InterceptRequestCallback.class, new NxComplexInterceptRequestCallback(network, component, map)); pane.requestCallback = new NxComplexInterceptRequestCallback(component, map);
pane.browser.navigation().loadUrl("emb:dynamic"); pane.browser.navigation().loadUrl("emb:dynamic");
return this; return this;
} }
@ -235,8 +243,8 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
*/ */
@Override @Override
public NewModernUIPane.Builder<T> withHTML(String html) { public NewModernUIPane.Builder<T> withHTML(String html) {
Network network = pane.browser.engine().network(); pane.scheme = Scheme.of("html");
network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network)); pane.requestCallback = new NxInterceptRequestCallback();
pane.browser.mainFrame().ifPresent(frame -> { pane.browser.mainFrame().ifPresent(frame -> {
frame.loadHtml(html); frame.loadHtml(html);
}); });

16
designer-base/src/main/java/com/fr/design/ui/compatible/NxComplexInterceptRequestCallback.java

@ -9,9 +9,6 @@ import com.fr.web.struct.AtomBuilder;
import com.fr.web.struct.PathGroup; import com.fr.web.struct.PathGroup;
import com.fr.web.struct.category.ScriptPath; import com.fr.web.struct.category.ScriptPath;
import com.fr.web.struct.category.StylePath; import com.fr.web.struct.category.StylePath;
import com.teamdev.jxbrowser.net.Network;
import com.teamdev.jxbrowser.net.UrlRequest;
import com.teamdev.jxbrowser.net.callback.InterceptRequestCallback;
import java.io.InputStream; import java.io.InputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -26,21 +23,20 @@ public class NxComplexInterceptRequestCallback extends NxInterceptRequestCallbac
private AssembleComponent component; private AssembleComponent component;
public NxComplexInterceptRequestCallback(Network network, AssembleComponent component) { public NxComplexInterceptRequestCallback(AssembleComponent component) {
super(network);
this.component = component; this.component = component;
} }
public NxComplexInterceptRequestCallback(Network network, AssembleComponent component, Map<String, String> map) { public NxComplexInterceptRequestCallback(AssembleComponent component, Map<String, String> map) {
super(network, map); super(map);
this.component = component; this.component = component;
} }
@Override @Override
protected Response next(UrlRequest urlRequest, String path) { protected Response next(Params params, String path) {
if (path.startsWith("emb:dynamic")) { if (path.startsWith("emb:dynamic")) {
String text = htmlText(map); String text = htmlText(map);
return InterceptRequestCallback.Response.intercept(generateBasicUrlRequestJob(urlRequest, "text/html", text.getBytes(StandardCharsets.UTF_8))); return Response.intercept(generateBasicUrlRequestJob(params, "text/html", text.getBytes(StandardCharsets.UTF_8)));
} else { } else {
int index = path.indexOf("="); int index = path.indexOf("=");
if (index > 0) { if (index > 0) {
@ -52,7 +48,7 @@ public class NxComplexInterceptRequestCallback extends NxInterceptRequestCallbac
if (inputStream == null) { if (inputStream == null) {
return Response.proceed(); return Response.proceed();
} }
return InterceptRequestCallback.Response.intercept(generateBasicUrlRequestJob(urlRequest, getMimeType(path), IOUtils.inputStream2Bytes(inputStream))); return Response.intercept(generateBasicUrlRequestJob(params, getMimeType(path), IOUtils.inputStream2Bytes(inputStream)));
} }
} }

34
designer-base/src/main/java/com/fr/design/ui/compatible/NxInterceptRequestCallback.java

@ -9,11 +9,10 @@ import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.codec.net.URLCodec; import com.fr.third.org.apache.commons.codec.net.URLCodec;
import com.teamdev.jxbrowser.net.HttpHeader; import com.teamdev.jxbrowser.net.HttpHeader;
import com.teamdev.jxbrowser.net.HttpStatus; import com.teamdev.jxbrowser.net.HttpStatus;
import com.teamdev.jxbrowser.net.Network;
import com.teamdev.jxbrowser.net.UrlRequest; import com.teamdev.jxbrowser.net.UrlRequest;
import com.teamdev.jxbrowser.net.UrlRequestJob; import com.teamdev.jxbrowser.net.UrlRequestJob;
import com.teamdev.jxbrowser.net.callback.InterceptRequestCallback;
import com.teamdev.jxbrowser.net.callback.InterceptUrlRequestCallback;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -29,17 +28,14 @@ import java.util.Optional;
* @version 10.0 * @version 10.0
* Created by richie on 2020/3/25 * Created by richie on 2020/3/25
*/ */
public class NxInterceptRequestCallback implements InterceptRequestCallback { public class NxInterceptRequestCallback implements InterceptUrlRequestCallback {
Network network;
Map<String, String> map; Map<String, String> map;
public NxInterceptRequestCallback(Network network) { public NxInterceptRequestCallback() {
this.network = network;
} }
public NxInterceptRequestCallback(Network network, Map<String, String> map) { public NxInterceptRequestCallback(Map<String, String> map) {
this.network = network;
this.map = map; this.map = map;
} }
@ -48,21 +44,21 @@ public class NxInterceptRequestCallback implements InterceptRequestCallback {
UrlRequest urlRequest = params.urlRequest(); UrlRequest urlRequest = params.urlRequest();
String path = urlRequest.url(); String path = urlRequest.url();
if (path.startsWith("file:")) { if (path.startsWith("file:")) {
Optional<UrlRequestJob> optional = generateFileProtocolUrlRequestJob(urlRequest, path); Optional<UrlRequestJob> optional = generateFileProtocolUrlRequestJob(params, path);
if (optional.isPresent()) { if (optional.isPresent()) {
return InterceptRequestCallback.Response.intercept(optional.get()); return Response.intercept(optional.get());
} }
} else { } else {
return next(urlRequest, path); return next(params, path);
} }
return Response.proceed(); return Response.proceed();
} }
Response next(UrlRequest urlRequest, String path) { Response next(Params params, String path) {
return Response.proceed(); return Response.proceed();
} }
private Optional<UrlRequestJob> generateFileProtocolUrlRequestJob(UrlRequest urlRequest, String path) { private Optional<UrlRequestJob> generateFileProtocolUrlRequestJob(Params params, String path) {
try { try {
String url = new URLCodec().decode(path); String url = new URLCodec().decode(path);
String filePath = TemplateUtils.renderParameter4Tpl(url, map); String filePath = TemplateUtils.renderParameter4Tpl(url, map);
@ -77,7 +73,7 @@ public class NxInterceptRequestCallback implements InterceptRequestCallback {
} else { } else {
bytes = IOUtils.inputStream2Bytes(inputStream); bytes = IOUtils.inputStream2Bytes(inputStream);
} }
return Optional.of(generateBasicUrlRequestJob(urlRequest, mimeType, bytes)); return Optional.of(generateBasicUrlRequestJob(params, mimeType, bytes));
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
@ -88,12 +84,12 @@ public class NxInterceptRequestCallback implements InterceptRequestCallback {
return ArrayUtils.contains(new String[]{"text/html", "text/javascript", "text/css"}, mimeType); return ArrayUtils.contains(new String[]{"text/html", "text/javascript", "text/css"}, mimeType);
} }
UrlRequestJob generateBasicUrlRequestJob(UrlRequest urlRequest, String mimeType, byte[] bytes) { UrlRequestJob generateBasicUrlRequestJob(Params params, String mimeType, byte[] bytes) {
UrlRequestJob.Options options = UrlRequestJob.Options UrlRequestJob.Options options = UrlRequestJob.Options
.newBuilder(urlRequest.id(), HttpStatus.OK) .newBuilder(HttpStatus.OK)
.addHttpHeader(HttpHeader.of("Content-Type", mimeType)) .addHttpHeader(HttpHeader.of("Content-Type", mimeType))
.build(); .build();
UrlRequestJob urlRequestJob = network.newUrlRequestJob(options); UrlRequestJob urlRequestJob = params.newUrlRequestJob(options);
urlRequestJob.write(bytes); urlRequestJob.write(bytes);
urlRequestJob.complete(); urlRequestJob.complete();
return urlRequestJob; return urlRequestJob;
@ -145,4 +141,8 @@ public class NxInterceptRequestCallback implements InterceptRequestCallback {
return "text/html"; return "text/html";
} }
} }
public void setMap(Map<String, String> map) {
this.map = map;
}
} }

3
designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java

@ -7,6 +7,7 @@ import com.fr.design.dialog.NotificationDialogAction;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.RemoteWorkspace; import com.fr.design.env.RemoteWorkspace;
import com.fr.design.i18n.DesignSizeI18nManager;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.env.CheckServiceDialog; import com.fr.env.CheckServiceDialog;
@ -107,7 +108,7 @@ public class VersionCheckUtils {
CheckServiceDialog checkServiceDialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), GeneralUtils.readFullBuildNO(), getRemoteBranch(envName), getNoExistServiceDescription(envName)); CheckServiceDialog checkServiceDialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), GeneralUtils.readFullBuildNO(), getRemoteBranch(envName), getNoExistServiceDescription(envName));
checkServiceDialog.setVisible(true); checkServiceDialog.setVisible(true);
} }
}); },DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.version.check.dialog"));
notificationDialog.setVisible(true); notificationDialog.setVisible(true);
} }

30
designer-base/src/main/java/com/fr/env/HelpLink.java vendored

@ -0,0 +1,30 @@
package com.fr.env;
import com.fr.general.locale.LocaleCenter;
import com.fr.general.locale.LocaleMark;
import com.fr.locale.InterProviderFactory;
import com.fr.stable.StringUtils;
import java.util.HashMap;
import java.util.Map;
/**
* 错误提示中的跳转链接管理
*
* @author hades
* @version 10.0
* Created by hades on 2021/8/9
*/
public class HelpLink {
public static String getLink(String solution) {
Map<String, String> map = new HashMap<>();
LocaleMark<String> linkMark = LocaleCenter.getMark(RemoteDesignLocaleMark.class);
String link = linkMark.getValue();
map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Change_PassWord"), StringUtils.EMPTY);
map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Cert_Error_Solution"), link);
map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Connection_Unknown_Error_Solution"), link);
map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_NetWork_Connection_Error_Solution"), link);
return map.get(solution);
}
}

36
designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java vendored

@ -0,0 +1,36 @@
package com.fr.env;
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
* @version 10.0
* Created by hades on 2021/8/9
*/
public class RemoteDesignLocaleMark implements LocaleMark<String> {
private Map<Locale, String> map = new HashMap<>();
private static final String REMOTE_DESIGN_CN = CloudCenter.getInstance().acquireUrlByKind("help.remote.design.zh_CN", "https://help.fanruan.com/finereport/doc-view-3925.html");
private static final String REMOTE_DESIGN_EN = CloudCenter.getInstance().acquireUrlByKind("help.remote.design.en_US", "https://help.fanruan.com/finereport-en/doc-view-3862.html");
public RemoteDesignLocaleMark() {
map.put(Locale.CHINA, REMOTE_DESIGN_CN);
map.put(Locale.KOREA, REMOTE_DESIGN_EN);
map.put(Locale.JAPAN, REMOTE_DESIGN_EN);
map.put(Locale.US, REMOTE_DESIGN_EN);
map.put(Locale.TAIWAN, REMOTE_DESIGN_CN);
}
@Override
public String getValue() {
String result = map.get(GeneralContext.getLocale());
return result == null ? REMOTE_DESIGN_CN : result;
}
}

48
designer-base/src/main/java/com/fr/env/RemoteEnvPane.java vendored

@ -4,8 +4,6 @@ import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.border.UITitledBorder; import com.fr.design.border.UITitledBorder;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.fun.DesignerEnvProcessor; import com.fr.design.fun.DesignerEnvProcessor;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
@ -22,17 +20,12 @@ import com.fr.design.i18n.DesignSizeI18nManager;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.scrollruler.ModLineBorder; import com.fr.design.scrollruler.ModLineBorder;
import com.fr.license.exception.RegistEditionException; import com.fr.env.handler.RemoteDesignExceptionHandler;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.guava.base.Strings; import com.fr.third.guava.base.Strings;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.exception.WorkspaceAuthException;
import com.fr.workspace.engine.exception.WorkspaceCheckException;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
@ -66,9 +59,7 @@ import java.io.File;
import static com.fr.design.layout.TableLayout.FILL; import static com.fr.design.layout.TableLayout.FILL;
import static com.fr.design.layout.TableLayout.PREFERRED; import static com.fr.design.layout.TableLayout.PREFERRED;
import static com.fr.env.TestConnectionResult.AUTH_FAILED;
import static com.fr.third.guava.base.Optional.fromNullable; import static com.fr.third.guava.base.Optional.fromNullable;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
/** /**
* @author yaohwu * @author yaohwu
@ -573,8 +564,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
fileChooserButton.addActionListener(new ActionListener() { fileChooserButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder(). FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder().fileSelectionMode(FileSelectionMode.FILE).build();
fileSelectionMode(FileSelectionMode.FILE).build();
int saveValue = fileChooserProvider.showDialog(SwingUtilities.getWindowAncestor(RemoteEnvPane.this)); int saveValue = fileChooserProvider.showDialog(SwingUtilities.getWindowAncestor(RemoteEnvPane.this));
if (saveValue == JFileChooser.APPROVE_OPTION) { if (saveValue == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooserProvider.getSelectedFile(); File selectedFile = fileChooserProvider.getSelectedFile();
@ -589,42 +579,24 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
final RemoteDesignerWorkspaceInfo remoteEnv = updateBean(); final RemoteDesignerWorkspaceInfo remoteEnv = updateBean();
final WorkspaceConnectionInfo connection = remoteEnv.getConnection(); final WorkspaceConnectionInfo connection = remoteEnv.getConnection();
final SwingWorker<TestConnectionResult, Void> worker = new SwingWorker<TestConnectionResult, Void>() { final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
@Override @Override
protected TestConnectionResult doInBackground() throws Exception { protected Boolean doInBackground() throws Exception {
try { return WorkContext.getConnector().testConnection(connection);
return TestConnectionResult.parse(WorkContext.getConnector().testConnection(connection), connection);
} catch (WorkspaceAuthException ignored) {
return AUTH_FAILED;
} catch (RegistEditionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
throw e;
} catch (WorkspaceCheckException e) {
return TestConnectionResult.parseByException(e);
}
} }
@Override @Override
protected void done() { protected void done() {
okButton.setEnabled(true); okButton.setEnabled(true);
try { try {
TestConnectionResult result = get(); if (get()) {
if (result.isVerifyResult()) { message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Successful"));
dialog.dispose(); uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
FineLoggerFactory.getLogger().error(result.getText().replaceAll(TestConnectionResult.WRAP, StringUtils.EMPTY) + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"));
FineJOptionPane.showMessageDialog(RemoteEnvPane.this,
new MessageWithLink(result.getText(), Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"), connection.getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH),
Toolkit.i18nText("Fine-Design_Basic_Dialog_Message_Title"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
} }
message.setText(result.getText());
uiLabel.setIcon(result.getIcon());
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage()); dialog.dispose();
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed")); RemoteDesignExceptionHandler.getInstance().handleInTest(e, remoteEnv);
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
} }
dialogDownPane.remove(cancelButton); dialogDownPane.remove(cancelButton);
dialogDownPane.revalidate(); dialogDownPane.revalidate();

16
designer-base/src/main/java/com/fr/env/handler/Handler.java vendored

@ -0,0 +1,16 @@
package com.fr.env.handler;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public interface Handler<T, R> {
/**
* @param t
* @return 是否需要继续处理
*/
R handle(T t);
}

28
designer-base/src/main/java/com/fr/env/handler/RefWrapper.java vendored

@ -0,0 +1,28 @@
package com.fr.env.handler;
/**
*
* @author hades
* @version 10.0
* Created by hades on 2021/8/11
*/
public class RefWrapper {
private final Throwable throwable;
private final String link;
public RefWrapper(Throwable throwable, String link) {
this.throwable = throwable;
this.link = link;
}
public Throwable getThrowable() {
return throwable;
}
public String getLink() {
return link;
}
}

90
designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java vendored

@ -0,0 +1,90 @@
package com.fr.env.handler;
import com.fr.design.EnvChangeEntrance;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.i18n.Toolkit;
import com.fr.env.RemoteWorkspaceURL;
import com.fr.env.handler.impl.CancelHandler;
import com.fr.env.handler.impl.CommonHandler;
import com.fr.env.handler.impl.ExecutionHandler;
import com.fr.env.handler.impl.UnexpectedHandler;
import com.fr.log.FineLoggerFactory;
import java.util.ArrayList;
import java.util.List;
import javax.swing.UIManager;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public class RemoteDesignExceptionHandler {
private static final RemoteDesignExceptionHandler INSTANCE = new RemoteDesignExceptionHandler();
public static RemoteDesignExceptionHandler getInstance() {
return INSTANCE;
}
private final List<Handler<RefWrapper, ResultWrapper>> testList = new ArrayList<>();
private final List<Handler<RefWrapper, ResultWrapper>> switchList = new ArrayList<>();
private RemoteDesignExceptionHandler() {
// 要保证顺序
testList.add(new CancelHandler());
testList.add(new ExecutionHandler());
testList.add(new UnexpectedHandler());
testList.add(new CommonHandler(false));
switchList.add(new CancelHandler());
switchList.add(new ExecutionHandler());
switchList.add(new UnexpectedHandler());
switchList.add(new CommonHandler(true));
}
public void handle(Throwable e, List<Handler<RefWrapper, ResultWrapper>> list, DesignerWorkspaceInfo workspaceInfo) {
Throwable throwable = e;
ResultWrapper wrapper;
String link = workspaceInfo.getConnection().getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH;
for (Handler<RefWrapper, ResultWrapper> handler : list) {
wrapper = handler.handle(new RefWrapper(throwable, link));
throwable = wrapper.getThrowable();
if (!wrapper.isNext()) {
break;
}
}
FineLoggerFactory.getLogger().error(throwable.getMessage(), throwable);
}
public void handleInSwitch(Throwable e, DesignerWorkspaceInfo workspaceInfo) {
if (workspaceInfo == null || workspaceInfo.getType() == DesignerWorkspaceType.Local) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineJOptionPane.showMessageDialog(EnvChangeEntrance.getInstance().getDialog(),
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
return;
}
handle(e, switchList, workspaceInfo);
}
public void handleInStart(Throwable e, DesignerWorkspaceInfo workspaceInfo) {
if (workspaceInfo == null || workspaceInfo.getType() == DesignerWorkspaceType.Local) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return;
}
handle(e, testList, workspaceInfo);
}
public void handleInTest(Throwable e, DesignerWorkspaceInfo workspaceInfo) {
handle(e, testList, workspaceInfo);
}
}

30
designer-base/src/main/java/com/fr/env/handler/ResultWrapper.java vendored

@ -0,0 +1,30 @@
package com.fr.env.handler;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public class ResultWrapper {
private final boolean next;
private final Throwable throwable;
public ResultWrapper(Throwable throwable) {
this(true, throwable);
}
public ResultWrapper(boolean next, Throwable e) {
this.next = next;
this.throwable = e;
}
public boolean isNext() {
return next;
}
public Throwable getThrowable() {
return throwable;
}
}

22
designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java vendored

@ -0,0 +1,22 @@
package com.fr.env.handler.impl;
import com.fr.env.handler.Handler;
import com.fr.env.handler.RefWrapper;
import com.fr.env.handler.ResultWrapper;
import java.util.concurrent.CancellationException;
/**
* 取消测试连接时的处理器
*
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public class CancelHandler implements Handler<RefWrapper, ResultWrapper> {
@Override
public ResultWrapper handle(RefWrapper wrapper) {
Throwable e = wrapper.getThrowable();
return new ResultWrapper(!(e instanceof CancellationException), e);
}
}

52
designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java vendored

@ -0,0 +1,52 @@
package com.fr.env.handler.impl;
import com.fr.base.exception.ExceptionDescriptor;
import com.fr.design.EnvChangeEntrance;
import com.fr.design.dialog.UIDetailErrorLinkDialog;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.env.HelpLink;
import com.fr.env.handler.Handler;
import com.fr.env.handler.RefWrapper;
import com.fr.env.handler.ResultWrapper;
import com.fr.stable.StringUtils;
import javax.swing.SwingUtilities;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public class CommonHandler implements Handler<RefWrapper, ResultWrapper> {
private final boolean onSwitch;
public CommonHandler(boolean onSwitch) {
this.onSwitch = onSwitch;
}
@Override
public ResultWrapper handle(RefWrapper wrapper) {
Throwable e = wrapper.getThrowable();
if (e instanceof ExceptionDescriptor) {
ExceptionDescriptor exceptionDescriptor = (ExceptionDescriptor) e;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String link = HelpLink.getLink(exceptionDescriptor.solution());
UIDetailErrorLinkDialog detailErrorLinkDialog = UIDetailErrorLinkDialog.newBuilder().
setWindow(onSwitch ? DesignerContext.getDesignerFrame() : EnvChangeEntrance.getInstance().getDialog()).
setErrorCode(exceptionDescriptor.errorCode()).
setReason(exceptionDescriptor.reason()).
setSolution(exceptionDescriptor.solution()).
setDetailReason(exceptionDescriptor.detailReason()).
setTitle(Toolkit.i18nText("Fine-Design_Basic_Connection_Failed")).
setLink(StringUtils.isEmpty(link) ? wrapper.getLink() : link).
setThrowable(e).build();
detailErrorLinkDialog.setVisible(true);
}
});
}
return new ResultWrapper(e);
}
}

23
designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java vendored

@ -0,0 +1,23 @@
package com.fr.env.handler.impl;
import com.fr.env.handler.Handler;
import com.fr.env.handler.RefWrapper;
import com.fr.env.handler.ResultWrapper;
import java.util.concurrent.ExecutionException;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public class ExecutionHandler implements Handler<RefWrapper, ResultWrapper> {
@Override
public ResultWrapper handle(RefWrapper wrapper) {
Throwable e = wrapper.getThrowable();
if (e instanceof ExecutionException) {
return new ResultWrapper(e.getCause());
}
return new ResultWrapper(e);
}
}

26
designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java vendored

@ -0,0 +1,26 @@
package com.fr.env.handler.impl;
import com.fr.base.exception.ExceptionDescriptor;
import com.fr.env.handler.Handler;
import com.fr.env.handler.RefWrapper;
import com.fr.env.handler.ResultWrapper;
import com.fr.workspace.engine.convert.ExceptionConverter;
/**
* 出现预料之外的情况异常处理器
*
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public class UnexpectedHandler implements Handler<RefWrapper, ResultWrapper> {
@Override
public ResultWrapper handle(RefWrapper wrapper) {
Throwable e = wrapper.getThrowable();
if (!(e instanceof ExceptionDescriptor)) {
return new ResultWrapper(ExceptionConverter.getInstance().convert(e)) ;
}
return new ResultWrapper(e);
}
}

1
designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties

@ -4,3 +4,4 @@ com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=630*31
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=630*280 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=630*280
com.fr.design.report.ReportColumnsPane=800*600 com.fr.design.report.ReportColumnsPane=800*600
com.fr.env.RemoteEnvPane.dialog=458*132 com.fr.env.RemoteEnvPane.dialog=458*132
com.fr.design.version.check.dialog=490*95

1
designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties

@ -3,3 +3,4 @@ com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=610*185
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=610*31 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=610*31
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=610*280 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=610*280
com.fr.env.RemoteEnvPane.dialog=458*132 com.fr.env.RemoteEnvPane.dialog=458*132
com.fr.design.version.check.dialog=430*95

1
designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties

@ -3,3 +3,4 @@ com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=490*185
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=490*35 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=490*35
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=490*280 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=490*280
com.fr.env.RemoteEnvPane.dialog=458*132 com.fr.env.RemoteEnvPane.dialog=458*132
com.fr.design.version.check.dialog=450*95

1
designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties

@ -4,3 +4,4 @@ com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=385*185
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=385*31 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=385*31
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=385*280 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=385*280
com.fr.env.RemoteEnvPane.dialog=308*132 com.fr.env.RemoteEnvPane.dialog=308*132
com.fr.design.version.check.dialog=230*95

1
designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties

@ -3,3 +3,4 @@ com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=385*185
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=385*31 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=385*31
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=385*280 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=385*280
com.fr.env.RemoteEnvPane.dialog=308*132 com.fr.env.RemoteEnvPane.dialog=308*132
com.fr.design.version.check.dialog=230*95

21
designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java vendored

@ -4,7 +4,10 @@ import com.fr.invoke.Reflect;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReaderHelper; import com.fr.stable.xml.XMLReaderHelper;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.WorkspaceClient;
import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.connect.WorkspaceConnector;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.junit.Assert; import org.junit.Assert;
@ -18,15 +21,31 @@ import java.io.ByteArrayOutputStream;
*/ */
public class RemoteDesignerWorkspaceInfoTest extends TestCase { public class RemoteDesignerWorkspaceInfoTest extends TestCase {
public void testCheckValid() { public void testCheckValid() throws Exception {
RemoteDesignerWorkspaceInfo workspaceInfo0 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("http://localhost:8075/webroot/decision", "admin", "123", "", "", true)); RemoteDesignerWorkspaceInfo workspaceInfo0 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("http://localhost:8075/webroot/decision", "admin", "123", "", "", true));
RemoteDesignerWorkspaceInfo workspaceInfo1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("http://127.0.0.1:8075/webroot/decision", "admin", "123", "", "", true)); RemoteDesignerWorkspaceInfo workspaceInfo1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("http://127.0.0.1:8075/webroot/decision", "admin", "123", "", "", true));
RemoteDesignerWorkspaceInfo workspaceInfo2 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("https://127.0.0.1:8075/webroot/decision", "admin", "123", "", "", true)); RemoteDesignerWorkspaceInfo workspaceInfo2 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("https://127.0.0.1:8075/webroot/decision", "admin", "123", "", "", true));
RemoteDesignerWorkspaceInfo workspaceInfo3 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("https://localhost:8075/webroot/decision", "admin", "123", "", "", true)); RemoteDesignerWorkspaceInfo workspaceInfo3 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("https://localhost:8075/webroot/decision", "admin", "123", "", "", true));
WorkspaceConnector connector = WorkContext.getConnector();
WorkspaceConnector workspaceConnector = new WorkspaceConnector() {
@Override
public boolean testConnection(WorkspaceConnectionInfo connection) throws Exception {
return false;
}
@Override
public WorkspaceClient connect(WorkspaceConnectionInfo connection) throws Exception {
return null;
}
};
WorkContext.setConnector(workspaceConnector);
Assert.assertFalse(workspaceInfo0.checkValid()); Assert.assertFalse(workspaceInfo0.checkValid());
Assert.assertFalse(workspaceInfo1.checkValid()); Assert.assertFalse(workspaceInfo1.checkValid());
Assert.assertFalse(workspaceInfo2.checkValid()); Assert.assertFalse(workspaceInfo2.checkValid());
Assert.assertFalse(workspaceInfo3.checkValid()); Assert.assertFalse(workspaceInfo3.checkValid());
WorkContext.setConnector(connector);
} }
public void testReadXml() { public void testReadXml() {

204
designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java

@ -8,110 +8,122 @@ import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.base.background.ColorBackground; import com.fr.base.background.ColorBackground;
import com.fr.chart.chartglyph.Marker; import com.fr.chart.chartglyph.Marker;
import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.ConfigHelper;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.plugin.chart.ConfigHelper;
import javax.swing.DefaultComboBoxModel;
import javax.swing.*; import javax.swing.JLabel;
import java.awt.*; import javax.swing.JList;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
/** /**
* Combobox for selecting marker. * Combobox for selecting marker.
*/ */
public class MarkerComboBox extends UIComboBox { public class MarkerComboBox extends UIComboBox {
private static final double TEXT_X_COORDINATES = 12d; private static final double TEXT_X_COORDINATES = 12d;
/** /**
* Constructor. * Constructor.
* *
* @param markerArray the array of marker. * @param markerArray the array of marker.
*/ */
public MarkerComboBox(Marker[] markerArray) { public MarkerComboBox(Marker[] markerArray) {
this.setModel(new DefaultComboBoxModel(markerArray)); this.setModel(new DefaultComboBoxModel(markerArray));
this.setRenderer(new MarkerCellRenderer()); this.setRenderer(new MarkerCellRenderer());
} }
/** /**
* Get selected marker. * Get selected marker.
*/ */
public Marker getSelectedMarkder() { public Marker getSelectedMarkder() {
return (Marker) getSelectedItem(); return (Marker) getSelectedItem();
} }
/** /**
* Set the selected marker. * Set the selected marker.
*/ */
public void setSelectedMarker(Marker marker) { public void setSelectedMarker(Marker marker) {
setSelectedItem(marker); setSelectedItem(marker);
} }
/** /**
* CellRenderer. * CellRenderer.
*/ */
class MarkerCellRenderer extends UIComboBoxRenderer { class MarkerCellRenderer extends UIComboBoxRenderer {
public Component getListCellRendererComponent(JList list,
Object value, int index, boolean isSelected, boolean cellHasFocus) { private Marker marker = null;
this.marker = (Marker) value; private boolean isSelected = false;
this.isSelected = isSelected;
public Component getListCellRendererComponent(JList list,
return this; Object value, int index, boolean isSelected, boolean cellHasFocus) {
} this.marker = (Marker) value;
this.isSelected = isSelected;
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g; String text = null;
if (marker != null) {
Dimension d = getSize(); boolean isAutoMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.AUTO_M);
g2d.setColor(Color.black); boolean isNullMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.NULL_M);
g2d.setFont(FRContext.getDefaultValues().getFRFont()); if (isAutoMarker || isNullMarker) {
text = isNullMarker
if (marker != null) { ? Toolkit.i18nText("Fine-Design_Report_None")
boolean isAutoMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.AUTO_M); : Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto");
boolean isNullMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.NULL_M); }
}
if (isAutoMarker || isNullMarker) { JLabel comp = (JLabel) super.getListCellRendererComponent(list, text, index, isSelected, cellHasFocus);
String text = isNullMarker return comp;
?Toolkit.i18nText("Fine-Design_Report_None") }
:Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto");
public void paint(Graphics g) {
paintTextMarker(g2d, d, text); Graphics2D g2d = (Graphics2D) g;
} else { Dimension d = getSize();
if (marker.getBackground() == null) { if (marker != null) {
marker.setBackground(ColorBackground.getInstance(Color.black)); boolean isAutoMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.AUTO_M);
} boolean isNullMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.NULL_M);
marker.paint(g2d, d.width / 2, d.height / 2); if (isAutoMarker || isNullMarker) {
} super.paint(g);
} } else {
g2d.setColor(Color.black);
if (isSelected) { if (marker.getBackground() == null) {
g2d.setColor(Color.blue); marker.setBackground(ColorBackground.getInstance(Color.black));
GraphHelper.drawRect(g2d, 0, 0, d.width - 1, d.height - 1); }
} marker.paint(g2d, d.width / 2, d.height / 2);
} }
}
public Dimension getPreferredSize() {
return new Dimension(36, 16); if (isSelected) {
} g2d.setColor(Color.blue);
GraphHelper.drawRect(g2d, 0, 0, d.width - 1, d.height - 1);
public Dimension getMinimumSize() { }
return getPreferredSize(); }
}
public Dimension getPreferredSize() {
private Marker marker = null; return new Dimension(36, 16);
private boolean isSelected = false; }
private void paintTextMarker(Graphics2D g2d, Dimension d, String text) { public Dimension getMinimumSize() {
g2d.setColor(Color.black); return getPreferredSize();
FRFont font = FRContext.getDefaultValues().getFRFont(); }
int resolution = ScreenResolution.getScreenResolution();
Font rfont = font.applyResolutionNP(resolution);
g2d.setFont(rfont); private void paintTextMarker(Graphics2D g2d, Dimension d, String text) {
FontMetrics fm = GraphHelper.getFontMetrics(rfont); g2d.setColor(Color.black);
FRFont font = FRContext.getDefaultValues().getFRFont();
GraphHelper.drawString(g2d, text, TEXT_X_COORDINATES, (d.height - fm.getHeight()) / 2 + fm.getAscent()); int resolution = ScreenResolution.getScreenResolution();
} Font rfont = font.applyResolutionNP(resolution);
} g2d.setFont(rfont);
FontMetrics fm = GraphHelper.getFontMetrics(rfont);
GraphHelper.drawString(g2d, text, TEXT_X_COORDINATES, (d.height - fm.getHeight()) / 2 + fm.getAscent());
}
}
} }

10
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java

@ -277,11 +277,11 @@ public class UIColorPickerPane extends BasicPane implements UIObserver {
*/ */
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
if (designTypeButtonGroup.getSelectedIndex() == 0) { if (designTypeButtonGroup.getSelectedIndex() == 0) {
return new Dimension(colorGroup.getPreferredSize().width + textGroup.getPreferredSize().width, upControlPane.getPreferredSize().height + getBoundY()); return new Dimension(colorGroup.getPreferredSize().width + textGroup.getPreferredSize().width, upControlPane.getPreferredSize().height + getPreferredMarginY());
} else { } else {
int extra = stagePanel == null ? 0 : stagePanel.getPreferredSize().height + getBoundY(); int extra = stagePanel == null ? 0 : stagePanel.getPreferredSize().height + getPreferredMarginY();
return new Dimension(colorGroup.getPreferredSize().width + textGroup.getPreferredSize().width, return new Dimension(colorGroup.getPreferredSize().width + textGroup.getPreferredSize().width,
extra + textGroup.getPreferredSize().height + upControlPane.getPreferredSize().height + OFF_HEIGHT + getBoundY()); extra + textGroup.getPreferredSize().height + upControlPane.getPreferredSize().height + OFF_HEIGHT + getPreferredMarginY());
} }
} }
@ -662,6 +662,10 @@ public class UIColorPickerPane extends BasicPane implements UIObserver {
return UPCONTROLPANE_WIDTH; return UPCONTROLPANE_WIDTH;
} }
protected int getPreferredMarginY() {
return MARGIN_TOP;
}
/** /**
*刷新颜色选取器 *刷新颜色选取器
* @param colorArray 颜色值 * @param colorArray 颜色值

17
designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java

@ -1,12 +1,9 @@
package com.fr.van.chart.designer.component; package com.fr.van.chart.designer.component;
import com.fr.base.FRContext;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.general.FRFont;
import com.fr.plugin.chart.type.LineType; import com.fr.plugin.chart.type.LineType;
import com.fr.stable.Constants; import com.fr.stable.Constants;
@ -14,8 +11,6 @@ import javax.swing.JLabel;
import javax.swing.JList; import javax.swing.JList;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
@ -37,9 +32,9 @@ public class LineTypeComboBox extends UIComboBox {
public Component getListCellRendererComponent( public Component getListCellRendererComponent(
JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
this.lineType = (LineType) value; this.lineType = (LineType) value;
comp.setText(null); value = lineType == LineType.NONE ? Toolkit.i18nText("Fine-Design_Report_None") : null;
JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
return comp; return comp;
} }
@ -51,14 +46,6 @@ public class LineTypeComboBox extends UIComboBox {
g2d.setColor(getForeground()); g2d.setColor(getForeground());
switch (this.lineType) { switch (this.lineType) {
case NONE:
FRFont font = FRContext.getDefaultValues().getFRFont();
int resolution = ScreenResolution.getScreenResolution();
Font rfont = font.applyResolutionNP(resolution);
g2d.setFont(rfont);
FontMetrics fm = GraphHelper.getFontMetrics(rfont);
GraphHelper.drawString(g2d, Toolkit.i18nText("Fine-Design_Report_None"), 4, (d.height - fm.getHeight()) / 2 + fm.getAscent());
break;
case SOLID: case SOLID:
GraphHelper.drawLine(g2d, 4, d.height / 2, d.width - 8, d.height / 2); GraphHelper.drawLine(g2d, 4, d.height / 2, d.width - 8, d.height / 2);
break; break;

4
designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java

@ -132,6 +132,10 @@ public class VanChartGaugeSeriesPane extends VanChartMultiColorSeriesPane {
return 10; return 10;
} }
protected int getPreferredMarginY() {
return 10;
}
protected double getDescriptionWidth() { protected double getDescriptionWidth() {
double descriptionWidth = super.getDescriptionWidth(); double descriptionWidth = super.getDescriptionWidth();
if (valueFillStylePane == null) { if (valueFillStylePane == null) {

7
designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java

@ -865,4 +865,11 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public boolean isParentAbsolute() { public boolean isParentAbsolute() {
return ((XCreator) this.getParent()).acceptType(XWAbsoluteLayout.class); return ((XCreator) this.getParent()).acceptType(XWAbsoluteLayout.class);
} }
public int getLevel() {
if (this.getParent() == null) {
return 1;
}
return ((XCreator) this.getParent()).getLevel() + 1;
}
} }

3
designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java

@ -318,6 +318,8 @@ public class EditingMouseListener extends MouseInputAdapter {
offsetEventPoint(e); offsetEventPoint(e);
XCreator component = designer.getComponentAt(e); XCreator component = designer.getComponentAt(e);
designer.getSpacingLineDrawer().updateMouseEvent(e, true);
setCoverPaneNotDisplay(component, e, false); setCoverPaneNotDisplay(component, e, false);
if (processTopLayoutMouseMove(component, e)) { if (processTopLayoutMouseMove(component, e)) {
@ -353,7 +355,6 @@ public class EditingMouseListener extends MouseInputAdapter {
return; return;
} }
designer.getSpacingLineDrawer().updateMouseEvent(e, true);
processChartEditorMouseMove(component, e); processChartEditorMouseMove(component, e);
e.translatePoint(oldX - e.getX(), oldY - e.getY()); e.translatePoint(oldX - e.getX(), oldY - e.getY());
designer.repaint(); designer.repaint();

65
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -835,6 +835,38 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return null; return null;
} }
/**
* 从root里面查找层级为level的控件
*/
private XCreator xCreatorAt(int x, int y, XCreator root, int level) {
if (root == null || !root.isVisible()) {
return null;
}
x -= root.getX();
y -= root.getY();
if (root instanceof XLayoutContainer) {
XLayoutContainer rootContainer = (XLayoutContainer) root;
int count = rootContainer.getXCreatorCount();
for (int i = 0; i < count; i++) {
XCreator child = rootContainer.getXCreator(i);
XCreator dest = xCreatorAt(x, y, child, level);
if (dest != null && dest.getLevel() == level) {
return dest;
}
}
}
Rectangle rect = ComponentUtils.computeVisibleRect(root);
if (isIntersectArea(x, y, rect)) {
// 判断是否处于交叉区域
return root;
}
return null;
}
/** /**
* 从已选择的组件中找x,y所在的组件 * 从已选择的组件中找x,y所在的组件
*/ */
@ -1095,25 +1127,38 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
* */ * */
@Override @Override
public XCreator getComponentAt(int x, int y) { public XCreator getComponentAt(int x, int y) {
XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent; XLayoutContainer container = getRootContainer(y);
if (container == null) { XCreator result = xCreatorAt(getRelativeScaleX(x) - container.getX(), getRelativeScaleY(y) - container.getY(), container);
container = rootComponent;
}
int relativeX = x + (int) (formArea.getHorizontalValue() / scale) - container.getX();
int relativeY = y + (int) (formArea.getVerticalValue() / scale) - container.getY();
XCreator result = xCreatorAt(relativeX, relativeY, container);
return result == null ? getComponentAt(x, y, null) : result; return result == null ? getComponentAt(x, y, null) : result;
} }
@Nullable @Nullable
public XCreator getComponentAt(int x, int y, XCreator[] except) { public XCreator getComponentAt(int x, int y, XCreator[] except) {
XLayoutContainer container = getRootContainer(y);
XCreator comp = xCreatorAt(getRelativeScaleX(x), getRelativeScaleY(y), container, except);
return comp == null ? container : comp;
}
public XCreator getComponentAt(int x, int y, int level) {
XLayoutContainer container = getRootContainer(y);
XCreator comp = xCreatorAt(getRelativeScaleX(x), getRelativeScaleY(y), container, level);
return comp == null ? container : comp;
}
private XLayoutContainer getRootContainer(int y) {
XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent; XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent;
if (container == null) { if (container == null) {
container = rootComponent; container = rootComponent;
} }
XCreator comp = xCreatorAt(x + (int)(formArea.getHorizontalValue()/scale), (int)(y + formArea.getVerticalValue()/scale), container, return container;
except); }
return comp == null ? container : comp;
private int getRelativeScaleX(int x) {
return x + (int)(formArea.getHorizontalValue() / scale);
}
private int getRelativeScaleY(int y) {
return y + (int)(formArea.getVerticalValue() / scale);
} }
public SelectionModel getSelectionModel() { public SelectionModel getSelectionModel() {

41
designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.utils.ComponentUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.GraphDrawHelper; import com.fr.stable.GraphDrawHelper;
@ -21,8 +22,9 @@ public class FormSpacingLineDrawer {
private static final int MIN_SPACING = 10; private static final int MIN_SPACING = 10;
private FormDesigner designer; private FormDesigner designer;
private XCreator hoverCreator; private XCreator hoverCreator = null;
private Rectangle selectedRec; private Rectangle selectedRec;
private Rectangle hoveredRec;
private boolean isMouseMoveEvent = false; private boolean isMouseMoveEvent = false;
public FormSpacingLineDrawer(FormDesigner designer) { public FormSpacingLineDrawer(FormDesigner designer) {
@ -30,12 +32,14 @@ public class FormSpacingLineDrawer {
} }
public void updateMouseEvent(MouseEvent e, boolean isMouseMoveEvent) { public void updateMouseEvent(MouseEvent e, boolean isMouseMoveEvent) {
this.hoverCreator = designer.getComponentAt(e); XCreator creator = designer.getSelectionModel().getSelection().getSelectedCreator();
if (creator != null) {
this.hoverCreator = designer.getComponentAt(e.getX(), e.getY(), creator.getLevel());
}
this.isMouseMoveEvent = isMouseMoveEvent; this.isMouseMoveEvent = isMouseMoveEvent;
} }
public void draw(Graphics g) { public void draw(Graphics g) {
this.selectedRec = designer.getSelectionModel().getSelection().getSelctionBounds();
if (!isDrawSpacingLine()) { if (!isDrawSpacingLine()) {
return; return;
} }
@ -44,6 +48,9 @@ public class FormSpacingLineDrawer {
return; return;
} }
this.selectedRec = designer.getSelectionModel().getSelection().getRelativeBounds();
this.hoveredRec = ComponentUtils.getRelativeBounds(hoverCreator);
drawHorizontalSpacingLine(g); drawHorizontalSpacingLine(g);
drawVerticalSpacingLine(g); drawVerticalSpacingLine(g);
} }
@ -131,14 +138,6 @@ public class FormSpacingLineDrawer {
designer.getSelectionModel().getSelection().getSelectedCreator().getParent() == null; designer.getSelectionModel().getSelection().getSelectedCreator().getParent() == null;
} }
private boolean isHoveredRootComponent() {
return designer.isRoot(hoverCreator);
}
private boolean isHoveredForm() {
return hoverCreator.getParent() == null;
}
private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) { private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) {
return nearestSides[0].isVerticalCenterLineBeforeTheParallelLine(nearestSides[1]) || nearestSides[0].isVerticalCenterLineBehindTheParallelLine(nearestSides[1]); return nearestSides[0].isVerticalCenterLineBeforeTheParallelLine(nearestSides[1]) || nearestSides[0].isVerticalCenterLineBehindTheParallelLine(nearestSides[1]);
} }
@ -147,12 +146,13 @@ public class FormSpacingLineDrawer {
return isSelectedForm() || isSelectedRootComponent(); return isSelectedForm() || isSelectedRootComponent();
} }
private boolean isHoveredRootPane() { private boolean isSelectedCreatorSameParentWithHoveredCreator() {
return isHoveredForm() || isHoveredRootComponent(); XCreator selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator();
return selectedCreator != null && hoverCreator != null && selectedCreator.getParent() == hoverCreator.getParent();
} }
private boolean isDrawSpacingLine() { private boolean isDrawSpacingLine() {
return !isSelectedRootPane() && !isHoveredRootPane() && isMouseMoveEvent; return !isSelectedRootPane() && isSelectedCreatorSameParentWithHoveredCreator() && isMouseMoveEvent;
} }
private AbstractFormParallelLine[] getNearestHorizontalSide() { private AbstractFormParallelLine[] getNearestHorizontalSide() {
@ -162,8 +162,8 @@ public class FormSpacingLineDrawer {
}; };
AbstractFormParallelLine[] hoveredCreatorSides = new AbstractFormParallelLine[] { AbstractFormParallelLine[] hoveredCreatorSides = new AbstractFormParallelLine[] {
new FormHorizontalParallelLine(hoverCreator.getY(), hoverCreator.getX(), hoverCreator.getX() + hoverCreator.getWidth()), new FormHorizontalParallelLine(hoveredRec.y, hoveredRec.x, hoveredRec.x + hoveredRec.width),
new FormHorizontalParallelLine(hoverCreator.getY() + hoverCreator.getHeight(), hoverCreator.getX(), hoverCreator.getX() + hoverCreator.getWidth()) new FormHorizontalParallelLine(hoveredRec.y + hoveredRec.height, hoveredRec.x, hoveredRec.x + hoveredRec.width)
}; };
return getNearestSide(selectedRecSides, hoveredCreatorSides); return getNearestSide(selectedRecSides, hoveredCreatorSides);
} }
@ -175,19 +175,20 @@ public class FormSpacingLineDrawer {
}; };
AbstractFormParallelLine[] hoveredCreatorSides = new AbstractFormParallelLine[] { AbstractFormParallelLine[] hoveredCreatorSides = new AbstractFormParallelLine[] {
new FormVerticalParallelLine(hoverCreator.getX(), hoverCreator.getY(), hoverCreator.getY() + hoverCreator.getHeight()), new FormVerticalParallelLine(hoveredRec.x, hoveredRec.y, hoveredRec.y + hoveredRec.height),
new FormVerticalParallelLine(hoverCreator.getX() + hoverCreator.getWidth(), hoverCreator.getY(), hoverCreator.getY() + hoverCreator.getHeight()) new FormVerticalParallelLine(hoveredRec.x + hoveredRec.width, hoveredRec.y, hoveredRec.y + hoveredRec.height)
}; };
return getNearestSide(selectedRecSides, hoveredCreatorSides); return getNearestSide(selectedRecSides, hoveredCreatorSides);
} }
private AbstractFormParallelLine[] getNearestSide(AbstractFormParallelLine[] lines1, AbstractFormParallelLine[] lines2) { private AbstractFormParallelLine[] getNearestSide(AbstractFormParallelLine[] lines1, AbstractFormParallelLine[] lines2) {
AbstractFormParallelLine[] nearestSides = new AbstractFormParallelLine[2]; AbstractFormParallelLine[] nearestSides = new AbstractFormParallelLine[] {lines1[0], lines2[0]};
int minDistance = lines1[0].getDistanceWithLine(lines2[0]); int minDistance = lines1[0].getDistanceWithLine(lines2[0]);
for (int i = 0; i < lines1.length; i++) { for (int i = 0; i < lines1.length; i++) {
for (int j = 0; j < lines2.length; j++) { for (int j = 0; j < lines2.length; j++) {
int distance = lines1[i].getDistanceWithLine(lines2[j]); int distance = lines1[i].getDistanceWithLine(lines2[j]);
if (distance <= minDistance) { if (distance < minDistance) {
minDistance = distance;
nearestSides[0] = lines1[i]; nearestSides[0] = lines1[i];
nearestSides[1] = lines2[j]; nearestSides[1] = lines2[j];
} }

7
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -1135,4 +1135,11 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
formDesign.hidePopup(); formDesign.hidePopup();
} }
} }
@Override
public void refreshFormDesigner() {
if (formDesign != null) {
formDesign.repaint();
}
}
} }

60
designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java

@ -1,6 +1,12 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout;
import com.fr.form.ui.container.WLayout;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.util.Arrays; import java.util.Arrays;
@ -10,6 +16,7 @@ import java.util.List;
public class MultiSelectionArrangement { public class MultiSelectionArrangement {
private FormDesigner designer; private FormDesigner designer;
private XLayoutContainer parent; // 当前选中的那些组件所在父容器
private List<XCreator> selectedCreators; private List<XCreator> selectedCreators;
private Rectangle rec; private Rectangle rec;
@ -22,46 +29,47 @@ public class MultiSelectionArrangement {
for (XCreator creator : selectedCreators) { for (XCreator creator : selectedCreators) {
creator.setLocation(rec.x, creator.getY()); creator.setLocation(rec.x, creator.getY());
} }
repaint(); update();
} }
public void rightAlign() { public void rightAlign() {
for (XCreator creator : selectedCreators) { for (XCreator creator : selectedCreators) {
creator.setLocation(rec.x + rec.width - creator.getWidth(), creator.getY()); creator.setLocation(rec.x + rec.width - creator.getWidth(), creator.getY());
} }
repaint(); update();
} }
public void topAlign() { public void topAlign() {
for (XCreator creator : selectedCreators) { for (XCreator creator : selectedCreators) {
creator.setLocation(creator.getX(), rec.y); creator.setLocation(creator.getX(), rec.y);
} }
repaint(); update();
} }
public void bottomAlign() { public void bottomAlign() {
for (XCreator creator : selectedCreators) { for (XCreator creator : selectedCreators) {
creator.setLocation(creator.getX(), rec.y + rec.height - creator.getHeight()); creator.setLocation(creator.getX(), rec.y + rec.height - creator.getHeight());
} }
repaint(); update();
} }
public void horizontalCenterAlign() { public void horizontalCenterAlign() {
for (XCreator creator : selectedCreators) { for (XCreator creator : selectedCreators) {
creator.setLocation(rec.x + rec.width / 2 - creator.getWidth() / 2, creator.getY()); creator.setLocation(rec.x + rec.width / 2 - creator.getWidth() / 2, creator.getY());
} }
repaint(); update();
} }
public void verticalCenterAlign() { public void verticalCenterAlign() {
for (XCreator creator : selectedCreators) { for (XCreator creator : selectedCreators) {
creator.setLocation(creator.getX(), rec.y + rec.height / 2 - creator.getHeight() / 2); creator.setLocation(creator.getX(), rec.y + rec.height / 2 - creator.getHeight() / 2);
} }
repaint(); update();
} }
// 水平分布,自动,间距由selectedCreators和border共同计算而来 // 水平分布,自动,间距由selectedCreators和border共同计算而来
public void horizontalAutoDistribution() { public void horizontalAutoDistribution() {
sortHorizontal();
int gap = calculateHorizontalGap(); int gap = calculateHorizontalGap();
horizontalDistribution(gap); horizontalDistribution(gap);
} }
@ -73,17 +81,15 @@ public class MultiSelectionArrangement {
} }
private void horizontalDistribution(int gap) { private void horizontalDistribution(int gap) {
sortHorizontal();
for (int i = 1; i < selectedCreators.size() - 1; i++) { for (int i = 1; i < selectedCreators.size() - 1; i++) {
XCreator creator = selectedCreators.get(i); XCreator creator = selectedCreators.get(i);
XCreator preCreator = selectedCreators.get(i - 1); XCreator preCreator = selectedCreators.get(i - 1);
creator.setLocation(preCreator.getX() + preCreator.getWidth() + gap, creator.getY()); creator.setLocation(preCreator.getX() + preCreator.getWidth() + gap, creator.getY());
} }
repaint(); update();
} }
private void reSizeRecByHorizontal(int gap) { private void reSizeRecByHorizontal(int gap) {
sortHorizontal();
int width = 0; int width = 0;
for (XCreator creator : selectedCreators) { for (XCreator creator : selectedCreators) {
width += creator.getWidth(); width += creator.getWidth();
@ -131,10 +137,14 @@ public class MultiSelectionArrangement {
for (XCreator creator : selectedCreators) { for (XCreator creator : selectedCreators) {
sum += creator.getWidth(); sum += creator.getWidth();
} }
return (rec.width - sum) / (selectedCreators.size() - 1); XCreator head = selectedCreators.get(0);
XCreator tail = selectedCreators.get(selectedCreators.size() - 1);
int distanceBetweenHeadAndTailCreators = Math.abs(head.getX() - tail.getX()) + tail.getWidth();
return (distanceBetweenHeadAndTailCreators - sum) / (selectedCreators.size() - 1);
} }
public void verticalAutoDistribution() { public void verticalAutoDistribution() {
sortVertical();
int gap = calculateVerticalGap(); int gap = calculateVerticalGap();
verticalDistribution(gap); verticalDistribution(gap);
} }
@ -145,17 +155,15 @@ public class MultiSelectionArrangement {
} }
private void verticalDistribution(int gap) { private void verticalDistribution(int gap) {
sortVertical();
for (int i = 1; i < selectedCreators.size() - 1; i++) { for (int i = 1; i < selectedCreators.size() - 1; i++) {
XCreator creator = selectedCreators.get(i); XCreator creator = selectedCreators.get(i);
XCreator preCreator = selectedCreators.get(i - 1); XCreator preCreator = selectedCreators.get(i - 1);
creator.setLocation(creator.getX(), preCreator.getY() + preCreator.getHeight() + gap); creator.setLocation(creator.getX(), preCreator.getY() + preCreator.getHeight() + gap);
} }
repaint(); update();
} }
private void reSizeRecByVertical(int gap) { private void reSizeRecByVertical(int gap) {
sortVertical();
int height = 0; int height = 0;
for (XCreator creator : selectedCreators) { for (XCreator creator : selectedCreators) {
height += creator.getHeight(); height += creator.getHeight();
@ -202,17 +210,35 @@ public class MultiSelectionArrangement {
for (XCreator creator : selectedCreators) { for (XCreator creator : selectedCreators) {
sum += creator.getHeight(); sum += creator.getHeight();
} }
return (rec.height - sum) / (selectedCreators.size() - 1); XCreator head = selectedCreators.get(0);
XCreator tail = selectedCreators.get(selectedCreators.size() - 1);
int distanceBetweenHeadAndTailCreators = Math.abs(head.getY() - tail.getY()) + tail.getHeight();
return (distanceBetweenHeadAndTailCreators - sum) / (selectedCreators.size() - 1);
} }
private void update() { private void update() {
FormSelection selection = designer.getSelectionModel().getSelection(); FormSelection selection = designer.getSelectionModel().getSelection();
this.selectedCreators = Arrays.asList(selection.getSelectedCreators()); this.selectedCreators = Arrays.asList(selection.getSelectedCreators());
this.rec = selection.getSelctionBounds(); this.rec = selection.getSelctionBounds();
this.parent = getParent(selection.getSelectedCreator());
if (parent != null) {
// 这里要修改修改engine里面的对象才能成功保存,光修改设计器对象没用
WLayout wabs = parent.toData();
for (XCreator creator : selectedCreators) {
wabs.setBounds(creator.toData(), creator.getBounds());
}
}
} }
private void repaint() { private XLayoutContainer getParent(XCreator source) {
designer.repaint(); if(source.acceptType(XWCardTagLayout.class)){
update(); return (XLayoutContainer)source.getParent();
}
XLayoutContainer container = XCreatorUtils.getParentXLayoutContainer(source);
if (source.acceptType(XWFitLayout.class) || source.acceptType(XWParameterLayout.class)) {
container = null;
}
return container;
} }
} }

14
designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java

@ -412,20 +412,6 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
if (!isValid) { if (!isValid) {
return; return;
} }
//fanglei:下面的注释不要删,只是暂时屏蔽
// int value = downPanel.getVerticalScrollBar().getValue();
// if (hasSelectParaPane(getEditingFormDesigner())) {
// cardLayout.show(centerPane, PARA);
// mobileParaWidgetTable.refreshData();
// } else {
// cardLayout.show(centerPane, BODY);
// mobileWidgetTable.refreshData();
// }
// //出现滚动条
// downPanel.doLayout();
// //控件列表选中某组件,触发表单中选中控件,选中事件又触发列表刷新,滚动条回到0
// //此处设置滚动条值为刷新前
// downPanel.getVerticalScrollBar().setValue(value);
if (mobileExtraPropertyPanes != null) { if (mobileExtraPropertyPanes != null) {
for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) { for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) {
extraPane.populate(designer); extraPane.populate(designer);

27
designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/AbstractMultiSelectionArrangementButton.java

@ -1,23 +1,32 @@
package com.fr.design.mainframe.widget.arrangement.buttons; package com.fr.design.mainframe.widget.arrangement.buttons;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.mainframe.MultiSelectionArrangement; import com.fr.design.mainframe.MultiSelectionArrangement;
public abstract class AbstractMultiSelectionArrangementButton implements MultiSelectionArrangementButton { public abstract class AbstractMultiSelectionArrangementButton extends UIButton implements MultiSelectionArrangementButton, UIObserver {
private static final long serialVersionUID = -2114423583742242771L;
protected MultiSelectionArrangement arrangement; protected MultiSelectionArrangement arrangement;
protected UIObserverListener uiObserverListener;
public AbstractMultiSelectionArrangementButton(MultiSelectionArrangement arrangement) { public AbstractMultiSelectionArrangementButton(MultiSelectionArrangement arrangement) {
super();
this.arrangement = arrangement; this.arrangement = arrangement;
this.setNormalPainted(false);
this.setBorderPaintedOnlyWhenPressed(true);
this.setIcon(getIcon());
this.setToolTipText(getTipText());
this.addActionListener(getActionListener());
} }
@Override @Override
public UIButton create() { public void registerChangeListener(UIObserverListener listener) {
UIButton btn = new UIButton(); uiObserverListener = listener;
btn.setNormalPainted(false); }
btn.setBorderPaintedOnlyWhenPressed(true);
btn.setIcon(getIcon()); @Override
btn.setToolTipText(getTipText()); public boolean shouldResponseChangeListener() {
btn.addActionListener(getActionListener()); return true;
return btn;
} }
} }

1
designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/BottomAlignButton.java

@ -29,6 +29,7 @@ public class BottomAlignButton extends AbstractMultiSelectionArrangementButton {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
arrangement.bottomAlign(); arrangement.bottomAlign();
uiObserverListener.doChange();
} }
}; };
} }

1
designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalCenterButton.java

@ -29,6 +29,7 @@ public class HorizontalCenterButton extends AbstractMultiSelectionArrangementBut
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
arrangement.horizontalCenterAlign(); arrangement.horizontalCenterAlign();
uiObserverListener.doChange();
} }
}; };
} }

1
designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalDistributionButton.java

@ -29,6 +29,7 @@ public class HorizontalDistributionButton extends AbstractMultiSelectionArrangem
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
arrangement.horizontalAutoDistribution(); arrangement.horizontalAutoDistribution();
uiObserverListener.doChange();
} }
}; };
} }

1
designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/LeftAlignButton.java

@ -29,6 +29,7 @@ public class LeftAlignButton extends AbstractMultiSelectionArrangementButton {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
arrangement.leftAlign(); arrangement.leftAlign();
uiObserverListener.doChange();
} }
}; };
} }

4
designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/MultiSelectionArrangementButton.java

@ -1,7 +1,5 @@
package com.fr.design.mainframe.widget.arrangement.buttons; package com.fr.design.mainframe.widget.arrangement.buttons;
import com.fr.design.gui.ibutton.UIButton;
import javax.swing.Icon; import javax.swing.Icon;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -11,6 +9,4 @@ public interface MultiSelectionArrangementButton {
String getTipText(); String getTipText();
ActionListener getActionListener(); ActionListener getActionListener();
UIButton create();
} }

1
designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/RightAlignButton.java

@ -29,6 +29,7 @@ public class RightAlignButton extends AbstractMultiSelectionArrangementButton {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
arrangement.rightAlign(); arrangement.rightAlign();
uiObserverListener.doChange();
} }
}; };
} }

1
designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/TopAlignButton.java

@ -29,6 +29,7 @@ public class TopAlignButton extends AbstractMultiSelectionArrangementButton {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
arrangement.topAlign(); arrangement.topAlign();
uiObserverListener.doChange();
} }
}; };
} }

1
designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalCenterButton.java

@ -29,6 +29,7 @@ public class VerticalCenterButton extends AbstractMultiSelectionArrangementButto
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
arrangement.verticalCenterAlign(); arrangement.verticalCenterAlign();
uiObserverListener.doChange();
} }
}; };
} }

1
designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalDistributionButton.java

@ -29,6 +29,7 @@ public class VerticalDistributionButton extends AbstractMultiSelectionArrangemen
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
arrangement.verticalAutoDistribution(); arrangement.verticalAutoDistribution();
uiObserverListener.doChange();
} }
}; };
} }

86
designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java

@ -1,8 +1,10 @@
package com.fr.design.mainframe.widget.ui; package com.fr.design.mainframe.widget.ui;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UIIntNumberField; import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
@ -19,6 +21,7 @@ import com.fr.design.mainframe.widget.arrangement.buttons.VerticalCenterButton;
import com.fr.design.mainframe.widget.arrangement.buttons.VerticalDistributionButton; import com.fr.design.mainframe.widget.arrangement.buttons.VerticalDistributionButton;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -26,18 +29,27 @@ import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.event.FocusAdapter; import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
public class FormMultiWidgetCardPane extends FormWidgetCardPane { public class FormMultiWidgetCardPane extends FormWidgetCardPane {
private AttributeChangeListener listener;
private MultiSelectionArrangement arrangement; private MultiSelectionArrangement arrangement;
public FormMultiWidgetCardPane(FormDesigner designer) { public FormMultiWidgetCardPane(FormDesigner designer) {
super(designer); super(designer);
arrangement = new MultiSelectionArrangement(designer);
} }
public void initPropertyPane() { public void initPropertyPane() {
arrangement = new MultiSelectionArrangement(designer);
content.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0)); content.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0));
content.add(createArrangementLayoutPane(), BorderLayout.CENTER); content.add(createArrangementLayoutPane(), BorderLayout.CENTER);
this.listener = new AttributeChangeListener() {
@Override
public void attributeChange() {
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_RESIZED);
}
};
} }
// 整个排列分布面板的layout,可以看成一个三行一列的表格,第一行是分布,第二行是自动间距,第三行是手动间距 // 整个排列分布面板的layout,可以看成一个三行一列的表格,第一行是分布,第二行是自动间距,第三行是手动间距
@ -71,12 +83,12 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane {
}; };
Component[][] components = new Component[][] { Component[][] components = new Component[][] {
new Component[] { new Component[] {
new LeftAlignButton(arrangement).create(), new LeftAlignButton(arrangement),
new HorizontalCenterButton(arrangement).create(), new HorizontalCenterButton(arrangement),
new RightAlignButton(arrangement).create(), new RightAlignButton(arrangement),
new TopAlignButton(arrangement).create(), new TopAlignButton(arrangement),
new VerticalCenterButton(arrangement).create(), new VerticalCenterButton(arrangement),
new BottomAlignButton(arrangement).create() new BottomAlignButton(arrangement)
} }
}; };
JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 18, 0); JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 18, 0);
@ -90,8 +102,8 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane {
TableLayout.PREFERRED, TableLayout.PREFERRED,
TableLayout.PREFERRED TableLayout.PREFERRED
}; };
UIButton horizontalAutoSpacingBtn = new HorizontalDistributionButton(arrangement).create(); UIButton horizontalAutoSpacingBtn = new HorizontalDistributionButton(arrangement);
UIButton verticalAutoSpacingBtn = new VerticalDistributionButton(arrangement).create(); UIButton verticalAutoSpacingBtn = new VerticalDistributionButton(arrangement);
if (designer.getSelectionModel().getSelection().size() < 3) { if (designer.getSelectionModel().getSelection().size() < 3) {
horizontalAutoSpacingBtn.setEnabled(false); horizontalAutoSpacingBtn.setEnabled(false);
verticalAutoSpacingBtn.setEnabled(false); verticalAutoSpacingBtn.setEnabled(false);
@ -129,20 +141,8 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane {
TableLayout.PREFERRED, TableLayout.PREFERRED,
TableLayout.FILL TableLayout.FILL
}; };
UITextField horizontalSpacingNumberField = new UIIntNumberField(); UITextField horizontalSpacingNumberField = createIntNumberField(false, Toolkit.i18nText("Fine-Design_Multi_Selection_Manual_Horizontal_Spacing_Tip"));
horizontalSpacingNumberField.addFocusListener(new FocusAdapter() { UITextField verticalSpacingNumberField = createIntNumberField(true, Toolkit.i18nText("Fine-Design_Multi_Selection_Manual_Vertical_Spacing_Tip"));
@Override
public void focusLost(FocusEvent e) {
distributionDoChange(horizontalSpacingNumberField.getText(), false);
}
});
UITextField verticalSpacingNumberField = new UIIntNumberField();
verticalSpacingNumberField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
distributionDoChange(verticalSpacingNumberField.getText(), true);
}
});
Component[][] components = new Component[][] { Component[][] components = new Component[][] {
new Component[] { new Component[] {
new UILabel(IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_horizontal_spacing.png")), new UILabel(IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_horizontal_spacing.png")),
@ -157,13 +157,37 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane {
return createTitleLayout(Toolkit.i18nText("Fine-Design_Multi_Selection_Manual_Spacing"), centerPane); return createTitleLayout(Toolkit.i18nText("Fine-Design_Multi_Selection_Manual_Spacing"), centerPane);
} }
private void distributionDoChange(String text, boolean isVertical) { private UINumberField createIntNumberField(boolean isVertical, String tipText) {
if (StableUtils.isNumber(text)) { final UINumberField numberField = new UINumberField();
numberField.setPlaceholder(tipText);
numberField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
distributionDoChange(numberField, isVertical);
}
});
numberField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
distributionDoChange(numberField, isVertical);
}
}
});
return numberField;
}
private void distributionDoChange(UINumberField numberField, boolean isVertical) {
String text = numberField.getText();
if (StringUtils.isNotEmpty(text) && StableUtils.isNumber(text)) {
int gap = (int) Math.floor(Float.parseFloat(text));
numberField.setValue(gap);
if (isVertical) { if (isVertical) {
arrangement.verticalManualDistribution(Math.round(Float.parseFloat(text))); arrangement.verticalManualDistribution(gap);
} else { } else {
arrangement.horizontalManualDistribution(Math.round(Float.parseFloat(text))); arrangement.horizontalManualDistribution(gap);
} }
attributeChanged();
} }
} }
@ -175,4 +199,10 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane {
jPanel.add(centerPane, BorderLayout.CENTER); jPanel.add(centerPane, BorderLayout.CENTER);
return jPanel; return jPanel;
} }
@Override
public void populate() {
initListener(this);
this.addAttributeChangeListener(listener);
}
} }

948
designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java

File diff suppressed because it is too large Load Diff

26
designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java

@ -15,6 +15,8 @@ import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.write.submit.DBManipulationPane; import com.fr.design.write.submit.DBManipulationPane;
import com.fr.form.event.Listener; import com.fr.form.event.Listener;
import com.fr.js.JavaScript; import com.fr.js.JavaScript;
import com.fr.report.web.util.ReportEngineEventMapping;
import com.fr.write.JavaScriptResourceInfo;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -25,6 +27,7 @@ import java.awt.FlowLayout;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -39,9 +42,12 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
private static final String DBCOMMIT = Toolkit.i18nText("Fine-Design_Basic_JavaScript_Commit_To_Database"); private static final String DBCOMMIT = Toolkit.i18nText("Fine-Design_Basic_JavaScript_Commit_To_Database");
private static final String CUSTOMACTION = Toolkit.i18nText("Fine-Design_Report_Submit_Type_Custom"); private static final String CUSTOMACTION = Toolkit.i18nText("Fine-Design_Report_Submit_Type_Custom");
private static final String EMAIL = Toolkit.i18nText("Fine-Design_Report_Email_Sent_Email"); private static final String EMAIL = Toolkit.i18nText("Fine-Design_Report_Email_Sent_Email");
private static final String EXPORT = Toolkit.i18nText("Fine-Design_Basic_Export_JS_Event");
private Listener listener; private Listener listener;
JavaScriptActionPane javaScriptActionPane;
public ListenerEditPane() { public ListenerEditPane() {
this.initComponents(new String[0]); this.initComponents(new String[0]);
} }
@ -62,8 +68,12 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
nameText = new UITextField(8); nameText = new UITextField(8);
nameText.setEditable(false); nameText.setEditable(false);
namePane.add(nameText, BorderLayout.WEST); namePane.add(nameText, BorderLayout.WEST);
final String[] style = {JS, DBCOMMIT, CUSTOMACTION, EMAIL}; final List<String> style = new ArrayList<>(Arrays.asList(JS, DBCOMMIT, CUSTOMACTION, EMAIL));
styleBox = new UIComboBox(style); boolean workbook = DesignerContext.getDesignerFrame().getSelectedJTemplate().isJWorkBook();
if (workbook) {
style.add(EXPORT);
}
styleBox = new UIComboBox(style.toArray());
namePane.add(styleBox); namePane.add(styleBox);
namePane = GUICoreUtils.createFlowPane(new Component[]{ namePane = GUICoreUtils.createFlowPane(new Component[]{
new UILabel(" " + Toolkit.i18nText("Fine-Design_Report_Event_Name") + ":"), new UILabel(" " + Toolkit.i18nText("Fine-Design_Report_Event_Name") + ":"),
@ -81,7 +91,8 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
// 提交入库 // 提交入库
List dbManiList = new ArrayList(); List dbManiList = new ArrayList();
dbManiList.add(autoCreateDBManipulationPane()); dbManiList.add(autoCreateDBManipulationPane());
Commit2DBJavaScriptPane commit2DBJavaScriptPane = new Commit2DBJavaScriptPane(JavaScriptActionPane.createDefaultJavaScriptActionPane(), javaScriptActionPane = JavaScriptActionPane.createDefaultJavaScriptActionPane();
Commit2DBJavaScriptPane commit2DBJavaScriptPane = new Commit2DBJavaScriptPane(javaScriptActionPane,
dbManiList); dbManiList);
hyperlinkPane.add(DBCOMMIT, commit2DBJavaScriptPane); hyperlinkPane.add(DBCOMMIT, commit2DBJavaScriptPane);
// 自定义事件 // 自定义事件
@ -90,6 +101,12 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
// 发送邮件 // 发送邮件
EmailPane emailPane = new EmailPane(); EmailPane emailPane = new EmailPane();
hyperlinkPane.add(EMAIL, emailPane); hyperlinkPane.add(EMAIL, emailPane);
// 导出事件
if (workbook) {
ExportJavaScriptPane exportJavaScriptPane = new ExportJavaScriptPane();
hyperlinkPane.add(EXPORT, exportJavaScriptPane);
cards.add(exportJavaScriptPane);
}
cards.add(javaScriptPane); cards.add(javaScriptPane);
cards.add(commit2DBJavaScriptPane); cards.add(commit2DBJavaScriptPane);
cards.add(customActionPane); cards.add(customActionPane);
@ -164,9 +181,12 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
@Override @Override
public Listener updateBean() { public Listener updateBean() {
String actionLocaleName = ReportEngineEventMapping.getLocaleName(listener.getEventName());
javaScriptActionPane.setResourceInfo(new JavaScriptResourceInfo(JavaScriptResourceInfo.Type.WEB_CONFIG, Toolkit.i18nText(actionLocaleName)));
this.listener.setEventName(this.nameText.getText()); this.listener.setEventName(this.nameText.getText());
FurtherBasicBeanPane<? extends JavaScript> pane = this.cards.get(this.styleBox.getSelectedIndex()); FurtherBasicBeanPane<? extends JavaScript> pane = this.cards.get(this.styleBox.getSelectedIndex());
this.listener.setAction(pane.updateBean()); this.listener.setAction(pane.updateBean());
return this.listener; return this.listener;
} }
} }

10
designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java

@ -185,7 +185,7 @@ public class AuthorityToolBarPane<T extends WebContent> extends BasicBeanPane<Re
*/ */
private void checkToolBarPaneEnable() { private void checkToolBarPaneEnable() {
List<ToolBarButton> toolBarButtons = toolBarPane.getToolBarButtons(); List<ToolBarButton> toolBarButtons = toolBarPane.getToolBarButtons();
boolean isnotEnable = ComparatorUtils.equals(title.getText(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Server_Toolbar_Choose_Role"))&& !WorkContext.getCurrent().isRoot(); boolean isnotEnable = ComparatorUtils.equals(title.getText(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Server_Toolbar_Choose_Role")) && !WorkContext.getCurrent().isRoot();
for (ToolBarButton button : toolBarButtons) { for (ToolBarButton button : toolBarButtons) {
button.setEnabled(!isnotEnable); button.setEnabled(!isnotEnable);
} }
@ -296,9 +296,15 @@ public class AuthorityToolBarPane<T extends WebContent> extends BasicBeanPane<Re
if (toolBarManager.length == 0) { if (toolBarManager.length == 0) {
return; return;
} }
ToolBar resultToolbar = new ToolBar();
for (int i = 0; i < toolBarManager.length; i++) { for (int i = 0; i < toolBarManager.length; i++) {
toolBarPane.populateBean(toolBarManager[i].getToolBar()); ToolBar toolBar = toolBarManager[i].getToolBar();
for (int j = 0; j < toolBar.getWidgetSize(); j++) {
Widget widget = toolBar.getWidget(j);
resultToolbar.addWidget(widget);
}
} }
toolBarPane.populateBean(resultToolbar);
} }

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

@ -1238,4 +1238,12 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
designer.hidePopup(); designer.hidePopup();
} }
} }
@Override
public void refreshFormDesigner() {
FormDesigner designer = (FormDesigner) parameterPane.getParaDesigner();
if (designer != null) {
designer.repaint();
}
}
} }

13
designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java

@ -20,6 +20,7 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.login.DesignerLoginHelper; import com.fr.design.login.DesignerLoginHelper;
import com.fr.design.login.DesignerLoginSource; import com.fr.design.login.DesignerLoginSource;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo;
import com.fr.design.mainframe.share.constants.ComponentType; import com.fr.design.mainframe.share.constants.ComponentType;
import com.fr.design.mainframe.share.constants.ComponentTypes; import com.fr.design.mainframe.share.constants.ComponentTypes;
import com.fr.design.mainframe.share.constants.DisplayDevice; import com.fr.design.mainframe.share.constants.DisplayDevice;
@ -36,6 +37,9 @@ import com.fr.form.share.bean.StyleThemeBean;
import com.fr.form.share.constants.ShareComponentConstants; import com.fr.form.share.constants.ShareComponentConstants;
import com.fr.form.share.group.DefaultShareGroupManager; import com.fr.form.share.group.DefaultShareGroupManager;
import com.fr.form.share.Group; import com.fr.form.share.Group;
import com.fr.json.JSON;
import com.fr.json.JSONArray;
import com.fr.json.JSONFactory;
import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginContext;
import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.PluginManager;
@ -622,6 +626,15 @@ public class ShareMainPane extends JPanel {
provider.setDesignerVersion(ProductConstants.VERSION); provider.setDesignerVersion(ProductConstants.VERSION);
provider.setVendor(loginLabel.getText()); provider.setVendor(loginLabel.getText());
provider.setFileName(provider.getNameWithID()); provider.setFileName(provider.getNameWithID());
provider.setVendorUid(DesignerEnvManager.getEnvManager().getDesignerLoginUid());
provider.setCreateTime(System.currentTimeMillis());
JSONArray historyCreatedReuses = JSONFactory.createJSON(
JSON.ARRAY,
ComponentReuseNotificationInfo.getInstance().getHistoryCreatedReuses()
);
historyCreatedReuses.add(uuid);
ComponentReuseNotificationInfo.getInstance().setHistoryCreatedReuses(historyCreatedReuses.toString());
DesignerEnvManager.getEnvManager().saveXMLFile();
if (upload) { if (upload) {
provider.setSummary(content.getText()); provider.setSummary(content.getText());

1175
designer-realize/src/main/java/com/fr/design/webattr/EditToolBar.java

File diff suppressed because it is too large Load Diff

3
designer-realize/src/main/java/com/fr/design/widget/CellWidgetCardPane.java

@ -14,7 +14,6 @@ import com.fr.design.widget.ui.BasicWidgetPropertySettingPane;
import com.fr.form.event.Listener; import com.fr.form.event.Listener;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
@ -166,7 +165,7 @@ public class CellWidgetCardPane extends BasicPane {
} }
widgetPropertyPane.update(widget); widgetPropertyPane.update(widget);
Listener[] listener = eventPane == null ? new Listener[0] : eventPane.updateListeners(); Listener[] listener = eventPane == null ? new Listener[0] : eventPane.updateListeners(widget);
widget.clearListeners(); widget.clearListeners();
for (Listener l : listener) { for (Listener l : listener) {
widget.addListener(l); widget.addListener(l);

50
designer-realize/src/main/java/com/fr/design/widget/WidgetEventPane.java

@ -1,29 +1,30 @@
package com.fr.design.widget; package com.fr.design.widget;
import java.lang.reflect.Constructor;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.controlpane.UIListGroupControlPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.CellWidgetPropertyPane;
import com.fr.design.write.submit.DBManipulationPane;
import com.fr.design.write.submit.SmartInsertDBManipulationInWidgetEventPane;
import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.controlpane.UIListGroupControlPane;
import com.fr.design.gui.frpane.ListenerUpdatePane; import com.fr.design.gui.frpane.ListenerUpdatePane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.javascript.JavaScriptActionPane; import com.fr.design.javascript.JavaScriptActionPane;
import com.fr.design.mainframe.CellWidgetPropertyPane;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.write.submit.DBManipulationPane;
import com.fr.design.write.submit.SmartInsertDBManipulationInWidgetEventPane;
import com.fr.form.event.Listener; import com.fr.form.event.Listener;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.grid.selection.Selection;
import com.fr.general.NameObject; import com.fr.general.NameObject;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.Selection;
import com.fr.js.Commit2DBJavaScript;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
import com.fr.write.JavaScriptResourceInfo;
import javax.swing.*; import javax.swing.BorderFactory;
import java.lang.reflect.Constructor;
public class WidgetEventPane extends UIListGroupControlPane { public class WidgetEventPane extends UIListGroupControlPane {
private static final Selection NO_SELECTION = new CellSelection(-1, -1, -1, -1); private static final Selection NO_SELECTION = new CellSelection(-1, -1, -1, -1);
@ -32,9 +33,11 @@ public class WidgetEventPane extends UIListGroupControlPane {
private ElementCasePane object; private ElementCasePane object;
private Widget targetWidget;
public WidgetEventPane(ElementCasePane pane) { public WidgetEventPane(ElementCasePane pane) {
this.object = pane; this.object = pane;
if(pane != null){ if (pane != null) {
selection = pane.getSelection(); selection = pane.getSelection();
} }
setBorder(BorderFactory.createEmptyBorder(10, 0, 15, 0)); setBorder(BorderFactory.createEmptyBorder(10, 0, 15, 0));
@ -125,18 +128,21 @@ public class WidgetEventPane extends UIListGroupControlPane {
if (widget == null) { if (widget == null) {
return; return;
} }
this.targetWidget = widget;
refreshPane(widget, EventCreator.createEventCreator(widget.supportedEvents(), WidgetEventListenerUpdatePane.class)); refreshPane(widget, EventCreator.createEventCreator(widget.supportedEvents(), WidgetEventListenerUpdatePane.class));
} }
/** /**
* 更新 * 更新
* @return 监听器 *
*/ * @return 监听器
public Listener[] updateListeners() { */
public Listener[] updateListeners(Widget widget) {
this.targetWidget = widget;
Nameable[] res = this.update(); Nameable[] res = this.update();
Listener[] res_array = new Listener[res.length]; Listener[] res_array = new Listener[res.length];
for (int i = 0, len = res.length; i < len; i++) { for (int i = 0, len = res.length; i < len; i++) {
res_array[i] = (Listener) ((NameObject)res[i]).getObject(); res_array[i] = (Listener) ((NameObject) res[i]).getObject();
} }
return res_array; return res_array;
} }
@ -174,14 +180,22 @@ public class WidgetEventPane extends UIListGroupControlPane {
if (constructor != null) { if (constructor != null) {
return constructor; return constructor;
} else { } else {
if (AssistUtils.equals(cls.getName(),Object.class.getName())) { if (AssistUtils.equals(cls.getName(), Object.class.getName())) {
return null; return null;
} }
return getConstructor(clazz, cls.getSuperclass()); return getConstructor(clazz, cls.getSuperclass());
} }
} }
protected String getWrapperLabelText(){ @Override
public void wrapperListener(Listener listener) {
if (listener.getAction() instanceof Commit2DBJavaScript) {
Commit2DBJavaScript commit2DBJavaScript = (Commit2DBJavaScript) listener.getAction();
commit2DBJavaScript.setJsResourceInfo(new JavaScriptResourceInfo(JavaScriptResourceInfo.Type.WIDGET, targetWidget.getWidgetName()));
}
}
protected String getWrapperLabelText() {
return Toolkit.i18nText("Fine-Design_Report_Event"); return Toolkit.i18nText("Fine-Design_Report_Event");
} }

17
designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java

@ -8,9 +8,8 @@ import com.fr.design.editlock.ServerTableDataLockChangeChecker;
import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.env.LocalDesignerWorkspaceInfo;
import com.fr.design.i18n.Toolkit;
import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.design.versioncheck.VersionCheckUtils;
import com.fr.env.TestConnectionResult; import com.fr.env.handler.RemoteDesignExceptionHandler;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.event.Listener; import com.fr.event.Listener;
@ -21,7 +20,6 @@ import com.fr.stable.StringUtils;
import com.fr.value.NotNullLazyValue; import com.fr.value.NotNullLazyValue;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.engine.exception.WorkspaceCheckException;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -61,7 +59,7 @@ public class DesignerWorkspaceProvider extends Activator {
Workspace workspace = DesignerWorkspaceGenerator.generate(workspaceInfo); Workspace workspace = DesignerWorkspaceGenerator.generate(workspaceInfo);
boolean checkValid = workspace != null && workspaceInfo.checkValid(); boolean checkValid = workspace != null && workspaceInfo.checkValid();
if (!checkValid) { if (!checkValid) {
EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner(); EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner(null, workspaceInfo);
} else { } else {
WorkContext.switchTo(workspace); WorkContext.switchTo(workspace);
//在设计器完全启动完成后,对初始环境进行一次服务检测,对主要功能无影响,异常仅做日志提示即可 //在设计器完全启动完成后,对初始环境进行一次服务检测,对主要功能无影响,异常仅做日志提示即可
@ -78,16 +76,7 @@ public class DesignerWorkspaceProvider extends Activator {
}); });
} }
} catch (Throwable e) { } catch (Throwable e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner(e, workspaceInfo);
if (e.getCause() instanceof WorkspaceCheckException) {
WorkspaceCheckException exception = (WorkspaceCheckException) e.getCause();
// 输出标准详情
TestConnectionResult result = TestConnectionResult.parseByException(exception);
if (result.isVerifyResult()) {
FineLoggerFactory.getLogger().error(result.getText().replaceAll(TestConnectionResult.WRAP, StringUtils.EMPTY) + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"));
}
}
EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner();
} }
} }
pluginErrorRemind(); pluginErrorRemind();

Loading…
Cancel
Save