diff --git a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java index 269918448..99cd17916 100644 --- a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java @@ -11,6 +11,7 @@ import com.fr.design.gui.imenu.UIScrollPopUpMenu; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; +import com.fr.design.utils.DesignUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.file.FILE; @@ -35,7 +36,6 @@ import java.awt.AlphaComposite; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; -import java.awt.Font; import java.awt.GradientPaint; import java.awt.Graphics; import java.awt.Graphics2D; @@ -136,7 +136,7 @@ public class MutilTempalteTabPane extends JComponent { this.addMouseMotionListener(new MultiTemplateTabMouseMotionListener()); this.setBorder(null); this.setForeground(new Color(58, 56, 58)); - this.setFont(new Font(Toolkit.i18nText("Fine-Design_Basic_Song_TypeFace"), 0, 12)); + this.setFont(DesignUtils.getDefaultGUIFont().applySize(12)); openedTemplate = HistoryTemplateListCache.getInstance().getHistoryList(); selectedIndex = openedTemplate.size() - 1; AWTEventListener awt = new AWTEventListener() { diff --git a/designer-base/src/main/java/com/fr/design/fun/MobileParamUIProvider.java b/designer-base/src/main/java/com/fr/design/fun/MobileParamUIProvider.java new file mode 100644 index 000000000..a8d8acc4e --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/MobileParamUIProvider.java @@ -0,0 +1,37 @@ +package com.fr.design.fun; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.form.ui.mobile.MobileParamStyle; +import com.fr.stable.fun.mark.Mutable; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/12/30 + */ + +public interface MobileParamUIProvider extends Mutable { + String XML_TAG = "MobileParamUIProvider"; + + int CURRENT_LEVEL = 1; + + + /** + * 扩展项的参数面板样式 + * @return + */ + Class classForMobileParamStyle(); + + /** + * 移动端参数面板中扩展项的面板 + * @return + */ + Class> classForMobileParamAppearance(); + + /** + * 扩展项的名称描述 + * @return + */ + String displayName(); + +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileParamUIProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileParamUIProvider.java new file mode 100644 index 000000000..c31e74f7f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileParamUIProvider.java @@ -0,0 +1,25 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.MobileParamUIProvider; +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/12/30 + */ +@API(level = MobileParamUIProvider.CURRENT_LEVEL) +public abstract class AbstractMobileParamUIProvider extends AbstractProvider implements MobileParamUIProvider { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java index 435d5a465..f3771a0f9 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java @@ -13,6 +13,8 @@ import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.workspace.WorkContext; +import java.util.HashMap; +import java.util.Map; import javax.swing.BorderFactory; import javax.swing.JTree; import javax.swing.tree.DefaultTreeCellRenderer; @@ -21,7 +23,6 @@ import javax.swing.tree.TreePath; import java.awt.Color; import java.awt.Component; import java.io.File; -import java.util.ArrayList; import java.util.Arrays; /* @@ -199,14 +200,14 @@ public class EnvFileTree extends RefreshableJTree { // 用FileNodeFilter过滤一下 if (filter != null) { - java.util.List tList = new ArrayList(); - for (int i = 0; i < resFns.length; i++) { - if (filter.accept(resFns[i])) { - tList.add(resFns[i]); + Map fileNodes = new HashMap<>(); + for (FileNode fileNode : resFns) { + // war包部署下会生成两份classes目录,需要去重一下 + if (filter.accept(fileNode)) { + fileNodes.put(fileNode.getName(), fileNode); } } - - resFns = tList.toArray(new FileNode[tList.size()]); + resFns = fileNodes.values().toArray(new FileNode[fileNodes.size()]); } Arrays.sort(resFns, new FileNodeComparator(FRContext.getFileNodes().getSupportedTypes())); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/DefaultMobileParamUIProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/DefaultMobileParamUIProvider.java new file mode 100644 index 000000000..3448ab202 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/DefaultMobileParamUIProvider.java @@ -0,0 +1,33 @@ +package com.fr.design.mainframe.mobile.provider; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.fun.impl.AbstractMobileParamUIProvider; +import com.fr.design.mainframe.mobile.ui.DefaultMobileParamDefinePane; +import com.fr.form.ui.mobile.MobileParamStyle; +import com.fr.form.ui.mobile.impl.DefaultMobileParameterStyle; +import com.fr.locale.InterProviderFactory; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/1/4 + */ +public class DefaultMobileParamUIProvider extends AbstractMobileParamUIProvider { + + @Override + public Class classForMobileParamStyle() { + return DefaultMobileParameterStyle.class; + } + + @Override + public Class> classForMobileParamAppearance() { + return DefaultMobileParamDefinePane.class; + } + + @Override + public String displayName() { + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Report_DEFAULT"); + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/EmptyMobileParamUIProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/EmptyMobileParamUIProvider.java new file mode 100644 index 000000000..46ed13071 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/EmptyMobileParamUIProvider.java @@ -0,0 +1,43 @@ +package com.fr.design.mainframe.mobile.provider; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.fun.impl.AbstractMobileParamUIProvider; +import com.fr.design.mainframe.mobile.ui.EmptyMobileParamDefinePane; +import com.fr.form.ui.mobile.MobileParamStyle; +import com.fr.report.fun.MobileParamStyleProvider; +import com.fr.report.mobile.EmptyMobileParamStyle; + +/** + * 作为MobileParamStyleProvider接口实现兼容转换层 + * + * @author hades + * @version 10.0 + * Created by hades on 2021/1/4 + */ +public class EmptyMobileParamUIProvider extends AbstractMobileParamUIProvider { + + private MobileParamStyleProvider styleProvider; + + public EmptyMobileParamUIProvider(MobileParamStyleProvider styleProvider) { + this.styleProvider = styleProvider; + } + + @Override + public Class classForMobileParamStyle() { + return EmptyMobileParamStyle.class; + } + + @Override + public Class> classForMobileParamAppearance() { + return EmptyMobileParamDefinePane.class; + } + + @Override + public String displayName() { + return styleProvider.descriptor(); + } + + public MobileParamStyleProvider getStyleProvider() { + return styleProvider; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileParamDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileParamDefinePane.java new file mode 100644 index 000000000..838e8f599 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileParamDefinePane.java @@ -0,0 +1,42 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.form.ui.mobile.MobileParamStyle; +import com.fr.form.ui.mobile.impl.DefaultMobileParameterStyle; +import java.awt.BorderLayout; +import javax.swing.JPanel; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/1/4 + */ +public class DefaultMobileParamDefinePane extends BasicBeanPane { + + public DefaultMobileParamDefinePane() { + initComponents(); + } + + private void initComponents() { + this.setLayout(new BorderLayout()); + JPanel centerPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Set")); + this.add(centerPane); + } + + @Override + public void populateBean(MobileParamStyle ob) { + // do nothing + } + + @Override + public MobileParamStyle updateBean() { + return new DefaultMobileParameterStyle(); + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/EmptyMobileParamDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/EmptyMobileParamDefinePane.java new file mode 100644 index 000000000..b973d599a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/EmptyMobileParamDefinePane.java @@ -0,0 +1,47 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.form.ui.mobile.MobileParamStyle; +import com.fr.report.fun.MobileParamStyleProvider; +import com.fr.report.mobile.EmptyMobileParamStyle; +import java.awt.BorderLayout; +import javax.swing.JPanel; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/1/4 + */ +public class EmptyMobileParamDefinePane extends BasicBeanPane { + + private final MobileParamStyleProvider styleProvider; + + public EmptyMobileParamDefinePane(MobileParamStyleProvider styleProvider) { + this.styleProvider = styleProvider; + initComponents(); + } + + private void initComponents() { + this.setLayout(new BorderLayout()); + JPanel centerPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Set")); + this.add(centerPane); + } + + + @Override + public void populateBean(MobileParamStyle ob) { + + } + + @Override + public MobileParamStyle updateBean() { + return new EmptyMobileParamStyle(styleProvider); + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileParamDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileParamDefinePane.java new file mode 100644 index 000000000..cd9ee2202 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileParamDefinePane.java @@ -0,0 +1,55 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.fun.MobileParamUIProvider; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.mobile.provider.EmptyMobileParamUIProvider; +import com.fr.form.ui.mobile.MobileParamStyle; +import com.fr.general.ComparatorUtils; +import com.fr.invoke.Reflect; +import com.fr.report.mobile.EmptyMobileParamStyle; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/1/4 + */ +public class MobileParamDefinePane extends BasicBeanPane { + + private BasicBeanPane customBeanPane; + + public MobileParamDefinePane(MobileParamUIProvider provider) { + if (provider == null || provider.classForMobileParamAppearance() == null || provider.classForMobileParamAppearance() == null) { + return; + } + if (ComparatorUtils.equals(provider.classForMobileParamStyle(), EmptyMobileParamStyle.class)) { + EmptyMobileParamUIProvider emptyMobileParamUIProvider = (EmptyMobileParamUIProvider) provider; + this.customBeanPane = Reflect.on(provider.classForMobileParamAppearance()).create(emptyMobileParamUIProvider.getStyleProvider()).get(); + } else { + this.customBeanPane = Reflect.on(provider.classForMobileParamAppearance()).create().get(); + } + initComponents(); + } + + private void initComponents() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.add(customBeanPane); + } + + @Override + public void populateBean(MobileParamStyle ob) { + this.customBeanPane.populateBean(ob); + } + + @Override + public MobileParamStyle updateBean() { + + return this.customBeanPane.updateBean(); + + } + + @Override + protected String title4PopupWindow() { + return "MobileParamDefinePane"; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileParamSettingPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileParamSettingPane.java new file mode 100644 index 000000000..d2a358c19 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileParamSettingPane.java @@ -0,0 +1,150 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.BasicPane; +import com.fr.design.fun.MobileParamUIProvider; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.mobile.provider.DefaultMobileParamUIProvider; +import com.fr.design.mainframe.mobile.provider.EmptyMobileParamUIProvider; +import com.fr.form.ui.container.WParameterLayout; +import com.fr.form.ui.mobile.MobileParamStyle; +import com.fr.general.ComparatorUtils; +import com.fr.report.ExtraReportClassManager; +import com.fr.report.fun.MobileParamStyleProvider; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import javax.swing.DefaultListCellRenderer; +import javax.swing.DefaultListModel; +import javax.swing.JList; +import javax.swing.JPanel; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/1/4 + */ +public class MobileParamSettingPane extends BasicPane { + + private DefaultListModel listModel; + private JPanel right; + private CardLayout card; + private JList paramStyleList; + + + private Map> map = new HashMap<>(); + + + public MobileParamSettingPane() { + initComponents(); + } + + + private void initComponents() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + listModel = new DefaultListModel<>(); + card = new CardLayout(); + right = FRGUIPaneFactory.createCardLayout_S_Pane(); + right.setLayout(card); + MobileParamUIProvider[] mobileParamUIProviders = getMobileParamUIProviders(); + for (MobileParamUIProvider provider : mobileParamUIProviders) { + addShowPane(provider); + } + initLeftPane(); + initRightPane(); + } + + private void initLeftPane() { + paramStyleList = new JList<>(listModel); + paramStyleList.setCellRenderer(new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof MobileParamStyle) { + MobileParamStyle style = (MobileParamStyle) value; + this.setText(style.toString()); + } + return this; + } + }); + paramStyleList.addListSelectionListener(e -> { + String selectedValue = (String) paramStyleList.getSelectedValue(); + card.show(right, selectedValue); + }); + JPanel leftPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + leftPane.add(paramStyleList); + leftPane.setPreferredSize(new Dimension(100, 500)); + this.add(leftPane, BorderLayout.WEST); + } + + private void initRightPane() { + JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + JPanel attrConfPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + centerPane.setPreferredSize(new Dimension(500, 500)); + attrConfPane.add(right, BorderLayout.CENTER); + centerPane.add(attrConfPane, BorderLayout.CENTER); + this.add(centerPane, BorderLayout.CENTER); + } + + + public void populate(MobileParamStyle mobileParamStyle) { + if (mobileParamStyle != null) { + MobileParamUIProvider[] mobileParamUIProviders = getMobileParamUIProviders(); + for (int i = 0; i < mobileParamUIProviders.length; i++) { + MobileParamUIProvider provider = mobileParamUIProviders[i]; + if (ComparatorUtils.equals(mobileParamStyle.disPlayName(), provider.displayName())) { + String displayName = provider.displayName(); + paramStyleList.setSelectedIndex(i); + map.get(displayName).populateBean(mobileParamStyle); + card.show(right, displayName); + return; + } + } + } + paramStyleList.setSelectedIndex(0); + } + + private void addShowPane(MobileParamUIProvider provider) { + String displayName = provider.displayName(); + listModel.addElement(provider.displayName()); + BasicBeanPane paramStyleBasicBeanPane = new MobileParamDefinePane(provider); + right.add(displayName, paramStyleBasicBeanPane); + map.put(displayName, paramStyleBasicBeanPane); + } + + public MobileParamStyle update() { + return map.get(paramStyleList.getSelectedValue()).updateBean(); + } + + + @Override + protected String title4PopupWindow() { + return null; + } + + private MobileParamUIProvider[] getMobileParamUIProviders() { + Set paramUIProviders = ExtraDesignClassManager.getInstance().getArray(MobileParamUIProvider.XML_TAG); + List result = new ArrayList<>(); + result.add(new DefaultMobileParamUIProvider()); + result.addAll(paramUIProviders); + Set nameSets = paramUIProviders.stream().map(MobileParamUIProvider::displayName).collect(Collectors.toSet()); + // 兼容老接口 + Set paramStyleProviders = ExtraReportClassManager.getInstance().getArray(MobileParamStyleProvider.MARK_STRING); + + paramStyleProviders = paramStyleProviders.stream().filter(provider -> !nameSets.contains(provider.descriptor())).collect(Collectors.toSet()); + + for (MobileParamStyleProvider provider : paramStyleProviders) { + result.add(new EmptyMobileParamUIProvider(provider)); + } + + return result.toArray(new MobileParamUIProvider[0]); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/widget/wrappers/MobileParamWrapper.java b/designer-base/src/main/java/com/fr/design/mainframe/widget/wrappers/MobileParamWrapper.java new file mode 100644 index 000000000..d4f2b8129 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/widget/wrappers/MobileParamWrapper.java @@ -0,0 +1,34 @@ +package com.fr.design.mainframe.widget.wrappers; + +import com.fr.design.Exception.ValidationException; +import com.fr.design.designer.properties.Decoder; +import com.fr.design.designer.properties.Encoder; +import com.fr.locale.InterProviderFactory; +import org.jetbrains.annotations.Nullable; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/1/4 + */ +public class MobileParamWrapper implements Encoder, Decoder { + + @Nullable + @Override + public Object decode(String txt) { + return null; + } + + @Override + public void validate(String txt) throws ValidationException { + // do nothing + } + + @Override + public String encode(Object v) { + if (v == null) { + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Report_DEFAULT"); + } + return v.toString(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmUtils.java b/designer-base/src/main/java/com/fr/design/upm/UpmUtils.java index d27b6721a..e97a5826a 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmUtils.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmUtils.java @@ -3,6 +3,7 @@ package com.fr.design.upm; import com.fr.common.annotations.Negative; import com.fr.config.ServerPreferenceConfig; import com.fr.general.CloudCenter; +import com.fr.general.GeneralContext; import com.fr.stable.StringUtils; import java.util.ArrayList; @@ -31,6 +32,7 @@ public class UpmUtils { Map map4Tpl = new HashMap<>(); map4Tpl.put("version", ServerPreferenceConfig.getInstance().getOptimizedUPMVersion()); map4Tpl.put("new_version", fetchLatestVersion()); + map4Tpl.put("language", GeneralContext.getLocale().toString()); return map4Tpl; } diff --git a/designer-base/src/test/java/com/fr/design/upm/UpmUtilsTest.java b/designer-base/src/test/java/com/fr/design/upm/UpmUtilsTest.java new file mode 100644 index 000000000..31119d049 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/upm/UpmUtilsTest.java @@ -0,0 +1,57 @@ +package com.fr.design.upm; + +import com.fr.config.ServerPreferenceConfig; +import com.fr.general.CloudCenter; +import com.fr.general.GeneralContext; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.Locale; +import java.util.Map; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2021/1/5 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({ServerPreferenceConfig.class, CloudCenter.class}) +@SuppressStaticInitializationFor("com.fr.general.CloudCenter") +public class UpmUtilsTest { + + @Test + public void testRenderMap() { + + ServerPreferenceConfig serverPreferenceConfig = EasyMock.mock(ServerPreferenceConfig.class); + EasyMock.expect(serverPreferenceConfig.getOptimizedUPMVersion()).andReturn("1.0").anyTimes(); + PowerMock.mockStatic(ServerPreferenceConfig.class); + EasyMock.expect(ServerPreferenceConfig.getInstance()).andReturn(serverPreferenceConfig).anyTimes(); + + CloudCenter cloudCenter = EasyMock.mock(CloudCenter.class); + EasyMock.expect(cloudCenter.acquireUrlByKind("upm.script.version")).andReturn("2.0").anyTimes(); + PowerMock.mockStatic(CloudCenter.class); + EasyMock.expect(CloudCenter.getInstance()).andReturn(cloudCenter).anyTimes(); + + EasyMock.replay(serverPreferenceConfig, cloudCenter); + PowerMock.replayAll(); + + GeneralContext.setLocale(Locale.CHINA); + + Map map4Tpl = UpmUtils.renderMap(); + Assert.assertEquals(map4Tpl.size(), 3); + Assert.assertEquals(map4Tpl.get("version"), "1.0"); + Assert.assertEquals(map4Tpl.get("new_version"), "2.0"); + Assert.assertEquals(map4Tpl.get("language"), "zh_CN"); + + + EasyMock.verify(serverPreferenceConfig, cloudCenter); + PowerMock.verifyAll(); + + } +} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java index c087d78fe..b961aaee0 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java @@ -42,6 +42,18 @@ public interface LayoutAdapter { */ boolean addBean(XCreator creator, int x, int y); + /** + * 组件的ComponentAdapter在添加组件时,如果发现布局管理器不为空,会继而调用该布局管理器的 + * addComp方法来完成组件的具体添加。在该方法内,布局管理器可以提供额外的功能。 + * + * @param creator 被添加的新组件 + * @param x 添加的位置x,该位置是相对于container的 + * @param y 添加的位置y,该位置是相对于container的 + * @param accept 是否添加新组件 + * @return 是否添加成功,成功返回true,否则false + */ + boolean addBean(XCreator creator, int x, int y, boolean accept); + /** * 返回该布局管理适配器的Painter,为容器提供放置位置的标识。 */ @@ -91,4 +103,4 @@ public interface LayoutAdapter { * @param initHeight 组件之前高度 */ void removeBean(XCreator creator, int initWidth, int initHeight); -} \ No newline at end of file +} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java index 493dd02aa..e9851a7e8 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java @@ -78,7 +78,23 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter { */ @Override public boolean addBean(XCreator creator, int x, int y) { - if (!accept(creator, x, y)) { + boolean accept = accept(creator, x, y); + return addBean(creator, x, y, accept); + } + + /** + * 组件的ComponentAdapter在添加组件时,如果发现布局管理器不为空,会继而调用该布局管理器的 + * addComp方法来完成组件的具体添加。在该方法内,布局管理器可以提供额外的功能。 + * + * @param creator 被添加的新组件 + * @param x 添加的位置x,该位置是相对于container的 + * @param y 添加的位置y,该位置是相对于container的 + * @param accept 是否添加新组件 + * @return 是否添加成功,成功返回true,否则false + */ + @Override + public boolean addBean(XCreator creator, int x, int y, boolean accept) { + if (!accept) { return false; } addComp(creator, x, y); @@ -86,6 +102,7 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter { return true; } + /** * 删除组件 * @@ -186,4 +203,4 @@ public abstract class AbstractLayoutAdapter implements LayoutAdapter { public XLayoutContainer getContainer() { return this.container; } -} \ No newline at end of file +} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java index d5a680b61..2b33159e8 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java @@ -18,7 +18,8 @@ import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.general.ComparatorUtils; import com.fr.general.act.BorderPacker; -import java.awt.*; +import java.awt.Rectangle; + /** * tab布局tabFit适配器 @@ -73,8 +74,7 @@ public class FRTabFitLayoutAdapter extends FRFitLayoutAdapter { y = adjustY(y, tabLayout); } //这时候应该要用计算后的父fit布局添加 - this.container.getLayoutAdapter().addBean(creator, x, y); - ((XWidgetCreator) creator).recalculateChildrenSize(); + this.container.getLayoutAdapter().addBean(creator, x, y, true); return true; } // 如果不在边缘,容器为本自适应布局,增加组件的位置就是相对于容器的位置 diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleMobileParamEditor.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleMobileParamEditor.java new file mode 100644 index 000000000..94fa4607c --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleMobileParamEditor.java @@ -0,0 +1,48 @@ +package com.fr.design.mainframe.widget.accessibles; + +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.mainframe.mobile.ui.MobileParamSettingPane; +import com.fr.design.mainframe.widget.wrappers.MobileParamWrapper; +import com.fr.form.ui.container.WParameterLayout; +import com.fr.form.ui.mobile.MobileParamStyle; +import com.fr.report.mobile.EmptyMobileParamStyle; +import javax.swing.SwingUtilities; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/1/4 + */ +public class AccessibleMobileParamEditor extends UneditableAccessibleEditor { + + private MobileParamSettingPane mobileParamSettingPane; + + public AccessibleMobileParamEditor(MobileParamSettingPane mobileParamSettingPane) { + super(new MobileParamWrapper()); + this.mobileParamSettingPane = mobileParamSettingPane; + } + + @Override + protected void showEditorPane() { + mobileParamSettingPane.setPreferredSize(BasicDialog.MEDIUM); + BasicDialog dlg = mobileParamSettingPane.showWindow(SwingUtilities.getWindowAncestor(this)); + dlg.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + MobileParamStyle mobileParamStyle = mobileParamSettingPane.update(); + setValue(mobileParamStyle); + FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + WParameterLayout wParameterLayout = (WParameterLayout) formDesigner.getSelectionModel().getSelection().getSelectedCreator().toData(); + if (mobileParamStyle instanceof EmptyMobileParamStyle) { + wParameterLayout.setProvider(((EmptyMobileParamStyle) mobileParamStyle).getProvider()); + } + fireStateChanged(); + } + }); + mobileParamSettingPane.populate((MobileParamStyle) getValue()); + dlg.setVisible(true); + } +} diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ParaMobileDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ParaMobileDefinePane.java index cf909618c..1c1fe0150 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ParaMobileDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ParaMobileDefinePane.java @@ -5,11 +5,9 @@ import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.properties.PropertyTab; -import com.fr.design.designer.properties.items.Item; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.fun.ParameterExpandablePaneUIProvider; import com.fr.design.gui.frpane.AttributeChangeListener; -import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; @@ -17,25 +15,21 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.MobileWidgetListPane; import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.mainframe.mobile.ui.MobileParamSettingPane; +import com.fr.design.mainframe.widget.accessibles.AccessibleMobileParamEditor; import com.fr.form.ui.container.WParameterLayout; import com.fr.form.ui.container.WSortLayout; +import com.fr.form.ui.mobile.MobileParamStyle; import com.fr.general.CloudCenter; -import com.fr.general.ComparatorUtils; -import com.fr.general.SiteCenter; import com.fr.log.FineLoggerFactory; -import com.fr.report.ExtraReportClassManager; -import com.fr.report.fun.MobileParamStyleProvider; -import com.fr.report.mobile.DefaultMobileParamStyle; - +import com.fr.report.mobile.EmptyMobileParamStyle; import javax.swing.BorderFactory; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Cursor; import java.awt.Desktop; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.net.URI; @@ -47,10 +41,9 @@ import java.util.Set; public class ParaMobileDefinePane extends MobileWidgetDefinePane { private XCreator paraCreator; private FormDesigner designer; - private Item[] items; - private UIComboBox paramLocationComboBox; private AttributeChangeListener changeListener; private MobileWidgetListPane mobileWidgetListPane; + private AccessibleMobileParamEditor mobileParamEditor; public ParaMobileDefinePane(XCreator xCreator) { this.paraCreator = xCreator; @@ -81,18 +74,15 @@ public class ParaMobileDefinePane extends MobileWidgetDefinePane { // 手机属性 private UIExpandablePane getMobilePropertyPane() { - paramLocationComboBox = getParamLocationComboBox(); + mobileParamEditor = new AccessibleMobileParamEditor(new MobileParamSettingPane()); UILabel tipLabel = getTipLabel(); double f = TableLayout.FILL; double p = TableLayout.PREFERRED; double[] rowSize = {p, p}; double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}, {1, 1}}; - if (ExtraReportClassManager.getInstance().getArray(MobileParamStyleProvider.MARK_STRING).isEmpty()) { - ((WParameterLayout) (paraCreator.toData())).setProvider((MobileParamStyleProvider) ((Item) paramLocationComboBox.getItemAt(0)).getValue()); - } Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Parameter_Panel")), paramLocationComboBox}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Parameter_Panel")), mobileParamEditor}, new Component[]{tipLabel, null}, }; JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1); @@ -102,18 +92,6 @@ public class ParaMobileDefinePane extends MobileWidgetDefinePane { return new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Properties_Mobile"), 280, 20, jPanel); } - private Item[] getItems() { - Set pluginCreators = ExtraReportClassManager.getInstance().getArray(MobileParamStyleProvider.MARK_STRING); - Item[] items = new Item[pluginCreators.size() + 1]; - MobileParamStyleProvider provider = new DefaultMobileParamStyle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default")); - items[0] = new Item(provider.descriptor(), provider); - int i = 1; - for (MobileParamStyleProvider mobileParamStyleProvider : pluginCreators) { - items[i++] = new Item(mobileParamStyleProvider.descriptor(), mobileParamStyleProvider); - } - return items; - } - private UILabel getTipLabel() { UILabel tipLabel = new UILabel(); StringBuilder text = new StringBuilder(); @@ -156,21 +134,6 @@ public class ParaMobileDefinePane extends MobileWidgetDefinePane { return tipLabel; } - private UIComboBox getParamLocationComboBox() { - items = getItems(); - - UIComboBox paramLocationComoBox = new UIComboBox(items); - paramLocationComoBox.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - ((WParameterLayout) (paraCreator.toData())).setProvider((MobileParamStyleProvider) ((Item) e.getItem()).getValue()); - } - } - }); - return paramLocationComoBox; - } - // 控件顺序 private UIExpandablePane getMobileWidgetListPane() { mobileWidgetListPane = new MobileWidgetListPane(designer, (WSortLayout) paraCreator.toData()); @@ -205,27 +168,20 @@ public class ParaMobileDefinePane extends MobileWidgetDefinePane { // 设置监听 this.bindListeners2Widgets(); this.addAttributeChangeListener(changeListener); - int index = 0; - try { - MobileParamStyleProvider provider = ((WParameterLayout) paraCreator.toData()).getProvider(); - String currentQueryType = provider.createJSON().getString("queryType"); - for (int i = 0; i < items.length; i++) { - String existedQueryType = ((MobileParamStyleProvider) items[i].getValue()).createJSON().getString("queryType"); - if (ComparatorUtils.equals(existedQueryType, currentQueryType)) { - index = i; - break; - } - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - paramLocationComboBox.setSelectedIndex(index); - + WParameterLayout wParameterLayout = (WParameterLayout) paraCreator.toData(); + this.mobileParamEditor.setValue(wParameterLayout.getMobileParamStyle()); } @Override public void update() { mobileWidgetListPane.updateToDesigner(); + WParameterLayout wParameterLayout = (WParameterLayout) paraCreator.toData(); + MobileParamStyle mobileParamStyle = (MobileParamStyle) this.mobileParamEditor.getValue(); + if (mobileParamStyle instanceof EmptyMobileParamStyle) { + wParameterLayout.setProvider(((EmptyMobileParamStyle) mobileParamStyle).getProvider()); + } + wParameterLayout.setMobileParamStyle(mobileParamStyle); + designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); } }