From 8a9a1d7e7316f2987c0bbcc31e7e973b5e793202 Mon Sep 17 00:00:00 2001 From: plough Date: Mon, 9 Oct 2017 18:55:52 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-4883=20=E4=BB=A3=E7=A0=81=E8=A7=84?= =?UTF-8?q?=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../parameter/ParameterDefinitePane.java | 23 +-- .../designer/beans/models/SelectionModel.java | 150 ++++++++++-------- .../form/parameter/FormParaDesigner.java | 16 +- .../com/fr/design/mainframe/FormDesigner.java | 8 +- .../parameter/ParameterToolBarPane.java | 14 +- 5 files changed, 117 insertions(+), 94 deletions(-) diff --git a/designer/src/com/fr/design/parameter/ParameterDefinitePane.java b/designer/src/com/fr/design/parameter/ParameterDefinitePane.java index 4f8adabbbb..cb53dd8b7c 100644 --- a/designer/src/com/fr/design/parameter/ParameterDefinitePane.java +++ b/designer/src/com/fr/design/parameter/ParameterDefinitePane.java @@ -75,12 +75,23 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus this.setBorder(null); this.setLayout(FRGUIPaneFactory.createBorderLayout()); setComponentBg(this); -// formParaDesignEditor = new FormParaDesigner(new FormParameterUI()); paraDesignEditor = DesignModuleFactory.getFormParaDesigner(); if (paraDesignEditor == null) { return; } paraDesignEditor.initWidgetToolbarPane(); + + this.add(paraDesignEditor.createWrapper(), BorderLayout.CENTER); + + setButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/toolbarbtn/parametersetting.png")); + setButton.set4ToolbarButton(); + isshowWindowItem = new JCheckBoxMenuItem(Inter.getLocText("ParameterD-Show_Parameter_Window")); + isdelayItem = new JCheckBoxMenuItem(Inter.getLocText("ParameterD-Delay_Playing")); + + initListeners(); + } + + private void initListeners() { ((TargetComponent) paraDesignEditor).addTargetModifiedListener(new TargetModifiedListener() { @Override public void targetModified(TargetModifiedEvent e) { @@ -93,7 +104,6 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus paraDesignEditor.addListener(this); propertyChangeListener = new PropertyChangeAdapter() { - @Override public void propertyChange() { if (isEditing) { @@ -102,12 +112,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus } } }; - this.add(paraDesignEditor.createWrapper(), BorderLayout.CENTER); -// WidgetToolBarPane.getRecentSearchManger(formParaDesignEditor); - setButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/toolbarbtn/parametersetting.png")); - setButton.set4ToolbarButton(); - isshowWindowItem = new JCheckBoxMenuItem(Inter.getLocText("ParameterD-Show_Parameter_Window")); isshowWindowItem.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { @@ -116,9 +121,8 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus } } }); - isdelayItem = new JCheckBoxMenuItem(Inter.getLocText("ParameterD-Delay_Playing")); - isdelayItem.addItemListener(new ItemListener() { + isdelayItem.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (propertyChangeListener != null) { @@ -128,7 +132,6 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus } }); - setButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { diff --git a/designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java b/designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java index 354ba3f63d..e805ced3ca 100644 --- a/designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java +++ b/designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java @@ -136,37 +136,7 @@ public class SelectionModel { private void unselectedPaste() { if (designer.getClass().equals(FormDesigner.class)) { if (selection.getSelectedCreator() instanceof XWFitLayout) { - if (selection.getSelectedCreator().getClass().equals(XWTabFitLayout.class)) { - XLayoutContainer container = (XLayoutContainer) selection.getSelectedCreator(); - //tab布局编辑器内部左上角第一个坐标点 - int leftUpX = container.toData().getMargin().getLeft() + 1; - int leftUpY = container.toData().getMargin().getTop() + 1; - //选中第一个坐标点坐在的组件 - selection.setSelectedCreator((XCreator) container.getComponentAt(leftUpX, leftUpY)); - Rectangle rectangle = selection.getRelativeBounds(); - if (hasSelectedPasteSource()) { - selectedPaste(); - } else { - FormSelectionUtils.paste2Container(designer, container, clipboard, - rectangle.x + rectangle.width / 2, - rectangle.y + DELTA_X_Y); - } - } else { - //自适应布局编辑器内部左上角第一个坐标点 - int leftUpX = designer.getRootComponent().toData().getMargin().getLeft() + 1; - int leftUpY = designer.getRootComponent().toData().getMargin().getTop() + 1; - //选中第一个坐标点坐在的组件 - selection.setSelectedCreator((XCreator) designer.getRootComponent().getComponentAt(leftUpX, leftUpY)); - Rectangle rectangle = selection.getRelativeBounds(); - if (hasSelectedPasteSource()) { - selectedPaste(); - } else { - FormSelectionUtils.paste2Container(designer, designer.getRootComponent(), - clipboard, - rectangle.x + rectangle.width / 2, - rectangle.y + DELTA_X_Y); - } - } + pasteXWFitLayout(); } else { //绝对布局 //编辑器外面还有两层容器,使用designer.getRootComponent()获取到的是编辑器中层的容器,不是编辑器表层 @@ -186,6 +156,40 @@ public class SelectionModel { } } + private void pasteXWFitLayout() { + if (selection.getSelectedCreator().getClass().equals(XWTabFitLayout.class)) { + XLayoutContainer container = (XLayoutContainer) selection.getSelectedCreator(); + //tab布局编辑器内部左上角第一个坐标点 + int leftUpX = container.toData().getMargin().getLeft() + 1; + int leftUpY = container.toData().getMargin().getTop() + 1; + //选中第一个坐标点坐在的组件 + selection.setSelectedCreator((XCreator) container.getComponentAt(leftUpX, leftUpY)); + Rectangle rectangle = selection.getRelativeBounds(); + if (hasSelectedPasteSource()) { + selectedPaste(); + } else { + FormSelectionUtils.paste2Container(designer, container, clipboard, + rectangle.x + rectangle.width / 2, + rectangle.y + DELTA_X_Y); + } + } else { + //自适应布局编辑器内部左上角第一个坐标点 + int leftUpX = designer.getRootComponent().toData().getMargin().getLeft() + 1; + int leftUpY = designer.getRootComponent().toData().getMargin().getTop() + 1; + //选中第一个坐标点坐在的组件 + selection.setSelectedCreator((XCreator) designer.getRootComponent().getComponentAt(leftUpX, leftUpY)); + Rectangle rectangle = selection.getRelativeBounds(); + if (hasSelectedPasteSource()) { + selectedPaste(); + } else { + FormSelectionUtils.paste2Container(designer, designer.getRootComponent(), + clipboard, + rectangle.x + rectangle.width / 2, + rectangle.y + DELTA_X_Y); + } + } + } + /** * 粘贴时选择组件 */ @@ -404,45 +408,57 @@ public class SelectionModel { if (x < (bounds.x - XCreatorConstants.RESIZE_BOX_SIZ)) { return Location.outer; } else if ((x >= (bounds.x - XCreatorConstants.RESIZE_BOX_SIZ)) && (x <= bounds.x)) { - if (y < (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) { - return Location.outer; - } else if ((y >= (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) && (y <= bounds.y)) { - return Location.left_top; - } else if ((y > bounds.y) && (y < (bounds.y + bounds.height))) { - return Location.left; - } else if ((y >= (bounds.y + bounds.height)) - && (y <= (bounds.y + bounds.height + XCreatorConstants.RESIZE_BOX_SIZ))) { - return Location.left_bottom; - } else { - return Location.outer; - } + return getDirectionLeft(bounds, y); } else if ((x > bounds.x) && (x < (bounds.x + bounds.width))) { - if (y < (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) { - return Location.outer; - } else if ((y >= (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) && (y <= bounds.y)) { - return Location.top; - } else if ((y > bounds.y) && (y < (bounds.y + bounds.height))) { - return Location.inner; - } else if ((y >= (bounds.y + bounds.height)) - && (y <= (bounds.y + bounds.height + XCreatorConstants.RESIZE_BOX_SIZ))) { - return Location.bottom; - } else { - return Location.outer; - } + return getDirectionCenter(bounds, y); } else if ((x >= (bounds.x + bounds.width)) && (x <= (bounds.x + bounds.width + XCreatorConstants.RESIZE_BOX_SIZ))) { - if (y < (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) { - return Location.outer; - } else if ((y >= (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) && (y <= bounds.y)) { - return Location.right_top; - } else if ((y > bounds.y) && (y < (bounds.y + bounds.height))) { - return Location.right; - } else if ((y >= (bounds.y + bounds.height)) - && (y <= (bounds.y + bounds.height + XCreatorConstants.RESIZE_BOX_SIZ))) { - return Location.right_bottom; - } else { - return Location.outer; - } + return getDirectionRight(bounds, y); + } else { + return Location.outer; + } + } + + private Direction getDirectionRight(Rectangle bounds, int y) { + if (y < (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) { + return Location.outer; + } else if ((y >= (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) && (y <= bounds.y)) { + return Location.right_top; + } else if ((y > bounds.y) && (y < (bounds.y + bounds.height))) { + return Location.right; + } else if ((y >= (bounds.y + bounds.height)) + && (y <= (bounds.y + bounds.height + XCreatorConstants.RESIZE_BOX_SIZ))) { + return Location.right_bottom; + } else { + return Location.outer; + } + } + + private Direction getDirectionCenter(Rectangle bounds, int y) { + if (y < (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) { + return Location.outer; + } else if ((y >= (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) && (y <= bounds.y)) { + return Location.top; + } else if ((y > bounds.y) && (y < (bounds.y + bounds.height))) { + return Location.inner; + } else if ((y >= (bounds.y + bounds.height)) + && (y <= (bounds.y + bounds.height + XCreatorConstants.RESIZE_BOX_SIZ))) { + return Location.bottom; + } else { + return Location.outer; + } + } + + private Direction getDirectionLeft(Rectangle bounds, int y) { + if (y < (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) { + return Location.outer; + } else if ((y >= (bounds.y - XCreatorConstants.RESIZE_BOX_SIZ)) && (y <= bounds.y)) { + return Location.left_top; + } else if ((y > bounds.y) && (y < (bounds.y + bounds.height))) { + return Location.left; + } else if ((y >= (bounds.y + bounds.height)) + && (y <= (bounds.y + bounds.height + XCreatorConstants.RESIZE_BOX_SIZ))) { + return Location.left_bottom; } else { return Location.outer; } diff --git a/designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java b/designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java index cc100df8ed..b9d24b2cd8 100644 --- a/designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java +++ b/designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java @@ -70,6 +70,9 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP private static final int SECOND_H_LOCATION = 170; private static final int ADD_HEIGHT = 20; private static final int H_GAP = 105; + private static final int SUBMIT_BUTTON_H_LOCATION = 270; + private static final int PARA_IMAGE_SHIFT_X = -4; + private static final int FORM_AREA_PADDING_LEFT = 13; private static Image paraImage = BaseUtils.readImage("/com/fr/design/images/form/parameter.png"); @@ -166,12 +169,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP @Override public void fireCreatorModified(DesignerEvent evt) { - if (evt.getCreatorEventID() == DesignerEvent.CREATOR_ADDED - || evt.getCreatorEventID() == DesignerEvent.CREATOR_CUTED - || evt.getCreatorEventID() == DesignerEvent.CREATOR_PASTED - || evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED - || evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED - || evt.getCreatorEventID() == DesignerEvent.CREATOR_RENAMED) { + if (evt.getCreatorEventID() != DesignerEvent.CREATOR_SELECTED) { paraDefinitePane.setParameterArray( paraDefinitePane.getNoRepeatParas(DesignModelAdapter.getCurrentModelAdapter().getParameters())); paraDefinitePane.refreshParameter(); @@ -187,7 +185,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP */ public Component createWrapper() { FormArea area = new FormArea(this, false); - area.setBorder(BorderFactory.createEmptyBorder(0, 13, 0, 0)); + area.setBorder(BorderFactory.createEmptyBorder(0, FORM_AREA_PADDING_LEFT, 0, 0)); return area; } @@ -439,7 +437,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP } for (Parameter p : paras) { if (p.getName().equalsIgnoreCase(creator.toData().getWidgetName())) { - g.drawImage(paraImage, creator.getX() - 4, creator.getY() + 2, null); + g.drawImage(paraImage, creator.getX() + PARA_IMAGE_SHIFT_X, creator.getY() + 2, null); break; } } @@ -617,7 +615,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP formSubmitButton.setWidgetName("Search"); formSubmitButton.setText(Inter.getLocText("FR-Designer_Query")); xCreator = XCreatorUtils.createXCreator(formSubmitButton); - if (!(this.autoAddComponent(xCreator, 270, FIRST_V_LOCATION + V_COMPONENT_GAP + if (!(this.autoAddComponent(xCreator, SUBMIT_BUTTON_H_LOCATION, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { return false; } diff --git a/designer_form/src/com/fr/design/mainframe/FormDesigner.java b/designer_form/src/com/fr/design/mainframe/FormDesigner.java index 98bfbfeb44..fe998656be 100644 --- a/designer_form/src/com/fr/design/mainframe/FormDesigner.java +++ b/designer_form/src/com/fr/design/mainframe/FormDesigner.java @@ -123,6 +123,7 @@ public class FormDesigner extends TargetComponent
implements TreeSelection private static final int SECOND_H_LOCATION = 170; private static final int ADD_HEIGHT = 20; private static final int H_GAP = 105; + private static final int SUBMIT_BUTTON_H_LOCATION = 270; public FormDesigner(Form form) { this(form, null); @@ -294,7 +295,7 @@ public class FormDesigner extends TargetComponent implements TreeSelection formSubmitButton.setWidgetName("Search"); formSubmitButton.setText(Inter.getLocText("FR-Designer_Query")); xCreator = XCreatorUtils.createXCreator(formSubmitButton); - if (!(this.autoAddComponent(xCreator, 270, FIRST_V_LOCATION + V_COMPONENT_GAP + if (!(this.autoAddComponent(xCreator, SUBMIT_BUTTON_H_LOCATION, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { return; } @@ -1146,7 +1147,7 @@ public class FormDesigner extends TargetComponent implements TreeSelection * 同步 */ public void populateRootSize() { - + // do nothing } /** @@ -1232,6 +1233,7 @@ public class FormDesigner extends TargetComponent implements TreeSelection */ @Override public void stopEditing() { + // do nothing } /** @@ -1411,7 +1413,7 @@ public class FormDesigner extends TargetComponent implements TreeSelection parent = parent.getParent(); } - Object[] components = path.toArray(); + Object[] components = (Object[]) path.toArray(); if (components.length == 0) { return null; } diff --git a/designer_form/src/com/fr/design/parameter/ParameterToolBarPane.java b/designer_form/src/com/fr/design/parameter/ParameterToolBarPane.java index daac4c2db8..422c08ab09 100644 --- a/designer_form/src/com/fr/design/parameter/ParameterToolBarPane.java +++ b/designer_form/src/com/fr/design/parameter/ParameterToolBarPane.java @@ -35,6 +35,7 @@ public class ParameterToolBarPane extends BasicBeanPane { private static final int BUTTON_HEIGHT = 20; private static final int WIDTH = 225; private static final int L_H = 18; + private static final int LABEL_PADDING_LEFT = 4; public ParameterToolBarPane() { this.setLayout(new FlowParameterPaneLayout()); @@ -47,9 +48,9 @@ public class ParameterToolBarPane extends BasicBeanPane { return new Dimension(super.getPreferredSize().width, 18); } }; - label.setText(Inter.getLocText("FR-Following_parameters_are_not_generated")+":"); + label.setText(Inter.getLocText("FR-Following_parameters_are_not_generated") + ":"); label.setHorizontalAlignment(SwingConstants.LEFT); - label.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0)); + label.setBorder(BorderFactory.createEmptyBorder(0, LABEL_PADDING_LEFT, 0, 0)); this.add(label); addAll = new UIButton(Inter.getLocText("FR-Designer_Add_all")); @@ -68,7 +69,7 @@ public class ParameterToolBarPane extends BasicBeanPane { public Parameter getTargetParameter(UIButton button) { int index = parameterSelectedLabellist.indexOf(button); - if(index < 0 || index > parameterList.length - 1) { + if (index < 0 || index > parameterList.length - 1) { return null; } return parameterList[index]; @@ -122,12 +123,15 @@ public class ParameterToolBarPane extends BasicBeanPane { private class FlowParameterPaneLayout implements LayoutManager { public FlowParameterPaneLayout() { + // do nothing } public void addLayoutComponent(String name, Component comp) { + // do nothing } public void removeLayoutComponent(Component comp) { + // do nothing } public Dimension preferredLayoutSize(Container parent) { @@ -135,7 +139,7 @@ public class ParameterToolBarPane extends BasicBeanPane { layoutContainer(parent); - int h= ((parameterSelectedLabellist.size() == 0) ? 0 : breakid * (BUTTON_HEIGHT + GAP_V) + GAP_BV + L_H + GAP_H + addAll.getPreferredSize().height); + int h= (parameterSelectedLabellist.isEmpty() ? 0 : breakid * (BUTTON_HEIGHT + GAP_V) + GAP_BV + L_H + GAP_H + addAll.getPreferredSize().height); return new Dimension(w, h); } @@ -153,7 +157,7 @@ public class ParameterToolBarPane extends BasicBeanPane { breakid = 1; for (UIButton tab : parameterSelectedLabellist) { Dimension dim = tab.getPreferredSize(); - if(x + dim.width > width) { + if (x + dim.width > width) { breakid++; x = 0; y += (dim.height + GAP_V);