From 3d5a088abf7e54417f24ca9b5d0833b5af5e3575 Mon Sep 17 00:00:00 2001 From: hades Date: Mon, 9 Aug 2021 16:47:32 +0800 Subject: [PATCH 01/32] =?UTF-8?q?REPORT-55795=20=E3=80=9010.0.19=E3=80=91?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E8=A7=84=E8=8C=83=E2=80=94=E2=80=94=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=99=A8=E8=BF=9C=E7=A8=8B=E8=AE=BE=E8=AE=A1=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 88 +------ .../dialog/UIDetailErrorLinkDialog.java | 239 ++++++++++++++++++ .../fr/design/env/DesignerWorkspaceInfo.java | 2 +- .../env/RemoteDesignerWorkspaceInfo.java | 15 +- .../src/main/java/com/fr/env/HelpLink.java | 32 +++ .../com/fr/env/RemoteDesignLocaleMark.java | 36 +++ .../main/java/com/fr/env/RemoteEnvPane.java | 44 +--- .../main/java/com/fr/env/handler/Handler.java | 16 ++ .../handler/RemoteDesignExceptionHandler.java | 88 +++++++ .../com/fr/env/handler/ResultWrapper.java | 30 +++ .../fr/env/handler/impl/CancelHandler.java | 18 ++ .../fr/env/handler/impl/CommonHandler.java | 48 ++++ .../fr/env/handler/impl/ExecutionHandler.java | 21 ++ .../env/handler/impl/UnexpectedHandler.java | 24 ++ .../module/DesignerWorkspaceProvider.java | 14 +- 15 files changed, 580 insertions(+), 135 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java create mode 100644 designer-base/src/main/java/com/fr/env/HelpLink.java create mode 100644 designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java create mode 100644 designer-base/src/main/java/com/fr/env/handler/Handler.java create mode 100644 designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java create mode 100644 designer-base/src/main/java/com/fr/env/handler/ResultWrapper.java create mode 100644 designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java create mode 100644 designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java create mode 100644 designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java create mode 100644 designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 14145d1197..785f3b92b8 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/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.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; -import com.fr.design.dialog.link.MessageWithLink; import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; 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.versioncheck.VersionCheckUtils; import com.fr.env.EnvListPane; -import com.fr.env.RemoteWorkspaceURL; -import com.fr.env.TestConnectionResult; +import com.fr.env.handler.RemoteDesignExceptionHandler; import com.fr.exit.DesignerExiter; -import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import com.fr.invoke.Reflect; import com.fr.json.JSONArray; -import com.fr.license.exception.RegistEditionException; import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; 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.engine.base.FineObjectPool; 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.rpc.WorkspaceProxyPool; @@ -66,7 +60,6 @@ import java.util.List; import java.util.Set; import java.util.HashSet; -import static javax.swing.JOptionPane.ERROR_MESSAGE; import static javax.swing.JOptionPane.QUESTION_MESSAGE; public class EnvChangeEntrance { @@ -79,6 +72,8 @@ public class EnvChangeEntrance { private static EnvChangeEntrance singleton = new EnvChangeEntrance(); } + private BasicDialog dialog; + private EnvChangeEntrance() { @@ -116,13 +111,6 @@ public class EnvChangeEntrance { Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); boolean checkValid = workspace != null && selectedEnv.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; } @@ -149,34 +137,9 @@ public class EnvChangeEntrance { template.refreshToolArea(); } 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) { - if (exception.getCause() instanceof WorkspaceCheckException) { - handleWorkspaceCheckException((WorkspaceCheckException) exception.getCause(), strategy, connectionInfo); - } 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"))); - } + // 失败的处理 + RemoteDesignExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv); return false; } TemplateTreePane.getInstance().refreshDockingView(); @@ -188,29 +151,6 @@ public class EnvChangeEntrance { 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) { final EnvListPane envListPane = new EnvListPane(); final BasicDialog envListDialog = envListPane.showWindow(DesignerContext.getDesignerFrame()); - + dialog = envListDialog; envListPane.populateEnvManager(envName); envListDialog.addDialogActionListener(new DialogActionAdapter() { @@ -457,6 +397,7 @@ public class EnvChangeEntrance { @Override public void doCancel() { envListDialog.dispose(); + dialog = null; // todo 断开了但是没选择新的环境,那么尝试重连旧环境,等接口 } }); @@ -474,6 +415,7 @@ public class EnvChangeEntrance { final EnvListPane envListPane = new EnvListPane(); envListPane.populateEnvManager(DesignerEnvManager.getEnvManager().getCurEnvName()); BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); + dialog = envListDialog; envListDialog.addDialogActionListener(new DialogActionAdapter() { @Override @@ -489,6 +431,7 @@ public class EnvChangeEntrance { @Override public void doCancel() { + dialog = null; DesignerExiter.getInstance().execute(); } }); @@ -523,6 +466,9 @@ public class EnvChangeEntrance { return false; } + public BasicDialog getDialog() { + return dialog; + } /** * 提示显示策略 @@ -559,14 +505,4 @@ public class EnvChangeEntrance { interface PopTip { 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); - } - } } diff --git a/designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java b/designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java new file mode 100644 index 0000000000..b487714f91 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java @@ -0,0 +1,239 @@ +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 = ""; + private static final String TAG_A_END = ""; + + 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); + 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 = Math.max(maxWidth, GraphHelper.getWidth(solution, DesignUtils.getDefaultGUIFont())); + return panel; + + } + + @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); + } + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java index ccc98bfe37..3882291d00 100644 --- a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java @@ -15,5 +15,5 @@ public interface DesignerWorkspaceInfo extends XMLable { WorkspaceConnectionInfo getConnection(); - boolean checkValid(); + boolean checkValid() throws Exception; } diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java index 96069b4356..920a13dbfb 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java @@ -168,8 +168,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { @Override - public boolean checkValid() { - boolean result = false; + public boolean checkValid() throws Exception { String newPort = Integer.toString(DesignerEnvManager.getEnvManager().getEmbedServerPort()); if (!ComparatorUtils.equals(port, newPort)) { // 使用过程中 更改了内置服务器端口 重新初始化下 @@ -177,15 +176,9 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { } if (FILTER_SET.contains(connection.getUrl())) { FineLoggerFactory.getLogger().error("url is same with local designer"); - return result; + return false; } - try { - WorkContext.getConnector().validateVT(connection); - result = true; - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - return result; - } - return result; + WorkContext.getConnector().validateVT(connection); + return true; } } diff --git a/designer-base/src/main/java/com/fr/env/HelpLink.java b/designer-base/src/main/java/com/fr/env/HelpLink.java new file mode 100644 index 0000000000..87975761f9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/HelpLink.java @@ -0,0 +1,32 @@ +package com.fr.env; + +import com.fr.design.DesignerEnvManager; +import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.general.locale.LocaleCenter; +import com.fr.general.locale.LocaleMark; +import com.fr.locale.InterProviderFactory; +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 map = new HashMap<>(); + String currentName = DesignerEnvManager.getEnvManager().getCurEnvName(); + DesignerWorkspaceInfo workspaceInfo = DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentName); + LocaleMark linkMark = LocaleCenter.getMark(RemoteDesignLocaleMark.class); + String link = linkMark.getValue(); + map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Change_PassWord"), workspaceInfo.getConnection().getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH); + 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); + } + + +} diff --git a/designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java b/designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java new file mode 100644 index 0000000000..877a9224b2 --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java @@ -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 { + + private Map 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; + } + +} diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index 3635937783..e0a9d8ece2 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -4,8 +4,6 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.beans.BasicBeanPane; 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.fun.DesignerEnvProcessor; import com.fr.design.gui.ibutton.UIButton; @@ -19,17 +17,13 @@ import com.fr.design.i18n.DesignSizeI18nManager; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.DesignerContext; import com.fr.design.scrollruler.ModLineBorder; -import com.fr.license.exception.RegistEditionException; -import com.fr.log.FineLoggerFactory; +import com.fr.env.handler.RemoteDesignExceptionHandler; import com.fr.stable.StringUtils; import com.fr.third.guava.base.Strings; import com.fr.workspace.WorkContext; 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.BoxLayout; import javax.swing.JDialog; @@ -62,9 +56,7 @@ import java.io.File; import static com.fr.design.layout.TableLayout.FILL; 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 javax.swing.JOptionPane.ERROR_MESSAGE; /** * @author yaohwu @@ -585,42 +577,24 @@ public class RemoteEnvPane extends BasicBeanPane { final RemoteDesignerWorkspaceInfo remoteEnv = updateBean(); final WorkspaceConnectionInfo connection = remoteEnv.getConnection(); - final SwingWorker worker = new SwingWorker() { + final SwingWorker worker = new SwingWorker() { @Override - protected TestConnectionResult doInBackground() throws Exception { - try { - 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); - } + protected Boolean doInBackground() throws Exception { + return WorkContext.getConnector().testConnection(connection); } @Override protected void done() { okButton.setEnabled(true); try { - TestConnectionResult result = get(); - if (result.isVerifyResult()) { - dialog.dispose(); - 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")); + if (get()) { + message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Successful")); + uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon")); } - message.setText(result.getText()); - uiLabel.setIcon(result.getIcon()); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e, e.getMessage()); - message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed")); - uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon")); + dialog.dispose(); + RemoteDesignExceptionHandler.getInstance().handleInTest(e); } dialogDownPane.remove(cancelButton); dialogDownPane.revalidate(); diff --git a/designer-base/src/main/java/com/fr/env/handler/Handler.java b/designer-base/src/main/java/com/fr/env/handler/Handler.java new file mode 100644 index 0000000000..ba2769d2da --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/handler/Handler.java @@ -0,0 +1,16 @@ +package com.fr.env.handler; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/8/5 + */ +public interface Handler { + + /** + * @param t + * @return 是否需要继续处理 + */ + R handle(T t); + +} diff --git a/designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java b/designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java new file mode 100644 index 0000000000..81d10611fd --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java @@ -0,0 +1,88 @@ +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.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> testList = new ArrayList<>(); + + private final List> 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> list) { + Throwable throwable = e; + ResultWrapper wrapper; + for (Handler handler : list) { + wrapper = handler.handle(throwable); + 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); + } + + public void handleInStart(Throwable e, DesignerWorkspaceInfo workspaceInfo) { + if (workspaceInfo == null || workspaceInfo.getType() == DesignerWorkspaceType.Local) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + return; + } + handle(e, testList); + } + + public void handleInTest(Throwable e) { + handle(e, testList); + } + +} diff --git a/designer-base/src/main/java/com/fr/env/handler/ResultWrapper.java b/designer-base/src/main/java/com/fr/env/handler/ResultWrapper.java new file mode 100644 index 0000000000..2e9d705d39 --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/handler/ResultWrapper.java @@ -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; + } +} diff --git a/designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java b/designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java new file mode 100644 index 0000000000..28b324def0 --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java @@ -0,0 +1,18 @@ +package com.fr.env.handler.impl; + +import com.fr.env.handler.Handler; +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 { + + @Override + public ResultWrapper handle(Throwable e) { + return new ResultWrapper(!(e instanceof CancellationException), e); + } +} diff --git a/designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java b/designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java new file mode 100644 index 0000000000..9449ba11ef --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java @@ -0,0 +1,48 @@ +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.ResultWrapper; +import javax.swing.SwingUtilities; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/8/5 + */ +public class CommonHandler implements Handler { + + private final boolean onSwitch; + + public CommonHandler(boolean onSwitch) { + this.onSwitch = onSwitch; + } + + @Override + public ResultWrapper handle(Throwable e) { + if (e instanceof ExceptionDescriptor) { + ExceptionDescriptor exceptionDescriptor = (ExceptionDescriptor) e; + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + 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(HelpLink.getLink(exceptionDescriptor.solution())). + setThrowable(e).build(); + detailErrorLinkDialog.setVisible(true); + } + }); + } + return new ResultWrapper(e); + } +} diff --git a/designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java b/designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java new file mode 100644 index 0000000000..67adf23548 --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java @@ -0,0 +1,21 @@ +package com.fr.env.handler.impl; + +import com.fr.env.handler.Handler; +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 { + + @Override + public ResultWrapper handle(Throwable e) { + if (e instanceof ExecutionException) { + return new ResultWrapper(e.getCause()); + } + return new ResultWrapper(e.getCause()); + } +} diff --git a/designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java b/designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java new file mode 100644 index 0000000000..5a47e7de5c --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java @@ -0,0 +1,24 @@ +package com.fr.env.handler.impl; + +import com.fr.base.exception.ExceptionDescriptor; +import com.fr.env.handler.Handler; +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 { + + @Override + public ResultWrapper handle(Throwable e) { + if (!(e instanceof ExceptionDescriptor)) { + return new ResultWrapper(ExceptionConverter.getInstance().convert(e)) ; + } + return new ResultWrapper(e); + } +} diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java index 220a4e39e2..dbebb5f992 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java +++ b/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.DesignerWorkspaceInfo; import com.fr.design.env.LocalDesignerWorkspaceInfo; -import com.fr.design.i18n.Toolkit; 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.EventDispatcher; import com.fr.event.Listener; @@ -21,7 +20,6 @@ import com.fr.stable.StringUtils; import com.fr.value.NotNullLazyValue; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; -import com.fr.workspace.engine.exception.WorkspaceCheckException; import org.jetbrains.annotations.NotNull; @@ -78,15 +76,7 @@ public class DesignerWorkspaceProvider extends Activator { }); } } catch (Throwable e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - 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")); - } - } + RemoteDesignExceptionHandler.getInstance().handleInStart(e, workspaceInfo); EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner(); } } From f0558e4e3faf402617c0dde6ed592d0e50be7bd0 Mon Sep 17 00:00:00 2001 From: hades Date: Mon, 9 Aug 2021 17:03:17 +0800 Subject: [PATCH 02/32] =?UTF-8?q?=E6=97=A0jira=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=86=B2=E7=AA=81=20=E9=94=99=E8=AF=AF=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/gui/controlpane/JControlPane.java | 1 - designer-realize/src/main/java/com/fr/poly/PolyConstants.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlPane.java index 36e5ea4f3c..0d01ddbdaa 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlPane.java @@ -120,7 +120,6 @@ abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper, S } public void showEditPane() { - // record this.cardLayout.show(cardPane, EDIT); } diff --git a/designer-realize/src/main/java/com/fr/poly/PolyConstants.java b/designer-realize/src/main/java/com/fr/poly/PolyConstants.java index a754bdff38..50eaa16dac 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyConstants.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyConstants.java @@ -14,5 +14,5 @@ public class PolyConstants { } // 操作聚合报表添加行(列)的组件的高(宽)度 - public static final int OPERATION_SIZE = 30; + public static final int OPERATION_SIZE = 15; } \ No newline at end of file From aadc1a145abd93ff3241b9254705a8a4ad658cf1 Mon Sep 17 00:00:00 2001 From: hades Date: Mon, 9 Aug 2021 17:05:15 +0800 Subject: [PATCH 03/32] =?UTF-8?q?=E6=97=A0jira=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=86=B2=E7=AA=81=20=E9=94=99=E8=AF=AF=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/ui/compatible/ModernUIPaneFactory.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java b/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java index 54b115264e..8616b647b4 100644 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java @@ -11,10 +11,10 @@ import com.fr.stable.os.OperatingSystem; public class ModernUIPaneFactory { public static ModernUIPane.Builder modernUIPaneBuilder() { -// if (OperatingSystem.isWindows()) { -// return new NewModernUIPane.Builder<>(); -// } else { -// } - return new ModernUIPane.Builder<>(); + if (OperatingSystem.isWindows()) { + return new NewModernUIPane.Builder<>(); + } else { + return new ModernUIPane.Builder<>(); + } } } From 1ad6e86411293606c552c911cb4e0ebd07aeaa54 Mon Sep 17 00:00:00 2001 From: hades Date: Mon, 9 Aug 2021 17:36:25 +0800 Subject: [PATCH 04/32] =?UTF-8?q?REPORT-55795=20=E3=80=9010.0.19=E3=80=91?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E8=A7=84=E8=8C=83=E2=80=94=E2=80=94=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=99=A8=E8=BF=9C=E7=A8=8B=E8=AE=BE=E8=AE=A1=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E9=83=A8=E5=88=86=20fix=20=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../env/RemoteDesignerWorkspaceInfoTest.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java b/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java index d6e89cd93f..e5fa7e3095 100644 --- a/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java +++ b/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java @@ -4,7 +4,10 @@ import com.fr.invoke.Reflect; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLReaderHelper; 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.WorkspaceConnector; import junit.framework.TestCase; import org.junit.Assert; @@ -18,15 +21,31 @@ import java.io.ByteArrayOutputStream; */ 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 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 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(workspaceInfo1.checkValid()); Assert.assertFalse(workspaceInfo2.checkValid()); Assert.assertFalse(workspaceInfo3.checkValid()); + WorkContext.setConnector(connector); } public void testReadXml() { From 4fbcdc4c8400e4d48263c6fdf5f8519bd8029011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Tue, 10 Aug 2021 17:01:48 +0800 Subject: [PATCH 05/32] =?UTF-8?q?REPORT-54885=20=E5=B8=83=E5=B1=80?= =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E9=97=A8=E6=A7=9B=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E6=B2=A1=E9=80=9A=E8=BF=87=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/designer/creator/XCreator.java | 7 ++ .../mainframe/EditingMouseListener.java | 3 +- .../com/fr/design/mainframe/FormDesigner.java | 65 ++++++++++++++++--- .../mainframe/FormSpacingLineDrawer.java | 22 +++---- .../widget/ui/FormMultiWidgetCardPane.java | 2 +- 5 files changed, 74 insertions(+), 25 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index 8980c09a12..ed90a1c540 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/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() { return ((XCreator) this.getParent()).acceptType(XWAbsoluteLayout.class); } + + public int getLevel() { + if (this.getParent() == null) { + return 1; + } + return ((XCreator) this.getParent()).getLevel() + 1; + } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index 87b55e1756..25726a5634 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -318,6 +318,8 @@ public class EditingMouseListener extends MouseInputAdapter { offsetEventPoint(e); XCreator component = designer.getComponentAt(e); + designer.getSpacingLineDrawer().updateMouseEvent(e, true); + setCoverPaneNotDisplay(component, e, false); if (processTopLayoutMouseMove(component, e)) { @@ -353,7 +355,6 @@ public class EditingMouseListener extends MouseInputAdapter { return; } - designer.getSpacingLineDrawer().updateMouseEvent(e, true); processChartEditorMouseMove(component, e); e.translatePoint(oldX - e.getX(), oldY - e.getY()); designer.repaint(); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java index 9f49de1d89..7d7b341663 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java @@ -835,6 +835,38 @@ public class FormDesigner extends TargetComponent
implements TreeSelection 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所在的组件 */ @@ -1095,25 +1127,38 @@ public class FormDesigner extends TargetComponent implements TreeSelection * */ @Override public XCreator getComponentAt(int x, int y) { - XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent; - if (container == null) { - 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); + XLayoutContainer container = getRootContainer(y); + XCreator result = xCreatorAt(getRelativeScaleX(x) - container.getX(), getRelativeScaleY(y) - container.getY(), container); return result == null ? getComponentAt(x, y, null) : result; } @Nullable 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; if (container == null) { container = rootComponent; } - XCreator comp = xCreatorAt(x + (int)(formArea.getHorizontalValue()/scale), (int)(y + formArea.getVerticalValue()/scale), container, - except); - return comp == null ? container : comp; + return container; + } + + 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() { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java index a46a59af49..f70df03c30 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java @@ -21,7 +21,7 @@ public class FormSpacingLineDrawer { private static final int MIN_SPACING = 10; private FormDesigner designer; - private XCreator hoverCreator; + private XCreator hoverCreator = null; private Rectangle selectedRec; private boolean isMouseMoveEvent = false; @@ -30,7 +30,10 @@ public class FormSpacingLineDrawer { } 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; } @@ -131,14 +134,6 @@ public class FormSpacingLineDrawer { 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) { return nearestSides[0].isVerticalCenterLineBeforeTheParallelLine(nearestSides[1]) || nearestSides[0].isVerticalCenterLineBehindTheParallelLine(nearestSides[1]); } @@ -147,12 +142,13 @@ public class FormSpacingLineDrawer { return isSelectedForm() || isSelectedRootComponent(); } - private boolean isHoveredRootPane() { - return isHoveredForm() || isHoveredRootComponent(); + private boolean isSelectedCreatorSameParentWithHoveredCreator() { + XCreator selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); + return selectedCreator != null && hoverCreator != null && selectedCreator.getParent() == hoverCreator.getParent(); } private boolean isDrawSpacingLine() { - return !isSelectedRootPane() && !isHoveredRootPane() && isMouseMoveEvent; + return !isSelectedRootPane() && isSelectedCreatorSameParentWithHoveredCreator() && isMouseMoveEvent; } private AbstractFormParallelLine[] getNearestHorizontalSide() { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java index 77e6a67d86..c1dda9cc95 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java @@ -32,10 +32,10 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane { public FormMultiWidgetCardPane(FormDesigner designer) { super(designer); - arrangement = new MultiSelectionArrangement(designer); } public void initPropertyPane() { + arrangement = new MultiSelectionArrangement(designer); content.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0)); content.add(createArrangementLayoutPane(), BorderLayout.CENTER); } From 6c28ceb1283c3eebc5683ff380c26ce2a749ff2e Mon Sep 17 00:00:00 2001 From: Lanlan Date: Tue, 10 Aug 2021 17:47:29 +0800 Subject: [PATCH 06/32] =?UTF-8?q?REPORT-54640=20-=20=E3=80=9010.0.19?= =?UTF-8?q?=E3=80=91=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=9F=8B=E7=82=B9=E9=87=8D?= =?UTF-8?q?=E6=9E=84=E5=89=A5=E7=A6=BB=E4=BA=8C=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reuse/ComponentReuseNotificationInfo.java | 14 +++++++++++++- .../fr/design/share/ui/generate/ShareMainPane.java | 13 +++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfo.java b/designer-base/src/main/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfo.java index 0ec6f26ad4..3d305d8ace 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfo.java +++ b/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 String historyCreatedReuses = "[]"; + public long getLastNotifyTime() { return lastNotifyTime; } @@ -62,12 +64,21 @@ public class ComponentReuseNotificationInfo implements XMLable { DesignerEnvManager.getEnvManager().saveXMLFile(); } + public String getHistoryCreatedReuses() { + return historyCreatedReuses; + } + + public void setHistoryCreatedReuses(String historyCreatedReuses) { + this.historyCreatedReuses = historyCreatedReuses; + } + @Override public void readXML(XMLableReader reader) { this.setLastNotifyTime(reader.getAttrAsLong("lastNotifyTime", 0L)); this.setNotifiedNumber(reader.getAttrAsInt("notifiedNumber", 0)); this.setClickedWidgetLib(reader.getAttrAsBoolean("clickedWidgetLib", false)); this.setLastGuidePopUpTime(reader.getAttrAsLong("lastGuidePopUpTime", 0L)); + this.setHistoryCreatedReuses(reader.getAttrAsString("historyCreatedReuses", "[]")); } @Override @@ -76,7 +87,8 @@ public class ComponentReuseNotificationInfo implements XMLable { writer.attr("lastNotifyTime", this.lastNotifyTime) .attr("notifiedNumber", this.notifiedNumber) .attr("clickedWidgetLib", this.clickedWidgetLib) - .attr("lastGuidePopUpTime", this.lastGuidePopUpTime); + .attr("lastGuidePopUpTime", this.lastGuidePopUpTime) + .attr("historyCreatedReuses", this.historyCreatedReuses);; writer.end(); } diff --git a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java b/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java index a4fc73fbe7..ea5298cf26 100644 --- a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java +++ b/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.DesignerLoginSource; 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.ComponentTypes; 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.group.DefaultShareGroupManager; 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.manage.PluginFilter; import com.fr.plugin.manage.PluginManager; @@ -622,6 +626,15 @@ public class ShareMainPane extends JPanel { provider.setDesignerVersion(ProductConstants.VERSION); provider.setVendor(loginLabel.getText()); 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) { provider.setSummary(content.getText()); From 70e34d8da4e81435e3b36815663a87fa57377e87 Mon Sep 17 00:00:00 2001 From: "Bruce.Deng" Date: Wed, 11 Aug 2021 09:35:48 +0800 Subject: [PATCH 07/32] =?UTF-8?q?REPORT-54891=20=E3=80=9010.0.19=E3=80=91?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=AF=BC=E5=87=BA=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javascript/ExportJavaScriptPane.java | 453 ++++++++++++++++++ .../javascript/JavaScriptActionPane.java | 4 + .../design/javascript/ListenerEditPane.java | 16 +- 3 files changed, 471 insertions(+), 2 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java diff --git a/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java b/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java new file mode 100644 index 0000000000..a1546025f9 --- /dev/null +++ b/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 { + + 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 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 list = parameterViewPane.update(); + HashSet 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("" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Front") + "\\/:*?\"<>|" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Back") + ""); + 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()); + DefaultComboBoxModel comboBoxModel = (DefaultComboBoxModel) 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 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 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 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); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java b/designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java index f54b070b0a..168d514049 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java @@ -44,6 +44,10 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane { contentDBManiPane.add(createDBManipulationPane()); paneList.add(new Commit2DBJavaScriptPane(this, contentDBManiPane)); paneList.add(initEmaiPane()); + boolean workbook = DesignerContext.getDesignerFrame().getSelectedJTemplate().isJWorkBook(); + if (workbook) { + paneList.add(new ExportJavaScriptPane()); + } Set javaScriptActionProviders = ExtraDesignClassManager.getInstance().getArray(JavaScriptActionProvider.XML_TAG); if (javaScriptActionProviders != null) { for (JavaScriptActionProvider jsp : javaScriptActionProviders) { diff --git a/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java b/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java index b89971f879..df05e7880d 100644 --- a/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java +++ b/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java @@ -25,6 +25,7 @@ import java.awt.FlowLayout; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Set; @@ -39,6 +40,7 @@ public class ListenerEditPane extends BasicBeanPane { 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 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; @@ -62,8 +64,12 @@ public class ListenerEditPane extends BasicBeanPane { nameText = new UITextField(8); nameText.setEditable(false); namePane.add(nameText, BorderLayout.WEST); - final String[] style = {JS, DBCOMMIT, CUSTOMACTION, EMAIL}; - styleBox = new UIComboBox(style); + final List style = new ArrayList<>(Arrays.asList(JS, DBCOMMIT, CUSTOMACTION, EMAIL)); + boolean workbook = DesignerContext.getDesignerFrame().getSelectedJTemplate().isJWorkBook(); + if (workbook) { + style.add(EXPORT); + } + styleBox = new UIComboBox(style.toArray()); namePane.add(styleBox); namePane = GUICoreUtils.createFlowPane(new Component[]{ new UILabel(" " + Toolkit.i18nText("Fine-Design_Report_Event_Name") + ":"), @@ -90,6 +96,12 @@ public class ListenerEditPane extends BasicBeanPane { // 发送邮件 EmailPane emailPane = new EmailPane(); hyperlinkPane.add(EMAIL, emailPane); + // 导出事件 + if (workbook) { + ExportJavaScriptPane exportJavaScriptPane = new ExportJavaScriptPane(); + hyperlinkPane.add(EXPORT, exportJavaScriptPane); + cards.add(exportJavaScriptPane); + } cards.add(javaScriptPane); cards.add(commit2DBJavaScriptPane); cards.add(customActionPane); From e40b2d1c1fa5a9aefdeb301e8fcc0d546127451e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Wed, 11 Aug 2021 11:03:44 +0800 Subject: [PATCH 08/32] =?UTF-8?q?CHART-20211=20=E9=9D=A2=E6=9D=BF=E9=97=B4?= =?UTF-8?q?=E8=B7=9D=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/gui/style/series/UIColorPickerPane.java | 10 +++++++--- .../fr/van/chart/gauge/VanChartGaugeSeriesPane.java | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java index fb2d1c31ad..6529efce05 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java +++ b/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() { 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 { - 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, - 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; } + protected int getPreferredMarginY() { + return MARGIN_TOP; + } + /** *刷新颜色选取器 * @param colorArray 颜色值 diff --git a/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java index afdd2d4ca9..d3f997295b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java @@ -132,6 +132,10 @@ public class VanChartGaugeSeriesPane extends VanChartMultiColorSeriesPane { return 10; } + protected int getPreferredMarginY() { + return 10; + } + protected double getDescriptionWidth() { double descriptionWidth = super.getDescriptionWidth(); if (valueFillStylePane == null) { From 182b9164dcda7cd6e67ad1ce7ab23d7865e2f662 Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 11 Aug 2021 13:34:56 +0800 Subject: [PATCH 09/32] =?UTF-8?q?REPORT-55795=20=E3=80=9010.0.19=E3=80=91?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E8=A7=84=E8=8C=83=E2=80=94=E2=80=94=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=99=A8=E8=BF=9C=E7=A8=8B=E8=AE=BE=E8=AE=A1=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/EnvChangeEntrance.java | 2 ++ .../fr/design/dialog/UIDetailErrorLinkDialog.java | 14 +++++++++++++- .../src/main/java/com/fr/env/HelpLink.java | 12 ++++++++++-- .../src/main/java/com/fr/env/RemoteEnvPane.java | 1 + .../com/fr/env/handler/impl/CancelHandler.java | 2 ++ .../com/fr/env/handler/impl/CommonHandler.java | 1 + 6 files changed, 29 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 785f3b92b8..606013ed1e 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -20,6 +20,7 @@ import com.fr.design.notification.NotificationCenter; import com.fr.design.utils.DesignUtils; import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.env.EnvListPane; +import com.fr.env.HelpLink; import com.fr.env.handler.RemoteDesignExceptionHandler; import com.fr.exit.DesignerExiter; import com.fr.general.GeneralUtils; @@ -139,6 +140,7 @@ public class EnvChangeEntrance { pluginErrorRemind(); } catch (Exception exception) { // 失败的处理 + HelpLink.setConnectionInfo(connectionInfo); RemoteDesignExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv); return false; } diff --git a/designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java b/designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java index b487714f91..b9854c6bcd 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java +++ b/designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java @@ -44,6 +44,7 @@ public class UIDetailErrorLinkDialog extends UIDialog { private static final int GAP_10 = 10; private static final String TAG_A_START = ""; private static final String TAG_A_END = ""; + private static final double SCALE = 1.2; private final Dimension dimension = new Dimension(300, 180); @@ -99,6 +100,7 @@ public class UIDetailErrorLinkDialog extends UIDialog { this.getContentPane().add(actionPane, BorderLayout.SOUTH); this.setSize(dimension); this.setResizable(false); + this.setModal(true); GUICoreUtils.centerWindow(this); } @@ -139,11 +141,21 @@ public class UIDetailErrorLinkDialog extends UIDialog { UILabel solutionLabel = new UILabel(solution); panel.add(solutionLabel, BorderLayout.CENTER); } - dimension.width = Math.max(maxWidth, GraphHelper.getWidth(solution, DesignUtils.getDefaultGUIFont())); + 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 diff --git a/designer-base/src/main/java/com/fr/env/HelpLink.java b/designer-base/src/main/java/com/fr/env/HelpLink.java index 87975761f9..dda75a9247 100644 --- a/designer-base/src/main/java/com/fr/env/HelpLink.java +++ b/designer-base/src/main/java/com/fr/env/HelpLink.java @@ -5,28 +5,36 @@ import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.general.locale.LocaleCenter; import com.fr.general.locale.LocaleMark; import com.fr.locale.InterProviderFactory; +import com.fr.workspace.connect.WorkspaceConnectionInfo; import java.util.HashMap; import java.util.Map; /** + * 错误提示中的跳转链接管理 + * * @author hades * @version 10.0 * Created by hades on 2021/8/9 */ public class HelpLink { + private static WorkspaceConnectionInfo connectionInfo; + public static String getLink(String solution) { Map map = new HashMap<>(); String currentName = DesignerEnvManager.getEnvManager().getCurEnvName(); DesignerWorkspaceInfo workspaceInfo = DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentName); LocaleMark linkMark = LocaleCenter.getMark(RemoteDesignLocaleMark.class); String link = linkMark.getValue(); - map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Change_PassWord"), workspaceInfo.getConnection().getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH); + String url = connectionInfo == null ? workspaceInfo.getConnection().getUrl() : connectionInfo.getUrl(); + map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Change_PassWord"), url + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH); 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); } - + public static void setConnectionInfo(WorkspaceConnectionInfo connectionInfo) { + HelpLink.connectionInfo = connectionInfo; + } } diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index 1ea909ccca..6d34cd7c07 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -596,6 +596,7 @@ public class RemoteEnvPane extends BasicBeanPane { } } catch (Exception e) { dialog.dispose(); + HelpLink.setConnectionInfo(connection); RemoteDesignExceptionHandler.getInstance().handleInTest(e); } dialogDownPane.remove(cancelButton); diff --git a/designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java b/designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java index 28b324def0..dc36cb4db9 100644 --- a/designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java +++ b/designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java @@ -5,6 +5,8 @@ import com.fr.env.handler.ResultWrapper; import java.util.concurrent.CancellationException; /** + * 取消测试连接时的处理器 + * * @author hades * @version 10.0 * Created by hades on 2021/8/5 diff --git a/designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java b/designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java index 9449ba11ef..dd6a1e52e4 100644 --- a/designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java +++ b/designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java @@ -40,6 +40,7 @@ public class CommonHandler implements Handler { setLink(HelpLink.getLink(exceptionDescriptor.solution())). setThrowable(e).build(); detailErrorLinkDialog.setVisible(true); + HelpLink.setConnectionInfo(null); } }); } From 7268eacb44028581cf038679880e834ad3f85a4d Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 11 Aug 2021 14:14:02 +0800 Subject: [PATCH 10/32] =?UTF-8?q?REPORT-55795=20=E3=80=9010.0.19=E3=80=91?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E8=A7=84=E8=8C=83=E2=80=94=E2=80=94=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=99=A8=E8=BF=9C=E7=A8=8B=E8=AE=BE=E8=AE=A1=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E9=83=A8=E5=88=86=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 2 -- .../src/main/java/com/fr/env/HelpLink.java | 14 ++-------- .../main/java/com/fr/env/RemoteEnvPane.java | 3 +- .../java/com/fr/env/handler/RefWrapper.java | 28 +++++++++++++++++++ .../handler/RemoteDesignExceptionHandler.java | 20 +++++++------ .../fr/env/handler/impl/CancelHandler.java | 6 ++-- .../fr/env/handler/impl/CommonHandler.java | 11 +++++--- .../fr/env/handler/impl/ExecutionHandler.java | 8 ++++-- .../env/handler/impl/UnexpectedHandler.java | 6 ++-- 9 files changed, 62 insertions(+), 36 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/env/handler/RefWrapper.java diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 606013ed1e..785f3b92b8 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -20,7 +20,6 @@ import com.fr.design.notification.NotificationCenter; import com.fr.design.utils.DesignUtils; import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.env.EnvListPane; -import com.fr.env.HelpLink; import com.fr.env.handler.RemoteDesignExceptionHandler; import com.fr.exit.DesignerExiter; import com.fr.general.GeneralUtils; @@ -140,7 +139,6 @@ public class EnvChangeEntrance { pluginErrorRemind(); } catch (Exception exception) { // 失败的处理 - HelpLink.setConnectionInfo(connectionInfo); RemoteDesignExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv); return false; } diff --git a/designer-base/src/main/java/com/fr/env/HelpLink.java b/designer-base/src/main/java/com/fr/env/HelpLink.java index dda75a9247..c717ce6ea6 100644 --- a/designer-base/src/main/java/com/fr/env/HelpLink.java +++ b/designer-base/src/main/java/com/fr/env/HelpLink.java @@ -1,11 +1,9 @@ package com.fr.env; -import com.fr.design.DesignerEnvManager; -import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.general.locale.LocaleCenter; import com.fr.general.locale.LocaleMark; import com.fr.locale.InterProviderFactory; -import com.fr.workspace.connect.WorkspaceConnectionInfo; +import com.fr.stable.StringUtils; import java.util.HashMap; import java.util.Map; @@ -18,23 +16,15 @@ import java.util.Map; */ public class HelpLink { - private static WorkspaceConnectionInfo connectionInfo; - public static String getLink(String solution) { Map map = new HashMap<>(); - String currentName = DesignerEnvManager.getEnvManager().getCurEnvName(); - DesignerWorkspaceInfo workspaceInfo = DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentName); LocaleMark linkMark = LocaleCenter.getMark(RemoteDesignLocaleMark.class); String link = linkMark.getValue(); - String url = connectionInfo == null ? workspaceInfo.getConnection().getUrl() : connectionInfo.getUrl(); - map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Change_PassWord"), url + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH); + 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); } - public static void setConnectionInfo(WorkspaceConnectionInfo connectionInfo) { - HelpLink.connectionInfo = connectionInfo; - } } diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index 6d34cd7c07..17dc72dba5 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -596,8 +596,7 @@ public class RemoteEnvPane extends BasicBeanPane { } } catch (Exception e) { dialog.dispose(); - HelpLink.setConnectionInfo(connection); - RemoteDesignExceptionHandler.getInstance().handleInTest(e); + RemoteDesignExceptionHandler.getInstance().handleInTest(e, remoteEnv); } dialogDownPane.remove(cancelButton); dialogDownPane.revalidate(); diff --git a/designer-base/src/main/java/com/fr/env/handler/RefWrapper.java b/designer-base/src/main/java/com/fr/env/handler/RefWrapper.java new file mode 100644 index 0000000000..a2db84d239 --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/handler/RefWrapper.java @@ -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; + } +} diff --git a/designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java b/designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java index 81d10611fd..7e6154eeee 100644 --- a/designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java +++ b/designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java @@ -5,6 +5,7 @@ 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; @@ -30,9 +31,9 @@ public class RemoteDesignExceptionHandler { return INSTANCE; } - private final List> testList = new ArrayList<>(); + private final List> testList = new ArrayList<>(); - private final List> switchList = new ArrayList<>(); + private final List> switchList = new ArrayList<>(); private RemoteDesignExceptionHandler() { // 要保证顺序 @@ -47,11 +48,12 @@ public class RemoteDesignExceptionHandler { switchList.add(new CommonHandler(true)); } - public void handle(Throwable e, List> list) { + public void handle(Throwable e, List> list, DesignerWorkspaceInfo workspaceInfo) { Throwable throwable = e; ResultWrapper wrapper; - for (Handler handler : list) { - wrapper = handler.handle(throwable); + String link = workspaceInfo.getConnection().getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH; + for (Handler handler : list) { + wrapper = handler.handle(new RefWrapper(throwable, link)); throwable = wrapper.getThrowable(); if (!wrapper.isNext()) { break; @@ -70,7 +72,7 @@ public class RemoteDesignExceptionHandler { UIManager.getIcon("OptionPane.errorIcon")); return; } - handle(e, switchList); + handle(e, switchList, workspaceInfo); } public void handleInStart(Throwable e, DesignerWorkspaceInfo workspaceInfo) { @@ -78,11 +80,11 @@ public class RemoteDesignExceptionHandler { FineLoggerFactory.getLogger().error(e.getMessage(), e); return; } - handle(e, testList); + handle(e, testList, workspaceInfo); } - public void handleInTest(Throwable e) { - handle(e, testList); + public void handleInTest(Throwable e, DesignerWorkspaceInfo workspaceInfo) { + handle(e, testList, workspaceInfo); } } diff --git a/designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java b/designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java index dc36cb4db9..140d0ec136 100644 --- a/designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java +++ b/designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java @@ -1,6 +1,7 @@ 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; @@ -11,10 +12,11 @@ import java.util.concurrent.CancellationException; * @version 10.0 * Created by hades on 2021/8/5 */ -public class CancelHandler implements Handler { +public class CancelHandler implements Handler { @Override - public ResultWrapper handle(Throwable e) { + public ResultWrapper handle(RefWrapper wrapper) { + Throwable e = wrapper.getThrowable(); return new ResultWrapper(!(e instanceof CancellationException), e); } } diff --git a/designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java b/designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java index dd6a1e52e4..2fc8f9e156 100644 --- a/designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java +++ b/designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java @@ -7,7 +7,9 @@ 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; /** @@ -15,7 +17,7 @@ import javax.swing.SwingUtilities; * @version 10.0 * Created by hades on 2021/8/5 */ -public class CommonHandler implements Handler { +public class CommonHandler implements Handler { private final boolean onSwitch; @@ -24,12 +26,14 @@ public class CommonHandler implements Handler { } @Override - public ResultWrapper handle(Throwable e) { + 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()). @@ -37,10 +41,9 @@ public class CommonHandler implements Handler { setSolution(exceptionDescriptor.solution()). setDetailReason(exceptionDescriptor.detailReason()). setTitle(Toolkit.i18nText("Fine-Design_Basic_Connection_Failed")). - setLink(HelpLink.getLink(exceptionDescriptor.solution())). + setLink(StringUtils.isEmpty(link) ? wrapper.getLink() : link). setThrowable(e).build(); detailErrorLinkDialog.setVisible(true); - HelpLink.setConnectionInfo(null); } }); } diff --git a/designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java b/designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java index 67adf23548..5388935ea1 100644 --- a/designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java +++ b/designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java @@ -1,6 +1,7 @@ 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; @@ -9,13 +10,14 @@ import java.util.concurrent.ExecutionException; * @version 10.0 * Created by hades on 2021/8/5 */ -public class ExecutionHandler implements Handler { +public class ExecutionHandler implements Handler { @Override - public ResultWrapper handle(Throwable e) { + public ResultWrapper handle(RefWrapper wrapper) { + Throwable e = wrapper.getThrowable(); if (e instanceof ExecutionException) { return new ResultWrapper(e.getCause()); } - return new ResultWrapper(e.getCause()); + return new ResultWrapper(e); } } diff --git a/designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java b/designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java index 5a47e7de5c..28a2b645df 100644 --- a/designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java +++ b/designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java @@ -2,6 +2,7 @@ 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; @@ -12,10 +13,11 @@ import com.fr.workspace.engine.convert.ExceptionConverter; * @version 10.0 * Created by hades on 2021/8/5 */ -public class UnexpectedHandler implements Handler { +public class UnexpectedHandler implements Handler { @Override - public ResultWrapper handle(Throwable e) { + public ResultWrapper handle(RefWrapper wrapper) { + Throwable e = wrapper.getThrowable(); if (!(e instanceof ExceptionDescriptor)) { return new ResultWrapper(ExceptionConverter.getInstance().convert(e)) ; } From fa9c285c7d5868582f894de2fc13665f0deb0ebc Mon Sep 17 00:00:00 2001 From: pengda Date: Thu, 12 Aug 2021 13:56:30 +0800 Subject: [PATCH 11/32] =?UTF-8?q?REPORT-55637=20=E8=BF=9C=E7=A8=8B?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E7=9A=84=20=E8=AE=B0=E4=BD=8F=E5=AF=86?= =?UTF-8?q?=E7=A0=81=20=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E5=8B=BE=E9=80=89=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/EnvChangeEntrance.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 14145d1197..3015cb858c 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -450,7 +450,7 @@ public class EnvChangeEntrance { // 切换完成后清理密码 updateNotRememberPwdEnv(); if (changeResult) { - VersionCheckUtils.showVersionCheckDialog(envListPane.updateEnvManager()); + VersionCheckUtils.showVersionCheckDialog(envListPane.getSelectedName()); } } @@ -483,7 +483,7 @@ public class EnvChangeEntrance { DesignerExiter.getInstance().execute(); } else { updateNotRememberPwdEnv(); - VersionCheckUtils.showVersionCheckDialog(envListPane.updateEnvManager()); + VersionCheckUtils.showVersionCheckDialog(envListPane.getSelectedName()); } } From 9cca8d76715af0da7c6e62f7d1df39573339b279 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Fri, 13 Aug 2021 09:36:06 +0800 Subject: [PATCH 12/32] =?UTF-8?q?REPORT-55696=20=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96-=E8=BF=9C=E7=A8=8B=E7=89=88=E6=9C=AC=E4=B8=8D?= =?UTF-8?q?=E4=B8=80=E8=87=B4=E7=9A=84=E6=8F=90=E7=A4=BA=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E5=9C=A8=E9=9D=9E=E4=B8=AD=E6=96=87=E4=B8=8B=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=B8=8D=E5=85=A8=20&&=20REPORT-55415=20=E5=AF=8C=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E6=A1=86=EF=BC=8C=E9=BC=A0=E6=A0=87=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=E7=9A=84=E5=AD=97=E4=BD=93=EF=BC=8C=E4=BC=9A?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E6=89=80=E9=80=89=E5=AD=97=E4=BD=93=E9=83=BD?= =?UTF-8?q?=E5=8F=98=E6=88=90=E4=B8=80=E6=A0=B7=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/dialog/NotificationDialog.java | 12 +- .../versioncheck/VersionCheckUtils.java | 3 +- .../fr/design/i18n/dimension_en.properties | 3 +- .../fr/design/i18n/dimension_ja_JP.properties | 3 +- .../fr/design/i18n/dimension_ko_KR.properties | 3 +- .../fr/design/i18n/dimension_zh.properties | 3 +- .../fr/design/i18n/dimension_zh_TW.properties | 3 +- .../design/cell/editor/RichTextToolBar.java | 948 +++++++++--------- 8 files changed, 500 insertions(+), 478 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java b/designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java index b136f50c89..258a6cf8a5 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java +++ b/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.design.gui.ilable.UILabel; +import com.fr.design.i18n.DesignSizeI18nManager; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; 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.module.ModuleContext; import com.fr.stable.StringUtils; + import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; @@ -40,9 +42,17 @@ public class NotificationDialog extends JDialog { private UILabel messageText; private NotificationDialogAction notificationDialogAction; private ScheduledExecutorService TIMER; + private Dimension dialogSize = new Dimension(230, 95); 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); + if (dimension != null) { + this.dialogSize = dimension; + } setTitle(title); 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.setBorder(BorderFactory.createEmptyBorder()); centerPanel.add(jScrollPane, BorderLayout.CENTER); - centerPanel.setPreferredSize(new Dimension(230, 95)); + centerPanel.setPreferredSize(dialogSize); body.add(centerPanel, BorderLayout.CENTER); //查看详情 diff --git a/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java b/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java index 24431cd957..e5624c4531 100644 --- a/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java +++ b/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.DesignerWorkspaceType; import com.fr.design.env.RemoteWorkspace; +import com.fr.design.i18n.DesignSizeI18nManager; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; 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.setVisible(true); } - }); + },DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.version.check.dialog")); notificationDialog.setVisible(true); } diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties index 6a227a996a..bd26abb1be 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties @@ -3,4 +3,5 @@ com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=630*185 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=630*31 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=630*280 com.fr.design.report.ReportColumnsPane=800*600 -com.fr.env.RemoteEnvPane.dialog=458*132 \ No newline at end of file +com.fr.env.RemoteEnvPane.dialog=458*132 +com.fr.design.version.check.dialog=490*95 \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties index db3632a293..5a0cb009e3 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties @@ -2,4 +2,5 @@ com.fr.design.mainframe.check.CheckButton=280*118 com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=610*185 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=610*31 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=610*280 -com.fr.env.RemoteEnvPane.dialog=458*132 \ No newline at end of file +com.fr.env.RemoteEnvPane.dialog=458*132 +com.fr.design.version.check.dialog=430*95 \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties index b9d7ef15ab..17a8209db6 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties @@ -2,4 +2,5 @@ com.fr.design.mainframe.check.CheckButton=230*118 com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=490*185 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=490*35 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=490*280 -com.fr.env.RemoteEnvPane.dialog=458*132 \ No newline at end of file +com.fr.env.RemoteEnvPane.dialog=458*132 +com.fr.design.version.check.dialog=450*95 \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties index 818a9d5d62..1c5f50ccaa 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties @@ -3,4 +3,5 @@ com.fr.design.mainframe.check.CheckButton=250*118 com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=385*185 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=385*31 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=385*280 -com.fr.env.RemoteEnvPane.dialog=308*132 \ No newline at end of file +com.fr.env.RemoteEnvPane.dialog=308*132 +com.fr.design.version.check.dialog=230*95 \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties index 87d117140e..fcbcb8c52a 100644 --- a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties @@ -2,4 +2,5 @@ com.fr.design.mainframe.check.CheckButton=250*118 com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=385*185 com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=385*31 com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=385*280 -com.fr.env.RemoteEnvPane.dialog=308*132 \ No newline at end of file +com.fr.env.RemoteEnvPane.dialog=308*132 +com.fr.design.version.check.dialog=230*95 \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java b/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java index 5f0fd27d2f..f95681be32 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java +++ b/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java @@ -58,14 +58,14 @@ import java.math.BigDecimal; * * @date: 2014-12-5-下午1:10:31 */ -public class RichTextToolBar extends BasicPane{ +public class RichTextToolBar extends BasicPane { private static final Dimension BUTTON_SIZE = new Dimension(24, 20); - /** - * 富文本字体下拉框默认首选字体 非设计器UI界面字体 - */ - private static final FRFont DEFAULT_FONT = FRContext.getDefaultValues().getFRFont().applySize(13); + /** + * 富文本字体下拉框默认首选字体 非设计器UI界面字体 + */ + private static final FRFont DEFAULT_FONT = FRContext.getDefaultValues().getFRFont().applySize(13); private UIComboBox fontNameComboBox; private UIComboBox fontSizeComboBox; @@ -86,9 +86,9 @@ public class RichTextToolBar extends BasicPane{ } public RichTextToolBar(RichTextEditingPane textPane) { - this.textPane = textPane; + this.textPane = textPane; - this.initComponents(); + this.initComponents(); } @Override @@ -97,18 +97,18 @@ public class RichTextToolBar extends BasicPane{ } protected void initComponents() { - //初始化并设置所有按钮样式 + //初始化并设置所有按钮样式 initAllButton(); //添加到工具栏 addToToolBar(); } - private void initAllButton(){ + private void initAllButton() { fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); fontNameComboBox.setPreferredSize(new Dimension(144, 20)); - fontSizeComboBox = new UIComboBox(FRFontPane.getFontSizes()); - colorSelectPane = new UIToolbarColorButton(BaseUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); - colorSelectPane.set4Toolbar(); + fontSizeComboBox = new UIComboBox(FRFontPane.getFontSizes()); + colorSelectPane = new UIToolbarColorButton(BaseUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); + colorSelectPane.set4Toolbar(); bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); @@ -123,28 +123,28 @@ public class RichTextToolBar extends BasicPane{ setToolTips(); //样式 setAllButtonStyle(); - //绑定监听器 + //绑定监听器 bindListener(); } - private void setAllButtonStyle(){ - setButtonStyle(bold); - setButtonStyle(italic); - setButtonStyle(underline); - setButtonStyle(subPane); - setButtonStyle(superPane); - setButtonStyle(formulaPane); + private void setAllButtonStyle() { + setButtonStyle(bold); + setButtonStyle(italic); + setButtonStyle(underline); + setButtonStyle(subPane); + setButtonStyle(superPane); + setButtonStyle(formulaPane); } - private void setButtonStyle(UIButton button){ - button.setNormalPainted(false); - button.setBackground(null); - button.setOpaque(false); - button.setPreferredSize(BUTTON_SIZE); - button.setBorderPaintedOnlyWhenPressed(true); + private void setButtonStyle(UIButton button) { + button.setNormalPainted(false); + button.setBackground(null); + button.setOpaque(false); + button.setPreferredSize(BUTTON_SIZE); + button.setBorderPaintedOnlyWhenPressed(true); } - private void addToToolBar(){ + private void addToToolBar() { this.setLayout(new FlowLayout(FlowLayout.LEFT)); this.add(fontNameComboBox); @@ -158,12 +158,12 @@ public class RichTextToolBar extends BasicPane{ this.add(formulaPane); } - private void bindListener(){ - // 这里下拉框默认选中字体 不由UI界面字体决定 两套不同体系 + private void bindListener() { + // 这里下拉框默认选中字体 不由UI界面字体决定 两套不同体系 fontNameComboBox.addItemListener(fontNameItemListener); - fontNameComboBox.setSelectedItem(DEFAULT_FONT.getFamily()); + fontNameComboBox.setSelectedItem(DEFAULT_FONT.getFamily()); fontSizeComboBox.addItemListener(fontSizeItemListener); - fontSizeComboBox.setSelectedItem(scaleDown(DEFAULT_FONT.getSize())); + fontSizeComboBox.setSelectedItem(scaleDown(DEFAULT_FONT.getSize())); bold.addActionListener(blodChangeAction); italic.addActionListener(itaChangeAction); @@ -200,466 +200,472 @@ public class RichTextToolBar extends BasicPane{ } /** - * 移除输入监听 - * 用于populate时, 插入字符串, 那时不需要插入监听 - * - * - * @date 2015-1-5-下午5:13:04 - * - */ - public void removeInputListener(){ - this.textPane.getDocument().removeDocumentListener(inputListener); + * 移除输入监听 + * 用于populate时, 插入字符串, 那时不需要插入监听 + * + * + * @date 2015-1-5-下午5:13:04 + * + */ + public void removeInputListener() { + this.textPane.getDocument().removeDocumentListener(inputListener); } /** - * 增加输入监听事件 - * - * - * @date 2015-1-5-下午5:13:26 - * - */ - public void addInputListener(){ - this.textPane.getDocument().addDocumentListener(inputListener); + * 增加输入监听事件 + * + * + * @date 2015-1-5-下午5:13:26 + * + */ + public void addInputListener() { + this.textPane.getDocument().addDocumentListener(inputListener); } private ActionListener blodChangeAction = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - boolean isBold = RichTextToolBar.this.bold.isSelected(); - // 调用setCharacterAttributes函数设置文本区选择文本的字体 - MutableAttributeSet attr = new SimpleAttributeSet(); - StyleConstants.setBold(attr, !isBold); - setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); - } - }; - - private ActionListener itaChangeAction = new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - boolean isIta = RichTextToolBar.this.italic.isSelected(); - // 调用setCharacterAttributes函数设置文本区选择文本的字体 - MutableAttributeSet attr = new SimpleAttributeSet(); - StyleConstants.setItalic(attr, !isIta); - setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); - } - }; - - private ActionListener underlineChangeAction = new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - boolean isUnder = RichTextToolBar.this.underline.isSelected(); - // 调用setCharacterAttributes函数设置文本区选择文本的字体 - MutableAttributeSet attr = new SimpleAttributeSet(); - StyleConstants.setUnderline(attr, !isUnder); - setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); - } - }; - private ActionListener subChangeAction = new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - boolean isSub = RichTextToolBar.this.subPane.isSelected(); - MutableAttributeSet attr = new SimpleAttributeSet(); - if (!isSub && RichTextToolBar.this.superPane.isSelected()) { - RichTextToolBar.this.superPane.setSelected(false); - StyleConstants.setSuperscript(attr, false); - } - // 调用setCharacterAttributes函数设置文本区选择文本的字体 - StyleConstants.setSubscript(attr, !isSub); - setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); - } - }; - private ActionListener superChangeAction = new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - boolean isSuper = RichTextToolBar.this.superPane.isSelected(); - // 调用setCharacterAttributes函数设置文本区选择文本的字体 - MutableAttributeSet attr = new SimpleAttributeSet(); - if (!isSuper && RichTextToolBar.this.subPane.isSelected()) { - RichTextToolBar.this.subPane.setSelected(false); - StyleConstants.setSubscript(attr, false); - } - StyleConstants.setSuperscript(attr, !isSuper); - setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); - } - }; - - private ChangeListener colorChangeAction = new ChangeListener() { + @Override + public void actionPerformed(ActionEvent e) { + boolean isBold = RichTextToolBar.this.bold.isSelected(); + // 调用setCharacterAttributes函数设置文本区选择文本的字体 + MutableAttributeSet attr = new SimpleAttributeSet(); + StyleConstants.setBold(attr, !isBold); + setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); + } + }; + + private ActionListener itaChangeAction = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + boolean isIta = RichTextToolBar.this.italic.isSelected(); + // 调用setCharacterAttributes函数设置文本区选择文本的字体 + MutableAttributeSet attr = new SimpleAttributeSet(); + StyleConstants.setItalic(attr, !isIta); + setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); + } + }; + + private ActionListener underlineChangeAction = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + boolean isUnder = RichTextToolBar.this.underline.isSelected(); + // 调用setCharacterAttributes函数设置文本区选择文本的字体 + MutableAttributeSet attr = new SimpleAttributeSet(); + StyleConstants.setUnderline(attr, !isUnder); + setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); + } + }; + private ActionListener subChangeAction = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + boolean isSub = RichTextToolBar.this.subPane.isSelected(); + MutableAttributeSet attr = new SimpleAttributeSet(); + if (!isSub && RichTextToolBar.this.superPane.isSelected()) { + RichTextToolBar.this.superPane.setSelected(false); + StyleConstants.setSuperscript(attr, false); + } + // 调用setCharacterAttributes函数设置文本区选择文本的字体 + StyleConstants.setSubscript(attr, !isSub); + setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); + } + }; + private ActionListener superChangeAction = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + boolean isSuper = RichTextToolBar.this.superPane.isSelected(); + // 调用setCharacterAttributes函数设置文本区选择文本的字体 + MutableAttributeSet attr = new SimpleAttributeSet(); + if (!isSuper && RichTextToolBar.this.subPane.isSelected()) { + RichTextToolBar.this.subPane.setSelected(false); + StyleConstants.setSubscript(attr, false); + } + StyleConstants.setSuperscript(attr, !isSuper); + setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); + } + }; + + private ChangeListener colorChangeAction = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - Color color = RichTextToolBar.this.colorSelectPane.getColor(); - color = color == null ? Color.BLACK : color; - // 调用setCharacterAttributes函数设置文本区选择文本的字体 - MutableAttributeSet attr = new SimpleAttributeSet(); - StyleConstants.setForeground(attr, color); - setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); + Color color = RichTextToolBar.this.colorSelectPane.getColor(); + color = color == null ? Color.BLACK : color; + // 调用setCharacterAttributes函数设置文本区选择文本的字体 + MutableAttributeSet attr = new SimpleAttributeSet(); + StyleConstants.setForeground(attr, color); + setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); } }; - // 设置文本区选择文本的样式 - private void setCharacterAttributes(JEditorPane editor, AttributeSet attr, - boolean replace) { - //注意不要失焦 - textPane.requestFocus(); - - // 取得选择文本的起始位置和结束位置 - int start = editor.getSelectionStart(); - int end = editor.getSelectionEnd(); - - // 如果选中文本,设置选中文本的样式 - if (start != end) { - StyledDocument doc = (StyledDocument) textPane.getDocument(); - // 将所选文本设置为新的样式,replace为false表示不覆盖原有的样式 - doc.setCharacterAttributes(start, end - start, attr, replace); - } - } - - private ItemListener fontSizeItemListener = new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - int fontSize = (Integer) RichTextToolBar.this.fontSizeComboBox.getSelectedItem(); - fontSize= scaleUp(fontSize); - // 调用setCharacterAttributes函数设置文本区选择文本的字体 - MutableAttributeSet attr = new SimpleAttributeSet(); - StyleConstants.setFontSize(attr, fontSize); - setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); - } + // 设置文本区选择文本的样式 + private void setCharacterAttributes(JEditorPane editor, AttributeSet attr, + boolean replace) { + //注意不要失焦 + textPane.requestFocus(); + + // 取得选择文本的起始位置和结束位置 + int start = editor.getSelectionStart(); + int end = editor.getSelectionEnd(); + + // 如果选中文本,设置选中文本的样式 + if (start != end) { + StyledDocument doc = (StyledDocument) textPane.getDocument(); + // 将所选文本设置为新的样式,replace为false表示不覆盖原有的样式 + doc.setCharacterAttributes(start, end - start, attr, replace); + } + } + + private ItemListener fontSizeItemListener = new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + int fontSize = (Integer) RichTextToolBar.this.fontSizeComboBox.getSelectedItem(); + fontSize = scaleUp(fontSize); + // 调用setCharacterAttributes函数设置文本区选择文本的字体 + MutableAttributeSet attr = new SimpleAttributeSet(); + StyleConstants.setFontSize(attr, fontSize); + setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); + } }; - private ItemListener fontNameItemListener = new ItemListener() { + private ItemListener fontNameItemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { - String fontName = (String) RichTextToolBar.this.fontNameComboBox.getSelectedItem(); - // 调用setCharacterAttributes函数设置文本区选择文本的字体 - MutableAttributeSet attr = new SimpleAttributeSet(); - StyleConstants.setFontFamily(attr, fontName); - setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); + String fontName = (String) RichTextToolBar.this.fontNameComboBox.getSelectedItem(); + if (fontName != null) { + // 调用setCharacterAttributes函数设置文本区选择文本的字体 + MutableAttributeSet attr = new SimpleAttributeSet(); + StyleConstants.setFontFamily(attr, fontName); + setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); + } } }; - private ActionListener formulaActionListener = new ActionListener() { - public void actionPerformed(ActionEvent evt) { - final UIFormula formulaPane = FormulaFactory.createFormulaPane(); - formulaPane.populate(BaseFormula.createFormulaBuilder().build()); - formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { - @Override - public void doOk() { - StyledDocument doc = (StyledDocument) textPane.getDocument(); - BaseFormula fm = formulaPane.update(); - String content = RichTextConverter.asFormula(fm.getContent()); - int start = textPane.getSelectionStart(); + private ActionListener formulaActionListener = new ActionListener() { + public void actionPerformed(ActionEvent evt) { + final UIFormula formulaPane = FormulaFactory.createFormulaPane(); + formulaPane.populate(BaseFormula.createFormulaBuilder().build()); + formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + StyledDocument doc = (StyledDocument) textPane.getDocument(); + BaseFormula fm = formulaPane.update(); + String content = RichTextConverter.asFormula(fm.getContent()); + int start = textPane.getSelectionStart(); AttributeSet attrs = start > 0 ? doc.getCharacterElement(start - 1).getAttributes() : new SimpleAttributeSet(); - try { - doc.insertString(start, content, attrs); - } catch (BadLocationException e) { + try { + doc.insertString(start, content, attrs); + } catch (BadLocationException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - }).setVisible(true); - } - }; - - private int roundUp(double num){ - String numStr = Double.toString(num); - numStr = new BigDecimal(numStr).setScale(0, BigDecimal.ROUND_HALF_UP).toString(); - return Integer.valueOf(numStr); - } - - private CaretListener textCareListener = new CaretListener() { - - //根据选中部分的文字样式, 来动态显示工具栏上按钮的状态 - private void setSelectedCharStyle(int start, int end, StyledDocument doc){ - boolean isBold = true; - boolean isItalic = true; - boolean isUnderline = true; - boolean isSubscript = true; - boolean isSuperscript = true; - String fontName_1st = null; - int fontSize_1st = 0; - Color fontColor_1st = null; - - for (int i = start; i < end; i++) { - Element ele = doc.getCharacterElement(i); - AttributeSet attrs = ele.getAttributes(); - - //粗体 - isBold = isBold && StyleConstants.isBold(attrs); - //斜体 - isItalic = isItalic && StyleConstants.isItalic(attrs); - //下划线 - isUnderline = isUnderline && StyleConstants.isUnderline(attrs); - //下标 - isSubscript = isSubscript && StyleConstants.isSubscript(attrs); - //上标 - isSuperscript = isSuperscript && StyleConstants.isSuperscript(attrs); - - if(i == start){ - fontName_1st = (String) attrs.getAttribute(StyleConstants.FontFamily); - fontSize_1st = (Integer) attrs.getAttribute(StyleConstants.FontSize); - fontColor_1st = (Color) attrs.getAttribute(StyleConstants.Foreground); - fontColor_1st = fontColor_1st == null ? Color.BLACK : fontColor_1st; - } - } - - setButtonSelected(isBold, isItalic, isUnderline, isSubscript, isSuperscript, - fontName_1st, fontSize_1st, fontColor_1st); - } - - //动态显示工具栏上按钮的状态 - private void setButtonSelected(boolean isBold, boolean isItalic, boolean isUnderline, - boolean isSubscript, boolean isSuperscript, String fontName_1st, - int fontSize_1st, Color fontColor_1st){ - bold.setSelected(isBold); - italic.setSelected(isItalic); - underline.setSelected(isUnderline); - subPane.setSelected(isSuperscript ? false : isSubscript); - superPane.setSelected(isSuperscript); - //为什么字体名称, 大小, 颜色, 不需要去判断是否全相同呢 - //因为如果全相同, 则设置为第一个字符的样式, 如果不全相同, 那么默认也设置成第一个字符的样式. - fontNameComboBox.setSelectedItem(fontName_1st); - fontSizeComboBox.removeItemListener(fontSizeItemListener); - fontSizeComboBox.setSelectedItem(scaleDown(fontSize_1st)); - fontSizeComboBox.addItemListener(fontSizeItemListener); - selectColorPane(fontColor_1st); - } - - private void selectColorPane(Color color){ - colorSelectPane.removeColorChangeListener(colorChangeAction); - colorSelectPane.setColor(color); - colorSelectPane.addColorChangeListener(colorChangeAction); - } - - @Override - public void caretUpdate(CaretEvent e) { - StyledDocument doc = (StyledDocument) textPane.getDocument(); - - // 取得选择文本的起始位置和结束位置 - int start = textPane.getSelectionStart(); - int end = textPane.getSelectionEnd(); - - //如果没有选定字符 - if(end == start){ - return; - } - - setSelectedCharStyle(start, end, doc); - } - }; - - //设置当前光标位样式 - private MouseListener setMouseCurrentStyle = new MouseAdapter() { - - @Override - public void mouseClicked(MouseEvent e) { - StyledDocument doc = (StyledDocument) textPane.getDocument(); - - // 取得选择文本的起始位置和结束位置 - int start = textPane.getSelectionStart(); - int end = textPane.getSelectionEnd(); - - if(start != end){ - return; - } - - setToLastCharStyle(end, doc); - } - - //如果默认不选字符, 那么设置为最后一个字符的样式 - private void setToLastCharStyle(int end, StyledDocument doc){ - if(textPane.isUpdating()){ - return; - } - - //取前一个字符的样式 - Element ele = doc.getCharacterElement(end - 1); - AttributeSet attrs = ele.getAttributes(); - populateToolBar(attrs); - } - }; - - /** - * 从样式中更新工具栏上的按钮状态 - * - * @param attrs 样式 - * - * - * @date 2015-1-5-下午5:12:33 - * - */ - public void populateToolBar(AttributeSet attrs){ - int size = scaleDown(StyleConstants.getFontSize(attrs)); - fontNameComboBox.setSelectedItem(StyleConstants.getFontFamily(attrs)); - fontSizeComboBox.setSelectedItem(size); - - bold.setSelected(StyleConstants.isBold(attrs)); - italic.setSelected(StyleConstants.isItalic(attrs)); - underline.setSelected(StyleConstants.isUnderline(attrs)); - subPane.setSelected(StyleConstants.isSubscript(attrs)); - superPane.setSelected(StyleConstants.isSuperscript(attrs)); - Color foreGround = StyleConstants.getForeground(attrs); - foreGround = foreGround == null ? Color.BLACK : foreGround; - colorSelectPane.setColor(foreGround); - colorSelectPane.repaint(); - } - - //pt转为px =*4/3 - private int scaleUp(int fontSize) { - return roundUp(FontTransformUtil.pt2px(fontSize)); - } - - //px转pt = *3/4 - private int scaleDown(int fontSize) { - return roundUp(FontTransformUtil.px2pt(fontSize)); - } - - - private DocumentListener inputListener = new DocumentListener() { - - @Override - public void removeUpdate(DocumentEvent e) { - } - - @Override - public void insertUpdate(DocumentEvent e) { - //标志正在更新内容 - textPane.startUpdating(); - final MutableAttributeSet attr = updateStyleFromToolBar(); - final int start = textPane.getSelectionStart(); - int end = textPane.getSelectionEnd(); - - if (start != end) { - textPane.finishUpdating(); - return; - } - - //放到SwingWorker里, 是因为在documentListener里不能动态改变doc内容 - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - changeContentStyle(start, attr); - } - }); - } - - //根据Style来显示populate按钮 - private void changeContentStyle(int start, MutableAttributeSet attr){ - changeContentStyle(start, attr, 1); - } - - private void changeContentStyle(int start, MutableAttributeSet attr, int contentLength){ - // 将所选文本设置为新的样式,replace为false表示不覆盖原有的样式 - StyledDocument doc = (StyledDocument) textPane.getDocument(); - doc.setCharacterAttributes(start, contentLength, attr, false); - textPane.finishUpdating(); - } - - //将界面上的设置赋值给输入的字符 - private MutableAttributeSet updateStyleFromToolBar(){ - final boolean isBold = bold.isSelected(); - final boolean isItalic = italic.isSelected(); - final boolean isSub = subPane.isSelected(); - final boolean isSuper = superPane.isSelected(); - final boolean isUnderLine = underline.isSelected(); - final String fontName = (String) fontNameComboBox.getSelectedItem(); - final int fontSize = scaleUp((Integer) fontSizeComboBox.getSelectedItem()); - final Color foreGround = colorSelectPane.getColor() == null ? Color.BLACK : colorSelectPane.getColor(); - - MutableAttributeSet attr = new SimpleAttributeSet(); - StyleConstants.setBold(attr, isBold); - StyleConstants.setItalic(attr, isItalic); - StyleConstants.setSubscript(attr, isSub); - StyleConstants.setSuperscript(attr, isSuper); - StyleConstants.setUnderline(attr, isUnderLine); - StyleConstants.setForeground(attr, foreGround); - StyleConstants.setFontFamily(attr, fontName); - StyleConstants.setFontSize(attr, fontSize); - - return attr; - } - - private static final int NOT_INITED = -1; - private static final int UPDATING = -2; - //记录上一次输入成功后光标点定位, 因为有可能文本是在中间插入的 - private int inputStart = NOT_INITED; - private static final int JDK_6 = 6; - private static final int JDK_7 = 7; - - @Override - public void changedUpdate(DocumentEvent e) { - //这边需要注意, jdk1.6和1.7对于输入法的处理逻辑不一样, jdk6时直接在输入法中输入一大段中文 - //他会一个个insert进去直接触发inserupdate事件, 而jdk7会直接把所有的塞进来. - //inserupdate那边绑定的是一个个插入的事件, 多个一起插入的放这 - //bug84777 8.0不走if逻辑,改成只有jdk7走if逻辑 - if(StableUtils.getMajorJavaVersion() == JDK_7){ - if(isUpdating()){ - return; - } - StyledDocument doc = (StyledDocument) textPane.getDocument(); - final String content; - initFlag(doc); - - final int start = textPane.getSelectionStart(); - final int inputLen = start - inputStart; - //检测输入内容 - try { - content = doc.getText(inputStart, inputLen); - } catch (BadLocationException e1) { - return; - } - - //中文输入法, 默认输入字符会被输入法的框截取住, jtextpane得到是一个空格, 此时不做处理 - if(StringUtils.isBlank(content) || inputLen <= 0){ - return; - } - //设置一次性输入多个文字的样式 - setContentStyle(inputLen); - } - } - - private void setContentStyle(final int inputLen){ - //缓存下Start, 下面要用来设置样式 - final int _start = inputStart; - final MutableAttributeSet attr = updateStyleFromToolBar(); - - //放到SwingWorker里, 是因为在documentListener里不能动态改变doc内容 - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - //防止触发死循环change事件 - startUpdating(); - //Start-1 是因为中文输入法会用空格占1位 - changeContentStyle(_start, attr, inputLen); - resetFlag(); - } - }); - } - - private boolean isUpdating(){ - return inputStart == UPDATING; - } - - private void startUpdating(){ - inputStart = UPDATING; - } - - //初始标记状态, 用于记录中文输入法多个字符同时输入的问题 - private void initFlag(StyledDocument doc){ - if(inputStart != NOT_INITED){ - return; - } - inputStart = textPane.getSelectionStart() - 1; - } - - //重置标记状态 - private void resetFlag(){ - inputStart = NOT_INITED; - } - }; + } + } + }).setVisible(true); + } + }; + + private int roundUp(double num) { + String numStr = Double.toString(num); + numStr = new BigDecimal(numStr).setScale(0, BigDecimal.ROUND_HALF_UP).toString(); + return Integer.valueOf(numStr); + } + + private CaretListener textCareListener = new CaretListener() { + + //根据选中部分的文字样式, 来动态显示工具栏上按钮的状态 + private void setSelectedCharStyle(int start, int end, StyledDocument doc) { + boolean isBold = true; + boolean isItalic = true; + boolean isUnderline = true; + boolean isSubscript = true; + boolean isSuperscript = true; + String fontName_1st = null; + int fontSize_1st = 0; + Color fontColor_1st = null; + + for (int i = start; i < end; i++) { + Element ele = doc.getCharacterElement(i); + AttributeSet attrs = ele.getAttributes(); + + //粗体 + isBold = isBold && StyleConstants.isBold(attrs); + //斜体 + isItalic = isItalic && StyleConstants.isItalic(attrs); + //下划线 + isUnderline = isUnderline && StyleConstants.isUnderline(attrs); + //下标 + isSubscript = isSubscript && StyleConstants.isSubscript(attrs); + //上标 + isSuperscript = isSuperscript && StyleConstants.isSuperscript(attrs); + + if (i == start) { + fontName_1st = (String) attrs.getAttribute(StyleConstants.FontFamily); + fontSize_1st = (Integer) attrs.getAttribute(StyleConstants.FontSize); + fontColor_1st = (Color) attrs.getAttribute(StyleConstants.Foreground); + fontColor_1st = fontColor_1st == null ? Color.BLACK : fontColor_1st; + } else { + if (!(attrs.getAttribute(StyleConstants.FontFamily)).equals(fontName_1st)) { + fontName_1st = null; + } + } + } + + setButtonSelected(isBold, isItalic, isUnderline, isSubscript, isSuperscript, + fontName_1st, fontSize_1st, fontColor_1st); + } + + //动态显示工具栏上按钮的状态 + private void setButtonSelected(boolean isBold, boolean isItalic, boolean isUnderline, + boolean isSubscript, boolean isSuperscript, String fontName_1st, + int fontSize_1st, Color fontColor_1st) { + bold.setSelected(isBold); + italic.setSelected(isItalic); + underline.setSelected(isUnderline); + subPane.setSelected(isSuperscript ? false : isSubscript); + superPane.setSelected(isSuperscript); + //为什么字体名称, 大小, 颜色, 不需要去判断是否全相同呢 + //因为如果全相同, 则设置为第一个字符的样式, 如果不全相同, 那么默认也设置成第一个字符的样式. + fontNameComboBox.setSelectedItem(fontName_1st); + fontSizeComboBox.removeItemListener(fontSizeItemListener); + fontSizeComboBox.setSelectedItem(scaleDown(fontSize_1st)); + fontSizeComboBox.addItemListener(fontSizeItemListener); + selectColorPane(fontColor_1st); + } + + private void selectColorPane(Color color) { + colorSelectPane.removeColorChangeListener(colorChangeAction); + colorSelectPane.setColor(color); + colorSelectPane.addColorChangeListener(colorChangeAction); + } + + @Override + public void caretUpdate(CaretEvent e) { + StyledDocument doc = (StyledDocument) textPane.getDocument(); + + // 取得选择文本的起始位置和结束位置 + int start = textPane.getSelectionStart(); + int end = textPane.getSelectionEnd(); + + //如果没有选定字符 + if (end == start) { + return; + } + + setSelectedCharStyle(start, end, doc); + } + }; + + //设置当前光标位样式 + private MouseListener setMouseCurrentStyle = new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent e) { + StyledDocument doc = (StyledDocument) textPane.getDocument(); + + // 取得选择文本的起始位置和结束位置 + int start = textPane.getSelectionStart(); + int end = textPane.getSelectionEnd(); + + if (start != end) { + return; + } + + setToLastCharStyle(end, doc); + } + + //如果默认不选字符, 那么设置为最后一个字符的样式 + private void setToLastCharStyle(int end, StyledDocument doc) { + if (textPane.isUpdating()) { + return; + } + + //取前一个字符的样式 + Element ele = doc.getCharacterElement(end - 1); + AttributeSet attrs = ele.getAttributes(); + populateToolBar(attrs); + } + }; + + /** + * 从样式中更新工具栏上的按钮状态 + * + * @param attrs 样式 + * + * + * @date 2015-1-5-下午5:12:33 + * + */ + public void populateToolBar(AttributeSet attrs) { + int size = scaleDown(StyleConstants.getFontSize(attrs)); + fontNameComboBox.setSelectedItem(StyleConstants.getFontFamily(attrs)); + fontSizeComboBox.setSelectedItem(size); + + bold.setSelected(StyleConstants.isBold(attrs)); + italic.setSelected(StyleConstants.isItalic(attrs)); + underline.setSelected(StyleConstants.isUnderline(attrs)); + subPane.setSelected(StyleConstants.isSubscript(attrs)); + superPane.setSelected(StyleConstants.isSuperscript(attrs)); + Color foreGround = StyleConstants.getForeground(attrs); + foreGround = foreGround == null ? Color.BLACK : foreGround; + colorSelectPane.setColor(foreGround); + colorSelectPane.repaint(); + } + + //pt转为px =*4/3 + private int scaleUp(int fontSize) { + return roundUp(FontTransformUtil.pt2px(fontSize)); + } + + //px转pt = *3/4 + private int scaleDown(int fontSize) { + return roundUp(FontTransformUtil.px2pt(fontSize)); + } + + + private DocumentListener inputListener = new DocumentListener() { + + @Override + public void removeUpdate(DocumentEvent e) { + } + + @Override + public void insertUpdate(DocumentEvent e) { + //标志正在更新内容 + textPane.startUpdating(); + final MutableAttributeSet attr = updateStyleFromToolBar(); + final int start = textPane.getSelectionStart(); + int end = textPane.getSelectionEnd(); + + if (start != end) { + textPane.finishUpdating(); + return; + } + + //放到SwingWorker里, 是因为在documentListener里不能动态改变doc内容 + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + changeContentStyle(start, attr); + } + }); + } + + //根据Style来显示populate按钮 + private void changeContentStyle(int start, MutableAttributeSet attr) { + changeContentStyle(start, attr, 1); + } + + private void changeContentStyle(int start, MutableAttributeSet attr, int contentLength) { + // 将所选文本设置为新的样式,replace为false表示不覆盖原有的样式 + StyledDocument doc = (StyledDocument) textPane.getDocument(); + doc.setCharacterAttributes(start, contentLength, attr, false); + textPane.finishUpdating(); + } + + //将界面上的设置赋值给输入的字符 + private MutableAttributeSet updateStyleFromToolBar() { + final boolean isBold = bold.isSelected(); + final boolean isItalic = italic.isSelected(); + final boolean isSub = subPane.isSelected(); + final boolean isSuper = superPane.isSelected(); + final boolean isUnderLine = underline.isSelected(); + final String fontName = (String) fontNameComboBox.getSelectedItem(); + final int fontSize = scaleUp((Integer) fontSizeComboBox.getSelectedItem()); + final Color foreGround = colorSelectPane.getColor() == null ? Color.BLACK : colorSelectPane.getColor(); + + MutableAttributeSet attr = new SimpleAttributeSet(); + StyleConstants.setBold(attr, isBold); + StyleConstants.setItalic(attr, isItalic); + StyleConstants.setSubscript(attr, isSub); + StyleConstants.setSuperscript(attr, isSuper); + StyleConstants.setUnderline(attr, isUnderLine); + StyleConstants.setForeground(attr, foreGround); + StyleConstants.setFontFamily(attr, fontName); + StyleConstants.setFontSize(attr, fontSize); + + return attr; + } + + private static final int NOT_INITED = -1; + private static final int UPDATING = -2; + //记录上一次输入成功后光标点定位, 因为有可能文本是在中间插入的 + private int inputStart = NOT_INITED; + private static final int JDK_6 = 6; + private static final int JDK_7 = 7; + + @Override + public void changedUpdate(DocumentEvent e) { + //这边需要注意, jdk1.6和1.7对于输入法的处理逻辑不一样, jdk6时直接在输入法中输入一大段中文 + //他会一个个insert进去直接触发inserupdate事件, 而jdk7会直接把所有的塞进来. + //inserupdate那边绑定的是一个个插入的事件, 多个一起插入的放这 + //bug84777 8.0不走if逻辑,改成只有jdk7走if逻辑 + if (StableUtils.getMajorJavaVersion() == JDK_7) { + if (isUpdating()) { + return; + } + StyledDocument doc = (StyledDocument) textPane.getDocument(); + final String content; + initFlag(doc); + + final int start = textPane.getSelectionStart(); + final int inputLen = start - inputStart; + //检测输入内容 + try { + content = doc.getText(inputStart, inputLen); + } catch (BadLocationException e1) { + return; + } + + //中文输入法, 默认输入字符会被输入法的框截取住, jtextpane得到是一个空格, 此时不做处理 + if (StringUtils.isBlank(content) || inputLen <= 0) { + return; + } + //设置一次性输入多个文字的样式 + setContentStyle(inputLen); + } + } + + private void setContentStyle(final int inputLen) { + //缓存下Start, 下面要用来设置样式 + final int _start = inputStart; + final MutableAttributeSet attr = updateStyleFromToolBar(); + + //放到SwingWorker里, 是因为在documentListener里不能动态改变doc内容 + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + //防止触发死循环change事件 + startUpdating(); + //Start-1 是因为中文输入法会用空格占1位 + changeContentStyle(_start, attr, inputLen); + resetFlag(); + } + }); + } + + private boolean isUpdating() { + return inputStart == UPDATING; + } + + private void startUpdating() { + inputStart = UPDATING; + } + + //初始标记状态, 用于记录中文输入法多个字符同时输入的问题 + private void initFlag(StyledDocument doc) { + if (inputStart != NOT_INITED) { + return; + } + inputStart = textPane.getSelectionStart() - 1; + } + + //重置标记状态 + private void resetFlag() { + inputStart = NOT_INITED; + } + }; } From 31cf1032960e7673d2edfe84608b55909f6770aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Fri, 13 Aug 2021 23:02:48 +0800 Subject: [PATCH 13/32] =?UTF-8?q?REPORT-56906&REPORT-56926=20=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E4=B8=80=E4=B8=AA=E8=BE=93=E5=85=A5=E6=A1=86?= =?UTF-8?q?=EF=BC=8C=E5=8F=AA=E6=94=AF=E6=8C=81=E8=BE=93=E5=85=A5=E6=95=B4?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/ispinner/UnsignedIntUISpinner.java | 4 +- .../gui/itextfield/UIIntNumberField.java | 65 ++++++++++++------- .../itextfield/UIPositiveIntNumberField.java | 61 +++++++++++++++++ .../ui/MobileCollapsedStyleExpandPane.java | 4 +- .../fr/design/report/freeze/RowSpinner.java | 4 +- .../GlobalNativePrintSettingPane.java | 4 +- 6 files changed, 109 insertions(+), 33 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveIntNumberField.java diff --git a/designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java b/designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java index 42a40cd79e..4d4e2794b1 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java +++ b/designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java @@ -1,6 +1,6 @@ package com.fr.design.gui.ispinner; -import com.fr.design.gui.itextfield.UIIntNumberField; +import com.fr.design.gui.itextfield.UIPositiveIntNumberField; import com.fr.design.gui.itextfield.UINumberField; @@ -29,7 +29,7 @@ public class UnsignedIntUISpinner extends UISpinner { @Override protected UINumberField initNumberField() { - return new UIIntNumberField() { + return new UIPositiveIntNumberField() { public boolean shouldResponseChangeListener() { return false; } diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/UIIntNumberField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/UIIntNumberField.java index 37b1e74e4a..e81694d267 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/UIIntNumberField.java +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/UIIntNumberField.java @@ -1,38 +1,32 @@ package com.fr.design.gui.itextfield; - import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.PlainDocument; import java.awt.Toolkit; -/** - * Created with IntelliJ IDEA. - * User: Lenovo - * Date: 13-3-29 - * Time: 下午12:02 - * To change this template use File | Settings | File Templates. - */ public class UIIntNumberField extends UINumberField { + private static final long serialVersionUID = 4946379346015964509L; + public void setFieldDocument() { setDocument(createNumberDocument()); } public class NumberDocument extends PlainDocument { + private static final long serialVersionUID = 1024213269275179172L; + public NumberDocument() { } - public void insertString(int offset, String s, AttributeSet a) throws BadLocationException { - String str = getText(0, getLength()); - - if (!s.matches("^[0-9]+$")) { - Toolkit.getDefaultToolkit().beep(); - return; - } - + public boolean checkString(int offset, String s, String str) { String strNew = str.substring(0, offset) + s + str.substring(offset, getLength()); + return isMinusSignOnly(strNew) || (isIntNumber(strNew) && isInputIllegalNumber(strNew) && !isOverMaxOrMinValue(strNew)); - if (isOverMaxOrMinValue(strNew) && !isContinueInsertWhenOverMaxOrMinValue()) { + } + + public void insertString(int offset, String s, AttributeSet a) throws BadLocationException { + String str = getText(0, getLength()); + if (!checkString(offset, s, str)) { Toolkit.getDefaultToolkit().beep(); return; } @@ -41,21 +35,42 @@ public class UIIntNumberField extends UINumberField { super.insertString(offset, s, a); } + private boolean isMinusSignOnly(String s) { + return s.contains("-") && s.length() == 1; + } + /** - * 是否继续插入输入的字符 - 当超出范围时 - * - * @return true : 继续插入输入的字符 + * 输入字符是否是不合法数字 + * @param s 输入的字符串 + * @return 是否不合法 */ - public boolean isContinueInsertWhenOverMaxOrMinValue() { - return false; + private boolean isInputIllegalNumber(String s) { + try { + Integer.parseInt(s); + } catch (Exception e) { + return false; + } + return true; + } + + private boolean isIntNumber(String s) { + boolean result = true; + for (int i = 0; i < s.length(); i++) { + String ch = s.charAt(i) + ""; + if (!ch.matches("^[0-9\\-]+$")) { + result = false; + } + } + return result; } - private boolean isOverMaxOrMinValue( String strNew) { - return (Double.parseDouble(strNew)getMaxValue()); + private boolean isOverMaxOrMinValue(String s) { + int value = Integer.parseInt(s); + return (value < getMinValue() || value > getMaxValue()); } } public NumberDocument createNumberDocument() { return new NumberDocument(); } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveIntNumberField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveIntNumberField.java new file mode 100644 index 0000000000..b78cacf4dd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveIntNumberField.java @@ -0,0 +1,61 @@ +package com.fr.design.gui.itextfield; + + +import javax.swing.text.AttributeSet; +import javax.swing.text.BadLocationException; +import javax.swing.text.PlainDocument; +import java.awt.Toolkit; + +/** + * Created with IntelliJ IDEA. + * User: Lenovo + * Date: 13-3-29 + * Time: 下午12:02 + * To change this template use File | Settings | File Templates. + */ +public class UIPositiveIntNumberField extends UINumberField { + public void setFieldDocument() { + setDocument(createNumberDocument()); + } + + public class NumberDocument extends PlainDocument { + public NumberDocument() { + } + + public void insertString(int offset, String s, AttributeSet a) throws BadLocationException { + String str = getText(0, getLength()); + + if (!s.matches("^[0-9\\-]+$")) { + Toolkit.getDefaultToolkit().beep(); + return; + } + + String strNew = str.substring(0, offset) + s + str.substring(offset, getLength()); + + if (isOverMaxOrMinValue(strNew) && !isContinueInsertWhenOverMaxOrMinValue()) { + Toolkit.getDefaultToolkit().beep(); + return; + } + + setisContentChanged(true); + super.insertString(offset, s, a); + } + + /** + * 是否继续插入输入的字符 - 当超出范围时 + * + * @return true : 继续插入输入的字符 + */ + public boolean isContinueInsertWhenOverMaxOrMinValue() { + return false; + } + + private boolean isOverMaxOrMinValue( String strNew) { + return (Double.parseDouble(strNew)getMaxValue()); + } + } + + public NumberDocument createNumberDocument() { + return new NumberDocument(); + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java index 8fd34d4524..531a946b7e 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java @@ -2,7 +2,7 @@ package com.fr.design.mainframe.mobile.ui; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; -import com.fr.design.gui.itextfield.UIIntNumberField; +import com.fr.design.gui.itextfield.UIPositiveIntNumberField; import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; @@ -39,7 +39,7 @@ public class MobileCollapsedStyleExpandPane extends MobileCollapsedStylePane { this.rowSpinner = new UISpinner(1, Integer.MAX_VALUE, 1, 1) { @Override protected UINumberField initNumberField(){ - return new UIIntNumberField(); + return new UIPositiveIntNumberField(); } }; this.rowSpinner.setPreferredSize(new Dimension(62, COMPONENT_HEIGHT)); diff --git a/designer-realize/src/main/java/com/fr/design/report/freeze/RowSpinner.java b/designer-realize/src/main/java/com/fr/design/report/freeze/RowSpinner.java index da652a0e44..961b05cfc1 100644 --- a/designer-realize/src/main/java/com/fr/design/report/freeze/RowSpinner.java +++ b/designer-realize/src/main/java/com/fr/design/report/freeze/RowSpinner.java @@ -1,7 +1,7 @@ package com.fr.design.report.freeze; import com.fr.design.gui.ispinner.UISpinner; -import com.fr.design.gui.itextfield.UIIntNumberField; +import com.fr.design.gui.itextfield.UIPositiveIntNumberField; import com.fr.design.gui.itextfield.UINumberField; /** @@ -25,7 +25,7 @@ public class RowSpinner extends UISpinner { @Override protected UINumberField initNumberField(){ - return new UIIntNumberField(); + return new UIPositiveIntNumberField(); } diff --git a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/GlobalNativePrintSettingPane.java b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/GlobalNativePrintSettingPane.java index 7b3643899a..e9877b2514 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/GlobalNativePrintSettingPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/GlobalNativePrintSettingPane.java @@ -3,7 +3,7 @@ package com.fr.design.webattr.printsettings; import com.fr.base.print.NativePrintAttr; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.itextfield.UIIntNumberField; +import com.fr.design.gui.itextfield.UIPositiveIntNumberField; import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; @@ -89,7 +89,7 @@ public class GlobalNativePrintSettingPane extends AbstractNativePrintSettingPane } private JPanel getPrintPortFieldPane() { - printPortField = new UIIntNumberField(); + printPortField = new UIPositiveIntNumberField(); printPortField.setMaxValue(NativePrintAttr.MAX_PRINT_PORT_VALUE); printPortField.setColumns(PRINT_PORT_FIELD_COLUMNS); JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); From 7a85d9cd65c87b59935c7b4a82b69f40567cd130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Fri, 13 Aug 2021 23:04:01 +0800 Subject: [PATCH 14/32] =?UTF-8?q?REPORT-56906&REPORT-56926=20=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E4=B8=80=E4=B8=AA=E7=AC=94=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/itextfield/UIPositiveIntNumberField.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveIntNumberField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveIntNumberField.java index b78cacf4dd..ec99777d7b 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveIntNumberField.java +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveIntNumberField.java @@ -25,7 +25,7 @@ public class UIPositiveIntNumberField extends UINumberField { public void insertString(int offset, String s, AttributeSet a) throws BadLocationException { String str = getText(0, getLength()); - if (!s.matches("^[0-9\\-]+$")) { + if (!s.matches("^[0-9]+$")) { Toolkit.getDefaultToolkit().beep(); return; } From 05a3713694220edd440e1c3123494120f3085528 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Sat, 14 Aug 2021 12:16:34 +0800 Subject: [PATCH 15/32] =?UTF-8?q?REPORT-56595=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E9=A2=84=E8=A7=88=E6=97=B6=E5=8F=AF=E5=A4=8D=E5=88=B6?= =?UTF-8?q?-=E8=A1=A8=E5=A4=B4=E5=A4=8D=E5=88=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/preview/CopyableJTable.java | 116 ++++++++++++++++-- 1 file changed, 108 insertions(+), 8 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java index 38b5a08e47..7baf51ddd6 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java +++ b/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.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.TableColumnModel; import java.awt.*; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.StringSelection; @@ -40,27 +44,104 @@ public class CopyableJTable extends SortableJTable { int commandKeyCode = 157; //选中单元格的背景色 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) { super(tableModel); initListener(); + this.getTableHeader().setDefaultRenderer(tableHeaderCellRenderer); } private void initListener() { 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() { @Override public void mouseDragged(MouseEvent evt) { + mouseDrag = true; int row = self.rowAtPoint(evt.getPoint()); int col = self.columnAtPoint(evt.getPoint()); if (self.updateEndPoint(row, col)) { - self.repaint(); + self.refreshTable(); } } + + public void mouseMoved(MouseEvent e) { + mouseDrag = false; + } }); this.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { + headerSelect = false; int row = self.rowAtPoint(e.getPoint()); int col = self.columnAtPoint(e.getPoint()); if (!self.isControlDown) { @@ -74,7 +155,7 @@ public class CopyableJTable extends SortableJTable { self.addPoint(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) { + if (headerSelect && row != -1) + return false; if (endRow != row || endCol != col) { endRow = row; endCol = col; @@ -157,13 +240,12 @@ public class CopyableJTable extends SortableJTable { private void copy() { FineLoggerFactory.getLogger().info("copy cell value"); java.util.List> table = new ArrayList<>(); - if ((startRow != endRow || startCol != endCol) && - Math.min(startRow, endRow) > -1 && Math.min(startCol, endCol) > -1) { + if ((startRow != endRow || startCol != endCol) && Math.min(startCol, endCol) > -1) { for (int i = Math.min(startRow, endRow); i <= Math.max(startRow, endRow); i++) { table.add(new ArrayList<>()); for (int j = Math.min(startCol, endCol); j <= Math.max(startCol, endCol); j++) { - Object text = this.getValueAt(i, j); - table.get(i - Math.min(startRow, endRow)).add(text); + Object text = this.getTableValue(i, j); + table.get(table.size() - 1).add(text); } } } else if (pointList.size() > 0) { @@ -176,8 +258,8 @@ public class CopyableJTable extends SortableJTable { table.add(new ArrayList<>()); currentRow++; } - Object text = this.getValueAt(point.x, point.y); - table.get(currentRow - startRow).add(text); + Object text = this.getTableValue(point.x, point.y); + table.get(table.size() - 1).add(text); } } @@ -186,6 +268,24 @@ public class CopyableJTable extends SortableJTable { 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) { if (row >= Math.min(startRow, endRow) && row <= Math.max(startRow, endRow)) { if (col >= Math.min(startCol, endCol) && col <= Math.max(startCol, endCol)) { From bee3075e5f291f3436ad1d4e74ade0648b0dfa42 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Sat, 14 Aug 2021 12:35:33 +0800 Subject: [PATCH 16/32] =?UTF-8?q?REPORT-55481=20=E6=A8=A1=E6=9D=BFWeb?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=9A=84=E9=A1=B6=E9=83=A8=E5=92=8C=E5=BA=95?= =?UTF-8?q?=E9=83=A8=E5=B7=A5=E5=85=B7=E6=A0=8F=E5=9C=A8=E6=9D=83=E9=99=90?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=97=B6=EF=BC=8C=E9=A1=B6=E9=83=A8=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E6=A0=8F=E8=A2=AB=E5=BA=95=E9=83=A8=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=A0=8F=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/AuthorityToolBarPane.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java index 1fc891c8b3..5eb1de3664 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java @@ -185,7 +185,7 @@ public class AuthorityToolBarPane extends BasicBeanPane 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) { button.setEnabled(!isnotEnable); } @@ -296,9 +296,15 @@ public class AuthorityToolBarPane extends BasicBeanPane Date: Mon, 16 Aug 2021 11:14:37 +0800 Subject: [PATCH 17/32] =?UTF-8?q?REPORT-56134js=E6=8F=90=E4=BA=A4=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E6=8A=A5=E9=94=99=E4=B8=AD=E6=B7=BB=E5=8A=A0=E5=AE=9A?= =?UTF-8?q?=E4=BD=8D=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/controlpane/JControlUpdatePane.java | 13 +- .../gui/controlpane/JListControlPane.java | 7 + .../controlpane/ListControlPaneProvider.java | 3 + .../gui/controlpane/UIListControlPane.java | 7 + .../controlpane/UIListGroupControlPane.java | 7 +- .../javascript/Commit2DBJavaScriptPane.java | 104 +- .../javascript/JavaScriptActionPane.java | 15 +- .../design/javascript/ListenerEditPane.java | 10 +- .../com/fr/design/webattr/EditToolBar.java | 1175 +++++++++-------- .../fr/design/widget/CellWidgetCardPane.java | 3 +- .../com/fr/design/widget/WidgetEventPane.java | 50 +- 11 files changed, 735 insertions(+), 659 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java index ebe41b2bc7..3ddb144a5f 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java +++ b/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.gui.ilist.ListModelElement; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.form.event.Listener; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; @@ -76,9 +77,12 @@ class JControlUpdatePane extends JPanel { cardPane.add(updatePanes[i], String.valueOf(i)); } card.show(cardPane, String.valueOf(i)); - try{ + try { + if (ob2Populate instanceof Listener) { + listControlPane.wrapperListener((Listener) ob2Populate); + } updatePanes[i].populateBean(ob2Populate); - }catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } break; @@ -103,12 +107,15 @@ class JControlUpdatePane extends JPanel { if (pane != null && pane.isVisible()) { Object bean = pane.updateBean(); try { + if (bean instanceof Listener) { + listControlPane.wrapperListener((Listener) bean); + } if (bean instanceof RemoteDesignerWorkspaceInfo) { DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(elEditing.wrapper.getName()); String remindTime = info.getRemindTime(); ((RemoteDesignerWorkspaceInfo) bean).setRemindTime(remindTime); } - }catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().info("remindTime is not exist"); } if (i < creators.length) { diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java index b82a584679..f119c55cd3 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java +++ b/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.ModNameActionListener; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.form.event.Listener; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; import com.fr.invoke.Reflect; @@ -417,4 +418,10 @@ public abstract class JListControlPane extends JControlPane implements ListContr public JControlUpdatePane getControlUpdatePane() { return (JControlUpdatePane) controlUpdatePane; } + + @Override + public void wrapperListener(Listener listener){ + + } + } diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneProvider.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneProvider.java index 1565f348d0..6d000c1153 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneProvider.java +++ b/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.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.ListModelElement; +import com.fr.form.event.Listener; import com.fr.stable.Nameable; import javax.swing.DefaultListModel; @@ -32,4 +33,6 @@ public interface ListControlPaneProvider extends UnrepeatedNameHelper { void showSelectPane(); void showEditPane(); ShortCut4JControlPane[] getShorts(); + + void wrapperListener(Listener listener); } diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java index b7b8674be7..7ba536492a 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListControlPane.java +++ b/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.ListModelElement; import com.fr.design.gui.ilist.UINameEdList; +import com.fr.form.event.Listener; import com.fr.stable.ArrayUtils; import com.fr.stable.Nameable; @@ -314,4 +315,10 @@ public abstract class UIListControlPane extends UIControlPane implements ListCon public JNameEdList getNameableList() { return nameableList; } + + @Override + public void wrapperListener(Listener listener){ + + } + } diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java index 82bf99bf33..6ec5f496a6 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIListGroupControlPane.java +++ b/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 public Nameable[] update() { - java.util.List res = new java.util.ArrayList(); + List res = new ArrayList(); getControlUpdatePane().update(); Iterator> iterator = nameEdListMap.entrySet().iterator(); while (iterator.hasNext()) { @@ -516,6 +516,11 @@ public abstract class UIListGroupControlPane extends UIControlPane implements Li return StringUtils.EMPTY; } + @Override + public void wrapperListener(Listener listener){ + + } + private class ListWrapperPane extends JPanel { private UINameEdList nameEdList; diff --git a/designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java b/designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java index dbccb7c50c..e5100b54b3 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java @@ -1,16 +1,17 @@ package com.fr.design.javascript; -import com.fr.design.write.submit.DBManipulationPane; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.gui.frpane.CommitTabbedPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.layout.FRGUIPaneFactory; - +import com.fr.design.write.submit.DBManipulationPane; import com.fr.js.Commit2DBJavaScript; import com.fr.write.DBManipulation; -import javax.swing.*; -import java.awt.*; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Dimension; import java.util.ArrayList; import java.util.List; @@ -25,63 +26,64 @@ public class Commit2DBJavaScriptPane extends FurtherBasicBeanPane 1){ + /** + * 界面重置 + */ + public void reset() { + this.javaScriptActionPane.setCall(null); + //重置后只保留,只留第一个tab + while (dbmPaneList.size() > 1) { dbmPaneList.remove(1); } - ((DBManipulationPane)dbmPaneList.get(0)).populateBean(null); - } + ((DBManipulationPane) dbmPaneList.get(0)).populateBean(null); + } - @Override + @Override /** * 将JavaBean内的数据输出至界面上 */ @@ -131,11 +134,15 @@ public class Commit2DBJavaScriptPane extends FurtherBasicBeanPane { private List contentDBManiPane; + private JavaScriptResourceInfo resourceInfo; + private JavaScript call = null; public JavaScriptActionPane() { @@ -71,6 +74,14 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane { } + public JavaScriptResourceInfo getResourceInfo() { + return resourceInfo; + } + + public void setResourceInfo(JavaScriptResourceInfo resourceInfo) { + this.resourceInfo = resourceInfo; + } + /** * 生成回调函数的按钮 * @@ -178,8 +189,8 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane { * @return 返回生成的面板 */ - public static JavaScriptActionPane createDefault() { - return new JavaScriptActionPane() { + public static JavaScriptActionPane createDefault() { + return new JavaScriptActionPane() { @Override public DBManipulationPane createDBManipulationPane() { return new DBManipulationPane(); diff --git a/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java b/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java index b89971f879..68936daa6c 100644 --- a/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java +++ b/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.form.event.Listener; import com.fr.js.JavaScript; +import com.fr.report.web.util.ReportEngineEventMapping; +import com.fr.write.JavaScriptResourceInfo; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -42,6 +44,8 @@ public class ListenerEditPane extends BasicBeanPane { private Listener listener; + JavaScriptActionPane javaScriptActionPane; + public ListenerEditPane() { this.initComponents(new String[0]); } @@ -81,7 +85,8 @@ public class ListenerEditPane extends BasicBeanPane { // 提交入库 List dbManiList = new ArrayList(); dbManiList.add(autoCreateDBManipulationPane()); - Commit2DBJavaScriptPane commit2DBJavaScriptPane = new Commit2DBJavaScriptPane(JavaScriptActionPane.createDefaultJavaScriptActionPane(), + javaScriptActionPane = JavaScriptActionPane.createDefaultJavaScriptActionPane(); + Commit2DBJavaScriptPane commit2DBJavaScriptPane = new Commit2DBJavaScriptPane(javaScriptActionPane, dbManiList); hyperlinkPane.add(DBCOMMIT, commit2DBJavaScriptPane); // 自定义事件 @@ -164,9 +169,12 @@ public class ListenerEditPane extends BasicBeanPane { @Override 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()); FurtherBasicBeanPane pane = this.cards.get(this.styleBox.getSelectedIndex()); this.listener.setAction(pane.updateBean()); + return this.listener; } } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/webattr/EditToolBar.java b/designer-realize/src/main/java/com/fr/design/webattr/EditToolBar.java index f1cd05a907..c75c6607c7 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/EditToolBar.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/EditToolBar.java @@ -38,6 +38,7 @@ import com.fr.report.web.button.write.AppendColumnRow; import com.fr.report.web.button.write.Submit; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; +import com.fr.write.JavaScriptResourceInfo; import javax.swing.BorderFactory; import javax.swing.Box; @@ -67,473 +68,476 @@ import java.util.Set; public class EditToolBar extends BasicPane { - private static final String EMAIL = "email"; - private static final String CUSTOM = "custom"; - private static final String EXPORT = "export"; - private static final String NONE = "none"; - private static final String EDIT_EXCEL = "editexcel"; - private static final String APPEND_COUNT = "appendcount"; - private static final String SUBMIT = "submit"; - - private JWorkBook jwb; - private JList list; - private DefaultListModel listModel; - private JPanel right; - private CardLayout card; - private ButtonPane bp; - private ToolBarButton lastButton; - private Background background = null; - private UICheckBox defaultCheckBox; - - private ListSelectionListener listSelectionListener = new ListSelectionListener() { - public void valueChanged(ListSelectionEvent evt) { - if (lastButton != null) { - lastButton.setWidget(bp.update()); - } - if (list.getSelectedValue() instanceof ToolBarButton) { - lastButton = (ToolBarButton) list.getSelectedValue(); - if (lastButton.getWidget() instanceof Button) { - card.show(right, "button"); - bp.populate(lastButton.getWidget()); - } else { - bp.populate(lastButton.getWidget()); - card.show(right, "none"); - } - } - } - }; - - - private ActionListener actioner = new ActionListener() { - /** - * - */ - public void actionPerformed(ActionEvent arg0) { - final BackgroundPane backgroundPane = new BackgroundPane(); - BasicDialog dialog = backgroundPane.showWindow(DesignerContext.getDesignerFrame()); - backgroundPane.populate(EditToolBar.this.background); - dialog.addDialogActionListener(new DialogActionAdapter() { - public void doOk() { - EditToolBar.this.background = backgroundPane.update(); - if (EditToolBar.this.background != null) { - EditToolBar.this.defaultCheckBox.setSelected(false); - } - } - }); - dialog.setVisible(true); - } - }; - - public EditToolBar() { - initComponent(); - } - - /** - * 初始化 - */ - public void initComponent() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - JPanel left = FRGUIPaneFactory.createBorderLayout_S_Pane(); - listModel = new DefaultListModel(); - list = new JList(listModel); - list.setCellRenderer(render); - left.add(new JScrollPane(list), BorderLayout.CENTER); - if (listModel.getSize() > 0) { - list.setSelectedIndex(0); - } - - ToolBarDef toolbarDef = new ToolBarDef(); - toolbarDef.addShortCut(new MoveUpItemAction()); - toolbarDef.addShortCut(new MoveDownItemAction()); - toolbarDef.addShortCut(new RemoveAction()); - UIToolbar toolBar = ToolBarDef.createJToolBar(); - toolbarDef.updateToolBar(toolBar); - left.add(toolBar, BorderLayout.NORTH); - - right = FRGUIPaneFactory.createCardLayout_S_Pane(); - card = new CardLayout(); - right.setLayout(card); - bp = new ButtonPane(); - right.add("none", FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane()); - right.add("button", bp); - - JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, left, right); - // splitPane.setDividerLocation(left.getMinimumSize().width); - splitPane.setDividerLocation(120); - this.add(splitPane); - list.addListSelectionListener(listSelectionListener); - JPanel backgroundPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - UIButton bgButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Background")); - defaultCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default_Background")); - bgButton.addActionListener(actioner); - backgroundPane.add(defaultCheckBox); - backgroundPane.add(bgButton); - backgroundPane.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Background"))); - this.add(backgroundPane, BorderLayout.SOUTH); - } - - ListCellRenderer render = new DefaultListCellRenderer() { - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - if (value instanceof ToolBarButton) { - ToolBarButton button = (ToolBarButton) value; - this.setText(button.getNameOption().optionName()); - this.setIcon(button.getNameOption().optionIcon()); - } - return this; - } - }; - - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit"); - } - - public void populate(FToolBar ftoolbar) { - this.populate(ftoolbar, null); - } - - public void populate(FToolBar ftoolbar, ToolBarButton button) { - if (ftoolbar == null) { - return; - } - for (int i = 0; i < ftoolbar.getButtonlist().size(); i++) { - listModel.addElement(ftoolbar.getButtonlist().get(i)); - } - this.list.validate(); - this.list.repaint(); - if (ftoolbar.getButtonlist().size() > 0) { - this.list.setSelectedIndex(0); - } - if (button != null) { - this.list.setSelectedValue(button, true); - } - this.background = ftoolbar.getBackground(); - - this.defaultCheckBox.setSelected(ftoolbar.isDefault() ? true : false); - } - - public FToolBar update() { - if (this.list.getSelectedIndex() > -1) { - for (int i = 0; i < listModel.getSize(); i++) { - this.list.setSelectedIndex(i); - ToolBarButton toolBarButton = (ToolBarButton) this.list.getSelectedValue(); - Widget widget = this.bp.update(); - toolBarButton.setWidget(widget); - if (widget instanceof Button) { - String iconname = ((Button) widget).getIconName(); - if (StringUtils.isNotBlank(iconname)) { - Image iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(iconname); - if (iconImage != null) { - toolBarButton.setIcon(new ImageIcon(iconImage)); - } else { - FineLoggerFactory.getLogger().warn(iconname + " can not find in finedb!"); - } - } - } - } - } - List list = new ArrayList(); - for (int i = 0; i < listModel.size(); i++) { - list.add((ToolBarButton) listModel.get(i)); - } - FToolBar ftoolBar = new FToolBar(); - ftoolBar.setButtonlist(list); - - ftoolBar.setDefault(this.defaultCheckBox.isSelected()); - if (!ftoolBar.isDefault()) { - ftoolBar.setBackground(this.background); - } - return ftoolBar; - } - - private class MoveUpItemAction extends UpdateAction { - public MoveUpItemAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Move_Up")); - this.setMnemonic('U'); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/up.png")); - } - - /** - * - */ - public void actionPerformed(ActionEvent evt) { - int selectedIndex = list.getSelectedIndex(); - if (selectedIndex == -1) { - return; - } - - // 上移 - if (selectedIndex > 0) { - DefaultListModel listModel = (DefaultListModel) list.getModel(); - - Object selecteObj1 = listModel.get(selectedIndex - 1); - listModel.set(selectedIndex - 1, listModel.get(selectedIndex)); - listModel.set(selectedIndex, selecteObj1); - - list.setSelectedIndex(selectedIndex - 1); - list.ensureIndexIsVisible(selectedIndex - 1); - list.validate(); - } - } - } - - private class MoveDownItemAction extends UpdateAction { - public MoveDownItemAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Move_Down")); - this.setMnemonic('D'); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/down.png")); - } - - /** - * - */ - public void actionPerformed(ActionEvent evt) { - int selectedIndex = list.getSelectedIndex(); - if (selectedIndex == -1) { - return; - } - - // 下移 - if (selectedIndex == -1) { - return; - } - - if (selectedIndex < list.getModel().getSize() - 1) { - DefaultListModel listModel = (DefaultListModel) list.getModel(); - - Object selecteObj1 = listModel.get(selectedIndex + 1); - listModel.set(selectedIndex + 1, listModel.get(selectedIndex)); - listModel.set(selectedIndex, selecteObj1); - - list.setSelectedIndex(selectedIndex + 1); - list.ensureIndexIsVisible(selectedIndex + 1); - list.validate(); - } - } - } - - public class RemoveAction extends UpdateAction { - public RemoveAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Delete")); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/remove.png")); - } - - /** - * 动作 - * @param e 事件 - */ - public void actionPerformed(ActionEvent e) { - int i = list.getSelectedIndex(); - if (i < 0 || !(listModel.getElementAt(i) instanceof ToolBarButton)) { - return; - } - int val = FineJOptionPane.showConfirmDialog(EditToolBar.this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Are_You_Sure_To_Delete_The_Data") + "?", - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION); - if (val != JOptionPane.YES_OPTION) { - return; - } - listModel.removeElementAt(i); - list.validate(); - if (listModel.size() > 0) { - list.setSelectedIndex(0); - } else { - card.show(right, "none"); - } - } - } - - public class ButtonPane extends BasicPane { - private CardLayout card; - private JPanel centerPane; - private UICheckBox icon, text, pdf, excelP, excelO, excelS, image, word, - isPopup, isVerify, failSubmit, isCurSheet, excelImClean, - excelImCover, excelImAppend, excelImCust, - customConsignee, consigneeByDepartment, consigneeByRole; - private UIBasicSpinner count; - private Widget widget; - private UITextField nameField; - private IconDefinePane iconPane; - private UIButton button; - private JavaScriptActionPane javaScriptPane; - private ExportToolBarProvider[] exportToolBarProviders; - - private ActionListener actionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - if (isVerify.isSelected()) { - failSubmit.setVisible(true); - } else { - failSubmit.setVisible(false); - failSubmit.setSelected(false); - } - } - }; - - public ButtonPane() { - this.initComponents(); - } - - /** - * 初始化元素 - */ - public void initComponents() { - Set set = ExtraDesignClassManager.getInstance().getArray(ExportToolBarProvider.XML_TAG); - exportToolBarProviders = set.toArray(new ExportToolBarProvider[set.size()]); - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - JPanel north = FRGUIPaneFactory.createBorderLayout_S_Pane(); - icon = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Show_Icon")); - text = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Show_Text")); - - north.add(icon, BorderLayout.NORTH); - north.add(text, BorderLayout.CENTER); - - nameField = new UITextField(8); - iconPane = new IconDefinePane(); - javaScriptPane = JavaScriptActionPane.createDefault(); - - double p = TableLayout.PREFERRED; - double rowSize[] = {p, p}; - double columnSize[] = {p, p}; - - Component[][] coms = new Component[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Printer_Alias") + ":"), nameField}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Icon") + ":"), iconPane}}; - - JPanel nameIconPane = TableLayoutHelper.createTableLayoutPane(coms, rowSize, columnSize); - - north.add(nameIconPane, BorderLayout.SOUTH); - - north.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Form_Button_Property"))); - this.add(north, BorderLayout.NORTH); - JPanel none = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - centerPane = FRGUIPaneFactory.createCardLayout_S_Pane(); - card = new CardLayout(); - centerPane.setLayout(card); - centerPane.add(CUSTOM, getCustomPane()); - centerPane.add(EXPORT, getExport()); - centerPane.add(EMAIL, getEmail()); - centerPane.add(NONE, none); - centerPane.add(getCpane(), APPEND_COUNT); - centerPane.add(getSubmitPane(), SUBMIT); - - Set extraButtonSet = ExtraDesignClassManager.getInstance().getArray(ExtraButtonToolBarProvider.XML_TAG); - for (ExtraButtonToolBarProvider provider : extraButtonSet) { - provider.updateCenterPane(centerPane); - } - - this.add(centerPane, BorderLayout.CENTER); - } - - - private JPanel getCustomPane() { - JPanel customPane = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); - - button = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_User_Defined_Event")); - customPane.add(button); - customPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit") + "JS", null)); - button.addActionListener(l); - return customPane; - } - - private JPanel getExport() { - JPanel export = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); - // export.setLayout(new BoxLayout(export, BoxLayout.Y_AXIS)); - pdf = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_PDF")); - excelP = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Output_Excel_Page")); - excelO = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_Excel_Simple")); - excelS = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_Excel_Sheet")); - word = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_Word")); - image = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Image")); - export.add(pdf); - export.add(Box.createVerticalStrut(2)); - export.add(excelP); - export.add(Box.createVerticalStrut(2)); - export.add(excelO); - export.add(Box.createVerticalStrut(2)); - export.add(excelS); - export.add(Box.createVerticalStrut(2)); - export.add(word); - export.add(Box.createVerticalStrut(2)); - export.add(image); - for(int i=0; i 0) { + list.setSelectedIndex(0); + } + + ToolBarDef toolbarDef = new ToolBarDef(); + toolbarDef.addShortCut(new MoveUpItemAction()); + toolbarDef.addShortCut(new MoveDownItemAction()); + toolbarDef.addShortCut(new RemoveAction()); + UIToolbar toolBar = ToolBarDef.createJToolBar(); + toolbarDef.updateToolBar(toolBar); + left.add(toolBar, BorderLayout.NORTH); + + right = FRGUIPaneFactory.createCardLayout_S_Pane(); + card = new CardLayout(); + right.setLayout(card); + bp = new ButtonPane(); + right.add("none", FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane()); + right.add("button", bp); + + JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, left, right); + // splitPane.setDividerLocation(left.getMinimumSize().width); + splitPane.setDividerLocation(120); + this.add(splitPane); + list.addListSelectionListener(listSelectionListener); + JPanel backgroundPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + UIButton bgButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Background")); + defaultCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default_Background")); + bgButton.addActionListener(actioner); + backgroundPane.add(defaultCheckBox); + backgroundPane.add(bgButton); + backgroundPane.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Background"))); + this.add(backgroundPane, BorderLayout.SOUTH); + } + + ListCellRenderer render = new DefaultListCellRenderer() { + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + if (value instanceof ToolBarButton) { + ToolBarButton button = (ToolBarButton) value; + this.setText(button.getNameOption().optionName()); + this.setIcon(button.getNameOption().optionIcon()); + } + return this; + } + }; + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit"); + } + + public void populate(FToolBar ftoolbar) { + this.populate(ftoolbar, null); + } + + public void populate(FToolBar ftoolbar, ToolBarButton button) { + if (ftoolbar == null) { + return; + } + for (int i = 0; i < ftoolbar.getButtonlist().size(); i++) { + listModel.addElement(ftoolbar.getButtonlist().get(i)); + } + this.list.validate(); + this.list.repaint(); + if (ftoolbar.getButtonlist().size() > 0) { + this.list.setSelectedIndex(0); + } + if (button != null) { + this.list.setSelectedValue(button, true); + } + this.background = ftoolbar.getBackground(); + + this.defaultCheckBox.setSelected(ftoolbar.isDefault() ? true : false); + } + + public FToolBar update() { + if (this.list.getSelectedIndex() > -1) { + for (int i = 0; i < listModel.getSize(); i++) { + this.list.setSelectedIndex(i); + ToolBarButton toolBarButton = (ToolBarButton) this.list.getSelectedValue(); + Widget widget = this.bp.update(); + toolBarButton.setWidget(widget); + if (widget instanceof Button) { + String iconname = ((Button) widget).getIconName(); + if (StringUtils.isNotBlank(iconname)) { + Image iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(iconname); + if (iconImage != null) { + toolBarButton.setIcon(new ImageIcon(iconImage)); + } else { + FineLoggerFactory.getLogger().warn(iconname + " can not find in finedb!"); + } + } + } + } + } + List list = new ArrayList(); + for (int i = 0; i < listModel.size(); i++) { + list.add((ToolBarButton) listModel.get(i)); + } + FToolBar ftoolBar = new FToolBar(); + ftoolBar.setButtonlist(list); + + ftoolBar.setDefault(this.defaultCheckBox.isSelected()); + if (!ftoolBar.isDefault()) { + ftoolBar.setBackground(this.background); + } + return ftoolBar; + } + + private class MoveUpItemAction extends UpdateAction { + public MoveUpItemAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Move_Up")); + this.setMnemonic('U'); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/up.png")); + } + + /** + * + */ + public void actionPerformed(ActionEvent evt) { + int selectedIndex = list.getSelectedIndex(); + if (selectedIndex == -1) { + return; + } + + // 上移 + if (selectedIndex > 0) { + DefaultListModel listModel = (DefaultListModel) list.getModel(); + + Object selecteObj1 = listModel.get(selectedIndex - 1); + listModel.set(selectedIndex - 1, listModel.get(selectedIndex)); + listModel.set(selectedIndex, selecteObj1); + + list.setSelectedIndex(selectedIndex - 1); + list.ensureIndexIsVisible(selectedIndex - 1); + list.validate(); + } + } + } + + private class MoveDownItemAction extends UpdateAction { + public MoveDownItemAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Move_Down")); + this.setMnemonic('D'); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/down.png")); + } + + /** + * + */ + public void actionPerformed(ActionEvent evt) { + int selectedIndex = list.getSelectedIndex(); + if (selectedIndex == -1) { + return; + } + + // 下移 + if (selectedIndex == -1) { + return; + } + + if (selectedIndex < list.getModel().getSize() - 1) { + DefaultListModel listModel = (DefaultListModel) list.getModel(); + + Object selecteObj1 = listModel.get(selectedIndex + 1); + listModel.set(selectedIndex + 1, listModel.get(selectedIndex)); + listModel.set(selectedIndex, selecteObj1); + + list.setSelectedIndex(selectedIndex + 1); + list.ensureIndexIsVisible(selectedIndex + 1); + list.validate(); + } + } + } + + public class RemoveAction extends UpdateAction { + public RemoveAction() { + this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Delete")); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/remove.png")); + } + + /** + * 动作 + * + * @param e 事件 + */ + public void actionPerformed(ActionEvent e) { + int i = list.getSelectedIndex(); + if (i < 0 || !(listModel.getElementAt(i) instanceof ToolBarButton)) { + return; + } + int val = FineJOptionPane.showConfirmDialog(EditToolBar.this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Are_You_Sure_To_Delete_The_Data") + "?", + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION); + if (val != JOptionPane.YES_OPTION) { + return; + } + listModel.removeElementAt(i); + list.validate(); + if (listModel.size() > 0) { + list.setSelectedIndex(0); + } else { + card.show(right, "none"); + } + } + } + + public class ButtonPane extends BasicPane { + private CardLayout card; + private JPanel centerPane; + private UICheckBox icon, text, pdf, excelP, excelO, excelS, image, word, + isPopup, isVerify, failSubmit, isCurSheet, excelImClean, + excelImCover, excelImAppend, excelImCust, + customConsignee, consigneeByDepartment, consigneeByRole; + private UIBasicSpinner count; + private Widget widget; + private UITextField nameField; + private IconDefinePane iconPane; + private UIButton button; + private JavaScriptActionPane javaScriptPane; + private ExportToolBarProvider[] exportToolBarProviders; + + private ActionListener actionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (isVerify.isSelected()) { + failSubmit.setVisible(true); + } else { + failSubmit.setVisible(false); + failSubmit.setSelected(false); + } + } + }; + + public ButtonPane() { + this.initComponents(); + } + + /** + * 初始化元素 + */ + public void initComponents() { + Set set = ExtraDesignClassManager.getInstance().getArray(ExportToolBarProvider.XML_TAG); + exportToolBarProviders = set.toArray(new ExportToolBarProvider[set.size()]); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel north = FRGUIPaneFactory.createBorderLayout_S_Pane(); + icon = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Show_Icon")); + text = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Show_Text")); + + north.add(icon, BorderLayout.NORTH); + north.add(text, BorderLayout.CENTER); + + nameField = new UITextField(8); + iconPane = new IconDefinePane(); + javaScriptPane = JavaScriptActionPane.createDefault(); + + double p = TableLayout.PREFERRED; + double rowSize[] = {p, p}; + double columnSize[] = {p, p}; + + Component[][] coms = new Component[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Printer_Alias") + ":"), nameField}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Icon") + ":"), iconPane}}; + + JPanel nameIconPane = TableLayoutHelper.createTableLayoutPane(coms, rowSize, columnSize); + + north.add(nameIconPane, BorderLayout.SOUTH); + + north.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Form_Button_Property"))); + this.add(north, BorderLayout.NORTH); + JPanel none = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + centerPane = FRGUIPaneFactory.createCardLayout_S_Pane(); + card = new CardLayout(); + centerPane.setLayout(card); + centerPane.add(CUSTOM, getCustomPane()); + centerPane.add(EXPORT, getExport()); + centerPane.add(EMAIL, getEmail()); + centerPane.add(NONE, none); + centerPane.add(getCpane(), APPEND_COUNT); + centerPane.add(getSubmitPane(), SUBMIT); + + Set extraButtonSet = ExtraDesignClassManager.getInstance().getArray(ExtraButtonToolBarProvider.XML_TAG); + for (ExtraButtonToolBarProvider provider : extraButtonSet) { + provider.updateCenterPane(centerPane); + } + + this.add(centerPane, BorderLayout.CENTER); + } + + + private JPanel getCustomPane() { + JPanel customPane = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); + + button = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_User_Defined_Event")); + customPane.add(button); + customPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit") + "JS", null)); + button.addActionListener(l); + return customPane; + } + + private JPanel getExport() { + JPanel export = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); + // export.setLayout(new BoxLayout(export, BoxLayout.Y_AXIS)); + pdf = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_PDF")); + excelP = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Output_Excel_Page")); + excelO = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_Excel_Simple")); + excelS = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_Excel_Sheet")); + word = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_Word")); + image = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Image")); + export.add(pdf); + export.add(Box.createVerticalStrut(2)); + export.add(excelP); + export.add(Box.createVerticalStrut(2)); + export.add(excelO); + export.add(Box.createVerticalStrut(2)); + export.add(excelS); + export.add(Box.createVerticalStrut(2)); + export.add(word); + export.add(Box.createVerticalStrut(2)); + export.add(image); + for (int i = 0; i < ArrayUtils.getLength(exportToolBarProviders); i++) { + export = exportToolBarProviders[i].updateCenterPane(export); + } + + export.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Form_Button_Property"), null)); + return export; + } + + private JPanel getEmail() { + JPanel email = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); + customConsignee = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Custom_Consignee")); + consigneeByDepartment = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Consignee_By_Department")); + consigneeByRole = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Consignee_By_Role")); + email.add(customConsignee); + email.add(Box.createVerticalStrut(2)); + email.add(consigneeByDepartment); + email.add(Box.createVerticalStrut(2)); + email.add(consigneeByRole); + email.add(Box.createVerticalStrut(2)); + + email.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Form_Button_Property"), null)); + return email; + } + + private JPanel getCpane() { + JPanel appendCountPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); + count = new UIBasicSpinner(new SpinnerNumberModel(1, 0, Integer.MAX_VALUE, 1)); + UILabel countLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Add_Row_Column_Numbers") + ":"); + JPanel cpane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + cpane.add(countLabel); + cpane.add(count); + appendCountPane.add(cpane); + return cpane; + } + + + private JPanel getSubmitPane() { + isVerify = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Verify_Data_Verify")); + failSubmit = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Verify_Fail_Still_Submit")); + isCurSheet = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Only_Submit_Current_Sheet")); + JPanel submitPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); + submitPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Form_Button_Property"), null)); + submitPane.add(isVerify); + submitPane.add(failSubmit); + submitPane.add(isCurSheet); + isVerify.addActionListener(actionListener); + return submitPane; + } + + @Override + protected String title4PopupWindow() { + return "Button"; + } + + ActionListener l = new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (!(widget instanceof CustomToolBarButton)) { + return; + } + if (javaScriptPane == null || ((CustomToolBarButton) widget).getJSImpl() == null) { + javaScriptPane = JavaScriptActionPane.createDefault(); + } + javaScriptPane.setResourceInfo(new JavaScriptResourceInfo(JavaScriptResourceInfo.Type.WIDGET, ((Button) widget).getText())); + + javaScriptPane.setPreferredSize(new Dimension(750, 500)); + BasicDialog dialog = javaScriptPane.showWindow(SwingUtilities.getWindowAncestor(ButtonPane.this)); + dialog.addDialogActionListener(new DialogActionAdapter() { + + @Override + public void doCancel() { + javaScriptPane.populateBean(((CustomToolBarButton) widget).getJSImpl()); + } + + @Override + public void doOk() { + ((CustomToolBarButton) widget).setJSImpl(javaScriptPane.updateBean()); + } + }); + dialog.setVisible(true); + } + }; /** * 更新 @@ -557,16 +561,16 @@ public class EditToolBar extends BasicPane { populateEmail(); } - Set extraButtonSet = ExtraDesignClassManager.getInstance().getArray(ExtraButtonToolBarProvider.XML_TAG); - for (ExtraButtonToolBarProvider provider : extraButtonSet) { - provider.populate(widget, card, centerPane); - } - } + Set extraButtonSet = ExtraDesignClassManager.getInstance().getArray(ExtraButtonToolBarProvider.XML_TAG); + for (ExtraButtonToolBarProvider provider : extraButtonSet) { + provider.populate(widget, card, centerPane); + } + } - private void populateAppendColumnRow(){ - card.show(centerPane, "appendcount"); - count.setValue(((AppendColumnRow) widget).getCount()); - } + private void populateAppendColumnRow() { + card.show(centerPane, "appendcount"); + count.setValue(((AppendColumnRow) widget).getCount()); + } private void populateExport(){ card.show(centerPane, "export"); @@ -584,113 +588,116 @@ public class EditToolBar extends BasicPane { } } - private void populateEmail(){ - card.show(centerPane, EMAIL); - Email email = (Email) widget; - this.customConsignee.setSelected(email.isCustomConsignee()); - this.consigneeByDepartment.setSelected(email.isConsigneeByDepartment()); - this.consigneeByRole.setSelected(email.isConsigneeByRole()); - } - - private void populateCustomToolBarButton(){ - card.show(centerPane, "custom"); - CustomToolBarButton customToolBarButton = (CustomToolBarButton) widget; - if (customToolBarButton.getJSImpl() != null) { - this.javaScriptPane.populateBean(customToolBarButton.getJSImpl()); - } - } - - private void populateSubmit(){ - card.show(centerPane, "submit"); - Submit submit = ((Submit) widget); - this.isVerify.setSelected(submit.isVerify()); - if (!submit.isVerify()) { - this.failSubmit.setVisible(false); - } - this.failSubmit.setSelected(submit.isFailVerifySubmit()); - this.isCurSheet.setSelected(submit.isOnlySubmitSelect()); - } - - private void populateDefault(){ - Button button = (Button) widget; - this.icon.setSelected(button.isShowIcon()); - this.text.setSelected(button.isShowText()); - this.nameField.setText(button.getText()); - this.iconPane.populate(((Button) widget).getIconName()); - } - - /** - * 更新 - * - * @return 对应组件 - */ - public Widget update() { - if (widget instanceof Export) { - updateExport(); - } else if (widget instanceof AppendColumnRow) { - ((AppendColumnRow) widget).setCount(((Integer) count.getValue()).intValue()); - } else if (widget instanceof Submit) { - updateSubmit(); - } else if (widget instanceof CustomToolBarButton) { - updateCustomToolBarButton(); - } else if (widget instanceof Email) { - updateEmail(); - } - if (widget instanceof Button) { - updateDefault(); - } - - Set extraButtonSet = ExtraDesignClassManager.getInstance().getArray(ExtraButtonToolBarProvider.XML_TAG); - for (ExtraButtonToolBarProvider provider : extraButtonSet) { - provider.update(widget); - } - - return widget; - } - - private void updateDefault(){ - ((Button) widget).setShowIcon(this.icon.isSelected()); - ((Button) widget).setShowText(this.text.isSelected()); - ((Button) widget).setText(this.nameField.getText()); - ((Button) widget).setIconName(this.iconPane.update()); - } - - private void updateSubmit(){ - Submit submit = ((Submit) widget); - submit.setVerify(this.isVerify.isSelected()); - submit.setFailVerifySubmit(this.failSubmit.isSelected()); - submit.setOnlySubmitSelect(this.isCurSheet.isSelected()); - } - - private void updateExport(){ - Export export = (Export) widget; - export.setPdfAvailable(this.pdf.isSelected()); - export.setExcelPAvailable(this.excelP.isSelected()); - export.setExcelOAvailable(this.excelO.isSelected()); - export.setExcelSAvailable(this.excelS.isSelected()); - export.setWordAvailable(this.word.isSelected()); - export.setImageAvailable(this.image.isSelected()); - if(exportToolBarProviders != null){ - for(int i=0; i extraButtonSet = ExtraDesignClassManager.getInstance().getArray(ExtraButtonToolBarProvider.XML_TAG); + for (ExtraButtonToolBarProvider provider : extraButtonSet) { + provider.update(widget); + } + + return widget; + } + + private void updateDefault() { + ((Button) widget).setShowIcon(this.icon.isSelected()); + ((Button) widget).setShowText(this.text.isSelected()); + ((Button) widget).setText(this.nameField.getText()); + ((Button) widget).setIconName(this.iconPane.update()); + } + + private void updateSubmit() { + Submit submit = ((Submit) widget); + submit.setVerify(this.isVerify.isSelected()); + submit.setFailVerifySubmit(this.failSubmit.isSelected()); + submit.setOnlySubmitSelect(this.isCurSheet.isSelected()); + } + + private void updateExport() { + Export export = (Export) widget; + export.setPdfAvailable(this.pdf.isSelected()); + export.setExcelPAvailable(this.excelP.isSelected()); + export.setExcelOAvailable(this.excelO.isSelected()); + export.setExcelSAvailable(this.excelS.isSelected()); + export.setWordAvailable(this.word.isSelected()); + export.setImageAvailable(this.image.isSelected()); + if (exportToolBarProviders != null) { + for (int i = 0; i < exportToolBarProviders.length; i++) { + exportToolBarProviders[i].update(); + ; + } + } + } + + private void updateEmail() { + Email email = ((Email) widget); + email.setCustomConsignee(this.customConsignee.isSelected()); + email.setConsigneeByDepartment(this.consigneeByDepartment.isSelected()); + email.setConsigneeByRole(this.consigneeByRole.isSelected()); + } + + private void updateCustomToolBarButton() { + CustomToolBarButton customToolBarButton = (CustomToolBarButton) widget; + if (customToolBarButton.getJSImpl() == null) { + this.javaScriptPane = JavaScriptActionPane.createDefault(); + } + javaScriptPane.setResourceInfo(new JavaScriptResourceInfo(JavaScriptResourceInfo.Type.CUSTOM_BUTTON, ((Button) widget).getText())); + + customToolBarButton.setJSImpl(this.javaScriptPane.updateBean()); + } + } } diff --git a/designer-realize/src/main/java/com/fr/design/widget/CellWidgetCardPane.java b/designer-realize/src/main/java/com/fr/design/widget/CellWidgetCardPane.java index 57e87e090d..8928e5fb6f 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/CellWidgetCardPane.java +++ b/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.ui.Widget; - import javax.swing.BorderFactory; import javax.swing.JPanel; import java.awt.BorderLayout; @@ -166,7 +165,7 @@ public class CellWidgetCardPane extends BasicPane { } widgetPropertyPane.update(widget); - Listener[] listener = eventPane == null ? new Listener[0] : eventPane.updateListeners(); + Listener[] listener = eventPane == null ? new Listener[0] : eventPane.updateListeners(widget); widget.clearListeners(); for (Listener l : listener) { widget.addListener(l); diff --git a/designer-realize/src/main/java/com/fr/design/widget/WidgetEventPane.java b/designer-realize/src/main/java/com/fr/design/widget/WidgetEventPane.java index 936001d702..679915da7d 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/WidgetEventPane.java +++ b/designer-realize/src/main/java/com/fr/design/widget/WidgetEventPane.java @@ -1,29 +1,30 @@ package com.fr.design.widget; -import java.lang.reflect.Constructor; 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.UIListGroupControlPane; import com.fr.design.gui.frpane.ListenerUpdatePane; +import com.fr.design.i18n.Toolkit; import com.fr.design.javascript.JavaScriptActionPane; +import com.fr.design.mainframe.CellWidgetPropertyPane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; 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.ui.Widget; -import com.fr.grid.selection.Selection; - import com.fr.general.NameObject; 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.Nameable; +import com.fr.write.JavaScriptResourceInfo; -import javax.swing.*; +import javax.swing.BorderFactory; +import java.lang.reflect.Constructor; public class WidgetEventPane extends UIListGroupControlPane { 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 Widget targetWidget; + public WidgetEventPane(ElementCasePane pane) { this.object = pane; - if(pane != null){ + if (pane != null) { selection = pane.getSelection(); } setBorder(BorderFactory.createEmptyBorder(10, 0, 15, 0)); @@ -125,18 +128,21 @@ public class WidgetEventPane extends UIListGroupControlPane { if (widget == null) { return; } + this.targetWidget = widget; refreshPane(widget, EventCreator.createEventCreator(widget.supportedEvents(), WidgetEventListenerUpdatePane.class)); } - /** - * 更新 - * @return 监听器 - */ - public Listener[] updateListeners() { + /** + * 更新 + * + * @return 监听器 + */ + public Listener[] updateListeners(Widget widget) { + this.targetWidget = widget; Nameable[] res = this.update(); Listener[] res_array = new Listener[res.length]; 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; } @@ -174,14 +180,22 @@ public class WidgetEventPane extends UIListGroupControlPane { if (constructor != null) { return constructor; } else { - if (AssistUtils.equals(cls.getName(),Object.class.getName())) { + if (AssistUtils.equals(cls.getName(), Object.class.getName())) { return null; } 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"); } From 6ed7588b7b04ed56f94c666ead775713e6db34e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Mon, 16 Aug 2021 14:28:09 +0800 Subject: [PATCH 18/32] =?UTF-8?q?REPORT-56906=20=20=E7=94=B1=E4=BA=8EUIInt?= =?UTF-8?q?NumberField=E8=A2=AB=E5=BC=95=E7=94=A8=E7=9A=84=E5=9C=B0?= =?UTF-8?q?=E6=96=B9=E5=A4=AA=E5=A4=9A=E4=BA=86=EF=BC=8C=E6=89=80=E4=BB=A5?= =?UTF-8?q?=E8=BF=98=E5=8E=9F=E8=BF=99=E4=B8=AA=E7=B1=BB=E7=9A=84=E9=87=8D?= =?UTF-8?q?=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/ispinner/UnsignedIntUISpinner.java | 4 +- .../gui/itextfield/UIIntNumberField.java | 66 +++++++--------- .../UIPositiveAndNegativeIntNumberField.java | 76 +++++++++++++++++++ .../itextfield/UIPositiveIntNumberField.java | 61 --------------- .../ui/MobileCollapsedStyleExpandPane.java | 4 +- .../widget/ui/FormMultiWidgetCardPane.java | 6 +- .../fr/design/report/freeze/RowSpinner.java | 4 +- .../GlobalNativePrintSettingPane.java | 4 +- 8 files changed, 113 insertions(+), 112 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveAndNegativeIntNumberField.java delete mode 100644 designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveIntNumberField.java diff --git a/designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java b/designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java index 4d4e2794b1..42a40cd79e 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java +++ b/designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java @@ -1,6 +1,6 @@ package com.fr.design.gui.ispinner; -import com.fr.design.gui.itextfield.UIPositiveIntNumberField; +import com.fr.design.gui.itextfield.UIIntNumberField; import com.fr.design.gui.itextfield.UINumberField; @@ -29,7 +29,7 @@ public class UnsignedIntUISpinner extends UISpinner { @Override protected UINumberField initNumberField() { - return new UIPositiveIntNumberField() { + return new UIIntNumberField() { public boolean shouldResponseChangeListener() { return false; } diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/UIIntNumberField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/UIIntNumberField.java index e81694d267..862eedaff0 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/UIIntNumberField.java +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/UIIntNumberField.java @@ -1,32 +1,39 @@ package com.fr.design.gui.itextfield; + import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.PlainDocument; import java.awt.Toolkit; +/** + * Created with IntelliJ IDEA. + * User: Lenovo + * Date: 13-3-29 + * Time: 下午12:02 + * To change this template use File | Settings | File Templates. + * fanglei: 这个类名字虽然叫整数输入框,但是里面的业务仅支持输入正整数,由于被引用的地方太多无法更改,知道就行 + */ public class UIIntNumberField extends UINumberField { - private static final long serialVersionUID = 4946379346015964509L; - public void setFieldDocument() { setDocument(createNumberDocument()); } public class NumberDocument extends PlainDocument { - private static final long serialVersionUID = 1024213269275179172L; - public NumberDocument() { } - public boolean checkString(int offset, String s, String str) { - String strNew = str.substring(0, offset) + s + str.substring(offset, getLength()); - return isMinusSignOnly(strNew) || (isIntNumber(strNew) && isInputIllegalNumber(strNew) && !isOverMaxOrMinValue(strNew)); - - } - public void insertString(int offset, String s, AttributeSet a) throws BadLocationException { String str = getText(0, getLength()); - if (!checkString(offset, s, str)) { + + if (!s.matches("^[0-9]+$")) { + Toolkit.getDefaultToolkit().beep(); + return; + } + + String strNew = str.substring(0, offset) + s + str.substring(offset, getLength()); + + if (isOverMaxOrMinValue(strNew) && !isContinueInsertWhenOverMaxOrMinValue()) { Toolkit.getDefaultToolkit().beep(); return; } @@ -35,42 +42,21 @@ public class UIIntNumberField extends UINumberField { super.insertString(offset, s, a); } - private boolean isMinusSignOnly(String s) { - return s.contains("-") && s.length() == 1; - } - /** - * 输入字符是否是不合法数字 - * @param s 输入的字符串 - * @return 是否不合法 + * 是否继续插入输入的字符 - 当超出范围时 + * + * @return true : 继续插入输入的字符 */ - private boolean isInputIllegalNumber(String s) { - try { - Integer.parseInt(s); - } catch (Exception e) { - return false; - } - return true; - } - - private boolean isIntNumber(String s) { - boolean result = true; - for (int i = 0; i < s.length(); i++) { - String ch = s.charAt(i) + ""; - if (!ch.matches("^[0-9\\-]+$")) { - result = false; - } - } - return result; + public boolean isContinueInsertWhenOverMaxOrMinValue() { + return false; } - private boolean isOverMaxOrMinValue(String s) { - int value = Integer.parseInt(s); - return (value < getMinValue() || value > getMaxValue()); + private boolean isOverMaxOrMinValue( String strNew) { + return (Double.parseDouble(strNew)getMaxValue()); } } public NumberDocument createNumberDocument() { return new NumberDocument(); } -} +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveAndNegativeIntNumberField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveAndNegativeIntNumberField.java new file mode 100644 index 0000000000..6f903d5cb7 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveAndNegativeIntNumberField.java @@ -0,0 +1,76 @@ +package com.fr.design.gui.itextfield; + +import javax.swing.text.AttributeSet; +import javax.swing.text.BadLocationException; +import javax.swing.text.PlainDocument; +import java.awt.Toolkit; + +public class UIPositiveAndNegativeIntNumberField extends UINumberField { + private static final long serialVersionUID = 4946379346015964509L; + + public void setFieldDocument() { + setDocument(createNumberDocument()); + } + + public class NumberDocument extends PlainDocument { + private static final long serialVersionUID = 1024213269275179172L; + + public NumberDocument() { + } + + public boolean checkString(int offset, String s, String str) { + String strNew = str.substring(0, offset) + s + str.substring(offset, getLength()); + return isMinusSignOnly(strNew) || (isIntNumber(strNew) && isInputIllegalNumber(strNew) && !isOverMaxOrMinValue(strNew)); + + } + + public void insertString(int offset, String s, AttributeSet a) throws BadLocationException { + String str = getText(0, getLength()); + if (!checkString(offset, s, str)) { + Toolkit.getDefaultToolkit().beep(); + return; + } + + setisContentChanged(true); + super.insertString(offset, s, a); + } + + private boolean isMinusSignOnly(String s) { + return s.contains("-") && s.length() == 1; + } + + /** + * 输入字符是否是不合法数字 + * @param s 输入的字符串 + * @return 是否不合法 + */ + private boolean isInputIllegalNumber(String s) { + try { + Integer.parseInt(s); + } catch (Exception e) { + return false; + } + return true; + } + + private boolean isIntNumber(String s) { + boolean result = true; + for (int i = 0; i < s.length(); i++) { + String ch = s.charAt(i) + ""; + if (!ch.matches("^[0-9\\-]+$")) { + result = false; + } + } + return result; + } + + private boolean isOverMaxOrMinValue(String s) { + int value = Integer.parseInt(s); + return (value < getMinValue() || value > getMaxValue()); + } + } + + public NumberDocument createNumberDocument() { + return new NumberDocument(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveIntNumberField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveIntNumberField.java deleted file mode 100644 index ec99777d7b..0000000000 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveIntNumberField.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.fr.design.gui.itextfield; - - -import javax.swing.text.AttributeSet; -import javax.swing.text.BadLocationException; -import javax.swing.text.PlainDocument; -import java.awt.Toolkit; - -/** - * Created with IntelliJ IDEA. - * User: Lenovo - * Date: 13-3-29 - * Time: 下午12:02 - * To change this template use File | Settings | File Templates. - */ -public class UIPositiveIntNumberField extends UINumberField { - public void setFieldDocument() { - setDocument(createNumberDocument()); - } - - public class NumberDocument extends PlainDocument { - public NumberDocument() { - } - - public void insertString(int offset, String s, AttributeSet a) throws BadLocationException { - String str = getText(0, getLength()); - - if (!s.matches("^[0-9]+$")) { - Toolkit.getDefaultToolkit().beep(); - return; - } - - String strNew = str.substring(0, offset) + s + str.substring(offset, getLength()); - - if (isOverMaxOrMinValue(strNew) && !isContinueInsertWhenOverMaxOrMinValue()) { - Toolkit.getDefaultToolkit().beep(); - return; - } - - setisContentChanged(true); - super.insertString(offset, s, a); - } - - /** - * 是否继续插入输入的字符 - 当超出范围时 - * - * @return true : 继续插入输入的字符 - */ - public boolean isContinueInsertWhenOverMaxOrMinValue() { - return false; - } - - private boolean isOverMaxOrMinValue( String strNew) { - return (Double.parseDouble(strNew)getMaxValue()); - } - } - - public NumberDocument createNumberDocument() { - return new NumberDocument(); - } -} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java index 531a946b7e..8fd34d4524 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java @@ -2,7 +2,7 @@ package com.fr.design.mainframe.mobile.ui; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; -import com.fr.design.gui.itextfield.UIPositiveIntNumberField; +import com.fr.design.gui.itextfield.UIIntNumberField; import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; @@ -39,7 +39,7 @@ public class MobileCollapsedStyleExpandPane extends MobileCollapsedStylePane { this.rowSpinner = new UISpinner(1, Integer.MAX_VALUE, 1, 1) { @Override protected UINumberField initNumberField(){ - return new UIPositiveIntNumberField(); + return new UIIntNumberField(); } }; this.rowSpinner.setPreferredSize(new Dimension(62, COMPONENT_HEIGHT)); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java index c1dda9cc95..fa9a9bd0bc 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java @@ -2,7 +2,7 @@ package com.fr.design.mainframe.widget.ui; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.itextfield.UIIntNumberField; +import com.fr.design.gui.itextfield.UIPositiveAndNegativeIntNumberField; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; @@ -129,14 +129,14 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane { TableLayout.PREFERRED, TableLayout.FILL }; - UITextField horizontalSpacingNumberField = new UIIntNumberField(); + UITextField horizontalSpacingNumberField = new UIPositiveAndNegativeIntNumberField(); horizontalSpacingNumberField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { distributionDoChange(horizontalSpacingNumberField.getText(), false); } }); - UITextField verticalSpacingNumberField = new UIIntNumberField(); + UITextField verticalSpacingNumberField = new UIPositiveAndNegativeIntNumberField(); verticalSpacingNumberField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { diff --git a/designer-realize/src/main/java/com/fr/design/report/freeze/RowSpinner.java b/designer-realize/src/main/java/com/fr/design/report/freeze/RowSpinner.java index 961b05cfc1..da652a0e44 100644 --- a/designer-realize/src/main/java/com/fr/design/report/freeze/RowSpinner.java +++ b/designer-realize/src/main/java/com/fr/design/report/freeze/RowSpinner.java @@ -1,7 +1,7 @@ package com.fr.design.report.freeze; import com.fr.design.gui.ispinner.UISpinner; -import com.fr.design.gui.itextfield.UIPositiveIntNumberField; +import com.fr.design.gui.itextfield.UIIntNumberField; import com.fr.design.gui.itextfield.UINumberField; /** @@ -25,7 +25,7 @@ public class RowSpinner extends UISpinner { @Override protected UINumberField initNumberField(){ - return new UIPositiveIntNumberField(); + return new UIIntNumberField(); } diff --git a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/GlobalNativePrintSettingPane.java b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/GlobalNativePrintSettingPane.java index e9877b2514..7b3643899a 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/GlobalNativePrintSettingPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/GlobalNativePrintSettingPane.java @@ -3,7 +3,7 @@ package com.fr.design.webattr.printsettings; import com.fr.base.print.NativePrintAttr; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.itextfield.UIPositiveIntNumberField; +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.layout.FRGUIPaneFactory; @@ -89,7 +89,7 @@ public class GlobalNativePrintSettingPane extends AbstractNativePrintSettingPane } private JPanel getPrintPortFieldPane() { - printPortField = new UIPositiveIntNumberField(); + printPortField = new UIIntNumberField(); printPortField.setMaxValue(NativePrintAttr.MAX_PRINT_PORT_VALUE); printPortField.setColumns(PRINT_PORT_FIELD_COLUMNS); JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); From 39a0b0db0af3db516eb04bcf33823c13e1b9bca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Mon, 16 Aug 2021 14:48:44 +0800 Subject: [PATCH 19/32] =?UTF-8?q?CHART-20229=20=E5=9B=BE=E8=A1=A8=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/gui/xcombox/MarkerComboBox.java | 204 +++++++++--------- .../designer/component/LineTypeComboBox.java | 17 +- 2 files changed, 110 insertions(+), 111 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java b/designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java index 5909437c70..8534ed4b72 100644 --- a/designer-chart/src/main/java/com/fr/design/gui/xcombox/MarkerComboBox.java +++ b/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.background.ColorBackground; 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.UIComboBoxRenderer; import com.fr.design.i18n.Toolkit; +import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; +import com.fr.plugin.chart.ConfigHelper; - -import javax.swing.*; -import java.awt.*; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JLabel; +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. */ public class MarkerComboBox extends UIComboBox { - private static final double TEXT_X_COORDINATES = 12d; - - /** - * Constructor. - * - * @param markerArray the array of marker. - */ - public MarkerComboBox(Marker[] markerArray) { - this.setModel(new DefaultComboBoxModel(markerArray)); - this.setRenderer(new MarkerCellRenderer()); - } - - /** - * Get selected marker. - */ - public Marker getSelectedMarkder() { - return (Marker) getSelectedItem(); - } - - /** - * Set the selected marker. - */ - public void setSelectedMarker(Marker marker) { - setSelectedItem(marker); - } - - /** - * CellRenderer. - */ - class MarkerCellRenderer extends UIComboBoxRenderer { - public Component getListCellRendererComponent(JList list, - Object value, int index, boolean isSelected, boolean cellHasFocus) { - this.marker = (Marker) value; - this.isSelected = isSelected; - - return this; - } - - public void paint(Graphics g) { - Graphics2D g2d = (Graphics2D) g; - - Dimension d = getSize(); - g2d.setColor(Color.black); - g2d.setFont(FRContext.getDefaultValues().getFRFont()); - - if (marker != null) { - boolean isAutoMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.AUTO_M); - boolean isNullMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.NULL_M); - - if (isAutoMarker || isNullMarker) { - String text = isNullMarker - ?Toolkit.i18nText("Fine-Design_Report_None") - :Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto"); - - paintTextMarker(g2d, d, text); - } else { - if (marker.getBackground() == null) { - marker.setBackground(ColorBackground.getInstance(Color.black)); - } - marker.paint(g2d, d.width / 2, d.height / 2); - } - } - - if (isSelected) { - g2d.setColor(Color.blue); - GraphHelper.drawRect(g2d, 0, 0, d.width - 1, d.height - 1); - } - } - - public Dimension getPreferredSize() { - return new Dimension(36, 16); - } - - public Dimension getMinimumSize() { - return getPreferredSize(); - } - - private Marker marker = null; - private boolean isSelected = false; - - private void paintTextMarker(Graphics2D g2d, Dimension d, String text) { - g2d.setColor(Color.black); - 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, text, TEXT_X_COORDINATES, (d.height - fm.getHeight()) / 2 + fm.getAscent()); - } - } + private static final double TEXT_X_COORDINATES = 12d; + + /** + * Constructor. + * + * @param markerArray the array of marker. + */ + public MarkerComboBox(Marker[] markerArray) { + this.setModel(new DefaultComboBoxModel(markerArray)); + this.setRenderer(new MarkerCellRenderer()); + } + + /** + * Get selected marker. + */ + public Marker getSelectedMarkder() { + return (Marker) getSelectedItem(); + } + + /** + * Set the selected marker. + */ + public void setSelectedMarker(Marker marker) { + setSelectedItem(marker); + } + + /** + * CellRenderer. + */ + class MarkerCellRenderer extends UIComboBoxRenderer { + + private Marker marker = null; + private boolean isSelected = false; + + public Component getListCellRendererComponent(JList list, + Object value, int index, boolean isSelected, boolean cellHasFocus) { + this.marker = (Marker) value; + this.isSelected = isSelected; + + String text = null; + if (marker != null) { + boolean isAutoMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.AUTO_M); + boolean isNullMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.NULL_M); + if (isAutoMarker || isNullMarker) { + text = isNullMarker + ? Toolkit.i18nText("Fine-Design_Report_None") + : Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto"); + } + } + JLabel comp = (JLabel) super.getListCellRendererComponent(list, text, index, isSelected, cellHasFocus); + return comp; + } + + public void paint(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + Dimension d = getSize(); + if (marker != null) { + boolean isAutoMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.AUTO_M); + boolean isNullMarker = ComparatorUtils.equals(marker.getMarkerType(), ConfigHelper.NULL_M); + if (isAutoMarker || isNullMarker) { + super.paint(g); + } else { + g2d.setColor(Color.black); + if (marker.getBackground() == null) { + marker.setBackground(ColorBackground.getInstance(Color.black)); + } + marker.paint(g2d, d.width / 2, d.height / 2); + } + } + + if (isSelected) { + g2d.setColor(Color.blue); + GraphHelper.drawRect(g2d, 0, 0, d.width - 1, d.height - 1); + } + } + + public Dimension getPreferredSize() { + return new Dimension(36, 16); + } + + public Dimension getMinimumSize() { + return getPreferredSize(); + } + + + private void paintTextMarker(Graphics2D g2d, Dimension d, String text) { + g2d.setColor(Color.black); + 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, text, TEXT_X_COORDINATES, (d.height - fm.getHeight()) / 2 + fm.getAscent()); + } + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java index 8502888bd3..395d615926 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java @@ -1,12 +1,9 @@ package com.fr.van.chart.designer.component; -import com.fr.base.FRContext; import com.fr.base.GraphHelper; -import com.fr.base.ScreenResolution; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.i18n.Toolkit; -import com.fr.general.FRFont; import com.fr.plugin.chart.type.LineType; import com.fr.stable.Constants; @@ -14,8 +11,6 @@ import javax.swing.JLabel; import javax.swing.JList; import java.awt.Component; import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; @@ -37,9 +32,9 @@ public class LineTypeComboBox extends UIComboBox { public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); 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; } @@ -51,14 +46,6 @@ public class LineTypeComboBox extends UIComboBox { g2d.setColor(getForeground()); 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: GraphHelper.drawLine(g2d, 4, d.height / 2, d.width - 8, d.height / 2); break; From 9b8f88406762c4eb9b677cf50cd9e427d1b84707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Mon, 16 Aug 2021 15:02:52 +0800 Subject: [PATCH 20/32] =?UTF-8?q?REPORT-56929=20=E3=80=90FRM=E5=B8=83?= =?UTF-8?q?=E5=B1=80=E6=8E=A8=E8=8D=90=E3=80=91=E7=BB=84=E4=BB=B6=E5=A4=8D?= =?UTF-8?q?=E7=94=A8-=E6=89=8B=E5=8A=A8=E9=97=B4=E8=B7=9D=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=A1=86=E7=9B=AE=E5=89=8D=E4=B8=8D=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=9B=9E=E8=BD=A6=E8=A7=A6=E5=8F=91=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widget/ui/FormMultiWidgetCardPane.java | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java index fa9a9bd0bc..699c34b2a4 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java @@ -26,6 +26,8 @@ import java.awt.BorderLayout; import java.awt.Component; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; public class FormMultiWidgetCardPane extends FormWidgetCardPane { private MultiSelectionArrangement arrangement; @@ -129,20 +131,8 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane { TableLayout.PREFERRED, TableLayout.FILL }; - UITextField horizontalSpacingNumberField = new UIPositiveAndNegativeIntNumberField(); - horizontalSpacingNumberField.addFocusListener(new FocusAdapter() { - @Override - public void focusLost(FocusEvent e) { - distributionDoChange(horizontalSpacingNumberField.getText(), false); - } - }); - UITextField verticalSpacingNumberField = new UIPositiveAndNegativeIntNumberField(); - verticalSpacingNumberField.addFocusListener(new FocusAdapter() { - @Override - public void focusLost(FocusEvent e) { - distributionDoChange(verticalSpacingNumberField.getText(), true); - } - }); + UITextField horizontalSpacingNumberField = createIntNumberField(false); + UITextField verticalSpacingNumberField = createIntNumberField(true); Component[][] components = new Component[][] { new Component[] { new UILabel(IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_horizontal_spacing.png")), @@ -157,6 +147,25 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane { return createTitleLayout(Toolkit.i18nText("Fine-Design_Multi_Selection_Manual_Spacing"), centerPane); } + private UIPositiveAndNegativeIntNumberField createIntNumberField(boolean isVertical) { + final UIPositiveAndNegativeIntNumberField intNumberField = new UIPositiveAndNegativeIntNumberField(); + intNumberField.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + distributionDoChange(intNumberField.getText(), isVertical); + } + }); + intNumberField.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + distributionDoChange(intNumberField.getText(), isVertical); + } + } + }); + return intNumberField; + } + private void distributionDoChange(String text, boolean isVertical) { if (StableUtils.isNumber(text)) { if (isVertical) { From c95c24b7b6ce626b2d8b22ce54f523c9376c7c61 Mon Sep 17 00:00:00 2001 From: hades Date: Mon, 16 Aug 2021 17:33:27 +0800 Subject: [PATCH 21/32] =?UTF-8?q?KERNEL-7634=20jxbrowser=20=E5=B0=8F?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=86=8D=E5=8D=87=E7=BA=A7=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 8 ++-- .../ui/compatible/ModernUIPaneFactory.java | 9 +++- .../design/ui/compatible/NewModernUIPane.java | 44 +++++++++++-------- .../NxComplexInterceptRequestCallback.java | 16 +++---- .../NxInterceptRequestCallback.java | 34 +++++++------- 5 files changed, 61 insertions(+), 50 deletions(-) diff --git a/build.gradle b/build.gradle index 804f1ad0f9..a469ec9c27 100644 --- a/build.gradle +++ b/build.gradle @@ -60,10 +60,10 @@ allprojects { implementation 'com.fr.third:jxbrowser:6.23' implementation 'com.fr.third:jxbrowser-mac:6.23' implementation 'com.fr.third:jxbrowser-win64:6.23' - implementation 'com.fr.third:jxbrowser-v7:7.7' - implementation 'com.fr.third:jxbrowser-mac-v7:7.7' - implementation 'com.fr.third:jxbrowser-win64-v7:7.7' - implementation 'com.fr.third:jxbrowser-swing-v7:7.7' + implementation 'com.fr.third:jxbrowser-v7:7.15' + implementation 'com.fr.third:jxbrowser-mac-v7:7.15' + implementation 'com.fr.third:jxbrowser-win64-v7:7.15' + implementation 'com.fr.third:jxbrowser-swing-v7:7.15' implementation 'com.fr.third.server:servlet-api:3.0' implementation 'org.swingexplorer:swexpl:2.0.1' implementation 'org.swingexplorer:swag:1.0' diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java b/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java index 8616b647b4..5ae56627e9 100644 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java +++ b/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 static ModernUIPane.Builder 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<>(); } else { return new ModernUIPane.Builder<>(); diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java b/designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java index ab883516cf..33747d3f15 100644 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java +++ b/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.RenderingMode; import com.teamdev.jxbrowser.js.JsObject; -import com.teamdev.jxbrowser.net.Network; -import com.teamdev.jxbrowser.net.callback.InterceptRequestCallback; +import com.teamdev.jxbrowser.net.Scheme; import com.teamdev.jxbrowser.view.swing.BrowserView; import java.awt.BorderLayout; import java.awt.Dimension; import java.util.Map; -import java.util.Optional; + import javax.swing.JDialog; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; @@ -43,6 +42,8 @@ public class NewModernUIPane extends ModernUIPane { private String namespace = "Pool"; private String variable = "data"; private String expression = "update()"; + private Scheme scheme; + private NxInterceptRequestCallback requestCallback; private NewModernUIPane() { super(); @@ -96,7 +97,13 @@ public class NewModernUIPane extends ModernUIPane { } 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(); // 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的 @@ -124,8 +131,9 @@ public class NewModernUIPane extends ModernUIPane { */ @Override public void redirect(String url, Map map) { - Network network = browser.engine().network(); - network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network, map)); + if (requestCallback != null) { + requestCallback.setMap(map); + } browser.navigation().loadUrl(url); } @@ -169,8 +177,8 @@ public class NewModernUIPane extends ModernUIPane { */ @Override public NewModernUIPane.Builder withEMB(final String path) { - Network network = pane.browser.engine().network(); - network.set(InterceptRequestCallback.class, new NxComplexInterceptRequestCallback(network, null)); + pane.scheme = Scheme.of("emb"); + pane.requestCallback = new NxComplexInterceptRequestCallback(null); pane.browser.navigation().loadUrl("emb:" + path); return this; } @@ -182,8 +190,8 @@ public class NewModernUIPane extends ModernUIPane { */ @Override public NewModernUIPane.Builder withURL(final String url) { - Network network = pane.browser.engine().network(); - network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network)); + pane.scheme = Scheme.of("file"); + pane.requestCallback = new NxComplexInterceptRequestCallback(null); pane.browser.navigation().loadUrl(url); return this; } @@ -195,8 +203,8 @@ public class NewModernUIPane extends ModernUIPane { */ @Override public NewModernUIPane.Builder withURL(final String url, Map map) { - Network network = pane.browser.engine().network(); - network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network, map)); + pane.scheme = Scheme.of("file"); + pane.requestCallback = new NxInterceptRequestCallback(map); pane.browser.navigation().loadUrl(url); return this; } @@ -208,8 +216,8 @@ public class NewModernUIPane extends ModernUIPane { */ @Override public NewModernUIPane.Builder withComponent(AssembleComponent component) { - Network network = pane.browser.engine().network(); - network.set(InterceptRequestCallback.class, new NxComplexInterceptRequestCallback(network, component)); + pane.scheme = Scheme.of("emb"); + pane.requestCallback = new NxComplexInterceptRequestCallback(component); pane.browser.navigation().loadUrl("emb:dynamic"); return this; } @@ -221,8 +229,8 @@ public class NewModernUIPane extends ModernUIPane { */ @Override public NewModernUIPane.Builder withComponent(AssembleComponent component, Map map) { - Network network = pane.browser.engine().network(); - network.set(InterceptRequestCallback.class, new NxComplexInterceptRequestCallback(network, component, map)); + pane.scheme = Scheme.of("emb"); + pane.requestCallback = new NxComplexInterceptRequestCallback(component, map); pane.browser.navigation().loadUrl("emb:dynamic"); return this; } @@ -235,8 +243,8 @@ public class NewModernUIPane extends ModernUIPane { */ @Override public NewModernUIPane.Builder withHTML(String html) { - Network network = pane.browser.engine().network(); - network.set(InterceptRequestCallback.class, new NxInterceptRequestCallback(network)); + pane.scheme = Scheme.of("html"); + pane.requestCallback = new NxInterceptRequestCallback(); pane.browser.mainFrame().ifPresent(frame -> { frame.loadHtml(html); }); diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/NxComplexInterceptRequestCallback.java b/designer-base/src/main/java/com/fr/design/ui/compatible/NxComplexInterceptRequestCallback.java index f3147b6529..eb85495d40 100644 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/NxComplexInterceptRequestCallback.java +++ b/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.category.ScriptPath; 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.nio.charset.StandardCharsets; @@ -26,21 +23,20 @@ public class NxComplexInterceptRequestCallback extends NxInterceptRequestCallbac private AssembleComponent component; - public NxComplexInterceptRequestCallback(Network network, AssembleComponent component) { - super(network); + public NxComplexInterceptRequestCallback(AssembleComponent component) { this.component = component; } - public NxComplexInterceptRequestCallback(Network network, AssembleComponent component, Map map) { - super(network, map); + public NxComplexInterceptRequestCallback(AssembleComponent component, Map map) { + super(map); this.component = component; } @Override - protected Response next(UrlRequest urlRequest, String path) { + protected Response next(Params params, String path) { if (path.startsWith("emb:dynamic")) { 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 { int index = path.indexOf("="); if (index > 0) { @@ -52,7 +48,7 @@ public class NxComplexInterceptRequestCallback extends NxInterceptRequestCallbac if (inputStream == null) { return Response.proceed(); } - return InterceptRequestCallback.Response.intercept(generateBasicUrlRequestJob(urlRequest, getMimeType(path), IOUtils.inputStream2Bytes(inputStream))); + return Response.intercept(generateBasicUrlRequestJob(params, getMimeType(path), IOUtils.inputStream2Bytes(inputStream))); } } diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/NxInterceptRequestCallback.java b/designer-base/src/main/java/com/fr/design/ui/compatible/NxInterceptRequestCallback.java index e2ab7ad93c..32a8f8b610 100644 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/NxInterceptRequestCallback.java +++ b/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.teamdev.jxbrowser.net.HttpHeader; import com.teamdev.jxbrowser.net.HttpStatus; -import com.teamdev.jxbrowser.net.Network; import com.teamdev.jxbrowser.net.UrlRequest; 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.IOException; import java.io.InputStream; @@ -29,17 +28,14 @@ import java.util.Optional; * @version 10.0 * Created by richie on 2020/3/25 */ -public class NxInterceptRequestCallback implements InterceptRequestCallback { +public class NxInterceptRequestCallback implements InterceptUrlRequestCallback { - Network network; Map map; - public NxInterceptRequestCallback(Network network) { - this.network = network; + public NxInterceptRequestCallback() { } - public NxInterceptRequestCallback(Network network, Map map) { - this.network = network; + public NxInterceptRequestCallback(Map map) { this.map = map; } @@ -48,21 +44,21 @@ public class NxInterceptRequestCallback implements InterceptRequestCallback { UrlRequest urlRequest = params.urlRequest(); String path = urlRequest.url(); if (path.startsWith("file:")) { - Optional optional = generateFileProtocolUrlRequestJob(urlRequest, path); + Optional optional = generateFileProtocolUrlRequestJob(params, path); if (optional.isPresent()) { - return InterceptRequestCallback.Response.intercept(optional.get()); + return Response.intercept(optional.get()); } } else { - return next(urlRequest, path); + return next(params, path); } return Response.proceed(); } - Response next(UrlRequest urlRequest, String path) { + Response next(Params params, String path) { return Response.proceed(); } - private Optional generateFileProtocolUrlRequestJob(UrlRequest urlRequest, String path) { + private Optional generateFileProtocolUrlRequestJob(Params params, String path) { try { String url = new URLCodec().decode(path); String filePath = TemplateUtils.renderParameter4Tpl(url, map); @@ -77,7 +73,7 @@ public class NxInterceptRequestCallback implements InterceptRequestCallback { } else { bytes = IOUtils.inputStream2Bytes(inputStream); } - return Optional.of(generateBasicUrlRequestJob(urlRequest, mimeType, bytes)); + return Optional.of(generateBasicUrlRequestJob(params, mimeType, bytes)); } catch (Exception 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); } - UrlRequestJob generateBasicUrlRequestJob(UrlRequest urlRequest, String mimeType, byte[] bytes) { + UrlRequestJob generateBasicUrlRequestJob(Params params, String mimeType, byte[] bytes) { UrlRequestJob.Options options = UrlRequestJob.Options - .newBuilder(urlRequest.id(), HttpStatus.OK) + .newBuilder(HttpStatus.OK) .addHttpHeader(HttpHeader.of("Content-Type", mimeType)) .build(); - UrlRequestJob urlRequestJob = network.newUrlRequestJob(options); + UrlRequestJob urlRequestJob = params.newUrlRequestJob(options); urlRequestJob.write(bytes); urlRequestJob.complete(); return urlRequestJob; @@ -145,4 +141,8 @@ public class NxInterceptRequestCallback implements InterceptRequestCallback { return "text/html"; } } + + public void setMap(Map map) { + this.map = map; + } } \ No newline at end of file From b95ee92287317e5053ee427c9ebd4803e59ce43b Mon Sep 17 00:00:00 2001 From: xiqiu Date: Mon, 16 Aug 2021 18:37:25 +0800 Subject: [PATCH 22/32] =?UTF-8?q?REPORT-53615=20=20=20=E9=A9=B1=E5=8A=A8?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=9A=84=E8=AE=BE=E8=AE=A1=E5=99=A8=E9=80=82?= =?UTF-8?q?=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/connect/JDBCDefPane.java | 441 ++++++++++++------ 1 file changed, 286 insertions(+), 155 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java index 8a9a9779c1..13211c3b45 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java @@ -1,6 +1,8 @@ package com.fr.design.data.datapane.connect; 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.design.border.UITitledBorder; 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.EncodeConstants; import com.fr.stable.StringUtils; +import com.fr.third.guava.collect.HashBiMap; +import com.fr.workspace.WorkContext; import javax.swing.BorderFactory; import javax.swing.JFileChooser; @@ -45,6 +49,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -101,8 +106,123 @@ public class JDBCDefPane extends JPanel { private JDBCDatabaseConnection jdbcDatabase; private boolean needRefresh = true; + 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> jdbc = jdbcMap.entrySet().iterator(); + while (jdbc.hasNext()) { + Entry 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(); + } + } + } + }; + private UIComboBox driverManageBox; + private ActionLabel driverManageLabel; + private UIComboBox driverLoaderBox; + 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); + } + }; + private HashBiMap nameAndRepresent; public JDBCDefPane() { + initMap(); this.setBorder(UITitledBorder.createBorderWithTitle("JDBC" + ":")); this.setLayout(FRGUIPaneFactory.createLabelFlowLayout()); JPanel innerthis = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); @@ -115,7 +235,14 @@ public class JDBCDefPane extends JPanel { } dbtypeComboBox.addActionListener(dbtypeActionListener); 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.setEditable(true); driverComboBox.addActionListener(driverListener); @@ -155,17 +282,39 @@ public class JDBCDefPane extends JPanel { _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.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent evt) { String url = CloudCenter.getInstance().acquireUrlByKind("odbc.help"); 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()); - 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); JPanel hostPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); @@ -225,48 +374,21 @@ public class JDBCDefPane extends JPanel { innerthis.add(centerPanel); } - public void populate(JDBCDatabaseConnection jdbcDatabase) { - needRefresh = false; - if (jdbcDatabase == null) { - jdbcDatabase = new JDBCDatabaseConnection(); - } - this.jdbcDatabase = jdbcDatabase; - if (ComparatorUtils.equals(jdbcDatabase.getDriver(), "sun.jdbc.odbc.JdbcOdbcDriver") - && jdbcDatabase.getURL().startsWith("jdbc:odbc:Driver={Microsoft")) { - this.dbtypeComboBox.setSelectedItem("Access"); - } else { - Iterator> jdbc = jdbcMap.entrySet().iterator(); - boolean out = false; - while (jdbc.hasNext()) { - Entry entry = jdbc.next(); - DriverURLName[] dus = entry.getValue(); - for (int i = 0, len = dus.length; i < len; i++) { - if (ComparatorUtils.equals(dus[i].getDriver(), jdbcDatabase.getDriver())) { - this.dbtypeComboBox.setSelectedItem(entry.getKey()); - out = true; - break; - } - } - if (out) { - break; - } - } - if (!out) { - this.dbtypeComboBox.setSelectedItem(OTHER_DB); - } + private void initMap() { + Map driverLoaders = DriverLoaderConfig.getInstance().getDriverLoaders(); + nameAndRepresent = getDriverLoaderAndRepresent(driverLoaders); + } + + private HashBiMap getDriverLoaderAndRepresent(Map driverLoaders) { + HashBiMap driverHashBiMap = HashBiMap.create(); + if (WorkContext.getCurrent().isWarDeploy()) { + return driverHashBiMap; } - this.jdbcDatabase.setIdentity(jdbcDatabase.getIdentity()); - this.driverComboBox.setSelectedItem(jdbcDatabase.getDriver()); - this.urlTextField.setText(jdbcDatabase.getURL()); - this.userNameTextField.setText(jdbcDatabase.getUser()); - this.passwordTextField.setText(jdbcDatabase.getPassword()); - this.originalCharSet = jdbcDatabase.getOriginalCharsetName(); - if (StringUtils.isBlank(originalCharSet)) { - this.charSetComboBox.setSelectedItem(Toolkit.i18nText("Fine-Design_Encode_Auto")); - } else { - this.charSetComboBox.setSelectedItem(jdbcDatabase.getOriginalCharsetName()); + // name 是唯一的,name+driver自然也是唯一的 + for (DriverLoader driverLoader : driverLoaders.values()) { + driverHashBiMap.put(driverLoader.getName(), getRepresent(driverLoader.getDriverClass(), driverLoader.getName())); } - needRefresh = false; + return driverHashBiMap; } protected JDBCDatabaseConnection getJDBCDatabase() { @@ -288,108 +410,29 @@ public class JDBCDefPane extends JPanel { } } - public JDBCDatabaseConnection update() { - if (jdbcDatabase == null) { - jdbcDatabase = new JDBCDatabaseConnection(); - } - Object driveItem = this.driverComboBox.getSelectedItem(); - jdbcDatabase.setDriver(driveItem == null ? null : driveItem.toString().trim()); - jdbcDatabase.setURL(this.urlTextField.getText().trim()); - jdbcDatabase.setUser(this.userNameTextField.getText().trim()); - jdbcDatabase.setPassword(new String(this.passwordTextField.getPassword()).trim()); - jdbcDatabase.setOriginalCharsetName(this.originalCharSet); - if (this.charSetComboBox.getSelectedIndex() == 0) { - jdbcDatabase.setNewCharsetName(null); - jdbcDatabase.setOriginalCharsetName(null); - } else { - jdbcDatabase.setNewCharsetName(EncodeConstants.ENCODING_GBK); - jdbcDatabase.setOriginalCharsetName(((String) this.charSetComboBox.getSelectedItem())); - } - return jdbcDatabase; + private String getRepresent(String driverClass, String driverName) { + return driverClass + "(" + driverName + ")"; } - 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; - } + private boolean isSelfDefine() { + return ComparatorUtils.equals(Toolkit.i18nText("Fine-Design_Driver_Manage_Self_Define"), driverManageBox.getSelectedItem()); + } - 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); + private void refreshDriverLoader() { + Set representSet = nameAndRepresent.values(); + driverLoaderBox.clearBoxItems(); + for (String represent : representSet) { + driverLoaderBox.addItem(represent); } - }; - - 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> jdbc = jdbcMap.entrySet().iterator(); - while (jdbc.hasNext()) { - Entry 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() { - 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; - } - } + 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")); } - }; + } InputMethodListener portInputMethodListener = new InputMethodListener() { @Override @@ -426,6 +469,109 @@ public class JDBCDefPane extends JPanel { } }; + public void populate(JDBCDatabaseConnection jdbcDatabase) { + // 单例对象,重新打开的时候并不会新建,但是由于driverloaderbox里面需要是动态内容,因此需要进行刷新动作 + initMap(); + refreshDriverLoader(); + needRefresh = false; + if (jdbcDatabase == null) { + jdbcDatabase = new JDBCDatabaseConnection(); + } + this.jdbcDatabase = jdbcDatabase; + if (ComparatorUtils.equals(jdbcDatabase.getDriver(), "sun.jdbc.odbc.JdbcOdbcDriver") + && jdbcDatabase.getURL().startsWith("jdbc:odbc:Driver={Microsoft")) { + this.dbtypeComboBox.setSelectedItem("Access"); + } else { + Iterator> jdbc = jdbcMap.entrySet().iterator(); + boolean out = false; + while (jdbc.hasNext()) { + Entry entry = jdbc.next(); + DriverURLName[] dus = entry.getValue(); + for (int i = 0, len = dus.length; i < len; i++) { + if (ComparatorUtils.equals(dus[i].getDriver(), jdbcDatabase.getDriver())) { + this.dbtypeComboBox.setSelectedItem(entry.getKey()); + out = true; + break; + } + } + if (out) { + break; + } + } + if (!out) { + this.dbtypeComboBox.setSelectedItem(OTHER_DB); + } + } + this.jdbcDatabase.setIdentity(jdbcDatabase.getIdentity()); + // 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.userNameTextField.setText(jdbcDatabase.getUser()); + this.passwordTextField.setText(jdbcDatabase.getPassword()); + this.originalCharSet = jdbcDatabase.getOriginalCharsetName(); + if (StringUtils.isBlank(originalCharSet)) { + this.charSetComboBox.setSelectedItem(Toolkit.i18nText("Fine-Design_Encode_Auto")); + } else { + this.charSetComboBox.setSelectedItem(jdbcDatabase.getOriginalCharsetName()); + } + needRefresh = false; + } + + public JDBCDatabaseConnection update() { + if (jdbcDatabase == null) { + jdbcDatabase = new JDBCDatabaseConnection(); + } + jdbcDatabase.setURL(this.urlTextField.getText().trim()); + jdbcDatabase.setUser(this.userNameTextField.getText().trim()); + jdbcDatabase.setPassword(new String(this.passwordTextField.getPassword()).trim()); + jdbcDatabase.setOriginalCharsetName(this.originalCharSet); + if (this.charSetComboBox.getSelectedIndex() == 0) { + jdbcDatabase.setNewCharsetName(null); + jdbcDatabase.setOriginalCharsetName(null); + } else { + jdbcDatabase.setNewCharsetName(EncodeConstants.ENCODING_GBK); + jdbcDatabase.setOriginalCharsetName(((String) this.charSetComboBox.getSelectedItem())); + } + String driverLoader = (String) this.driverLoaderBox.getSelectedItem(); + if (driverLoader == null) { + driverLoader = StringUtils.EMPTY; + } + if (isSelfDefine()) { + String[] split = driverLoader.split("\\("); + if (split.length > 1) { + String name = split[1]; + if (name.length() > 0) { + jdbcDatabase.setDriverSource(name.substring(0, name.length() - 1)); + } else { + jdbcDatabase.setDriverSource(StringUtils.EMPTY); + } + } 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; + } + private void updatePara() { String dbType = dbtypeComboBox.getSelectedItem().toString(); if (ComparatorUtils.equals(dbType, OTHER_DB) || ComparatorUtils.equals(dbType, "Access") || ComparatorUtils.equals(dbType, "SQLite")) { @@ -489,21 +635,6 @@ public class JDBCDefPane extends JPanel { 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) { return PORT.matcher(port).find(); From 0fd8b045d62155b8dca8071cda1564d98c3dea5c Mon Sep 17 00:00:00 2001 From: xiqiu Date: Mon, 16 Aug 2021 19:54:14 +0800 Subject: [PATCH 23/32] =?UTF-8?q?REPORT-53615=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datapane/connect/JDBCDefPane.java | 81 +++++++++---------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java index 13211c3b45..1b2953b4c5 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java @@ -102,10 +102,13 @@ public class JDBCDefPane extends JPanel { private Component[][] partComponents; // 请不要改动dbtype,只应该最后添加 private final String[] dbtype = {"Oracle", "DB2", "SQL Server", "MySQL", "Sybase", "Access", "Derby", "Postgre", "SQLite", "Inceptor", OTHER_DB}; - - private JDBCDatabaseConnection jdbcDatabase; private boolean needRefresh = true; + private UIComboBox driverManageBox; + private ActionLabel driverManageLabel; + private UIComboBox driverLoaderBox; + private HashBiMap nameAndRepresent; + ActionListener driverListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -175,9 +178,6 @@ public class JDBCDefPane extends JPanel { } } }; - private UIComboBox driverManageBox; - private ActionLabel driverManageLabel; - private UIComboBox driverLoaderBox; ActionListener driverManageListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -219,7 +219,41 @@ public class JDBCDefPane extends JPanel { DatabaseConnectionPane.JDBC.getAdvancedAttrPane().populate(jdbcDatabase); } }; - private HashBiMap nameAndRepresent; + + 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() { initMap(); @@ -434,41 +468,6 @@ public class JDBCDefPane extends JPanel { } } - 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 void populate(JDBCDatabaseConnection jdbcDatabase) { // 单例对象,重新打开的时候并不会新建,但是由于driverloaderbox里面需要是动态内容,因此需要进行刷新动作 initMap(); From 1d76a4bbcd64046b86afc76e2b07c445c5a8aad9 Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 17 Aug 2021 10:02:14 +0800 Subject: [PATCH 24/32] =?UTF-8?q?REPORT-57057=20=E8=BF=9C=E7=A8=8B?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E6=8A=A5=E9=94=99=E8=A7=84=E8=8C=83-?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E8=BF=9C=E7=A8=8B=E7=8A=B6=E6=80=81=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=E8=AE=BE=E8=AE=A1=E5=99=A8=E6=97=B6=EF=BC=8C=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E5=BC=B9=E7=AA=97=E8=A2=AB=20=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=9B=AE=E5=BD=95=E7=9A=84=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/EnvChangeEntrance.java | 5 ++++- .../java/com/fr/start/module/DesignerWorkspaceProvider.java | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 1b38bb1505..98c079ee2b 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -407,7 +407,7 @@ public class EnvChangeEntrance { /** * 处理异常 */ - public void dealEvnExceptionWhenStartDesigner() { + public void dealEvnExceptionWhenStartDesigner(Throwable e, DesignerWorkspaceInfo workspaceInfo) { ProcessEventPipe eventPipe = FineProcessContext.getParentPipe(); if (eventPipe != null) { eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue())); @@ -435,6 +435,9 @@ public class EnvChangeEntrance { DesignerExiter.getInstance().execute(); } }); + if (e != null) { + RemoteDesignExceptionHandler.getInstance().handleInStart(e, workspaceInfo); + } envListDialog.setVisible(true); } diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java index dbebb5f992..d5b6cdb632 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java @@ -59,7 +59,7 @@ public class DesignerWorkspaceProvider extends Activator { Workspace workspace = DesignerWorkspaceGenerator.generate(workspaceInfo); boolean checkValid = workspace != null && workspaceInfo.checkValid(); if (!checkValid) { - EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner(); + EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner(null, workspaceInfo); } else { WorkContext.switchTo(workspace); //在设计器完全启动完成后,对初始环境进行一次服务检测,对主要功能无影响,异常仅做日志提示即可 @@ -76,8 +76,7 @@ public class DesignerWorkspaceProvider extends Activator { }); } } catch (Throwable e) { - RemoteDesignExceptionHandler.getInstance().handleInStart(e, workspaceInfo); - EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner(); + EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner(e, workspaceInfo); } } pluginErrorRemind(); From dc80e662e74f9bbcb97da769919b862cd1fda640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Tue, 17 Aug 2021 15:59:02 +0800 Subject: [PATCH 25/32] =?UTF-8?q?REPORT-57233=20=E3=80=90FRM=E5=B8=83?= =?UTF-8?q?=E5=B1=80=E6=8E=A8=E8=8D=90=E3=80=91=E7=BB=84=E4=BB=B6=E5=A4=8D?= =?UTF-8?q?=E7=94=A8-=E5=AF=B9=E9=BD=90=E3=80=81=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E9=97=B4=E8=B7=9D=E3=80=81=E6=89=8B=E5=8A=A8=E9=97=B4=E8=B7=9D?= =?UTF-8?q?=EF=BC=8C=E8=B0=83=E6=95=B4=E5=90=8E=E6=B2=A1=E6=9C=89=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E6=A8=A1=E6=9D=BF=E7=9A=84=E4=BF=9D=E5=AD=98=E5=92=8C?= =?UTF-8?q?=E8=BF=98=E5=8E=9F=E6=8C=89=E9=92=AE=EF=BC=8C=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E5=86=8D=E6=89=93=E5=BC=80=E6=AD=A4=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E8=BF=98=E6=98=AF=E8=B0=83=E6=95=B4=E5=89=8D=E7=9A=84?= =?UTF-8?q?=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/MultiSelectionArrangement.java | 44 ++++++++++++++----- .../design/mainframe/WidgetPropertyPane.java | 14 ------ ...stractMultiSelectionArrangementButton.java | 27 ++++++++---- .../buttons/BottomAlignButton.java | 1 + .../buttons/HorizontalCenterButton.java | 1 + .../buttons/HorizontalDistributionButton.java | 1 + .../arrangement/buttons/LeftAlignButton.java | 1 + .../MultiSelectionArrangementButton.java | 4 -- .../arrangement/buttons/RightAlignButton.java | 1 + .../arrangement/buttons/TopAlignButton.java | 1 + .../buttons/VerticalCenterButton.java | 1 + .../buttons/VerticalDistributionButton.java | 1 + .../widget/ui/FormMultiWidgetCardPane.java | 41 ++++++++++++----- 13 files changed, 88 insertions(+), 50 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java b/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java index 1b0962febd..b9eb18f753 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java @@ -1,6 +1,12 @@ package com.fr.design.mainframe; 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.util.Arrays; @@ -10,6 +16,7 @@ import java.util.List; public class MultiSelectionArrangement { private FormDesigner designer; + private XLayoutContainer parent; // 当前选中的那些组件所在父容器 private List selectedCreators; private Rectangle rec; @@ -22,42 +29,42 @@ public class MultiSelectionArrangement { for (XCreator creator : selectedCreators) { creator.setLocation(rec.x, creator.getY()); } - repaint(); + update(); } public void rightAlign() { for (XCreator creator : selectedCreators) { creator.setLocation(rec.x + rec.width - creator.getWidth(), creator.getY()); } - repaint(); + update(); } public void topAlign() { for (XCreator creator : selectedCreators) { creator.setLocation(creator.getX(), rec.y); } - repaint(); + update(); } public void bottomAlign() { for (XCreator creator : selectedCreators) { creator.setLocation(creator.getX(), rec.y + rec.height - creator.getHeight()); } - repaint(); + update(); } public void horizontalCenterAlign() { for (XCreator creator : selectedCreators) { creator.setLocation(rec.x + rec.width / 2 - creator.getWidth() / 2, creator.getY()); } - repaint(); + update(); } public void verticalCenterAlign() { for (XCreator creator : selectedCreators) { creator.setLocation(creator.getX(), rec.y + rec.height / 2 - creator.getHeight() / 2); } - repaint(); + update(); } // 水平分布,自动,间距由selectedCreators和border共同计算而来 @@ -79,7 +86,7 @@ public class MultiSelectionArrangement { XCreator preCreator = selectedCreators.get(i - 1); creator.setLocation(preCreator.getX() + preCreator.getWidth() + gap, creator.getY()); } - repaint(); + update(); } private void reSizeRecByHorizontal(int gap) { @@ -151,7 +158,7 @@ public class MultiSelectionArrangement { XCreator preCreator = selectedCreators.get(i - 1); creator.setLocation(creator.getX(), preCreator.getY() + preCreator.getHeight() + gap); } - repaint(); + update(); } private void reSizeRecByVertical(int gap) { @@ -209,10 +216,25 @@ public class MultiSelectionArrangement { FormSelection selection = designer.getSelectionModel().getSelection(); this.selectedCreators = Arrays.asList(selection.getSelectedCreators()); 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() { - designer.repaint(); - update(); + private XLayoutContainer getParent(XCreator source) { + if(source.acceptType(XWCardTagLayout.class)){ + return (XLayoutContainer)source.getParent(); + } + XLayoutContainer container = XCreatorUtils.getParentXLayoutContainer(source); + if (source.acceptType(XWFitLayout.class) || source.acceptType(XWParameterLayout.class)) { + container = null; + } + return container; } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java b/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java index b4fc1122bc..e61e8a600e 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java @@ -412,20 +412,6 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper if (!isValid) { 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) { for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) { extraPane.populate(designer); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/AbstractMultiSelectionArrangementButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/AbstractMultiSelectionArrangementButton.java index ac687d4256..dc268f4c5b 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/AbstractMultiSelectionArrangementButton.java +++ b/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; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ibutton.UIButton; 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 UIObserverListener uiObserverListener; public AbstractMultiSelectionArrangementButton(MultiSelectionArrangement arrangement) { + super(); this.arrangement = arrangement; + this.setNormalPainted(false); + this.setBorderPaintedOnlyWhenPressed(true); + this.setIcon(getIcon()); + this.setToolTipText(getTipText()); + this.addActionListener(getActionListener()); } @Override - public UIButton create() { - UIButton btn = new UIButton(); - btn.setNormalPainted(false); - btn.setBorderPaintedOnlyWhenPressed(true); - btn.setIcon(getIcon()); - btn.setToolTipText(getTipText()); - btn.addActionListener(getActionListener()); - return btn; + public void registerChangeListener(UIObserverListener listener) { + uiObserverListener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/BottomAlignButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/BottomAlignButton.java index 41318ff67b..99bf3a6c3a 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/BottomAlignButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/BottomAlignButton.java @@ -29,6 +29,7 @@ public class BottomAlignButton extends AbstractMultiSelectionArrangementButton { @Override public void actionPerformed(ActionEvent e) { arrangement.bottomAlign(); + uiObserverListener.doChange(); } }; } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalCenterButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalCenterButton.java index 7eface48f4..6dc9c09b4a 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalCenterButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalCenterButton.java @@ -29,6 +29,7 @@ public class HorizontalCenterButton extends AbstractMultiSelectionArrangementBut @Override public void actionPerformed(ActionEvent e) { arrangement.horizontalCenterAlign(); + uiObserverListener.doChange(); } }; } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalDistributionButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalDistributionButton.java index 678ce895bf..0a0e225fc6 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalDistributionButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalDistributionButton.java @@ -29,6 +29,7 @@ public class HorizontalDistributionButton extends AbstractMultiSelectionArrangem @Override public void actionPerformed(ActionEvent e) { arrangement.horizontalAutoDistribution(); + uiObserverListener.doChange(); } }; } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/LeftAlignButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/LeftAlignButton.java index 3f8d685c77..20a25a87cb 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/LeftAlignButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/LeftAlignButton.java @@ -29,6 +29,7 @@ public class LeftAlignButton extends AbstractMultiSelectionArrangementButton { @Override public void actionPerformed(ActionEvent e) { arrangement.leftAlign(); + uiObserverListener.doChange(); } }; } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/MultiSelectionArrangementButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/MultiSelectionArrangementButton.java index 06bc2026be..99b7635708 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/MultiSelectionArrangementButton.java +++ b/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; -import com.fr.design.gui.ibutton.UIButton; - import javax.swing.Icon; import java.awt.event.ActionListener; @@ -11,6 +9,4 @@ public interface MultiSelectionArrangementButton { String getTipText(); ActionListener getActionListener(); - - UIButton create(); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/RightAlignButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/RightAlignButton.java index 02f20fc45e..5fac70bd7a 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/RightAlignButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/RightAlignButton.java @@ -29,6 +29,7 @@ public class RightAlignButton extends AbstractMultiSelectionArrangementButton { @Override public void actionPerformed(ActionEvent e) { arrangement.rightAlign(); + uiObserverListener.doChange(); } }; } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/TopAlignButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/TopAlignButton.java index 7100b3b960..ebb2c4d21a 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/TopAlignButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/TopAlignButton.java @@ -29,6 +29,7 @@ public class TopAlignButton extends AbstractMultiSelectionArrangementButton { @Override public void actionPerformed(ActionEvent e) { arrangement.topAlign(); + uiObserverListener.doChange(); } }; } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalCenterButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalCenterButton.java index 81d86d5583..9898f9002c 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalCenterButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalCenterButton.java @@ -29,6 +29,7 @@ public class VerticalCenterButton extends AbstractMultiSelectionArrangementButto @Override public void actionPerformed(ActionEvent e) { arrangement.verticalCenterAlign(); + uiObserverListener.doChange(); } }; } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalDistributionButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalDistributionButton.java index 538463b6b3..50ec6ac894 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalDistributionButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalDistributionButton.java @@ -29,6 +29,7 @@ public class VerticalDistributionButton extends AbstractMultiSelectionArrangemen @Override public void actionPerformed(ActionEvent e) { arrangement.verticalAutoDistribution(); + uiObserverListener.doChange(); } }; } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java index 699c34b2a4..57076e066f 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java @@ -1,8 +1,10 @@ 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.ilable.UILabel; -import com.fr.design.gui.itextfield.UIPositiveAndNegativeIntNumberField; +import com.fr.design.gui.itextfield.UIIntNumberField; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; 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.general.IOUtils; import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -30,6 +33,7 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; public class FormMultiWidgetCardPane extends FormWidgetCardPane { + private AttributeChangeListener listener; private MultiSelectionArrangement arrangement; public FormMultiWidgetCardPane(FormDesigner designer) { @@ -40,6 +44,12 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane { arrangement = new MultiSelectionArrangement(designer); content.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0)); content.add(createArrangementLayoutPane(), BorderLayout.CENTER); + this.listener = new AttributeChangeListener() { + @Override + public void attributeChange() { + designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_RESIZED); + } + }; } // 整个排列分布面板的layout,可以看成一个三行一列的表格,第一行是分布,第二行是自动间距,第三行是手动间距 @@ -73,12 +83,12 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane { }; Component[][] components = new Component[][] { new Component[] { - new LeftAlignButton(arrangement).create(), - new HorizontalCenterButton(arrangement).create(), - new RightAlignButton(arrangement).create(), - new TopAlignButton(arrangement).create(), - new VerticalCenterButton(arrangement).create(), - new BottomAlignButton(arrangement).create() + new LeftAlignButton(arrangement), + new HorizontalCenterButton(arrangement), + new RightAlignButton(arrangement), + new TopAlignButton(arrangement), + new VerticalCenterButton(arrangement), + new BottomAlignButton(arrangement) } }; JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 18, 0); @@ -92,8 +102,8 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane { TableLayout.PREFERRED, TableLayout.PREFERRED }; - UIButton horizontalAutoSpacingBtn = new HorizontalDistributionButton(arrangement).create(); - UIButton verticalAutoSpacingBtn = new VerticalDistributionButton(arrangement).create(); + UIButton horizontalAutoSpacingBtn = new HorizontalDistributionButton(arrangement); + UIButton verticalAutoSpacingBtn = new VerticalDistributionButton(arrangement); if (designer.getSelectionModel().getSelection().size() < 3) { horizontalAutoSpacingBtn.setEnabled(false); verticalAutoSpacingBtn.setEnabled(false); @@ -147,8 +157,8 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane { return createTitleLayout(Toolkit.i18nText("Fine-Design_Multi_Selection_Manual_Spacing"), centerPane); } - private UIPositiveAndNegativeIntNumberField createIntNumberField(boolean isVertical) { - final UIPositiveAndNegativeIntNumberField intNumberField = new UIPositiveAndNegativeIntNumberField(); + private UIIntNumberField createIntNumberField(boolean isVertical) { + final UIIntNumberField intNumberField = new UIIntNumberField(); intNumberField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { @@ -167,12 +177,13 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane { } private void distributionDoChange(String text, boolean isVertical) { - if (StableUtils.isNumber(text)) { + if (StringUtils.isNotEmpty(text) && StableUtils.isNumber(text)) { if (isVertical) { arrangement.verticalManualDistribution(Math.round(Float.parseFloat(text))); } else { arrangement.horizontalManualDistribution(Math.round(Float.parseFloat(text))); } + attributeChanged(); } } @@ -184,4 +195,10 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane { jPanel.add(centerPane, BorderLayout.CENTER); return jPanel; } + + @Override + public void populate() { + initListener(this); + this.addAttributeChangeListener(listener); + } } From d09a4584793f1dcc35147ebf8a383ebe1355b013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Tue, 17 Aug 2021 16:05:30 +0800 Subject: [PATCH 26/32] =?UTF-8?q?REPORT-57233=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E8=B0=83=E8=AF=95=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/widget/ui/FormMultiWidgetCardPane.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java index 57076e066f..b053ea6337 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java @@ -4,7 +4,7 @@ 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.ilable.UILabel; -import com.fr.design.gui.itextfield.UIIntNumberField; +import com.fr.design.gui.itextfield.UIPositiveAndNegativeIntNumberField; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; @@ -157,8 +157,8 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane { return createTitleLayout(Toolkit.i18nText("Fine-Design_Multi_Selection_Manual_Spacing"), centerPane); } - private UIIntNumberField createIntNumberField(boolean isVertical) { - final UIIntNumberField intNumberField = new UIIntNumberField(); + private UIPositiveAndNegativeIntNumberField createIntNumberField(boolean isVertical) { + final UIPositiveAndNegativeIntNumberField intNumberField = new UIPositiveAndNegativeIntNumberField(); intNumberField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { From 92825af427883c4e7b7e84c67ce37741d25a4f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Tue, 17 Aug 2021 17:21:19 +0800 Subject: [PATCH 27/32] =?UTF-8?q?REPORT-56926=20=E3=80=90FRM=E5=B8=83?= =?UTF-8?q?=E5=B1=80=E6=8E=A8=E8=8D=90=E3=80=91=E7=BB=84=E4=BB=B6=E5=A4=8D?= =?UTF-8?q?=E7=94=A8-=E6=89=8B=E5=8A=A8=E9=97=B4=E8=B7=9D=E7=9B=AE?= =?UTF-8?q?=E5=89=8D=E4=B8=8D=E6=94=AF=E6=8C=81=E8=BE=93=E5=85=A5=E5=B0=8F?= =?UTF-8?q?=E6=95=B0=EF=BC=88=E5=85=81=E8=AE=B8=E8=BE=93=E5=85=A5=E5=B0=8F?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E4=BD=86=E8=87=AA=E5=8A=A8=E5=8F=96=E6=95=B4?= =?UTF-8?q?=E5=A4=84=E7=90=86=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UIPositiveAndNegativeIntNumberField.java | 76 ------------------- .../widget/ui/FormMultiWidgetCardPane.java | 25 +++--- 2 files changed, 14 insertions(+), 87 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveAndNegativeIntNumberField.java diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveAndNegativeIntNumberField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveAndNegativeIntNumberField.java deleted file mode 100644 index 6f903d5cb7..0000000000 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/UIPositiveAndNegativeIntNumberField.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.fr.design.gui.itextfield; - -import javax.swing.text.AttributeSet; -import javax.swing.text.BadLocationException; -import javax.swing.text.PlainDocument; -import java.awt.Toolkit; - -public class UIPositiveAndNegativeIntNumberField extends UINumberField { - private static final long serialVersionUID = 4946379346015964509L; - - public void setFieldDocument() { - setDocument(createNumberDocument()); - } - - public class NumberDocument extends PlainDocument { - private static final long serialVersionUID = 1024213269275179172L; - - public NumberDocument() { - } - - public boolean checkString(int offset, String s, String str) { - String strNew = str.substring(0, offset) + s + str.substring(offset, getLength()); - return isMinusSignOnly(strNew) || (isIntNumber(strNew) && isInputIllegalNumber(strNew) && !isOverMaxOrMinValue(strNew)); - - } - - public void insertString(int offset, String s, AttributeSet a) throws BadLocationException { - String str = getText(0, getLength()); - if (!checkString(offset, s, str)) { - Toolkit.getDefaultToolkit().beep(); - return; - } - - setisContentChanged(true); - super.insertString(offset, s, a); - } - - private boolean isMinusSignOnly(String s) { - return s.contains("-") && s.length() == 1; - } - - /** - * 输入字符是否是不合法数字 - * @param s 输入的字符串 - * @return 是否不合法 - */ - private boolean isInputIllegalNumber(String s) { - try { - Integer.parseInt(s); - } catch (Exception e) { - return false; - } - return true; - } - - private boolean isIntNumber(String s) { - boolean result = true; - for (int i = 0; i < s.length(); i++) { - String ch = s.charAt(i) + ""; - if (!ch.matches("^[0-9\\-]+$")) { - result = false; - } - } - return result; - } - - private boolean isOverMaxOrMinValue(String s) { - int value = Integer.parseInt(s); - return (value < getMinValue() || value > getMaxValue()); - } - } - - public NumberDocument createNumberDocument() { - return new NumberDocument(); - } -} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java index b053ea6337..a49d719d26 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java @@ -4,7 +4,7 @@ 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.ilable.UILabel; -import com.fr.design.gui.itextfield.UIPositiveAndNegativeIntNumberField; +import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; @@ -157,31 +157,34 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane { return createTitleLayout(Toolkit.i18nText("Fine-Design_Multi_Selection_Manual_Spacing"), centerPane); } - private UIPositiveAndNegativeIntNumberField createIntNumberField(boolean isVertical) { - final UIPositiveAndNegativeIntNumberField intNumberField = new UIPositiveAndNegativeIntNumberField(); - intNumberField.addFocusListener(new FocusAdapter() { + private UINumberField createIntNumberField(boolean isVertical) { + final UINumberField numberField = new UINumberField(); + numberField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { - distributionDoChange(intNumberField.getText(), isVertical); + distributionDoChange(numberField, isVertical); } }); - intNumberField.addKeyListener(new KeyAdapter() { + numberField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { - distributionDoChange(intNumberField.getText(), isVertical); + distributionDoChange(numberField, isVertical); } } }); - return intNumberField; + return numberField; } - private void distributionDoChange(String text, boolean isVertical) { + 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) { - arrangement.verticalManualDistribution(Math.round(Float.parseFloat(text))); + arrangement.verticalManualDistribution(gap); } else { - arrangement.horizontalManualDistribution(Math.round(Float.parseFloat(text))); + arrangement.horizontalManualDistribution(gap); } attributeChanged(); } From 2502b232a93886df2b1c96387a4ae48786a54099 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Tue, 17 Aug 2021 18:02:31 +0800 Subject: [PATCH 28/32] =?UTF-8?q?REPORT-56532=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=99=A8=E5=BC=B9=E7=AA=97=20&&=20REPORT-566?= =?UTF-8?q?83=20=E6=96=87=E4=BB=B6=E9=80=89=E6=8B=A9=E5=99=A8=E5=BC=B9?= =?UTF-8?q?=E7=AA=97-=E5=9B=BE=E7=89=87=E5=8E=8B=E7=BC=A9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=85=A5=E5=8F=A3=E8=BF=81=E7=A7=BB=E7=9A=84=E5=88=9D?= =?UTF-8?q?=E6=AC=A1=E6=8F=90=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/file/PreferencePane.java | 2 +- .../ifilechooser/JavaFxNativeFileChooser.java | 87 ++++++++++++++++--- .../background/image/ImageFileChooser.java | 15 ++-- 3 files changed, 86 insertions(+), 18 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index a41f962954..24e359d6f0 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -503,7 +503,7 @@ public class PreferencePane extends BasicPane { new JavaFxNativeFileChooser.Builder(). fileSelectionMode(FileSelectionMode.DIR). build(); - int saveValue = fileChooserProvider.showDialog(null); + int saveValue = fileChooserProvider.showDialog(chooseDirBtn); if (saveValue == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooserProvider.getSelectedFile(); logExportDirectoryField.setText(selectedFile.getAbsolutePath()); diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java index b5fce35db1..038212bfde 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java +++ b/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.upm.UpmUtils; +import com.fr.design.mainframe.DesignerContext; import com.fr.log.FineLoggerFactory; -import com.fr.stable.StringUtils; 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.FileChooser; -import javafx.stage.Window; +import javafx.stage.Modality; +import javafx.stage.Stage; +import javafx.stage.StageStyle; import javax.swing.*; -import javax.swing.filechooser.FileNameExtensionFilter; import java.awt.*; import java.io.File; import java.util.List; @@ -40,9 +46,17 @@ public class JavaFxNativeFileChooser implements FileChooserProvider { @Override public int showDialog(Component parent) { final CountDownLatch latch = new CountDownLatch(1); - PlatformImpl.startup(new Runnable() { + PlatformImpl.startup(() -> { + }); + Platform.setImplicitExit(false); + Platform.runLater(new Runnable() { @Override public void run() { + Component fileChooserParent = parent; + if (fileChooserParent == null) { + fileChooserParent = DesignerContext.getDesignerFrame(); + } + Stage stage = showCoverStage(fileChooserParent); try { if (fileSelectionMode == FileSelectionMode.FILE || fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) { FileChooser fileChooser = new FileChooser(); @@ -50,12 +64,12 @@ public class JavaFxNativeFileChooser implements FileChooserProvider { fileChooser.getExtensionFilters().addAll(filters); fileChooser.setInitialDirectory(currentDirectory); if (fileSelectionMode == FileSelectionMode.FILE) { - File file = fileChooser.showOpenDialog(null); + File file = fileChooser.showOpenDialog(stage); if (file != null) { selectedFiles = new File[]{file}; } } else if (fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) { - List fileList = fileChooser.showOpenMultipleDialog(null); + List fileList = fileChooser.showOpenMultipleDialog(stage); if (fileList != null) { selectedFiles = new File[fileList.size()]; fileList.toArray(selectedFiles); @@ -65,17 +79,70 @@ public class JavaFxNativeFileChooser implements FileChooserProvider { DirectoryChooser directoryChooser = new DirectoryChooser(); directoryChooser.setTitle(title); directoryChooser.setInitialDirectory(currentDirectory); - File folder = directoryChooser.showDialog(null); + File folder = directoryChooser.showDialog(stage); if (folder != null) { selectedFiles = new File[]{folder}; } - System.out.println(folder); } - } catch (Exception e) { FineLoggerFactory.getLogger().error(e, e.getMessage()); } finally { 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; } } }); diff --git a/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java b/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java index 57f0d59d63..9c5b1af4d1 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java +++ b/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java @@ -32,11 +32,7 @@ public class ImageFileChooser { new JavaFxNativeFileChooser.Builder(). fileSelectionMode(FileSelectionMode.FILE). title(Toolkit.i18nText("Fine-Design_Basic_Open")). - filters(new FileChooser.ExtensionFilter[]{ - new FileChooser.ExtensionFilter("jpg", "*.jpg"), - new FileChooser.ExtensionFilter("gif", "*.gif"), - new FileChooser.ExtensionFilter("png", "*.png"), - new FileChooser.ExtensionFilter("bmp", "*.bmp")}). + filter(Toolkit.i18nText("Fine-Design_Basic_Image_Image_Files"), "*.jpg", "*.gif", "*.png", "*.bmp"). build(); } @@ -72,8 +68,13 @@ public class ImageFileChooser { private void showImageCompressMoveTip() { if (DesignerEnvManager.getEnvManager().isShowImageCompressMoveTip()) { - DesignerToastMsgUtil.toastWarning(Toolkit.i18nText("Fine-Design_Image_Compress_Move_Tip")); - DesignerEnvManager.getEnvManager().setShowImageCompressMoveTip(false); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + DesignerToastMsgUtil.toastWarning(Toolkit.i18nText("Fine-Design_Image_Compress_Move_Tip")); + DesignerEnvManager.getEnvManager().setShowImageCompressMoveTip(false); + } + }); } } } From 42f24c5bcf1f09c2421cad431eac7d087bb396b6 Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 18 Aug 2021 10:10:33 +0800 Subject: [PATCH 29/32] =?UTF-8?q?REPORT-55756=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E7=95=8C=E9=9D=A2=E7=A7=BB=E5=8A=A8=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E6=A0=8F=E4=BF=9D=E6=8C=81=E5=81=9C=E7=95=99?= =?UTF-8?q?=E5=8E=9F=E4=BD=8D=E7=BD=AE=EF=BC=8C=E6=B2=A1=E6=9C=89=E9=9A=8F?= =?UTF-8?q?=E7=9D=80=E7=A7=BB=E5=8A=A8=EF=BC=8C=E8=BF=99=E4=B8=AA=E7=9C=8B?= =?UTF-8?q?=E4=B8=8B=E8=A6=81=E4=B8=8D=E8=A6=81=E4=BC=98=E5=8C=96=E4=B8=8B?= =?UTF-8?q?=E3=80=82=E9=BC=A0=E6=A0=87=E5=86=8D=E5=9B=9E=E5=88=B0=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E7=94=BB=E5=B8=83=E5=B0=B1=E5=A5=BD=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/PluginClassRefreshManager.java | 18 ++++++++++++++++-- .../com/fr/design/mainframe/DesignerFrame.java | 8 ++++++++ .../com/fr/design/mainframe/JTemplate.java | 4 ++++ .../java/com/fr/design/mainframe/JForm.java | 7 +++++++ .../com/fr/design/mainframe/JWorkBook.java | 8 ++++++++ 5 files changed, 43 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java b/designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java index 9e1d57dfd9..4e81a7ece4 100644 --- a/designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java +++ b/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.fun.HyperlinkProvider; 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.PluginEventListener; import com.fr.plugin.observer.PluginEventType; @@ -28,7 +30,7 @@ public class PluginClassRefreshManager { @Override public void on(PluginEvent event) { // 重载模版之前 触发下hide - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange(); + fireTabChange(); // 兼容之前版本特性 for (String tag : context) { if (event.getContext().contain(tag)) { @@ -53,12 +55,24 @@ public class PluginClassRefreshManager { public void on(PluginEvent event) { PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, pluginAfterRunEventListener); if (DesignerLaunchStatus.getStatus() != DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE) { - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange(); + fireTabChange(); 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() { return INSTANCE; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 39cdbb9303..a5784959a8 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -275,6 +275,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta //刷新FixedPopupPane的位置 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.setVisible(false); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 8b76b30f49..79f6a5c1e8 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -221,6 +221,10 @@ public abstract class JTemplate> // do nothing } + public void refreshFormDesigner() { + // do nothing + } + /** * @deprecated move to cloud ops plugin,left only for compatible diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index 8c9b1f2bc8..0bee88e903 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -1135,4 +1135,11 @@ public class JForm extends JTemplate implements BaseJForm { designer.hidePopup(); } } + + @Override + public void refreshFormDesigner() { + FormDesigner designer = (FormDesigner) parameterPane.getParaDesigner(); + if (designer != null) { + designer.repaint(); + } + } } From bccc08590de08ae3b4f386c52b93cafaca6e33e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Wed, 18 Aug 2021 11:09:28 +0800 Subject: [PATCH 30/32] =?UTF-8?q?REPORT-56925=20=E3=80=90FRM=E5=B8=83?= =?UTF-8?q?=E5=B1=80=E6=8E=A8=E8=8D=90=E3=80=91=E7=BB=84=E4=BB=B6=E5=A4=8D?= =?UTF-8?q?=E7=94=A8-=E6=89=8B=E5=8A=A8=E9=97=B4=E8=B7=9D=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=A1=86=E6=B2=A1=E6=9C=89=E6=98=BE=E7=A4=BA=E6=B0=B4?= =?UTF-8?q?=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/widget/ui/FormMultiWidgetCardPane.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java index a49d719d26..30dc8124a1 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java @@ -141,8 +141,8 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane { TableLayout.PREFERRED, TableLayout.FILL }; - UITextField horizontalSpacingNumberField = createIntNumberField(false); - UITextField verticalSpacingNumberField = createIntNumberField(true); + UITextField horizontalSpacingNumberField = createIntNumberField(false, Toolkit.i18nText("Fine-Design_Multi_Selection_Manual_Horizontal_Spacing_Tip")); + UITextField verticalSpacingNumberField = createIntNumberField(true, Toolkit.i18nText("Fine-Design_Multi_Selection_Manual_Vertical_Spacing_Tip")); Component[][] components = new Component[][] { new Component[] { new UILabel(IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_horizontal_spacing.png")), @@ -157,8 +157,9 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane { return createTitleLayout(Toolkit.i18nText("Fine-Design_Multi_Selection_Manual_Spacing"), centerPane); } - private UINumberField createIntNumberField(boolean isVertical) { + private UINumberField createIntNumberField(boolean isVertical, String tipText) { final UINumberField numberField = new UINumberField(); + numberField.setPlaceholder(tipText); numberField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { From ea2a93476e2fc297c30f8d5f000b4b26fd384e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Wed, 18 Aug 2021 13:50:16 +0800 Subject: [PATCH 31/32] =?UTF-8?q?REPORT-57326&EPORT-57324&REPORT-57330&REP?= =?UTF-8?q?ORT-56895=20=E5=B8=83=E5=B1=80=E6=8E=A8=E8=8D=90=E8=8B=A5?= =?UTF-8?q?=E5=B9=B2=E9=97=B4=E8=B7=9D=E7=BA=BF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/FormSpacingLineDrawer.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java index f70df03c30..e2982f0414 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe; import com.fr.design.designer.creator.XCreator; +import com.fr.design.utils.ComponentUtils; import com.fr.stable.Constants; import com.fr.stable.GraphDrawHelper; @@ -23,6 +24,7 @@ public class FormSpacingLineDrawer { private FormDesigner designer; private XCreator hoverCreator = null; private Rectangle selectedRec; + private Rectangle hoveredRec; private boolean isMouseMoveEvent = false; public FormSpacingLineDrawer(FormDesigner designer) { @@ -38,7 +40,6 @@ public class FormSpacingLineDrawer { } public void draw(Graphics g) { - this.selectedRec = designer.getSelectionModel().getSelection().getSelctionBounds(); if (!isDrawSpacingLine()) { return; } @@ -47,6 +48,9 @@ public class FormSpacingLineDrawer { return; } + this.selectedRec = designer.getSelectionModel().getSelection().getRelativeBounds(); + this.hoveredRec = ComponentUtils.getRelativeBounds(hoverCreator); + drawHorizontalSpacingLine(g); drawVerticalSpacingLine(g); } @@ -158,8 +162,8 @@ public class FormSpacingLineDrawer { }; AbstractFormParallelLine[] hoveredCreatorSides = new AbstractFormParallelLine[] { - new FormHorizontalParallelLine(hoverCreator.getY(), hoverCreator.getX(), hoverCreator.getX() + hoverCreator.getWidth()), - new FormHorizontalParallelLine(hoverCreator.getY() + hoverCreator.getHeight(), hoverCreator.getX(), hoverCreator.getX() + hoverCreator.getWidth()) + new FormHorizontalParallelLine(hoveredRec.y, hoveredRec.x, hoveredRec.x + hoveredRec.width), + new FormHorizontalParallelLine(hoveredRec.y + hoveredRec.height, hoveredRec.x, hoveredRec.x + hoveredRec.width) }; return getNearestSide(selectedRecSides, hoveredCreatorSides); } @@ -171,19 +175,20 @@ public class FormSpacingLineDrawer { }; AbstractFormParallelLine[] hoveredCreatorSides = new AbstractFormParallelLine[] { - new FormVerticalParallelLine(hoverCreator.getX(), hoverCreator.getY(), hoverCreator.getY() + hoverCreator.getHeight()), - new FormVerticalParallelLine(hoverCreator.getX() + hoverCreator.getWidth(), hoverCreator.getY(), hoverCreator.getY() + hoverCreator.getHeight()) + new FormVerticalParallelLine(hoveredRec.x, hoveredRec.y, hoveredRec.y + hoveredRec.height), + new FormVerticalParallelLine(hoveredRec.x + hoveredRec.width, hoveredRec.y, hoveredRec.y + hoveredRec.height) }; return getNearestSide(selectedRecSides, hoveredCreatorSides); } 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]); for (int i = 0; i < lines1.length; i++) { for (int j = 0; j < lines2.length; j++) { int distance = lines1[i].getDistanceWithLine(lines2[j]); - if (distance <= minDistance) { + if (distance < minDistance) { + minDistance = distance; nearestSides[0] = lines1[i]; nearestSides[1] = lines2[j]; } From 842f4c621e2eeffc39cc297ed5731a079140bd00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Wed, 18 Aug 2021 15:39:27 +0800 Subject: [PATCH 32/32] =?UTF-8?q?REPORT-57238=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=97=B4=E8=B7=9D=E8=AE=A1=E7=AE=97=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/MultiSelectionArrangement.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java b/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java index b9eb18f753..54298e186d 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java @@ -69,6 +69,7 @@ public class MultiSelectionArrangement { // 水平分布,自动,间距由selectedCreators和border共同计算而来 public void horizontalAutoDistribution() { + sortHorizontal(); int gap = calculateHorizontalGap(); horizontalDistribution(gap); } @@ -80,7 +81,6 @@ public class MultiSelectionArrangement { } private void horizontalDistribution(int gap) { - sortHorizontal(); for (int i = 1; i < selectedCreators.size() - 1; i++) { XCreator creator = selectedCreators.get(i); XCreator preCreator = selectedCreators.get(i - 1); @@ -90,7 +90,6 @@ public class MultiSelectionArrangement { } private void reSizeRecByHorizontal(int gap) { - sortHorizontal(); int width = 0; for (XCreator creator : selectedCreators) { width += creator.getWidth(); @@ -138,10 +137,14 @@ public class MultiSelectionArrangement { for (XCreator creator : selectedCreators) { 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() { + sortVertical(); int gap = calculateVerticalGap(); verticalDistribution(gap); } @@ -152,7 +155,6 @@ public class MultiSelectionArrangement { } private void verticalDistribution(int gap) { - sortVertical(); for (int i = 1; i < selectedCreators.size() - 1; i++) { XCreator creator = selectedCreators.get(i); XCreator preCreator = selectedCreators.get(i - 1); @@ -162,7 +164,6 @@ public class MultiSelectionArrangement { } private void reSizeRecByVertical(int gap) { - sortVertical(); int height = 0; for (XCreator creator : selectedCreators) { height += creator.getHeight(); @@ -209,7 +210,10 @@ public class MultiSelectionArrangement { for (XCreator creator : selectedCreators) { 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() {