From 3718d8c56854f0d9d83182c7369b185533413663 Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 22 Sep 2017 09:40:36 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-4694=20tab=E7=BB=84=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E5=88=87=E6=8D=A2tab=E6=97=B6=E7=BB=84=E4=BB=B6=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=B2=A1=E6=9C=89=E6=94=B9=E5=8F=98=E5=92=8C=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6=E8=BE=B9=E7=95=8C=E5=8F=AF=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/WidgetAbsoluteBoundPane.java | 24 ++-- .../designer/component/WidgetBoundPane.java | 110 +++++++++++++++++- .../layout/WTabFitLayoutDefinePane.java | 41 ++++++- .../layout/WTitleLayoutDefinePane.java | 6 +- 4 files changed, 164 insertions(+), 17 deletions(-) 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 7cf0493de..3862b5f00 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 @@ -1,26 +1,20 @@ package com.fr.design.widget.ui.designer.component; import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.widget.WidgetBoundsPaneFactory; -import com.fr.form.ui.container.WAbsoluteLayout; - +import com.fr.form.ui.container.WLayout; import java.awt.*; /** * Created by ibm on 2017/8/3. */ public class WidgetAbsoluteBoundPane extends WidgetBoundPane { - protected XWAbsoluteLayout parent; private UISpinner x; private UISpinner y; public WidgetAbsoluteBoundPane(XCreator source){ super(source); - XLayoutContainer xLayoutContainer = getParent(source); - this.parent = (XWAbsoluteLayout) xLayoutContainer; } public void initBoundPane() { @@ -40,13 +34,25 @@ public class WidgetAbsoluteBoundPane extends WidgetBoundPane { if (parent == null) { return; } - WAbsoluteLayout wabs = parent.toData(); + WLayout wabs = parent.toData(); wabs.setBounds(creator.toData(), bounds); creator.setBounds(bounds); } + + public void limitWidth(WLayout wabs, int w, Rectangle bounds, Rectangle rec){ + bounds.width = w; + } + + public void limitHeight(WLayout wabs, int h, Rectangle bounds, Rectangle rec){ + bounds.height = h; + } + + + + protected String title4PopupWindow() { - return ""; + return "absoluteBound"; } public void populate() { 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 da5334cc2..4af43dbd1 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 @@ -1,11 +1,22 @@ 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.cardlayout.XWCardLayout; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.utils.ComponentUtils; import com.fr.design.widget.WidgetBoundsPaneFactory; +import com.fr.form.ui.PaddingMargin; +import com.fr.form.ui.container.WFitLayout; +import com.fr.form.ui.container.WLayout; +import com.fr.general.Inter; +import javax.swing.*; import java.awt.*; /** @@ -13,6 +24,9 @@ import java.awt.*; */ public class WidgetBoundPane extends BasicPane { + private static final int MINHEIGHT = WLayout.MIN_HEIGHT; + private static final int MINWIDTH = WLayout.MIN_WIDTH; + protected XLayoutContainer parent; protected XCreator creator; protected UISpinner width; protected UISpinner height; @@ -20,6 +34,7 @@ public class WidgetBoundPane extends BasicPane { public WidgetBoundPane(XCreator source) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.creator = source; + this.parent = getParent(source); initBoundPane(); } @@ -34,19 +49,20 @@ public class WidgetBoundPane extends BasicPane { public void initBoundPane() { width = new UISpinner(0, 1200, 1); height = new UISpinner(0, 1200, 1); + if (creator.acceptType(XWCardLayout.class)) { + width.setEnabled(false); + height.setEnabled(false); + } this.add(WidgetBoundsPaneFactory.createBoundsPane(width, height)); } public void update() { - Rectangle bounds = new Rectangle(creator.getBounds()); - bounds.width = (int) width.getValue(); - bounds.height = (int) height.getValue(); - creator.setBounds(bounds); + fix(); } protected String title4PopupWindow() { - return ""; + return "widgetBound"; } public void populate() { @@ -54,4 +70,88 @@ public class WidgetBoundPane extends BasicPane { width.setValue(bounds.width); height.setValue(bounds.height); } + + public void fix() { + Rectangle bounds = new Rectangle(creator.getBounds()); + int w = (int) width.getValue(); + int h = (int) height.getValue(); + Rectangle rec = ComponentUtils.getRelativeBounds(parent); + WLayout wabs = parent.toData(); + if (bounds.width != w) { + limitWidth(wabs, w, bounds, rec); + } + if (bounds.height != h) { + limitHeight(wabs, h, bounds, rec); + } + creator.setBounds(bounds); + } + + + public void adjustComponents(Rectangle bounds, int difference, int row) { + FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + Rectangle backupBounds = getBound(); + FRFitLayoutAdapter layoutAdapter = (FRFitLayoutAdapter) AdapterBus.searchLayoutAdapter(formDesigner, creator); + if (layoutAdapter != null) { + layoutAdapter.setEdit(true); + layoutAdapter.calculateBounds(backupBounds, bounds, creator, row, difference); + } + } + + public void limitWidth(WLayout wabs, int w, Rectangle bounds, Rectangle rec) { + int difference = 0; + int minWidth = (int) (MINWIDTH * ((WFitLayout) wabs).getResolutionScaling()); + PaddingMargin margin = wabs.getMargin(); + if (bounds.width != w) { + if (bounds.width == rec.width - margin.getLeft() - margin.getRight()) { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Beyond_Bounds")); + width.setValue(bounds.width); + return; + } else if (w < minWidth) { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Min_Width") + Integer.toString(minWidth)); + width.setValue(bounds.width); + return; + } + difference = bounds.width - w; + bounds.width = w; + } + width.setValue(bounds.width); + wabs.setBounds(creator.toData(), bounds); + adjustComponents(bounds, difference, 0); + } + + public void limitHeight(WLayout wabs, int h, Rectangle bounds, Rectangle rec) { + int difference = 0; + PaddingMargin margin = wabs.getMargin(); + int minHeight = (int) (MINHEIGHT * ((WFitLayout) wabs).getResolutionScaling()); + if (bounds.height != h) { + if (bounds.height == rec.height - margin.getTop() - margin.getBottom()) { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Beyond_Bounds")); + height.setValue(bounds.height); + return; + } else if (h < minHeight) { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Min_Height") + Integer.toString(minHeight)); + height.setValue(bounds.height); + return; + } + difference = bounds.height - h; + bounds.height = h; + } + wabs.setBounds(creator.toData(), bounds); + creator.setBounds(bounds); + adjustComponents(bounds, difference, 1); + } + + + public Rectangle getBound() { + Rectangle bounds = new Rectangle(creator.getBounds()); + if (parent == null) { + return bounds; + } + Rectangle rec = ComponentUtils.getRelativeBounds(parent); + bounds.x += rec.x; + bounds.y += rec.y; + return bounds; + + } + } diff --git a/designer_form/src/com/fr/design/widget/ui/designer/layout/WTabFitLayoutDefinePane.java b/designer_form/src/com/fr/design/widget/ui/designer/layout/WTabFitLayoutDefinePane.java index 82ea84af0..b522950a3 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/layout/WTabFitLayoutDefinePane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/layout/WTabFitLayoutDefinePane.java @@ -2,6 +2,9 @@ package com.fr.design.widget.ui.designer.layout; import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.cardlayout.XWCardLayout; +import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; +import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; @@ -11,7 +14,12 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.widget.ui.designer.AbstractDataModify; import com.fr.design.widget.ui.designer.component.PaddingBoundPane; import com.fr.design.widget.ui.designer.component.TabFitLayoutBackgroundPane; +import com.fr.form.ui.CardSwitchButton; +import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; +import com.fr.form.ui.container.cardlayout.WCardTagLayout; +import com.fr.form.ui.container.cardlayout.WCardTitleLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; +import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import javax.swing.*; @@ -70,16 +78,47 @@ public class WTabFitLayoutDefinePane extends AbstractDataModify { borderStyle.populate(ob); paddingBoundPane.populate(ob); componentInterval.setValue(ob.getCompInterval()); + if(ob.getCurrentCard() == null){ + ob.setCurrentCard(getRelateSwitchButton(ob)); + } titleField.setText(ob.getCurrentCard().getText()); } + private CardSwitchButton getRelateSwitchButton(WTabFitLayout layout){ + int index = layout.getIndex(); + + XWCardLayout cardLayout = (XWCardLayout)creator.getBackupParent(); + XWCardMainBorderLayout border = (XWCardMainBorderLayout)cardLayout.getBackupParent(); + WCardMainBorderLayout borderLayout = border.toData(); + WCardTitleLayout titleLayout = borderLayout.getTitlePart(); + if(titleLayout == null){ + return null; + } + + WCardTagLayout tagLayout = titleLayout.getTagPart(); + return tagLayout == null ? null : tagLayout.getSwitchButton(index); + } + + + private void setLayoutGap(int gap, WTabFitLayout layout, XWTabFitLayout xwTabFitLayout) { + if(xwTabFitLayout.canAddInterval(gap)){ + int interval = layout.getCompInterval(); + if (gap != interval) { + xwTabFitLayout.moveContainerMargin(); + xwTabFitLayout.moveCompInterval(xwTabFitLayout.getAcualInterval()); + layout.setCompInterval(gap); + xwTabFitLayout.addCompInterval(xwTabFitLayout.getAcualInterval()); + } + } + } @Override public WTabFitLayout updateBean() { WTabFitLayout layout = (WTabFitLayout) creator.toData(); borderStyle.update(layout); paddingBoundPane.update(layout); - layout.setCompInterval((int)componentInterval.getValue()); + int gap = (int)componentInterval.getValue(); + setLayoutGap(gap, layout, (XWTabFitLayout)creator); layout.getCurrentCard().setText(titleField.getText()); return layout; } diff --git a/designer_form/src/com/fr/design/widget/ui/designer/layout/WTitleLayoutDefinePane.java b/designer_form/src/com/fr/design/widget/ui/designer/layout/WTitleLayoutDefinePane.java index dd0b80bba..a507a99b8 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/layout/WTitleLayoutDefinePane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/layout/WTitleLayoutDefinePane.java @@ -12,6 +12,7 @@ import com.fr.design.widget.ui.designer.AbstractDataModify; import com.fr.design.widget.ui.designer.component.PaddingBoundPane; import com.fr.form.ui.*; import com.fr.form.ui.container.WTitleLayout; +import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import javax.swing.*; @@ -32,7 +33,6 @@ public abstract class WTitleLayoutDefinePane