Browse Source

REPORT-4850 [9.0插件]控件类型的插件,控件属性面板没有适配新版设计器

master
kerry 7 years ago
parent
commit
419aa44195
  1. 10
      designer_base/src/com/fr/design/designer/creator/CRPropertyDescriptor.java
  2. 11
      designer_base/src/com/fr/design/mainframe/widget/accessibles/BaseAccessibleEditor.java
  3. 7
      designer_form/src/com/fr/design/designer/beans/ComponentAdapter.java
  4. 45
      designer_form/src/com/fr/design/designer/beans/adapters/component/CompositeComponentAdapter.java
  5. 76
      designer_form/src/com/fr/design/designer/creator/CRPropertyDescriptorPane.java
  6. 24
      designer_form/src/com/fr/design/designer/creator/PropertyGroupPane.java
  7. 2
      designer_form/src/com/fr/design/designer/creator/XWidgetCreator.java
  8. 2
      designer_form/src/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java
  9. 10
      designer_form/src/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java
  10. 12
      designer_form/src/com/fr/design/widget/ui/designer/AbstractDataModify.java
  11. 72
      designer_form/src/com/fr/design/widget/ui/designer/WidgetDefinePane.java

10
designer_base/src/com/fr/design/designer/creator/CRPropertyDescriptor.java

@ -15,6 +15,7 @@ import java.beans.PropertyDescriptor;
*/ */
public final class CRPropertyDescriptor extends PropertyDescriptor { public final class CRPropertyDescriptor extends PropertyDescriptor {
public static final String RENDERER = "renderer"; public static final String RENDERER = "renderer";
private boolean isSubProperty = false;
private PropertyChangeAdapter l; private PropertyChangeAdapter l;
@ -59,4 +60,13 @@ public final class CRPropertyDescriptor extends PropertyDescriptor {
this.setDisplayName(displayName); this.setDisplayName(displayName);
return this; return this;
} }
public CRPropertyDescriptor setSubLevel(boolean isSubProperty) {
this.isSubProperty = isSubProperty;
return this;
}
public boolean isSubLevel() {
return isSubProperty;
}
} }

11
designer_base/src/com/fr/design/mainframe/widget/accessibles/BaseAccessibleEditor.java

@ -12,6 +12,7 @@ import java.util.ArrayList;
import javax.swing.AbstractButton; import javax.swing.AbstractButton;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@ -64,7 +65,15 @@ public class BaseAccessibleEditor extends BasicPane implements AccessibleEditor
} }
protected ITextComponent createTextField() { protected ITextComponent createTextField() {
return new TextField(); return new TextField() {
public void registerChangeListener(UIObserverListener listener) {
return;
}
public boolean shouldResponseChangeListener() {
return false;
}
};
} }
private void initComponents() { private void initComponents() {

7
designer_form/src/com/fr/design/designer/beans/ComponentAdapter.java

@ -9,6 +9,7 @@ import javax.swing.JPopupMenu;
import com.fr.design.beans.GroupModel; import com.fr.design.beans.GroupModel;
import com.fr.design.designer.beans.events.DesignerEditor; import com.fr.design.designer.beans.events.DesignerEditor;
import com.fr.design.designer.creator.PropertyGroupPane;
/** /**
* 组件适配器接口 * 组件适配器接口
@ -40,6 +41,12 @@ public interface ComponentAdapter {
*/ */
ArrayList<GroupModel> getXCreatorPropertyModel(); ArrayList<GroupModel> getXCreatorPropertyModel();
/**
* 为当前组件创建描述各属性pane, 分组返回
* @return ArrayList<PropertyGroupPane>
*/
ArrayList<PropertyGroupPane> getXCreatorPropertyPane();
/** /**
* 提供双击设计器的编辑器 * 提供双击设计器的编辑器
* @param bean 鼠标双击的被设计组件 * @param bean 鼠标双击的被设计组件

45
designer_form/src/com/fr/design/designer/beans/adapters/component/CompositeComponentAdapter.java

@ -7,6 +7,7 @@ import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.actions.ChangeNameAction; import com.fr.design.designer.beans.actions.ChangeNameAction;
import com.fr.design.designer.beans.events.DesignerEditor; import com.fr.design.designer.beans.events.DesignerEditor;
import com.fr.design.designer.creator.CRPropertyDescriptor; import com.fr.design.designer.creator.CRPropertyDescriptor;
import com.fr.design.designer.creator.PropertyGroupPane;
import com.fr.design.designer.creator.XButton; import com.fr.design.designer.creator.XButton;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
@ -90,6 +91,30 @@ public class CompositeComponentAdapter implements ComponentAdapter {
private ArrayList<PropertyGroupModel> createPropertyGroupModels(CRPropertyDescriptor[] properties) { private ArrayList<PropertyGroupModel> createPropertyGroupModels(CRPropertyDescriptor[] properties) {
HashMap<String, ArrayList<CRPropertyDescriptor>> maps = new HashMap<String, ArrayList<CRPropertyDescriptor>>(); HashMap<String, ArrayList<CRPropertyDescriptor>> maps = new HashMap<String, ArrayList<CRPropertyDescriptor>>();
ArrayList<String> groupNames = getGroupNames(properties, maps);
ArrayList<PropertyGroupModel> groups = new ArrayList<PropertyGroupModel>();
for (String groupName : groupNames) {
ArrayList<CRPropertyDescriptor> groupProperties = maps.get(groupName);
PropertyGroupModel groupModel = new PropertyGroupModel(groupName, xCreator, groupProperties
.toArray(new CRPropertyDescriptor[0]), designer);
groups.add(groupModel);
}
return groups;
}
private ArrayList<PropertyGroupPane> createPropertyGroupPanes(CRPropertyDescriptor[] properties) {
HashMap<String, ArrayList<CRPropertyDescriptor>> maps = new HashMap<String, ArrayList<CRPropertyDescriptor>>();
ArrayList<String> groupNames = getGroupNames(properties, maps);
ArrayList<PropertyGroupPane> groups = new ArrayList<PropertyGroupPane>();
for (String groupName : groupNames) {
ArrayList<CRPropertyDescriptor> groupProperties = maps.get(groupName);
PropertyGroupPane propertyGroupPane = new PropertyGroupPane(groupProperties.toArray(new CRPropertyDescriptor[0]), xCreator, groupName);
groups.add(propertyGroupPane);
}
return groups;
}
private ArrayList<String> getGroupNames(CRPropertyDescriptor[] properties, HashMap<String, ArrayList<CRPropertyDescriptor>> maps ){
ArrayList<String> groupNames = new ArrayList<String>(); ArrayList<String> groupNames = new ArrayList<String>();
for (CRPropertyDescriptor property : properties) { for (CRPropertyDescriptor property : properties) {
String groupName = (String) property.getValue(XCreatorConstants.PROPERTY_CATEGORY); String groupName = (String) property.getValue(XCreatorConstants.PROPERTY_CATEGORY);
@ -108,14 +133,7 @@ public class CompositeComponentAdapter implements ComponentAdapter {
groupProperties.add(property); groupProperties.add(property);
} }
adjustGroupNamesPosition(groupNames); adjustGroupNamesPosition(groupNames);
ArrayList<PropertyGroupModel> groups = new ArrayList<PropertyGroupModel>(); return groupNames;
for (String groupName : groupNames) {
ArrayList<CRPropertyDescriptor> groupProperties = maps.get(groupName);
PropertyGroupModel groupModel = new PropertyGroupModel(groupName, xCreator, groupProperties
.toArray(new CRPropertyDescriptor[0]), designer);
groups.add(groupModel);
}
return groups;
} }
public void adjustGroupNamesPosition(ArrayList<String> groupNames){ public void adjustGroupNamesPosition(ArrayList<String> groupNames){
@ -138,6 +156,17 @@ public class CompositeComponentAdapter implements ComponentAdapter {
return groupModels; return groupModels;
} }
@Override
public ArrayList<PropertyGroupPane> getXCreatorPropertyPane() {
ArrayList<PropertyGroupPane> groupModels = new ArrayList<PropertyGroupPane>();
CRPropertyDescriptor[] properties;
properties = getCalculateCreatorProperties();
ArrayList<PropertyGroupPane> groups = createPropertyGroupPanes(properties);
// Collections.sort(groups);
groupModels.addAll(groups);
return groupModels;
}
/** /**
* 自适应布局中放置文本框等用的scaleLayout和报表块图表块支持的标题控件用的titleLayout时 * 自适应布局中放置文本框等用的scaleLayout和报表块图表块支持的标题控件用的titleLayout时
* 控件树处只显示父容器但是控件属性还是为自身的 * 控件树处只显示父容器但是控件属性还是为自身的

76
designer_form/src/com/fr/design/designer/creator/CRPropertyDescriptorPane.java

@ -1,13 +1,19 @@
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.xtable.TableUtils; import com.fr.design.gui.xtable.TableUtils;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.editors.ExtendedPropertyEditor; import com.fr.design.mainframe.widget.editors.ExtendedPropertyEditor;
import com.fr.design.mainframe.widget.editors.StringEditor; import com.fr.design.mainframe.widget.editors.StringEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils;
import java.awt.*; import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.Component;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.beans.PropertyEditor; import java.beans.PropertyEditor;
@ -20,6 +26,7 @@ public class CRPropertyDescriptorPane {
private CRPropertyDescriptor crPropertyDescriptor; private CRPropertyDescriptor crPropertyDescriptor;
private XCreator xCreator; private XCreator xCreator;
private PropertyEditor propertyEditor; private PropertyEditor propertyEditor;
private boolean isPopulate = true;
public CRPropertyDescriptorPane(CRPropertyDescriptor crPropertyDescriptor, XCreator xCreator) { public CRPropertyDescriptorPane(CRPropertyDescriptor crPropertyDescriptor, XCreator xCreator) {
this.crPropertyDescriptor = crPropertyDescriptor; this.crPropertyDescriptor = crPropertyDescriptor;
@ -27,7 +34,19 @@ public class CRPropertyDescriptorPane {
} }
public Component[] createTableLayoutComponent() { public Component[] createTableLayoutComponent() {
return new Component[]{new UILabel(crPropertyDescriptor.getDisplayName()), initEditorComponent(crPropertyDescriptor, xCreator)}; Component component = initEditorComponent(crPropertyDescriptor, xCreator);
if (component instanceof UICheckBox) {
((UICheckBox) component).setText(crPropertyDescriptor.getDisplayName());
return new Component[]{component, null};
}
if (crPropertyDescriptor.isSubLevel()) {
JPanel subPanel = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{new Component[]{new UILabel(crPropertyDescriptor.getDisplayName()), component}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L2, IntervalConstants.INTERVAL_L1);
subPanel.setBorder(BorderFactory.createEmptyBorder(0, IntervalConstants.INTERVAL_L5, 0, 0));
return new Component[]{subPanel, null};
}
return new Component[]{new UILabel(crPropertyDescriptor.getDisplayName()), component};
} }
private Component initEditorComponent(CRPropertyDescriptor crPropertyDescriptor, final XCreator xCreator) { private Component initEditorComponent(CRPropertyDescriptor crPropertyDescriptor, final XCreator xCreator) {
@ -35,22 +54,40 @@ public class CRPropertyDescriptorPane {
try { try {
// 如果已有的编辑器就生成对应的component // 如果已有的编辑器就生成对应的component
Class<?> editorClass = crPropertyDescriptor.getPropertyEditorClass(); Class<?> editorClass = crPropertyDescriptor.getPropertyEditorClass();
ExtendedPropertyEditor editor = null;
if (editorClass != null) { if (editorClass != null) {
propertyEditor = initExtendEditor(crPropertyDescriptor, xCreator); editor = (ExtendedPropertyEditor) crPropertyDescriptor.createPropertyEditor(xCreator.toData());
component = propertyEditor.getCustomEditor(); if (editor == null) {
Class propType = crPropertyDescriptor.getPropertyType();
editor = TableUtils.getPropertyEditorClass(propType).newInstance();
}
} else { } else {
Class propType = crPropertyDescriptor.getPropertyType(); Class propType = crPropertyDescriptor.getPropertyType();
Class<? extends PropertyEditor> defaultEditorClass = TableUtils.getPropertyEditorClass(propType); Class<? extends ExtendedPropertyEditor> defaultEditorClass = TableUtils.getPropertyEditorClass(propType);
if (defaultEditorClass == null) { if (defaultEditorClass == null) {
defaultEditorClass = StringEditor.class; defaultEditorClass = StringEditor.class;
} }
propertyEditor = defaultEditorClass.newInstance(); editor = defaultEditorClass.newInstance();
component = propertyEditor.getCustomEditor();
} }
propertyEditor.addPropertyChangeListener(new PropertyChangeListener() { propertyEditor = editor;
component = propertyEditor.getCustomEditor();
final ExtendedPropertyEditor extendEditor = editor;
extendEditor.addPropertyChangeListener(new PropertyChangeListener() {
@Override @Override
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
if (isPopulate) {
return;
}
if (ComparatorUtils.equals(extendEditor.getValue(), getValue(xCreator.toData()))) {
return;
}
update(xCreator.toData()); update(xCreator.toData());
if (extendEditor.refreshInTime()) {
WidgetPropertyPane.getInstance().refreshDockingView();
}
} }
}); });
} catch (Exception e) { } catch (Exception e) {
@ -71,19 +108,34 @@ public class CRPropertyDescriptorPane {
public void populate(Widget widget) { public void populate(Widget widget) {
try { try {
Method m = crPropertyDescriptor.getReadMethod(); isPopulate = true;
Object value = m.invoke(widget); Object value = getValue(widget);
propertyEditor.setValue(value); propertyEditor.setValue(value);
isPopulate = false;
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
} }
public Object getValue(Widget widget) {
try {
Method m = crPropertyDescriptor.getReadMethod();
Object value = m.invoke(widget);
return value;
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
return null;
}
} }
public void update(Widget widget) { public void update(Widget widget) {
try { try {
Object value = propertyEditor.getValue();
Method m = crPropertyDescriptor.getWriteMethod(); Method m = crPropertyDescriptor.getWriteMethod();
m.invoke(widget, propertyEditor.getValue()); m.invoke(widget, value);
crPropertyDescriptor.firePropertyChanged();
} catch (Exception e) { } catch (Exception e) {
} }

24
designer_form/src/com/fr/design/designer/creator/PropertyGroupPane.java

@ -8,8 +8,12 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.form.ui.FreeButton; import com.fr.form.ui.FreeButton;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import javax.swing.*; import javax.swing.BorderFactory;
import java.awt.*; import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
/** /**
* Created by kerry on 2017/9/7. * Created by kerry on 2017/9/7.
@ -18,6 +22,16 @@ public class PropertyGroupPane extends BasicPane {
private CRPropertyDescriptor[] crPropertyDescriptors; private CRPropertyDescriptor[] crPropertyDescriptors;
private CRPropertyDescriptorPane[] crPropertyDescriptorPanes; private CRPropertyDescriptorPane[] crPropertyDescriptorPanes;
private XCreator xCreator; private XCreator xCreator;
private String groupName;
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public PropertyGroupPane(CRPropertyDescriptor[] crPropertyDescriptors, XCreator xCreator) { public PropertyGroupPane(CRPropertyDescriptor[] crPropertyDescriptors, XCreator xCreator) {
this.crPropertyDescriptors = crPropertyDescriptors; this.crPropertyDescriptors = crPropertyDescriptors;
@ -26,6 +40,12 @@ public class PropertyGroupPane extends BasicPane {
initComponent(); initComponent();
} }
public PropertyGroupPane(CRPropertyDescriptor[] crPropertyDescriptors, XCreator xCreator, String groupName) {
this(crPropertyDescriptors, xCreator);
this.groupName = groupName;
}
public void initComponent() { public void initComponent() {
int count = crPropertyDescriptors.length; int count = crPropertyDescriptors.length;
crPropertyDescriptorPanes = new CRPropertyDescriptorPane[count]; crPropertyDescriptorPanes = new CRPropertyDescriptorPane[count];

2
designer_form/src/com/fr/design/designer/creator/XWidgetCreator.java

@ -57,7 +57,7 @@ public abstract class XWidgetCreator extends XCreator {
}), }),
new CRPropertyDescriptor("labelName", this.data.getClass(), "getLabelName", "setLabelName") new CRPropertyDescriptor("labelName", this.data.getClass(), "getLabelName", "setLabelName")
.setI18NName(Inter.getLocText("FR-Designer_Label_Name")) .setI18NName(Inter.getLocText("FR-Designer_Label_Name"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "FR-Designer_Advanced") .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced")
}; };
} }

2
designer_form/src/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java

@ -156,7 +156,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane {
private void initDefinePane() { private void initDefinePane() {
currentEditorDefinePane = null; currentEditorDefinePane = null;
XCreator creator = getXCreatorDedicated(); XCreator creator = getXCreatorDedicated();
FormWidgetDefinePaneFactoryBase.RN rn = FormWidgetDefinePaneFactoryBase.createWidgetDefinePane(creator, creator.toData(), new Operator() { FormWidgetDefinePaneFactoryBase.RN rn = FormWidgetDefinePaneFactoryBase.createWidgetDefinePane(creator, designer, creator.toData(), new Operator() {
@Override @Override
public void did(DataCreatorUI ui, String cardName) { public void did(DataCreatorUI ui, String cardName) {
//todo //todo

10
designer_form/src/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java

@ -3,6 +3,8 @@ package com.fr.design.widget;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.gui.core.WidgetConstants; import com.fr.design.gui.core.WidgetConstants;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.widget.ui.designer.WidgetDefinePane;
import com.fr.design.parameter.RootDesignDefinePane; import com.fr.design.parameter.RootDesignDefinePane;
import com.fr.design.widget.ui.designer.*; import com.fr.design.widget.ui.designer.*;
import com.fr.design.widget.ui.designer.layout.*; import com.fr.design.widget.ui.designer.layout.*;
@ -11,7 +13,6 @@ import com.fr.form.ui.*;
import com.fr.form.ui.container.*; import com.fr.form.ui.container.*;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.Inter;
import com.fr.stable.bridge.BridgeMark; import com.fr.stable.bridge.BridgeMark;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
@ -66,8 +67,6 @@ public class FormWidgetDefinePaneFactoryBase {
defineMap.put(WCardLayout.class, new Appearance(WCardLayoutDefinePane.class, "wCardLayout")); defineMap.put(WCardLayout.class, new Appearance(WCardLayoutDefinePane.class, "wCardLayout"));
defineMap.put(Label.class, new Appearance(LabelDefinePane.class, "label")); defineMap.put(Label.class, new Appearance(LabelDefinePane.class, "label"));
defineMap.put(WTabFitLayout.class, new Appearance(WTabFitLayoutDefinePane.class, "wTabFitLayout")); defineMap.put(WTabFitLayout.class, new Appearance(WTabFitLayoutDefinePane.class, "wTabFitLayout"));
//todo 添加扩展控件接口
// defineMap.putAll(getOtherWidgetOptionMap());
} }
@ -76,10 +75,11 @@ public class FormWidgetDefinePaneFactoryBase {
} }
public static RN createWidgetDefinePane(XCreator creator, Widget widget, Operator operator) { public static RN createWidgetDefinePane(XCreator creator, FormDesigner designer, Widget widget, Operator operator) {
Appearance dn = defineMap.get(widget.getClass()); Appearance dn = defineMap.get(widget.getClass());
if(dn == null){ if(dn == null){
dn = new Appearance(DefaultWidgetDefinePane.class, "default"); WidgetDefinePane widgetDefinePane = new WidgetDefinePane(creator, designer);
return new RN(widgetDefinePane, widgetDefinePane.title4PopupWindow());
} }
DataModify<Widget> definePane = null; DataModify<Widget> definePane = null;
try { try {

12
designer_form/src/com/fr/design/widget/ui/designer/AbstractDataModify.java

@ -3,6 +3,7 @@ package com.fr.design.widget.ui.designer;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.data.DataCreatorUI; import com.fr.design.data.DataCreatorUI;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.widget.DataModify; import com.fr.design.widget.DataModify;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -13,6 +14,7 @@ import javax.swing.JComponent;
*/ */
public abstract class AbstractDataModify<T> extends BasicBeanPane<T> implements DataModify<T> { public abstract class AbstractDataModify<T> extends BasicBeanPane<T> implements DataModify<T> {
protected XCreator creator; protected XCreator creator;
protected FormDesigner designer;
protected String globalName; protected String globalName;
@ -20,11 +22,21 @@ public abstract class AbstractDataModify<T> extends BasicBeanPane<T> implements
this.creator = xCreator; this.creator = xCreator;
} }
public AbstractDataModify(XCreator xCreator, FormDesigner designer){
this.creator = xCreator;
this.designer = designer;
}
@Override @Override
public DataCreatorUI dataUI() { public DataCreatorUI dataUI() {
return null; return null;
} }
@Override
public String title4PopupWindow() {
return creator.createDefaultName();
}
@Override @Override
public JComponent toSwingComponent() { public JComponent toSwingComponent() {
return this; return this;

72
designer_form/src/com/fr/design/widget/ui/designer/WidgetDefinePane.java

@ -0,0 +1,72 @@
package com.fr.design.widget.ui.designer;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.creator.PropertyGroupPane;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.util.ArrayList;
/**
* Created by kerry on 2017/9/27.
*/
public class WidgetDefinePane extends AbstractDataModify<Widget> {
private ArrayList<PropertyGroupPane> groupPanes;
private static final int START_INDEX = 1;
public WidgetDefinePane(XCreator source, FormDesigner designer) {
super(source, designer);
this.setLayout(FRGUIPaneFactory.createBorderLayout());
initComponent(source, designer);
}
public void initComponent(XCreator source, FormDesigner designer) {
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, source);
groupPanes = adapter.getXCreatorPropertyPane();
//todo 留着做兼容,以后删掉
for (int i = 0; i < groupPanes.size(); i++) {
if (ComparatorUtils.equals(groupPanes.get(i).getGroupName(), "Form-Basic_Properties")) {
groupPanes.remove(i);
}
}
this.add(createCenterPane(START_INDEX), BorderLayout.CENTER);
}
private JPanel createCenterPane(int index) {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
if (index != groupPanes.size()) {
jPanel.add(createExpandPane(groupPanes.get(index - 1)), BorderLayout.NORTH);
jPanel.add(createCenterPane(index + 1), BorderLayout.CENTER);
} else {
jPanel.add(createExpandPane(groupPanes.get(index - 1)), BorderLayout.CENTER);
}
return jPanel;
}
public JPanel createExpandPane(PropertyGroupPane propertyGroupPane) {
JPanel jPanel = new UIExpandablePane(Inter.getLocText(propertyGroupPane.getGroupName()), 280, 24, propertyGroupPane);
return jPanel;
}
public void populateBean(Widget ob) {
for (int i = 0; i < groupPanes.size(); i++) {
groupPanes.get(i).populate(ob);
}
}
public Widget updateBean() {
return creator.toData();
}
}
Loading…
Cancel
Save