From 772880c9afc67ab3748f44cc8d7f10d2618ec72f Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 7 Nov 2017 16:29:31 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-5484=20=E8=A1=A8=E5=8D=95=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6=E4=BD=8D=E7=BD=AE=E7=BB=84=E4=BB=B6=E6=94=B9=E6=88=90?= =?UTF-8?q?=E7=84=A6=E7=82=B9=E5=A4=B1=E5=8E=BB=E8=A7=A6=E5=8F=91=E4=BF=9D?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/ispinner/UISpinner.java | 10 +++- .../widget/ui/FormWidgetCardPane.java | 1 + .../ui/designer/component/UIBoundSpinner.java | 48 +++++++++++++++++++ .../component/WidgetAbsoluteBoundPane.java | 17 ++++--- .../designer/component/WidgetBoundPane.java | 12 +++-- 5 files changed, 76 insertions(+), 12 deletions(-) create mode 100644 designer_form/src/com/fr/design/widget/ui/designer/component/UIBoundSpinner.java diff --git a/designer_base/src/com/fr/design/gui/ispinner/UISpinner.java b/designer_base/src/com/fr/design/gui/ispinner/UISpinner.java index 0ec3768aa5..361619ae29 100644 --- a/designer_base/src/com/fr/design/gui/ispinner/UISpinner.java +++ b/designer_base/src/com/fr/design/gui/ispinner/UISpinner.java @@ -101,11 +101,15 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver return; } this.value = value; + setTextField(value); + fireStateChanged(); + } + + protected void setTextField(double value){ textField.getDocument().removeDocumentListener(docListener); textField.setValue(value); textField.getDocument().addDocumentListener(docListener); - fireStateChanged(); } public void setTextFieldValue(double value) { @@ -257,6 +261,10 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver } } }); + initTextFiledListeners(); + } + + protected void initTextFiledListeners(){ textField.getDocument().removeDocumentListener(docListener); textField.getDocument().addDocumentListener(docListener); textField.addFocusListener(new FocusAdapter() { diff --git a/designer_form/src/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java b/designer_form/src/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java index 1ac55c2eda..07a1fe033b 100644 --- a/designer_form/src/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java +++ b/designer_form/src/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java @@ -215,6 +215,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { public void updateWidgetBound (){ if (widgetBoundPane != null && ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Coords_And_Size"))) { widgetBoundPane.update(); + designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_RESIZED); } designer.refreshDesignerUI(); } diff --git a/designer_form/src/com/fr/design/widget/ui/designer/component/UIBoundSpinner.java b/designer_form/src/com/fr/design/widget/ui/designer/component/UIBoundSpinner.java new file mode 100644 index 0000000000..426d27f1ae --- /dev/null +++ b/designer_form/src/com/fr/design/widget/ui/designer/component/UIBoundSpinner.java @@ -0,0 +1,48 @@ +package com.fr.design.widget.ui.designer.component; + +import com.fr.design.gui.ispinner.UISpinner; + +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; + +/** + * Created by kerry on 2017/11/7. + */ +public class UIBoundSpinner extends UISpinner{ + + public UIBoundSpinner(double minValue, double maxValue, double dierta) { + super(minValue, maxValue, dierta); + } + + public UIBoundSpinner(double minValue, double maxValue, double dierta, double defaultValue) { + super(minValue, maxValue, dierta, defaultValue); + } + + @Override + protected void initTextFiledListeners(){ + this.getTextField().addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + setTextFieldValue(getTextField().getValue()); + setTextField(value); + } + }); + + this.getTextField().addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + setTextFieldValue(getTextField().getValue()); + setTextField(value); + } + } + }); + } + + @Override + protected void setTextField(double value){ + this.getTextField().setValue(value); + } +} diff --git a/designer_form/src/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java b/designer_form/src/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java index c0d71c08af..262e52588a 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java @@ -20,11 +20,12 @@ public class WidgetAbsoluteBoundPane extends WidgetBoundPane { super(source); } + @Override public void initBoundPane() { - x = new UISpinner(0, Integer.MAX_VALUE, 1); - y = new UISpinner(0, Integer.MAX_VALUE, 1); - width = new UISpinner(0, Integer.MAX_VALUE, 1); - height = new UISpinner(0, Integer.MAX_VALUE, 1); + x = new UIBoundSpinner(0, Integer.MAX_VALUE, 1); + y = new UIBoundSpinner(0, Integer.MAX_VALUE, 1); + width = new UIBoundSpinner(0, Integer.MAX_VALUE, 1); + height = new UIBoundSpinner(0, Integer.MAX_VALUE, 1); x.setGlobalName(Inter.getLocText("FR-Designer_Coords_And_Size")); y.setGlobalName(Inter.getLocText("FR-Designer_Coords_And_Size")); width.setGlobalName(Inter.getLocText("FR-Designer_Coords_And_Size")); @@ -32,7 +33,7 @@ public class WidgetAbsoluteBoundPane extends WidgetBoundPane { this.add(WidgetBoundsPaneFactory.createAbsoluteBoundsPane(x, y, width, height)); } - + @Override public void update() { super.update(); Rectangle bounds = new Rectangle(creator.getBounds()); @@ -46,20 +47,22 @@ public class WidgetAbsoluteBoundPane extends WidgetBoundPane { creator.setBounds(bounds); } - + @Override public void limitWidth(WLayout wabs, int w, Rectangle bounds, Rectangle rec){ bounds.width = w; } + @Override public void limitHeight(WLayout wabs, int h, Rectangle bounds, Rectangle rec){ bounds.height = h; } - + @Override protected String title4PopupWindow() { return "absoluteBound"; } + @Override public void populate() { super.populate(); Rectangle bounds = new Rectangle(creator.getBounds()); diff --git a/designer_form/src/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java b/designer_form/src/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java index 2a033227e8..25fcece419 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java @@ -2,7 +2,11 @@ package com.fr.design.widget.ui.designer.component; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter; -import com.fr.design.designer.creator.*; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ispinner.UISpinner; @@ -48,8 +52,8 @@ public class WidgetBoundPane extends BasicPane { } public void initBoundPane() { - width = new UISpinner(0, Integer.MAX_VALUE, 1); - height = new UISpinner(0, Integer.MAX_VALUE, 1); + width = new UIBoundSpinner(0, Integer.MAX_VALUE, 1); + height = new UIBoundSpinner(0, Integer.MAX_VALUE, 1); width.setGlobalName(Inter.getLocText("FR-Designer_Coords_And_Size")); height.setGlobalName(Inter.getLocText("FR-Designer_Coords_And_Size")); if (creator.acceptType(XWCardLayout.class)) { @@ -64,6 +68,7 @@ public class WidgetBoundPane extends BasicPane { fix(); } + @Override protected String title4PopupWindow() { return "widgetBound"; } @@ -86,7 +91,6 @@ public class WidgetBoundPane extends BasicPane { if (bounds.height != h) { limitHeight(wabs, h, bounds, rec); } - creator.setBounds(bounds); }