|
|
|
@ -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); |
|
|
|
|
} |
|
|
|
|