Browse Source

绝对布局的属性表缩放属性新增

master
zhouping 8 years ago
parent
commit
687f040263
  1. 14
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  2. 31
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java
  3. 12
      designer_form/src/com/fr/design/designer/properties/AbsoluteStateRenderer.java
  4. 12
      designer_form/src/com/fr/design/designer/properties/AbsoluteStateWrapper.java
  5. 94
      designer_form/src/com/fr/design/designer/properties/FRAbsoluteLayoutPropertiesGroupModel.java
  6. 19
      designer_form/src/com/fr/design/designer/properties/items/FRAbsoluteConstraintsItems.java
  7. 13
      designer_form/src/com/fr/design/mainframe/widget/editors/AbsoluteLayoutDirectionEditor.java

14
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java

@ -2,14 +2,14 @@ package com.fr.design.designer.beans.adapters.layout;
import java.awt.*;
import com.fr.design.beans.GroupModel;
import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.painters.FRAbsoluteLayoutPainter;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.*;
import com.fr.design.designer.properties.BoundsGroupModel;
import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel;
import com.fr.design.designer.properties.FRFitLayoutPropertiesGroupModel;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils;
@ -112,4 +112,10 @@ public class FRAbsoluteLayoutAdapter extends AbstractLayoutAdapter {
public ConstraintsGroupModel getLayoutConstraints(XCreator creator) {
return new BoundsGroupModel((XWAbsoluteLayout)container, creator);
}
@Override
public GroupModel getLayoutProperties() {
XWAbsoluteLayout xwAbsoluteLayout = (XWAbsoluteLayout) container;
return new FRAbsoluteLayoutPropertiesGroupModel(xwAbsoluteLayout);
}
}

31
designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java

@ -7,6 +7,7 @@ import java.awt.*;
import java.awt.event.ContainerEvent;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.beans.IntrospectionException;
import java.util.HashMap;
import com.fr.design.designer.beans.AdapterBus;
@ -17,15 +18,21 @@ import com.fr.design.designer.beans.adapters.layout.FRAbsoluteLayoutAdapter;
import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.form.layout.FRAbsoluteLayout;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
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.PaddingMarginCellRenderer;
import com.fr.form.ui.Connector;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.stable.core.PropertyChangeAdapter;
/**
* @author richer
@ -105,7 +112,17 @@ public class XWAbsoluteLayout extends XLayoutContainer {
protected void initLayoutManager() {
this.setLayout(new FRAbsoluteLayout());
}
/**
* 是否支持标题样式
*
* @return 默认false
*/
@Override
public boolean hasTitleStyle() {
return false;
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
@ -211,6 +228,18 @@ public class XWAbsoluteLayout extends XLayoutContainer {
}
}
/**
* 得到属性名
* @return 属性名
* @throws java.beans.IntrospectionException
*/
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
return new CRPropertyDescriptor[] {
new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(
Inter.getLocText("FR-Designer_Form-Widget_Name"))
};
}
public void paint(Graphics g) {
super.paint(g);
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层

12
designer_form/src/com/fr/design/designer/properties/AbsoluteStateRenderer.java

@ -0,0 +1,12 @@
package com.fr.design.designer.properties;
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer;
/**
* Created by zhouping on 2016/8/1.
*/
public class AbsoluteStateRenderer extends EncoderCellRenderer {
public AbsoluteStateRenderer() {
super(new AbsoluteStateWrapper());
}
}

12
designer_form/src/com/fr/design/designer/properties/AbsoluteStateWrapper.java

@ -0,0 +1,12 @@
package com.fr.design.designer.properties;
import com.fr.design.designer.properties.items.FRAbsoluteConstraintsItems;
/**
* Created by zhouping on 2016/8/1.
*/
public class AbsoluteStateWrapper extends ItemWrapper{
public AbsoluteStateWrapper() {
super(new FRAbsoluteConstraintsItems());
}
}

94
designer_form/src/com/fr/design/designer/properties/FRAbsoluteLayoutPropertiesGroupModel.java

@ -0,0 +1,94 @@
package com.fr.design.designer.properties;
import com.fr.design.beans.GroupModel;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.mainframe.widget.editors.AbsoluteLayoutDirectionEditor;
import com.fr.design.mainframe.widget.editors.IntegerPropertyEditor;
import com.fr.design.mainframe.widget.editors.PropertyCellEditor;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.general.Inter;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
/**
* Created by zhouping on 2016/8/1.
*/
public class FRAbsoluteLayoutPropertiesGroupModel implements GroupModel {
private PropertyCellEditor editor;
private DefaultTableCellRenderer renderer;
private AbsoluteLayoutDirectionEditor stateEditor;
private AbsoluteStateRenderer stateRenderer;
private WAbsoluteLayout layout;
private XWAbsoluteLayout xwAbsoluteLayout;
public FRAbsoluteLayoutPropertiesGroupModel(XWAbsoluteLayout xwAbsoluteLayout){
this.xwAbsoluteLayout = xwAbsoluteLayout;
this.layout = xwAbsoluteLayout.toData();
renderer = new DefaultTableCellRenderer();
editor = new PropertyCellEditor(new IntegerPropertyEditor());
stateEditor = new AbsoluteLayoutDirectionEditor();
stateRenderer = new AbsoluteStateRenderer();
}
/**
* 布局管理器自己的属性
*/
@Override
public String getGroupName() {
return Inter.getLocText("FR-Designer-Widget_Area_Scaling");
}
@Override
public int getRowCount() {
return 1;
}
@Override
public TableCellRenderer getRenderer(int row) {
return stateRenderer;
}
@Override
public TableCellEditor getEditor(int row) {
return stateEditor;
}
@Override
public Object getValue(int row, int column) {
if (column == 0) {
return Inter.getLocText("FR-Designer-Widget_Scaling_Mode");
} else {
return layout.getCompState();
}
}
@Override
public boolean setValue(Object value, int row, int column) {
int state = 0;
if(value instanceof Integer) {
state = (Integer)value;
}
if (column == 0 || state < 0) {
return false;
} else {
if (row == 0) {
layout.setCompState(state);
return true;
}
return false;
}
}
/**
* 是否可编辑
* @param row
* @return
*/
@Override
public boolean isEditable(int row) {
return true;
}
}

19
designer_form/src/com/fr/design/designer/properties/items/FRAbsoluteConstraintsItems.java

@ -0,0 +1,19 @@
package com.fr.design.designer.properties.items;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.general.Inter;
/**
* Created by zhouping on 2016/8/1.
*/
public class FRAbsoluteConstraintsItems implements ItemProvider{
public static final Item[] ITEMS = new Item[] {
new Item(Inter.getLocText("FR-Designer_Widget_Scaling_Mode_Fit"), WAbsoluteLayout.STATE_FIT),
new Item(Inter.getLocText("FR-Designer_Widget_Scaling_Mode_Fixed"), WAbsoluteLayout.STATE_FIXED)
};
public Item[] getItems() {
return ITEMS;
}
}

13
designer_form/src/com/fr/design/mainframe/widget/editors/AbsoluteLayoutDirectionEditor.java

@ -0,0 +1,13 @@
package com.fr.design.mainframe.widget.editors;
import com.fr.design.designer.properties.EnumerationEditor;
import com.fr.design.designer.properties.items.FRAbsoluteConstraintsItems;
/**
* Created by zhouping on 2016/8/1.
*/
public class AbsoluteLayoutDirectionEditor extends EnumerationEditor {
public AbsoluteLayoutDirectionEditor() {
super(new FRAbsoluteConstraintsItems());
}
}
Loading…
Cancel
Save