Browse Source

REPORT-578 表单组件样式属性小改良

master
kerry 8 years ago
parent
commit
fbbaab5055
  1. 67
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  2. 2
      designer_form/src/com/fr/design/designer/creator/XChartEditor.java
  3. 4
      designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java
  4. 2
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  5. 2
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java
  6. 42
      designer_form/src/com/fr/design/designer/properties/FRFitLayoutConstraints.java
  7. 2
      designer_form/src/com/fr/design/gui/xpane/LayoutBorderPane.java

67
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java

@ -24,6 +24,7 @@ import com.fr.design.designer.properties.FRFitLayoutConstraints;
import com.fr.design.designer.properties.FRFitLayoutPropertiesGroupModel;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.JForm;
import com.fr.design.utils.ComponentUtils;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WLayout;
@ -44,6 +45,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 构造函数
*
* @param container XWFitLayout容器
*/
public FRFitLayoutAdapter(XLayoutContainer container) {
@ -104,7 +106,6 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
}
private void addParentCreator(XCreator child) {
XLayoutContainer parentPanel = child.initCreatorWrapper(minHeight);
container.add(parentPanel, child.toData().getWidgetName());
@ -112,6 +113,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 能否对应位置放置当前组件
*
* @param creator 组件
* @param x 添加的位置x该位置是相对于container的
* @param y 添加的位置y该位置是相对于container的
@ -162,6 +164,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 是否在组件边缘
*
* @param x 横坐标
* @param y 纵坐标
* @return 是否在组件边缘
@ -178,6 +181,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 是否在组件边缘
*
* @param x 横坐标
* @param y 纵坐标
* @param container 参照组件
@ -234,6 +238,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 判断是否鼠标在组件的三等分区域如果组件在布局管理器中间上下左右都可能会三等分
*
* @param parentComp 鼠标所在区域的组件
* @param x 坐标x
* @param y 坐标y
@ -245,6 +250,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 是否为组件交叉点区域 或者是相邻三组建中间点
*
* @param currentComp 当前组件
* @param x 坐标x
* @param y 坐标y
@ -261,6 +267,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
protected void clearCompsList() {
super.clearCompsList();
}
private Rectangle adjustBackupBound(Rectangle backupBound, XWCardMainBorderLayout mainLayout) {
// 参数界面高度对纵坐标产生的影响
JForm jform = (JForm) (HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
@ -284,6 +291,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 拖拽控件边框后根据控件的大小尺寸进行相关组件的调整
*
* @param creator 组件
*/
@Override
@ -328,6 +336,43 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
updateCreatorBackBound();
}
/**
* 拖拽控件边框后根据控件的大小尺寸进行相关组件的调整
*
* @param backupBound 边界备份
* @param bounds 组件边界
* @param xCreator 组件
* @param row 选中的行
* @param difference 偏移量
*/
public void calculateBounds(Rectangle backupBound, Rectangle bounds, XCreator xCreator, int row, int difference) {
Rectangle rc = new Rectangle(0,0,0,0);
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xCreator);
if (parent != null) {
Rectangle rec = ComponentUtils.getRelativeBounds(parent);
rc.x = rec.x;
rc.y = rec.y;
}
int x = backupBound.x - rc.x, y = backupBound.y - rc.y;
//处理左右延伸
switch (row) {
case 0:
if (backupBound.width + backupBound.x == container.getWidth() - margin.getRight() +rc.x) {
x += difference;
}
break;
case 1:
if(backupBound.y + backupBound.height == container.getHeight() - margin.getBottom() +rc.y){
y += difference;
}
break;
}
bounds.setLocation(x,y);
xCreator.setBackupBound(backupBound);
xCreator.setBounds(bounds);
this.fix(xCreator);
}
private void dealLeft(Rectangle backupBound, int x, int[] posXs, int difference, XCreator creator) {
if (backupBound.x == margin.getLeft()) {
return;
@ -614,11 +659,13 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
//重新计算上下两侧组件size、point
if (CalculateUpRelatComponent(difference)) {
CalculateDownRelatComponent(objY + difference, -difference);
};
}
;
}
/**
* 新拖入组件时计算调整其他关联组件位置大小
*
* @param child 新拖入的组件
* @param x 鼠标所在x坐标
* @param y 鼠标所在y坐标
@ -659,6 +706,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 三等分区域时调整相关联的组件
*
* @param currentComp 鼠标所在组件
* @param child 待插入组件
*/
@ -677,6 +725,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 重新计算内部组件大小
*
* @param x 坐标x
* @param y 坐标y
* @param creatorWidth 删除的组件之前所在布局的宽度
@ -888,9 +937,9 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 拖拽组件时遍历某一侧组件得到该侧组件能够缩放的最小宽度tab布局最小宽度 = 内部组件数 * 单个组件最小宽度
*
* @param list 某一侧组件的集合 leftComps<Component>
* @return int 最小宽度
*
*/
private int getCompsMinWidth(List<?> list) {
return getMaxCompsNum(list, true) * WLayout.MIN_WIDTH;
@ -898,9 +947,9 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 拖拽组件遍历某一侧得到该侧组件能够缩放的最小高度tab布局最小高度 = 内部组件数 * 单个组件最小高度 + 标题高度
*
* @param list 某一侧组件集合
* @return int 最小高度
*
*/
private int getCompsMinHeight(List<?> list) {
for (int i = 0; i < list.size(); i++) {
@ -915,10 +964,10 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 根据子组件的横()坐标获取某一侧组件的最大内部组件数
*
* @param list 某一侧组件集合
* @param isHor 是否以横坐标为准
* @return int 最大内部组件数
*
*/
private int getMaxCompsNum(List<?> list, boolean isHor) {
int maxCompNums = 1;
@ -940,6 +989,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 根据偏移量缩放内部组件大小,tab布局用到
*
* @param creator tab布局
* @param offset 偏移量
* @param isHor 是否为横向拖拽
@ -998,6 +1048,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 删除或拉伸控件右边框 调整右侧组件位置大小
*
* @param objX 调整后的坐标x
* @param objWidth 调整后的宽度
*/
@ -1016,9 +1067,9 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 实际拖拽偏移量是否超出了可调整的宽度范围
*
* @param offset 实际偏移量
* @return boolean 是否超出调整范围
*
*/
private boolean isBeyondAdjustWidthScope(int offset) {
boolean isBeyondScope = false;
@ -1074,9 +1125,9 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 实际拖拽偏移量是否超出了可调整的高度范围
*
* @param offset 实际偏移量
* @return boolean 是否超出调整范围
*
*/
private boolean isBeyondAdjustHeightScope(int offset) {
boolean isBeyondScope = false;
@ -1095,6 +1146,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
}
return false;
}
/**
* 删除或拉伸上边框 调整上方的组件位置大小
*/
@ -1115,6 +1167,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
/**
* 不调整只计算位置
*
* @return child的位置
*/
public int[] getChildPosition(Component currentComp, XCreator child, int x, int y) {

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

@ -86,7 +86,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Inter
.getLocText("Form-Widget_Name")),
new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass(
WLayoutBorderStyleEditor.class).setRendererClass(LayoutBorderStyleRenderer.class).setI18NName(
WLayoutBorderStyleEditor.class).setI18NName(
Inter.getLocText("Chart-Style_Name")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced")
.setPropertyChangeListener(new PropertyChangeAdapter() {

4
designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java

@ -66,7 +66,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Inter
.getLocText("FR-Designer_Form-Widget_Name")),
new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass(
WLayoutBorderStyleEditor.class).setRendererClass(LayoutBorderStyleRenderer.class).setI18NName(
WLayoutBorderStyleEditor.class).setI18NName(
Inter.getLocText("FR-Engine_Style")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced")
.setPropertyChangeListener(new PropertyChangeAdapter() {
@ -76,7 +76,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
}
}),
new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class)
.setRendererClass(PaddingMarginCellRenderer.class).setI18NName(Inter.getLocText("FR-Designer_Layout-Padding"))
.setI18NName(Inter.getLocText("FR-Designer_Layout-Padding"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
};
}

2
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java

@ -283,7 +283,7 @@ public class XWCardLayout extends XLayoutContainer {
}
}),
new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass(
CardTagWLayoutBorderStyleEditor.class).setRendererClass(LayoutBorderStyleRenderer.class).setI18NName(
CardTagWLayoutBorderStyleEditor.class).setI18NName(
Inter.getLocText("FR-Engine_Style")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced")
.setPropertyChangeListener(new PropertyChangeAdapter() {

2
designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java

@ -64,7 +64,7 @@ public class XWTabFitLayout extends XWFitLayout {
new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Inter
.getLocText("FR-Designer_Form-Widget_Name")),
new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class)
.setRendererClass(PaddingMarginCellRenderer.class).setI18NName(Inter.getLocText("FR-Designer_Layout-Padding"))
.setI18NName(Inter.getLocText("FR-Designer_Layout-Padding"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
};
}

42
designer_form/src/com/fr/design/designer/properties/FRFitLayoutConstraints.java

@ -1,10 +1,18 @@
package com.fr.design.designer.properties;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.editors.IntegerPropertyEditor;
import com.fr.design.mainframe.widget.editors.PropertyCellEditor;
import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.utils.ComponentUtils;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WFitLayout;
import com.fr.general.Inter;
@ -23,6 +31,7 @@ import java.awt.*;
//控件在自适应布局中宽度、高度属性,7.1.1不可编辑
public class FRFitLayoutConstraints implements ConstraintsGroupModel {
private static final int MINHEIGHT = XCreator.SMALL_PREFERRED_SIZE.height;
private static final int MINWIDTH = XCreator.SMALL_PREFERRED_SIZE.width;
private static final int ROWNUM = 2;
private DefaultTableCellRenderer renderer;
@ -80,12 +89,18 @@ public class FRFitLayoutConstraints implements ConstraintsGroupModel {
public boolean setValue(Object value, int row, int column) {
if (column == 1) {
int v = value == null ? 0 : ((Number) value).intValue();
Rectangle bounds = new Rectangle(xCreator.getBounds());
int difference = 0;
Rectangle bounds = getBounds();
switch (row) {
case 0:
if(v < MINWIDTH){
JOptionPane.showMessageDialog(null, Inter.getLocText("Min-Width") + Integer.toString(MINWIDTH));
v = xCreator.getWidth();
}
if (bounds.width == v){
return false;
}
difference = bounds.width - v;
bounds.width = v;
break;
case 1:
@ -96,25 +111,44 @@ public class FRFitLayoutConstraints implements ConstraintsGroupModel {
if (bounds.height == v){
return false;
}
difference = bounds.height - v;
bounds.height = v;
break;
}
WFitLayout wFitLayout = parent.toData();
wFitLayout.setBounds(xCreator.toData(),bounds);
xCreator.setBounds(bounds);
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
Rectangle backupBounds = getBounds();
FRFitLayoutAdapter layoutAdapter = (FRFitLayoutAdapter) AdapterBus.searchLayoutAdapter(formDesigner, xCreator);
if (layoutAdapter != null) {
layoutAdapter.calculateBounds(backupBounds, bounds, xCreator, row, difference);
}
return true;
} else {
return false;
}
}
public Rectangle getBounds(){
Rectangle bounds = new Rectangle(xCreator.getBounds());
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xCreator);
if (parent == null) {
return bounds;
}
Rectangle rec = ComponentUtils.getRelativeBounds(parent);
bounds.x += rec.x;
bounds.y += rec.y;
return bounds;
}
/**
* 该行是否可编辑
* @param row
* @return 第row行可编辑返回true否则返回false
*/
public boolean isEditable(int row) {
return false;
return true;
}
}

2
designer_form/src/com/fr/design/gui/xpane/LayoutBorderPane.java

@ -280,7 +280,7 @@ public class LayoutBorderPane extends BasicPane {
Constants.LINE_THICK, //3px
};
public final static String[] BORDER_TYPE = new String[]{Inter.getLocText("FR-Designer-Widget-Style_Standard"), Inter.getLocText("FR-Designer-Widget-Style_Title")};
public final static String[] BORDER_TYPE = new String[]{Inter.getLocText("FR-Designer-Widget-Style_Standard"), Inter.getLocText("FR-Designer-Widget-Style_Custom")};
public final static String[] BORDER_STYLE= new String[]{Inter.getLocText("FR-Designer-Widget-Style_Common"), Inter.getLocText("FR-Designer-Widget-Style_Shadow")};
private final static Dimension BUTTON_SIZE = new Dimension(24, 20);

Loading…
Cancel
Save