diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 823a551ffe..cec7b921da 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -20,6 +20,7 @@ import com.fr.design.locale.impl.ProductImproveMark; import com.fr.design.login.DesignerLoginType; import com.fr.design.login.config.DesignerLoginConfigManager; import com.fr.design.mainframe.ComponentReuseNotifyUtil; +import com.fr.design.mainframe.simple.SimpleDesignerConfig; import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.notification.SnapChatConfig; @@ -226,6 +227,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private boolean propertiesUsable; + private SimpleDesignerConfig fvsDesignerConfig = SimpleDesignerConfig.getInstance("FvsDesignerConfig"); + /** * DesignerEnvManager. */ @@ -1012,6 +1015,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.designerStartupConfig.setEnabled(enabled); } + public SimpleDesignerConfig getFvsDesignerConfig() { + return fvsDesignerConfig; + } + /** * 返回环境名称迭代器 */ @@ -1863,6 +1870,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { readSnapChatConfig(reader); } else if (name.equals(DesignerLoginConfigManager.XML_TAG)) { readDesignerLoginAttr(reader); + } else if (name.equals(fvsDesignerConfig.getName())) { + readFvsDesignerConfig(reader); } else { readLayout(reader, name); } @@ -2113,6 +2122,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { writeSnapChatConfig(writer); writeComponentReuseNotificationInfo(writer); writeDesignerLoginAttr(writer); + writeFvsDesignerConfig(writer); writer.end(); } @@ -2419,6 +2429,14 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.designerLoginConfigManager.writeXML(writer); } + private void readFvsDesignerConfig(XMLableReader reader) { + reader.readXMLObject(fvsDesignerConfig); + } + + private void writeFvsDesignerConfig(XMLPrintWriter writer) { + this.fvsDesignerConfig.writeXML(writer); + } + enum XmlHandler { Self; diff --git a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java index 468982d96f..a756a544b1 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java +++ b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java @@ -188,7 +188,7 @@ public abstract class DesignTableDataManager { public static void addDsChangeListener(ChangeListener l) { JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); String key = StringUtils.EMPTY; - if (template != null) { + if (JTemplate.isValid(template)) { key = template.getPath(); } List dsListeners = dsListenersMap.get(key); diff --git a/designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java b/designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java index f7492aefcc..331e980834 100644 --- a/designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java +++ b/designer-base/src/main/java/com/fr/design/data/MapCompareUtils.java @@ -16,6 +16,8 @@ public final class MapCompareUtils { /** * 对比两个map 查找出相比orig,other中有哪些是新增的、删除的或者被修改的,并分别进行处理 * + * 对比时默认用equals方法来判断是否为 EntryEventKind#UPDATED + * * @param orig 原始map * @param other 参考的新map * @param eventHandler 有区别时的事件处理器 @@ -24,12 +26,29 @@ public final class MapCompareUtils { */ public static void contrastMapEntries(@NotNull Map orig, @NotNull Map other, @NotNull EventHandler eventHandler) { + contrastMapEntries(orig, other, eventHandler, UpdateRule.DEFAULT); + } + + /** + * 对比两个map 查找出相比orig,other中有哪些是新增的、删除的或者被修改的,并分别进行处理 + * + * 对比时用自定义的规则来判断是否为 EntryEventKind#UPDATED + * + * @param orig 原始map + * @param other 参考的新map + * @param eventHandler 有区别时的事件处理器 + * @param updateRule 自定义的Update事件判定规则 + * @param + * @param + */ + public static void contrastMapEntries(@NotNull Map orig, @NotNull Map other, @NotNull EventHandler eventHandler, @NotNull UpdateRule updateRule) { + Map copiedOrig = new LinkedHashMap<>(orig); other.forEach((k, v) -> { V existedV = copiedOrig.remove(k); if (existedV != null) { - if (!v.equals(existedV)) { + if (updateRule.needUpdate(existedV, v)) { eventHandler.on(EntryEventKind.UPDATED, k, v); } } else { @@ -41,10 +60,31 @@ public final class MapCompareUtils { } + /** + * 事件处理器,对应比较后的三种结果的事件处理 + * @param + * @param + */ public interface EventHandler { void on(EntryEventKind entryEventKind, K k, V v); } + /** + * 数据被修改(EntryEventKind.UPDATED) 的判定规则 + * @param + * @param + */ + public interface UpdateRule { + + EntryEventKind eventKind = EntryEventKind.UPDATED; + + UpdateRule DEFAULT = new UpdateRule() {}; + + default boolean needUpdate(V origin, V v) { + return !v.equals(origin); + } + } + public enum EntryEventKind { ADDED, REMOVED, diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java index e750fa3488..f9ae5948f5 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java @@ -192,6 +192,32 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh default: break; } + }, new MapCompareUtils.UpdateRule() { + @Override + public boolean needUpdate(Connection origin, Connection connection) { + return needUpdate0(origin, connection); + } + + /** + * 是否需要更新处理 + * 1. Connection本身equals为false,代表字段修改 + * 2. 非内置的Connection,即插件提供的Connection + * todo 原本一个equals方法就可以搞定,但是插件里面没有实现equals,结果导致不能正确判断,只能主代码里做兼容,很恶心,先记个todo,以后看有没有办法改掉 + * @param origin + * @param connection + * @return + */ + private boolean needUpdate0(Connection origin, Connection connection) { + return !connection.equals(origin) || !isEmbedConnection(connection); + } + + /** + * 是否是主工程里内置的Connection + * @return + */ + private boolean isEmbedConnection(Connection connection) { + return connection instanceof JDBCDatabaseConnection || connection instanceof JNDIDatabaseConnection; + } }); this.validateConnections(addedOrUpdatedConnections); diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java index 92fdd4878a..ea591f3bf4 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java @@ -3,6 +3,7 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginOperateUtils; +import com.fr.design.extra.exe.callback.handle.PluginCallBackHelper; import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; @@ -73,7 +74,7 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback { }else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); + PluginCallBackHelper.showErrorMessage(result, pluginInfo); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java index 0b1eb33fb9..09c360b4f1 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java @@ -4,6 +4,7 @@ import com.fr.design.bridge.exec.JSCallback; import com.fr.design.bridge.exec.JSExecutor; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginOperateUtils; +import com.fr.design.extra.exe.callback.handle.PluginCallBackHelper; import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; @@ -63,7 +64,7 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { } else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); + PluginCallBackHelper.showErrorMessage(result, pluginInfo); } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java index 21c7871f52..31bf482ebe 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java @@ -3,6 +3,7 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginOperateUtils; +import com.fr.design.extra.exe.callback.handle.PluginCallBackHelper; import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; @@ -72,7 +73,7 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback { }else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); + PluginCallBackHelper.showErrorMessage(result, pluginInfo); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java index 8dbad6a541..3469ed1a59 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java @@ -3,6 +3,7 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginOperateUtils; +import com.fr.design.extra.exe.callback.handle.PluginCallBackHelper; import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; @@ -38,7 +39,7 @@ public class UpdateOnlineCallback extends AbstractDealPreTaskCallback { } else { jsCallback.execute("failed"); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Plugin_Update_Failed")); - FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); + PluginCallBackHelper.showErrorMessage(result, pluginInfo); } } } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java new file mode 100644 index 0000000000..fc5f957f63 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginCallBackHelper.java @@ -0,0 +1,70 @@ +package com.fr.design.extra.exe.callback.handle; + +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.dialog.link.MessageWithLink; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.error.PluginErrorCode; +import com.fr.plugin.manage.control.PluginTaskResult; + +/** + * 帮助处理插件操作(安装、更新等)的弹窗 + * @author Yvan + */ +public class PluginCallBackHelper { + + private static final String NEW_LINE_TAG = "
"; + private static final String REFERENCE = Toolkit.i18nText("Fine-Design_Basic_Plugin_File_Validate_Reference"); + private static final String HELP_DOCUMENT_NAME = Toolkit.i18nText("Fine-Design_Basic_Plugin_File_Validate_HELP_DOCUMENT_NAME"); + private static final String CONNECTOR = "-"; + private static final String HELP_DOCUMENT_LINK = Toolkit.i18nText("Fine-Design_Basic_Plugin_File_Validate_HELP_DOCUMENT_LINK"); + + + /** + * 展示插件操作失败后的提示弹窗 + * @param result + * @param pluginInfo + */ + public static void showErrorMessage(PluginTaskResult result, String pluginInfo) { + // 单独处理下插件完整性校验失败的提示 + if (PluginCallBackHelper.needHandleInvalidatePackage(result)) { + MessageWithLink messageWithLink = PluginCallBackHelper.generate4InvalidatePackage(pluginInfo); + PluginTaskResultErrorDialog resultDialog = new PluginTaskResultErrorDialog(null, messageWithLink); + resultDialog.showResult(); + } else { + FineJOptionPane.showMessageDialog(null, pluginInfo, Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), FineJOptionPane.ERROR_MESSAGE); + } + } + + /** + * 判断是否需要处理 插件安装包校验失败 导致的安装失败任务 + * @param result + * @return + */ + private static boolean needHandleInvalidatePackage(PluginTaskResult result) { + return !result.isSuccess() && result.getCode() == PluginErrorCode.InstallPackageValidateFailed; + } + + /** + * 根据插件原始报错信息,构建MessageWithLink + * @param originInfo + * @return + */ + private static MessageWithLink generate4InvalidatePackage(String originInfo) { + + return new MessageWithLink(getSupplementaryMessage(originInfo), HELP_DOCUMENT_NAME, HELP_DOCUMENT_LINK); + } + + /** + * 根据插件原始报错信息,获取增加了补充说明后的信息 + * @param originInfo + * @return + */ + private static String getSupplementaryMessage(String originInfo) { + return new StringBuilder() + .append(originInfo) + .append(NEW_LINE_TAG) + .append(REFERENCE) + .append(CONNECTOR) + .toString(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginTaskResultErrorDialog.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginTaskResultErrorDialog.java new file mode 100644 index 0000000000..da4f432080 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/handle/PluginTaskResultErrorDialog.java @@ -0,0 +1,86 @@ +package com.fr.design.extra.exe.callback.handle; + +import com.fr.base.svg.IconUtils; +import com.fr.design.dialog.link.MessageWithLink; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.VerticalFlowLayout; +import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.BorderFactory; +import javax.swing.JDialog; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * 当前仅处理Error提示,之后有需要再扩展 + * @author Yvan + */ +public class PluginTaskResultErrorDialog extends JDialog { + + private static final Dimension LABEL = new Dimension(60, 90); + + private JPanel contentPane; + + private UILabel errorLabel; + + private UIButton confirmButton; + + private MessageWithLink messageWithLink; + + public PluginTaskResultErrorDialog(Frame parent, MessageWithLink messageWithLink) { + super(parent, true); + this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning")); + this.messageWithLink = messageWithLink; + + initContentPane(); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setResizable(false); + this.add(contentPane, BorderLayout.CENTER); + this.setSize(new Dimension( 380, 160)); + GUICoreUtils.centerWindow(this); + } + + /** + * 初始化内容面板 + */ + private void initContentPane() { + this.contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + // error图标 + errorLabel = new UILabel(IconUtils.readIcon("/com/fr/design/standard/system/error_tips.svg")); + errorLabel.setPreferredSize(LABEL); + errorLabel.setBorder(BorderFactory.createEmptyBorder(10, 20, 40, 20)); + // 提示内容 + JPanel messagePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + messagePane.add(errorLabel, BorderLayout.WEST); + messagePane.add(messageWithLink, BorderLayout.CENTER); + messagePane.setBorder(BorderFactory.createEmptyBorder(20, 10, 0, 10)); + this.contentPane.add(messagePane, BorderLayout.CENTER); + // 确定按钮 + confirmButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Button_OK")); + confirmButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + hideResult(); + } + }); + JPanel confirmPane = new JPanel(new VerticalFlowLayout()); + confirmPane.add(confirmButton); + confirmPane.setBorder(BorderFactory.createEmptyBorder(0, 160, 10, 0)); + this.contentPane.add(confirmPane, BorderLayout.SOUTH); + } + + public void showResult() { + this.setVisible(true); + } + + public void hideResult() { + this.setVisible(false); + } +} diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java index 296c1f2de5..61093401f2 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java @@ -19,6 +19,7 @@ import com.fr.plugin.context.PluginContext; import com.fr.stable.CoreConstants; import com.fr.stable.StringUtils; import com.fr.third.org.apache.commons.io.FilenameUtils; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Collections; @@ -26,7 +27,6 @@ import java.util.HashMap; import java.util.List; import java.util.ListIterator; import java.util.Map; -import java.util.Set; /** * 历史模板缓存 @@ -99,6 +99,7 @@ public class HistoryTemplateListCache implements CallbackEvent { } + @Nullable public JTemplate getCurrentEditingTemplate() { return this.editingTemplate; } @@ -109,8 +110,11 @@ public class HistoryTemplateListCache implements CallbackEvent { */ public void setCurrentEditingTemplate(JTemplate jt) { this.editingTemplate = jt; + + if (!JTemplate.isValid(jt)) { + return; + } //如果当前历史面板中没有 - if (contains(jt) == -1) { addHistory(); } diff --git a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java index 401fae8497..3a2e56d220 100644 --- a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java @@ -152,15 +152,18 @@ public class FRGUIPaneFactory { return new FRGridLayout(nColumn); } + public static LayoutManager createCenterLayout(JComponent centerBody) { + return createCenterLayout(centerBody, 0.3d); + } + /** * 将 centerBody 为中心,创建一个布局 * 注:只有当且仅当有一个组件,且希望组件 上下左右 居中时使用 * @param centerBody 中心组件 * @return 布局方式 */ - public static LayoutManager createCenterLayout(JComponent centerBody) { + public static LayoutManager createCenterLayout(JComponent centerBody, double factor) { - final double yFactor = 0.30; return new LayoutManager() { @Override @@ -186,7 +189,7 @@ public class FRGUIPaneFactory { int bodyWidth = centerBody.getPreferredSize().width; int bodyHeight = centerBody.getPreferredSize().height; int labelX = (width - bodyWidth) / 2; - int labelY = (int) ((height - bodyHeight) * yFactor); + int labelY = (int) ((height - bodyHeight) * factor); centerBody.setBounds(labelX, labelY, bodyWidth, bodyHeight); } 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 da8f28f60d..dfd2a20cd0 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 @@ -696,7 +696,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta username = connection == null ? StringUtils.EMPTY : connection.getUserName(); } defaultTitleSB.append(username).append("@").append(envName).append("[").append(workspace.getDescription()).append("]"); - if (editingTemplate != null) { + if (JTemplate.isValid(editingTemplate)) { String path = editingTemplate.getPath(); if (!editingTemplate.getEditingFILE().exists()) { path = FILEFactory.MEM_PREFIX + path; @@ -815,6 +815,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta basePane.remove(layout.getLayoutComponent(BorderLayout.EAST)); basePane.add(designerOpenEmptyPanel, BorderLayout.CENTER); + resetToolkitByPlus(ToolBarMenuDock.NULLAVOID); + + // 这里挺恶心的,是为了保证对插件的兼容性适配 + // 不然的话,插件就会 npe + // 见 https://work.fineres.com/browse/REPORT-76091 + HistoryTemplateListCache.getInstance().setCurrentEditingTemplate(JNullTemplate.NULL); + layeredPane.repaint(); } @@ -1081,7 +1088,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (jt != null) { + if (JTemplate.isValid(jt)) { DesignerEnvManager.getEnvManager().setLastOpenFile(jt.getEditingFILE().getPath()); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JNullTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JNullTemplate.java new file mode 100644 index 0000000000..d10df810a2 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/JNullTemplate.java @@ -0,0 +1,207 @@ +package com.fr.design.mainframe; + +import com.fr.design.DesignModelAdapter; +import com.fr.design.designer.TargetComponent; +import com.fr.design.gui.frpane.HyperlinkGroupPane; +import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; +import com.fr.design.gui.imenu.UIMenuItem; +import com.fr.design.mainframe.template.info.TemplateProcessInfo; +import com.fr.design.menu.ShortCut; +import com.fr.design.menu.ToolBarDef; + +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JPanel; + +/** + * created by Harrison on 2022/08/09 + **/ +public class JNullTemplate extends JTemplate { + + public static final JTemplate NULL = new JNullTemplate(); + + @Override + public void copy() { + + } + + @Override + public boolean paste() { + return false; + } + + @Override + public boolean cut() { + return false; + } + + @Override + public AuthorityEditPane createAuthorityEditPane() { + return null; + } + + @Override + public JPanel getEastUpPane() { + return null; + } + + @Override + public JPanel getEastDownPane() { + return null; + } + + @Override + public ToolBarDef[] toolbars4Target() { + return new ToolBarDef[0]; + } + + @Override + public JComponent[] toolBarButton4Form() { + return new JComponent[0]; + } + + @Override + public void refreshEastPropertiesPane() { + + } + + @Override + public TargetComponent getCurrentElementCasePane() { + return null; + } + + @Override + public JComponent getCurrentReportComponentPane() { + return null; + } + + @Override + public TemplateProcessInfo getProcessInfo() { + return null; + } + + @Override + public void setJTemplateResolution(int resolution) { + + } + + @Override + public int getJTemplateResolution() { + return 0; + } + + @Override + protected JComponent createCenterPane() { + return null; + } + + @Override + public void removeTemplateSelection() { + + } + + @Override + public void refreshContainer() { + + } + + @Override + public void removeParameterPaneSelection() { + + } + + @Override + public void setScale(int resolution) { + + } + + @Override + public int getScale() { + return 0; + } + + @Override + public int selfAdaptUpdate() { + return 0; + } + + @Override + protected DesignModelAdapter createDesignModel() { + return null; + } + + @Override + public UIMenuItem[] createMenuItem4Preview() { + return new UIMenuItem[0]; + } + + @Override + protected BaseUndoState createUndoState() { + return null; + } + + @Override + protected void applyUndoState(BaseUndoState baseUndoState) { + + } + + @Override + public String suffix() { + return null; + } + + @Override + public ShortCut[] shortcut4TemplateMenu() { + return new ShortCut[0]; + } + + @Override + public ShortCut[] shortCuts4Authority() { + return new ShortCut[0]; + } + + @Override + public boolean isJWorkBook() { + return false; + } + + @Override + public HyperlinkGroupPane getHyperLinkPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { + return null; + } + + @Override + public HyperlinkGroupPane getHyperLinkPaneNoPop(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { + return null; + } + + @Override + public void setAuthorityMode(boolean isUpMode) { + + } + + @Override + public Icon getIcon() { + return null; + } + + @Override + public String route() { + return null; + } + + @Override + public JPanel[] toolbarPanes4Form() { + return new JPanel[0]; + } + + @Override + public JComponent toolBar4Authority() { + return null; + } + + @Override + public int getToolBarHeight() { + return 0; + } +} 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 eaf4b84bfa..29cfcadbb5 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 @@ -1973,5 +1973,14 @@ public abstract class JTemplate> public void setDesignerUIMode() { DesignerUIModeConfig.getInstance().setAbsoluteMeasureUIMode(); } - + + /** + * 判断当前的模板是否是有效的模板 + * + * @param jt 模板 + * @return 是/否 + */ + public static boolean isValid(JTemplate jt) { + return jt != null && jt != JNullTemplate.NULL; + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java b/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java new file mode 100644 index 0000000000..0f14fef756 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java @@ -0,0 +1,83 @@ +package com.fr.design.mainframe.simple; + +import com.fr.json.JSONObject; +import com.fr.stable.StringUtils; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLable; +import com.fr.stable.xml.XMLableReader; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Wei + * 一个简单属性(字符串)存储类,用于自定义简单属性的存储 + * 如:getInstance("FVSDesignerConfig")可在FineReportEnv.xml中定义一个存储FVS相关配置 + */ +public class SimpleDesignerConfig implements XMLable { + + private static final Map configs = new HashMap<>(); + + private SimpleDesignerConfig(String name) { + this.name = name; + } + + public static SimpleDesignerConfig getInstance(String name) { + SimpleDesignerConfig config = configs.get(name); + if (config == null) { + config = new SimpleDesignerConfig(name); + configs.put(name, config); + } + return config; + } + + private String name = ""; + + private JSONObject content = new JSONObject(); + + public void addAttr(String key, String value) { + content.put(key, value); + } + + public JSONObject getContent() { + return content; + } + + public void setContent(JSONObject content) { + this.content = content; + } + + + @Override + public void readXML(XMLableReader reader) { + if (reader.isAttr()) { + String rawContent = reader.getAttrAsString("content", null); + if (StringUtils.isNotBlank(rawContent)) { + this.content = new JSONObject(rawContent); + } + } + } + + @Override + public void writeXML(XMLPrintWriter writer) { + writer.startTAG(name); + if (this.content != null) { + writer.attr("content", this.content.toString()); + } + writer.end(); + } + + @Override + public Object clone() throws CloneNotSupportedException { + SimpleDesignerConfig cloned = (SimpleDesignerConfig) super.clone(); + if (this.content != null) { + cloned.content = new JSONObject(this.content.toString()); + } + cloned.name = this.name; + return cloned; + } + + public String getName() { + return name; + } +} diff --git a/designer-base/src/main/java/com/fr/start/BaseDesigner.java b/designer-base/src/main/java/com/fr/start/BaseDesigner.java index 89c928e2c4..68cb616e17 100644 --- a/designer-base/src/main/java/com/fr/start/BaseDesigner.java +++ b/designer-base/src/main/java/com/fr/start/BaseDesigner.java @@ -38,6 +38,7 @@ import com.fr.workspace.base.WorkspaceStatus; import java.awt.Window; import java.lang.reflect.Method; +import java.util.concurrent.atomic.AtomicBoolean; /** * The main class of Report Designer. @@ -142,7 +143,46 @@ public abstract class BaseDesigner extends ToolBarMenuDock { } private boolean openFile(final DesignerFrame df, boolean isException, FILE file) { - + + AtomicBoolean isExWrapper = new AtomicBoolean(isException); + openTemplate(df, isExWrapper, file); + + if (OperatingSystem.isMacOS()) { + enableFullScreenMode(df); + } + + JTemplate selectedJTemplate = df.getSelectedJTemplate(); + if (selectedJTemplate != null) { + selectedJTemplate.requestGridFocus(); + } + return isExWrapper.get(); + } + + private void openTemplate(DesignerFrame df, AtomicBoolean isException, FILE file) { + + // 如果是起始页启动中 + if (openTemplateOnStartup(df, isException, file)) { + return; + } + + openTemplate0(df, isException, file); + } + + private void openTemplate0(DesignerFrame df, AtomicBoolean isException, FILE file) { + + file = getExtraFILE(isException, file); + + if (file != null && file.exists() && !isException.get()) { + df.openTemplate(file); + } else { + df.addAndActivateJTemplate(); + // 如果没有模板,则需要确认一下 + MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + } + } + + private FILE getExtraFILE(AtomicBoolean isException, FILE file) { + //启动时打开指定文件的接口 DesignerStartOpenFileProcessor processor = ExtraDesignClassManager.getInstance().getSingle(DesignerStartOpenFileProcessor.XML_TAG); // 如果插件没有,且又开启了启动时打开空文件,则使用启动时打开空文件 @@ -154,53 +194,50 @@ public abstract class BaseDesigner extends ToolBarMenuDock { if (f != null) { file = f;//避免null } else { - isException = true;//此时有文件nullpointer异常,执行打开空文件 + isException.set(true);//此时有文件nullpointer异常,执行打开空文件 } } - - openTemplate(df, isException, file); - - if (OperatingSystem.isMacOS()) { - enableFullScreenMode(df); - } - - JTemplate selectedJTemplate = df.getSelectedJTemplate(); - if (selectedJTemplate != null) { - selectedJTemplate.requestGridFocus(); - } - return isException; + return file; } - private void openTemplate(DesignerFrame df, boolean isException, FILE file) { + private boolean openTemplateOnStartup(DesignerFrame df, AtomicBoolean isException, FILE file) { boolean onStartup = DesignerStartupContext.getInstance().isSupport(); if (onStartup) { DesignerStartupContext context = DesignerStartupContext.getInstance(); if (context.isCreateNew()) { - df.addAndActivateJTemplate(); - // 如果没有模板,则需要确认一下 - MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); - return; + return createNewTemplate(df); } - if (context.isOpenLastFile()) { - if (file != null && file.exists() && !isException) { - df.openTemplate(file); - return; - } + if (isOpenTemplate(isException, file, context)) { + return openTemplate(df, file); } if (context.isOpenEmpty()) { - df.showEmptyJTemplate(); - return; + return openEmpty(df); } } + return false; + } - if (file != null && file.exists() && !isException) { - df.openTemplate(file); - } else { - df.addAndActivateJTemplate(); - // 如果没有模板,则需要确认一下 - MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); - } + private boolean isOpenTemplate(AtomicBoolean isException, FILE file, DesignerStartupContext context) { + + return context.isOpenLastFile() && file != null && file.exists() && !isException.get(); + } + + private boolean openEmpty(DesignerFrame df) { + df.showEmptyJTemplate(); + return true; + } + + private boolean openTemplate(DesignerFrame df, FILE file) { + df.openTemplate(file); + return true; + } + + private boolean createNewTemplate(DesignerFrame df) { + df.addAndActivateJTemplate(); + // 如果没有模板,则需要确认一下 + MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + return true; } private void enableFullScreenMode(Window window) { diff --git a/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java b/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java index e89598ae27..41ab4edff7 100644 --- a/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java +++ b/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java @@ -68,7 +68,7 @@ public class DesignerOpenEmptyPanel extends JPanel { this.body.add(createIcon, BorderLayout.NORTH); this.body.add(createButtonPanel, BorderLayout.SOUTH); - setLayout(FRGUIPaneFactory.createCenterLayout(this.body)); + setLayout(FRGUIPaneFactory.createCenterLayout(this.body, 0.4d)); ColorUtils.syncBackground(this, Color.WHITE); diff --git a/designer-base/src/main/java/com/fr/start/common/DesignerStartupExecutor.java b/designer-base/src/main/java/com/fr/start/common/DesignerStartupExecutor.java index 1a033e8cd2..b4358f047b 100644 --- a/designer-base/src/main/java/com/fr/start/common/DesignerStartupExecutor.java +++ b/designer-base/src/main/java/com/fr/start/common/DesignerStartupExecutor.java @@ -1,15 +1,10 @@ package com.fr.start.common; -import java.util.ArrayList; -import java.util.List; - /** * created by Harrison on 2022/07/03 **/ public class DesignerStartupExecutor { - private List warmupTasks = new ArrayList<>(); - public void execute(Runnable runnable) { if (!DesignerStartupContext.getInstance().onWarmup()) { @@ -17,11 +12,6 @@ public class DesignerStartupExecutor { } } - public void reset() { - - warmupTasks.clear(); - } - public static DesignerStartupExecutor getInstance() { return DesignerStartupExecutorHolder.INSTANCE; } diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java index 4b82545a01..c345c8991d 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java @@ -3,10 +3,12 @@ package com.fr.startup.ui; import com.fr.design.DesignerEnvManager; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceType; +import com.fr.stable.StringUtils; import com.fr.third.guava.collect.Lists; import com.fr.workspace.connect.WorkspaceConnectionInfo; import java.util.ArrayList; +import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -33,7 +35,10 @@ public class StartupPageModel { public static StartupPageModel create() { DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); + String curEnvName = envManager.getCurEnvName(); Iterator envNameIterator = envManager.getEnvNameIterator(); + + Comparator startupWorkspaceBeanComparator = convertComparator(curEnvName); List infos = Lists.newArrayList(envNameIterator) .stream() .map((e) -> { @@ -45,6 +50,7 @@ public class StartupPageModel { return new StartupWorkspaceBean(e, workspaceInfo.getPath(), workspaceInfo.getType()); } }) + .sorted(startupWorkspaceBeanComparator) .collect(Collectors.toList()); Map> recentFileMap = new HashMap<>(); for (StartupWorkspaceBean info : infos) { @@ -108,4 +114,17 @@ public class StartupPageModel { public void setOpenEmptyTemplateRunnable(Runnable openEmptyTemplateRunnable) { this.openEmptyTemplateRunnable = openEmptyTemplateRunnable; } + + private static Comparator convertComparator(String curEnvName) { + + return (o1, o2) -> { + if (StringUtils.equals(curEnvName, o1.getName())) { + return -1; + } + if (StringUtils.equals(curEnvName, o2.getName())) { + return 1; + } + return 0; + }; + } } diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java index fefe6e8eca..b73d13d9f9 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java @@ -12,7 +12,10 @@ import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.ColorUtils; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.exit.DesignerExiter; +import com.fr.general.GeneralUtils; import com.fr.log.FineLoggerFactory; +import com.fr.stable.ProductConstants; import com.fr.stable.collections.CollectionUtils; import org.jetbrains.annotations.NotNull; @@ -39,6 +42,8 @@ import java.awt.LayoutManager; import java.awt.RenderingHints; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.util.List; import java.util.Map; @@ -135,6 +140,8 @@ public class StartupPageWindow extends JFrame { // Workspace-detail setSize(SCREEN_SIZE); + setDefaultTitle(); + addDefaultListeners(); repaint(); validate(); @@ -143,6 +150,29 @@ public class StartupPageWindow extends JFrame { GUICoreUtils.centerWindow(this); } + private void addDefaultListeners() { + + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + DesignerExiter.getInstance().execute(); + } + }); + } + + private void setDefaultTitle() { + + StringBuilder sb = new StringBuilder(); + sb.append(ProductConstants.APP_NAME); + sb.append(" "); + sb.append(GeneralUtils.getVersion()); + sb.append(" "); + sb.append(ProductConstants.BRANCH); + sb.append(" "); + sb.append(Toolkit.i18nText("Fine-Design_Startup_Page_Title")); + setTitle(sb.toString()); + } + private void patchUIAction(StartupPageModel pageModel) { Runnable selectAndOpenLastTemplateRunnable = pageModel.getOpenLastTemplateRunnable(); @@ -317,7 +347,7 @@ public class StartupPageWindow extends JFrame { recentOpenGroupPanel.setPreferredSize(new Dimension(GROUP_WIDTH, (int) preferredSize.getHeight())); if (needScroll) { - int scrollHeight = (int) Math.round(itemHeight * RECENT_FILE_LIMIT + ITEM_VERTICAL_GAP * (RECENT_FILE_SCROLL)); + int scrollHeight = (int) Math.round(itemHeight * RECENT_FILE_LIMIT + ITEM_VERTICAL_GAP * (RECENT_FILE_LIMIT)); UIScrollPane scrollPane = new UIScrollPane(recentOpenGroupPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0)); scrollPane.setPreferredSize(new Dimension(GROUP_WIDTH, scrollHeight)); diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java index a22c32b03b..5251509d3c 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java @@ -63,7 +63,10 @@ public class StartupPageWorkspacePanel extends JPanel { private static final Dimension PATH_DIMENSION = new Dimension(100, 20); private static final Dimension SELECT_WORKSPACE_DIMENSION = new Dimension(210, 72); private static final Dimension SELECT_CREATE_DIMENSION = new Dimension(60, 72); - public static final int COLUMN_LIMIT = 3; + + private static final int COLUMN_LIMIT = 3; + private static final int DOUBLE_CLICK_COUNT = 2; + public static final int PARTITION_LIMIT = 2; /* model */ @@ -95,12 +98,14 @@ public class StartupPageWorkspacePanel extends JPanel { this.contentPanel = generateLimitContentPanel(partitions); this.add(contentPanel, BorderLayout.NORTH); - this.tailPanel = generateTailPanel(); + if (partitions.size() > PARTITION_LIMIT) { + this.tailPanel = generateTailPanel(); + this.add(tailPanel, BorderLayout.SOUTH); + } this.createNewTemplateRunnable = pageModel.getCreateNewTemplateRunnable(); this.openEmptyTemplateRunnable = pageModel.getOpenEmptyTemplateRunnable(); - this.add(tailPanel, BorderLayout.SOUTH); this.repaint(); } @@ -221,7 +226,7 @@ public class StartupPageWorkspacePanel extends JPanel { layoutSelectWorkspacePanel(workspaceInfo, workspaceItemDesc); - layoutSelectAndCreatePanel(workspaceItemDesc); + layoutSelectAndCreatePanel(workspaceInfo, workspaceItemDesc); partitionPanel.add(workspaceItemDesc); @@ -293,10 +298,8 @@ public class StartupPageWorkspacePanel extends JPanel { int roundOffset = 15; // 画一个圆角 int fixRoundWidth = getWidth() - rectOffset; - int fixRoundHeight = getHeight() - BORDER_THIN; - g2d.drawRoundRect(strokeOffset, strokeOffset, fixRoundWidth, fixRoundHeight, ARC_DIAMETER, ARC_DIAMETER); - // 画一个直角 - g2d.drawRoundRect(getWidth() - roundOffset, strokeOffset, roundOffset - strokeOffset, getHeight() - BORDER_THIN, 0, 0); + int fixRoundHeight = getHeight() - BORDER_THIN * 2; + g2d.drawRoundRect(BORDER_THIN, BORDER_THIN, fixRoundWidth, fixRoundHeight, ARC_DIAMETER, ARC_DIAMETER); g2d.setColor(backColor); @@ -306,8 +309,13 @@ public class StartupPageWorkspacePanel extends JPanel { // 偏左一点的 fixedX int fixedX = getWidth() - roundOffset - BORDER_THIN; // 圆角和直角相交的区域 - int coverWidth = 10; + int coverWidth = 15; g2d.fillRect(fixedX, BORDER_THIN, coverWidth, coverHeight); + + g2d.setColor(borderColor); + g2d.drawLine(getWidth() / 2, BORDER_THIN, getWidth(), BORDER_THIN); + g2d.drawLine(getWidth() / 2, getHeight() - BORDER_THIN, getWidth(), getHeight() - BORDER_THIN); + g2d.drawLine(getWidth() - strokeOffset, BORDER_THIN, getWidth() - strokeOffset, getHeight() - BORDER_THIN); } } }; @@ -335,6 +343,7 @@ public class StartupPageWorkspacePanel extends JPanel { Font font = nameLabel.getFont(); Font newSizeFont = font.deriveFont(font.getStyle(), NAME_LABEL_SIZE); nameLabel.setFont(newSizeFont); + nameLabel.setPreferredSize(PATH_DIMENSION); Color nameForeground = nameLabel.getForeground(); simpleDescPanel.add(nameLabel,BorderLayout.NORTH); @@ -372,7 +381,7 @@ public class StartupPageWorkspacePanel extends JPanel { public void mousePressed(MouseEvent e) { int clickCount = e.getClickCount(); - if (clickCount == BORDER_THIN) { + if (clickCount == DOUBLE_CLICK_COUNT) { pageModel.setSelectWorkspaceInfo(workspaceInfo); openEmptyTemplateRunnable.run(); return; @@ -420,7 +429,7 @@ public class StartupPageWorkspacePanel extends JPanel { workspaceItemDesc.add(selectWorkspacePanel, BorderLayout.WEST); } - private void layoutSelectAndCreatePanel(JPanel workspaceItemDesc) { + private void layoutSelectAndCreatePanel(StartupWorkspaceBean workspaceInfo, JPanel workspaceItemDesc) { // 选择并新建 AtomicReference borderColorRef = new AtomicReference<>(null); @@ -450,12 +459,19 @@ public class StartupPageWorkspacePanel extends JPanel { if (borderColor != null) { g2d.setColor(borderColor); g2d.setStroke(new BasicStroke(BORDER_THIN)); + + int borderOffset = BORDER_THIN * 2; // 画画的笔触需要调整一下 - g2d.drawRoundRect(strokeOffset, strokeOffset, getWidth() - rectOffset, getHeight() - BORDER_THIN, 0, 0); - g2d.drawRoundRect(getWidth() - fixedRoundOffset, strokeOffset, roundOffset - strokeOffset, getHeight() - BORDER_THIN, ARC_DIAMETER, ARC_DIAMETER); + //g2d.drawRoundRect(strokeOffset, strokeOffset, getWidth() - rectOffset, getHeight() - BORDER_THIN, 0, 0); + g2d.drawRoundRect(BORDER_THIN, BORDER_THIN, getWidth() - borderOffset, getHeight() - borderOffset, ARC_DIAMETER, ARC_DIAMETER); g2d.setColor(backColor); - int fillWidth = 11; - g2d.fillRect(getWidth() - fixedRoundOffset - BORDER_THIN, BORDER_THIN, fillWidth, getHeight() - BORDER_THIN * 2); + int fillWidth = 15; + g2d.fillRect(0, 0, fillWidth, getHeight()); + + g2d.setColor(borderColor); + g2d.drawLine(BORDER_THIN, BORDER_THIN, fillWidth, BORDER_THIN); + g2d.drawLine(BORDER_THIN, getHeight() - BORDER_THIN, fillWidth, getHeight() - BORDER_THIN); + g2d.drawLine(BORDER_THIN, BORDER_THIN, BORDER_THIN, getHeight() - BORDER_THIN); } } @@ -484,6 +500,7 @@ public class StartupPageWorkspacePanel extends JPanel { } @Override public void mousePressed(MouseEvent e) { + pageModel.setSelectWorkspaceInfo(workspaceInfo); createNewTemplateRunnable.run(); } }); diff --git a/designer-base/src/main/resources/com/fr/design/standard/system/error_tips.svg b/designer-base/src/main/resources/com/fr/design/standard/system/error_tips.svg new file mode 100755 index 0000000000..900205215b --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/standard/system/error_tips.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/designer-base/src/test/java/com/fr/startup/ui/StartupPageWindowTest.java b/designer-base/src/test/java/com/fr/startup/ui/StartupPageWindowTest.java index c1d33a66a6..804bb7d3fb 100644 --- a/designer-base/src/test/java/com/fr/startup/ui/StartupPageWindowTest.java +++ b/designer-base/src/test/java/com/fr/startup/ui/StartupPageWindowTest.java @@ -16,13 +16,13 @@ public class StartupPageWindowTest { @Override public void run() { HashMap> recentOpenFileMap = new HashMap<>(); - recentOpenFileMap.put("111", Lists.newArrayList("111.cpt", "222//3333.cpt","333.cpt", "444.cpt", "555.cpt", "666.cpt")); + recentOpenFileMap.put("111", Lists.newArrayList("111.cpt", "222//3333.cpt","333.cpt", "444.cpt", "555.cpt", "666.cpt", "777.cpt")); StartupPageModel model = new StartupPageModel(Stream.of( StartupWorkspaceBean.create("111", "222333344455556663333444555566633334445555666"), StartupWorkspaceBean.create("113", "222"), StartupWorkspaceBean.create("114", "222"), StartupWorkspaceBean.create("115", "222"), StartupWorkspaceBean.create("116", "222"), - StartupWorkspaceBean.create("117", "222"), StartupWorkspaceBean.create("118", "222"), StartupWorkspaceBean.create("119", "222"), - StartupWorkspaceBean.create("121", "222"), StartupWorkspaceBean.create("122", "222"), StartupWorkspaceBean.create("123", "222"), - StartupWorkspaceBean.create("124", "222"), StartupWorkspaceBean.create("125", "222"), StartupWorkspaceBean.create("126", "222") + //StartupWorkspaceBean.create("117", "222"), StartupWorkspaceBean.create("118", "222"), StartupWorkspaceBean.create("119", "222"), + //StartupWorkspaceBean.create("121", "222"), StartupWorkspaceBean.create("122", "222"), StartupWorkspaceBean.create("123", "222"), + StartupWorkspaceBean.create("1245678888888", "222"), StartupWorkspaceBean.create("125", "222"), StartupWorkspaceBean.create("126", "222") ).collect(Collectors.toList()), recentOpenFileMap); StartupPageWindow window = new StartupPageWindow(model); window.setVisible(true); diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java index 6d7ba7699b..be12d6214a 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java @@ -1,6 +1,10 @@ package com.fr.design.chart.series.SeriesCondition; import com.fr.chart.chartattr.Chart; +import com.fr.chart.chartattr.ChartCommonCondition; +import com.fr.chart.chartattr.Plot; +import com.fr.chart.chartglyph.ConditionAttr; +import com.fr.chart.chartglyph.ConditionCollection; import com.fr.data.DSColumnWithSummaryMethod; import com.fr.data.util.function.AbstractDataFunction; import com.fr.design.chart.ChartDataHelper; @@ -9,8 +13,11 @@ import com.fr.design.editor.editor.Editor; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.plugin.chart.attr.plot.VanChartPlot; +import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.plugin.chart.custom.type.CustomPlotType; import java.awt.Dimension; +import java.util.List; import javax.swing.DefaultComboBoxModel; public class ColSelectedWithSummaryMethodEditor extends Editor { @@ -88,4 +95,24 @@ public class ColSelectedWithSummaryMethodEditor extends Editor list = ((VanChartCustomPlot) plot).getCustomPlotList(); + VanChartPlot vanChartPlot = list.get(index); + ConditionCollection conditionCollection = vanChartPlot.getConditionCollection(); + ConditionAttr[] conditionAttrs = conditionCollection.getAllConditionAttrList(); + for (ConditionAttr conditionAttr : conditionAttrs) { + if (conditionAttr.getCondition() instanceof ChartCommonCondition) { + ChartCommonCondition chartCommonCondition = (ChartCommonCondition) conditionAttr.getCondition(); + if (chartCommonCondition.getCompare().getValue() instanceof DSColumnWithSummaryMethod) { + DSColumnWithSummaryMethod dsColumnWithSummaryMethod = (DSColumnWithSummaryMethod) chartCommonCondition.getCompare().getValue(); + columnNameComboBoxModel.setSelectedItem(dsColumnWithSummaryMethod.getFieldName()); + summaryMethodComboBoxModel.setSelectedItem(ChartCommonCondition.FORMAT_MAP.get(String.valueOf(dsColumnWithSummaryMethod.getDataFunction().getFormula()))); + return; + } + } + } + } + } + } diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomPlotConditionAttrTabPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomPlotConditionAttrTabPane.java index c9b45162f7..0f23c5050e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomPlotConditionAttrTabPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomPlotConditionAttrTabPane.java @@ -93,9 +93,8 @@ public class VanChartCustomPlotConditionAttrTabPane extends VanChartCustomPlotTa CustomPlotType plotType = CustomPlotFactory.getCustomType(chartPlot); VanChartRichEditorPane.refreshCustomChartTableFieldNames(chart, plotType); ColSelectedWithSummaryMethodEditor.refreshCustomChartTableFieldNames(chart, plotType); - JPanel selectedPane = paneList.get(index); - if (chart != null && chartPlot != null && selectedPane instanceof VanChartConditionAttrPane) { - ((VanChartConditionAttrPane) selectedPane).populateBean(chartPlot); + if (chart != null) { + ColSelectedWithSummaryMethodEditor.update(index, chart.getPlot()); } } } diff --git a/designer-realize/src/main/java/com/fr/start/DesignerSubListener.java b/designer-realize/src/main/java/com/fr/start/DesignerSubListener.java index 52d364f6cd..50134622da 100644 --- a/designer-realize/src/main/java/com/fr/start/DesignerSubListener.java +++ b/designer-realize/src/main/java/com/fr/start/DesignerSubListener.java @@ -8,6 +8,7 @@ import com.fr.exit.DesignerExiter; import com.fr.process.engine.core.CarryMessageEvent; import com.fr.process.engine.core.FineProcessContext; import com.fr.process.engine.core.FineProcessEngineEvent; +import com.fr.start.common.DesignerStartupContext; /** * @author hades @@ -31,6 +32,10 @@ public class DesignerSubListener { FineProcessContext.getParentPipe().listen(FineProcessEngineEvent.READY, new Listener() { @Override public void on(Event event, Null param) { + // 如果是在起始页的等待过程中 + if (DesignerStartupContext.getInstance().isOnWaiting()) { + return; + } if (DesignerContext.getDesignerFrame() == null || !DesignerContext.getDesignerFrame().isShowing()) { DesignerExiter.getInstance().exitUnexpectedly(() -> { diff --git a/designer-realize/src/main/java/com/fr/start/module/optimized/DesignUpdateActivator.java b/designer-realize/src/main/java/com/fr/start/module/optimized/DesignUpdateActivator.java new file mode 100644 index 0000000000..b6ad5ce2a6 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/start/module/optimized/DesignUpdateActivator.java @@ -0,0 +1,25 @@ +package com.fr.start.module.optimized; + +import com.fr.start.common.DesignerStartupContext; +import com.fr.update.activator.BasicUpdateActivator; +import com.fr.update.base.FineUpdateUnit; + +/** + * created by Harrison on 2022/08/11 + **/ +public class DesignUpdateActivator extends BasicUpdateActivator { + + @Override + public void start() { + + if (DesignerStartupContext.getInstance().onWarmup()) { + try { + prepare4Start(); + FineUpdateUnit.makeNew(); + } catch (Throwable ignore) { + } + } else { + super.start(); + } + } +} diff --git a/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java b/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java index 12e1e1f7c0..98ff33466d 100644 --- a/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java @@ -1,5 +1,6 @@ package com.fr.start.module.optimized; +import com.fr.design.DesignerEnvManager; import com.fr.design.ui.util.UIUtil; import com.fr.log.FineLoggerFactory; import com.fr.module.Activator; @@ -10,6 +11,7 @@ import com.fr.start.util.DesignerStartupPageUtil; import com.fr.start.warmup.DesignerPreWarmTask; import com.fr.startup.ui.StartupPageModel; import com.fr.startup.ui.StartupPageWindow; +import com.fr.startup.ui.StartupWorkspaceBean; import com.fr.third.org.apache.commons.lang3.time.StopWatch; import com.fr.value.NotNullLazyValue; import org.jetbrains.annotations.NotNull; @@ -66,18 +68,21 @@ public class DesignerStartupPageActivator extends Activator { // selectAndOpenLast model.setOpenLastTemplateRunnable(() -> { context.setOpenLastFile(true); + handleModel(model); launchAfterWarmup(warmTask); }); // selectAndOpenEmpty model.setOpenEmptyTemplateRunnable(() -> { context.setOpenEmpty(true); + handleModel(model); launchAfterWarmup(warmTask); }); // selectAndCreateNew model.setCreateNewTemplateRunnable(() -> { context.setCreateNew(true); + handleModel(model); launchAfterWarmup(warmTask); }); @@ -87,6 +92,13 @@ public class DesignerStartupPageActivator extends Activator { }); } + private void handleModel(StartupPageModel model) { + + // 将选中的环境设置为当前环境 + StartupWorkspaceBean selectWorkspaceInfo = model.getSelectWorkspaceInfo(); + DesignerEnvManager.getEnvManager().setCurEnvName(selectWorkspaceInfo.getName()); + } + private void launchAfterWarmup(DesignerPreWarmTask warmTask) { StopWatch stopWatch = StopWatch.createStarted();