|
|
@ -1,38 +1,25 @@ |
|
|
|
package com.fr.design.file; |
|
|
|
package com.fr.design.file; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
|
|
|
|
import com.fr.base.GraphHelper; |
|
|
|
import com.fr.base.GraphHelper; |
|
|
|
import com.fr.base.svg.IconUtils; |
|
|
|
import com.fr.base.svg.IconUtils; |
|
|
|
import com.fr.base.vcs.DesignerMode; |
|
|
|
import com.fr.base.vcs.DesignerMode; |
|
|
|
import com.fr.design.actions.UpdateAction; |
|
|
|
import com.fr.design.actions.UpdateAction; |
|
|
|
import com.fr.design.actions.file.LocateAction; |
|
|
|
import com.fr.design.actions.file.LocateAction; |
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
import com.fr.design.dialog.FineJOptionPane; |
|
|
|
|
|
|
|
import com.fr.design.gui.imenu.UIMenuItem; |
|
|
|
import com.fr.design.gui.imenu.UIMenuItem; |
|
|
|
import com.fr.design.gui.imenu.UIPopupMenu; |
|
|
|
import com.fr.design.gui.imenu.UIPopupMenu; |
|
|
|
import com.fr.design.gui.imenu.UIScrollPopUpMenu; |
|
|
|
import com.fr.design.gui.imenu.UIScrollPopUpMenu; |
|
|
|
import com.fr.design.i18n.DesignSizeI18nManager; |
|
|
|
import com.fr.design.i18n.DesignSizeI18nManager; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
|
|
|
|
import com.fr.design.mainframe.JTemplate; |
|
|
|
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.DesignUtils; |
|
|
|
import com.fr.design.utils.TemplateUtils; |
|
|
|
|
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.design.utils.gui.GUIPaintUtils; |
|
|
|
import com.fr.design.utils.gui.GUIPaintUtils; |
|
|
|
import com.fr.design.worker.WorkerManager; |
|
|
|
|
|
|
|
import com.fr.design.worker.save.CallbackSaveWorker; |
|
|
|
|
|
|
|
import com.fr.file.FILE; |
|
|
|
import com.fr.file.FILE; |
|
|
|
import com.fr.file.FileNodeFILE; |
|
|
|
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.IOUtils; |
|
|
|
import com.fr.general.IOUtils; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
|
|
|
import com.fr.stable.Constants; |
|
|
|
import com.fr.stable.Constants; |
|
|
|
import com.fr.third.javax.annotation.Nonnull; |
|
|
|
|
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
|
|
|
|
import com.fr.workspace.server.lock.TplOperator; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.BorderFactory; |
|
|
|
import javax.swing.ButtonModel; |
|
|
|
import javax.swing.ButtonModel; |
|
|
@ -41,11 +28,8 @@ import javax.swing.ImageIcon; |
|
|
|
import javax.swing.JComponent; |
|
|
|
import javax.swing.JComponent; |
|
|
|
import javax.swing.JMenu; |
|
|
|
import javax.swing.JMenu; |
|
|
|
import javax.swing.JMenuItem; |
|
|
|
import javax.swing.JMenuItem; |
|
|
|
import javax.swing.JOptionPane; |
|
|
|
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
|
|
|
import javax.swing.JSeparator; |
|
|
|
import javax.swing.JSeparator; |
|
|
|
import javax.swing.MenuElement; |
|
|
|
import javax.swing.MenuElement; |
|
|
|
import javax.swing.SwingConstants; |
|
|
|
|
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
import javax.swing.plaf.basic.BasicMenuItemUI; |
|
|
|
import javax.swing.plaf.basic.BasicMenuItemUI; |
|
|
|
import java.awt.AWTEvent; |
|
|
|
import java.awt.AWTEvent; |
|
|
@ -59,7 +43,6 @@ import java.awt.Graphics2D; |
|
|
|
import java.awt.RenderingHints; |
|
|
|
import java.awt.RenderingHints; |
|
|
|
import java.awt.event.AWTEventListener; |
|
|
|
import java.awt.event.AWTEventListener; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseListener; |
|
|
|
import java.awt.event.MouseListener; |
|
|
@ -71,14 +54,9 @@ import java.awt.geom.Path2D; |
|
|
|
import java.awt.geom.RoundRectangle2D; |
|
|
|
import java.awt.geom.RoundRectangle2D; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import static com.fr.design.dialog.FineJOptionPane.showConfirmDialog; |
|
|
|
|
|
|
|
import static javax.swing.JOptionPane.OK_CANCEL_OPTION; |
|
|
|
|
|
|
|
import static javax.swing.JOptionPane.OK_OPTION; |
|
|
|
|
|
|
|
import static javax.swing.JOptionPane.WARNING_MESSAGE; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 改个名字,一个拼写 n 个错误 |
|
|
|
* 改个名字,一个拼写 n 个错误 |
|
|
|
* |
|
|
|
* 模板tab的操作和ui已拆分,后续需要添加模板tab的操作在 TemplateTabManager 中添加 |
|
|
|
* @author daisy |
|
|
|
* @author daisy |
|
|
|
* @version 11.0 |
|
|
|
* @version 11.0 |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
@ -114,10 +92,6 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static MultiTemplateTabPane THIS; |
|
|
|
private static MultiTemplateTabPane THIS; |
|
|
|
//用于存放工作簿
|
|
|
|
|
|
|
|
private java.util.List<JTemplate<?, ?>> openedTemplate; |
|
|
|
|
|
|
|
//选中的Tab项
|
|
|
|
|
|
|
|
private int selectedIndex = 0; |
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
private int mouseOveredIndex = -1; |
|
|
|
private int mouseOveredIndex = -1; |
|
|
|
|
|
|
|
|
|
|
@ -136,16 +110,11 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
|
|
|
|
|
|
|
|
//记录关闭按钮的状态
|
|
|
|
//记录关闭按钮的状态
|
|
|
|
private int closeIconIndex = -1; |
|
|
|
private int closeIconIndex = -1; |
|
|
|
private boolean isCloseCurrent = false; |
|
|
|
|
|
|
|
private Icon clodeMode = CLOSE; |
|
|
|
private Icon clodeMode = CLOSE; |
|
|
|
private Icon listDownMode = LIST_DOWN; |
|
|
|
private Icon listDownMode = LIST_DOWN; |
|
|
|
private boolean isShowList = false; |
|
|
|
private boolean isShowList = false; |
|
|
|
|
|
|
|
|
|
|
|
//自动新建的模板B若没有进行任何编辑,切换到其他
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// 模板时,模板B会自动关闭
|
|
|
|
|
|
|
|
private JTemplate<?, ?> temTemplate = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static MultiTemplateTabPane getInstance() { |
|
|
|
public static MultiTemplateTabPane getInstance() { |
|
|
|
if (THIS == null) { |
|
|
|
if (THIS == null) { |
|
|
@ -165,8 +134,6 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
this.setBorder(null); |
|
|
|
this.setBorder(null); |
|
|
|
this.setForeground(new Color(58, 56, 58)); |
|
|
|
this.setForeground(new Color(58, 56, 58)); |
|
|
|
this.setFont(DesignUtils.getDefaultGUIFont().applySize(12)); |
|
|
|
this.setFont(DesignUtils.getDefaultGUIFont().applySize(12)); |
|
|
|
openedTemplate = HistoryTemplateListCache.getInstance().getHistoryList(); |
|
|
|
|
|
|
|
selectedIndex = openedTemplate.size() - 1; |
|
|
|
|
|
|
|
AWTEventListener awt = new AWTEventListener() { |
|
|
|
AWTEventListener awt = new AWTEventListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void eventDispatched(AWTEvent event) { |
|
|
|
public void eventDispatched(AWTEvent event) { |
|
|
@ -206,45 +173,13 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
//根据当前i18n语言环境,动态调整popupMenu的宽度
|
|
|
|
//根据当前i18n语言环境,动态调整popupMenu的宽度
|
|
|
|
menu.setPreferredSize(new Dimension((int) DesignSizeI18nManager.getInstance(). |
|
|
|
menu.setPreferredSize(new Dimension((int) DesignSizeI18nManager.getInstance(). |
|
|
|
i18nDimension("com.fr.design.file.MultiTemplateTabPane.popUpMenu").getWidth(), height)); |
|
|
|
i18nDimension("com.fr.design.file.MultiTemplateTabPane.popUpMenu").getWidth(), height)); |
|
|
|
GUICoreUtils.showPopupMenu(menu, MultiTemplateTabPane.getInstance(), e.getX(), MultiTemplateTabPane.getInstance().getY() - 1 + MultiTemplateTabPane.getInstance().getHeight()); |
|
|
|
GUICoreUtils.showPopupMenu(menu, MultiTemplateTabPane.this, e.getX(), MultiTemplateTabPane.this.getY() - 1 + MultiTemplateTabPane.this.getHeight()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
enum CloseOption { |
|
|
|
|
|
|
|
Left(Toolkit.i18nText("Fine-Design_Close_templates_To_The_Left")) { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
boolean shouldClose(int tplIndex, int i) { |
|
|
|
|
|
|
|
return i < tplIndex; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
Right(Toolkit.i18nText("Fine-Design_Close_templates_To_The_Right")) { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
boolean shouldClose(int tplIndex, int i) { |
|
|
|
|
|
|
|
return i > tplIndex; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
All(Toolkit.i18nText("Fine-Design_Close_All_templates")), |
|
|
|
|
|
|
|
Others(Toolkit.i18nText("Fine-Design_Close_Other_templates")) { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
boolean shouldClose(int tplIndex, int i) { |
|
|
|
|
|
|
|
return i != tplIndex; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String optionName; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CloseOption(String optionName) { |
|
|
|
|
|
|
|
this.optionName = optionName; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean shouldClose(int tplIndex, int i) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static class CloseMenuItemJSeparator extends JSeparator { |
|
|
|
private static class CloseMenuItemJSeparator extends JSeparator { |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -272,41 +207,10 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
//处于搜索模式时,先退出搜索模式,再定位
|
|
|
|
//DefaultTemplateTabOperate.getInstance().locateTemplateInTree(this.tplIndex);
|
|
|
|
if (TemplateTreeSearchManager.getInstance().isInSearchMode()) { |
|
|
|
TemplateTabManager.getInstance().getCurrentOperator().locateTemplateInTree(this.tplIndex); |
|
|
|
TemplateTreeSearchManager.getInstance().outOfSearchMode(); |
|
|
|
|
|
|
|
TemplateTreePane.getInstance().refreshDockingView(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
JTemplate<?, ?> template = openedTemplate.get(this.tplIndex); |
|
|
|
|
|
|
|
locateTemplate(template); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void locateTemplate(JTemplate<?, ?> template) { |
|
|
|
|
|
|
|
FILE currentTemplate = template.getEditingFILE(); |
|
|
|
|
|
|
|
//模板不属于当前环境,跟预览一样先提示保存,再定位模板
|
|
|
|
|
|
|
|
//如果是拖拽进来的模板单单用exist不能判断,这边参考预览的判断逻辑(browserTemplate),补充一下
|
|
|
|
|
|
|
|
if (!currentTemplate.exists() || !(currentTemplate instanceof FileNodeFILE)) { |
|
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
|
worker.start(template.getRuntimeId()); |
|
|
|
|
|
|
|
worker.addSuccessCallback(new Runnable() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void run() { |
|
|
|
|
|
|
|
gotoEditingTemplateLeaf(template.getPath()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
gotoEditingTemplateLeaf(template.getPath()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private class RightMenuCloseAction extends UpdateAction { |
|
|
|
private class RightMenuCloseAction extends UpdateAction { |
|
|
@ -316,230 +220,82 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
|
|
|
|
|
|
|
|
public RightMenuCloseAction(CloseOption option, int tplIndex) { |
|
|
|
public RightMenuCloseAction(CloseOption option, int tplIndex) { |
|
|
|
this.option = option; |
|
|
|
this.option = option; |
|
|
|
this.setName(option.optionName); |
|
|
|
this.setName(option.getOptionName()); |
|
|
|
this.tplIndex = tplIndex; |
|
|
|
this.tplIndex = tplIndex; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false); |
|
|
|
TemplateTabManager.getInstance().getCurrentOperator().closeAction(option, this.tplIndex); |
|
|
|
if (saveSomeTempaltePane.showSavePane()) { |
|
|
|
MultiTemplateTabPane.this.repaint(); |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (option == CloseOption.All) { |
|
|
|
|
|
|
|
DesignerContext.getDesignerFrame().addAndActivateJTemplate(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
DesignerContext.getDesignerFrame().activateJTemplate(currentTemplate); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MultiTemplateTabPane.getInstance().repaint(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void closeTemplate(JTemplate<?, ?>[] templates, JTemplate<?, ?> currentTemplate) { |
|
|
|
|
|
|
|
for (int i = 0; i < templates.length; i++) { |
|
|
|
|
|
|
|
if (option.shouldClose(tplIndex, i)) { |
|
|
|
|
|
|
|
JTemplate<?, ?> jTemplate = templates[i]; |
|
|
|
|
|
|
|
if (jTemplate == currentTemplate) { |
|
|
|
|
|
|
|
currentTemplate = option == CloseOption.All ? null : templates[tplIndex]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//判断关闭的模板是不是格式刷的被参照的模板
|
|
|
|
|
|
|
|
openedTemplate.remove(jTemplate); |
|
|
|
|
|
|
|
if (jTemplate != currentTemplate) { |
|
|
|
|
|
|
|
MultiTemplateTabPane.getInstance().closeFormat(jTemplate); |
|
|
|
|
|
|
|
HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate); |
|
|
|
|
|
|
|
closeAndFreeLock(jTemplate); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void closeAndFreeLock(@Nonnull JTemplate<?, ?> template) { |
|
|
|
|
|
|
|
FILE file = template.getEditingFILE(); |
|
|
|
|
|
|
|
// 只有是环境内的文件,才执行释放锁
|
|
|
|
|
|
|
|
if (file != null && file.isEnvFile()) { |
|
|
|
|
|
|
|
// release lock
|
|
|
|
|
|
|
|
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(file.getPath()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 留作兼容 |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
public JTemplate getSelectedFile() { |
|
|
|
public JTemplate getSelectedFile() { |
|
|
|
if (openedTemplate.size() == selectedIndex) { |
|
|
|
return TemplateTabManager.getInstance().getSelectedFile(); |
|
|
|
selectedIndex = Math.max(--selectedIndex, 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return openedTemplate.get(selectedIndex); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 关闭掉当前已打开文件列表中指定的文件 |
|
|
|
* 关闭掉当前已打开文件列表中指定的文件 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param file 指定的文件 |
|
|
|
* @param file 指定的文件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
public void closeFileTemplate(FILE file) { |
|
|
|
public void closeFileTemplate(FILE file) { |
|
|
|
for (JTemplate<?, ?> temp : openedTemplate) { |
|
|
|
TemplateTabManager.getInstance().closeFileTemplate(file); |
|
|
|
if (ComparatorUtils.equals(file, temp.getEditingFILE())) { |
|
|
|
|
|
|
|
closeSpecifiedTemplate(temp); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Dimension getPreferredSize() { |
|
|
|
|
|
|
|
Dimension dimension = super.getPreferredSize(); |
|
|
|
|
|
|
|
dimension.height = HEIGHT; |
|
|
|
|
|
|
|
return dimension; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private UIMenuItem initCloseOther() { |
|
|
|
|
|
|
|
UIMenuItem closeOther = new UIMenuItem(Toolkit.i18nText("Fine-Design_Basic_FS_Close_Other_Templates")); |
|
|
|
|
|
|
|
// Yvan: 英文下文本显示不全,后续发现如果将模板名设置的比较短,其它语言也会出现显示不全的问题,所以设置一下文本水平居中
|
|
|
|
|
|
|
|
closeOther.setHorizontalAlignment(SwingConstants.CENTER); |
|
|
|
|
|
|
|
setListDownItemPreferredSize(closeOther); |
|
|
|
|
|
|
|
closeOther.addActionListener(new ActionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
|
|
if (openedTemplate.size() == 1) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!TemplateSavingChecker.check()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false); |
|
|
|
|
|
|
|
//点击关闭其他模板,并且点击确定保存
|
|
|
|
|
|
|
|
if (saveSomeTempaltePane.showSavePane()) { |
|
|
|
|
|
|
|
JTemplate<?, ?>[] panes = new JTemplate<?, ?>[openedTemplate.size()]; |
|
|
|
|
|
|
|
for (int i = 0; i < openedTemplate.size(); i++) { |
|
|
|
|
|
|
|
panes[i] = openedTemplate.get(i); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < panes.length; i++) { |
|
|
|
|
|
|
|
if (i != selectedIndex) { |
|
|
|
|
|
|
|
JTemplate<?, ?> jTemplate = panes[i]; |
|
|
|
|
|
|
|
//判断关闭的模板是不是格式刷的被参照的模板
|
|
|
|
|
|
|
|
openedTemplate.remove(jTemplate); |
|
|
|
|
|
|
|
closeFormat(jTemplate); |
|
|
|
|
|
|
|
HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate); |
|
|
|
|
|
|
|
closeAndFreeLock(jTemplate); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
|
|
|
HistoryTemplateListCache.getInstance().removeAllHistory(); |
|
|
|
|
|
|
|
DesignerContext.getDesignerFrame().activateJTemplate(currentTemplate); |
|
|
|
|
|
|
|
THIS.repaint(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//如果取消保存了,则不关闭其他模板
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
if (openedTemplate.size() == 1) { |
|
|
|
|
|
|
|
closeOther.setEnabled(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return closeOther; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private UIMenuItem[] createListDownTemplate() { |
|
|
|
|
|
|
|
UIMenuItem[] templates = new UIMenuItem[openedTemplate.size()]; |
|
|
|
|
|
|
|
for (int i = 0; i < openedTemplate.size(); i++) { |
|
|
|
|
|
|
|
final int index = i; |
|
|
|
|
|
|
|
final JTemplate tem = openedTemplate.get(i); |
|
|
|
|
|
|
|
templates[i] = new UIMenuItem(tempalteShowName(tem), tem.getIcon()); |
|
|
|
|
|
|
|
templates[i].setUI(new UIListDownItemUI()); |
|
|
|
|
|
|
|
setListDownItemPreferredSize(templates[i]); |
|
|
|
|
|
|
|
if (i == selectedIndex) { |
|
|
|
|
|
|
|
//画选中的高亮
|
|
|
|
|
|
|
|
templates[i].setBackground(UIConstants.SHADOW_CENTER); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
templates[i].addActionListener(new ActionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
|
|
selectedIndex = index; |
|
|
|
|
|
|
|
tem.activeNewJTemplate(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return templates; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setListDownItemPreferredSize(UIMenuItem item) { |
|
|
|
|
|
|
|
Dimension dimension = item.getPreferredSize(); |
|
|
|
|
|
|
|
dimension.height = LIST_DOWN_HEIGHT; |
|
|
|
|
|
|
|
item.setPreferredSize(dimension); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String tempalteShowName(JTemplate<?, ?> template) { |
|
|
|
|
|
|
|
String name = TemplateUtils.createLockeTemplatedName(template, template.getTemplateName()); |
|
|
|
|
|
|
|
if (!template.isSaved() && !name.endsWith(" *")) { |
|
|
|
|
|
|
|
name += " *"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return name; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 刷新打开模板 |
|
|
|
* 刷新打开模板 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param history 模板 |
|
|
|
* @param history 模板 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
public void refreshOpenedTemplate(List<JTemplate<?, ?>> history) { |
|
|
|
public void refreshOpenedTemplate(List<JTemplate<?, ?>> history) { |
|
|
|
openedTemplate = history; |
|
|
|
TemplateTabManager.getInstance().refreshOpenedTemplate(history); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 设置临时Template |
|
|
|
|
|
|
|
* @param auotCreate |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
public void setTemTemplate(JTemplate<?, ?> auotCreate) { |
|
|
|
public void setTemTemplate(JTemplate<?, ?> auotCreate) { |
|
|
|
temTemplate = auotCreate; |
|
|
|
TemplateTabManager.getInstance().setTemTemplate(auotCreate); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 设置选中模板索引 |
|
|
|
|
|
|
|
* @param index |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void setSelectedIndex(int index) { |
|
|
|
|
|
|
|
TemplateTabManager.getInstance().getCurrentOperator().setSelectIndex(index); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void showListDown() { |
|
|
|
@Override |
|
|
|
|
|
|
|
public Dimension getPreferredSize() { |
|
|
|
|
|
|
|
Dimension dimension = super.getPreferredSize(); |
|
|
|
|
|
|
|
dimension.height = HEIGHT; |
|
|
|
|
|
|
|
return dimension; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UIScrollPopUpMenu menu = new UIScrollPopUpMenu(); |
|
|
|
private String tempalteShowName(JTemplate<?, ?> template) { |
|
|
|
menu.setBorder(BorderFactory.createEmptyBorder(-3, 3, 3, 0)); |
|
|
|
return TemplateTabManager.getInstance().getTemplateShowName(template); |
|
|
|
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]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
GUICoreUtils.showPopupMenu(menu, MultiTemplateTabPane.getInstance(), MultiTemplateTabPane.getInstance().getWidth() - menu.getPreferredSize().width, getY() - 1 + getHeight()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setSelectedIndex(int index) { |
|
|
|
private void showListDown() { |
|
|
|
selectedIndex = index; |
|
|
|
UIScrollPopUpMenu menu = MultiTemplateTabMenuFactory.getInstance().createMenu(); |
|
|
|
|
|
|
|
GUICoreUtils.showPopupMenu(menu, MultiTemplateTabPane.this, MultiTemplateTabPane.this.getWidth() - menu.getPreferredSize().width, getY() - 1 + getHeight()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -566,15 +322,18 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
paintDefaultBackground(g2d); |
|
|
|
paintDefaultBackground(g2d); |
|
|
|
//最多能画的个数
|
|
|
|
//最多能画的个数
|
|
|
|
int maxTemplateNum = (int) (maxWidth) / MINWIDTH; |
|
|
|
int maxTemplateNum = (int) (maxWidth) / MINWIDTH; |
|
|
|
|
|
|
|
int templateTabCount = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size(); |
|
|
|
|
|
|
|
int currentSelectedIndex = TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex(); |
|
|
|
//计算开始画的最小模板index和最大模板index
|
|
|
|
//计算开始画的最小模板index和最大模板index
|
|
|
|
calMinAndMaxIndex(maxTemplateNum); |
|
|
|
calMinAndMaxIndex(maxTemplateNum); |
|
|
|
calculateRealAverageWidth(maxWidth, maxTemplateNum); |
|
|
|
calculateRealAverageWidth(maxWidth, maxTemplateNum); |
|
|
|
int maxStringlength = calculateStringMaxLength(); |
|
|
|
int maxStringlength = calculateStringMaxLength(); |
|
|
|
if (selectedIndex >= openedTemplate.size()) { |
|
|
|
if ( currentSelectedIndex >= templateTabCount) { |
|
|
|
selectedIndex = openedTemplate.size() - 1; |
|
|
|
TemplateTabManager.getInstance().getCurrentOperator().setSelectIndex( |
|
|
|
|
|
|
|
templateTabCount - 1); |
|
|
|
} |
|
|
|
} |
|
|
|
if (selectedIndex < 0) { |
|
|
|
if (TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex() < 0) { |
|
|
|
selectedIndex = 0; |
|
|
|
TemplateTabManager.getInstance().getCurrentOperator().setSelectIndex(0); |
|
|
|
} |
|
|
|
} |
|
|
|
double templateStartX = 0; |
|
|
|
double templateStartX = 0; |
|
|
|
startX = new int[maxPaintIndex - minPaintIndex + 1]; |
|
|
|
startX = new int[maxPaintIndex - minPaintIndex + 1]; |
|
|
@ -582,7 +341,7 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
|
|
|
|
|
|
|
|
//从可以开始展示在tab面板上的tab开始画
|
|
|
|
//从可以开始展示在tab面板上的tab开始画
|
|
|
|
for (int i = minPaintIndex; i <= maxPaintIndex; i++) { |
|
|
|
for (int i = minPaintIndex; i <= maxPaintIndex; i++) { |
|
|
|
JTemplate template = openedTemplate.get(i); |
|
|
|
JTemplate template = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().get(i); |
|
|
|
Icon icon = template.getIcon(); |
|
|
|
Icon icon = template.getIcon(); |
|
|
|
String name = tempalteShowName(template); |
|
|
|
String name = tempalteShowName(template); |
|
|
|
//如果tab名字的长度大于最大能显示的英文字符长度,则进行省略号处理
|
|
|
|
//如果tab名字的长度大于最大能显示的英文字符长度,则进行省略号处理
|
|
|
@ -599,7 +358,7 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
selectedIcon = CLOSE; |
|
|
|
selectedIcon = CLOSE; |
|
|
|
} |
|
|
|
} |
|
|
|
if (i == selectedIndex) { |
|
|
|
if (i == TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex()) { |
|
|
|
if (template.isSaving()) { |
|
|
|
if (template.isSaving()) { |
|
|
|
selectedIcon = WHITE_SAVING_CLOSE_ICON; |
|
|
|
selectedIcon = WHITE_SAVING_CLOSE_ICON; |
|
|
|
} |
|
|
|
} |
|
|
@ -608,8 +367,8 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
if (template.isSaving()) { |
|
|
|
if (template.isSaving()) { |
|
|
|
selectedIcon = GREY_SAVING_CLOSE_ICON; |
|
|
|
selectedIcon = GREY_SAVING_CLOSE_ICON; |
|
|
|
} |
|
|
|
} |
|
|
|
boolean isLeft = i < selectedIndex; |
|
|
|
boolean left = i < TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex(); |
|
|
|
startX[i - minPaintIndex] = paintUnSelectedTab(g2d, icon, templateStartX, name, selectedIcon, isLeft, mouseOveredIndex, i); |
|
|
|
startX[i - minPaintIndex] = paintUnSelectedTab(g2d, icon, templateStartX, name, selectedIcon, left, mouseOveredIndex, i); |
|
|
|
} |
|
|
|
} |
|
|
|
templateStartX += realWidth; |
|
|
|
templateStartX += realWidth; |
|
|
|
} |
|
|
|
} |
|
|
@ -684,38 +443,39 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void calMinAndMaxIndex(int maxTemplateNum) { |
|
|
|
private void calMinAndMaxIndex(int maxTemplateNum) { |
|
|
|
|
|
|
|
int templateTabCount = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size(); |
|
|
|
//如果个数大于最多能容纳的个数,则多余的进行处理
|
|
|
|
//如果个数大于最多能容纳的个数,则多余的进行处理
|
|
|
|
if (openedTemplate.size() > maxTemplateNum) { |
|
|
|
if (templateTabCount > maxTemplateNum) { |
|
|
|
//所点击列表中的标签页处在标签页栏最后一个标签页之后,则标签页栏左移至所点击标签页出现
|
|
|
|
//所点击列表中的标签页处在标签页栏最后一个标签页之后,则标签页栏左移至所点击标签页出现
|
|
|
|
if (selectedIndex >= maxPaintIndex) { |
|
|
|
if (TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex() >= maxPaintIndex) { |
|
|
|
minPaintIndex = selectedIndex - maxTemplateNum + 1; |
|
|
|
minPaintIndex = TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex() - maxTemplateNum + 1; |
|
|
|
maxPaintIndex = selectedIndex; |
|
|
|
maxPaintIndex = TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex(); |
|
|
|
if (minPaintIndex <= 0) { |
|
|
|
if (minPaintIndex <= 0) { |
|
|
|
minPaintIndex = 0; |
|
|
|
minPaintIndex = 0; |
|
|
|
maxPaintIndex = maxTemplateNum - 1; |
|
|
|
maxPaintIndex = maxTemplateNum - 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (selectedIndex <= minPaintIndex) { |
|
|
|
} else if (TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex() <= minPaintIndex) { |
|
|
|
//所点击列表中的标签页处在标签页栏第一个标签页之前,则标签页栏右移至所点击标签页出现
|
|
|
|
//所点击列表中的标签页处在标签页栏第一个标签页之前,则标签页栏右移至所点击标签页出现
|
|
|
|
minPaintIndex = selectedIndex; |
|
|
|
minPaintIndex = TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex(); |
|
|
|
maxPaintIndex = minPaintIndex + maxTemplateNum - 1; |
|
|
|
maxPaintIndex = minPaintIndex + maxTemplateNum - 1; |
|
|
|
if (maxPaintIndex > openedTemplate.size() - 1) { |
|
|
|
if (maxPaintIndex > templateTabCount- 1) { |
|
|
|
maxPaintIndex = openedTemplate.size() - 1; |
|
|
|
maxPaintIndex = templateTabCount - 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (selectedIndex >= openedTemplate.size() - 1) { |
|
|
|
if (TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex() >= templateTabCount - 1) { |
|
|
|
selectedIndex = openedTemplate.size() - 1; |
|
|
|
TemplateTabManager.getInstance().getCurrentOperator().setSelectIndex(templateTabCount - 1); |
|
|
|
maxPaintIndex = selectedIndex; |
|
|
|
maxPaintIndex = TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex(); |
|
|
|
minPaintIndex = selectedIndex - maxTemplateNum + 1; |
|
|
|
minPaintIndex = TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex() - maxTemplateNum + 1; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
maxPaintIndex = minPaintIndex + maxTemplateNum - 1; |
|
|
|
maxPaintIndex = minPaintIndex + maxTemplateNum - 1; |
|
|
|
if (maxPaintIndex > openedTemplate.size() - 1) { |
|
|
|
if (maxPaintIndex > templateTabCount - 1) { |
|
|
|
maxPaintIndex = openedTemplate.size() - 1; |
|
|
|
maxPaintIndex = templateTabCount - 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
minPaintIndex = 0; |
|
|
|
minPaintIndex = 0; |
|
|
|
maxPaintIndex = openedTemplate.size() - 1; |
|
|
|
maxPaintIndex = templateTabCount - 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -723,7 +483,7 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
//个数小于最多能容纳的个数的情况下,看看宽度每个要画多少
|
|
|
|
//个数小于最多能容纳的个数的情况下,看看宽度每个要画多少
|
|
|
|
private void calculateRealAverageWidth(double maxwidth, int templateNum) { |
|
|
|
private void calculateRealAverageWidth(double maxwidth, int templateNum) { |
|
|
|
|
|
|
|
|
|
|
|
int num = openedTemplate.size() > templateNum ? templateNum : openedTemplate.size(); |
|
|
|
int num = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size() > templateNum ? templateNum : TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size(); |
|
|
|
realWidth = (int) (maxwidth / (num)); |
|
|
|
realWidth = (int) (maxwidth / (num)); |
|
|
|
if (realWidth > MAXWIDTH) { |
|
|
|
if (realWidth > MAXWIDTH) { |
|
|
|
realWidth = MAXWIDTH; |
|
|
|
realWidth = MAXWIDTH; |
|
|
@ -887,10 +647,13 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
generalPath.closePath(); |
|
|
|
generalPath.closePath(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 设置是否关闭当前打开的模板 |
|
|
|
|
|
|
|
* @param isCloseCurrent |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
public void setIsCloseCurrent(boolean isCloseCurrent) { |
|
|
|
public void setIsCloseCurrent(boolean isCloseCurrent) { |
|
|
|
this.isCloseCurrent = isCloseCurrent; |
|
|
|
TemplateTabManager.getInstance().setCloseCurrent(isCloseCurrent); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -898,57 +661,35 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
* |
|
|
|
* |
|
|
|
* @param specifiedTemplate 模板 |
|
|
|
* @param specifiedTemplate 模板 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
public void closeSpecifiedTemplate(JTemplate<?, ?> specifiedTemplate) { |
|
|
|
public void closeSpecifiedTemplate(JTemplate<?, ?> specifiedTemplate) { |
|
|
|
if (specifiedTemplate == null) { |
|
|
|
TemplateTabManager.getInstance().closeSpecifiedTemplate(specifiedTemplate); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) { |
|
|
|
|
|
|
|
specifiedTemplate.stopEditing(); |
|
|
|
private boolean isOverCloseIcon(int evtX) { |
|
|
|
int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", |
|
|
|
boolean overCloseIcon = false; |
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); |
|
|
|
for (int i = 0; i < startX.length; i++) { |
|
|
|
if (returnVal == JOptionPane.YES_OPTION) { |
|
|
|
if (evtX >= startX[i] && evtX <= startX[i] + CLOSE.getIconWidth()) { |
|
|
|
CallbackSaveWorker worker = specifiedTemplate.save(); |
|
|
|
overCloseIcon = true; |
|
|
|
worker.addSuccessCallback(new Runnable() { |
|
|
|
break; |
|
|
|
@Override |
|
|
|
|
|
|
|
public void run() { |
|
|
|
|
|
|
|
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); |
|
|
|
|
|
|
|
closeTpl(specifiedTemplate); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
worker.start(specifiedTemplate.getRuntimeId()); |
|
|
|
|
|
|
|
} else if (returnVal == JOptionPane.NO_OPTION) { |
|
|
|
|
|
|
|
closeTpl(specifiedTemplate); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
closeTpl(specifiedTemplate); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return overCloseIcon; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void closeTpl(@Nonnull JTemplate<?, ?> specifiedTemplate) { |
|
|
|
|
|
|
|
HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate); |
|
|
|
|
|
|
|
closeAndFreeLock(specifiedTemplate); |
|
|
|
|
|
|
|
activePrevTemplateAfterClose(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void closeAndFreeLock(@Nonnull JTemplate<?, ?> template) { |
|
|
|
private boolean isOverListDown(int evtX) { |
|
|
|
FILE file = template.getEditingFILE(); |
|
|
|
int maxWidth = getWidth() - LIST_BUTTON_WIDTH; |
|
|
|
// 只有是环境内的文件,才执行释放锁
|
|
|
|
return evtX >= (maxWidth + SMALLGAP) && evtX <= (getWidth() - SMALLGAP); |
|
|
|
if (file != null && file.isEnvFile()) { |
|
|
|
|
|
|
|
// release lock
|
|
|
|
|
|
|
|
TemplateResourceManager.getResource().closeTemplate(file.getPath()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 后台关闭当前编辑模板 |
|
|
|
* 后台关闭当前编辑模板 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
public void closeCurrentTpl() { |
|
|
|
public void closeCurrentTpl() { |
|
|
|
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
TemplateTabManager.getInstance().closeCurrentTpl(); |
|
|
|
this.setIsCloseCurrent(true); |
|
|
|
|
|
|
|
this.closeFormat(jTemplate); |
|
|
|
|
|
|
|
this.closeSpecifiedTemplate(jTemplate); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -956,71 +697,25 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
* |
|
|
|
* |
|
|
|
* @param closedTemplate 模板 |
|
|
|
* @param closedTemplate 模板 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
public void closeFormat(JTemplate closedTemplate) { |
|
|
|
public void closeFormat(JTemplate closedTemplate) { |
|
|
|
//表单不需要处理
|
|
|
|
TemplateTabManager.getInstance().closeFormat(closedTemplate); |
|
|
|
if (!closedTemplate.isJWorkBook()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (DesignerContext.getFormatState() == DesignerContext.FORMAT_STATE_NULL) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//是被参照的模板被关闭,则重置格式刷
|
|
|
|
|
|
|
|
closedTemplate.doConditionCancelFormat(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 关闭掉一个模板之后激活新的待显示模板 |
|
|
|
* 关闭掉一个模板之后激活新的待显示模板 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
public void activePrevTemplateAfterClose() { |
|
|
|
public void activePrevTemplateAfterClose() { |
|
|
|
if (openedTemplate.isEmpty()) { |
|
|
|
TemplateTabManager.getInstance().activePrevTemplateAfterClose(); |
|
|
|
//新建并激活模板
|
|
|
|
|
|
|
|
DesignerContext.getDesignerFrame().addAndActivateJTemplate(); |
|
|
|
|
|
|
|
selectedIndex = 0; |
|
|
|
|
|
|
|
//此时刚自动新建的模板在HistoryTemplateListCache的editingTemplate
|
|
|
|
|
|
|
|
temTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 如果关闭的模板是当前选中的模板,则重新激活当前 selectIndex 的模板;
|
|
|
|
|
|
|
|
// selectIndex 没有变化,但是对应的模板已经变成了前一张模板
|
|
|
|
|
|
|
|
if (closeIconIndex == selectedIndex || isCloseCurrent) { |
|
|
|
|
|
|
|
// 如果当前关闭的模板在最右侧,那么预览上一个,防止数组越界
|
|
|
|
|
|
|
|
if (selectedIndex >= maxPaintIndex) { |
|
|
|
|
|
|
|
// selectIndex 不会 <0 因为如果关闭的是打开的最后一个模板,那么关闭之后 openedTemplate.isEmpty() = true
|
|
|
|
|
|
|
|
selectedIndex--; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
isCloseCurrent = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 如果关闭的模板不是当前选中的模板,那么重新获取一下当前模板的 index,激活该 index
|
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
|
|
|
selectedIndex = HistoryTemplateListCache.getInstance().contains(template); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (selectedIndex < openedTemplate.size()) { |
|
|
|
|
|
|
|
//如果是已后台关闭的模板,则重新打开文件
|
|
|
|
|
|
|
|
openedTemplate.get(selectedIndex).activeOldJTemplate(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isOverCloseIcon(int evtX) { |
|
|
|
|
|
|
|
boolean isOverCloseIcon = false; |
|
|
|
|
|
|
|
for (int i = 0; i < startX.length; i++) { |
|
|
|
|
|
|
|
if (evtX >= startX[i] && evtX <= startX[i] + CLOSE.getIconWidth()) { |
|
|
|
|
|
|
|
isOverCloseIcon = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return isOverCloseIcon; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
private boolean isOverListDown(int evtX) { |
|
|
|
* 处理自动新建的模板 在切换时的处理 |
|
|
|
int maxWidth = getWidth() - LIST_BUTTON_WIDTH; |
|
|
|
*/ |
|
|
|
return evtX >= (maxWidth + SMALLGAP) && evtX <= (getWidth() - SMALLGAP); |
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void doWithtemTemplate() { |
|
|
|
|
|
|
|
TemplateTabManager.getInstance().doWithtemTemplate(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1036,29 +731,6 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 处理自动新建的模板 在切换时的处理 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void doWithtemTemplate() { |
|
|
|
|
|
|
|
//temtemplate保存的一定是手动新建的没有编辑或是编辑了没有保存的模板
|
|
|
|
|
|
|
|
//没有保存,说明有编辑;已经保存在磁盘里的文件,说明有过处理,并且已经保存,此时切换都不将其自动关闭
|
|
|
|
|
|
|
|
if (temTemplate == null || temTemplate == HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!temTemplate.isSaved() || !temTemplate.getEditingFILE().isMemFile()) { |
|
|
|
|
|
|
|
temTemplate = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//自动新建的模板B若没有进行任何编辑(新建模板没有进行任何编辑时saved都是true):还没有存盘
|
|
|
|
|
|
|
|
if (temTemplate != null && temTemplate.getEditingFILE().isMemFile() && temTemplate.isSaved()) { |
|
|
|
|
|
|
|
HistoryTemplateListCache.getInstance().closeSelectedReport(temTemplate); |
|
|
|
|
|
|
|
temTemplate = null; |
|
|
|
|
|
|
|
setSelectedIndex(HistoryTemplateListCache.getInstance().contains(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class UIListDownItemUI extends BasicMenuItemUI { |
|
|
|
private class UIListDownItemUI extends BasicMenuItemUI { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) { |
|
|
|
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) { |
|
|
@ -1161,44 +833,13 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
closeIconIndex = getTemplateIndex(evtX); |
|
|
|
closeIconIndex = getTemplateIndex(evtX); |
|
|
|
clodeMode = MOUSE_PRESS_CLOSE; |
|
|
|
clodeMode = MOUSE_PRESS_CLOSE; |
|
|
|
//关闭close图标所在的模板{
|
|
|
|
//关闭close图标所在的模板{
|
|
|
|
JTemplate<?, ?> template = openedTemplate.get(closeIconIndex); |
|
|
|
TemplateTabManager.getInstance().getCurrentOperator().closeByIndex(closeIconIndex); |
|
|
|
if (template.isOpening()) { |
|
|
|
|
|
|
|
WorkerManager.getInstance().cancelWorker(template.getPath()); |
|
|
|
|
|
|
|
} else if (template.isSaving()) { |
|
|
|
|
|
|
|
boolean completed = WorkerManager.getInstance().isCompleted(template.getTarget().getTemplateID()); |
|
|
|
|
|
|
|
if (!completed) { |
|
|
|
|
|
|
|
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), |
|
|
|
|
|
|
|
Toolkit.i18nText("Fine-Design_Close_Template_Tip", template.getEditingFILE().getName())); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//参考CloseCurrentTemplateAction,在closeFormat与closeSpecifiedTemplate之前要先设定isCloseCurrent,这样关闭之后才会自动切换tab
|
|
|
|
|
|
|
|
if (checkCurrentClose(template)) { |
|
|
|
|
|
|
|
setIsCloseCurrent(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
closeFormat(template); |
|
|
|
|
|
|
|
closeSpecifiedTemplate(template); |
|
|
|
|
|
|
|
DesignerContext.getDesignerFrame().getContentFrame().repaint(); |
|
|
|
|
|
|
|
isShowList = false; |
|
|
|
isShowList = false; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
//没有点击关闭和ListDown按钮,则切换到点击的模板处
|
|
|
|
//没有点击关闭和ListDown按钮,则切换到点击的模板处
|
|
|
|
closeIconIndex = -1; |
|
|
|
closeIconIndex = -1; |
|
|
|
clodeMode = CLOSE; |
|
|
|
clodeMode = CLOSE; |
|
|
|
int tempSelectedIndex = selectedIndex; |
|
|
|
TemplateTabManager.getInstance().getCurrentOperator().switchTpl(getTemplateIndex(evtX)); |
|
|
|
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(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
isShowList = false; |
|
|
|
isShowList = false; |
|
|
|
} |
|
|
|
} |
|
|
|
MultiTemplateTabPane.this.repaint(); |
|
|
|
MultiTemplateTabPane.this.repaint(); |
|
|
@ -1209,11 +850,6 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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 { |
|
|
|
private class MultiTemplateTabMouseMotionListener implements MouseMotionListener { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 鼠标拖拽 |
|
|
|
* 鼠标拖拽 |
|
|
@ -1237,7 +873,7 @@ public class MultiTemplateTabPane extends JComponent { |
|
|
|
|
|
|
|
|
|
|
|
//看是否需要显示toolTip
|
|
|
|
//看是否需要显示toolTip
|
|
|
|
if (mouseOveredIndex != -1 && isNeedToolTips[mouseOveredIndex - minPaintIndex]) { |
|
|
|
if (mouseOveredIndex != -1 && isNeedToolTips[mouseOveredIndex - minPaintIndex]) { |
|
|
|
setToolTipText(openedTemplate.get(mouseOveredIndex).getEditingFILE().getName()); |
|
|
|
setToolTipText(TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().get(mouseOveredIndex).getEditingFILE().getName()); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
setToolTipText(null); |
|
|
|
setToolTipText(null); |
|
|
|
} |
|
|
|
} |
|
|
|