Browse Source

REPORT-99485 适配FVS暂时维持可用状态

newui
vito 11 months ago
parent
commit
953ea6a77c
  1. 4
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  2. 23
      designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java
  3. 158
      designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java
  4. 59
      designer-base/src/main/java/com/fr/design/file/MultiTemplateTabUtils.java
  5. 18
      designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java
  6. 113
      designer-base/src/test/java/com/fr/design/file/MultiTemplateTabPaneTest.java

4
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java

@ -298,9 +298,7 @@ public class HistoryTemplateListCache implements CallbackEvent {
int index = iterator.nextIndex();
if (size == index + 1 && index > 0) {
//如果删除的是后一个Tab,则定位到前一个
MultiTemplateTabPane.getInstance().setSelectedIndex(
MultiTemplateTabPane.getInstance().calNextShowJTemplateIndex(index - 1));
MultiTemplateTabPane.getInstance().setSelectedIndex(index - 1);
}
}
}

23
designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java

@ -6,10 +6,8 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate;
import com.fr.stable.collections.CollectionUtils;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.Component;
import java.awt.Dimension;
import java.util.List;
@ -23,8 +21,6 @@ import java.util.List;
public class MultiTemplateTabMenuFactory {
private static final int ITEM_SIZE = 25;
private UIScrollPopUpMenu menu = null;
private static MultiTemplateTabMenuFactory INSTANCE = new MultiTemplateTabMenuFactory();
@ -62,29 +58,14 @@ public class MultiTemplateTabMenuFactory {
private UIMenuItem initCloseOther() {
UIMenuItem closeOther = new UIMenuItem(Toolkit.i18nText("Fine-Design_Close_Other_templates"));
closeOther.setHorizontalAlignment(SwingConstants.CENTER);
String currentOperator = getCurrentTabOperatorType();
closeOther.addActionListener(e -> MultiTemplateTabPane.getInstance().closeOtherByOperatorType(currentOperator));
if (MultiTemplateTabPane.getInstance().getOpenedJTemplatesByOperator(currentOperator).size() <= 1) {
closeOther.addActionListener(e -> MultiTemplateTabPane.getInstance().closeOther());
if (MultiTemplateTabPane.getInstance().getOpenedJTemplates().size() <= 1) {
closeOther.setEnabled(false);
}
return closeOther;
}
/**
* 美观用
*/
private JPanel createEmptyRow() {
return new JPanel() {
@Override
public Dimension getPreferredSize() {
Dimension d = super.getPreferredSize();
d.height = 1;
return d;
}
};
}
/**
* 创建 当前分类模板 item数组
*/

158
designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java

@ -50,8 +50,6 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.fine.theme.utils.FineClientProperties.BUTTON_TYPE_TOOLBAR_BUTTON;
import static com.fine.theme.utils.FineUIScale.scale;
@ -227,19 +225,17 @@ public class MultiTemplateTabPane extends Row {
/**
* 判断模板是否可以关闭两个条件1是否满足CloseOption里面的条件在左侧在右侧等2是否和当前正在编辑模板属于同一种模板tab操作类型
*
* @param closeJTemplate
* @param tplIndex
* @param i
* @return
*/
public boolean shouldClose(JTemplate closeJTemplate, int tplIndex, int i) {
public boolean shouldClose(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());
return matchOption;
}
}
@ -365,7 +361,7 @@ public class MultiTemplateTabPane extends Row {
JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
closeTemplate(closeCondition, templates, currentTemplate);
if (openedTemplate.size() == 0) {
if (openedTemplate.isEmpty()) {
DesignerContext.getDesignerFrame().addAndActivateJTemplate();
} else if (option == CloseOption.All) {
//openedTemplate(0)是JVirtualTemplate时需重新打开
@ -380,7 +376,7 @@ public class MultiTemplateTabPane extends Row {
private void closeTemplate(CloseCondition closeCondition, JTemplate<?, ?>[] templates, JTemplate<?, ?> currentTemplate) {
for (int i = 0; i < templates.length; i++) {
if (closeCondition.shouldClose(templates[i], tplIndex, i)) {
if (closeCondition.shouldClose(tplIndex, i)) {
JTemplate<?, ?> jTemplate = templates[i];
if (jTemplate == currentTemplate) {
currentTemplate = option == CloseOption.All ? null : templates[tplIndex];
@ -415,20 +411,18 @@ public class MultiTemplateTabPane extends Row {
/**
* 关闭所有指定模板tab操作类型的模板
*
* @param operatorType
*/
public void closeOtherByOperatorType(String operatorType) {
public void closeOther() {
JTemplate<?, ?> currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false);
if (saveSomeTempaltePane.showSavePane(null, false, true)) {
SaveSomeTemplatePane saveSomeTemplatePane = new SaveSomeTemplatePane(false);
if (saveSomeTemplatePane.showSavePane(null, false, true)) {
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);
closeTemplate(templates, currentEditingTemplate);
DesignerContext.getDesignerFrame().activateJTemplate(currentEditingTemplate);
MultiTemplateTabPane.getInstance().repaint();
@ -439,14 +433,10 @@ public class MultiTemplateTabPane extends Row {
* 关闭指定的非当前编辑模板
*
* @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) {
private static void closeTemplate(JTemplate<?, ?>[] templates, JTemplate<?, ?> currentEditingTemplate) {
for (JTemplate<?, ?> jTemplate : templates) {
if (jTemplate == currentEditingTemplate) {
continue;
}
MultiTemplateTabPane.getInstance().closeFormat(jTemplate);
@ -471,11 +461,6 @@ public class MultiTemplateTabPane extends Row {
}
private String tempalteShowName(JTemplate<?, ?> template) {
return template.getTabShowName(template);
}
public String getTemplateShowNameByIndex(int index) {
JTemplate template = openedTemplate.get(index);
return template.getTabShowName(template);
@ -566,67 +551,14 @@ public class MultiTemplateTabPane extends Row {
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());
List<JTemplate<?, ?>> showTemplates = getOpenedJTemplates();
int num = Math.min(showTemplates.size(), templateNum);
tabWidth = (int) (maxwidth / (num));
if (tabWidth > scale(MAXWIDTH)) {
@ -639,7 +571,6 @@ public class MultiTemplateTabPane extends Row {
public void setIsCloseCurrent(boolean isCloseCurrent) {
this.isCloseCurrent = isCloseCurrent;
}
/**
@ -658,12 +589,9 @@ public class MultiTemplateTabPane extends Row {
Toolkit.i18nText("Fine-Design_Basic_Dialog_Prompt"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION) {
CallbackSaveWorker worker = specifiedTemplate.save();
worker.addSuccessCallback(new Runnable() {
@Override
public void run() {
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName()));
closeTpl(specifiedTemplate);
}
worker.addSuccessCallback(() -> {
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) {
@ -738,9 +666,7 @@ public class MultiTemplateTabPane extends Row {
// 关闭的模板是当前选中的模板时,需要重新计算下一个待展示的模板的index
if (selectedIndex >= maxPaintIndex) {
// selectIndex 不会 <0 因为如果关闭的是打开的最后一个模板,那么关闭之后 openedTemplate.isEmpty() = true
selectedIndex = calNextShowJTemplateIndex(selectedIndex - 1);
} else {
selectedIndex = calNextShowJTemplateIndex(selectedIndex);
selectedIndex--;
}
isCloseCurrent = false;
}
@ -757,23 +683,11 @@ public class MultiTemplateTabPane extends Row {
}
}
/**
* 计算下一个可以展示的模板index
*
* @param currentIndex
* @return
*/
public int calNextShowJTemplateIndex(int currentIndex) {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
return MultiTemplateTabUtils.calShowTemplateIndex(currentIndex, openedTemplate, jTemplate.getTemplateTabOperatorType());
}
private boolean isOverCloseIcon(int evtX) {
boolean isOverCloseIcon = false;
// todo
for (int i = 0; i < startX.length; i++) {
if (evtX >= startX[i] && evtX <= startX[i] + clodeIcon.getIconWidth()) {
for (int x : startX) {
if (evtX >= x && evtX <= x + clodeIcon.getIconWidth()) {
isOverCloseIcon = true;
break;
}
@ -791,7 +705,7 @@ public class MultiTemplateTabPane extends Row {
private int getTemplateIndex(int evtX) {
int textX = scale(LEADING_WIDTH);
for (int i = minPaintIndex; i <= maxPaintIndex; i++) {
int textWidth = showJTemplateTab(openedTemplate.get(i)) ? tabWidth : 0;
int textWidth = tabWidth;
if (evtX >= textX && evtX < textX + textWidth) {
return i;
}
@ -971,28 +885,6 @@ public class MultiTemplateTabPane extends Row {
}
}
/**
* 判断是否显示在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());
}
/**
* 获取所有模板
*
@ -1002,16 +894,6 @@ public class MultiTemplateTabPane extends Row {
return Collections.unmodifiableList(openedTemplate);
}
/**
* 根据tab操作类型进行分类
*
* @return
*/
public Map<String, List<JTemplate<?, ?>>> getOpenedJTemplatesByCategory() {
return openedTemplate.stream()
.collect(Collectors.groupingBy(JTemplate::getTemplateTabOperatorType));
}
/**
* 返回当前tab数量
*

59
designer-base/src/main/java/com/fr/design/file/MultiTemplateTabUtils.java

@ -1,59 +0,0 @@
package com.fr.design.file;
import com.fr.design.mainframe.JTemplate;
import com.fr.general.ComparatorUtils;
import java.util.List;
import java.util.function.Predicate;
public class MultiTemplateTabUtils {
/**
* 计算离currentIndex最近的相同模式的模板index值优先左边
*
* @param currentIndex 当前index
* @param openedTemplate 模板list
* @param type 当前显示模式
* @return
*/
public static int calShowTemplateIndex(int currentIndex, List<JTemplate<?, ?>> openedTemplate, String type) {
if (currentIndex < 0 || currentIndex > openedTemplate.size() - 1) {
return -1;
}
int result = getShowJTemplateTab(currentIndex, openedTemplate, template -> showJTemplateTab(type, template));
if (result != -1) return result;
return getShowJTemplateTab(currentIndex, openedTemplate, template -> !showJTemplateTab(type, template));
}
/**
* 先从左找再从右找离得最近的满足条件的模板
*
* @param currentIndex 当前index
* @param openedTemplate 模板list
* @param predicate
* @return
*/
private static int getShowJTemplateTab(int currentIndex, List<JTemplate<?, ?>> openedTemplate, Predicate<JTemplate<?, ?>> predicate) {
for (int i = currentIndex; i >= 0; i--) {
if (predicate.test(openedTemplate.get(i))) {
return i;
}
}
for (int i = currentIndex + 1; i < openedTemplate.size(); i++) {
if (predicate.test(openedTemplate.get(i))) {
return i;
}
}
return -1;
}
/**
* 是否显示模板
*
* @param type 模板类型
* @param jTemplate 模板
* @return
*/
private static boolean showJTemplateTab(String type, JTemplate<?, ?> jTemplate) {
return ComparatorUtils.equals(type, jTemplate.getTemplateTabOperatorType());
}
}

18
designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java

@ -3,7 +3,6 @@ package com.fr.design.file;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.event.StateChangeListener;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icontainer.UIScrollPane;
@ -15,14 +14,19 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.*;
import javax.swing.AbstractListModel;
import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Window;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
/**
@ -215,7 +219,7 @@ public class SaveSomeTemplatePane extends BasicPane {
int currentIndex = opendedTemplate.indexOf(currentTemplate);
for (int i = 0; i < opendedTemplate.size(); i++) {
//满足关闭条件的才继续判断文件是否发生了改动
boolean needClose = option == null || option.shouldClose(opendedTemplate.get(i), currentIndex, i);
boolean needClose = option == null || option.shouldClose(currentIndex, i);
if (judgeSameTabType) {
needClose &= ComparatorUtils.equals(opendedTemplate.get(i).getTemplateTabOperatorType(), currentTemplate.getTemplateTabOperatorType());
}

113
designer-base/src/test/java/com/fr/design/file/MultiTemplateTabPaneTest.java

@ -14,13 +14,10 @@ import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.plugin.injectable.PluginModule;
import junit.framework.TestCase;
import org.junit.Assert;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.util.ArrayList;
import java.util.List;
public class MultiTemplateTabPaneTest extends TestCase {
@Override
@ -28,61 +25,61 @@ public class MultiTemplateTabPaneTest extends TestCase {
PluginModule.registerAgent(PluginModule.ExtraDesign, new ExtraDesignClassManager());
}
/**
* 当前显示模式A传入index左边(含当前)或右边有模式A的模板返回最近的模式A模板index优先左边
*/
public void test_index_left_has_same_mode_temp() {
//当前显示模式A,传入index左边(含当前)有模式A的模板,返回左边最近的模式A模板index
List<JTemplate<?, ?>> openedTemplateList = new ArrayList<>();
openedTemplateList.add(new A_Mode());
Assert.assertEquals(0, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode"));
openedTemplateList.add(new A_Mode());
Assert.assertEquals(1, MultiTemplateTabUtils.calShowTemplateIndex(1, openedTemplateList, "A_Mode"));
openedTemplateList.add(new B_Mode());
Assert.assertEquals(1, MultiTemplateTabUtils.calShowTemplateIndex(1, openedTemplateList, "A_Mode"));
}
public void test_index_left_has_not_but_right_has_same_mode_temp() {
//当前显示模式A,传入index左边没有但是右边有模式A的模板,返回右边最近的模式A模板index
List<JTemplate<?, ?>> openedTemplateList = new ArrayList<>();
openedTemplateList.add(new B_Mode());
openedTemplateList.add(new A_Mode());
Assert.assertEquals(1, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode"));
openedTemplateList.add(1, new B_Mode());
openedTemplateList.add(new A_Mode());
Assert.assertEquals(2, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode"));
openedTemplateList.add(new A_Mode());
Assert.assertEquals(2, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode"));
}
/**
* 当前显示模式A没有模式A的模板左边(含当前)或者右边有其他模式的模板返回最近的其他模式模式模板index优先左边
*/
public void test_no_same_mode_temp_but_index_left_has_other_mode_temp() {
//当前显示模式A,没有模式A的模板,左边(含当前)有其他模式模板,返回左边最近的其他模式模板index
List<JTemplate<?, ?>> openedTemplateList = new ArrayList<>();
openedTemplateList.add(new B_Mode());
Assert.assertEquals(0, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode"));
openedTemplateList.add(new B_Mode());
Assert.assertEquals(1, MultiTemplateTabUtils.calShowTemplateIndex(1, openedTemplateList, "A_Mode"));
}
public void test_has_no_temp() {
//当前显示模式A,没有模式A的模板,也没有其他模式的模板,返回-1
List<JTemplate<?, ?>> openedTemplateList = new ArrayList<>();
Assert.assertEquals(-1, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode"));
}
public void test_if_index_less_than_zero_or_more_than_open_temp_size() {
//index<0 或者超出openTemplateList.size时,返回-1
List<JTemplate<?, ?>> openedTemplateList = new ArrayList<>();
Assert.assertEquals(-1, MultiTemplateTabUtils.calShowTemplateIndex(-1, openedTemplateList, "A_Mode"));
Assert.assertEquals(-1, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode"));
openedTemplateList.add(new A_Mode());
Assert.assertEquals(-1, MultiTemplateTabUtils.calShowTemplateIndex(1, openedTemplateList, "A_Mode"));
}
// /**
// * 当前显示模式A,传入index左边(含当前)或右边有模式A的模板,返回最近的模式A模板index(优先左边)
// */
// public void test_index_left_has_same_mode_temp() {
// //当前显示模式A,传入index左边(含当前)有模式A的模板,返回左边最近的模式A模板index
// List<JTemplate<?, ?>> openedTemplateList = new ArrayList<>();
// openedTemplateList.add(new A_Mode());
// Assert.assertEquals(0, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode"));
// openedTemplateList.add(new A_Mode());
// Assert.assertEquals(1, MultiTemplateTabUtils.calShowTemplateIndex(1, openedTemplateList, "A_Mode"));
// openedTemplateList.add(new B_Mode());
// Assert.assertEquals(1, MultiTemplateTabUtils.calShowTemplateIndex(1, openedTemplateList, "A_Mode"));
// }
//
// public void test_index_left_has_not_but_right_has_same_mode_temp() {
// //当前显示模式A,传入index左边没有但是右边有模式A的模板,返回右边最近的模式A模板index
// List<JTemplate<?, ?>> openedTemplateList = new ArrayList<>();
// openedTemplateList.add(new B_Mode());
// openedTemplateList.add(new A_Mode());
// Assert.assertEquals(1, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode"));
// openedTemplateList.add(1, new B_Mode());
// openedTemplateList.add(new A_Mode());
// Assert.assertEquals(2, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode"));
// openedTemplateList.add(new A_Mode());
// Assert.assertEquals(2, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode"));
// }
//
// /**
// * 当前显示模式A,没有模式A的模板,左边(含当前)或者右边有其他模式的模板,返回最近的其他模式模式模板index(优先左边)
// */
// public void test_no_same_mode_temp_but_index_left_has_other_mode_temp() {
// //当前显示模式A,没有模式A的模板,左边(含当前)有其他模式模板,返回左边最近的其他模式模板index
// List<JTemplate<?, ?>> openedTemplateList = new ArrayList<>();
// openedTemplateList.add(new B_Mode());
// Assert.assertEquals(0, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode"));
// openedTemplateList.add(new B_Mode());
// Assert.assertEquals(1, MultiTemplateTabUtils.calShowTemplateIndex(1, openedTemplateList, "A_Mode"));
// }
// public void test_has_no_temp() {
// //当前显示模式A,没有模式A的模板,也没有其他模式的模板,返回-1
// List<JTemplate<?, ?>> openedTemplateList = new ArrayList<>();
// Assert.assertEquals(-1, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode"));
// }
//
//
// public void test_if_index_less_than_zero_or_more_than_open_temp_size() {
// //index<0 或者超出openTemplateList.size时,返回-1
// List<JTemplate<?, ?>> openedTemplateList = new ArrayList<>();
// Assert.assertEquals(-1, MultiTemplateTabUtils.calShowTemplateIndex(-1, openedTemplateList, "A_Mode"));
// Assert.assertEquals(-1, MultiTemplateTabUtils.calShowTemplateIndex(0, openedTemplateList, "A_Mode"));
// openedTemplateList.add(new A_Mode());
// Assert.assertEquals(-1, MultiTemplateTabUtils.calShowTemplateIndex(1, openedTemplateList, "A_Mode"));
// }
private class A_Mode extends AbstractTestMode {
public String getTemplateTabOperatorType() {

Loading…
Cancel
Save