Destiny.Lin
2 years ago
47 changed files with 985 additions and 194 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()); |
||||
} |
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.fr.design.mainframe.mobile.processor; |
||||
|
||||
import com.fr.stable.fun.mark.API; |
||||
|
||||
/** |
||||
* 移动端Form控件,样式模板,通用属性替换接口 |
||||
* |
||||
* @author Coral.Chen |
||||
* @since 11.0 |
||||
* Created on 2023/4/11 |
||||
*/ |
||||
@API(level = MobileStyleDefinePaneCreator.CURRENT_LEVEL) |
||||
public abstract class AbstractMobileStyleDefinePaneCreator implements MobileStyleDefinePaneCreator { |
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public int layerIndex() { |
||||
return DEFAULT_LAYER_INDEX; |
||||
} |
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.fr.design.mainframe.mobile.processor; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.form.ui.mobile.MobileCommonExtraStyle; |
||||
import com.fr.form.ui.mobile.MobileStyle; |
||||
import com.fr.stable.fun.mark.Immutable; |
||||
import org.jetbrains.annotations.Nullable; |
||||
|
||||
/** |
||||
* 移动端Form控件,样式模板,通用属性替换接口 |
||||
* |
||||
* @author Coral.Chen |
||||
* @since 11.0 |
||||
* Created on 2023/4/11 |
||||
*/ |
||||
public interface MobileStyleDefinePaneCreator extends Immutable { |
||||
String XML_TAG = "MobileStyleDefinePaneCreator"; |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
/** |
||||
* <p> 创建通用属性样式界面,可替换{@link com.fr.design.mainframe.mobile.ui.MobileStyleDefinePane} |
||||
* <p> 每种样式的通用属性面板是一样的 |
||||
* |
||||
* @param widget 控件 |
||||
* @param customDefinePane 自定义面板 |
||||
* @param mobileStyle 移动端样式 |
||||
* @return |
||||
*/ |
||||
@Nullable BasicBeanPane<MobileStyle> createBaseBeanPane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customDefinePane, Class<? extends MobileStyle> mobileStyle); |
||||
|
||||
/** |
||||
* 替换通用属性面板,注册额外属性 |
||||
* |
||||
* @return 属性类 |
||||
*/ |
||||
@Nullable Class<? extends MobileCommonExtraStyle> classForCommonExtraStyle(Widget widget); |
||||
} |
@ -1 +1,2 @@
|
||||
Fine-Designer_Login=i7hP48WAcuTrmxfN |
||||
Fine-Designer_Reu_Share_CERTIFICATE_PUBLIC_KEY=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCtsz62CPSWXZE/IYZRiAuTSZkw1WOwer8+JFktK0uKLAUuQoBr+UjAMFtRA8W7JgKMDwZy/2liEAiXEOSPU/hrdV8DtT541LnGi1X/hXiRwuttPWYN3L2GYm/d5blU+FBNwghBIrdAxXTzYBc6P4KL/oYXnMdTIrkz8tYkG3QoFQIDAQAB |
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,49 @@
|
||||
package com.fr.design.file; |
||||
|
||||
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; |
||||
import com.fr.file.filetree.FileNode; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
|
||||
/** |
||||
* |
||||
* @author Levy.Xie |
||||
* @version 11.0 |
||||
* Created by Levy.Xie on 2023/05/23 |
||||
*/ |
||||
public class FileOperationHelperTest { |
||||
|
||||
@Test |
||||
public void testIsSubDirectory() { |
||||
FileNode sourceNode1 = new FileNode("/usr/local/webroot/reportlets", true); |
||||
FileNode sourceNode2 = new FileNode("/usr/local/webroot/reportlets/demo", true); |
||||
FileNode sourceNode3 = new FileNode("/usr/local/webroot/reportlets/doc", true); |
||||
FileNode sourceNode4 = new FileNode("/usr/local/webroot/reportlets/doc/1.cpt", false); |
||||
FileNode sourceNode5 = new FileNode("/usr/local/webroot/reportlets/demo/test", true); |
||||
FileNode sourceNode6 = new FileNode("/usr/local/webroot/reportlets/demo/test", false); |
||||
FileNode sourceNode7 = new FileNode("/usr/local/webroot/reportlets/demo/test123", true); |
||||
FileNode sourceNode8 = new FileNode("/usr/local/webroot/reportlets/../reportlets/demo/test", true); |
||||
FileNode sourceNode9 = new FileNode("/usr/local/webroot/reportlets/../reportlets/demo/test/c", true); |
||||
|
||||
FileNode targetNode = new FileNode("/usr/local/webroot/reportlets/demo/test", true); |
||||
|
||||
Assert.assertTrue(FileOperationHelper.getInstance().isSubDirectoryOrSame(sourceNode1, targetNode)); |
||||
Assert.assertTrue(FileOperationHelper.getInstance().isSubDirectoryOrSame(sourceNode2, targetNode)); |
||||
Assert.assertFalse(FileOperationHelper.getInstance().isSubDirectoryOrSame(sourceNode3, targetNode)); |
||||
Assert.assertFalse(FileOperationHelper.getInstance().isSubDirectoryOrSame(sourceNode4, targetNode)); |
||||
Assert.assertTrue(FileOperationHelper.getInstance().isSubDirectoryOrSame(sourceNode5, targetNode)); |
||||
Assert.assertFalse(FileOperationHelper.getInstance().isSubDirectoryOrSame(sourceNode6, targetNode)); |
||||
Assert.assertFalse(FileOperationHelper.getInstance().isSubDirectoryOrSame(sourceNode7, targetNode)); |
||||
Assert.assertTrue(FileOperationHelper.getInstance().isSubDirectoryOrSame(sourceNode8, targetNode)); |
||||
Assert.assertFalse(FileOperationHelper.getInstance().isSubDirectoryOrSame(sourceNode9, targetNode)); |
||||
|
||||
|
||||
ExpandMutableTreeNode treeNode1 = new ExpandMutableTreeNode(sourceNode1); |
||||
ExpandMutableTreeNode treeNode2 = new ExpandMutableTreeNode(sourceNode2); |
||||
ExpandMutableTreeNode treeNode3 = new ExpandMutableTreeNode(sourceNode3); |
||||
ExpandMutableTreeNode treeNode4 = new ExpandMutableTreeNode(sourceNode4); |
||||
Assert.assertTrue(FileOperationHelper.getInstance().isSubDirectoryOrSame(new ExpandMutableTreeNode[]{treeNode1, treeNode2, treeNode3}, targetNode)); |
||||
Assert.assertFalse(FileOperationHelper.getInstance().isSubDirectoryOrSame(new ExpandMutableTreeNode[]{treeNode3, treeNode4}, targetNode)); |
||||
} |
||||
} |
@ -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