Browse Source

REPORT-75308 FVS大屏模板支持同时打开多个

newui
kerry 2 years ago
parent
commit
817eed5c79
  1. 2
      designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java
  2. 19
      designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java
  3. 24
      designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java
  4. 8
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

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

@ -68,7 +68,7 @@ public class SwitchExistEnv extends MenuDef {
EnvChangeEntrance.getInstance().chooseEnv(envName);
} else {
SaveSomeTemplatePane saveSomeTemplatePane = new SaveSomeTemplatePane(true);
if (saveSomeTemplatePane.showSavePane(true)) {
if (saveSomeTemplatePane.showSavePane()) {
// 用户模板保存后,才进行切换目录操作
EnvChangeEntrance.getInstance().switch2Env(envName);
}

19
designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java

@ -84,6 +84,7 @@ public class SaveSomeTemplatePane extends BasicPane {
for (int i = 0; i < unSavedTemplate.size(); i++) {
templateCheckBoxes[i] = new UICheckBox(unSavedTemplate.get(i).getEditingFILE().getName());
templateCheckBoxes[i].setSelected(true);
templateCheckBoxes[i].setEnabled(!unSavedTemplate.get(i).mustSaveBeforeSwitchEnv());
}
final UIList templatesList = new UIList(templateCheckBoxes);
@ -103,7 +104,9 @@ public class SaveSomeTemplatePane extends BasicPane {
boolean isSelected = chooseAllCheckBox.isSelected();
for (int i = 0; i < templatesList.getModel().getSize(); i++) {
UICheckBox checkBox = (UICheckBox) templatesList.getModel().getElementAt(i);
checkBox.setSelected(isSelected);
boolean mustSaveBeforeSwitchEnv = unSavedTemplate.get(i).mustSaveBeforeSwitchEnv();
checkBox.setSelected(mustSaveBeforeSwitchEnv || isSelected);
templateCheckBoxes[i].setEnabled(!mustSaveBeforeSwitchEnv);
}
templatesList.repaint();
}
@ -150,24 +153,12 @@ public class SaveSomeTemplatePane extends BasicPane {
return count;
}
/**
* 显示未保存弹窗
* @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());
return showSavePane(HistoryTemplateListPane.getInstance().getHistoryList());
}
/**

24
designer-base/src/main/java/com/fr/design/file/impl/AbstractTemplateTabOperate.java

@ -45,7 +45,7 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr
//用于存放工作簿
private java.util.List<JTemplate<?, ?>> openedTemplate = new ArrayList<>();
//选中的Tab项
private int selectedIndex = -1;
private int selectedIndex = 0;
public AbstractTemplateTabOperate() {
@ -257,9 +257,10 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr
}
private void closeTpl(@Nonnull JTemplate<?, ?> specifiedTemplate) {
JTemplate currentSelectedFile = getSelectedFile();
HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate);
closeAndFreeLock(specifiedTemplate);
activePrevTemplateAfterClose(specifiedTemplate == HistoryTemplateListCache.getInstance().getCurrentEditingTemplate());
activePrevTemplateAfterClose(specifiedTemplate == currentSelectedFile, currentSelectedFile);
}
/**
@ -270,12 +271,24 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr
activePrevTemplateAfterClose(TemplateTabManager.getInstance().isCloseCurrent());
}
/**
* 关闭掉一个模板之后激活新的待显示模板
*/
public void activePrevTemplateAfterClose(boolean isCurrentSelectedTpl) {
activePrevTemplateAfterClose(isCurrentSelectedTpl, HistoryTemplateListCache.getInstance().getCurrentEditingTemplate());
}
/**
* 关闭掉一个模板之后激活新的待显示模板
*/
public void activePrevTemplateAfterClose(boolean isCurrentSelectedTpl, JTemplate currentSelectedJTemplate) {
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
boolean couldSwitch = template != null && this.accept(template.getTemplateTabOperatorType());
if (openedTemplate.isEmpty()) {
TemplateTabManager.getInstance().activeNewTemplate();
if (couldSwitch){
TemplateTabManager.getInstance().activeNewTemplate();
}
selectedIndex = 0;
} else {
// 如果关闭的模板是当前选中的模板,则重新激活当前 selectIndex 的模板;
@ -290,10 +303,9 @@ public abstract class AbstractTemplateTabOperate implements TemplateTabOperatePr
}
// 如果关闭的模板不是当前选中的模板,那么重新获取一下当前模板的 index,激活该 index
else {
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
selectedIndex = this.openedTemplate.indexOf(template);
selectedIndex = this.openedTemplate.indexOf(currentSelectedJTemplate);
}
if (selectedIndex < openedTemplate.size()) {
if ( selectedIndex < openedTemplate.size() && couldSwitch) {
//如果是已后台关闭的模板,则重新打开文件
openedTemplate.get(selectedIndex).activeOldJTemplate();
}

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

@ -2082,4 +2082,12 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
public boolean supportCache(){
return true;
}
/**
* 切换环境之前是否一定要保存
* @return
*/
public boolean mustSaveBeforeSwitchEnv(){
return false;
}
}

Loading…
Cancel
Save