forked from fanruan/design
hades
4 years ago
11 changed files with 528 additions and 60 deletions
@ -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(); |
||||
|
||||
} |
@ -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(); |
||||
} |
||||
|
||||
} |
@ -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"); |
||||
} |
||||
|
||||
|
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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"; |
||||
} |
||||
} |
@ -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]); |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
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; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/1/4 |
||||
*/ |
||||
public class MobileParamWrapper implements Encoder, Decoder { |
||||
|
||||
@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(); |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
Loading…
Reference in new issue