|
|
@ -212,6 +212,28 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 模板可以关闭的条件 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
class CloseCondition { |
|
|
|
|
|
|
|
private CloseOption closeOption; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public CloseCondition(CloseOption closeOption) { |
|
|
|
|
|
|
|
this.closeOption = closeOption; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean shouldClose(JTemplate closeJTemplate, int tplIndex, int i) { |
|
|
|
|
|
|
|
boolean matchOption = this.closeOption.shouldClose(tplIndex, i); |
|
|
|
|
|
|
|
JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
|
|
|
if (currentTemplate == null) { |
|
|
|
|
|
|
|
return matchOption; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return matchOption && ComparatorUtils.equals(closeJTemplate.getTemplateTabOperatorType(), |
|
|
|
|
|
|
|
currentTemplate.getTemplateTabOperatorType()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
enum CloseOption { |
|
|
|
enum CloseOption { |
|
|
|
Left(Toolkit.i18nText("Fine-Design_Close_templates_To_The_Left")) { |
|
|
|
Left(Toolkit.i18nText("Fine-Design_Close_templates_To_The_Left")) { |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -324,14 +346,15 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
//只有关闭所有模板才需要判断当前模板,关闭左侧、右侧、其他都不需要
|
|
|
|
//只有关闭所有模板才需要判断当前模板,关闭左侧、右侧、其他都不需要
|
|
|
|
SaveSomeTemplatePane saveSomeTemplatePane = new SaveSomeTemplatePane(option == CloseOption.All); |
|
|
|
SaveSomeTemplatePane saveSomeTemplatePane = new SaveSomeTemplatePane(option == CloseOption.All); |
|
|
|
if (saveSomeTemplatePane.showSavePane(option, false)) { |
|
|
|
CloseCondition closeCondition = new CloseCondition(option); |
|
|
|
|
|
|
|
if (saveSomeTemplatePane.showSavePane(closeCondition, false)) { |
|
|
|
|
|
|
|
|
|
|
|
JTemplate<?, ?>[] templates = new JTemplate<?, ?>[openedTemplate.size()]; |
|
|
|
JTemplate<?, ?>[] templates = new JTemplate<?, ?>[openedTemplate.size()]; |
|
|
|
for (int i = 0; i < openedTemplate.size(); i++) { |
|
|
|
for (int i = 0; i < openedTemplate.size(); i++) { |
|
|
|
templates[i] = openedTemplate.get(i); |
|
|
|
templates[i] = openedTemplate.get(i); |
|
|
|
} |
|
|
|
} |
|
|
|
JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
closeTemplate(templates, currentTemplate); |
|
|
|
closeTemplate(closeCondition, templates, currentTemplate); |
|
|
|
|
|
|
|
|
|
|
|
if (openedTemplate.size() == 0) { |
|
|
|
if (openedTemplate.size() == 0) { |
|
|
|
DesignerContext.getDesignerFrame().addAndActivateJTemplate(); |
|
|
|
DesignerContext.getDesignerFrame().addAndActivateJTemplate(); |
|
|
@ -346,10 +369,9 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void closeTemplate(JTemplate<?, ?>[] templates, JTemplate<?, ?> currentTemplate) { |
|
|
|
private void closeTemplate(CloseCondition closeCondition, JTemplate<?, ?>[] templates, JTemplate<?, ?> currentTemplate) { |
|
|
|
String operator = currentTemplate.getTemplateTabOperatorType(); |
|
|
|
|
|
|
|
for (int i = 0; i < templates.length; i++) { |
|
|
|
for (int i = 0; i < templates.length; i++) { |
|
|
|
if (option.shouldClose(tplIndex, i) && ComparatorUtils.equals(operator, templates[i].getTemplateTabOperatorType())) { |
|
|
|
if (closeCondition.shouldClose(templates[i], tplIndex, i)) { |
|
|
|
JTemplate<?, ?> jTemplate = templates[i]; |
|
|
|
JTemplate<?, ?> jTemplate = templates[i]; |
|
|
|
if (jTemplate == currentTemplate) { |
|
|
|
if (jTemplate == currentTemplate) { |
|
|
|
currentTemplate = option == CloseOption.All ? null : templates[tplIndex]; |
|
|
|
currentTemplate = option == CloseOption.All ? null : templates[tplIndex]; |
|
|
|