Browse Source

fix:修改代码规范

feature/x
kerry 2 years ago
parent
commit
ca53cd0f6e
  1. 11
      designer-base/src/main/java/com/fr/design/file/CloseOption.java
  2. 8
      designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java
  3. 15
      designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java
  4. 40
      designer-base/src/main/java/com/fr/design/file/TemplateTabManager.java
  5. 9
      designer-base/src/main/java/com/fr/design/file/TemplateTabOperateProvider.java
  6. 44
      designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java
  7. 13
      designer-base/src/main/java/com/fr/design/file/impl/DefaultTemplateTabOperate.java
  8. 13
      designer-base/src/main/java/com/fr/design/file/impl/EmptyTemplateTabOperator.java
  9. 6
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  10. 7
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  11. 13
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

11
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;
}

8
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;
}

15
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<JTemplate<?, ?>> jTemplates) {
populate(jTemplates);
//如果有未保存的文件 ,则跳出保存对话框,选择要存储的项目

40
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<TemplateTabOperateProvider> 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,

9
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<JTemplate<?, ?>> getOpenedJTemplates();
/**
* 根据指定索引关闭模板
* @param index
*/
void closeByIndex(int index);
/**
* 关闭指定模板

44
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<JTemplate<?, ?>> openedTemplate = new ArrayList<>();
private java.util.List<JTemplate<?, ?>> 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<JTemplate<?, ?>> list) {
List<JTemplate<?, ?>> 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);
}

13
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

13
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

6
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;

7
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;

13
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<T extends BaseBook, U extends BaseUndoState<?>>
return jt != null && jt != JNullTemplate.NULL;
}
/**
* 当前模板是否可以被保存
* @return /
*/
public boolean canBeSaved(){
return true;
}
/**
* 当前的模板是否支持缓存
*
* @return /
*/
public boolean supportCache(){
return true;
}

Loading…
Cancel
Save