diff --git a/designer-base/src/main/java/com/fr/design/file/CloseOption.java b/designer-base/src/main/java/com/fr/design/file/CloseOption.java index c88e7658c8..79667dec0f 100644 --- a/designer-base/src/main/java/com/fr/design/file/CloseOption.java +++ b/designer-base/src/main/java/com/fr/design/file/CloseOption.java @@ -2,6 +2,11 @@ package com.fr.design.file; import com.fr.design.i18n.Toolkit; +/** + * @author kerry + * @since 11.0 + * created on 2023-04-14 + **/ public enum CloseOption { Left(Toolkit.i18nText("Fine-Design_Close_templates_To_The_Left")) { @Override @@ -36,6 +41,12 @@ public enum CloseOption { this.optionName = optionName; } + /** + * 判断指定索引模板是否应该被关闭 + * @param tplIndex + * @param i + * @return + */ public boolean shouldClose(int tplIndex, int i) { return true; } diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java index a67e129f78..edbe9cbab3 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java @@ -30,8 +30,8 @@ import java.util.Map; /** * @author Carlson - * @version 11.0 - * @description + * @since 11.0 + * created on 2023-04-14 **/ public class MultiTemplateTabMenuFactory { @@ -49,6 +49,10 @@ public class MultiTemplateTabMenuFactory { } + /** + * 返回右侧下拉菜单的工厂类 + * @return + */ public static MultiTemplateTabMenuFactory getInstance() { return INSTANCE; } diff --git a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java index 96d72d34c1..715cc94ba0 100644 --- a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java @@ -151,15 +151,30 @@ public class SaveSomeTemplatePane extends BasicPane { } + /** + * 显示未保存弹窗 + * @return + */ public boolean showSavePane() { return showSavePane(false); } + /** + * 显示未保存弹窗 + * @param switchEnv + * @return + */ public boolean showSavePane(boolean switchEnv) { return switchEnv ? showSavePane(DefaultTemplateTabOperate.getInstance().getOpenedJTemplates()) : showSavePane(HistoryTemplateListPane.getInstance().getHistoryList()); } + + /** + * 显示未保存弹窗 + * @param jTemplates + * @return + */ public boolean showSavePane(List> jTemplates) { populate(jTemplates); //如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目 diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java b/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java index 22a0bc37e4..da151d9b0f 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java @@ -12,13 +12,22 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +/** + * @author kerry + * @since 11.0 + * created on 2023-04-14 + **/ public class TemplateTabManager { private static class HOLDER { - private static final TemplateTabManager singleton = new TemplateTabManager(); + private static final TemplateTabManager SINGLETON = new TemplateTabManager(); } + /** + * 返回TemplateTabManager单例对象 + * @return + */ public static TemplateTabManager getInstance() { - return HOLDER.singleton; + return HOLDER.SINGLETON; } private TemplateTabManager() { @@ -27,15 +36,23 @@ public class TemplateTabManager { private List list = new ArrayList<>(); + /** + * 支持注册新的Operator + * @param templateTabOperateProvider + */ public void register(TemplateTabOperateProvider templateTabOperateProvider) { this.list.add(templateTabOperateProvider); } + /** + * 移除operator + * @param templateTabOperateProvider + */ public void remove(TemplateTabOperateProvider templateTabOperateProvider) { this.list.remove(templateTabOperateProvider); } - private boolean isCloseCurrent = false; + private boolean closeCurrent = false; //自动新建的模板B若没有进行任何编辑,切换到其他 // 模板时,模板B会自动关闭 @@ -43,17 +60,20 @@ public class TemplateTabManager { public boolean isCloseCurrent() { - return isCloseCurrent; + return closeCurrent; } public void setCloseCurrent(boolean closeCurrent) { - isCloseCurrent = closeCurrent; + this.closeCurrent = closeCurrent; } public void setTemTemplate(JTemplate temTemplate) { this.temTemplate = temTemplate; } + /** + * 刷新tab栏 + */ public void refresh() { getCurrentOperator().refresh(); } @@ -127,11 +147,18 @@ public class TemplateTabManager { } + /** + * 重置选中index + * @param jTemplate + */ public void resetSelectIndex(JTemplate jTemplate) { getCurrentOperator().resetSelectIndex(jTemplate); } + /** + * 激活新模板 + */ public void activeNewTemplate() { //先看其他模式中是否有已打开的模板,有的话切换过去 for (TemplateTabOperateProvider templateTabOperateProvider : list) { @@ -202,6 +229,9 @@ public class TemplateTabManager { return resultMap; } + /** + * 关闭其他 + */ public void closeOthers() { TemplateTabOperateProvider currentOperator = getCurrentOperator(); currentOperator.closeAction(CloseOption.Others, diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java b/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java index ff913f3342..7bcc816526 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java @@ -6,6 +6,11 @@ import com.fr.file.FILE; import java.util.List; +/** + * @author kerry + * @since 11.0 + * created on 2023-04-14 + **/ public interface TemplateTabOperateProvider { /** * 找到模板树中的位置 @@ -38,6 +43,10 @@ public interface TemplateTabOperateProvider { List> getOpenedJTemplates(); + /** + * 根据指定索引关闭模板 + * @param index + */ void closeByIndex(int index); /** * 关闭指定模板 diff --git a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java index b6bee6e6d8..e42b336f57 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java @@ -25,18 +25,25 @@ import com.fr.third.javax.annotation.Nonnull; import com.fr.workspace.WorkContext; import com.fr.workspace.server.lock.TplOperator; -import javax.swing.*; +import javax.swing.JOptionPane; import java.util.ArrayList; import java.util.List; import static com.fr.design.dialog.FineJOptionPane.showConfirmDialog; -import static javax.swing.JOptionPane.*; - +import static javax.swing.JOptionPane.OK_CANCEL_OPTION; +import static javax.swing.JOptionPane.OK_OPTION; +import static javax.swing.JOptionPane.WARNING_MESSAGE; + +/** + * @author kerry + * @since 11.0 + * created on 2023-04-14 + **/ public abstract class AbstractTemplateTabOperate implements TemplateTabOperateProvider { //用于存放工作簿 - protected java.util.List> openedTemplate = new ArrayList<>(); + private java.util.List> openedTemplate = new ArrayList<>(); //选中的Tab项 - protected int selectedIndex = -1; + private int selectedIndex = -1; public AbstractTemplateTabOperate() { @@ -57,7 +64,8 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr FILE currentTemplate = template.getEditingFILE(); //模板不属于当前环境,跟预览一样先提示保存,再定位模板 //如果是拖拽进来的模板单单用exist不能判断,这边参考预览的判断逻辑(browserTemplate),补充一下 - if ((!currentTemplate.exists() || !(currentTemplate instanceof FileNodeFILE)) && template.canBeSaved()) { + boolean needSave = (!currentTemplate.exists() || !(currentTemplate instanceof FileNodeFILE)) && template.canBeSaved(); + if (needSave) { int selVal = showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"), Toolkit.i18nText("Fine-Design_Basic_Preview_Tool_Tips"), OK_CANCEL_OPTION, WARNING_MESSAGE); if (OK_OPTION == selVal) { CallbackSaveWorker worker = template.saveAs(); @@ -96,6 +104,10 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr } } + /** + * 根据指定索引值关闭模板 + * @param index + */ public void closeByIndex(int index) { //关闭close图标所在的模板{ JTemplate template = openedTemplate.get(index); @@ -153,18 +165,19 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr public void switchTpl(int templateIndex) { int tempSelectedIndex = selectedIndex; JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if ((selectedIndex != templateIndex || !this.accept(jTemplate.getTemplateTabOperatorType())) - && templateIndex != -1) { + boolean shouldSwitch = (selectedIndex != templateIndex || !this.accept(jTemplate.getTemplateTabOperatorType())) + && templateIndex != -1; + if (shouldSwitch) { openedTemplate.get(selectedIndex).stopEditing(); selectedIndex = templateIndex; //如果在权限编辑情况下,不允许切换到表单类型的工作簿 if (DesignerMode.isAuthorityEditing() && !openedTemplate.get(selectedIndex).isJWorkBook()) { DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(tempSelectedIndex)); - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Form_Authority_Edited_Cannot_Be_Supported") + "!", Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Form_Authority_Edited_Cannot_Be_Supported") + "!", Toolkit.i18nText("Fine-Design_Basic_Alert"), WARNING_MESSAGE); return; } - JTemplate evtXTemplate = openedTemplate.get(templateIndex); - evtXTemplate.activeNewJTemplate(); + JTemplate evtTemplate = openedTemplate.get(templateIndex); + evtTemplate.activeNewJTemplate(); } } @@ -285,6 +298,10 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr TemplateTabManager.getInstance().refresh(); } + /** + * 刷新已打开的模板 + * @param list + */ public void refreshOpenedTemplate(List> list) { List> result = new ArrayList<>(); for (JTemplate jTemplate : list) { @@ -315,6 +332,11 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr return this.openedTemplate.indexOf(jTemplate); } + /** + * 是否支持指定操作类型 + * @param type + * @return + */ public boolean accept(String type) { return CompareUtils.isEqual(getOperatorType(), type); } diff --git a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java index 511b74894f..ae8ea292a9 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java @@ -2,20 +2,29 @@ package com.fr.design.file.impl; import com.fr.design.file.MultiTemplateTabPane; +/** + * @author kerry + * @since 11.0 + * created on 2023-04-14 + **/ public class DefaultTemplateTabOperate extends AbstractTemplateTabOperate { public static final String OPERATOR_TYPE = "DEFAULT_TEMPLATE_TAB_OPERATOR"; private static class HOLDER { - private static final DefaultTemplateTabOperate singleton = new DefaultTemplateTabOperate(); + private static final DefaultTemplateTabOperate SINGLETON = new DefaultTemplateTabOperate(); } private DefaultTemplateTabOperate() { super(); } + /** + * 返回DefaultTemplateTabOperate 单例 + * @return + */ public static DefaultTemplateTabOperate getInstance() { - return HOLDER.singleton; + return HOLDER.SINGLETON; } @Override diff --git a/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java b/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java index 804874138d..4afe59f16b 100644 --- a/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java +++ b/designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java @@ -9,9 +9,14 @@ import com.fr.stable.StringUtils; import java.util.ArrayList; import java.util.List; +/** + * @author kerry + * @since 11.0 + * created on 2023-04-14 + **/ public class EmptyTemplateTabOperator implements TemplateTabOperateProvider { private static class HOLDER { - private static final EmptyTemplateTabOperator singleton = new EmptyTemplateTabOperator(); + private static final EmptyTemplateTabOperator SINGLETON = new EmptyTemplateTabOperator(); } @@ -19,8 +24,12 @@ public class EmptyTemplateTabOperator implements TemplateTabOperateProvider { } + /** + * 返回空的模板taboperator单例 + * @return + */ public static EmptyTemplateTabOperator getInstance() { - return HOLDER.singleton; + return HOLDER.SINGLETON; } @Override 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 2f05dbbeb2..8b63b73e96 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 @@ -19,7 +19,11 @@ import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.event.DesignerOpenedListener; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; -import com.fr.design.file.*; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.file.SaveSomeTemplatePane; +import com.fr.design.file.TemplateTabManager; +import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.OemProcessor; import com.fr.design.fun.impl.AbstractTemplateTreeShortCutProvider; import com.fr.design.gui.iprogressbar.ProgressDialog; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index a07bfe1f1d..80fccc95cb 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -17,7 +17,12 @@ import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager; import com.fr.design.data.tabledata.ResponseDataSourceChange; import com.fr.design.dialog.FineJOptionPane; -import com.fr.design.file.*; +import com.fr.design.file.FileOperations; +import com.fr.design.file.FileToolbarStateChangeListener; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.file.TemplateTabManager; +import com.fr.design.file.TemplateTreePane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuHighLight; 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 b8fef1b007..dbf63e077c 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 @@ -30,7 +30,9 @@ import com.fr.design.designer.DesignerProxy; import com.fr.design.designer.TargetComponent; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.InformationWarnPane; -import com.fr.design.file.*; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.file.TemplateResourceManager; import com.fr.design.file.impl.DefaultTemplateTabOperate; import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.MenuHandler; @@ -1993,10 +1995,19 @@ public abstract class JTemplate> return jt != null && jt != JNullTemplate.NULL; } + /** + * 当前模板是否可以被保存 + * @return 是/否 + */ public boolean canBeSaved(){ return true; } + /** + * 当前的模板是否支持缓存 + * + * @return 是/否 + */ public boolean supportCache(){ return true; }