Browse Source

无任务 调整代码通过pmd

master
yaoh.wu 8 years ago
parent
commit
d6047fbd86
  1. 60
      designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java

60
designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java

@ -111,9 +111,27 @@ public class SelectionModel {
*/ */
public boolean pasteFromClipBoard() { public boolean pasteFromClipBoard() {
if (!clipboard.isEmpty()) { if (!clipboard.isEmpty()) {
XLayoutContainer parent = null;
//未选
if (!hasSelectionComponent()) { if (!hasSelectionComponent()) {
//未选
unselectedPaste();
} else {
//已选
selectedPaste();
}
} else {
Toolkit.getDefaultToolkit().beep();
}
return false;
}
public FormSelection getSelection() {
return selection;
}
/**
* 粘贴时未选择组件
*/
private void unselectedPaste() {
if (designer.getClass().equals(FormDesigner.class)) { if (designer.getClass().equals(FormDesigner.class)) {
if (selection.getSelectedCreator() instanceof XWFitLayout) { if (selection.getSelectedCreator() instanceof XWFitLayout) {
if (selection.getSelectedCreator().getClass().equals(XWTabFitLayout.class)) { if (selection.getSelectedCreator().getClass().equals(XWTabFitLayout.class)) {
@ -149,8 +167,12 @@ public class SelectionModel {
DELTA_X_Y); DELTA_X_Y);
} }
} }
//已选
else { /**
* 粘贴时选择组件
*/
private void selectedPaste() {
XLayoutContainer parent = null;
//获取到编辑器的表层容器(已选的组件的父容器就是表层容器) //获取到编辑器的表层容器(已选的组件的父容器就是表层容器)
parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator()); parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator());
if (parent != null && selection.getSelectedCreator().getParent() instanceof XWFitLayout) { if (parent != null && selection.getSelectedCreator().getParent() instanceof XWFitLayout) {
@ -158,22 +180,12 @@ public class SelectionModel {
Rectangle rec = selection.getRelativeBounds(); Rectangle rec = selection.getRelativeBounds();
FormSelectionUtils.paste2Container(designer, parent, clipboard, rec.x + rec.width / 2, rec.y + FormSelectionUtils.paste2Container(designer, parent, clipboard, rec.x + rec.width / 2, rec.y +
rec.height - BORDER_PROPORTION); rec.height - BORDER_PROPORTION);
} else if (parent != null && selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout) { } else if (parent != null && selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout) {
//绝对布局 //绝对布局
Rectangle rec = selection.getSelctionBounds(); Rectangle rec = selection.getSelctionBounds();
FormSelectionUtils.paste2Container(designer, parent, clipboard, rec.x + DELTA_X_Y, rec.y + DELTA_X_Y); FormSelectionUtils.paste2Container(designer, parent, clipboard, rec.x + DELTA_X_Y, rec.y + DELTA_X_Y);
} }
} }
} else {
Toolkit.getDefaultToolkit().beep();
}
return false;
}
public FormSelection getSelection() {
return selection;
}
/** /**
* 删除当前所有选择的组件 * 删除当前所有选择的组件
@ -268,18 +280,16 @@ public class SelectionModel {
if (designer.getClass().equals(FormDesigner.class)) { if (designer.getClass().equals(FormDesigner.class)) {
//frm本地组件复用 //frm本地组件复用
if (selectionXCreator != null) { if (selectionXCreator != null) {
if (selectionXCreator.getClass().equals(XWAbsoluteBodyLayout.class)) { //选中的是否是tab布局编辑器本身
//frm绝对布局编辑器 boolean tabEditor = selectionXCreator.getClass().equals(XWCardMainBorderLayout.class)
return false;
} else if (selectionXCreator.getClass().equals(XWCardMainBorderLayout.class)
|| selectionXCreator.getClass().equals(XWCardLayout.class) || selectionXCreator.getClass().equals(XWCardLayout.class)
|| selectionXCreator.getClass().equals(XWTabFitLayout.class)) { || selectionXCreator.getClass().equals(XWTabFitLayout.class);
//Tab布局编辑器 //选中的是否是frm绝对布局编辑器本身
return false; boolean absoluteEditor = selectionXCreator.getClass().equals(XWAbsoluteBodyLayout.class);
} else { //选中的是否是相对布局编辑器本身
//自适应布局编辑器 boolean relativeEditor = selectionXCreator.getClass().equals(XWFitLayout.class);
return !selectionXCreator.getClass().equals(XWFitLayout.class);
} return !(tabEditor || absoluteEditor || relativeEditor);
} else { } else {
return false; return false;
} }

Loading…
Cancel
Save