|
|
|
@ -1,8 +1,8 @@
|
|
|
|
|
package com.fr.design.file; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
|
import com.fr.base.GraphHelper; |
|
|
|
|
import com.fr.base.svg.IconUtils; |
|
|
|
|
import com.fr.base.vcs.DesignerMode; |
|
|
|
|
import com.fr.design.actions.UpdateAction; |
|
|
|
|
import com.fr.design.actions.file.LocateAction; |
|
|
|
@ -18,7 +18,6 @@ import com.fr.design.mainframe.JTemplate;
|
|
|
|
|
import com.fr.design.mainframe.TemplateSavingChecker; |
|
|
|
|
import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager; |
|
|
|
|
import com.fr.design.utils.DesignUtils; |
|
|
|
|
import com.fr.design.utils.TemplateUtils; |
|
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
|
import com.fr.design.utils.gui.GUIPaintUtils; |
|
|
|
|
import com.fr.design.worker.WorkerManager; |
|
|
|
@ -41,11 +40,11 @@ import javax.swing.JComponent;
|
|
|
|
|
import javax.swing.JMenu; |
|
|
|
|
import javax.swing.JMenuItem; |
|
|
|
|
import javax.swing.JOptionPane; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.JSeparator; |
|
|
|
|
import javax.swing.MenuElement; |
|
|
|
|
import javax.swing.SwingConstants; |
|
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
|
import javax.swing.ToolTipManager; |
|
|
|
|
import javax.swing.plaf.basic.BasicMenuItemUI; |
|
|
|
|
import java.awt.AWTEvent; |
|
|
|
|
import java.awt.AlphaComposite; |
|
|
|
@ -69,6 +68,8 @@ import java.awt.geom.Line2D;
|
|
|
|
|
import java.awt.geom.Path2D; |
|
|
|
|
import java.awt.geom.RoundRectangle2D; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
import static com.fr.design.dialog.FineJOptionPane.showConfirmDialog; |
|
|
|
|
import static javax.swing.JOptionPane.OK_CANCEL_OPTION; |
|
|
|
@ -85,12 +86,12 @@ import static javax.swing.JOptionPane.WARNING_MESSAGE;
|
|
|
|
|
**/ |
|
|
|
|
public class MultiTemplateTabPane extends JComponent { |
|
|
|
|
|
|
|
|
|
private static Icon LIST_DOWN = BaseUtils.readIcon("/com/fr/design/images/buttonicon/list_normal.png"); |
|
|
|
|
private static Icon MOUSE_OVER_LIST_DOWN = BaseUtils.readIcon("/com/fr/design/images/buttonicon/list_pressed.png"); |
|
|
|
|
private static Icon MOUSE_PRESS_LIST_DOWN = BaseUtils.readIcon("/com/fr/design/images/buttonicon/list_pressed.png"); |
|
|
|
|
private static Icon CLOSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/close_icon.png"); |
|
|
|
|
private static Icon MOUSE_OVER_CLOSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/mouseoverclose icon.png"); |
|
|
|
|
private static Icon MOUSE_PRESS_CLOSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/pressclose icon.png"); |
|
|
|
|
private static Icon LIST_DOWN = IconUtils.readIcon("/com/fr/design/standard/list/list"); |
|
|
|
|
private static Icon MOUSE_OVER_LIST_DOWN = IconUtils.readIcon("/com/fr/design/standard/list/list_pressed.svg"); |
|
|
|
|
private static Icon MOUSE_PRESS_LIST_DOWN = IconUtils.readIcon("/com/fr/design/standard/list/list_pressed.svg"); |
|
|
|
|
private static Icon CLOSE = IconUtils.readIcon("/com/fr/design/standard/close/close"); |
|
|
|
|
private static Icon MOUSE_OVER_CLOSE = IconUtils.readIcon("/com/fr/design/standard/close/close_mouseover.svg"); |
|
|
|
|
private static Icon MOUSE_PRESS_CLOSE = IconUtils.readIcon("/com/fr/design/standard/close/close_press.svg"); |
|
|
|
|
private static final Icon WHITE_SAVING_CLOSE_ICON = new ImageIcon(IOUtils.readImage("/com/fr/design/images/file/white_saving_close.gif")); |
|
|
|
|
private static final Icon GREY_SAVING_CLOSE_ICON = new ImageIcon(IOUtils.readImage("/com/fr/design/images/file/grey_saving_close.gif")); |
|
|
|
|
private static final String ELLIPSIS = "..."; |
|
|
|
@ -212,6 +213,35 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 模板可以关闭的条件 |
|
|
|
|
*/ |
|
|
|
|
class CloseCondition { |
|
|
|
|
private CloseOption closeOption; |
|
|
|
|
|
|
|
|
|
public CloseCondition(CloseOption closeOption) { |
|
|
|
|
this.closeOption = closeOption; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 判断模板是否可以关闭,两个条件:1、是否满足CloseOption里面的条件(在左侧、在右侧等)2、是否和当前正在编辑模板属于同一种模板tab操作类型 |
|
|
|
|
* @param closeJTemplate |
|
|
|
|
* @param tplIndex |
|
|
|
|
* @param i |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public boolean shouldClose(JTemplate closeJTemplate, int tplIndex, int i) { |
|
|
|
|
boolean matchOption = this.closeOption.shouldClose(tplIndex, i); |
|
|
|
|
JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
if (!JTemplate.isValid(currentTemplate)) { |
|
|
|
|
return matchOption; |
|
|
|
|
} |
|
|
|
|
return matchOption && ComparatorUtils.equals(closeJTemplate.getTemplateTabOperatorType(), |
|
|
|
|
currentTemplate.getTemplateTabOperatorType()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
enum CloseOption { |
|
|
|
|
Left(Toolkit.i18nText("Fine-Design_Close_templates_To_The_Left")) { |
|
|
|
|
@Override |
|
|
|
@ -322,29 +352,34 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false); |
|
|
|
|
if (saveSomeTempaltePane.showSavePane()) { |
|
|
|
|
//只有关闭所有模板才需要判断当前模板,关闭左侧、右侧、其他都不需要
|
|
|
|
|
SaveSomeTemplatePane saveSomeTemplatePane = new SaveSomeTemplatePane(option == CloseOption.All); |
|
|
|
|
CloseCondition closeCondition = new CloseCondition(option); |
|
|
|
|
if (saveSomeTemplatePane.showSavePane(closeCondition, false)) { |
|
|
|
|
|
|
|
|
|
JTemplate<?, ?>[] templates = new JTemplate<?, ?>[openedTemplate.size()]; |
|
|
|
|
for (int i = 0; i < openedTemplate.size(); i++) { |
|
|
|
|
templates[i] = openedTemplate.get(i); |
|
|
|
|
} |
|
|
|
|
JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
closeTemplate(templates, currentTemplate); |
|
|
|
|
closeTemplate(closeCondition, templates, currentTemplate); |
|
|
|
|
|
|
|
|
|
if (option == CloseOption.All) { |
|
|
|
|
if (openedTemplate.size() == 0) { |
|
|
|
|
DesignerContext.getDesignerFrame().addAndActivateJTemplate(); |
|
|
|
|
} else if (option == CloseOption.All){ |
|
|
|
|
//openedTemplate(0)是JVirtualTemplate时需重新打开
|
|
|
|
|
openedTemplate.get(0).activeOldJTemplate(); |
|
|
|
|
} else { |
|
|
|
|
DesignerContext.getDesignerFrame().activateJTemplate(currentTemplate); |
|
|
|
|
currentTemplate.activeOldJTemplate(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
MultiTemplateTabPane.getInstance().repaint(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void closeTemplate(JTemplate<?, ?>[] templates, JTemplate<?, ?> currentTemplate) { |
|
|
|
|
private void closeTemplate(CloseCondition closeCondition, JTemplate<?, ?>[] templates, JTemplate<?, ?> currentTemplate) { |
|
|
|
|
for (int i = 0; i < templates.length; i++) { |
|
|
|
|
if (option.shouldClose(tplIndex, i)) { |
|
|
|
|
if (closeCondition.shouldClose(templates[i], tplIndex, i)) { |
|
|
|
|
JTemplate<?, ?> jTemplate = templates[i]; |
|
|
|
|
if (jTemplate == currentTemplate) { |
|
|
|
|
currentTemplate = option == CloseOption.All ? null : templates[tplIndex]; |
|
|
|
@ -377,6 +412,46 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
return openedTemplate.get(selectedIndex); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 关闭所有指定模板tab操作类型的模板 |
|
|
|
|
* @param operatorType |
|
|
|
|
*/ |
|
|
|
|
public void closeOtherByOperatorType(String operatorType){ |
|
|
|
|
JTemplate<?, ?> currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false); |
|
|
|
|
if (saveSomeTempaltePane.showSavePane()) { |
|
|
|
|
List<JTemplate<?, ?>> openedTemplate = HistoryTemplateListCache.getInstance().getHistoryList(); |
|
|
|
|
|
|
|
|
|
JTemplate<?, ?>[] templates = new JTemplate<?, ?>[openedTemplate.size()]; |
|
|
|
|
for (int i = 0; i < openedTemplate.size(); i++) { |
|
|
|
|
templates[i] = openedTemplate.get(i); |
|
|
|
|
} |
|
|
|
|
closeTemplate(templates, currentEditingTemplate, operatorType); |
|
|
|
|
|
|
|
|
|
DesignerContext.getDesignerFrame().activateJTemplate(currentEditingTemplate); |
|
|
|
|
MultiTemplateTabPane.getInstance().repaint(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 关闭指定的非当前编辑模板 |
|
|
|
|
* @param templates |
|
|
|
|
* @param operatorType |
|
|
|
|
*/ |
|
|
|
|
private static void closeTemplate(JTemplate<?, ?>[] templates, JTemplate<?, ?> currentEditingTemplate, String operatorType) { |
|
|
|
|
for (int i = 0; i < templates.length; i++) { |
|
|
|
|
JTemplate<?, ?> jTemplate = templates[i]; |
|
|
|
|
boolean needClose = ComparatorUtils.equals(operatorType, jTemplate.getTemplateTabOperatorType()) |
|
|
|
|
&& jTemplate != currentEditingTemplate; |
|
|
|
|
if (!needClose) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
MultiTemplateTabPane.getInstance().closeFormat(jTemplate); |
|
|
|
|
HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate); |
|
|
|
|
MultiTemplateTabPane.getInstance().closeAndFreeLock(jTemplate); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 关闭掉当前已打开文件列表中指定的文件 |
|
|
|
@ -477,11 +552,7 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String tempalteShowName(JTemplate<?, ?> template) { |
|
|
|
|
String name = TemplateUtils.createLockeTemplatedName(template, template.getTemplateName()); |
|
|
|
|
if (!template.isSaved() && !name.endsWith(" *")) { |
|
|
|
|
name += " *"; |
|
|
|
|
} |
|
|
|
|
return name; |
|
|
|
|
return template.getTabShowName(template); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -499,40 +570,7 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void showListDown() { |
|
|
|
|
|
|
|
|
|
UIScrollPopUpMenu menu = new UIScrollPopUpMenu(); |
|
|
|
|
menu.setBorder(BorderFactory.createEmptyBorder(-3, 3, 3, 0)); |
|
|
|
|
menu.add(initCloseOther()); |
|
|
|
|
JSeparator separator = new JSeparator() { |
|
|
|
|
@Override |
|
|
|
|
public Dimension getPreferredSize() { |
|
|
|
|
Dimension d = super.getPreferredSize(); |
|
|
|
|
d.height = 1; |
|
|
|
|
return d; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
menu.add(new JPanel() { |
|
|
|
|
@Override |
|
|
|
|
public Dimension getPreferredSize() { |
|
|
|
|
Dimension d = super.getPreferredSize(); |
|
|
|
|
d.height = 1; |
|
|
|
|
return d; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
separator.setForeground(UIConstants.LINE_COLOR); |
|
|
|
|
menu.add(separator); |
|
|
|
|
menu.add(new JPanel() { |
|
|
|
|
@Override |
|
|
|
|
public Dimension getPreferredSize() { |
|
|
|
|
Dimension d = super.getPreferredSize(); |
|
|
|
|
d.height = 1; |
|
|
|
|
return d; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
UIMenuItem[] items = createListDownTemplate(); |
|
|
|
|
for (int i = 0; i < items.length; i++) { |
|
|
|
|
menu.add(items[i]); |
|
|
|
|
} |
|
|
|
|
UIScrollPopUpMenu menu = MultiTemplateTabMenuFactory.getInstance().createMenu(); |
|
|
|
|
GUICoreUtils.showPopupMenu(menu, MultiTemplateTabPane.getInstance(), MultiTemplateTabPane.getInstance().getWidth() - menu.getPreferredSize().width, getY() - 1 + getHeight()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -582,6 +620,9 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
//从可以开始展示在tab面板上的tab开始画
|
|
|
|
|
for (int i = minPaintIndex; i <= maxPaintIndex; i++) { |
|
|
|
|
JTemplate template = openedTemplate.get(i); |
|
|
|
|
if (!showJTemplateTab(template)){ |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
Icon icon = template.getIcon(); |
|
|
|
|
String name = tempalteShowName(template); |
|
|
|
|
//如果tab名字的长度大于最大能显示的英文字符长度,则进行省略号处理
|
|
|
|
@ -716,13 +757,67 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
minPaintIndex = 0; |
|
|
|
|
maxPaintIndex = openedTemplate.size() - 1; |
|
|
|
|
} |
|
|
|
|
//需要根据每个tab的宽度重新check下实际的maxPaintIndex和minPaintIndex
|
|
|
|
|
checkActualPaintIndex(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 先计算出需要补充的tab个数 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private int calTabCountComplemented(){ |
|
|
|
|
int a = 0; |
|
|
|
|
for (int i = minPaintIndex; i <= maxPaintIndex; i++) { |
|
|
|
|
JTemplate template = openedTemplate.get(i); |
|
|
|
|
if (!showJTemplateTab(template)) { |
|
|
|
|
a++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return a; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 由于可能存在宽度为0的tab,所以这边需要重新check下,先往后补,再往前补 |
|
|
|
|
*/ |
|
|
|
|
private void checkActualPaintIndex(){ |
|
|
|
|
int tabCount = calTabCountComplemented(); |
|
|
|
|
if (tabCount == 0){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (maxPaintIndex < openedTemplate.size() - 1) { |
|
|
|
|
for (int i = maxPaintIndex + 1; i < openedTemplate.size(); i++) { |
|
|
|
|
JTemplate template = openedTemplate.get(i); |
|
|
|
|
if (showJTemplateTab(template)) { |
|
|
|
|
tabCount--; |
|
|
|
|
} |
|
|
|
|
maxPaintIndex++; |
|
|
|
|
if (tabCount == 0){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (minPaintIndex > 0){ |
|
|
|
|
for (int i = minPaintIndex - 1; i >= 0; i--) { |
|
|
|
|
JTemplate template = openedTemplate.get(i); |
|
|
|
|
if (showJTemplateTab(template)) { |
|
|
|
|
tabCount--; |
|
|
|
|
} |
|
|
|
|
minPaintIndex--; |
|
|
|
|
if (tabCount == 0){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//个数小于最多能容纳的个数的情况下,看看宽度每个要画多少
|
|
|
|
|
private void calculateRealAverageWidth(double maxwidth, int templateNum) { |
|
|
|
|
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
List<JTemplate<?, ?>> showTemplates = getOpenedJTemplatesByOperator(jTemplate.getTemplateTabOperatorType()); |
|
|
|
|
|
|
|
|
|
int num = openedTemplate.size() > templateNum ? templateNum : openedTemplate.size(); |
|
|
|
|
int num = Math.min(showTemplates.size(), templateNum); |
|
|
|
|
realWidth = (int) (maxwidth / (num)); |
|
|
|
|
if (realWidth > MAXWIDTH) { |
|
|
|
|
realWidth = MAXWIDTH; |
|
|
|
@ -931,7 +1026,7 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
activePrevTemplateAfterClose(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void closeAndFreeLock(@Nonnull JTemplate<?, ?> template) { |
|
|
|
|
public void closeAndFreeLock(@Nonnull JTemplate<?, ?> template) { |
|
|
|
|
FILE file = template.getEditingFILE(); |
|
|
|
|
// 只有是环境内的文件,才执行释放锁
|
|
|
|
|
if (file != null && file.isEnvFile()) { |
|
|
|
@ -985,9 +1080,12 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
// selectIndex 没有变化,但是对应的模板已经变成了前一张模板
|
|
|
|
|
if (closeIconIndex == selectedIndex || isCloseCurrent) { |
|
|
|
|
// 如果当前关闭的模板在最右侧,那么预览上一个,防止数组越界
|
|
|
|
|
// 关闭的模板是当前选中的模板时,需要重新计算下一个待展示的模板的index
|
|
|
|
|
if (selectedIndex >= maxPaintIndex) { |
|
|
|
|
// selectIndex 不会 <0 因为如果关闭的是打开的最后一个模板,那么关闭之后 openedTemplate.isEmpty() = true
|
|
|
|
|
selectedIndex--; |
|
|
|
|
selectedIndex = calNextShowJTemplateIndex(selectedIndex - 1); |
|
|
|
|
} else { |
|
|
|
|
selectedIndex = calNextShowJTemplateIndex(selectedIndex); |
|
|
|
|
} |
|
|
|
|
isCloseCurrent = false; |
|
|
|
|
} |
|
|
|
@ -1004,6 +1102,26 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 计算下一个可以展示的模板index |
|
|
|
|
* @param currentIndex |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public int calNextShowJTemplateIndex(int currentIndex) { |
|
|
|
|
//先看是否有可以展示的模板
|
|
|
|
|
for (int i = currentIndex; i >= 0; i--) { |
|
|
|
|
if (showJTemplateTab(openedTemplate.get(i))) { |
|
|
|
|
return i; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (int i = currentIndex; i >= 0; i--) { |
|
|
|
|
if (!showJTemplateTab(openedTemplate.get(i))) { |
|
|
|
|
return i; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isOverCloseIcon(int evtX) { |
|
|
|
|
boolean isOverCloseIcon = false; |
|
|
|
@ -1026,7 +1144,7 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
private int getTemplateIndex(int evtX) { |
|
|
|
|
int textX = 0; |
|
|
|
|
for (int i = minPaintIndex; i <= maxPaintIndex; i++) { |
|
|
|
|
int textWidth = realWidth; |
|
|
|
|
int textWidth = showJTemplateTab(openedTemplate.get(i)) ? realWidth : 0; |
|
|
|
|
if (evtX >= textX && evtX < textX + textWidth) { |
|
|
|
|
return i; |
|
|
|
|
} |
|
|
|
@ -1088,6 +1206,7 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
|
|
|
|
|
private class MultiTemplateTabMouseListener implements MouseListener { |
|
|
|
|
|
|
|
|
|
private boolean oldLightWeightPopupEnabled; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 鼠标进入 |
|
|
|
@ -1096,7 +1215,8 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void mouseEntered(MouseEvent e) { |
|
|
|
|
// do nothing
|
|
|
|
|
this.oldLightWeightPopupEnabled = ToolTipManager.sharedInstance().isLightWeightPopupEnabled(); |
|
|
|
|
ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -1106,6 +1226,9 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
|
|
ToolTipManager.sharedInstance().setEnabled(false); |
|
|
|
|
ToolTipManager.sharedInstance().setEnabled(true); |
|
|
|
|
ToolTipManager.sharedInstance().setLightWeightPopupEnabled(this.oldLightWeightPopupEnabled); |
|
|
|
|
listDownMode = LIST_DOWN; |
|
|
|
|
closeIconIndex = -1; |
|
|
|
|
mouseOveredIndex = -1; |
|
|
|
@ -1171,6 +1294,10 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//参考CloseCurrentTemplateAction,在closeFormat与closeSpecifiedTemplate之前要先设定isCloseCurrent,这样关闭之后才会自动切换tab
|
|
|
|
|
if (checkCurrentClose(template)) { |
|
|
|
|
setIsCloseCurrent(true); |
|
|
|
|
} |
|
|
|
|
closeFormat(template); |
|
|
|
|
closeSpecifiedTemplate(template); |
|
|
|
|
DesignerContext.getDesignerFrame().getContentFrame().repaint(); |
|
|
|
@ -1179,29 +1306,49 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
//没有点击关闭和ListDown按钮,则切换到点击的模板处
|
|
|
|
|
closeIconIndex = -1; |
|
|
|
|
clodeMode = CLOSE; |
|
|
|
|
int tempSelectedIndex = selectedIndex; |
|
|
|
|
if (selectedIndex != getTemplateIndex(evtX) && getTemplateIndex(evtX) != -1) { |
|
|
|
|
openedTemplate.get(selectedIndex).stopEditing(); |
|
|
|
|
selectedIndex = getTemplateIndex(evtX); |
|
|
|
|
//如果在权限编辑情况下,不允许切换到表单类型的工作簿
|
|
|
|
|
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); |
|
|
|
|
MultiTemplateTabPane.this.repaint(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
JTemplate evtXTemplate = openedTemplate.get(getTemplateIndex(evtX)); |
|
|
|
|
evtXTemplate.activeNewJTemplate(); |
|
|
|
|
} |
|
|
|
|
switchJTemplate(getTemplateIndex(evtX)); |
|
|
|
|
isShowList = false; |
|
|
|
|
} |
|
|
|
|
MultiTemplateTabPane.this.repaint(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 切换到指定模板 |
|
|
|
|
* @param jTemplate |
|
|
|
|
*/ |
|
|
|
|
public void switchJTemplate(JTemplate jTemplate) { |
|
|
|
|
int switchIndex = this.openedTemplate.indexOf(jTemplate); |
|
|
|
|
if (switchIndex >= 0) { |
|
|
|
|
switchJTemplate(switchIndex); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 切换到指定index |
|
|
|
|
* @param switchIndex |
|
|
|
|
*/ |
|
|
|
|
private void switchJTemplate(int switchIndex){ |
|
|
|
|
int tempSelectedIndex = selectedIndex; |
|
|
|
|
if (selectedIndex != switchIndex && switchIndex != -1) { |
|
|
|
|
openedTemplate.get(selectedIndex).stopEditing(); |
|
|
|
|
selectedIndex = switchIndex; |
|
|
|
|
//如果在权限编辑情况下,不允许切换到表单类型的工作簿
|
|
|
|
|
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); |
|
|
|
|
MultiTemplateTabPane.this.repaint(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
JTemplate evtXTemplate = openedTemplate.get(switchIndex); |
|
|
|
|
evtXTemplate.activeNewJTemplate(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean checkCurrentClose(JTemplate template) { |
|
|
|
|
JTemplate currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
return JTemplate.isValid(currentTemplate) && ComparatorUtils.equals(template.getPath(), currentTemplate.getPath()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private class MultiTemplateTabMouseMotionListener implements MouseMotionListener { |
|
|
|
@ -1241,5 +1388,34 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 判断是否显示在tab栏上 |
|
|
|
|
* @param jTemplate |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private boolean showJTemplateTab(JTemplate jTemplate){ |
|
|
|
|
JTemplate current = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
return ComparatorUtils.equals(current.getTemplateTabOperatorType(), jTemplate.getTemplateTabOperatorType()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取tab操作类型的模板 |
|
|
|
|
* @param operator |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public List<JTemplate<?, ?>> getOpenedJTemplatesByOperator(String operator) { |
|
|
|
|
return openedTemplate.stream().filter((jTemplate) -> ComparatorUtils.equals(jTemplate.getTemplateTabOperatorType(), operator)) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据tab操作类型进行分类 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public Map<String, List<JTemplate<?, ?>>> getOpenedJTemplatesByCategory() { |
|
|
|
|
return openedTemplate.stream() |
|
|
|
|
.collect(Collectors.groupingBy(JTemplate::getTemplateTabOperatorType)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|