104 changed files with 1834 additions and 750 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,92 @@ |
|||||||
|
package com.fr.design.widget.ui.designer.mobile.component; |
||||||
|
|
||||||
|
import com.fr.design.designer.IntervalConstants; |
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.gui.icombocheckbox.UIComboCheckBox; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.design.mainframe.FormDesigner; |
||||||
|
import com.fr.design.mainframe.WidgetPropertyPane; |
||||||
|
import com.fr.design.utils.gui.UIComponentUtils; |
||||||
|
import com.fr.design.widget.FRWidgetFactory; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.container.WSortLayout; |
||||||
|
import com.fr.stable.ArrayUtils; |
||||||
|
|
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Component; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.LinkedHashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Hades |
||||||
|
* @date 2019/8/14 |
||||||
|
*/ |
||||||
|
public class MobileComponentFrozenPane extends BasicPane { |
||||||
|
|
||||||
|
private UIComboCheckBox uiComboCheckBox; |
||||||
|
|
||||||
|
public MobileComponentFrozenPane() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
UILabel frozenLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Frozen")); |
||||||
|
uiComboCheckBox = new UIComboCheckBox(initData()); |
||||||
|
JPanel wrapJPanel = UIComponentUtils.wrapWithBorderLayoutPane(uiComboCheckBox); |
||||||
|
Component[][] components = new Component[][]{ |
||||||
|
new Component[]{frozenLabel, wrapJPanel} |
||||||
|
}; |
||||||
|
JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); |
||||||
|
centerPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L5, 10, 0)); |
||||||
|
JPanel holder = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
holder.add(centerPane, BorderLayout.NORTH); |
||||||
|
this.add(holder, BorderLayout.NORTH); |
||||||
|
} |
||||||
|
|
||||||
|
private String[] initData() { |
||||||
|
FormDesigner designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); |
||||||
|
XCreator selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); |
||||||
|
Widget selectedModel = selectedCreator != null ? selectedCreator.toData() : null; |
||||||
|
|
||||||
|
if (selectedModel == null || !selectedModel.acceptType(WSortLayout.class)) { |
||||||
|
return ArrayUtils.EMPTY_STRING_ARRAY; |
||||||
|
} |
||||||
|
|
||||||
|
List<String> widgetList = ((WSortLayout) selectedModel).getNonContainerWidgetList(); |
||||||
|
return widgetList.toArray(new String[0]); |
||||||
|
} |
||||||
|
|
||||||
|
public void update(XCreator xCreator) { |
||||||
|
List<String> selected = new ArrayList<>(); |
||||||
|
WSortLayout wSortLayout = ((WSortLayout) xCreator.toData()); |
||||||
|
Object[] values = uiComboCheckBox.getSelectedValues(); |
||||||
|
for (Object widgetName : values) { |
||||||
|
selected.add((String) widgetName); |
||||||
|
} |
||||||
|
wSortLayout.updateFrozenWidgets(selected); |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(XCreator xCreator) { |
||||||
|
WSortLayout wSortLayout = ((WSortLayout) xCreator.toData()); |
||||||
|
List<String> all = wSortLayout.getNonContainerWidgetList(); |
||||||
|
List<String> selected = wSortLayout.getFrozenWidgets(); |
||||||
|
Map<Object, Boolean> map = new LinkedHashMap<>(); |
||||||
|
for (String value : selected) { |
||||||
|
map.put(value, true); |
||||||
|
} |
||||||
|
all.removeAll(selected); |
||||||
|
for (String value : all) { |
||||||
|
map.put(value, false); |
||||||
|
} |
||||||
|
uiComboCheckBox.setSelectedValues(map); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return "ComponentFrozenPane"; |
||||||
|
} |
||||||
|
} |
@ -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()); |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue