Browse Source

Merge pull request #3274 in DESIGN/design from bugfix/10.0 to feature/10.0

* commit '35fb58009f2c9a8b408d20d5901338d297aa7a4c':
  REPORT-32210 Tab块拖动添加失败
  REPORT-46575【10.0.13冒烟】mac下设计器字体展示不一致
  REPORT-46495 新版本插件管理,在设计器语言为中文时会显示语言筛选的标签
  REPORT-45689 添加注解
  REPORT-45689 顶部参数界面样式优化
  改用HashMap
  改用TreeSet
  REPORT-45895 war包部署 函数生成2份
persist/11.0
superman 4 years ago
parent
commit
2423dee651
  1. 4
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  2. 37
      designer-base/src/main/java/com/fr/design/fun/MobileParamUIProvider.java
  3. 25
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileParamUIProvider.java
  4. 15
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java
  5. 33
      designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/DefaultMobileParamUIProvider.java
  6. 43
      designer-base/src/main/java/com/fr/design/mainframe/mobile/provider/EmptyMobileParamUIProvider.java
  7. 42
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileParamDefinePane.java
  8. 47
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/EmptyMobileParamDefinePane.java
  9. 55
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileParamDefinePane.java
  10. 150
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileParamSettingPane.java
  11. 34
      designer-base/src/main/java/com/fr/design/mainframe/widget/wrappers/MobileParamWrapper.java
  12. 2
      designer-base/src/main/java/com/fr/design/upm/UpmUtils.java
  13. 57
      designer-base/src/test/java/com/fr/design/upm/UpmUtilsTest.java
  14. 14
      designer-form/src/main/java/com/fr/design/designer/beans/LayoutAdapter.java
  15. 21
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/AbstractLayoutAdapter.java
  16. 6
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java
  17. 48
      designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleMobileParamEditor.java
  18. 76
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ParaMobileDefinePane.java

4
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() {

37
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<? extends MobileParamStyle> classForMobileParamStyle();
/**
* 移动端参数面板中扩展项的面板
* @return
*/
Class<? extends BasicBeanPane<MobileParamStyle>> classForMobileParamAppearance();
/**
* 扩展项的名称描述
* @return
*/
String displayName();
}

25
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();
}
}

15
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<FileNode> tList = new ArrayList<FileNode>();
for (int i = 0; i < resFns.length; i++) {
if (filter.accept(resFns[i])) {
tList.add(resFns[i]);
Map<String, FileNode> 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()));

33
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<? extends MobileParamStyle> classForMobileParamStyle() {
return DefaultMobileParameterStyle.class;
}
@Override
public Class<? extends BasicBeanPane<MobileParamStyle>> classForMobileParamAppearance() {
return DefaultMobileParamDefinePane.class;
}
@Override
public String displayName() {
return InterProviderFactory.getProvider().getLocText("Fine-Engine_Report_DEFAULT");
}
}

43
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<? extends MobileParamStyle> classForMobileParamStyle() {
return EmptyMobileParamStyle.class;
}
@Override
public Class<? extends BasicBeanPane<MobileParamStyle>> classForMobileParamAppearance() {
return EmptyMobileParamDefinePane.class;
}
@Override
public String displayName() {
return styleProvider.descriptor();
}
public MobileParamStyleProvider getStyleProvider() {
return styleProvider;
}
}

42
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<MobileParamStyle> {
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;
}
}

47
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<MobileParamStyle> {
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;
}
}

55
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<MobileParamStyle> {
private BasicBeanPane<MobileParamStyle> 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";
}
}

150
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<String> listModel;
private JPanel right;
private CardLayout card;
private JList paramStyleList;
private Map<String, BasicBeanPane<MobileParamStyle>> 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<MobileParamStyle> 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<MobileParamUIProvider> paramUIProviders = ExtraDesignClassManager.getInstance().getArray(MobileParamUIProvider.XML_TAG);
List<MobileParamUIProvider> result = new ArrayList<>();
result.add(new DefaultMobileParamUIProvider());
result.addAll(paramUIProviders);
Set<String> nameSets = paramUIProviders.stream().map(MobileParamUIProvider::displayName).collect(Collectors.toSet());
// 兼容老接口
Set<MobileParamStyleProvider> 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]);
}
}

34
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();
}
}

2
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<String, String> map4Tpl = new HashMap<>();
map4Tpl.put("version", ServerPreferenceConfig.getInstance().getOptimizedUPMVersion());
map4Tpl.put("new_version", fetchLatestVersion());
map4Tpl.put("language", GeneralContext.getLocale().toString());
return map4Tpl;
}

57
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<String, String> 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();
}
}

14
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);
}
}

21
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;
}
}
}

6
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;
}
// 如果不在边缘,容器为本自适应布局,增加组件的位置就是相对于容器的位置

48
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);
}
}

76
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<MobileParamStyleProvider> 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);
}
}

Loading…
Cancel
Save