Browse Source
* commit '3ac44c646c567841fe85efcae3dae01a57d2d58a': REPORT-92333 frm图片控件,默认图片是中文 EPORT-97225 【H5控件增强】关于文本类控件的新功能,设计器设置项的屏蔽 格式化处理 添加注释 REPORT-95741 关闭自动新建的cpt模板,回到了fvs-tab;预期是打开下一张cpt/frmfeature/x
superman
1 year ago
14 changed files with 381 additions and 54 deletions
@ -0,0 +1,59 @@
|
||||
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()); |
||||
} |
||||
} |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 4.2 KiB |
@ -0,0 +1,289 @@
|
||||
package com.fr.design.file; |
||||
|
||||
import com.fr.design.DesignModelAdapter; |
||||
import com.fr.design.ExtraDesignClassManager; |
||||
import com.fr.design.designer.TargetComponent; |
||||
import com.fr.design.gui.frpane.HyperlinkGroupPane; |
||||
import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; |
||||
import com.fr.design.gui.imenu.UIMenuItem; |
||||
import com.fr.design.mainframe.AuthorityEditPane; |
||||
import com.fr.design.mainframe.BaseUndoState; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.design.mainframe.template.info.TemplateProcessInfo; |
||||
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 |
||||
protected void setUp() throws Exception { |
||||
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")); |
||||
} |
||||
|
||||
private class A_Mode extends AbstractTestMode { |
||||
public String getTemplateTabOperatorType() { |
||||
return "A_Mode"; |
||||
} |
||||
} |
||||
|
||||
private class B_Mode extends AbstractTestMode { |
||||
public String getTemplateTabOperatorType() { |
||||
return "B_Mode"; |
||||
} |
||||
} |
||||
|
||||
private abstract class AbstractTestMode extends JTemplate { |
||||
public AbstractTestMode() { |
||||
} |
||||
|
||||
@Override |
||||
public void copy() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public boolean paste() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public boolean cut() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public AuthorityEditPane createAuthorityEditPane() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public JPanel getEastUpPane() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public JPanel getEastDownPane() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public ToolBarDef[] toolbars4Target() { |
||||
return new ToolBarDef[0]; |
||||
} |
||||
|
||||
@Override |
||||
public JPanel[] toolbarPanes4Form() { |
||||
return new JPanel[0]; |
||||
} |
||||
|
||||
@Override |
||||
public JComponent[] toolBarButton4Form() { |
||||
return new JComponent[0]; |
||||
} |
||||
|
||||
@Override |
||||
public JComponent toolBar4Authority() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public int getToolBarHeight() { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
public void refreshEastPropertiesPane() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public TargetComponent getCurrentElementCasePane() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public JComponent getCurrentReportComponentPane() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public TemplateProcessInfo getProcessInfo() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void setJTemplateResolution(int resolution) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public int getJTemplateResolution() { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
protected JComponent createCenterPane() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void removeTemplateSelection() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void refreshContainer() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void removeParameterPaneSelection() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void setScale(int resolution) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public int getScale() { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
public int selfAdaptUpdate() { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
protected DesignModelAdapter createDesignModel() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public UIMenuItem[] createMenuItem4Preview() { |
||||
return new UIMenuItem[0]; |
||||
} |
||||
|
||||
@Override |
||||
protected BaseUndoState<?> createUndoState() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public String suffix() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public ShortCut[] shortcut4TemplateMenu() { |
||||
return new ShortCut[0]; |
||||
} |
||||
|
||||
@Override |
||||
public ShortCut[] shortCuts4Authority() { |
||||
return new ShortCut[0]; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isJWorkBook() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public HyperlinkGroupPane getHyperLinkPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public HyperlinkGroupPane getHyperLinkPaneNoPop(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void setAuthorityMode(boolean isUpMode) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public Icon getIcon() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public String route() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
protected void applyUndoState(BaseUndoState baseUndoState) { |
||||
|
||||
} |
||||
|
||||
} |
||||
} |
Loading…
Reference in new issue