|
|
|
@ -13,16 +13,13 @@ import com.fr.design.gui.imenu.UIScrollPopUpMenu;
|
|
|
|
|
import com.fr.design.i18n.DesignSizeI18nManager; |
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
import com.fr.design.mainframe.JTemplate; |
|
|
|
|
import com.fr.design.mainframe.TemplateSavingChecker; |
|
|
|
|
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.file.FILE; |
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
|
import com.fr.general.IOUtils; |
|
|
|
|
import com.fr.stable.Constants; |
|
|
|
|
import com.fr.third.javax.annotation.Nonnull; |
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
import javax.swing.ButtonModel; |
|
|
|
@ -31,10 +28,8 @@ import javax.swing.ImageIcon;
|
|
|
|
|
import javax.swing.JComponent; |
|
|
|
|
import javax.swing.JMenu; |
|
|
|
|
import javax.swing.JMenuItem; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.JSeparator; |
|
|
|
|
import javax.swing.MenuElement; |
|
|
|
|
import javax.swing.SwingConstants; |
|
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
|
import javax.swing.plaf.basic.BasicMenuItemUI; |
|
|
|
|
import java.awt.AWTEvent; |
|
|
|
@ -48,7 +43,6 @@ import java.awt.Graphics2D;
|
|
|
|
|
import java.awt.RenderingHints; |
|
|
|
|
import java.awt.event.AWTEventListener; |
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
import java.awt.event.MouseListener; |
|
|
|
@ -58,6 +52,7 @@ import java.awt.geom.GeneralPath;
|
|
|
|
|
import java.awt.geom.Line2D; |
|
|
|
|
import java.awt.geom.Path2D; |
|
|
|
|
import java.awt.geom.RoundRectangle2D; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 改个名字,一个拼写 n 个错误 |
|
|
|
@ -238,90 +233,60 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Dimension getPreferredSize() { |
|
|
|
|
Dimension dimension = super.getPreferredSize(); |
|
|
|
|
dimension.height = HEIGHT; |
|
|
|
|
return dimension; |
|
|
|
|
/** |
|
|
|
|
* 留作兼容 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Deprecated |
|
|
|
|
public JTemplate getSelectedFile() { |
|
|
|
|
return TemplateTabManager.getInstance().getSelectedFile(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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) { |
|
|
|
|
//int tabSize = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size();
|
|
|
|
|
int tabSize = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size(); |
|
|
|
|
if (tabSize == 1) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (!TemplateSavingChecker.check()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false); |
|
|
|
|
//点击关闭其他模板,并且点击确定保存
|
|
|
|
|
if (saveSomeTempaltePane.showSavePane()) { |
|
|
|
|
JTemplate<?, ?>[] panes = new JTemplate<?, ?>[tabSize]; |
|
|
|
|
for (int i = 0; i < tabSize; i++) { |
|
|
|
|
panes[i] = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().get(i); |
|
|
|
|
} |
|
|
|
|
for (int i = 0; i < panes.length; i++) { |
|
|
|
|
if (i != TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex()) { |
|
|
|
|
JTemplate<?, ?> jTemplate = panes[i]; |
|
|
|
|
//判断关闭的模板是不是格式刷的被参照的模板
|
|
|
|
|
TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().remove(jTemplate); |
|
|
|
|
TemplateTabManager.getInstance().closeFormat(jTemplate); |
|
|
|
|
HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate); |
|
|
|
|
closeAndFreeLock(jTemplate); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
|
|
|
|
TemplateTabManager.getInstance().resetSelectIndex(currentTemplate); |
|
|
|
|
THIS.repaint(); |
|
|
|
|
} |
|
|
|
|
//如果取消保存了,则不关闭其他模板
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
if (TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size() == 1) { |
|
|
|
|
closeOther.setEnabled(false); |
|
|
|
|
} |
|
|
|
|
return closeOther; |
|
|
|
|
/** |
|
|
|
|
* 关闭掉当前已打开文件列表中指定的文件 |
|
|
|
|
* |
|
|
|
|
* @param file 指定的文件 |
|
|
|
|
*/ |
|
|
|
|
@Deprecated |
|
|
|
|
public void closeFileTemplate(FILE file) { |
|
|
|
|
TemplateTabManager.getInstance().closeFileTemplate(file); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private UIMenuItem[] createListDownTemplate() { |
|
|
|
|
int templateTabCount = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().size(); |
|
|
|
|
UIMenuItem[] templates = new UIMenuItem[templateTabCount]; |
|
|
|
|
for (int i = 0; i < templateTabCount; i++) { |
|
|
|
|
final int index = i; |
|
|
|
|
final JTemplate tem = TemplateTabManager.getInstance().getCurrentOperator().getOpenedJTemplates().get(i); |
|
|
|
|
templates[i] = new UIMenuItem(tempalteShowName(tem), tem.getIcon()); |
|
|
|
|
templates[i].setUI(new UIListDownItemUI()); |
|
|
|
|
setListDownItemPreferredSize(templates[i]); |
|
|
|
|
if (i == TemplateTabManager.getInstance().getCurrentOperator().getSelectIndex()) { |
|
|
|
|
//画选中的高亮
|
|
|
|
|
templates[i].setBackground(UIConstants.SHADOW_CENTER); |
|
|
|
|
} |
|
|
|
|
templates[i].addActionListener(new ActionListener() { |
|
|
|
|
@Override |
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
TemplateTabManager.getInstance().getCurrentOperator().setSelectIndex(index); |
|
|
|
|
tem.activeNewJTemplate(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
return templates; |
|
|
|
|
/** |
|
|
|
|
* 刷新打开模板 |
|
|
|
|
* |
|
|
|
|
* @param history 模板 |
|
|
|
|
*/ |
|
|
|
|
@Deprecated |
|
|
|
|
public void refreshOpenedTemplate(List<JTemplate<?, ?>> history) { |
|
|
|
|
TemplateTabManager.getInstance().refreshOpenedTemplate(history); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setListDownItemPreferredSize(UIMenuItem item) { |
|
|
|
|
Dimension dimension = item.getPreferredSize(); |
|
|
|
|
dimension.height = LIST_DOWN_HEIGHT; |
|
|
|
|
item.setPreferredSize(dimension); |
|
|
|
|
/** |
|
|
|
|
* 设置临时Template |
|
|
|
|
* @param auotCreate |
|
|
|
|
*/ |
|
|
|
|
@Deprecated |
|
|
|
|
public void setTemTemplate(JTemplate<?, ?> auotCreate) { |
|
|
|
|
TemplateTabManager.getInstance().setTemTemplate(auotCreate); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设置选中模板索引 |
|
|
|
|
* @param index |
|
|
|
|
*/ |
|
|
|
|
@Deprecated |
|
|
|
|
public void setSelectedIndex(int index) { |
|
|
|
|
TemplateTabManager.getInstance().getCurrentOperator().setSelectIndex(index); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Dimension getPreferredSize() { |
|
|
|
|
Dimension dimension = super.getPreferredSize(); |
|
|
|
|
dimension.height = HEIGHT; |
|
|
|
|
return dimension; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String tempalteShowName(JTemplate<?, ?> template) { |
|
|
|
|
return TemplateTabManager.getInstance().getTemplateShowName(template); |
|
|
|
@ -682,14 +647,23 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
generalPath.closePath(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设置是否关闭当前打开的模板 |
|
|
|
|
* @param isCloseCurrent |
|
|
|
|
*/ |
|
|
|
|
@Deprecated |
|
|
|
|
public void setIsCloseCurrent(boolean isCloseCurrent) { |
|
|
|
|
TemplateTabManager.getInstance().setCloseCurrent(isCloseCurrent); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void closeAndFreeLock(@Nonnull JTemplate<?, ?> template) { |
|
|
|
|
FILE file = template.getEditingFILE(); |
|
|
|
|
// 只有是环境内的文件,才执行释放锁
|
|
|
|
|
if (file != null && file.isEnvFile()) { |
|
|
|
|
// release lock
|
|
|
|
|
TemplateResourceManager.getResource().closeTemplate(file.getPath()); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 关闭模板 |
|
|
|
|
* |
|
|
|
|
* @param specifiedTemplate 模板 |
|
|
|
|
*/ |
|
|
|
|
@Deprecated |
|
|
|
|
public void closeSpecifiedTemplate(JTemplate<?, ?> specifiedTemplate) { |
|
|
|
|
TemplateTabManager.getInstance().closeSpecifiedTemplate(specifiedTemplate); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -710,6 +684,40 @@ public class MultiTemplateTabPane extends JComponent {
|
|
|
|
|
return evtX >= (maxWidth + SMALLGAP) && evtX <= (getWidth() - SMALLGAP); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 后台关闭当前编辑模板 |
|
|
|
|
*/ |
|
|
|
|
@Deprecated |
|
|
|
|
public void closeCurrentTpl() { |
|
|
|
|
TemplateTabManager.getInstance().closeCurrentTpl(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 关闭模板 |
|
|
|
|
* |
|
|
|
|
* @param closedTemplate 模板 |
|
|
|
|
*/ |
|
|
|
|
@Deprecated |
|
|
|
|
public void closeFormat(JTemplate closedTemplate) { |
|
|
|
|
TemplateTabManager.getInstance().closeFormat(closedTemplate); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 关闭掉一个模板之后激活新的待显示模板 |
|
|
|
|
*/ |
|
|
|
|
@Deprecated |
|
|
|
|
public void activePrevTemplateAfterClose() { |
|
|
|
|
TemplateTabManager.getInstance().activePrevTemplateAfterClose(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 处理自动新建的模板 在切换时的处理 |
|
|
|
|
*/ |
|
|
|
|
@Deprecated |
|
|
|
|
public void doWithtemTemplate() { |
|
|
|
|
TemplateTabManager.getInstance().doWithtemTemplate(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int getTemplateIndex(int evtX) { |
|
|
|
|
int textX = 0; |
|
|
|
|