Browse Source

无任务代码调整

master
yaoh.wu 8 years ago
parent
commit
e82c0f921a
  1. 17
      designer_form/src/com/fr/design/designer/beans/LayoutAdapter.java
  2. 3
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java
  3. 22
      designer_form/src/com/fr/design/mainframe/FormSelection.java

17
designer_form/src/com/fr/design/designer/beans/LayoutAdapter.java

@ -6,6 +6,7 @@ import com.fr.design.designer.creator.XCreator;
/**
* 该接口是LayoutManager的BeanInfo类标准Java平台没有提供布局管理器的BeanInfo类
* 对于界面设计工具来说还需一些特殊的行为
*
* @since 6.5.3
*/
public interface LayoutAdapter {
@ -15,15 +16,17 @@ public interface LayoutAdapter {
* 管理适配器的accept来决定当前位置是否可以放置并提供特殊的标识比如红色区域标识
* 如在BorderLayout中如果某个方位已经放置了组件则此时应该返回false标识该区域不可以
* 放置
*@param creator 组件
*@param x 添加的位置x该位置是相对于container的
*@param y 添加的位置y该位置是相对于container的
*@return 是否可以放置
*
* @param creator 组件
* @param x 添加的位置x该位置是相对于container的
* @param y 添加的位置y该位置是相对于container的
* @return 是否可以放置
*/
boolean accept(XCreator creator, int x, int y);
/**
* 有的控件在拖拽调整大小后需要根据自身内容重新计算下当前的尺寸是否合适如果不合适就需要重新fix一下
*
* @param creator 组件
*/
void fix(XCreator creator);
@ -31,6 +34,7 @@ public interface LayoutAdapter {
/**
* 组件的ComponentAdapter在添加组件时如果发现布局管理器不为空会继而调用该布局管理器的
* addComp方法来完成组件的具体添加在该方法内布局管理器可以提供额外的功能
*
* @param creator 被添加的新组件
* @param x 添加的位置x该位置是相对于container的
* @param y 添加的位置y该位置是相对于container的
@ -45,6 +49,7 @@ public interface LayoutAdapter {
/**
* 显示parent的字组件child解决CardLayout中显示某个非显示组件的特殊情况
*
* @param child 组件
*/
void showComponent(XCreator child);
@ -53,6 +58,7 @@ public interface LayoutAdapter {
/**
* 组件叠放顺序前插入
*
* @param target 目标组件
* @param added 插入组件
*/
@ -60,6 +66,7 @@ public interface LayoutAdapter {
/**
* 组件叠放顺序后插入
*
* @param target 目标组件
* @param added 放置组件
*/
@ -67,6 +74,7 @@ public interface LayoutAdapter {
/**
* 能否放置更多组件
*
* @return 能则返回true
*/
boolean canAcceptMoreComponent();
@ -77,6 +85,7 @@ public interface LayoutAdapter {
/**
* 删除组件
*
* @param creator 组件
* @param initWidth 组件之前宽度
* @param initHeight 组件之前高度

3
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java

@ -63,11 +63,8 @@ public class FRTabFitLayoutAdapter extends FRFitLayoutAdapter {
// 经过accept判断后,container会被改变,先备份
XLayoutContainer backUpContainer = container;
Rectangle rect = ComponentUtils.getRelativeBounds(container);
System.out.println("xy: " + x + "\t" + y);
System.out.println(rect);
int posX = x - rect.x;
int posY = y - rect.y;
System.out.println("pos: " + posX + "\t" + posY);
if (!accept(creator, posX, posY)) {
return false;
}

22
designer_form/src/com/fr/design/mainframe/FormSelection.java

@ -37,6 +37,7 @@ public class FormSelection {
/**
* 是否没有选中的组件
*
* @return 为空返回true
*/
public boolean isEmpty() {
@ -45,6 +46,7 @@ public class FormSelection {
/**
* 选中的组件数量
*
* @return 选中的组件数量
*/
public int size() {
@ -53,6 +55,7 @@ public class FormSelection {
/**
* 去除选中的组件中指定组件
*
* @param creator 待去除组件
*/
public void removeCreator(XCreator creator) {
@ -61,6 +64,7 @@ public class FormSelection {
/**
* 是否成功删除选择的组件
*
* @param comp 组件
* @return 是则返回true
*/
@ -74,6 +78,7 @@ public class FormSelection {
/**
* 成功增加选中的组件
*
* @param creator 组件
* @return 成功增加返回true
*/
@ -87,6 +92,7 @@ public class FormSelection {
/**
* 是否是可以增加的
*
* @param creator 组件
* @return 是则返回true
*/
@ -108,6 +114,7 @@ public class FormSelection {
/**
* 返回选中的第一个组件为空返回null
*
* @return 返回选中组件
*/
public XCreator getSelectedCreator() {
@ -116,6 +123,7 @@ public class FormSelection {
/**
* 返回选中的所有组件
*
* @return 所有组件s
*/
public XCreator[] getSelectedCreators() {
@ -146,6 +154,7 @@ public class FormSelection {
/**
* 是否包含当前控件
*
* @param widget 控件
* @return 是则返回true
*/
@ -196,7 +205,7 @@ public class FormSelection {
}
public Rectangle getSelctionBounds() {
if(selection.isEmpty()) {
if (selection.isEmpty()) {
return new Rectangle();
}
Rectangle bounds = selection.get(0).getBounds();
@ -221,8 +230,8 @@ public class FormSelection {
if (size == 1) {
XCreator creator = selection.get(0);
creator.setBounds(rec);
if(creator.acceptType(XWParameterLayout.class)){
designer.setParaHeight((int)rec.getHeight());
if (creator.acceptType(XWParameterLayout.class)) {
designer.setParaHeight((int) rec.getHeight());
designer.getArea().doLayout();
}
LayoutUtils.layoutContainer(creator);
@ -235,8 +244,8 @@ public class FormSelection {
newBounds.height = rec.height * newBounds.height / backupBounds.height;
XCreator creator = selection.get(i);
creator.setBounds(newBounds);
if(creator.acceptType(XWParameterLayout.class)){
designer.setParaHeight((int)rec.getHeight());
if (creator.acceptType(XWParameterLayout.class)) {
designer.setParaHeight((int) rec.getHeight());
designer.getArea().doLayout();
}
}
@ -246,6 +255,7 @@ public class FormSelection {
/**
* 调整组件大小
*
* @param designer 设计界面组件
*/
public void fixCreator(FormDesigner designer) {
@ -275,6 +285,7 @@ public class FormSelection {
/**
* 剪切选中的所有组件
*
* @param clipBoard 剪切板
*/
public void cut2ClipBoard(FormSelection clipBoard) {
@ -289,6 +300,7 @@ public class FormSelection {
/**
* 复制选中的所有组件
*
* @param clipBoard 复制板
*/
public void copy2ClipBoard(FormSelection clipBoard) {

Loading…
Cancel
Save