Browse Source

Merge pull request #91 in BA/design from ~NEIL/design:master to master

* commit '811d74157e18fda1d793d2bdf1c088ab63b0ae68':
  移动端自适应master
master
superman 9 years ago
parent
commit
82710ab726
  1. 74
      designer/src/com/fr/design/actions/report/ReportMobileAttrAction.java
  2. 3
      designer/src/com/fr/design/mainframe/JWorkBook.java
  3. 118
      designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java
  4. 62
      designer/src/com/fr/design/report/mobile/ReportMobileAttrPane.java
  5. BIN
      designer_base/src/com/fr/design/images/m_report/mobile.png
  6. 10
      designer_form/src/com/fr/design/designer/creator/XCreator.java
  7. 103
      designer_form/src/com/fr/design/designer/creator/XElementCase.java
  8. 29
      designer_form/src/com/fr/design/designer/creator/XWTitleLayout.java
  9. 68
      designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyTable.java
  10. 29
      designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyUI.java
  11. 25
      designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java
  12. 50
      designer_form/src/com/fr/design/designer/properties/mobile/MobileFitEditor.java
  13. 10
      designer_form/src/com/fr/design/designer/properties/mobile/MobileFitRender.java
  14. 9
      designer_form/src/com/fr/design/designer/properties/mobile/MobileFitWrapper.java
  15. 86
      designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java
  16. 43
      designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java

74
designer/src/com/fr/design/actions/report/ReportMobileAttrAction.java

@ -0,0 +1,74 @@
package com.fr.design.actions.report;
import com.fr.base.BaseUtils;
import com.fr.design.actions.JWorkBookAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.report.mobile.ReportMobileAttrPane;
import com.fr.general.Inter;
import com.fr.main.TemplateWorkBook;
import com.fr.report.mobile.ElementCaseMobileAttr;
import javax.swing.*;
import java.awt.event.ActionEvent;
/**
* 设置cpt在移动端的一些属性, 包括自适应以及以后可能加展示区域之类的东西.
*
* Created by Administrator on 2016/5/12/0012.
*/
public class ReportMobileAttrAction extends JWorkBookAction{
public ReportMobileAttrAction(JWorkBook jwb) {
super(jwb);
this.setMenuKeySet(REPORT_APP_ATTR);
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/mobile.png"));
}
/**
* 执行动作
*
* @return 是否执行成功
*/
public void actionPerformed(ActionEvent evt) {
final JWorkBook jwb = getEditingComponent();
if (jwb == null) {
return;
}
final TemplateWorkBook wbTpl = jwb.getTarget();
ElementCaseMobileAttr mobileAttr = wbTpl.getReportMobileAttr();
final ReportMobileAttrPane mobileAttrPane = new ReportMobileAttrPane();
mobileAttrPane.populateBean(mobileAttr);
BasicDialog dialog = mobileAttrPane.showMediumWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
wbTpl.setReportMobileAttr(mobileAttrPane.updateBean());
jwb.fireTargetModified();
}
});
dialog.setVisible(true);
}
private static final MenuKeySet REPORT_APP_ATTR = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'P';
}
@Override
public String getMenuName() {
return Inter.getLocText("FR-Designer_Mobile-Attr");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
}

3
designer/src/com/fr/design/mainframe/JWorkBook.java

@ -7,10 +7,10 @@ import com.fr.design.DesignModelAdapter;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.AllowAuthorityEditAction; import com.fr.design.actions.AllowAuthorityEditAction;
import com.fr.design.actions.ExitAuthorityEditAction; import com.fr.design.actions.ExitAuthorityEditAction;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.actions.file.WebPreviewUtils; import com.fr.design.actions.file.WebPreviewUtils;
import com.fr.design.actions.file.export.*; import com.fr.design.actions.file.export.*;
import com.fr.design.actions.report.ReportExportAttrAction; import com.fr.design.actions.report.ReportExportAttrAction;
import com.fr.design.actions.report.ReportMobileAttrAction;
import com.fr.design.actions.report.ReportParameterAction; import com.fr.design.actions.report.ReportParameterAction;
import com.fr.design.actions.report.ReportWebAttrAction; import com.fr.design.actions.report.ReportWebAttrAction;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
@ -478,6 +478,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
new ReportWebAttrAction(this), new ReportWebAttrAction(this),
new ReportExportAttrAction(this), new ReportExportAttrAction(this),
new ReportParameterAction(this), new ReportParameterAction(this),
new ReportMobileAttrAction(this),
new NameSeparator(Inter.getLocText("Utils-Current_Sheet")), new NameSeparator(Inter.getLocText("Utils-Current_Sheet")),
}, this.reportComposite.getEditingReportComponent().shortcut4TemplateMenu()); }, this.reportComposite.getEditingReportComponent().shortcut4TemplateMenu());
} }

118
designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java

@ -0,0 +1,118 @@
package com.fr.design.report.mobile;
import com.fr.base.mobile.MobileFitAttrState;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Administrator on 2016/5/16/0016.
*/
public class MobileRadioGroupPane extends BasicBeanPane<MobileFitAttrState> {
private List<UIRadioButton> radioButtons = new ArrayList<UIRadioButton>();
public MobileRadioGroupPane(String title) {
initComponents(title);
}
private void initComponents(String title) {
double p = TableLayout.PREFERRED;
double[] rowSize = {p};
double[] columnSize = {p, p, p, p, p};
UIRadioButton defaultRadio = new UIRadioButton(MobileFitAttrState.DEFAULT.description());
defaultRadio.setSelected(true);
UIRadioButton horizonRadio = new UIRadioButton(MobileFitAttrState.HORIZONTAL.description());
UIRadioButton verticalRadio = new UIRadioButton(MobileFitAttrState.VERTICAL.description());
UIRadioButton notFitRadio = new UIRadioButton(MobileFitAttrState.NONE.description());
addToButtonGroup(defaultRadio, horizonRadio, verticalRadio, notFitRadio);
Component[][] components = new Component[][]{
new Component[]{new UILabel(title), defaultRadio, horizonRadio, verticalRadio, notFitRadio}
};
JPanel fitOpsPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
fitOpsPane.setBorder(BorderFactory.createEmptyBorder(10, 13, 10, 10));
this.add(fitOpsPane);
}
private void addToButtonGroup(UIRadioButton... radios) {
ButtonGroup buttonGroup = new ButtonGroup();
for (UIRadioButton radio : radios) {
radioButtons.add(radio);
buttonGroup.add(radio);
}
}
/**
* 设置按钮状态
*/
public void setEnabled(boolean enabled) {
for (UIRadioButton radioButton : radioButtons) {
radioButton.setEnabled(enabled);
}
}
/**
* 获取当前选中的按钮index
*
* @return 按钮index
*/
public int getSelectRadioIndex() {
for (int i = 0, len = radioButtons.size(); i < len; i++) {
if (radioButtons.get(i).isSelected()) {
return i;
}
}
return 0;
}
/**
* 选中指定index的按钮
*/
public void selectIndexButton(int index) {
if (index < 0 || index > radioButtons.size() - 1) {
return;
}
UIRadioButton button = radioButtons.get(index);
button.setSelected(true);
}
/**
* 给所有的按钮加上监听
*/
public void addActionListener(ActionListener actionListener) {
for (UIRadioButton radioButton : radioButtons) {
radioButton.addActionListener(actionListener);
}
}
@Override
public void populateBean(MobileFitAttrState ob) {
selectIndexButton(ob.getState());
}
@Override
public MobileFitAttrState updateBean() {
int index = getSelectRadioIndex();
return MobileFitAttrState.parse(index);
}
@Override
protected String title4PopupWindow() {
return StringUtils.EMPTY;
}
}

62
designer/src/com/fr/design/report/mobile/ReportMobileAttrPane.java

@ -0,0 +1,62 @@
package com.fr.design.report.mobile;
import com.fr.base.mobile.MobileFitAttrState;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.Inter;
import com.fr.report.mobile.ElementCaseMobileAttr;
import javax.swing.*;
import java.awt.*;
/**
* Created by Administrator on 2016/5/12/0012.
*/
public class ReportMobileAttrPane extends BasicBeanPane<ElementCaseMobileAttr> {
//横屏设置面板
private MobileRadioGroupPane horizionPane;
//竖屏设置面板
private MobileRadioGroupPane verticalPane;
public ReportMobileAttrPane() {
initComponents();
}
private void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel borderPane = FRGUIPaneFactory.createTitledBorderPane(this.title4PopupWindow());
JPanel fitOpsPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
horizionPane = new MobileRadioGroupPane(Inter.getLocText("FR-Designer_Mobile-Horizontal"));
verticalPane = new MobileRadioGroupPane(Inter.getLocText("FR-Designer_Mobile-Vertical"));
fitOpsPane.add(horizionPane, BorderLayout.NORTH);
fitOpsPane.add(verticalPane, BorderLayout.SOUTH);
borderPane.add(fitOpsPane);
this.add(borderPane);
}
@Override
public void populateBean(ElementCaseMobileAttr ob) {
if (ob == null) {
ob = new ElementCaseMobileAttr();
}
horizionPane.populateBean(ob.getHorziontalAttr());
verticalPane.populateBean(ob.getVerticalAttr());
}
@Override
public ElementCaseMobileAttr updateBean() {
MobileFitAttrState horizonState = horizionPane.updateBean();
MobileFitAttrState verticalState = verticalPane.updateBean();
return new ElementCaseMobileAttr(horizonState, verticalState);
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("FR-Designer_Fit-App");
}
}

BIN
designer_base/src/com/fr/design/images/m_report/mobile.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

10
designer_form/src/com/fr/design/designer/creator/XCreator.java

@ -8,6 +8,7 @@ import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.events.DesignerEditor; import com.fr.design.designer.beans.events.DesignerEditor;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.*; import com.fr.design.mainframe.*;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
@ -518,4 +519,13 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public void recalculateChildHeight(int height){ public void recalculateChildHeight(int height){
return; return;
} }
/**
* 获取当前组件自定义的属性表tab
*
* @return 属性表tab数组
*/
public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
return new WidgetPropertyUIProvider[0];
}
} }

103
designer_form/src/com/fr/design/designer/creator/XElementCase.java

@ -1,15 +1,15 @@
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.designer.properties.mobile.ElementCasePropertyUI;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.fun.FormElementCaseEditorProcessor; import com.fr.design.fun.FormElementCaseEditorProcessor;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.CoverReportPane; import com.fr.design.mainframe.CoverReportPane;
import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.widget.editors.BooleanEditor; import com.fr.design.mainframe.widget.editors.*;
import com.fr.design.mainframe.widget.editors.PaddingMarginEditor;
import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor;
import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer; import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer;
import com.fr.design.mainframe.widget.renderer.PaddingMarginCellRenderer; import com.fr.design.mainframe.widget.renderer.PaddingMarginCellRenderer;
import com.fr.form.FormElementCaseContainerProvider; import com.fr.form.FormElementCaseContainerProvider;
@ -25,6 +25,8 @@ import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor; import java.beans.PropertyDescriptor;
import java.util.ArrayList;
import java.util.List;
public class XElementCase extends XBorderStyleWidgetCreator implements FormElementCaseContainerProvider{ public class XElementCase extends XBorderStyleWidgetCreator implements FormElementCaseContainerProvider{
private UILabel imageLable; private UILabel imageLable;
@ -53,37 +55,66 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
* @return 返回组件属性值 * @return 返回组件属性值
* @throws IntrospectionException 异常 * @throws IntrospectionException 异常
*/ */
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
CRPropertyDescriptor[] crp = ((ElementCaseEditor) data).isHeightRestrict() ? revealHeightLimit() : getDefault();
CRPropertyDescriptor[] propertyTableEditor = new CRPropertyDescriptor[]{ FormElementCaseEditorProcessor processor = ExtraDesignClassManager.getInstance().getPropertyTableEditor();
new CRPropertyDescriptor("widgetName", this.data.getClass()) if (processor == null) {
.setI18NName(Inter.getLocText("Form-Widget_Name")), return crp;
new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass( }
WLayoutBorderStyleEditor.class).setRendererClass(LayoutBorderStyleRenderer.class).setI18NName( PropertyDescriptor[] extraEditor = processor.createPropertyDescriptor(this.data.getClass());
Inter.getLocText("FR-Designer-Widget_Style")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") return (CRPropertyDescriptor[]) ArrayUtils.addAll(crp, extraEditor);
.setPropertyChangeListener(new PropertyChangeAdapter() { }
@Override protected List<CRPropertyDescriptor> createNonListenerProperties() throws IntrospectionException {
public void propertyChange() { CRPropertyDescriptor[] propertyTableEditor = {
initStyle(); new CRPropertyDescriptor("widgetName", this.data.getClass())
} .setI18NName(Inter.getLocText("Form-Widget_Name")),
}), new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass(
new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class) WLayoutBorderStyleEditor.class).setRendererClass(LayoutBorderStyleRenderer.class).setI18NName(
.setRendererClass(PaddingMarginCellRenderer.class).setI18NName(Inter.getLocText("FR-Layout_Padding")) Inter.getLocText("FR-Designer-Widget_Style")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced").
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), setPropertyChangeListener(new PropertyChangeAdapter() {
new CRPropertyDescriptor("showToolBar", this.data.getClass()).setEditorClass(BooleanEditor.class)
.setI18NName(Inter.getLocText("Form-EC_toolbar")) @Override
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), public void propertyChange() {
initStyle();
}; }
}),
FormElementCaseEditorProcessor processor = ExtraDesignClassManager.getInstance().getPropertyTableEditor(); new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class)
if (processor == null){ .setRendererClass(PaddingMarginCellRenderer.class).setI18NName(Inter.getLocText("FR-Layout_Padding"))
return propertyTableEditor; .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
} new CRPropertyDescriptor("showToolBar", this.data.getClass()).setEditorClass(BooleanEditor.class)
PropertyDescriptor[] extraEditor = processor.createPropertyDescriptor(this.data.getClass()); .setI18NName(Inter.getLocText("Form-EC_toolbar"))
return (CRPropertyDescriptor[]) ArrayUtils.addAll(propertyTableEditor, extraEditor); .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
} new CRPropertyDescriptor("heightRestrict", this.data.getClass()).setEditorClass(InChangeBooleanEditor.class)
.setI18NName(Inter.getLocText("Form-EC_heightrestrict"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced")
};
List<CRPropertyDescriptor> defaultList = new ArrayList<>();
for (CRPropertyDescriptor propertyDescriptor : propertyTableEditor) {
defaultList.add(propertyDescriptor);
}
return defaultList;
}
protected CRPropertyDescriptor[] revealHeightLimit() throws IntrospectionException {
CRPropertyDescriptor heightLimitProperty = new CRPropertyDescriptor("heightPercent", this.data.getClass())
.setEditorClass(DoubleEditor.class)
.setI18NName(Inter.getLocText("Form-EC_heightpercent"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced");
ArrayList<CRPropertyDescriptor> defaultList = (ArrayList<CRPropertyDescriptor>) createNonListenerProperties();
defaultList.add(heightLimitProperty);
return defaultList.toArray(new CRPropertyDescriptor[defaultList.size()]);
}
protected CRPropertyDescriptor[] getDefault() throws IntrospectionException {
ArrayList<CRPropertyDescriptor> defaultList = (ArrayList<CRPropertyDescriptor>) createNonListenerProperties();
return defaultList.toArray(new CRPropertyDescriptor[defaultList.size()]);
}
@Override @Override
protected String getIconName() { protected String getIconName() {
@ -232,4 +263,8 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
} }
} }
@Override
public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
return new WidgetPropertyUIProvider[]{ new ElementCasePropertyUI(this)};
}
} }

29
designer_form/src/com/fr/design/designer/creator/XWTitleLayout.java

@ -3,13 +3,10 @@
*/ */
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.ContainerEvent;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRTitleLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRTitleLayoutAdapter;
import com.fr.design.form.layout.FRTitleLayout; import com.fr.design.form.layout.FRTitleLayout;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.form.ui.Label; import com.fr.form.ui.Label;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetTitle; import com.fr.form.ui.WidgetTitle;
@ -17,6 +14,9 @@ import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WTitleLayout; import com.fr.form.ui.container.WTitleLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import java.awt.*;
import java.awt.event.ContainerEvent;
/** /**
* 一些控件 如图表报表块有标题设置且标题的高度字体等不变 * 一些控件 如图表报表块有标题设置且标题的高度字体等不变
* @author jim * @author jim
@ -77,8 +77,8 @@ public class XWTitleLayout extends DedicateLayoutContainer {
super.resetCreatorName(name); super.resetCreatorName(name);
// 有标题的话,标题的名字也要重置下 // 有标题的话,标题的名字也要重置下
if (getXCreatorCount() > 1) { if (getXCreatorCount() > 1) {
getTitleCreator().toData().setWidgetName(WidgetTitle.TITLE_NAME_INDEX + name); getTitleCreator().toData().setWidgetName(WidgetTitle.TITLE_NAME_INDEX + name);
} }
} }
/** /**
@ -139,12 +139,12 @@ public class XWTitleLayout extends DedicateLayoutContainer {
WTitleLayout layout = this.toData(); WTitleLayout layout = this.toData();
XWidgetCreator creator = (XWidgetCreator) e.getChild(); XWidgetCreator creator = (XWidgetCreator) e.getChild();
FRTitleLayout lay = (FRTitleLayout) getLayout(); FRTitleLayout lay = (FRTitleLayout) getLayout();
Object constraints = lay.getConstraints(creator); Object constraints = lay.getConstraints(creator);
if (ComparatorUtils.equals(WTitleLayout.TITLE,constraints)) { if (ComparatorUtils.equals(WTitleLayout.TITLE,constraints)) {
layout.addTitle(creator.toData(), creator.getBounds()); layout.addTitle(creator.toData(), creator.getBounds());
} else if (ComparatorUtils.equals(WTitleLayout.BODY,constraints)) { } else if (ComparatorUtils.equals(WTitleLayout.BODY,constraints)) {
layout.addBody(creator.toData(), creator.getBounds()); layout.addBody(creator.toData(), creator.getBounds());
} }
} }
/** /**
@ -164,4 +164,9 @@ public class XWTitleLayout extends DedicateLayoutContainer {
wlayout.removeWidget(wgt); wlayout.removeWidget(wgt);
} }
@Override
public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
XCreator creator = getPropertyDescriptorCreator();
return creator.getWidgetPropertyUIProviders();
}
} }

68
designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyTable.java

@ -0,0 +1,68 @@
package com.fr.design.designer.properties.mobile;
import com.fr.base.FRContext;
import com.fr.design.designer.creator.CRPropertyDescriptor;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.itable.AbstractPropertyTable;
import com.fr.design.gui.itable.PropertyGroup;
import com.fr.design.gui.xtable.PropertyGroupModel;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.general.Inter;
import javax.swing.table.TableModel;
import java.beans.IntrospectionException;
import java.util.ArrayList;
/**
* Created by Administrator on 2016/5/16/0016.
*/
public class ElementCasePropertyTable extends AbstractPropertyTable {
private XCreator xCreator;
private FormDesigner designer;
public ElementCasePropertyTable(XCreator xCreator) {
this.xCreator = xCreator;
}
@Override
public void initPropertyGroups(Object source) {
this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner();
groups = new ArrayList<PropertyGroup>();
CRPropertyDescriptor[] propertyTableEditor = null;
try {
propertyTableEditor = new CRPropertyDescriptor[]{
new CRPropertyDescriptor("horziontalAttr", this.xCreator.toData().getClass()).setEditorClass(MobileFitEditor.class)
.setRendererClass(MobileFitRender.class)
.setI18NName(Inter.getLocText("FR-Designer_Mobile-Horizontal"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, Inter.getLocText("FR-Designer_Fit-App")),
new CRPropertyDescriptor("verticalAttr", this.xCreator.toData().getClass()).setEditorClass(MobileFitEditor.class)
.setRendererClass(MobileFitRender.class)
.setI18NName(Inter.getLocText("FR-Designer_Mobile-Vertical"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, Inter.getLocText("FR-Designer_Fit-App"))
};
} catch (IntrospectionException e) {
FRContext.getLogger().error(e.getMessage());
}
groups.add(new PropertyGroup(new PropertyGroupModel(Inter.getLocText("FR-Designer_Fit-App"), xCreator, propertyTableEditor, designer)));
TableModel model = new BeanTableModel();
setModel(model);
this.repaint();
}
@Override
public void firePropertyEdit() {
}
public void populate(FormDesigner designer) {
this.designer = designer;
initPropertyGroups(this.designer.getTarget());
}
}

29
designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyUI.java

@ -0,0 +1,29 @@
package com.fr.design.designer.properties.mobile;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XElementCase;
import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider;
import com.fr.design.gui.itable.AbstractPropertyTable;
import com.fr.general.Inter;
/**
* Created by Administrator on 2016/5/16/0016.
*/
public class ElementCasePropertyUI extends AbstractWidgetPropertyUIProvider {
private XCreator xCreator;
public ElementCasePropertyUI(XElementCase xElementCase) {
this.xCreator = xElementCase;
}
@Override
public AbstractPropertyTable createWidgetAttrTable() {
return new ElementCasePropertyTable(xCreator);
}
@Override
public String tableTitle() {
return Inter.getLocText("FR-Designer_Mobile-Attr");
}
}

25
designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java

@ -0,0 +1,25 @@
package com.fr.design.designer.properties.mobile;
import com.fr.base.mobile.MobileFitAttrState;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.designer.properties.items.ItemProvider;
public class MobileFitAlignmentItems implements ItemProvider {
private static Item[] VALUE_ITEMS;
static {
MobileFitAttrState[] allStates = MobileFitAttrState.values();
int len = allStates.length;
VALUE_ITEMS = new Item[len];
for (int i = 0; i < len ; i++) {
VALUE_ITEMS[i] = new Item(allStates[i].description(), allStates[i]);
}
}
@Override
public Item[] getItems() {
return VALUE_ITEMS;
}
}

50
designer_form/src/com/fr/design/designer/properties/mobile/MobileFitEditor.java

@ -0,0 +1,50 @@
package com.fr.design.designer.properties.mobile;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.designer.properties.items.ItemProvider;
import com.fr.design.mainframe.widget.editors.ComboEditor;
import java.util.Vector;
public class MobileFitEditor extends ComboEditor {
public MobileFitEditor() {
this(new MobileFitAlignmentItems());
}
public MobileFitEditor(ItemProvider provider) {
this(provider.getItems());
}
public MobileFitEditor(Item[] items) {
super(items);
}
public MobileFitEditor(Vector<Item> items) {
super(items);
}
@Override
public void setValue(Object value) {
if (value == null) {
return;
}
Item item = new Item(value.toString(), value);
comboBox.setSelectedItem(item);
}
@Override
public Object getValue() {
Item item = (Item) comboBox.getSelectedItem();
return item.getValue();
}
/**
* ÊÇ·ñÁ¢¼´Ë¢ÐÂ
* @return ÊÇ»òÕß·ñ
*/
@Override
public boolean refreshInTime() {
return false;
}
}

10
designer_form/src/com/fr/design/designer/properties/mobile/MobileFitRender.java

@ -0,0 +1,10 @@
package com.fr.design.designer.properties.mobile;
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer;
public class MobileFitRender extends EncoderCellRenderer {
public MobileFitRender(){
super(new MobileFitWrapper());
}
}

9
designer_form/src/com/fr/design/designer/properties/mobile/MobileFitWrapper.java

@ -0,0 +1,9 @@
package com.fr.design.designer.properties.mobile;
import com.fr.design.designer.properties.ItemWrapper;
public class MobileFitWrapper extends ItemWrapper {
public MobileFitWrapper(){
super(new MobileFitAlignmentItems());
}
}

86
designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java

@ -18,15 +18,15 @@ import java.util.ArrayList;
public class PropertyGroupModel extends AbstractPropertyGroupModel { public class PropertyGroupModel extends AbstractPropertyGroupModel {
private FormDesigner designer; private FormDesigner designer;
public PropertyGroupModel(String name, XCreator creator, CRPropertyDescriptor[] propArray, public PropertyGroupModel(String name, XCreator creator, CRPropertyDescriptor[] propArray,
FormDesigner designer) { FormDesigner designer) {
super(name, creator, propArray); super(name, creator, propArray);
this.designer = designer; this.designer = designer;
} }
@Override @Override
public Object getValue(int row, int column) { public Object getValue(int row, int column) {
if (column == 0) { if (column == 0) {
return properties[row].getDisplayName(); return properties[row].getDisplayName();
@ -49,9 +49,9 @@ public class PropertyGroupModel extends AbstractPropertyGroupModel {
try { try {
Method m = properties[row].getWriteMethod(); Method m = properties[row].getWriteMethod();
m.invoke(dealCreatorData(), value); m.invoke(dealCreatorData(), value);
//属性名称为控件名时,单独处理下 //属性名称为控件名时,单独处理下
if(ComparatorUtils.equals(FormConstants.NAME, properties[row].getName())){ if(ComparatorUtils.equals(FormConstants.NAME, properties[row].getName())){
creator.resetCreatorName(value.toString()); creator.resetCreatorName(value.toString());
} }
properties[row].firePropertyChanged(); properties[row].firePropertyChanged();
return true; return true;
@ -109,39 +109,43 @@ public class PropertyGroupModel extends AbstractPropertyGroupModel {
* @return * @return
*/ */
private Object dealCreatorData() { private Object dealCreatorData() {
return creator.getPropertyDescriptorCreator().toData(); return creator.getPropertyDescriptorCreator().toData();
} }
@Override @Override
protected void initEditor(final int row) throws Exception { protected void initEditor(final int row) throws Exception {
ExtendedPropertyEditor editor = (ExtendedPropertyEditor) properties[row].createPropertyEditor(dealCreatorData()); ExtendedPropertyEditor editor = (ExtendedPropertyEditor) properties[row].createPropertyEditor(dealCreatorData());
if (editor == null) { if (editor == null) {
Class propType = properties[row].getPropertyType(); Class propType = properties[row].getPropertyType();
editor = TableUtils.getPropertyEditorClass(propType).newInstance(); editor = TableUtils.getPropertyEditorClass(propType).newInstance();
} }
if (editor != null) { if (editor != null) {
final ExtendedPropertyEditor extendEditor = editor; final ExtendedPropertyEditor extendEditor = editor;
editors[row] = new PropertyCellEditor(editor); editors[row] = new PropertyCellEditor(editor);
extendEditor.addPropertyChangeListener(new PropertyChangeListener() { extendEditor.addPropertyChangeListener(new PropertyChangeListener() {
@Override @Override
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
if(ComparatorUtils.equals(extendEditor.getValue(),getValue(row,1))) { if(ComparatorUtils.equals(extendEditor.getValue(),getValue(row,1))) {
return; return;
} }
if (extendEditor.refreshInTime()) { if (extendEditor.refreshInTime()) {
editors[row].stopCellEditing(); editors[row].stopCellEditing();
} else { } else {
setValue(extendEditor.getValue(), row, 1); setValue(extendEditor.getValue(), row, 1);
if ("widgetName".equals(properties[row].getName())) {
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_RENAMED); if (designer == null) {
} else { return;
designer.fireTargetModified(); }
} if ("widgetName".equals(properties[row].getName())) {
designer.refreshDesignerUI(); designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_RENAMED);
} } else {
} designer.fireTargetModified();
}); }
} designer.refreshDesignerUI();
} }
}
});
}
}
} }

43
designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java

@ -1,23 +1,23 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import java.awt.BorderLayout;
import java.util.ArrayList;
import java.util.List;
import javax.swing.*;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.properties.EventPropertyTable;
import com.fr.design.designer.properties.WidgetPropertyTable;
import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.general.Inter;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itable.AbstractPropertyTable; import com.fr.design.gui.itable.AbstractPropertyTable;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.general.Inter;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.stable.ArrayUtils;
import com.fr.design.designer.properties.EventPropertyTable;
import com.fr.design.designer.properties.WidgetPropertyTable; import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
/** /**
* 控件属性表Docking * 控件属性表Docking
@ -88,7 +88,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
tabbedPane.addTab(Inter.getLocText("Form-Properties"), psp); tabbedPane.addTab(Inter.getLocText("Form-Properties"), psp);
tabbedPane.addTab(Inter.getLocText("Form-Events"), esp); tabbedPane.addTab(Inter.getLocText("Form-Events"), esp);
WidgetPropertyUIProvider[] widgetAttrProviders = ExtraDesignClassManager.getInstance().getWidgetAttrProviders(); WidgetPropertyUIProvider[] widgetAttrProviders = getExtraPropertyUIProviders();
for (WidgetPropertyUIProvider widgetAttrProvider : widgetAttrProviders) { for (WidgetPropertyUIProvider widgetAttrProvider : widgetAttrProviders) {
AbstractPropertyTable propertyTable = widgetAttrProvider.createWidgetAttrTable(); AbstractPropertyTable propertyTable = widgetAttrProvider.createWidgetAttrTable();
widgetPropertyTables.add(propertyTable); widgetPropertyTables.add(propertyTable);
@ -106,6 +106,25 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
} }
} }
/**
* 获取当前控件扩展的属性tab
* 来源有两个:
* 1, 各个控件从各自的Xcreator里扩展;
* 2, 所有的控件从插件里扩展.
*
* @return 扩展的tab
*/
private WidgetPropertyUIProvider[] getExtraPropertyUIProviders() {
FormSelection selection = designer.getSelectionModel().getSelection();
WidgetPropertyUIProvider[] embeddedPropertyUIProviders = null;
if (selection != null && selection.getSelectedCreator() != null) {
embeddedPropertyUIProviders = selection.getSelectedCreator().getWidgetPropertyUIProviders();
}
WidgetPropertyUIProvider[] widgetAttrProviders = ExtraDesignClassManager.getInstance().getWidgetAttrProviders();
widgetAttrProviders = (WidgetPropertyUIProvider[]) ArrayUtils.addAll(embeddedPropertyUIProviders, widgetAttrProviders);
return widgetAttrProviders;
}
public void setEditingFormDesigner(BaseFormDesigner editor) { public void setEditingFormDesigner(BaseFormDesigner editor) {
FormDesigner fd = (FormDesigner) editor; FormDesigner fd = (FormDesigner) editor;
super.setEditingFormDesigner(fd); super.setEditingFormDesigner(fd);

Loading…
Cancel
Save