forked from fanruan/design
Browse Source
* commit '0ed25a33c32c27edc7b776a20a43459f6e21f26c': (29 commits) MOBILE-21673 & MOBILE-21669 修复一处颜色选择框读取值时方法使用错误 日历、下拉框等全被Scale包住了,设置成真实的组件 MOBILE-21673 & MOBILE-21669 移动端控件插件化接口设计器支持 update 无 jira 任务, 单元测试 无jira sonar修复 REPORT-19897 英文版设计器显示问题 REPORT-19873 设计器英文 表单自适应被遮挡 补充单元测试 REPORT-19857 英文版alphafine显示问题 1. 把判断国际化的过程和 点击配置页面才能更新 的逻辑解耦。放到启动的时候做。 2. 配置不依赖于 searchOnline 而是判断中英文。 不ignored异常 加读写锁 初始化时从插件里捞一把 通过监听插件生命周期实现 插件天生可拔插,这里不能用static,应每次调用时获取 REPORT-19733 未装数据集插件的设计器远程设计时 编辑服务器数据集 点击确定会覆盖所有服务器中的插件数据集 update REPORT-19636 填报属性里,智能添加单元格组时,鼠标连续选中一片单元格,如果拖动稍微快了一点,选择会出现丢失 不要重复close close的一些细节 ...persist/11.0
vito
5 years ago
61 changed files with 1359 additions and 341 deletions
@ -0,0 +1,24 @@ |
|||||||
|
package com.fr.design.fun; |
||||||
|
|
||||||
|
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
import com.fr.stable.fun.mark.Mutable; |
||||||
|
|
||||||
|
/** |
||||||
|
* 移动端组件样式扩展接口 |
||||||
|
*/ |
||||||
|
public interface MobileWidgetStyleProvider extends Mutable { |
||||||
|
|
||||||
|
String XML_TAG = "MobileWidgetStyleProvider"; |
||||||
|
|
||||||
|
int CURRENT_LEVEL = 1; |
||||||
|
|
||||||
|
Class<? extends MobileStyle> classForMobileStyle(); |
||||||
|
|
||||||
|
Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance(); |
||||||
|
|
||||||
|
String xTypeForWidget(); |
||||||
|
|
||||||
|
String displayName(); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
package com.fr.design.fun.impl; |
||||||
|
|
||||||
|
import com.fr.design.fun.MobileWidgetStyleProvider; |
||||||
|
import com.fr.stable.fun.impl.AbstractProvider; |
||||||
|
import com.fr.stable.fun.mark.API; |
||||||
|
|
||||||
|
@API(level = MobileWidgetStyleProvider.CURRENT_LEVEL) |
||||||
|
public abstract class AbstractMobileWidgetStyleProvider extends AbstractProvider implements MobileWidgetStyleProvider { |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String mark4Provider() { |
||||||
|
return getClass().getName(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,77 @@ |
|||||||
|
package com.fr.design.gui.itree.filetree; |
||||||
|
|
||||||
|
import com.fr.base.FRContext; |
||||||
|
import com.fr.design.ExtraDesignClassManager; |
||||||
|
import com.fr.design.mainframe.App; |
||||||
|
import com.fr.general.GeneralContext; |
||||||
|
import com.fr.plugin.context.PluginContext; |
||||||
|
import com.fr.plugin.injectable.PluginModule; |
||||||
|
import com.fr.plugin.manage.PluginFilter; |
||||||
|
import com.fr.plugin.observer.PluginEvent; |
||||||
|
import com.fr.plugin.observer.PluginEventListener; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Set; |
||||||
|
import java.util.concurrent.locks.ReadWriteLock; |
||||||
|
import java.util.concurrent.locks.ReentrantReadWriteLock; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by alex sung on 2019/7/23. |
||||||
|
*/ |
||||||
|
public class FileNodeConstants { |
||||||
|
|
||||||
|
private static List<String> supportFileType; |
||||||
|
private static ReadWriteLock rwl = new ReentrantReadWriteLock(); |
||||||
|
|
||||||
|
private FileNodeConstants() { |
||||||
|
} |
||||||
|
|
||||||
|
static { |
||||||
|
initSupportedTypes(); |
||||||
|
|
||||||
|
GeneralContext.listenPluginRunningChanged(new PluginEventListener() { |
||||||
|
@Override |
||||||
|
public void on(PluginEvent pluginEvent) { |
||||||
|
initSupportedTypes(); |
||||||
|
} |
||||||
|
}, new PluginFilter() { |
||||||
|
@Override |
||||||
|
public boolean accept(PluginContext pluginContext) { |
||||||
|
return pluginContext.contain(PluginModule.ExtraDesign); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private static void addAppExtensions(String[] extensions) { |
||||||
|
for (int i = 0, size = extensions.length; i < size; i++) { |
||||||
|
if (!supportFileType.contains(extensions[i])) { |
||||||
|
supportFileType.add(extensions[i]); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private static void initSupportedTypes() { |
||||||
|
try { |
||||||
|
rwl.writeLock().lock(); |
||||||
|
supportFileType = new ArrayList<>(Arrays.asList(FRContext.getFileNodes().getSupportedTypes())); |
||||||
|
//通过插件扩展的
|
||||||
|
Set<App> apps = ExtraDesignClassManager.getInstance().getArray(App.MARK_STRING); |
||||||
|
for (App app : apps) { |
||||||
|
addAppExtensions(app.defaultExtensions()); |
||||||
|
} |
||||||
|
} finally { |
||||||
|
rwl.writeLock().unlock(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static String[] getSupportFileTypes() { |
||||||
|
try { |
||||||
|
rwl.readLock().lock(); |
||||||
|
return supportFileType.toArray(new String[0]); |
||||||
|
} finally { |
||||||
|
rwl.readLock().unlock(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
package com.fr.design.mainframe.mobile.ui; |
||||||
|
|
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
|
||||||
|
public class DefaultMobileStyleCustomDefinePane extends MobileStyleCustomDefinePane { |
||||||
|
|
||||||
|
|
||||||
|
public DefaultMobileStyleCustomDefinePane(Widget widget) { |
||||||
|
super(widget); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected JPanel createPreviewPane() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(MobileStyle ob) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public MobileStyle updateBean() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void init() { |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
package com.fr.design.mainframe.mobile.ui; |
||||||
|
|
||||||
|
import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider; |
||||||
|
import com.fr.form.ui.mobile.DefaultMobileStyle; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
import com.fr.locale.InterProviderFactory; |
||||||
|
|
||||||
|
public class DefaultMobileWidgetStyleProvider extends AbstractMobileWidgetStyleProvider { |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends MobileStyle> classForMobileStyle() { |
||||||
|
return DefaultMobileStyle.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance() { |
||||||
|
return DefaultMobileStyleCustomDefinePane.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String xTypeForWidget() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String displayName() { |
||||||
|
return InterProviderFactory.getProvider().getLocText("Fine-Engine_Report_DEFAULT"); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
package com.fr.design.mainframe.mobile.ui; |
||||||
|
|
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
|
||||||
|
public abstract class MobileStyleCustomDefinePane extends BasicBeanPane<MobileStyle> { |
||||||
|
|
||||||
|
protected Widget widget; |
||||||
|
|
||||||
|
public MobileStyleCustomDefinePane(Widget widget) { |
||||||
|
this.widget = widget; |
||||||
|
init(); |
||||||
|
} |
||||||
|
|
||||||
|
protected abstract JPanel createPreviewPane(); |
||||||
|
|
||||||
|
protected abstract void init(); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,115 @@ |
|||||||
|
package com.fr.design.mainframe.mobile.ui; |
||||||
|
|
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.style.color.NewColorSelectBox; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
import com.fr.general.FRFont; |
||||||
|
import com.fr.invoke.Reflect; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.border.TitledBorder; |
||||||
|
import javax.swing.event.ChangeEvent; |
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> { |
||||||
|
|
||||||
|
private Widget widget; |
||||||
|
private MobileStyleCustomDefinePane customBeanPane; |
||||||
|
private Class<? extends MobileStyle> mobileStyleClazz; |
||||||
|
private NewColorSelectBox colorSelectBox; |
||||||
|
|
||||||
|
MobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass, |
||||||
|
Class<? extends MobileStyle> mobileStyleClazz) { |
||||||
|
this.widget = widget; |
||||||
|
this.customBeanPane = Reflect.on(customBeanPaneClass).create(widget).get(); |
||||||
|
this.mobileStyleClazz = mobileStyleClazz; |
||||||
|
init(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(MobileStyle ob) { |
||||||
|
this.customBeanPane.populateBean(ob); |
||||||
|
colorSelectBox.setSelectObject(ob.getBackground()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public MobileStyle updateBean() { |
||||||
|
MobileStyle mobileStyle = Reflect.on(mobileStyleClazz).create().get(); |
||||||
|
this.widget.setMobileStyle(mobileStyle); |
||||||
|
this.customBeanPane.updateBean(); |
||||||
|
mobileStyle.setBackground(colorSelectBox.getSelectObject()); |
||||||
|
return mobileStyle; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
private void init() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
createGeneralPane(); |
||||||
|
createCustomPane(); |
||||||
|
} |
||||||
|
|
||||||
|
private void createGeneralPane() { |
||||||
|
createPreviewPane(); |
||||||
|
createBackgroundPane(); |
||||||
|
} |
||||||
|
|
||||||
|
private void createPreviewPane() { |
||||||
|
JPanel mobileStylePreviewPane = this.customBeanPane.createPreviewPane(); |
||||||
|
if(mobileStylePreviewPane != null) { |
||||||
|
JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Widget_Style_Preview"), null); |
||||||
|
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12, new Color(0x2f8ef100))); |
||||||
|
previewPane.setBorder(titledBorder); |
||||||
|
previewPane.setPreferredSize(new Dimension(500, 83)); |
||||||
|
previewPane.add(mobileStylePreviewPane, BorderLayout.CENTER); |
||||||
|
this.add(previewPane, BorderLayout.NORTH); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void createBackgroundPane() { |
||||||
|
|
||||||
|
JPanel backgroundPane = new JPanel(); |
||||||
|
backgroundPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 5)); |
||||||
|
backgroundPane.setPreferredSize(new Dimension(500, 65)); |
||||||
|
|
||||||
|
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_Common_Attribute"), null); |
||||||
|
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12, Color.BLUE)); |
||||||
|
backgroundPane.setBorder(titledBorder); |
||||||
|
|
||||||
|
UILabel colorSelectLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Widget_Background"), UILabel.RIGHT); |
||||||
|
colorSelectLabel.setPreferredSize(new Dimension(65, 20)); |
||||||
|
|
||||||
|
colorSelectBox = new NewColorSelectBox(152); |
||||||
|
colorSelectBox.addSelectChangeListener(new ChangeListener() { |
||||||
|
@Override |
||||||
|
public void stateChanged(ChangeEvent e) { |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
backgroundPane.add(colorSelectLabel); |
||||||
|
backgroundPane.add(colorSelectBox); |
||||||
|
|
||||||
|
this.add(backgroundPane, BorderLayout.NORTH); |
||||||
|
} |
||||||
|
|
||||||
|
private void createCustomPane() { |
||||||
|
JPanel configPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"), null); |
||||||
|
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12, Color.BLUE)); |
||||||
|
configPane.setBorder(titledBorder); |
||||||
|
|
||||||
|
configPane.add(this.customBeanPane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
this.add(configPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,136 @@ |
|||||||
|
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.MobileWidgetStyleProvider; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.container.WScaleLayout; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
import com.fr.form.ui.widget.CRBoundsWidget; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.stable.ArrayUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.MouseAdapter; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
public class MobileStylePane extends BasicPane { |
||||||
|
|
||||||
|
private Widget widget; |
||||||
|
private DefaultListModel<String> listModel; |
||||||
|
private JPanel right; |
||||||
|
private CardLayout card; |
||||||
|
private JList styleList; |
||||||
|
private Map<String, BasicBeanPane<MobileStyle>> map = new HashMap<>(); |
||||||
|
|
||||||
|
public MobileStylePane(Widget widget) { |
||||||
|
if(widget instanceof WScaleLayout) { |
||||||
|
this.widget = ((CRBoundsWidget)((WScaleLayout) widget).getBoundsWidget()).getWidget(); |
||||||
|
} else { |
||||||
|
this.widget = widget; |
||||||
|
} |
||||||
|
init(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(MobileStyle mobileStyle) { |
||||||
|
if(mobileStyle != null) { |
||||||
|
MobileWidgetStyleProvider[] styleProviders = getMobileWidgetStyleProviders(); |
||||||
|
for(int i = 0; i < styleProviders.length; i ++) { |
||||||
|
if(mobileStyle.getClass() == styleProviders[i].classForMobileStyle()) { |
||||||
|
String displayName = styleProviders[i].displayName(); |
||||||
|
styleList.setSelectedIndex(i); |
||||||
|
map.get(displayName).populateBean(mobileStyle); |
||||||
|
card.show(right, displayName); |
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
styleList.setSelectedIndex(0); |
||||||
|
} |
||||||
|
|
||||||
|
public MobileStyle update() { |
||||||
|
return map.get(styleList.getSelectedValue()).updateBean(); |
||||||
|
} |
||||||
|
|
||||||
|
private void init() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
listModel = new DefaultListModel<>(); |
||||||
|
card = new CardLayout(); |
||||||
|
right = FRGUIPaneFactory.createCardLayout_S_Pane(); |
||||||
|
right.setLayout(card); |
||||||
|
MobileWidgetStyleProvider[] styleProviders = getMobileWidgetStyleProviders(); |
||||||
|
for(MobileWidgetStyleProvider styleProvider: styleProviders) { |
||||||
|
this.addProvider2View(styleProvider); |
||||||
|
} |
||||||
|
this.addWestList(); |
||||||
|
this.addCenterConfig(); |
||||||
|
} |
||||||
|
|
||||||
|
private void addWestList() { |
||||||
|
styleList = new JList<>(listModel); |
||||||
|
styleList.setCellRenderer(render); |
||||||
|
styleList.addMouseListener(new MouseAdapter() { |
||||||
|
public void mouseClicked(MouseEvent e) { |
||||||
|
String selectedValue = (String)styleList.getSelectedValue(); |
||||||
|
card.show(right, selectedValue); |
||||||
|
} |
||||||
|
}); |
||||||
|
JPanel westPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
westPane.add(styleList, BorderLayout.CENTER); |
||||||
|
westPane.setPreferredSize(new Dimension(100, 500)); |
||||||
|
this.add(westPane, BorderLayout.WEST); |
||||||
|
} |
||||||
|
|
||||||
|
private void addCenterConfig() { |
||||||
|
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); |
||||||
|
} |
||||||
|
|
||||||
|
private void addProvider2View(MobileWidgetStyleProvider styleProvider) { |
||||||
|
String displayName = styleProvider.displayName(); |
||||||
|
Class<? extends MobileStyleCustomDefinePane> appearanceClazz = styleProvider.classForWidgetAppearance(); |
||||||
|
Class<? extends MobileStyle> mobileStyleClazz = styleProvider.classForMobileStyle(); |
||||||
|
|
||||||
|
listModel.addElement(displayName); |
||||||
|
try { |
||||||
|
BasicBeanPane<MobileStyle> mobileStyleBasicBeanPane = new MobileStyleDefinePane(widget, appearanceClazz, mobileStyleClazz); |
||||||
|
right.add(displayName, mobileStyleBasicBeanPane); |
||||||
|
map.put(displayName, mobileStyleBasicBeanPane); |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private static ListCellRenderer render = 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 MobileStyle) { |
||||||
|
MobileStyle l = (MobileStyle) value; |
||||||
|
this.setText(l.toString()); |
||||||
|
} |
||||||
|
return this; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
private MobileWidgetStyleProvider[] getMobileWidgetStyleProviders() { |
||||||
|
DefaultMobileWidgetStyleProvider defaultMobileWidgetStyleProvider = new DefaultMobileWidgetStyleProvider(); |
||||||
|
MobileWidgetStyleProvider[] styleProviders = ExtraDesignClassManager.getInstance().getMobileStyleOfWidget(widget.getXType()); |
||||||
|
styleProviders = ArrayUtils.insert(0, styleProviders, defaultMobileWidgetStyleProvider); |
||||||
|
return styleProviders; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
package com.fr.design.mainframe.widget.accessibles; |
||||||
|
|
||||||
|
import com.fr.design.dialog.BasicDialog; |
||||||
|
import com.fr.design.dialog.DialogActionAdapter; |
||||||
|
import com.fr.design.mainframe.mobile.ui.MobileStylePane; |
||||||
|
import com.fr.design.mainframe.widget.wrappers.MobileStyleWrapper; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
|
||||||
|
import javax.swing.SwingUtilities; |
||||||
|
import java.awt.Dimension; |
||||||
|
|
||||||
|
public class AccessibleMobileStyleEditor extends UneditableAccessibleEditor { |
||||||
|
|
||||||
|
private MobileStylePane stylePane; |
||||||
|
private static final Dimension DEFAULT_DIMENSION = new Dimension(600, 400); |
||||||
|
|
||||||
|
public AccessibleMobileStyleEditor(MobileStylePane stylePane) { |
||||||
|
super(new MobileStyleWrapper()); |
||||||
|
this.stylePane = stylePane; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void showEditorPane() { |
||||||
|
stylePane.setPreferredSize(DEFAULT_DIMENSION); |
||||||
|
BasicDialog dlg = stylePane.showWindow(SwingUtilities.getWindowAncestor(this)); |
||||||
|
dlg.addDialogActionListener(new DialogActionAdapter() { |
||||||
|
@Override |
||||||
|
public void doOk() { |
||||||
|
setValue(stylePane.update()); |
||||||
|
fireStateChanged(); |
||||||
|
} |
||||||
|
}); |
||||||
|
stylePane.populate((MobileStyle) getValue()); |
||||||
|
dlg.setVisible(true); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
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; |
||||||
|
|
||||||
|
public class MobileStyleWrapper implements Encoder, Decoder { |
||||||
|
@Override |
||||||
|
public Object decode(String txt) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void validate(String txt) throws ValidationException { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String encode(Object v) { |
||||||
|
if (v == null) { |
||||||
|
return InterProviderFactory.getProvider().getLocText("Fine-Engine_Report_DEFAULT"); |
||||||
|
} |
||||||
|
return v.toString(); |
||||||
|
} |
||||||
|
} |
After Width: | Height: | Size: 284 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 6.8 KiB |
@ -0,0 +1,51 @@ |
|||||||
|
package com.fr.design.gui.itree.filetree; |
||||||
|
|
||||||
|
import com.fr.base.extension.FileExtension; |
||||||
|
import com.fr.base.io.BaseBook; |
||||||
|
import com.fr.design.ExtraDesignClassManager; |
||||||
|
import com.fr.design.mainframe.AbstractAppProvider; |
||||||
|
import com.fr.design.mainframe.App; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.file.FILE; |
||||||
|
import com.fr.stable.fun.mark.Mutable; |
||||||
|
import org.easymock.EasyMock; |
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Test; |
||||||
|
|
||||||
|
import java.util.HashSet; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by alex sung on 2019/7/25. |
||||||
|
*/ |
||||||
|
public class FileNodeConstantsTest { |
||||||
|
@Test |
||||||
|
public void supportFileTypesTest(){ |
||||||
|
ExtraDesignClassManager extra = EasyMock.mock(ExtraDesignClassManager.class); |
||||||
|
Set<Mutable> apps = new HashSet<Mutable>(){{add(new MockCptxApp());}}; |
||||||
|
EasyMock.expect(extra.getArray(App.MARK_STRING)).andReturn(apps).anyTimes(); |
||||||
|
EasyMock.replay(extra); |
||||||
|
|
||||||
|
Assert.assertEquals(1, extra.getArray(App.MARK_STRING).size()); |
||||||
|
App app = (App) extra.getArray(App.MARK_STRING).iterator().next(); |
||||||
|
Assert.assertEquals("cptx", app.defaultExtensions()[0]); |
||||||
|
} |
||||||
|
|
||||||
|
private class MockCptxApp extends AbstractAppProvider{ |
||||||
|
@Override |
||||||
|
public String[] defaultExtensions() { |
||||||
|
return new String[] {FileExtension.CPTX.getExtension()}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JTemplate openTemplate(FILE tplFile) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public BaseBook asIOFile(FILE tplFile) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
package com.fr.design.designer.properties.mobile; |
||||||
|
|
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.designer.creator.XWScaleLayout; |
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider; |
||||||
|
import com.fr.design.gui.itable.AbstractPropertyTable; |
||||||
|
import com.fr.design.widget.ui.designer.mobile.MobileWidgetStyleDefinePane; |
||||||
|
|
||||||
|
public class MobileStylePropertyUI extends AbstractWidgetPropertyUIProvider { |
||||||
|
|
||||||
|
private XCreator xCreator; |
||||||
|
|
||||||
|
public MobileStylePropertyUI(XCreator xCreator) { |
||||||
|
if(xCreator instanceof XWScaleLayout) { |
||||||
|
this.xCreator = xCreator.getEditingChildCreator(); |
||||||
|
} else { |
||||||
|
this.xCreator = xCreator; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public AbstractPropertyTable createWidgetAttrTable() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public BasicPane createWidgetAttrPane() { |
||||||
|
return new MobileWidgetStyleDefinePane(xCreator); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String tableTitle() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,85 @@ |
|||||||
|
package com.fr.design.widget.ui.designer.mobile; |
||||||
|
|
||||||
|
import com.fr.design.constants.LayoutConstants; |
||||||
|
import com.fr.design.designer.IntervalConstants; |
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.gui.frpane.AttributeChangeListener; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.design.mainframe.FormDesigner; |
||||||
|
import com.fr.design.mainframe.widget.accessibles.AccessibleMobileStyleEditor; |
||||||
|
import com.fr.design.mainframe.mobile.ui.MobileStylePane; |
||||||
|
import com.fr.form.ui.mobile.MobileStyle; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
public class MobileWidgetStyleDefinePane extends MobileWidgetDefinePane { |
||||||
|
|
||||||
|
private XCreator xCreator; |
||||||
|
private AccessibleMobileStyleEditor mobileStyleEditor; |
||||||
|
private AttributeChangeListener changeListener; |
||||||
|
|
||||||
|
public MobileWidgetStyleDefinePane(XCreator xCreator) { |
||||||
|
this.xCreator = xCreator; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void setPreferredSize(Dimension dimension) { |
||||||
|
super.setPreferredSize(dimension); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void initPropertyGroups(Object source) { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Tab_Style_Template")); |
||||||
|
mobileStyleEditor = new AccessibleMobileStyleEditor(new MobileStylePane(this.xCreator.toData())); |
||||||
|
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane( |
||||||
|
new Component[][]{new Component[]{label, mobileStyleEditor}}, |
||||||
|
TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_LARGE |
||||||
|
); |
||||||
|
JPanel holder = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
holder.add(jPanel, BorderLayout.NORTH); |
||||||
|
|
||||||
|
this.add(holder, BorderLayout.NORTH); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populate(FormDesigner designer) { |
||||||
|
mobileStyleEditor.setValue(xCreator.toData().getMobileStyle()); |
||||||
|
this.bindListeners2Widgets(); |
||||||
|
this.addAttributeChangeListener(changeListener); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void update() { |
||||||
|
xCreator.toData().setMobileStyle((MobileStyle) mobileStyleEditor.getValue()); |
||||||
|
DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Dimension getPreferredSize() { |
||||||
|
return new Dimension(super.getPreferredSize().width, 30); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Dimension getMaximumSize() { |
||||||
|
return new Dimension(400, 200); |
||||||
|
} |
||||||
|
|
||||||
|
private void bindListeners2Widgets() { |
||||||
|
reInitAllListeners(); |
||||||
|
this.changeListener = new AttributeChangeListener() { |
||||||
|
@Override |
||||||
|
public void attributeChange() { |
||||||
|
update(); |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
private void reInitAllListeners() { |
||||||
|
initListener(this); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,50 @@ |
|||||||
|
package com.fr.design.mainframe.alphafine; |
||||||
|
|
||||||
|
import com.fr.design.DesignerEnvManager; |
||||||
|
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; |
||||||
|
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 org.powermock.reflect.Whitebox; |
||||||
|
|
||||||
|
@RunWith(PowerMockRunner.class) |
||||||
|
public class AlphaFineHelperTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
@PrepareForTest({GeneralContext.class, DesignerEnvManager.class}) |
||||||
|
@SuppressStaticInitializationFor("com.fr.design.mainframe.alphafine.AlphaFineHelper") |
||||||
|
public void testSwitchConfig4Locale() throws Exception { |
||||||
|
|
||||||
|
PowerMock.mockStatic(GeneralContext.class); |
||||||
|
EasyMock.expect(GeneralContext.isChineseEnv()).andReturn(true).times(1).andReturn(false).times(1); |
||||||
|
|
||||||
|
AlphaFineConfigManager mockConfig = EasyMock.partialMockBuilder(AlphaFineConfigManager.class).createMock(); |
||||||
|
Whitebox.setInternalState(mockConfig,"searchOnLine", true); |
||||||
|
EasyMock.replay(mockConfig); |
||||||
|
|
||||||
|
DesignerEnvManager manager = EasyMock.mock(DesignerEnvManager.class); |
||||||
|
EasyMock.expect(manager.getAlphaFineConfigManager()).andReturn(mockConfig).anyTimes(); |
||||||
|
|
||||||
|
EasyMock.replay(manager); |
||||||
|
|
||||||
|
PowerMock.mockStatic(DesignerEnvManager.class); |
||||||
|
EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(manager).anyTimes(); |
||||||
|
|
||||||
|
PowerMock.replayAll(); |
||||||
|
|
||||||
|
AlphaFineHelper.switchConfig4Locale(); |
||||||
|
AlphaFineConfigManager config = manager.getAlphaFineConfigManager(); |
||||||
|
Assert.assertEquals(true, config.isSearchOnLine()); |
||||||
|
|
||||||
|
AlphaFineHelper.switchConfig4Locale(); |
||||||
|
Assert.assertEquals(false, config.isSearchOnLine()); |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,66 @@ |
|||||||
|
package com.fr.design.widget; |
||||||
|
|
||||||
|
import com.fr.design.ExtraDesignClassManager; |
||||||
|
import com.fr.design.data.DataCreatorUI; |
||||||
|
import com.fr.design.widget.ui.ButtonDefinePane; |
||||||
|
import com.fr.form.ui.Button; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
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.PowerMockIgnore; |
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest; |
||||||
|
import org.powermock.modules.junit4.PowerMockRunner; |
||||||
|
|
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
@RunWith(PowerMockRunner.class) |
||||||
|
@PowerMockIgnore("javax.swing.*") |
||||||
|
public class WidgetDefinePaneFactoryTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
@PrepareForTest({ExtraDesignClassManager.class, WidgetDefinePaneFactory.class}) |
||||||
|
public void testCreateWidgetDefinePane() throws Exception { |
||||||
|
|
||||||
|
Map<Class<? extends Widget>, Appearance> map = new HashMap<>(); |
||||||
|
ExtraDesignClassManager mockDesignManager = EasyMock.mock(ExtraDesignClassManager.class); |
||||||
|
EasyMock.expect(mockDesignManager.getCellWidgetOptionsMap()).andReturn(map).anyTimes(); |
||||||
|
EasyMock.replay(mockDesignManager); |
||||||
|
|
||||||
|
PowerMock.mockStatic(ExtraDesignClassManager.class); |
||||||
|
EasyMock.expect(ExtraDesignClassManager.getInstance()).andReturn(mockDesignManager).anyTimes(); |
||||||
|
PowerMock.replayAll(ExtraDesignClassManager.class); |
||||||
|
|
||||||
|
Button mockWidget = EasyMock.mock(Button.class); |
||||||
|
EasyMock.replay(mockWidget); |
||||||
|
|
||||||
|
ButtonDefinePane mockPane = EasyMock.mock(ButtonDefinePane.class); |
||||||
|
mockPane.populateBean(EasyMock.anyObject(Button.class)); |
||||||
|
EasyMock.expectLastCall(); |
||||||
|
EasyMock.replay(mockPane); |
||||||
|
|
||||||
|
|
||||||
|
Operator mockOperator = EasyMock.mock(Operator.class); |
||||||
|
mockOperator.did(EasyMock.anyObject(DataCreatorUI.class), EasyMock.anyString()); |
||||||
|
EasyMock.replay(mockOperator); |
||||||
|
|
||||||
|
WidgetDefinePaneFactory.RN rn1 = WidgetDefinePaneFactory.createWidgetDefinePane(mockWidget, mockOperator); |
||||||
|
Assert.assertNull(rn1); |
||||||
|
|
||||||
|
Appearance appearance = new Appearance(ButtonDefinePane.class, "test"); |
||||||
|
map.put(mockWidget.getClass(), appearance); |
||||||
|
|
||||||
|
WidgetDefinePaneFactory.RN rn2 = WidgetDefinePaneFactory.createWidgetDefinePane(mockWidget, mockOperator); |
||||||
|
Assert.assertNotNull(rn2); |
||||||
|
|
||||||
|
map.clear(); |
||||||
|
|
||||||
|
WidgetDefinePaneFactory.RN rn3 = WidgetDefinePaneFactory.createWidgetDefinePane(mockWidget, mockOperator); |
||||||
|
Assert.assertNull(rn3); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue