Browse Source

无任务代码调整

master
yaoh.wu 8 years ago
parent
commit
e82c0f921a
  1. 272
      designer_base/src/com/fr/design/utils/ComponentUtils.java
  2. 31
      designer_form/src/com/fr/design/designer/beans/LayoutAdapter.java
  3. 3
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java
  4. 572
      designer_form/src/com/fr/design/mainframe/FormSelection.java

272
designer_base/src/com/fr/design/utils/ComponentUtils.java

@ -12,140 +12,140 @@ import java.util.ArrayList;
*/ */
public class ComponentUtils { public class ComponentUtils {
public static boolean isComponentVisible(Component comp) { public static boolean isComponentVisible(Component comp) {
if (!comp.isVisible() && !isRootComponent(comp)) { if (!comp.isVisible() && !isRootComponent(comp)) {
return false; return false;
} }
Component parent = comp.getParent(); Component parent = comp.getParent();
return parent == null || isComponentVisible(parent); return parent == null || isComponentVisible(parent);
} }
/** /**
* 获取component所在的容器的绝对位置 * 获取component所在的容器的绝对位置
*/ */
public static Rectangle getRelativeBounds(Component component) { public static Rectangle getRelativeBounds(Component component) {
Rectangle bounds = new Rectangle(0, 0, component.getWidth(), component.getHeight()); Rectangle bounds = new Rectangle(0, 0, component.getWidth(), component.getHeight());
Container parent = component.getParent(); Container parent = component.getParent();
while (parent != null) { while (parent != null) {
bounds.x += component.getX(); bounds.x += component.getX();
bounds.y += component.getY(); bounds.y += component.getY();
component = parent; component = parent;
parent = component.getParent(); parent = component.getParent();
} }
return bounds; return bounds;
} }
/** /**
* 恢复双缓冲状态dbcomponents保存着初始状态为启动双缓冲的组件 * 恢复双缓冲状态dbcomponents保存着初始状态为启动双缓冲的组件
*/ */
public static void resetBuffer(ArrayList<JComponent> dbcomponents) { public static void resetBuffer(ArrayList<JComponent> dbcomponents) {
for (JComponent jcomponent : dbcomponents) { for (JComponent jcomponent : dbcomponents) {
jcomponent.setDoubleBuffered(true); jcomponent.setDoubleBuffered(true);
} }
} }
/** /**
* 禁止双缓冲状态并将初始状态为启动双缓冲的组件保存到dbcomponents中 * 禁止双缓冲状态并将初始状态为启动双缓冲的组件保存到dbcomponents中
*/ */
public static void disableBuffer(Component comp, ArrayList<JComponent> dbcomponents) { public static void disableBuffer(Component comp, ArrayList<JComponent> dbcomponents) {
if ((comp instanceof JComponent) && comp.isDoubleBuffered()) { if ((comp instanceof JComponent) && comp.isDoubleBuffered()) {
JComponent jcomponent = (JComponent) comp; JComponent jcomponent = (JComponent) comp;
dbcomponents.add(jcomponent); dbcomponents.add(jcomponent);
jcomponent.setDoubleBuffered(false); jcomponent.setDoubleBuffered(false);
} }
if (comp instanceof Container) { if (comp instanceof Container) {
Container container = (Container) comp; Container container = (Container) comp;
int count = container.getComponentCount(); int count = container.getComponentCount();
if (count > 0) { if (count > 0) {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
Component component = container.getComponent(i); Component component = container.getComponent(i);
disableBuffer(component, dbcomponents); disableBuffer(component, dbcomponents);
} }
} }
} }
} }
public static int indexOfComponent(Container container, Component target) { public static int indexOfComponent(Container container, Component target) {
int count = container.getComponentCount(); int count = container.getComponentCount();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
Component child = container.getComponent(i); Component child = container.getComponent(i);
if (child == target) { if (child == target) {
return i; return i;
} }
} }
return -1; return -1;
} }
/** /**
* 计算组件root相对于其顶层容器的可见区域 * 计算组件root相对于其顶层容器的可见区域
*/ */
public static Rectangle computeVisibleRectRel2Root(Component root) { public static Rectangle computeVisibleRectRel2Root(Component root) {
Container container = findAncestorScrollPane(root); Container container = findAncestorScrollPane(root);
if (container == null) { if (container == null) {
return getRelativeBounds(root); return getRelativeBounds(root);
} else { } else {
// 如果是JScrollPane的子组件,需要计算其viewport与改组件的交叉的可见区域 // 如果是JScrollPane的子组件,需要计算其viewport与改组件的交叉的可见区域
return getBoundsRel2Parent(root, container); return getBoundsRel2Parent(root, container);
} }
} }
/** /**
* 计算组件root相对于其顶层容器的可见区域 * 计算组件root相对于其顶层容器的可见区域
*/ */
public static Rectangle computeVisibleRect(JComponent root) { public static Rectangle computeVisibleRect(JComponent root) {
Rectangle root_bounds = ComponentUtils.getRelativeBounds(root); Rectangle root_bounds = ComponentUtils.getRelativeBounds(root);
Rectangle rect = computeVisibleRectRel2Root(root); Rectangle rect = computeVisibleRectRel2Root(root);
rect.x -= root_bounds.x; rect.x -= root_bounds.x;
rect.y -= root_bounds.y; rect.y -= root_bounds.y;
return rect; return rect;
} }
private static Rectangle getBoundsRel2Parent(Component child, Container parent) { private static Rectangle getBoundsRel2Parent(Component child, Container parent) {
Rectangle cRect = getRelativeBounds(child); Rectangle cRect = getRelativeBounds(child);
Rectangle pRect = getRelativeBounds(parent); Rectangle pRect = getRelativeBounds(parent);
Rectangle bounds = new Rectangle(); Rectangle bounds = new Rectangle();
Rectangle2D.intersect(cRect, pRect, bounds); Rectangle2D.intersect(cRect, pRect, bounds);
return bounds; return bounds;
} }
public static Container findAncestorScrollPane(Component p) { public static Container findAncestorScrollPane(Component p) {
if ((p == null) || !(p instanceof Container)) { if ((p == null) || !(p instanceof Container)) {
return null; return null;
} }
Container c = p.getParent(); Container c = p.getParent();
return findAncestorScrollPane(c); return findAncestorScrollPane(c);
} }
public static boolean isRootComponent(Component root) { public static boolean isRootComponent(Component root) {
Container parent = root.getParent(); Container parent = root.getParent();
return parent == null; return parent == null;
} }
public static boolean isChildOf(Component component, Class parent) { public static boolean isChildOf(Component component, Class parent) {
Container container = component.getParent(); Container container = component.getParent();
if (container != null) { if (container != null) {
if (ComparatorUtils.equals(container.getClass(), parent)) { if (ComparatorUtils.equals(container.getClass(), parent)) {
return true; return true;
} else { } else {
return isChildOf(container, parent); return isChildOf(container, parent);
} }
} }
return false; return false;
} }
} }

31
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类 * 该接口是LayoutManager的BeanInfo类标准Java平台没有提供布局管理器的BeanInfo类
* 对于界面设计工具来说还需一些特殊的行为 * 对于界面设计工具来说还需一些特殊的行为
*
* @since 6.5.3 * @since 6.5.3
*/ */
public interface LayoutAdapter { public interface LayoutAdapter {
@ -15,15 +16,17 @@ public interface LayoutAdapter {
* 管理适配器的accept来决定当前位置是否可以放置并提供特殊的标识比如红色区域标识 * 管理适配器的accept来决定当前位置是否可以放置并提供特殊的标识比如红色区域标识
* 如在BorderLayout中如果某个方位已经放置了组件则此时应该返回false标识该区域不可以 * 如在BorderLayout中如果某个方位已经放置了组件则此时应该返回false标识该区域不可以
* 放置 * 放置
*@param creator 组件 *
*@param x 添加的位置x该位置是相对于container的 * @param creator 组件
*@param y 添加的位置y该位置是相对于container的 * @param x 添加的位置x该位置是相对于container的
*@return 是否可以放置 * @param y 添加的位置y该位置是相对于container的
* @return 是否可以放置
*/ */
boolean accept(XCreator creator, int x, int y); boolean accept(XCreator creator, int x, int y);
/** /**
* 有的控件在拖拽调整大小后需要根据自身内容重新计算下当前的尺寸是否合适如果不合适就需要重新fix一下 * 有的控件在拖拽调整大小后需要根据自身内容重新计算下当前的尺寸是否合适如果不合适就需要重新fix一下
*
* @param creator 组件 * @param creator 组件
*/ */
void fix(XCreator creator); void fix(XCreator creator);
@ -31,9 +34,10 @@ public interface LayoutAdapter {
/** /**
* 组件的ComponentAdapter在添加组件时如果发现布局管理器不为空会继而调用该布局管理器的 * 组件的ComponentAdapter在添加组件时如果发现布局管理器不为空会继而调用该布局管理器的
* addComp方法来完成组件的具体添加在该方法内布局管理器可以提供额外的功能 * addComp方法来完成组件的具体添加在该方法内布局管理器可以提供额外的功能
*
* @param creator 被添加的新组件 * @param creator 被添加的新组件
* @param x 添加的位置x该位置是相对于container的 * @param x 添加的位置x该位置是相对于container的
* @param y 添加的位置y该位置是相对于container的 * @param y 添加的位置y该位置是相对于container的
* @return 是否添加成功成功返回true否则false * @return 是否添加成功成功返回true否则false
*/ */
boolean addBean(XCreator creator, int x, int y); boolean addBean(XCreator creator, int x, int y);
@ -45,6 +49,7 @@ public interface LayoutAdapter {
/** /**
* 显示parent的字组件child解决CardLayout中显示某个非显示组件的特殊情况 * 显示parent的字组件child解决CardLayout中显示某个非显示组件的特殊情况
*
* @param child 组件 * @param child 组件
*/ */
void showComponent(XCreator child); void showComponent(XCreator child);
@ -53,20 +58,23 @@ public interface LayoutAdapter {
/** /**
* 组件叠放顺序前插入 * 组件叠放顺序前插入
*
* @param target 目标组件 * @param target 目标组件
* @param added 插入组件 * @param added 插入组件
*/ */
void addBefore(XCreator target, XCreator added); void addBefore(XCreator target, XCreator added);
/** /**
* 组件叠放顺序后插入 * 组件叠放顺序后插入
*
* @param target 目标组件 * @param target 目标组件
* @param added 放置组件 * @param added 放置组件
*/ */
void addAfter(XCreator target, XCreator added); void addAfter(XCreator target, XCreator added);
/** /**
* 能否放置更多组件 * 能否放置更多组件
*
* @return 能则返回true * @return 能则返回true
*/ */
boolean canAcceptMoreComponent(); boolean canAcceptMoreComponent();
@ -74,11 +82,12 @@ public interface LayoutAdapter {
ConstraintsGroupModel getLayoutConstraints(XCreator creator); ConstraintsGroupModel getLayoutConstraints(XCreator creator);
GroupModel getLayoutProperties(); GroupModel getLayoutProperties();
/** /**
* 删除组件 * 删除组件
* @param creator 组件 *
* @param initWidth 组件之前宽度 * @param creator 组件
* @param initWidth 组件之前宽度
* @param initHeight 组件之前高度 * @param initHeight 组件之前高度
*/ */
void removeBean(XCreator creator, int initWidth, int initHeight); void removeBean(XCreator creator, int initWidth, int 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会被改变,先备份 // 经过accept判断后,container会被改变,先备份
XLayoutContainer backUpContainer = container; XLayoutContainer backUpContainer = container;
Rectangle rect = ComponentUtils.getRelativeBounds(container); Rectangle rect = ComponentUtils.getRelativeBounds(container);
System.out.println("xy: " + x + "\t" + y);
System.out.println(rect);
int posX = x - rect.x; int posX = x - rect.x;
int posY = y - rect.y; int posY = y - rect.y;
System.out.println("pos: " + posX + "\t" + posY);
if (!accept(creator, posX, posY)) { if (!accept(creator, posX, posY)) {
return false; return false;
} }

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

@ -20,288 +20,300 @@ import com.fr.design.utils.gui.LayoutUtils;
public class FormSelection { public class FormSelection {
private ArrayList<XCreator> selection; private ArrayList<XCreator> selection;
private Rectangle backupBounds; private Rectangle backupBounds;
private ArrayList<Rectangle> recs = new ArrayList<Rectangle>(); private ArrayList<Rectangle> recs = new ArrayList<Rectangle>();
public FormSelection() { public FormSelection() {
selection = new ArrayList<XCreator>(); selection = new ArrayList<XCreator>();
} }
/** /**
* 重置选中的组件 * 重置选中的组件
*/ */
public void reset() { public void reset() {
selection.clear(); selection.clear();
} }
/** /**
* 是否没有选中的组件 * 是否没有选中的组件
* @return 为空返回true *
*/ * @return 为空返回true
public boolean isEmpty() { */
return selection.isEmpty(); public boolean isEmpty() {
} return selection.isEmpty();
}
/**
* 选中的组件数量 /**
* @return 选中的组件数量 * 选中的组件数量
*/ *
public int size() { * @return 选中的组件数量
return selection.size(); */
} public int size() {
return selection.size();
/** }
* 去除选中的组件中指定组件
* @param creator 待去除组件 /**
*/ * 去除选中的组件中指定组件
public void removeCreator(XCreator creator) { *
selection.remove(creator); * @param creator 待去除组件
} */
public void removeCreator(XCreator creator) {
/** selection.remove(creator);
* 是否成功删除选择的组件 }
* @param comp 组件
* @return 是则返回true /**
*/ * 是否成功删除选择的组件
public boolean removeSelectedCreator(XCreator comp) { *
if (selection.size() > 1 && selection.contains(comp)) { * @param comp 组件
removeCreator(comp); * @return 是则返回true
return true; */
} public boolean removeSelectedCreator(XCreator comp) {
return false; if (selection.size() > 1 && selection.contains(comp)) {
} removeCreator(comp);
return true;
/** }
* 成功增加选中的组件 return false;
* @param creator 组件 }
* @return 成功增加返回true
*/ /**
public boolean addSelectedCreator(XCreator creator) { * 成功增加选中的组件
if (addedable(creator)) { *
selection.add(creator); * @param creator 组件
return true; * @return 成功增加返回true
} */
return false; public boolean addSelectedCreator(XCreator creator) {
} if (addedable(creator)) {
selection.add(creator);
/** return true;
* 是否是可以增加的 }
* @param creator 组件 return false;
* @return 是则返回true }
*/
public boolean addedable(XCreator creator) { /**
if (selection.isEmpty()) { * 是否是可以增加的
return true; *
} * @param creator 组件
XLayoutContainer container = XCreatorUtils.getParentXLayoutContainer(creator); * @return 是则返回true
if (!(container instanceof XWAbsoluteLayout)) { */
return false; public boolean addedable(XCreator creator) {
} if (selection.isEmpty()) {
for (XCreator selected : selection) { return true;
if (selected == creator || XCreatorUtils.getParentXLayoutContainer(selected) != container) { }
return false; XLayoutContainer container = XCreatorUtils.getParentXLayoutContainer(creator);
} if (!(container instanceof XWAbsoluteLayout)) {
} return false;
return true; }
} for (XCreator selected : selection) {
if (selected == creator || XCreatorUtils.getParentXLayoutContainer(selected) != container) {
/** return false;
* 返回选中的第一个组件为空返回null }
* @return 返回选中组件 }
*/ return true;
public XCreator getSelectedCreator() { }
return !selection.isEmpty() ? selection.get(0) : null;
} /**
* 返回选中的第一个组件为空返回null
/** *
* 返回选中的所有组件 * @return 返回选中组件
* @return 所有组件s */
*/ public XCreator getSelectedCreator() {
public XCreator[] getSelectedCreators() { return !selection.isEmpty() ? selection.get(0) : null;
return selection.toArray(new XCreator[selection.size()]); }
}
/**
public Widget[] getSelectedWidgets() { * 返回选中的所有组件
Widget[] selectWidget = new Widget[selection.size()]; *
for (int i = 0; i < selection.size(); i++) { * @return 所有组件s
selectWidget[i] = selection.get(i).toData(); */
} public XCreator[] getSelectedCreators() {
return selectWidget; return selection.toArray(new XCreator[selection.size()]);
} }
public void setSelectedCreator(XCreator creator) { public Widget[] getSelectedWidgets() {
reset(); Widget[] selectWidget = new Widget[selection.size()];
selection.add(creator); for (int i = 0; i < selection.size(); i++) {
} selectWidget[i] = selection.get(i).toData();
}
public void setSelectedCreators(ArrayList<XCreator> selections) { return selectWidget;
reset(); }
for (XCreator creator : selections) {
if (addedable(creator)) { public void setSelectedCreator(XCreator creator) {
selection.add(creator); reset();
} selection.add(creator);
} }
}
public void setSelectedCreators(ArrayList<XCreator> selections) {
/** reset();
* 是否包含当前控件 for (XCreator creator : selections) {
* @param widget 控件 if (addedable(creator)) {
* @return 是则返回true selection.add(creator);
*/ }
public boolean contains(Widget widget) { }
for (XCreator creator : selection) { }
if (creator.toData() == widget) {
return true; /**
} * 是否包含当前控件
} *
return false; * @param widget 控件
} * @return 是则返回true
*/
public int[] getDirections() { public boolean contains(Widget widget) {
if (this.selection.size() > 1) { for (XCreator creator : selection) {
return Direction.ALL; if (creator.toData() == widget) {
} else if (this.selection.size() == 1) { return true;
return this.selection.get(0).getDirections(); }
} else { }
return new int[0]; return false;
} }
}
public int[] getDirections() {
/** if (this.selection.size() > 1) {
* 备份组件的bound return Direction.ALL;
*/ } else if (this.selection.size() == 1) {
public void backupBounds() { return this.selection.get(0).getDirections();
backupBounds = getRelativeBounds(); } else {
recs.clear(); return new int[0];
for (XComponent comp : selection) { }
recs.add(comp.getBounds()); }
}
} /**
* 备份组件的bound
public Rectangle getBackupBounds() { */
return backupBounds; public void backupBounds() {
} backupBounds = getRelativeBounds();
recs.clear();
public Rectangle getRelativeBounds() { for (XComponent comp : selection) {
Rectangle bounds = getSelctionBounds(); recs.add(comp.getBounds());
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(selection.get(0)); }
if (parent == null) { }
return bounds;
} public Rectangle getBackupBounds() {
Rectangle rec = ComponentUtils.getRelativeBounds(parent); return backupBounds;
bounds.x += rec.x; }
bounds.y += rec.y;
return bounds; public Rectangle getRelativeBounds() {
} Rectangle bounds = getSelctionBounds();
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(selection.get(0));
public Rectangle getSelctionBounds() { if (parent == null) {
if(selection.isEmpty()) { return bounds;
return new Rectangle(); }
} Rectangle rec = ComponentUtils.getRelativeBounds(parent);
Rectangle bounds = selection.get(0).getBounds(); bounds.x += rec.x;
for (int i = 1, len = selection.size(); i < len; i++) { bounds.y += rec.y;
bounds = bounds.union(selection.get(i).getBounds()); return bounds;
} }
return bounds;
} public Rectangle getSelctionBounds() {
if (selection.isEmpty()) {
public void setSelectionBounds(Rectangle rec, FormDesigner designer) { return new Rectangle();
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(selection.get(0)); }
Rectangle backupBounds = new Rectangle(this.backupBounds); Rectangle bounds = selection.get(0).getBounds();
if (parent != null) { for (int i = 1, len = selection.size(); i < len; i++) {
Rectangle r = ComponentUtils.getRelativeBounds(parent); bounds = bounds.union(selection.get(i).getBounds());
rec.x -= r.x; }
rec.y -= r.y; return bounds;
backupBounds.x -= r.x; }
backupBounds.y -= r.y;
} public void setSelectionBounds(Rectangle rec, FormDesigner designer) {
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(selection.get(0));
int size = selection.size(); Rectangle backupBounds = new Rectangle(this.backupBounds);
if (size == 1) { if (parent != null) {
XCreator creator = selection.get(0); Rectangle r = ComponentUtils.getRelativeBounds(parent);
creator.setBounds(rec); rec.x -= r.x;
if(creator.acceptType(XWParameterLayout.class)){ rec.y -= r.y;
designer.setParaHeight((int)rec.getHeight()); backupBounds.x -= r.x;
backupBounds.y -= r.y;
}
int size = selection.size();
if (size == 1) {
XCreator creator = selection.get(0);
creator.setBounds(rec);
if (creator.acceptType(XWParameterLayout.class)) {
designer.setParaHeight((int) rec.getHeight());
designer.getArea().doLayout(); designer.getArea().doLayout();
} }
LayoutUtils.layoutContainer(creator); LayoutUtils.layoutContainer(creator);
} else if (size > 1) { } else if (size > 1) {
for (int i = 0; i < selection.size(); i++) { for (int i = 0; i < selection.size(); i++) {
Rectangle newBounds = new Rectangle(recs.get(i)); Rectangle newBounds = new Rectangle(recs.get(i));
newBounds.x = rec.x + (newBounds.x - backupBounds.x) * rec.width / backupBounds.width; newBounds.x = rec.x + (newBounds.x - backupBounds.x) * rec.width / backupBounds.width;
newBounds.y = rec.y + (newBounds.y - backupBounds.y) * rec.height / backupBounds.height; newBounds.y = rec.y + (newBounds.y - backupBounds.y) * rec.height / backupBounds.height;
newBounds.width = rec.width * newBounds.width / backupBounds.width; newBounds.width = rec.width * newBounds.width / backupBounds.width;
newBounds.height = rec.height * newBounds.height / backupBounds.height; newBounds.height = rec.height * newBounds.height / backupBounds.height;
XCreator creator = selection.get(i); XCreator creator = selection.get(i);
creator.setBounds(newBounds); creator.setBounds(newBounds);
if(creator.acceptType(XWParameterLayout.class)){ if (creator.acceptType(XWParameterLayout.class)) {
designer.setParaHeight((int)rec.getHeight()); designer.setParaHeight((int) rec.getHeight());
designer.getArea().doLayout(); designer.getArea().doLayout();
} }
} }
LayoutUtils.layoutRootContainer(designer.getRootComponent()); LayoutUtils.layoutRootContainer(designer.getRootComponent());
} }
} }
/** /**
* 调整组件大小 * 调整组件大小
* @param designer 设计界面组件 *
*/ * @param designer 设计界面组件
public void fixCreator(FormDesigner designer) { */
for (XCreator creator : selection) { public void fixCreator(FormDesigner designer) {
LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(designer, creator); for (XCreator creator : selection) {
if (layoutAdapter != null) { LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(designer, creator);
creator.setBackupBound(backupBounds); if (layoutAdapter != null) {
layoutAdapter.fix(creator); creator.setBackupBound(backupBounds);
} layoutAdapter.fix(creator);
} }
} }
}
private void removeCreatorFromContainer(XCreator creator) {
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(creator); private void removeCreatorFromContainer(XCreator creator) {
if (parent == null) { XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(creator);
return; if (parent == null) {
} return;
// 删除其根组件,同时就删除了同时被选择的叶子组件 }
parent.remove(creator); // 删除其根组件,同时就删除了同时被选择的叶子组件
LayoutManager layout = parent.getLayout(); parent.remove(creator);
LayoutManager layout = parent.getLayout();
if (layout != null) {
// 刷新组件容器的布局 if (layout != null) {
LayoutUtils.layoutContainer(parent); // 刷新组件容器的布局
} LayoutUtils.layoutContainer(parent);
} }
}
/**
* 剪切选中的所有组件 /**
* @param clipBoard 剪切板 * 剪切选中的所有组件
*/ *
public void cut2ClipBoard(FormSelection clipBoard) { * @param clipBoard 剪切板
clipBoard.reset(); */
clipBoard.selection.addAll(selection); public void cut2ClipBoard(FormSelection clipBoard) {
clipBoard.reset();
for (XCreator creator : selection) { clipBoard.selection.addAll(selection);
removeCreatorFromContainer(creator);
} for (XCreator creator : selection) {
reset(); removeCreatorFromContainer(creator);
} }
reset();
/** }
* 复制选中的所有组件
* @param clipBoard 复制板 /**
*/ * 复制选中的所有组件
public void copy2ClipBoard(FormSelection clipBoard) { *
clipBoard.reset(); * @param clipBoard 复制板
*/
for (XCreator root : selection) { public void copy2ClipBoard(FormSelection clipBoard) {
try { clipBoard.reset();
XCreator creator = XCreatorUtils.createXCreator((Widget) root.toData().clone());
creator.setBounds(root.getBounds()); for (XCreator root : selection) {
clipBoard.selection.add(creator); try {
} catch (CloneNotSupportedException e) { XCreator creator = XCreatorUtils.createXCreator((Widget) root.toData().clone());
FRContext.getLogger().error(e.getMessage(), e); creator.setBounds(root.getBounds());
} clipBoard.selection.add(creator);
} } catch (CloneNotSupportedException e) {
} FRContext.getLogger().error(e.getMessage(), e);
}
}
}
} }
Loading…
Cancel
Save