From c990da3001a65b53f87038daddc78edde9410141 Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 12 Dec 2017 13:48:11 +0800 Subject: [PATCH 1/6] =?UTF-8?q?REPORT-2615=20=E5=A4=9A=E7=A7=8Dtab?= =?UTF-8?q?=E5=B8=83=E5=B1=80=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/locale/designer.properties | 7 + .../design/locale/designer_en_US.properties | 7 + .../design/locale/designer_ja_JP.properties | 9 +- .../design/locale/designer_ko_KR.properties | 9 +- .../design/locale/designer_zh_CN.properties | 9 +- .../design/locale/designer_zh_TW.properties | 7 + .../AccessibleTemplateStyleEditor.java | 42 ++ .../widget/accessibles/TemplateStylePane.java | 99 +++ .../accessibles/TemplateStylePreviewPane.java | 37 + .../widget/wrappers/TemplateStyleWrapper.java | 29 + .../widget/WidgetBoundsPaneFactory.java | 24 +- .../layout/FRBorderLayoutAdapter.java | 4 + .../adapters/layout/FRFitLayoutAdapter.java | 21 +- .../beans/painters/FRBorderLayoutPainter.java | 3 + .../designer/creator/XCreatorUtils.java | 3 + .../creator/XWHorizontalBoxLayout.java | 25 +- .../creator/cardlayout/XCardAddButton.java | 8 +- .../creator/cardlayout/XCardSwitchButton.java | 117 ++-- .../creator/cardlayout/XWCardLayout.java | 26 +- .../cardlayout/XWCardMainBorderLayout.java | 121 +++- .../creator/cardlayout/XWCardTagLayout.java | 239 ++++++- .../creator/cardlayout/XWCardTitleLayout.java | 48 +- .../creator/cardlayout/XWTabFitLayout.java | 23 + .../treeview/ComponentTreeCellRenderer.java | 10 +- .../fr/design/form/layout/FRFlowLayout.java | 24 + .../form/layout/FRHorizontalLayout.java | 36 + .../design/form/layout/FRVerticalLayout.java | 34 + .../gui/xpane/CardTagLayoutBorderPane.java | 85 +-- .../fr/design/gui/xpane/LayoutBorderPane.java | 639 ++++++++++-------- .../fr/design/mainframe/FormSelection.java | 12 +- .../widget/ui/FormWidgetCardPane.java | 8 +- .../FormWidgetDefinePaneFactoryBase.java | 2 + .../designer/component/WidgetBoundPane.java | 6 +- .../component/WidgetCardTagBoundPane.java | 76 +++ .../layout/WCardLayoutDefinePane.java | 50 +- .../layout/WCardMainLayoutDefinePane.java | 63 +- .../layout/WCardTagLayoutDefinePane.java | 114 ++++ 37 files changed, 1516 insertions(+), 560 deletions(-) create mode 100644 designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTemplateStyleEditor.java create mode 100644 designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java create mode 100644 designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java create mode 100644 designer_base/src/com/fr/design/mainframe/widget/wrappers/TemplateStyleWrapper.java create mode 100644 designer_form/src/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java create mode 100644 designer_form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index 7db99aed9..1475bb230 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -2153,3 +2153,10 @@ FR-Designer_Move_Up=Move up FR-Designer_Move_Down=Move down FR-Designer_Move_To_Top=Move to top FR-Designer_Move_To_Bottom=Move to bottom +FR-Designer_Tab_Style_Template=Style Template +FR-Designer_Tab_Template_One=Template One +FR-Designer_Tab_Template_Two=Template Two +FR-Designer_Tab_Template_Three=Template Three +FR-Designer_Tab_Template_Four=Template Four +FR-Designer_Tab_Template_Five=Template Five +FR-Designer_Tab_Template_Six=Template Six \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index b9fee5a51..f77802a02 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -2152,3 +2152,10 @@ FR-Designer_Move_Up=Move up FR-Designer_Move_Down=Move down FR-Designer_Move_To_Top=Move to top FR-Designer_Move_To_Bottom=Move to bottom +FR-Designer_Tab_Style_Template=Style Template +FR-Designer_Tab_Template_One=Template One +FR-Designer_Tab_Template_Two=Template Two +FR-Designer_Tab_Template_Three=Template Three +FR-Designer_Tab_Template_Four=Template Four +FR-Designer_Tab_Template_Five=Template Five +FR-Designer_Tab_Template_Six=Template Six diff --git a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties index 3fb5a00ec..0dda67fe6 100644 --- a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties +++ b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties @@ -2152,4 +2152,11 @@ FR-Designer_Format_JavaScript=Format Code FR-Designer_Move_Up= FR-Designer_Move_Down= FR-Designer_Move_To_Top= -FR-Designer_Move_To_Bottom= \ No newline at end of file +FR-Designer_Move_To_Bottom= +FR-Designer_Tab_Style_Template= +FR-Designer_Tab_Template_One= +FR-Designer_Tab_Template_Two= +FR-Designer_Tab_Template_Three= +FR-Designer_Tab_Template_Four= +FR-Designer_Tab_Template_Five= +FR-Designer_Tab_Template_Six= \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties index 2ca30085a..bff3b417f 100644 --- a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties +++ b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties @@ -2152,4 +2152,11 @@ FR-Designer_Format_JavaScript=Format Code FR-Designer_Move_Up= FR-Designer_Move_Down= FR-Designer_Move_To_Top= -FR-Designer_Move_To_Bottom= \ No newline at end of file +FR-Designer_Move_To_Bottom= +FR-Designer_Tab_Style_Template= +FR-Designer_Tab_Template_One= +FR-Designer_Tab_Template_Two= +FR-Designer_Tab_Template_Three= +FR-Designer_Tab_Template_Four= +FR-Designer_Tab_Template_Five= +FR-Designer_Tab_Template_Six= \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index 364c2515b..aea21175e 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -2152,4 +2152,11 @@ FR-Designer_Format_JavaScript=\u683C\u5F0F\u5316\u4EE3\u7801 FR-Designer_Move_Up=\u4E0A\u79FB\u4E00\u5C42 FR-Designer_Move_Down=\u4E0B\u79FB\u4E00\u5C42 FR-Designer_Move_To_Top=\u7F6E\u4E8E\u9876\u5C42 -FR-Designer_Move_To_Bottom=\u7F6E\u4E8E\u5E95\u5C42 \ No newline at end of file +FR-Designer_Move_To_Bottom=\u7F6E\u4E8E\u5E95\u5C42 +FR-Designer_Tab_Style_Template=\u6837\u5F0F\u6A21\u677F +FR-Designer_Tab_Template_One=\u6A21\u677F\u4E00 +FR-Designer_Tab_Template_Two=\u6A21\u677F\u4E8C +FR-Designer_Tab_Template_Three=\u6A21\u677F\u4E09 +FR-Designer_Tab_Template_Four=\u6A21\u677F\u56DB +FR-Designer_Tab_Template_Five=\u6A21\u677F\u4E94 +FR-Designer_Tab_Template_Six=\u6A21\u677F\u516D \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index 59602f2a9..863601505 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -2152,3 +2152,10 @@ FR-Designer_Move_Up=\u4E0A\u79FB\u4E00\u5C64 FR-Designer_Move_Down=\u4E0B\u79FB\u4E00\u5C64 FR-Designer_Move_To_Top=\u7F6E\u65BC\u9802\u5C64 FR-Designer_Move_To_Bottom=\u7F6E\u65BC\u5E95\u5C64 +FR-Designer_Tab_Style_Template=\u6A23\u5F0F\u6A21\u677F +FR-Designer_Tab_Template_One=\u6A21\u677F\u4E00 +FR-Designer_Tab_Template_Two=\u6A21\u677F\u4E8C +FR-Designer_Tab_Template_Three=\u6A21\u677F\u4E09 +FR-Designer_Tab_Template_Four=\u6A21\u677F\u56DB +FR-Designer_Tab_Template_Five=\u6A21\u677F\u4E94 +FR-Designer_Tab_Template_Six=\u6A21\u677F\u516D \ No newline at end of file diff --git a/designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTemplateStyleEditor.java b/designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTemplateStyleEditor.java new file mode 100644 index 000000000..5b92df50e --- /dev/null +++ b/designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTemplateStyleEditor.java @@ -0,0 +1,42 @@ +package com.fr.design.mainframe.widget.accessibles; + +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.base.TemplateStyle; +import com.fr.design.mainframe.widget.wrappers.TemplateStyleWrapper; + +import javax.swing.SwingUtilities; +import java.awt.Dimension; + +/** + * Created by kerry on 2017/11/23. + */ +public class AccessibleTemplateStyleEditor extends UneditableAccessibleEditor { + + private static final Dimension DEFAULT_DIMENSION = new Dimension(600, 400); + + private TemplateStylePane stylePane; + + public AccessibleTemplateStyleEditor() { + super(new TemplateStyleWrapper()); + } + + @Override + protected void showEditorPane() { + if (stylePane == null) { + stylePane = new TemplateStylePane(); + stylePane.setPreferredSize(DEFAULT_DIMENSION); + } + BasicDialog dlg = stylePane.showWindow(SwingUtilities.getWindowAncestor(this)); + dlg.addDialogActionListener(new DialogActionAdapter() { + + @Override + public void doOk() { + setValue(stylePane.update()); + fireStateChanged(); + } + }); + stylePane.populate((TemplateStyle) getValue()); + dlg.setVisible(true); + } +} diff --git a/designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java b/designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java new file mode 100644 index 000000000..3a0a35b01 --- /dev/null +++ b/designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java @@ -0,0 +1,99 @@ +package com.fr.design.mainframe.widget.accessibles; + +import com.fr.base.BannerTemplateStyle; +import com.fr.base.BookMarkTemplateStyle; +import com.fr.base.CardTemplateStyle; +import com.fr.base.DefaultTemplateStyle; +import com.fr.base.MenuTemplateStyle; +import com.fr.base.PentagonTemplateStyle; +import com.fr.base.TrapezoidTemplateStyle; +import com.fr.design.dialog.BasicPane; +import com.fr.base.TemplateStyle; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.DefaultListModel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * Created by kerry on 2017/11/23. + */ +public class TemplateStylePane extends BasicPane { + private DefaultListModel listModel; + private JList styleList; + private TemplateStylePreviewPane previewPane = new TemplateStylePreviewPane(new DefaultTemplateStyle()); + + public TemplateStylePane(){ + init(); + } + + public void init(){ + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + listModel = new DefaultListModel(); + listModel.addElement(new DefaultTemplateStyle()); + listModel.addElement(new CardTemplateStyle()); + listModel.addElement(new BookMarkTemplateStyle()); + listModel.addElement(new PentagonTemplateStyle()); + listModel.addElement(new MenuTemplateStyle()); + listModel.addElement(new TrapezoidTemplateStyle()); + listModel.addElement(new BannerTemplateStyle()); + styleList = new JList(listModel); + styleList.setCellRenderer(render); + + JPanel westPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + westPane.add(styleList, BorderLayout.CENTER); + JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + westPane.setPreferredSize(new Dimension(100, 500)); + centerPane.setPreferredSize(new Dimension(300, 500)); + centerPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("Preview"), null)); + centerPane.add(previewPane); + styleList.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + previewPane.repaint((TemplateStyle) styleList.getSelectedValue()); + } + }); + this.add(westPane, BorderLayout.WEST); + this.add(centerPane, BorderLayout.CENTER); + } + public static ListCellRenderer render = new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + if (value instanceof TemplateStyle) { + TemplateStyle l = (TemplateStyle) value; + this.setText(l.toString()); + } + return this; + } + }; + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("FR-Designer_Tab_Style_Template"); + } + + public void populate(TemplateStyle templateStyle) { + previewPane.repaint(templateStyle); + for(int i = 0; i< listModel.getSize(); i++){ + if((listModel.getElementAt(i).toString()).equals(templateStyle.toString())){ + styleList.setSelectedIndex(i); + return; + } + } + styleList.setSelectedIndex(0); + } + + public TemplateStyle update() { + return (TemplateStyle) styleList.getSelectedValue(); + } +} diff --git a/designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java b/designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java new file mode 100644 index 000000000..24b9b393f --- /dev/null +++ b/designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java @@ -0,0 +1,37 @@ +package com.fr.design.mainframe.widget.accessibles; + +import com.fr.base.BaseUtils; +import com.fr.base.TemplateStyle; + +import javax.swing.JPanel; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; + +/** + * Created by kerry on 2017/12/11. + */ +public class TemplateStylePreviewPane extends JPanel { + + private static final int WIDTH = 540; + private static final int HEIGHT = 500; + + private TemplateStyle templateStyle; + + public TemplateStylePreviewPane(TemplateStyle templateStyle){ + this.templateStyle = templateStyle; + } + + public void repaint (TemplateStyle templateStyle){ + this.templateStyle = templateStyle; + super.repaint(); + } + + @Override + public void paint(Graphics g) { + super.paint(g); + Graphics2D g2d = (Graphics2D) g.create(); + Image image = BaseUtils.readImage(templateStyle.getPreview()); + g2d.drawImage(image, 0, 0, WIDTH, HEIGHT, null); + } +} diff --git a/designer_base/src/com/fr/design/mainframe/widget/wrappers/TemplateStyleWrapper.java b/designer_base/src/com/fr/design/mainframe/widget/wrappers/TemplateStyleWrapper.java new file mode 100644 index 000000000..bcdf195f0 --- /dev/null +++ b/designer_base/src/com/fr/design/mainframe/widget/wrappers/TemplateStyleWrapper.java @@ -0,0 +1,29 @@ +package com.fr.design.mainframe.widget.wrappers; + +import com.fr.design.Exception.ValidationException; +import com.fr.design.designer.properties.Decoder; +import com.fr.design.designer.properties.Encoder; +import com.fr.stable.StringUtils; + +/** + * Created by kerry on 2017/11/23. + */ +public class TemplateStyleWrapper implements Encoder, Decoder { + @Override + public String encode(Object v) { + if (v == null) { + return StringUtils.EMPTY; + } + return v.toString(); + } + + @Override + public Object decode(String txt) { + return null; + } + + @Override + public void validate(String txt) throws ValidationException { + + } +} diff --git a/designer_base/src/com/fr/design/widget/WidgetBoundsPaneFactory.java b/designer_base/src/com/fr/design/widget/WidgetBoundsPaneFactory.java index 8092fc5e8..2d0fe314b 100644 --- a/designer_base/src/com/fr/design/widget/WidgetBoundsPaneFactory.java +++ b/designer_base/src/com/fr/design/widget/WidgetBoundsPaneFactory.java @@ -9,8 +9,11 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.general.Inter; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; /** * Created by plough on 2017/8/7. @@ -69,4 +72,21 @@ public class WidgetBoundsPaneFactory { boundsPane.add(centerPanel, BorderLayout.CENTER); return new UIExpandablePane(Inter.getLocText("FR-Designer_Coords_And_Size"), 230, 24, boundsPane); } + + + public static UIExpandablePane createCardTagBoundPane(UISpinner width) { + JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Inter.getLocText("FR-Designer-Widget_Size")), width}, + }; + double[] rowSize = {p}; + double[] columnSize = {p, f}; + int[][] rowCount = {{1, 1}}; + final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L6); + panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); + boundsPane.add(panel); + return new UIExpandablePane(Inter.getLocText("FR-Designer_Coords_And_Size"), 280, 24, boundsPane); + } } diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java index a819090ff..7ebc87202 100644 --- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java @@ -4,6 +4,7 @@ import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; +import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; import com.fr.general.ComparatorUtils; import com.fr.design.designer.beans.ConstraintsGroupModel; import com.fr.design.designer.beans.HoverPainter; @@ -35,6 +36,9 @@ public class FRBorderLayoutAdapter extends AbstractLayoutAdapter { * @param creator 组件 */ public void fix(XCreator creator) { + if(creator.acceptType(XWCardTagLayout.class)){ + creator = (XCreator) creator.getParent(); + } FRBorderLayout layout = (FRBorderLayout)container.getFRLayout(); Object constraints = layout.getConstraints(creator); if (ComparatorUtils.equals(constraints, BorderLayout.NORTH)) { diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java index c29304292..f818c1ee1 100644 --- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java @@ -13,6 +13,7 @@ import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; +import com.fr.design.designer.creator.cardlayout.XWCardTitleLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.properties.FRFitLayoutConstraints; import com.fr.design.designer.properties.FRFitLayoutPropertiesGroupModel; @@ -20,10 +21,13 @@ import com.fr.design.utils.ComponentUtils; import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WLayout; +import com.fr.form.ui.container.WTabDisplayPosition; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.general.ComparatorUtils; -import java.awt.*; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; @@ -281,9 +285,22 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { backupBound.y -= rec.y; XWCardLayout cardLayout = mainLayout.getCardPart(); LayoutBorderStyle style = cardLayout.toData().getBorderStyle(); + XWCardTitleLayout xwCardTitleLayout = mainLayout.getTitlePart(); + Dimension titleDimension = xwCardTitleLayout.getSize(); + // 当tab布局为标题样式时,才需要处理标题栏高度产生的影响 if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { - backupBound.y -= WCardMainBorderLayout.TAB_HEIGHT; + WTabDisplayPosition wTabDisplayPosition = xwCardTitleLayout.getDisplayPosition(); + switch (wTabDisplayPosition){ + case TOP_POSITION: + backupBound.y -= titleDimension.height; + break; + case LEFT_POSITION: + backupBound.x -= titleDimension.width; + break; + default: + return backupBound; + } } return backupBound; } diff --git a/designer_form/src/com/fr/design/designer/beans/painters/FRBorderLayoutPainter.java b/designer_form/src/com/fr/design/designer/beans/painters/FRBorderLayoutPainter.java index eeac7593f..2fb2f10f2 100644 --- a/designer_form/src/com/fr/design/designer/beans/painters/FRBorderLayoutPainter.java +++ b/designer_form/src/com/fr/design/designer/beans/painters/FRBorderLayoutPainter.java @@ -18,6 +18,9 @@ public class FRBorderLayoutPainter extends AbstractPainter { @Override public void paint(Graphics g, int startX, int startY) { + if(hotspot_bounds == null){ + return; + } super.paint(g, startX, startY); int x = hotspot.x; int y = hotspot.y; diff --git a/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java b/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java index 7a041ef4f..3d289a009 100644 --- a/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java +++ b/designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java @@ -237,6 +237,9 @@ public class XCreatorUtils { Container c = creator.getParent(); while (c != null) { XCreator crea = (XCreator) c; + if(crea.acceptType(XWCardTitleLayout.class)){ + return (XLayoutContainer) c.getParent(); + } if (crea.isDedicateContainer()) { return (XLayoutContainer) c.getParent(); } diff --git a/designer_form/src/com/fr/design/designer/creator/XWHorizontalBoxLayout.java b/designer_form/src/com/fr/design/designer/creator/XWHorizontalBoxLayout.java index 5844c9abd..215f11325 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWHorizontalBoxLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/XWHorizontalBoxLayout.java @@ -8,8 +8,7 @@ import java.awt.Dimension; import java.awt.event.ContainerEvent; import com.fr.design.designer.beans.LayoutAdapter; -import com.fr.design.designer.beans.adapters.layout.FRHorizontalLayoutAdapter; -import com.fr.design.designer.beans.location.Direction; +import com.fr.design.form.layout.FRFlowLayout; import com.fr.design.form.layout.FRHorizontalLayout; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WHorizontalBoxLayout; @@ -20,6 +19,16 @@ import com.fr.form.ui.container.WHorizontalBoxLayout; */ public class XWHorizontalBoxLayout extends XLayoutContainer { + public FRFlowLayout getFrFlowLayout() { + return frFlowLayout; + } + + public void setFrFlowLayout(FRFlowLayout frFlowLayout) { + this.frFlowLayout = frFlowLayout; + } + + private FRFlowLayout frFlowLayout ; + public XWHorizontalBoxLayout(WHorizontalBoxLayout widget, Dimension initSize) { super(widget, initSize); } @@ -46,7 +55,8 @@ public class XWHorizontalBoxLayout extends XLayoutContainer { @Override protected void initLayoutManager() { - this.setLayout(new FRHorizontalLayout(toData().getAlignment(), toData().getHgap(), toData().getVgap())); + this.frFlowLayout = new FRHorizontalLayout(toData().getAlignment(), toData().getHgap(), toData().getVgap()); + this.setLayout(frFlowLayout); } @Override @@ -60,7 +70,7 @@ public class XWHorizontalBoxLayout extends XLayoutContainer { for (int i = 0, count = this.getComponentCount(); i < count; i++) { if (creator == this.getComponent(i)) { wlayout.addWidget(wgt, i); - wlayout.setWidthAtWidget(wgt, creator.getWidth()); + frFlowLayout.componentAdded(e, wlayout); } } this.recalculateChildrenPreferredSize(); @@ -70,7 +80,7 @@ public class XWHorizontalBoxLayout extends XLayoutContainer { protected Dimension calculatePreferredSize(Widget wgt) { // 注意这里计算PreferredSize的时候需要取当前容器的实际大小 // 高度是自适应的,直接就写成0了 - return new Dimension(this.toData().getWidthAtWidget(wgt), 0); + return frFlowLayout.calculatePreferredSize(this.toData(), wgt); } // 在添加的时候需要把可拉伸的方向确定,所以重写了add方法 @@ -80,13 +90,12 @@ public class XWHorizontalBoxLayout extends XLayoutContainer { if (comp == null) { return null; } - XCreator creator = (XCreator) comp; - creator.setDirections(new int[]{Direction.LEFT, Direction.RIGHT}); + frFlowLayout.setDirections(comp); return comp; } @Override public LayoutAdapter getLayoutAdapter() { - return new FRHorizontalLayoutAdapter(this); + return frFlowLayout.getLayoutAdapter(this); } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java index 85e26e877..2de9bbac4 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java @@ -1,6 +1,9 @@ package com.fr.design.designer.creator.cardlayout; -import java.awt.*; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.event.MouseEvent; import javax.swing.Icon; @@ -106,7 +109,7 @@ public class XCardAddButton extends XButton{ FormHierarchyTreePane.getInstance().refreshRoot(); //将焦点切换到新增的tab对应的tabfitLayout上 showNewTab(editingMouseListener,index); - + tagLayout.setTabsAndAdjust(); LayoutUtils.layoutRootContainer(designer.getRootComponent()); } @@ -151,7 +154,6 @@ public class XCardAddButton extends XButton{ titleButton.setCustomStyle(true); titleButton.setShowButton(true); showButton.setBackupParent(tagLayout); - this.tagLayout.setCurrentCard(titleButton); this.tagLayout.setTabFitIndex(index); this.tagLayout.add(showButton); diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java index 04e678029..294ff0ab1 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java @@ -4,13 +4,12 @@ package com.fr.design.designer.creator.cardlayout; import com.fr.base.BaseUtils; -import com.fr.base.GraphHelper; -import com.fr.base.ScreenResolution; import com.fr.base.background.ColorBackground; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.XButton; +import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.ilable.UILabel; @@ -23,17 +22,26 @@ import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.WidgetTitle; +import com.fr.form.ui.container.WTabTextDirection; +import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.general.Background; +import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; import com.fr.general.Inter; -import javax.swing.*; -import java.awt.*; +import javax.swing.Action; +import javax.swing.Icon; +import javax.swing.JOptionPane; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Point; import java.awt.event.MouseEvent; import java.awt.geom.Rectangle2D; -import java.util.HashMap; -import java.util.Map; /** * @@ -65,8 +73,6 @@ public class XCardSwitchButton extends XButton { // tab按钮里的字体因为按钮内部的布局看起来比正常的要小,加个调整量 private static final int FONT_SIZE_ADJUST = 2; - private static final int SIDE_OFFSET = 57; - private XWCardLayout cardLayout; private XWCardTagLayout tagLayout; @@ -118,6 +124,7 @@ public class XCardSwitchButton extends XButton { public XCardSwitchButton(CardSwitchButton widget, Dimension initSize) { super(widget, initSize); + } public XCardSwitchButton(CardSwitchButton widget, Dimension initSize, @@ -180,7 +187,6 @@ public class XCardSwitchButton extends XButton { ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this); editingMouseListener.startEditing(this, adapter.getDesignerEditor(), adapter); } - setTabsAndAdjust(); if(SwingUtilities.isRightMouseButton(e)){ showPopupMenu(editingMouseListener, e, index, maxIndex); } @@ -211,7 +217,7 @@ public class XCardSwitchButton extends XButton { private void deleteCard(XCardSwitchButton button,int index){ String titleName = button.getContentLabel().getText(); int value = JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Designer_ConfirmDialog_Content") + "“" + titleName + "”", - Inter.getLocText("FR-Designer_ConfirmDialog_Title"),JOptionPane.YES_NO_OPTION); + Inter.getLocText("FR-Designer_ConfirmDialog_Title"), JOptionPane.YES_NO_OPTION); if (value != JOptionPane.OK_OPTION) { return; } @@ -296,7 +302,6 @@ public class XCardSwitchButton extends XButton { public void paintComponent(Graphics g) { super.paintComponent(g); - setTabsAndAdjust(); Graphics2D g2d = (Graphics2D) g; drawBackground(); drawTitle(); @@ -334,7 +339,22 @@ public class XCardSwitchButton extends XButton { //画标题 private void drawTitle() { CardSwitchButton button = (CardSwitchButton) this.toData(); - this.setButtonText(button.getText()); + String titleText = button.getText(); + if(tagLayout != null){ + WCardTagLayout wCardTagLayout = (WCardTagLayout) tagLayout.toData(); + StringBuilder titleString = new StringBuilder(); + //竖向处理 + if(ComparatorUtils.equals(wCardTagLayout.getTextDirection(), WTabTextDirection.TEXT_VER_DIRECTION)){ + titleString.append(""); + for(int i = 0; i < titleText.length(); i++){ + titleString.append(titleText.charAt(i)).append("
"); + } + titleString.append(""); + titleText = titleString.toString(); + } + } + + this.setButtonText(titleText); if (this.cardLayout == null) { initRelateLayout(this); } @@ -383,64 +403,37 @@ public class XCardSwitchButton extends XButton { public XLayoutContainer getTopLayout() { return this.getBackupParent().getTopLayout(); } - - public void setTabsAndAdjust() { - if (this.tagLayout == null) { - return; - } - int tabLength = this.tagLayout.getComponentCount(); - Map cardWidth = new HashMap<>(); - Map cardHeight = new HashMap<>(); - for (int i = 0; i < tabLength; i++) { - XCardSwitchButton temp = (XCardSwitchButton) this.tagLayout.getComponent(i); - CardSwitchButton tempCard = (CardSwitchButton) temp.toData(); - String tempText = tempCard.getText(); - Font f = tempCard.getFont(); - FontMetrics fm = GraphHelper.getFontMetrics(f); - cardWidth.put(i,fm.stringWidth(tempText)); - cardHeight.put(i,fm.getHeight()); - } - adjustTabs(tabLength, cardWidth, cardHeight); - } - - public void adjustTabs(int tabLength, Map width, Map height) { - if (width == null) { - return; - } - int tempX = 0; - for (int i = 0; i < tabLength; i++) { - Rectangle rectangle = this.tagLayout.getComponent(i).getBounds(); - Integer cardWidth = width.get(i) + SIDE_OFFSET; - //先用这边的固定高度 - Integer cardHeight = DEFAULT_BUTTON_HEIGHT; - rectangle.setSize(cardWidth, cardHeight); - rectangle.setBounds(tempX, 0, cardWidth, cardHeight); - tempX += cardWidth; - this.tagLayout.getComponent(i).setBounds(rectangle); - Dimension dimension = new Dimension(); - dimension.setSize(cardWidth, cardHeight); - XCardSwitchButton temp = (XCardSwitchButton) this.tagLayout.getComponent(i); - CardSwitchButton cardSwitchButton = (CardSwitchButton) temp.toData(); - FRFont frFont = cardSwitchButton.getFont(); - UILabel label = temp.getContentLabel(); - label.setSize(dimension); - label.setFont(frFont.applyResolutionNP(ScreenResolution.getScreenResolution())); - label.setForeground(frFont.getForeground()); - temp.setContentLabel(label); - temp.setSize(dimension); - temp.setPreferredSize(new Dimension(cardWidth, cardHeight)); - } - } - + + @Override public void doLayout() { super.doLayout(); - setTabsAndAdjust(); } + + /** + * 控件树里需要隐藏xwcardmainLayout,返回其子组件xwcardLayout; + * 标题样式下,this.getComponent(1)==xwcardLayout + * 标准样式下,this.getComponent(0)==xwcardLayout + * @return 子组件xwcardLayout + */ + @Override + public XCreator getXCreator() { + //根据index获取对应的tabFitLayout + int index = ((CardSwitchButton) this.toData()).getIndex(); + return (XCreator) cardLayout.getComponent(index); + } + + @Override protected void initXCreatorProperties() { super.initXCreatorProperties(); label = this.getContentLabel(); } + + public void firePropertyChange() { + super.firePropertyChange(); + tagLayout.setTabsAndAdjust(); + repaint(); + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java index 4c54efd4a..6beadc292 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java @@ -8,7 +8,11 @@ import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRCardLayoutAdapter; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.models.SelectionModel; -import com.fr.design.designer.creator.*; +import com.fr.design.designer.creator.CRPropertyDescriptor; +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.XWidgetCreator; import com.fr.design.form.layout.FRCardLayout; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.mainframe.FormDesigner; @@ -16,7 +20,11 @@ import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.widget.editors.BooleanEditor; import com.fr.design.mainframe.widget.editors.CardTagWLayoutBorderStyleEditor; import com.fr.design.mainframe.widget.editors.DoubleEditor; -import com.fr.form.ui.*; +import com.fr.form.ui.CardAddButton; +import com.fr.form.ui.CardSwitchButton; +import com.fr.form.ui.LayoutBorderStyle; +import com.fr.form.ui.Widget; +import com.fr.form.ui.WidgetTitle; import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WLayout; @@ -30,7 +38,9 @@ import com.fr.stable.Constants; import com.fr.stable.core.PropertyChangeAdapter; import javax.swing.border.Border; -import java.awt.*; +import java.awt.CardLayout; +import java.awt.Color; +import java.awt.Dimension; import java.awt.event.ContainerEvent; import java.beans.IntrospectionException; @@ -67,7 +77,7 @@ public class XWCardLayout extends XLayoutContainer { * */ public String createDefaultName() { - return "tabpane"; + return "cardlayout"; } /** @@ -146,10 +156,12 @@ public class XWCardLayout extends XLayoutContainer { //主结构是一个borderlayout, 标签部分是north, card部分为center WCardMainBorderLayout border = new WCardMainBorderLayout(); XWCardMainBorderLayout xMainBorder = new XWCardMainBorderLayout(border, dimension); + //将子WCardBorder的style设置到父容器上 + LayoutBorderStyle style = (this.toData()).getBorderStyle(); + border.setBorderStyle(style); this.setBackupParent(xMainBorder); - XWCardTitleLayout titlePart = this.initTitlePart(widgetName, xMainBorder); - xMainBorder.addTitlePart(titlePart); + xMainBorder.addTitlePart(titlePart, WBorderLayout.NORTH); return xMainBorder; } @@ -188,7 +200,7 @@ public class XWCardLayout extends XLayoutContainer { private XWCardTagLayout initTagPart(String widgetName, XWCardTitleLayout xTitle){ Dimension dimension = new Dimension(); //放置标题的tab流式布局 - WCardTagLayout tagLayout = new WCardTagLayout(); + WCardTagLayout tagLayout = new WCardTagLayout("tabpane" + widgetName.replaceAll(createDefaultName(), "")); XWCardTagLayout xTag = new XWCardTagLayout(tagLayout, dimension, this); xTag.setBackupParent(xTitle); diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java index 57a519080..70ed5984d 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java @@ -1,5 +1,5 @@ /** - * + * */ package com.fr.design.designer.creator.cardlayout; @@ -15,25 +15,31 @@ import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WBorderLayout; +import com.fr.form.ui.container.WTabDisplayPosition; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.general.IOUtils; -import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.general.Inter; - -import java.awt.*; +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Component; +import java.awt.Composite; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.util.ArrayList; /** * card布局主体框架 - * + * * * * @date: 2014-12-9-下午9:59:31 */ public class XWCardMainBorderLayout extends XWBorderLayout{ - + private static final int CENTER = 1; private static final int NORTH = 0; public static final Color DEFAULT_BORDER_COLOR = new Color(210,210,210); @@ -43,7 +49,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ private static final int EDIT_BTN_WIDTH = 60; private static final int EDIT_BTN_HEIGHT = 24; - + /** * 构造函数 */ @@ -53,38 +59,54 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ /** * 获取当前组件里的控件 - * + * * @return 控件 - * + * * * @date 2014-12-10-下午1:46:33 - * + * */ public WCardMainBorderLayout toData() { return (WCardMainBorderLayout) super.toData(); } - + /** * 添加标题区域 - * + * * @param title 标题区域 - * + * * * @date 2014-12-10-下午1:50:56 - * + * */ - public void addTitlePart(XWCardTitleLayout title){ - this.add(title, WBorderLayout.NORTH); + public void addTitlePart(XWCardTitleLayout title, String position){ + toData().setTabPosition(position); + this.add(title, position); } - + + public void add(Component comp, String position) { + super.add(comp, position); + } + + /** + * 切换到非添加状态 + * + * @return designer 表单设计器 + */ + public void stopAddingState(FormDesigner designer){ + designer.stopAddingState(); + return; + } + + /** * 添加card区域 - * + * * @param card card区域 - * + * * * @date 2014-12-10-下午1:50:37 - * + * */ public void addCardPart(XWCardLayout card){ this.add(card, WBorderLayout.CENTER); @@ -93,11 +115,17 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ public XWCardLayout getCardPart(){ return this.getComponentCount() == TITLE_STYLE ? (XWCardLayout)this.getComponent(CENTER) : (XWCardLayout)this.getComponent(NORTH); } - + public XWCardTitleLayout getTitlePart(){ + Component[] components = this.getComponents(); + for(Component component : components){ + if(component instanceof XWCardTitleLayout){ + return (XWCardTitleLayout)component; + } + } return (XWCardTitleLayout)this.getComponent(NORTH); } - + /** * 控件树里需要隐藏xwcardmainLayout,返回其子组件xwcardLayout; * 标题样式下,this.getComponent(1)==xwcardLayout @@ -106,15 +134,9 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ */ @Override public XCreator getXCreator() { - switch(this.getComponentCount()){ - case TITLE_STYLE: - return (XCreator)this.getComponent(TITLE_STYLE-1); - case NORMAL_STYLE: - return (XCreator)this.getComponent(NORMAL_STYLE-1); - default: - return this; - } + return this; } + /** * 控件树不显示此组件 * @param path 控件树list @@ -122,7 +144,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ public void notShowInComponentTree(ArrayList path) { path.remove(LAYOUT_INDEX); } - + @Override public ArrayList getTargetChildrenList() { ArrayList tabLayoutList = new ArrayList(); @@ -133,7 +155,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ } return tabLayoutList; } - + /** * 重新调整子组件的宽度 * @param width 宽度 @@ -164,7 +186,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ } } } - + /** * 重新调整子组件的高度 * @param height 高度 @@ -198,7 +220,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ tabLayout.adjustCreatorsHeight(percent); } } - + } public void paint(Graphics g) { @@ -275,4 +297,35 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ return this; } } + + /** + * data属性改变触发其他操作 + * + */ + public void firePropertyChange(){ + getCardPart().initStyle(); + } + + + public void resetTabDisplayPosition(WTabDisplayPosition wTabDisplayPosition){ + XWCardTitleLayout xwCardTitleLayout = getTitlePart(); + xwCardTitleLayout.resetNewBtnPosition(wTabDisplayPosition); + switch (wTabDisplayPosition){ + case TOP_POSITION: + this.addTitlePart(getTitlePart(),WBorderLayout.NORTH); + break; + case LEFT_POSITION: + this.addTitlePart(getTitlePart(),WBorderLayout.WEST); + break; + case BOTTOM_POSITION: + this.addTitlePart(getTitlePart(),WBorderLayout.SOUTH); + break; + case RIGHT_POSITION: + this.addTitlePart(getTitlePart(),WBorderLayout.EAST); + break; + default: + break; + } + this.addCardPart((XWCardLayout)this.getComponent(0)); + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java index 114ce3240..b91953e11 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java @@ -3,26 +3,47 @@ */ package com.fr.design.designer.creator.cardlayout; +import java.awt.Component; import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Rectangle; import java.awt.event.ContainerEvent; import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; import javax.swing.border.Border; +import com.fr.base.GraphHelper; +import com.fr.base.ScreenResolution; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.ComponentAdapter; +import com.fr.design.designer.beans.LayoutAdapter; +import com.fr.design.designer.beans.adapters.layout.FRHorizontalLayoutAdapter; +import com.fr.design.designer.beans.adapters.layout.FRVerticalLayoutAdapter; import com.fr.design.designer.beans.models.SelectionModel; +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.XWHorizontalBoxLayout; import com.fr.design.designer.creator.XWidgetCreator; +import com.fr.design.form.layout.FRFlowLayout; +import com.fr.design.form.layout.FRHorizontalLayout; +import com.fr.design.form.layout.FRVerticalLayout; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WCardLayout; +import com.fr.form.ui.container.WTabDisplayPosition; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; +import com.fr.general.ComparatorUtils; +import com.fr.general.FRFont; /** * @date: 2014-11-25-下午3:11:14 @@ -39,6 +60,12 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { private int tabFitIndex = 0; private CardSwitchButton currentCard; + private static final int WIDTH_SIDE_OFFSET = 57; + + private static final int HEIGHT_SIDE_OFFSET = 20; + + private static final int DEFAULT_BUTTON_HEIGHT = 40; + public CardSwitchButton getCurrentCard() { return currentCard; } @@ -75,14 +102,14 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { public XWCardTagLayout(WCardTagLayout widget, Dimension initSize) { super(widget, initSize); + initLayoutManager(); } /** * 构造函数 */ public XWCardTagLayout(WCardTagLayout widget, Dimension initSize, XWCardLayout cardLayout) { - super(widget, initSize); - + this(widget, initSize); this.cardLayout = cardLayout; } @@ -109,19 +136,20 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { WTabFitLayout fitLayout = new WTabFitLayout(widgetName, tabFitIndex, currentCard); fitLayout.setTabNameIndex(getTabNameIndex()); XWTabFitLayout tabFitLayout = new XWTabFitLayout(fitLayout, new Dimension()); + tabFitLayout.setxCardSwitchButton((XCardSwitchButton)this.getComponent(0)); tabFitLayout.setBackupParent(cardLayout); cardLayout.add(tabFitLayout, widgetName); this.cardLayout.toData().setShowIndex(index); cardLayout.showCard(); } + private void initCardLayout() { XWCardTitleLayout titleLayout = (XWCardTitleLayout) this.getBackupParent(); XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout) titleLayout.getBackupParent(); this.cardLayout = borderLayout.getCardPart(); } - /** * 将WLayout转换为XLayoutContainer */ @@ -132,6 +160,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { for (int i = 0; i < layout.getWidgetCount(); i++) { Widget wgt = layout.getWidget(i); if (wgt != null) { + initLayoutManager(); XWidgetCreator comp = (XWidgetCreator) XCreatorUtils.createXCreator(wgt, calculatePreferredSize(wgt)); this.add(comp, i); comp.setBackupParent(this); @@ -140,6 +169,10 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { isRefreshing = false; } + public String createDefaultName() { + return "tabpane"; + } + /** * 切换到非添加状态 * @@ -195,15 +228,9 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { FormDesigner designer = editingMouseListener.getDesigner(); SelectionModel selectionModel = editingMouseListener.getSelectionModel(); - XWCardTitleLayout titleLayout = (XWCardTitleLayout) this.getBackupParent(); - if (titleLayout != null) { - XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) titleLayout.getBackupParent(); - if (mainLayout != null) { - XWCardLayout cardLayout = mainLayout.getCardPart(); - selectionModel.setSelectedCreator(cardLayout); - } + if (e.getClickCount() <= 1) { + selectionModel.selectACreatorAtMouseEvent(e); } - if (editingMouseListener.stopEditing()) { if (this != designer.getRootComponent()) { ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this); @@ -212,8 +239,198 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { } } + public int[] getDirections() { + return ((XCreator)getParent()).getDirections(); + } + + public Rectangle getBounds() { + return this.getParent().getBounds(); + } + @Override public XLayoutContainer getTopLayout() { return this.getBackupParent().getTopLayout(); } + + public void notShowInComponentTree(ArrayList path) { + path.remove(0); + } + + + @Override + public void doLayout() { + //设置布局 + super.doLayout(); + } + + @Override + protected void initLayoutManager() { + FRFlowLayout frFlowLayout; + if (isHori()) { + frFlowLayout = new FRHorizontalLayout(((WCardTagLayout)toData()).getAlignment(), toData().getHgap(), toData().getVgap()); + }else{ + frFlowLayout = new FRVerticalLayout(((WCardTagLayout)toData()).getAlignment(), toData().getHgap(), toData().getVgap()); + } + this.setFrFlowLayout(frFlowLayout); + this.setLayout(frFlowLayout); + } + + + @Override + public LayoutAdapter getLayoutAdapter() { + if (isHori()) { + return new FRHorizontalLayoutAdapter(this); + }else{ + return new FRVerticalLayoutAdapter(this); + } + + } + + private boolean isHori(){ + WTabDisplayPosition displayPosition = ((WCardTagLayout)this.toData()).getDisplayPosition(); + if(displayPosition == null){ + displayPosition = WTabDisplayPosition.TOP_POSITION; + } + return ComparatorUtils.equals(displayPosition, WTabDisplayPosition.TOP_POSITION) || ComparatorUtils.equals(displayPosition, WTabDisplayPosition.BOTTOM_POSITION); + } + + + /** + * data属性改变触发其他操作 + * + */ + public void firePropertyChange() { + WCardTagLayout wCardTagLayout = (WCardTagLayout) this.toData(); + ((XWCardMainBorderLayout) getTopLayout()).resetTabDisplayPosition(wCardTagLayout.getDisplayPosition()); + //重置内部组件的大小和位置 + initLayoutManager(); + setTabsAndAdjust(); + repaint(); + } + + + public void setTabsAndAdjust() { + WCardTagLayout wCardTagLayout = (WCardTagLayout)this.toData(); + int tabLength = this.getComponentCount(); + Map cardWidth = new HashMap<>(); + Map cardHeight = new HashMap<>(); + for (int i = 0; i < tabLength; i++) { + XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i); + CardSwitchButton tempCard = (CardSwitchButton) temp.toData(); + String tempText = tempCard.getText(); + Font f = tempCard.getFont(); + FontMetrics fm = GraphHelper.getFontMetrics(f); + + switch (wCardTagLayout.getTextDirection()){ + case TEXT_HORI_DERECTION: + cardWidth.put(i,fm.stringWidth(tempText)); + cardHeight.put(i,fm.getHeight()); + break; + case TEXT_VER_DIRECTION: + int perHeight = fm.getHeight(); + int wordCount = tempText.length(); + if(tempText.length() !=0 ){ + cardWidth.put(i,fm.stringWidth(tempText)/tempText.length()); + }else { + cardWidth.put(i, 0); + } + cardHeight.put(i,(perHeight+3)*wordCount); + break; + default: + break; + } + } + if(isHori()){ + adjustTabsH(tabLength, cardWidth, cardHeight); + }else { + adjustTabsV(tabLength, cardWidth, cardHeight); + } + } + + public void adjustTabsH(int tabLength, Map width, Map height) { + if (width == null) { + return; + } + //调整XWCardTagLayout的高度 + int tempX = 0; + int maxHeight = DEFAULT_BUTTON_HEIGHT; + for (int i = 0; i < tabLength; i++) { + + Rectangle rectangle = this.getComponent(i).getBounds(); + Integer cardWidth = width.get(i) + WIDTH_SIDE_OFFSET; + Integer cardHeight = height.get(i)+ HEIGHT_SIDE_OFFSET ; + if(cardHeight < DEFAULT_BUTTON_HEIGHT){ + cardHeight = DEFAULT_BUTTON_HEIGHT; + } + maxHeight = maxHeight > cardHeight ? maxHeight : cardHeight ; + rectangle.setBounds(tempX, 0, cardWidth, cardHeight); + tempX += cardWidth; + XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i); + setTabBtnSize(cardWidth, cardHeight, temp); + } + + FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + XLayoutContainer parent = this.getBackupParent(); + Rectangle parentBounds = new Rectangle(parent.getBounds()); + parentBounds.height = maxHeight; + parent.setBounds(parentBounds); + LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(formDesigner, parent); + if (layoutAdapter != null) { + parent.setBackupBound(parent.getBounds()); + layoutAdapter.fix(parent); + } + } + + public void setTabBtnSize(int cardWidth, int cardHeight, XCardSwitchButton temp){ + Dimension dimension = new Dimension(); + dimension.setSize(cardWidth, cardHeight); + CardSwitchButton cardSwitchButton = (CardSwitchButton) temp.toData(); + FRFont frFont = cardSwitchButton.getFont(); + UILabel label = temp.getContentLabel(); + label.setSize(dimension); + label.setFont(frFont.applyResolutionNP(ScreenResolution.getScreenResolution())); + label.setForeground(frFont.getForeground()); + temp.setContentLabel(label); + temp.setSize(dimension); + temp.setPreferredSize(new Dimension(cardWidth, cardHeight)); + } + + + public void adjustTabsV(int tabLength, Map width, Map height) { + if (width == null) { + return; + } + int tempY = 0; + int maxWidth = DEFAULT_BUTTON_HEIGHT; + for (int i = 0; i < tabLength; i++) { + Rectangle rectangle = this.getComponent(i).getBounds(); + Integer cardWidth = width.get(i) + WIDTH_SIDE_OFFSET; + maxWidth = maxWidth > cardWidth ? maxWidth : cardWidth; + //先用这边的固定高度 + Integer cardHeight = height.get(i) + HEIGHT_SIDE_OFFSET; + + if(cardWidth < DEFAULT_BUTTON_HEIGHT){ + cardWidth = DEFAULT_BUTTON_HEIGHT; + } + if(cardHeight < DEFAULT_BUTTON_HEIGHT){ + cardHeight = DEFAULT_BUTTON_HEIGHT; + } + rectangle.setBounds(0, tempY, cardWidth, cardHeight); + tempY += cardHeight; + XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i); + setTabBtnSize(cardWidth, cardHeight, temp); + } + + FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + XLayoutContainer parent = this.getBackupParent(); + Rectangle parentBounds = new Rectangle(parent.getBounds()); + parentBounds.width = maxWidth; + parent.setBounds(parentBounds); + LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(formDesigner, parent); + if (layoutAdapter != null) { + parent.setBackupBound(parent.getBounds()); + layoutAdapter.fix(parent); + } + } + } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java index 1514ed403..d83501203 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java @@ -11,6 +11,7 @@ import javax.swing.border.Border; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.models.SelectionModel; +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.XWBorderLayout; @@ -19,6 +20,8 @@ import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WBorderLayout; +import com.fr.form.ui.container.WTabDisplayPosition; +import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTitleLayout; /** @@ -43,6 +46,11 @@ public class XWCardTitleLayout extends XWBorderLayout { public XWCardTitleLayout(WCardTitleLayout widget, Dimension initSize) { super(widget, initSize); } + + + public WTabDisplayPosition getDisplayPosition(){ + return ((WCardTagLayout)this.getTagPart().toData()).getDisplayPosition(); + } /** * 将WLayout转换为XLayoutContainer @@ -102,6 +110,29 @@ public class XWCardTitleLayout extends XWBorderLayout { public void addNewButton(XCardAddButton addBtn){ this.add(addBtn, WBorderLayout.EAST); } + + public void resetNewBtnPosition(WTabDisplayPosition wTabDisplayPosition){ + XCardAddButton xCardAddButton = (XCardAddButton) this.getComponent(0); + switch (wTabDisplayPosition){ + case TOP_POSITION: + this.add(xCardAddButton, WBorderLayout.EAST); + break; + case LEFT_POSITION: + this.add(xCardAddButton, WBorderLayout.SOUTH); + break; + case BOTTOM_POSITION: + this.add(xCardAddButton, WBorderLayout.EAST); + break; + case RIGHT_POSITION: + this.add(xCardAddButton, WBorderLayout.SOUTH); + break; + default: + break; + } + //需要重新添加一次保证组件顺序不变(重新初始化CardTagLayout改变内部布局) + XWCardTagLayout xwCardTagLayout = (XWCardTagLayout) this.getComponent(0); + this.addTagPart(xwCardTagLayout); + } /** * 切换到非添加状态 @@ -134,10 +165,8 @@ public class XWCardTitleLayout extends XWBorderLayout { FormDesigner designer = editingMouseListener.getDesigner(); SelectionModel selectionModel = editingMouseListener.getSelectionModel(); - XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) this.getBackupParent(); - if(mainLayout != null){ - XWCardLayout cardLayout = mainLayout.getCardPart(); - selectionModel.setSelectedCreator(cardLayout); + if (e.getClickCount() <= 1) { + selectionModel.selectACreatorAtMouseEvent(e); } if (editingMouseListener.stopEditing()) { @@ -152,4 +181,15 @@ public class XWCardTitleLayout extends XWBorderLayout { public XLayoutContainer getTopLayout() { return this.getBackupParent().getTopLayout(); } + + public String createDefaultName() { + return "tabpane"; + } + + + @Override + public XCreator getXCreator() { + return (XCreator)this.getComponent(1); + } + } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java index 42011c306..415d1637a 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java @@ -1,5 +1,6 @@ package com.fr.design.designer.creator.cardlayout; +import com.fr.base.GraphHelper; import com.fr.base.background.ColorBackground; import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRTabFitLayoutAdapter; @@ -37,6 +38,9 @@ import java.beans.IntrospectionException; public class XWTabFitLayout extends XWFitLayout { private static final int MIN_SIZE = 1; + + private static final int WIDTH_SIDE_OFFSET = 57; + // tab布局在拖拽导致的缩放里(含间隔时),如果拖拽宽高大于组件宽高,会导致调整的时候找不到原来的组件 // 这里先将拖拽之前的宽高先做备份 private static final Color NORMAL_GRAL = new Color(236,236,236); @@ -539,6 +543,15 @@ public class XWTabFitLayout extends XWFitLayout { public void firePropertyChange(){ checkButonType(); + //根据字体长度设置tab宽度 + setCardSwitchBtnSize(); + XWCardLayout cardLayout = (XWCardLayout) this.getBackupParent(); + XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) cardLayout.getBackupParent(); + XWCardTitleLayout titleLayout = mainLayout.getTitlePart(); +// //放置tab按钮的tagLayout + XWCardTagLayout tagLayout = titleLayout.getTagPart(); + tagLayout.setTabsAndAdjust(); + initialBackground = ((WTabFitLayout) data).getInitialBackground(); overBackground = ((WTabFitLayout) data).getOverBackground(); clickBackground = ((WTabFitLayout)data).getClickBackground(); @@ -554,4 +567,14 @@ public class XWTabFitLayout extends XWFitLayout { cardSwitchButton.setClickBackground(clickBackground); } } + + public void setCardSwitchBtnSize(){ + CardSwitchButton cardSwitchButton = (CardSwitchButton) xCardSwitchButton.toData(); + Font f = cardSwitchButton.getFont(); + FontMetrics fm = GraphHelper.getFontMetrics(f); + int width = fm.stringWidth(cardSwitchButton.getText())+ WIDTH_SIDE_OFFSET; + xCardSwitchButton.setPreferredSize(new Dimension(width, xCardSwitchButton.getHeight())); + } + + } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java b/designer_form/src/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java index 27db77a98..8ba77b816 100644 --- a/designer_form/src/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java +++ b/designer_form/src/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java @@ -6,6 +6,7 @@ import java.awt.Dimension; import javax.swing.Icon; import com.fr.design.constants.UIConstants; +import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.gui.ilable.UILabel; import javax.swing.JTree; import javax.swing.tree.DefaultTreeCellRenderer; @@ -23,7 +24,14 @@ public class ComponentTreeCellRenderer extends DefaultTreeCellRenderer { boolean leaf, int row, boolean hasFocus) { super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); if (value instanceof XCreator) { - setText(((XCreator) value).toData().getWidgetName()); + String name = ((XCreator) value).toData().getWidgetName(); + //树节点上不显示此控件 + if(value instanceof XWCardLayout){ + this.setSize(new Dimension(0, 0)); + this.setPreferredSize(new Dimension(0, 0)); + return this; + } + setText(name); Icon icon = XCreatorUtils.getCreatorIcon((XCreator) value); if (icon != null) { setIcon(icon); diff --git a/designer_form/src/com/fr/design/form/layout/FRFlowLayout.java b/designer_form/src/com/fr/design/form/layout/FRFlowLayout.java index 8c048f8d5..b06a6d6eb 100644 --- a/designer_form/src/com/fr/design/form/layout/FRFlowLayout.java +++ b/designer_form/src/com/fr/design/form/layout/FRFlowLayout.java @@ -1,10 +1,16 @@ package com.fr.design.form.layout; +import com.fr.design.designer.beans.LayoutAdapter; +import com.fr.design.designer.creator.XWHorizontalBoxLayout; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WHorizontalBoxLayout; + import java.awt.Component; import java.awt.Container; import java.awt.Dimension; import java.awt.Insets; import java.awt.LayoutManager; +import java.awt.event.ContainerEvent; public abstract class FRFlowLayout implements LayoutManager, FRLayoutManager, java.io.Serializable { @@ -52,6 +58,24 @@ public abstract class FRFlowLayout implements LayoutManager, FRLayoutManager, ja protected abstract void moveComponents(Container target, Insets insets, int total); + public void componentAdded(ContainerEvent e, WHorizontalBoxLayout wlayout){ + + } + + public Dimension calculatePreferredSize(WHorizontalBoxLayout wlayout, Widget widget){ + return new Dimension(); + } + + public void setDirections(Component component){ + + } + + public abstract LayoutAdapter getLayoutAdapter(XWHorizontalBoxLayout xwHorizontalBoxLayout) ; + + public void adjustComponents(Component component){ + + } + @Override public void addLayoutComponent(String name, Component comp) { diff --git a/designer_form/src/com/fr/design/form/layout/FRHorizontalLayout.java b/designer_form/src/com/fr/design/form/layout/FRHorizontalLayout.java index f5795d35d..7f6a24ae1 100644 --- a/designer_form/src/com/fr/design/form/layout/FRHorizontalLayout.java +++ b/designer_form/src/com/fr/design/form/layout/FRHorizontalLayout.java @@ -3,9 +3,20 @@ */ package com.fr.design.form.layout; +import com.fr.design.designer.beans.LayoutAdapter; +import com.fr.design.designer.beans.adapters.layout.FRHorizontalLayoutAdapter; +import com.fr.design.designer.beans.location.Direction; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XWHorizontalBoxLayout; +import com.fr.design.designer.creator.XWidgetCreator; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WHorizontalBoxLayout; + import java.awt.Component; import java.awt.Container; +import java.awt.Dimension; import java.awt.Insets; +import java.awt.event.ContainerEvent; /** * @author richer @@ -70,4 +81,29 @@ public class FRHorizontalLayout extends FRFlowLayout { } return total; } + + public void componentAdded(ContainerEvent e, WHorizontalBoxLayout wlayout){ + XWidgetCreator creator = (XWidgetCreator) e.getChild(); + Widget wgt = creator.toData(); + wlayout.setWidthAtWidget(wgt, creator.getWidth()); + } + + public Dimension calculatePreferredSize(WHorizontalBoxLayout wlayout, Widget widget){ + return new Dimension(wlayout.getWidthAtWidget(widget), 0); + } + + + public void setDirections(Component component){ + XCreator creator = (XCreator) component; + creator.setDirections(new int[]{Direction.LEFT, Direction.RIGHT}); + } + + public LayoutAdapter getLayoutAdapter(XWHorizontalBoxLayout xwHorizontalBoxLayout){ + return new FRHorizontalLayoutAdapter(xwHorizontalBoxLayout); + } + + public void adjustComponents(Component component){ + + } + } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/form/layout/FRVerticalLayout.java b/designer_form/src/com/fr/design/form/layout/FRVerticalLayout.java index 920177381..3783a0e41 100644 --- a/designer_form/src/com/fr/design/form/layout/FRVerticalLayout.java +++ b/designer_form/src/com/fr/design/form/layout/FRVerticalLayout.java @@ -3,9 +3,20 @@ */ package com.fr.design.form.layout; +import com.fr.design.designer.beans.LayoutAdapter; +import com.fr.design.designer.beans.adapters.layout.FRVerticalLayoutAdapter; +import com.fr.design.designer.beans.location.Direction; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XWHorizontalBoxLayout; +import com.fr.design.designer.creator.XWidgetCreator; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WHorizontalBoxLayout; + import java.awt.Component; import java.awt.Container; +import java.awt.Dimension; import java.awt.Insets; +import java.awt.event.ContainerEvent; /** @@ -73,4 +84,27 @@ public class FRVerticalLayout extends FRFlowLayout { } return total; } + + + public void componentAdded(ContainerEvent e, WHorizontalBoxLayout wlayout){ + XWidgetCreator creator = (XWidgetCreator) e.getChild(); + Widget wgt = creator.toData(); + wlayout.setWidthAtWidget(wgt, creator.getHeight()); + } + + public Dimension calculatePreferredSize(WHorizontalBoxLayout wlayout, Widget widget){ + return new Dimension(0, wlayout.getWidthAtWidget(widget)); + } + + + public void setDirections(Component component){ + XCreator creator = (XCreator) component; + creator.setDirections(new int[]{Direction.TOP, Direction.BOTTOM}); + } + + public LayoutAdapter getLayoutAdapter(XWHorizontalBoxLayout xwHorizontalBoxLayout){ + return new FRVerticalLayoutAdapter(xwHorizontalBoxLayout); + } + + } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPane.java b/designer_form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPane.java index a797f84cd..e49416356 100644 --- a/designer_form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPane.java +++ b/designer_form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPane.java @@ -4,19 +4,11 @@ package com.fr.design.gui.xpane; import java.awt.BorderLayout; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JPanel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - import com.fr.base.Utils; -import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; @@ -25,14 +17,9 @@ import com.fr.design.gui.style.FRFontPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.JForm; -import com.fr.design.mainframe.JTemplate; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.form.ui.LayoutBorderStyle; -import com.fr.form.ui.WidgetTitle; -import com.fr.general.FRFont; import com.fr.general.Inter; -import com.fr.stable.Constants; /** * CardTagLayoutBorderPane Pane. @@ -41,7 +28,8 @@ public class CardTagLayoutBorderPane extends LayoutBorderPane { public CardTagLayoutBorderPane(){ initComponents(); } - + + protected UIScrollPane initRightBottomPane(){ this.setFontSizeComboBox(new UIComboBox(FRFontPane.FONT_SIZES)); this.setFontNameComboBox(new UIComboBox(Utils.getAvailableFontFamilyNames4Report())); @@ -90,66 +78,35 @@ public class CardTagLayoutBorderPane extends LayoutBorderPane { JPanel rightPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); defaultPane.add(rightPane, BorderLayout.EAST); - rightPane.add(initRightBottomPane(), BorderLayout.CENTER); - JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (!jTemplate.isJWorkBook() && ((JForm)jTemplate).isSelectRootPane()){ - //界面上表单主体只有背景和透明度可以设置 - rightPane.add(initBodyRightTopPane(), BorderLayout.NORTH); - } else { - rightPane.add(initRightTopPane(), BorderLayout.NORTH); - } + rightPane.add(initRightTopPane(), BorderLayout.NORTH); } - - + + protected JComponent[] getBorderTypeComp(){ + return new JComponent[]{null, null}; + } + protected JComponent[] getBorderCornerSpinnerComp(){ + return new JComponent[]{null, null}; + } + + protected void switchBorderType(){ + return; + } + public LayoutBorderStyle update() { LayoutBorderStyle style = new LayoutBorderStyle(); - style.setType(this.getBorderTypeCombo().getSelectedIndex()); style.setBorderStyle(this.getBorderStyleCombo().getSelectedIndex()); style.setBorder(this.getCurrentLineCombo().getSelectedLineStyle()); style.setColor(this.getCurrentLineColorPane().getColor()); style.setBackground(this.getBackgroundPane().update()); style.setAlpha((float)(this.getNumberDragPane().updateBean()/this.getMaxNumber())); - - WidgetTitle title = style.getTitle() == null ? new WidgetTitle() : style.getTitle(); - title.setTextObject("title"); - FRFont frFont = title.getFrFont(); - frFont = frFont.applySize((Integer)this.getFontSizeComboBox().getSelectedItem()); - frFont = frFont.applyName(this.getFontNameComboBox().getSelectedItem().toString()); - frFont = frFont.applyForeground(this.getColorSelectPane().getColor()); - frFont = updateItalicBold(frFont); - int line = this.getUnderline().isSelected() ? this.getUnderlineCombo().getSelectedLineStyle() : Constants.LINE_NONE; - frFont = frFont.applyUnderline(line); - title.setFrFont(frFont); - title.setBackground(this.getTitleBackgroundPane().update()); - style.setTitle(title); return style; } + + protected void populateBorderType(){ + return; + } - - protected void populateTitle(){ - WidgetTitle widgetTitle = this.getBorderStyle() == null ? new WidgetTitle() : this.getBorderStyle().getTitle(); - widgetTitle = widgetTitle == null ? new WidgetTitle() : widgetTitle; - populateFont(widgetTitle); - this.getUnderline().addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - paintPreviewPane(); - } - }); - this.getUnderlineCombo().addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - paintPreviewPane(); - } - }); - - this.getTitleBackgroundPane().populateBean(widgetTitle.getBackground()); - this.getTitleBackgroundPane().addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - paintPreviewPane(); - } - }); - paintPreviewPane(); + protected void populateTitle(){ + return; } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/gui/xpane/LayoutBorderPane.java b/designer_form/src/com/fr/design/gui/xpane/LayoutBorderPane.java index 4c7c1d959..aee64ec2b 100644 --- a/designer_form/src/com/fr/design/gui/xpane/LayoutBorderPane.java +++ b/designer_form/src/com/fr/design/gui/xpane/LayoutBorderPane.java @@ -14,7 +14,11 @@ import com.fr.design.dialog.BasicPane; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.formula.TinyFormulaPane; import com.fr.design.gui.frpane.UINumberDragPane; -import com.fr.design.gui.ibutton.*; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ibutton.UIButtonUI; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icontainer.UIScrollPane; @@ -37,15 +41,35 @@ import com.fr.general.FRFont; import com.fr.general.Inter; import com.fr.stable.Constants; -import javax.swing.*; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.ButtonModel; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JToggleButton; import javax.swing.border.Border; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.plaf.basic.BasicToggleButtonUI; -import java.awt.*; -import java.awt.event.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import java.awt.geom.RoundRectangle2D; /** @@ -97,47 +121,47 @@ public class LayoutBorderPane extends BasicPane { private int minNumber = 0; private double maxNumber = 100; private int iconWidth = 32; - + public LayoutBorderStyle getBorderStyle() { - return borderStyle; - } + return borderStyle; + } - public void setBorderStyle(LayoutBorderStyle borderStyle) { - this.borderStyle = borderStyle; - } + public void setBorderStyle(LayoutBorderStyle borderStyle) { + this.borderStyle = borderStyle; + } - public LayoutBorderPreviewPane getLayoutBorderPreviewPane() { - return layoutBorderPreviewPane; - } + public LayoutBorderPreviewPane getLayoutBorderPreviewPane() { + return layoutBorderPreviewPane; + } - public void setLayoutBorderPreviewPane( - LayoutBorderPreviewPane layoutBorderPreviewPane) { - this.layoutBorderPreviewPane = layoutBorderPreviewPane; - } + public void setLayoutBorderPreviewPane( + LayoutBorderPreviewPane layoutBorderPreviewPane) { + this.layoutBorderPreviewPane = layoutBorderPreviewPane; + } - public UIComboBox getBorderTypeCombo() { - return borderTypeCombo; - } + public UIComboBox getBorderTypeCombo() { + return borderTypeCombo; + } - public void setBorderTypeCombo(UIComboBox borderTypeCombo) { - this.borderTypeCombo = borderTypeCombo; - } + public void setBorderTypeCombo(UIComboBox borderTypeCombo) { + this.borderTypeCombo = borderTypeCombo; + } - public UIComboBox getBorderStyleCombo() { - return borderStyleCombo; - } + public UIComboBox getBorderStyleCombo() { + return borderStyleCombo; + } - public void setBorderStyleCombo(UIComboBox borderStyleCombo) { - this.borderStyleCombo = borderStyleCombo; - } + public void setBorderStyleCombo(UIComboBox borderStyleCombo) { + this.borderStyleCombo = borderStyleCombo; + } - public LineComboBox getCurrentLineCombo() { - return currentLineCombo; - } + public LineComboBox getCurrentLineCombo() { + return currentLineCombo; + } - public void setCurrentLineCombo(LineComboBox currentLineCombo) { - this.currentLineCombo = currentLineCombo; - } + public void setCurrentLineCombo(LineComboBox currentLineCombo) { + this.currentLineCombo = currentLineCombo; + } public UISpinner getBorderCornerSpinner() { @@ -150,162 +174,162 @@ public class LayoutBorderPane extends BasicPane { public UIColorButton getCurrentLineColorPane() { - return currentLineColorPane; - } + return currentLineColorPane; + } - public void setCurrentLineColorPane(UIColorButton currentLineColorPane) { - this.currentLineColorPane = currentLineColorPane; - } + public void setCurrentLineColorPane(UIColorButton currentLineColorPane) { + this.currentLineColorPane = currentLineColorPane; + } - public BackgroundSpecialPane getBackgroundPane() { - return backgroundPane; - } + public BackgroundSpecialPane getBackgroundPane() { + return backgroundPane; + } - public void setBackgroundPane(BackgroundSpecialPane backgroundPane) { - this.backgroundPane = backgroundPane; - } + public void setBackgroundPane(BackgroundSpecialPane backgroundPane) { + this.backgroundPane = backgroundPane; + } - public UINumberDragPane getNumberDragPane() { - return numberDragPane; - } + public UINumberDragPane getNumberDragPane() { + return numberDragPane; + } - public void setNumberDragPane(UINumberDragPane numberDragPane) { - this.numberDragPane = numberDragPane; - } + public void setNumberDragPane(UINumberDragPane numberDragPane) { + this.numberDragPane = numberDragPane; + } - public TinyFormulaPane getFormulaPane() { - return formulaPane; - } + public TinyFormulaPane getFormulaPane() { + return formulaPane; + } - public void setFormulaPane(TinyFormulaPane formulaPane) { - this.formulaPane = formulaPane; - } + public void setFormulaPane(TinyFormulaPane formulaPane) { + this.formulaPane = formulaPane; + } - public UIComboBox getFontNameComboBox() { - return fontNameComboBox; - } + public UIComboBox getFontNameComboBox() { + return fontNameComboBox; + } - public void setFontNameComboBox(UIComboBox fontNameComboBox) { - this.fontNameComboBox = fontNameComboBox; - } + public void setFontNameComboBox(UIComboBox fontNameComboBox) { + this.fontNameComboBox = fontNameComboBox; + } - public UIComboBox getFontSizeComboBox() { - return fontSizeComboBox; - } + public UIComboBox getFontSizeComboBox() { + return fontSizeComboBox; + } - public void setFontSizeComboBox(UIComboBox fontSizeComboBox) { - this.fontSizeComboBox = fontSizeComboBox; - } + public void setFontSizeComboBox(UIComboBox fontSizeComboBox) { + this.fontSizeComboBox = fontSizeComboBox; + } - public UIColorButton getColorSelectPane() { - return colorSelectPane; - } + public UIColorButton getColorSelectPane() { + return colorSelectPane; + } - public void setColorSelectPane(UIColorButton colorSelectPane) { - this.colorSelectPane = colorSelectPane; - } + public void setColorSelectPane(UIColorButton colorSelectPane) { + this.colorSelectPane = colorSelectPane; + } - public UIToggleButton getBold() { - return bold; - } + public UIToggleButton getBold() { + return bold; + } - public void setBold(UIToggleButton bold) { - this.bold = bold; - } + public void setBold(UIToggleButton bold) { + this.bold = bold; + } - public UIToggleButton getItalic() { - return italic; - } + public UIToggleButton getItalic() { + return italic; + } - public void setItalic(UIToggleButton italic) { - this.italic = italic; - } + public void setItalic(UIToggleButton italic) { + this.italic = italic; + } - public UIToggleButton getUnderline() { - return underline; - } + public UIToggleButton getUnderline() { + return underline; + } - public void setUnderline(UIToggleButton underline) { - this.underline = underline; - } + public void setUnderline(UIToggleButton underline) { + this.underline = underline; + } - public LineComboBox getUnderlineCombo() { - return underlineCombo; - } + public LineComboBox getUnderlineCombo() { + return underlineCombo; + } - public void setUnderlineCombo(LineComboBox underlineCombo) { - this.underlineCombo = underlineCombo; - } + public void setUnderlineCombo(LineComboBox underlineCombo) { + this.underlineCombo = underlineCombo; + } - public UIButtonGroup gethAlignmentPane() { - return hAlignmentPane; - } + public UIButtonGroup gethAlignmentPane() { + return hAlignmentPane; + } - public void sethAlignmentPane(UIButtonGroup hAlignmentPane) { - this.hAlignmentPane = hAlignmentPane; - } + public void sethAlignmentPane(UIButtonGroup hAlignmentPane) { + this.hAlignmentPane = hAlignmentPane; + } - public BackgroundNoImagePane getTitleBackgroundPane() { - return titleBackgroundPane; - } + public BackgroundNoImagePane getTitleBackgroundPane() { + return titleBackgroundPane; + } - public void setTitleBackgroundPane(BackgroundNoImagePane titleBackgroundPane) { - this.titleBackgroundPane = titleBackgroundPane; - } + public void setTitleBackgroundPane(BackgroundNoImagePane titleBackgroundPane) { + this.titleBackgroundPane = titleBackgroundPane; + } - public UIScrollPane getTitlePane() { - return titlePane; - } + public UIScrollPane getTitlePane() { + return titlePane; + } - public void setTitlePane(UIScrollPane titlePane) { - this.titlePane = titlePane; - } + public void setTitlePane(UIScrollPane titlePane) { + this.titlePane = titlePane; + } - public int getMinNumber() { - return minNumber; - } + public int getMinNumber() { + return minNumber; + } - public void setMinNumber(int minNumber) { - this.minNumber = minNumber; - } + public void setMinNumber(int minNumber) { + this.minNumber = minNumber; + } - public double getMaxNumber() { - return maxNumber; - } + public double getMaxNumber() { + return maxNumber; + } - public void setMaxNumber(double maxNumber) { - this.maxNumber = maxNumber; - } + public void setMaxNumber(double maxNumber) { + this.maxNumber = maxNumber; + } - public int getIconWidth() { - return iconWidth; - } + public int getIconWidth() { + return iconWidth; + } - public void setIconWidth(int iconWidth) { - this.iconWidth = iconWidth; - } + public void setIconWidth(int iconWidth) { + this.iconWidth = iconWidth; + } - public final static int[] BORDER_LINE_STYLE_ARRAY = new int[]{ + public final static int[] BORDER_LINE_STYLE_ARRAY = new int[]{ Constants.LINE_NONE, Constants.LINE_THIN, //1px Constants.LINE_MEDIUM, //2px Constants.LINE_THICK, //3px - }; + }; public final static String[] BORDER_TYPE = new String[]{Inter.getLocText("FR-Designer-Widget-Style_Standard"), Inter.getLocText("FR-Designer-Widget-Style_Custom")}; public final static String[] BORDER_STYLE= new String[]{Inter.getLocText("FR-Designer-Widget-Style_Common"), Inter.getLocText("FR-Designer-Widget-Style_Shadow")}; private final static Dimension BUTTON_SIZE = new Dimension(24, 20); - + public LayoutBorderPane() { this.initComponents(); } - + protected void initComponents() { - this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); + this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); this.setLayout(FRGUIPaneFactory.createBorderLayout()); - + JPanel defaultPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); this.add(defaultPane, BorderLayout.CENTER); @@ -318,7 +342,7 @@ public class LayoutBorderPane extends BasicPane { borderPane.setBorder(BorderFactory.createEmptyBorder(10, 4, 10, 4)); layoutBorderPreviewPane = new LayoutBorderPreviewPane(borderStyle); - + borderPane.add(layoutBorderPreviewPane, BorderLayout.CENTER); JPanel rightPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); @@ -336,17 +360,7 @@ public class LayoutBorderPane extends BasicPane { } protected UIScrollPane initRightTopPane(){ - this.borderTypeCombo = new UIComboBox(BORDER_TYPE); - this.borderTypeCombo.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if(borderTypeCombo.getSelectedIndex() == 0){ - titlePane.setVisible(false); - } else { - titlePane.setVisible(true); - currentLineCombo.setSelectedItem(Constants.LINE_THIN); - } - } - }); + switchBorderType(); this.borderStyleCombo = new UIComboBox(BORDER_STYLE); this.currentLineCombo = new LineComboBox(BORDER_LINE_STYLE_ARRAY); this.currentLineColorPane = new UIColorButton(null); @@ -366,22 +380,43 @@ public class LayoutBorderPane extends BasicPane { double[] rowSize = {p,p,p,p,p,p,p,p}; double[] columnSize = { p, MAX_WIDTH}; JPanel rightTopContentPane = TableLayoutHelper.createCommonTableLayoutPane(new JComponent[][]{ - {new UILabel(Inter.getLocText("FR-Designer-Widget-Style_Frame_Style")), borderTypeCombo}, + getBorderTypeComp(), {new UILabel(Inter.getLocText("FR-Designer-Widget-Style_Render_Style")), borderStyleCombo}, {new UILabel(Inter.getLocText("FR-Designer-Widget-Style_Border_Line")), currentLineCombo}, {new UILabel(Inter.getLocText("FR-Designer-Widget-Style_Border_Color")), buttonPane}, - {new UILabel(Inter.getLocText("plugin-ChartF_Radius")+":"),borderCornerSpinner}, + getBorderCornerSpinnerComp(), {new UILabel(Inter.getLocText("FR-Designer-Widget-Style_Body_Background")), backgroundPane}, {new UILabel(""),new UILabel(Inter.getLocText("FR-Designer-Widget-Style_Alpha"))}, {new UILabel(""),transparencyPane}, - }, rowSize, columnSize, 10); + }, rowSize, columnSize, 10); rightTopContentPane.setBorder(BorderFactory.createEmptyBorder(15, 12, 10, 12)); UIScrollPane rightTopPane = new UIScrollPane(rightTopContentPane); rightTopPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("FR-Designer-Widget-Style_Frame"),null)); rightTopPane.setPreferredSize(rightTopPane.getPreferredSize()); return rightTopPane; } - + + protected JComponent[] getBorderTypeComp(){ + return new JComponent[]{new UILabel(Inter.getLocText("FR-Designer-Widget-Style_Frame_Style")), borderTypeCombo}; + } + + protected JComponent[] getBorderCornerSpinnerComp(){ + return new JComponent[]{new UILabel(Inter.getLocText("plugin-ChartF_Radius")+":"),borderCornerSpinner}; + } + + protected void switchBorderType(){ + this.borderTypeCombo = new UIComboBox(BORDER_TYPE); + this.borderTypeCombo.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + if(borderTypeCombo.getSelectedIndex() == 0){ + titlePane.setVisible(false); + } else { + titlePane.setVisible(true); + currentLineCombo.setSelectedItem(Constants.LINE_THIN); + } + } + }); + } @@ -452,8 +487,8 @@ public class LayoutBorderPane extends BasicPane { titlePane.setVisible(false); return titlePane; } - - + + protected JPanel initFontButtonPane(){ colorSelectPane = new UIColorButton(); @@ -524,8 +559,8 @@ public class LayoutBorderPane extends BasicPane { title.setPosition((Integer)hAlignmentPane.getSelectedItem()); title.setBackground(titleBackgroundPane.update()); style.setTitle(title); - return style; - } + return style; + } protected FRFont updateItalicBold(FRFont frFont) { int italic_bold = frFont.getStyle(); @@ -547,10 +582,10 @@ public class LayoutBorderPane extends BasicPane { } public void populate(LayoutBorderStyle style) { - if(this.borderStyle == null) { - borderStyle = new LayoutBorderStyle(); - } - this.borderStyle.setStyle(style); + if(this.borderStyle == null) { + borderStyle = new LayoutBorderStyle(); + } + this.borderStyle.setStyle(style); populateBorder(); @@ -558,7 +593,7 @@ public class LayoutBorderPane extends BasicPane { } - protected void populateBorder(){ + protected void populateBorderType(){ this.borderTypeCombo.setSelectedIndex(borderStyle.getType()); this.borderTypeCombo.addItemListener(new ItemListener() { @Override @@ -566,6 +601,10 @@ public class LayoutBorderPane extends BasicPane { paintPreviewPane(); } }); + } + + protected void populateBorder(){ + populateBorderType(); this.borderStyleCombo.setSelectedIndex(borderStyle.getBorderStyle()); this.borderStyleCombo.addItemListener(new ItemListener() { @Override @@ -610,7 +649,7 @@ public class LayoutBorderPane extends BasicPane { populateFourmula(widgetTitle); populateFont(widgetTitle); - + underline.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -631,10 +670,10 @@ public class LayoutBorderPane extends BasicPane { paintPreviewPane(); } }); - - titleBackgroundPane.populateBean(widgetTitle.getBackground()); + + titleBackgroundPane.populateBean(widgetTitle.getBackground()); this.titleBackgroundPane.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { @@ -716,27 +755,27 @@ public class LayoutBorderPane extends BasicPane { }; } - - private void populateFourmula(WidgetTitle widgetTitle) { - this.formulaPane.populateBean(widgetTitle.getTextObject().toString()); - this.formulaPane.getUITextField().getDocument() - .addDocumentListener(new DocumentListener() { - @Override - public void insertUpdate(DocumentEvent e) { - paintPreviewPane(); - } - @Override - public void removeUpdate(DocumentEvent e) { - paintPreviewPane(); - } - - @Override - public void changedUpdate(DocumentEvent e) { - paintPreviewPane(); - } - }); - } + private void populateFourmula(WidgetTitle widgetTitle) { + this.formulaPane.populateBean(widgetTitle.getTextObject().toString()); + this.formulaPane.getUITextField().getDocument() + .addDocumentListener(new DocumentListener() { + @Override + public void insertUpdate(DocumentEvent e) { + paintPreviewPane(); + } + + @Override + public void removeUpdate(DocumentEvent e) { + paintPreviewPane(); + } + + @Override + public void changedUpdate(DocumentEvent e) { + paintPreviewPane(); + } + }); + } protected JPanel createVerButtonPane(JToggleButton noBorder, String text) { @@ -747,119 +786,119 @@ public class LayoutBorderPane extends BasicPane { return verPane; } - + protected class VerButtonPane extends JPanel { - - JToggleButton noBorder; - BorderButton normalBorder; - BorderButton RoundedBorder; - ButtonGroup group; - - private VerButtonPane () { - setLayout(new FlowLayout(FlowLayout.CENTER)); - setBorder(BorderFactory.createEmptyBorder(0, 0, 4, 0)); - group = new ButtonGroup(); - noBorder = new BorderButton(NO_BORDERS); - normalBorder = new BorderButton(RIGHTANGLE_BORDERS); - RoundedBorder = new BorderButton(ROUNDED_BORDERS); - group.add(noBorder); - group.add(normalBorder); - group.add(RoundedBorder); - + + JToggleButton noBorder; + BorderButton normalBorder; + BorderButton RoundedBorder; + ButtonGroup group; + + private VerButtonPane () { + setLayout(new FlowLayout(FlowLayout.CENTER)); + setBorder(BorderFactory.createEmptyBorder(0, 0, 4, 0)); + group = new ButtonGroup(); + noBorder = new BorderButton(NO_BORDERS); + normalBorder = new BorderButton(RIGHTANGLE_BORDERS); + RoundedBorder = new BorderButton(ROUNDED_BORDERS); + group.add(noBorder); + group.add(normalBorder); + group.add(RoundedBorder); + // add(createVerButtonPane(noBorder, Inter.getLocText("None"))); // add(createVerButtonPane(normalBorder, Inter.getLocText("Border-Style-Normal"))); // add(createVerButtonPane(RoundedBorder, Inter.getLocText("Border-Style-Radius"))); - } - - public void populate(LayoutBorderStyle style) { - if(style.getBorder() == Constants.LINE_NONE) { - group.setSelected(noBorder.getModel(), true); - } else if(style.getBorderRadius() != NO_RADIUS) { + } + + public void populate(LayoutBorderStyle style) { + if(style.getBorder() == Constants.LINE_NONE) { + group.setSelected(noBorder.getModel(), true); + } else if(style.getBorderRadius() != NO_RADIUS) { group.setSelected(RoundedBorder.getModel(), true); } else { - group.setSelected(normalBorder.getModel(), true); - } - } - } - - private class BorderButton extends JToggleButton { - private BorderButton(int border) { - super(); - this.setIcon(new BorderButtonIcon(border)); - addBorderActionListener(border); - setPreferredSize(new Dimension(32, 32)); - this.setBorder(new UIRoundedBorder(new Color(220, 220, 220), 1, 5)); - this.setRolloverEnabled(true); - } - - @Override - public Border getBorder() { - ButtonModel model = getModel(); - if (this.isSelected()) { - return null; - } - if (isRolloverEnabled() && model.isRollover()) { - return new UIRoundedBorder(new Color(148, 148, 148), 1, 5); - } - return super.getBorder(); - } - - @Override - public void updateUI() { - setUI(new BorderToggleButtonUI()); - } - - private void addBorderActionListener(final int border) { - addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent ae) { - if (border == 0) { - borderStyle.reset(); - } else { - borderStyle.setColor(currentLineColorPane.getColor()); - borderStyle.setBorder(currentLineCombo.getSelectedLineStyle()); - borderStyle.setBorderRadius((int)borderCornerSpinner.getValue()); - } + group.setSelected(normalBorder.getModel(), true); + } + } + } + + private class BorderButton extends JToggleButton { + private BorderButton(int border) { + super(); + this.setIcon(new BorderButtonIcon(border)); + addBorderActionListener(border); + setPreferredSize(new Dimension(32, 32)); + this.setBorder(new UIRoundedBorder(new Color(220, 220, 220), 1, 5)); + this.setRolloverEnabled(true); + } + + @Override + public Border getBorder() { + ButtonModel model = getModel(); + if (this.isSelected()) { + return null; + } + if (isRolloverEnabled() && model.isRollover()) { + return new UIRoundedBorder(new Color(148, 148, 148), 1, 5); + } + return super.getBorder(); + } + + @Override + public void updateUI() { + setUI(new BorderToggleButtonUI()); + } + + private void addBorderActionListener(final int border) { + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + if (border == 0) { + borderStyle.reset(); + } else { + borderStyle.setColor(currentLineColorPane.getColor()); + borderStyle.setBorder(currentLineCombo.getSelectedLineStyle()); + borderStyle.setBorderRadius((int)borderCornerSpinner.getValue()); + } layoutBorderPreviewPane.repaint(); - } - }); - - } - } - - private class BorderToggleButtonUI extends BasicToggleButtonUI { - - @Override - public void paint(Graphics g, JComponent c) { - paintBackground(g, (AbstractButton) c); - super.paint(g, c); - } - - private void paintBackground(Graphics g, AbstractButton b) { - if (b.isContentAreaFilled()) { - Dimension size = b.getSize(); - Background background = new GradientBackground(new Color(247, 247, 247), new Color(228, 228, 228), - GradientBackground.TOP2BOTTOM); - background.paint(g, new RoundRectangle2D.Double(2, 2, size.width - 4, size.height - 4, 5, 5)); - } - } - - private void paintBorder(Graphics g, Color lineColor, int width, int height) { - Graphics2D g2d = (Graphics2D) g; - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.setColor(lineColor); - g2d.drawRoundRect(0, 0, width - 1, height - 1, 5, 5); - g2d.setColor(Color.WHITE); - g2d.drawRoundRect(1, 1, width - 3, height - 3, 5, 5); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - } - - @Override - protected void paintButtonPressed(Graphics g, AbstractButton b) { - Dimension size = b.getSize(); - paintBorder(g, new Color(78,143,203), size.height, size.width); - } - } + } + }); + + } + } + + private class BorderToggleButtonUI extends BasicToggleButtonUI { + + @Override + public void paint(Graphics g, JComponent c) { + paintBackground(g, (AbstractButton) c); + super.paint(g, c); + } + + private void paintBackground(Graphics g, AbstractButton b) { + if (b.isContentAreaFilled()) { + Dimension size = b.getSize(); + Background background = new GradientBackground(new Color(247, 247, 247), new Color(228, 228, 228), + GradientBackground.TOP2BOTTOM); + background.paint(g, new RoundRectangle2D.Double(2, 2, size.width - 4, size.height - 4, 5, 5)); + } + } + + private void paintBorder(Graphics g, Color lineColor, int width, int height) { + Graphics2D g2d = (Graphics2D) g; + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setColor(lineColor); + g2d.drawRoundRect(0, 0, width - 1, height - 1, 5, 5); + g2d.setColor(Color.WHITE); + g2d.drawRoundRect(1, 1, width - 3, height - 3, 5, 5); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); + } + + @Override + protected void paintButtonPressed(Graphics g, AbstractButton b) { + Dimension size = b.getSize(); + paintBorder(g, new Color(78,143,203), size.height, size.width); + } + } // Icon to display in shortcut setting buttons private class BorderButtonIcon implements Icon { @@ -883,13 +922,13 @@ public class LayoutBorderPane extends BasicPane { g.drawRect(3, 3, this.getIconWidth() - 7, this.getIconHeight() - 7); } else if (display == LayoutBorderPane.ROUNDED_BORDERS) { g.setColor(Color.black); - g.drawRoundRect(3, 3, this.getIconWidth() - 7, this.getIconHeight() - 7, 6, 6); + g.drawRoundRect(3, 3, this.getIconWidth() - 7, this.getIconHeight() - 7, 6, 6); } } } - @Override - protected String title4PopupWindow() { - return Inter.getLocText("FR-Designer-Widget_Style"); - } + @Override + protected String title4PopupWindow() { + return Inter.getLocText("FR-Designer-Widget_Style"); + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/mainframe/FormSelection.java b/designer_form/src/com/fr/design/mainframe/FormSelection.java index ff809371c..8f2fc6737 100644 --- a/designer_form/src/com/fr/design/mainframe/FormSelection.java +++ b/designer_form/src/com/fr/design/mainframe/FormSelection.java @@ -8,7 +8,14 @@ import com.fr.base.FRContext; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.location.Direction; -import com.fr.design.designer.creator.*; +import com.fr.design.designer.creator.XComponent; +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.XWAbsoluteLayout; +import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.XWParameterLayout; +import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; import com.fr.form.ui.Widget; import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.LayoutUtils; @@ -224,6 +231,9 @@ public class FormSelection { int size = selection.size(); if (size == 1) { XCreator creator = selection.get(0); + if(creator.acceptType(XWCardTagLayout.class)){ + creator = (XCreator)selection.get(0).getParent(); + } creator.setBounds(rec); if (creator.acceptType(XWParameterLayout.class)) { designer.setParaHeight((int) rec.getHeight()); 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 963caf8a3..841e9c290 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 @@ -10,6 +10,7 @@ import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.XWScaleLayout; import com.fr.design.designer.creator.XWTitleLayout; +import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; import com.fr.design.dialog.AttrScrollPane; import com.fr.design.dialog.BasicScrollPane; import com.fr.design.foldablepane.UIExpandablePane; @@ -22,6 +23,7 @@ import com.fr.design.widget.FormWidgetDefinePaneFactoryBase; import com.fr.design.widget.Operator; import com.fr.design.widget.ui.designer.component.WidgetAbsoluteBoundPane; import com.fr.design.widget.ui.designer.component.WidgetBoundPane; +import com.fr.design.widget.ui.designer.component.WidgetCardTagBoundPane; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WScaleLayout; import com.fr.form.ui.container.WTitleLayout; @@ -73,10 +75,12 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { public WidgetBoundPane createWidgetBoundPane(XCreator xCreator) { XLayoutContainer xLayoutContainer = getParent(xCreator); - if (xLayoutContainer == null || xCreator instanceof XWParameterLayout || xCreator instanceof XWAbsoluteLayout) { + if (xLayoutContainer == null || xCreator.acceptType(XWParameterLayout.class) || xCreator.acceptType(XWAbsoluteLayout.class)) { return null; - } else if (xLayoutContainer instanceof XWAbsoluteLayout) { + } else if (xLayoutContainer.acceptType(XWAbsoluteLayout.class)) { return new WidgetAbsoluteBoundPane(xCreator); + } else if(xCreator.acceptType(XWCardTagLayout.class)){ + return new WidgetCardTagBoundPane(xCreator); } return new WidgetBoundPane(xCreator); } diff --git a/designer_form/src/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java b/designer_form/src/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java index 47efd40fe..0de1e2bda 100644 --- a/designer_form/src/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java +++ b/designer_form/src/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java @@ -12,6 +12,7 @@ import com.fr.form.parameter.FormSubmitButton; import com.fr.form.ui.*; import com.fr.form.ui.container.*; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; +import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.stable.bridge.BridgeMark; import com.fr.stable.bridge.StableFactory; @@ -64,6 +65,7 @@ public class FormWidgetDefinePaneFactoryBase { defineMap.put(WAbsoluteBodyLayout.class, new Appearance(FRAbsoluteBodyLayoutDefinePane.class, "wAbsoluteBodyLayout")); defineMap.put(WParameterLayout.class, new Appearance(RootDesignDefinePane.class, "wParameterLayout")); defineMap.put(WCardMainBorderLayout.class, new Appearance(WCardMainLayoutDefinePane.class, "wCardMainBorderLayout")); + defineMap.put(WCardTagLayout.class, new Appearance(WCardTagLayoutDefinePane.class, "wCardMainBorderLayout")); defineMap.put(WCardLayout.class, new Appearance(WCardLayoutDefinePane.class, "wCardLayout")); defineMap.put(Label.class, new Appearance(LabelDefinePane.class, "label")); defineMap.put(WTabFitLayout.class, new Appearance(WTabFitLayoutDefinePane.class, "wTabFitLayout")); 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 db2f634e9..a046b2d18 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 @@ -8,6 +8,7 @@ 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.designer.creator.cardlayout.XWCardTagLayout; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.FRGUIPaneFactory; @@ -44,6 +45,9 @@ public class WidgetBoundPane extends BasicPane { } public XLayoutContainer getParent(XCreator source) { + if(source.acceptType(XWCardTagLayout.class)){ + return (XLayoutContainer)source.getParent(); + } XLayoutContainer container = XCreatorUtils.getParentXLayoutContainer(source); if (source.acceptType(XWFitLayout.class) || source.acceptType(XWParameterLayout.class)) { container = null; @@ -122,7 +126,6 @@ public class WidgetBoundPane extends BasicPane { difference = bounds.width - w; bounds.width = w; } - width.setValue(bounds.width); wabs.setBounds(creator.toData(), bounds); adjustComponents(bounds, difference, 0); } @@ -144,7 +147,6 @@ public class WidgetBoundPane extends BasicPane { difference = bounds.height - h; bounds.height = h; } - height.setValue(bounds.height); wabs.setBounds(creator.toData(), bounds); adjustComponents(bounds, difference, 1); } diff --git a/designer_form/src/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java b/designer_form/src/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java new file mode 100644 index 000000000..92fb9b965 --- /dev/null +++ b/designer_form/src/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java @@ -0,0 +1,76 @@ +package com.fr.design.widget.ui.designer.component; + +import com.fr.design.designer.beans.AdapterBus; +import com.fr.design.designer.beans.LayoutAdapter; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.widget.WidgetBoundsPaneFactory; +import com.fr.form.ui.container.WTabDisplayPosition; +import com.fr.form.ui.container.cardlayout.WCardTagLayout; +import com.fr.general.ComparatorUtils; +import com.fr.general.Inter; + +import java.awt.Rectangle; + +/** + * Created by kerry on 2017/12/4. + */ +public class WidgetCardTagBoundPane extends WidgetBoundPane { + private UISpinner cardTagWidth ; + + public WidgetCardTagBoundPane(XCreator source) { + super(source); + } + + @Override + public void initBoundPane() { + cardTagWidth = new UIBoundSpinner(0, Integer.MAX_VALUE, 1); + cardTagWidth.setGlobalName(Inter.getLocText("FR-Designer_Coords_And_Size")); + this.add(WidgetBoundsPaneFactory.createCardTagBoundPane(cardTagWidth)); + } + + @Override + public void update() { + if (parent == null) { + return; + } + FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + Rectangle parentBounds = new Rectangle(parent.getBounds()); + + WCardTagLayout tagLayout = (WCardTagLayout)creator.toData(); + WTabDisplayPosition displayPosition = tagLayout.getDisplayPosition(); + if( ComparatorUtils.equals(displayPosition, WTabDisplayPosition.TOP_POSITION) || ComparatorUtils.equals(displayPosition, WTabDisplayPosition.BOTTOM_POSITION)){ + parentBounds.height = (int)cardTagWidth.getValue(); + }else{ + parentBounds.width = (int)cardTagWidth.getValue(); + } + + parent.setBounds(parentBounds); + LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(formDesigner, parent); + if (layoutAdapter != null) { + parent.setBackupBound(parent.getBounds()); + layoutAdapter.fix(parent); + } + } + + @Override + protected String title4PopupWindow() { + return "absoluteBound"; + } + + @Override + public void populate() { + WCardTagLayout tagLayout = (WCardTagLayout)creator.toData(); + Rectangle bounds = new Rectangle(creator.getBounds()); + WTabDisplayPosition displayPosition = tagLayout.getDisplayPosition(); + if( ComparatorUtils.equals(displayPosition, WTabDisplayPosition.TOP_POSITION) || ComparatorUtils.equals(displayPosition, WTabDisplayPosition.BOTTOM_POSITION)){ + cardTagWidth.setValue(bounds.height); + }else{ + cardTagWidth.setValue(bounds.width); + } + + } + +} diff --git a/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardLayoutDefinePane.java b/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardLayoutDefinePane.java index a1d8347f5..177a184cc 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardLayoutDefinePane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardLayoutDefinePane.java @@ -1,32 +1,15 @@ 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.foldablepane.UIExpandablePane; -import com.fr.design.gui.icheckbox.UICheckBox; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.widget.accessibles.AccessibleCardTagWLayoutBorderStyleEditor; import com.fr.design.widget.ui.designer.AbstractDataModify; -import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.container.WCardLayout; -import com.fr.general.Inter; -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; /** * Created by ibm on 2017/8/7. */ public class WCardLayoutDefinePane extends AbstractDataModify { - private AccessibleCardTagWLayoutBorderStyleEditor accessibleCardTagWLayoutBorderStyleEditor; - private UICheckBox setCarousel; - private UISpinner carouselInterval; - private JPanel IntervalPane; public WCardLayoutDefinePane(XCreator xCreator) { super(xCreator); @@ -35,31 +18,6 @@ public class WCardLayoutDefinePane extends AbstractDataModify { public void initComponent() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); - carouselInterval = new UISpinner(0, 20, 1, 0); - accessibleCardTagWLayoutBorderStyleEditor = new AccessibleCardTagWLayoutBorderStyleEditor(); - JPanel accessibleCardlayout = FRGUIPaneFactory.createBorderLayout_S_Pane(); - JPanel stylePane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ - new Component[]{new UILabel(Inter.getLocText("FR-Designer-Widget_Style")), accessibleCardTagWLayoutBorderStyleEditor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1); - stylePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); - accessibleCardlayout.add(stylePane, BorderLayout.CENTER); - UIExpandablePane advanceExpandablePane = new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), 280, 20, accessibleCardlayout); - final JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - jPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - setCarousel = new UICheckBox(Inter.getLocText("FR-Designer_setCarousel")); - IntervalPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{ - new UILabel(Inter.getLocText("FR-Designer_carouselInterval")), carouselInterval}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); - IntervalPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - jPanel.add(setCarousel, BorderLayout.NORTH); - jPanel.add(IntervalPane, BorderLayout.CENTER); - setCarousel.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - IntervalPane.setVisible(setCarousel.isSelected()); - } - }); - UIExpandablePane setCarouselPane = new UIExpandablePane(Inter.getLocText("FR-Designer_Tab_carousel"), 280, 20, jPanel); - this.add(advanceExpandablePane, BorderLayout.NORTH); - this.add(setCarouselPane, BorderLayout.CENTER); } @Override @@ -69,19 +27,13 @@ public class WCardLayoutDefinePane extends AbstractDataModify { @Override public void populateBean(WCardLayout ob) { - accessibleCardTagWLayoutBorderStyleEditor.setValue(ob.getBorderStyle()); - setCarousel.setSelected(ob.isCarousel()); - IntervalPane.setVisible(ob.isCarousel()); - carouselInterval.setValue(ob.getCarouselInterval()); + } @Override public WCardLayout updateBean() { WCardLayout layout = (WCardLayout) creator.toData(); - layout.setBorderStyle((LayoutBorderStyle) accessibleCardTagWLayoutBorderStyleEditor.getValue()); - layout.setCarousel(setCarousel.isSelected()); - layout.setCarouselInterval((int)carouselInterval.getValue()); return layout; } } diff --git a/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardMainLayoutDefinePane.java b/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardMainLayoutDefinePane.java index 5eae81e3f..ff2b139c2 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardMainLayoutDefinePane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardMainLayoutDefinePane.java @@ -1,39 +1,92 @@ 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.foldablepane.UIExpandablePane; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.widget.accessibles.AccessibleCardTagWLayoutBorderStyleEditor; import com.fr.design.widget.ui.designer.AbstractDataModify; +import com.fr.form.ui.LayoutBorderStyle; +import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; -import java.awt.*; +import com.fr.general.Inter; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; /** * Created by ibm on 2017/8/2. */ public class WCardMainLayoutDefinePane extends AbstractDataModify { + private AccessibleCardTagWLayoutBorderStyleEditor accessibleCardTagWLayoutBorderStyleEditor; + private UICheckBox setCarousel; + private UISpinner carouselInterval; + private JPanel IntervalPane; public WCardMainLayoutDefinePane(XCreator xCreator) { super(xCreator); - this.setPreferredSize(new Dimension(0,0)); + initComponent(); } public void initComponent() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); + carouselInterval = new UISpinner(0, 20, 1, 0); + accessibleCardTagWLayoutBorderStyleEditor = new AccessibleCardTagWLayoutBorderStyleEditor(); + JPanel accessibleCardlayout = FRGUIPaneFactory.createBorderLayout_S_Pane(); + JPanel stylePane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ + new Component[]{new UILabel(Inter.getLocText("FR-Designer-Widget_Style")), accessibleCardTagWLayoutBorderStyleEditor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1); + stylePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); + accessibleCardlayout.add(stylePane, BorderLayout.CENTER); + UIExpandablePane advanceExpandablePane = new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), 280, 20, accessibleCardlayout); + final JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + jPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + setCarousel = new UICheckBox(Inter.getLocText("FR-Designer_setCarousel")); + IntervalPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{ + new UILabel(Inter.getLocText("FR-Designer_carouselInterval")), carouselInterval}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); + IntervalPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel.add(setCarousel, BorderLayout.NORTH); + jPanel.add(IntervalPane, BorderLayout.CENTER); + setCarousel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + IntervalPane.setVisible(setCarousel.isSelected()); + } + }); + UIExpandablePane setCarouselPane = new UIExpandablePane(Inter.getLocText("FR-Designer_Tab_carousel"), 280, 20, jPanel); + this.add(advanceExpandablePane, BorderLayout.NORTH); + this.add(setCarouselPane, BorderLayout.CENTER); } @Override public String title4PopupWindow() { - return "cardMainLayout"; + return "tabFitLayout"; } @Override public void populateBean(WCardMainBorderLayout ob) { - + WCardLayout cardLayout = ob.getCardPart(); + accessibleCardTagWLayoutBorderStyleEditor.setValue(ob.getBorderStyle()); + setCarousel.setSelected(cardLayout.isCarousel()); + IntervalPane.setVisible(ob.isCarousel()); + carouselInterval.setValue(cardLayout.getCarouselInterval()); } @Override public WCardMainBorderLayout updateBean() { - WCardMainBorderLayout layout = (WCardMainBorderLayout)creator.toData(); + WCardMainBorderLayout layout = (WCardMainBorderLayout) creator.toData(); + layout.setBorderStyle((LayoutBorderStyle) accessibleCardTagWLayoutBorderStyleEditor.getValue()); + WCardLayout wCardLayout = layout.getCardPart(); + wCardLayout.setCarousel(setCarousel.isSelected()); + wCardLayout.setCarouselInterval((int)carouselInterval.getValue()); return layout; } } diff --git a/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java b/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java new file mode 100644 index 000000000..517846a2f --- /dev/null +++ b/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java @@ -0,0 +1,114 @@ +package com.fr.design.widget.ui.designer.layout; + +import com.fr.base.TemplateStyle; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; +import com.fr.design.foldablepane.UIExpandablePane; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.style.FRFontPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.widget.accessibles.AccessibleImgBackgroundEditor; +import com.fr.design.mainframe.widget.accessibles.AccessibleTemplateStyleEditor; +import com.fr.design.widget.ui.designer.AbstractDataModify; +import com.fr.form.ui.LayoutBorderStyle; +import com.fr.form.ui.container.WTabDisplayPosition; +import com.fr.form.ui.container.WTabTextDirection; +import com.fr.form.ui.container.cardlayout.WCardTagLayout; +import com.fr.general.Background; +import com.fr.general.FRFont; +import com.fr.general.Inter; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; + +/** + * Created by kerry on 2017/11/16. + */ +public class WCardTagLayoutDefinePane extends AbstractDataModify { + private AccessibleImgBackgroundEditor backgroundEditor; + private FRFontPane frFontPane; + private UIButtonGroup displayPositionGroup; + private UIButtonGroup textDirectionGroup; + private AccessibleTemplateStyleEditor templateStyleEditor; + + public WCardTagLayoutDefinePane(XCreator xCreator) { + super(xCreator); + initComponent(); + } + + public void initComponent() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + + backgroundEditor = new AccessibleImgBackgroundEditor(); + templateStyleEditor = new AccessibleTemplateStyleEditor(); + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p, p, p, p}; + double[] columnSize = {p, f}; + int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; + + UILabel fontLabel = new UILabel(Inter.getLocText("FR-Designer_Font")); + fontLabel.setVerticalAlignment(SwingConstants.TOP); + frFontPane = new FRFontPane(); + displayPositionGroup = new UIButtonGroup(WTabDisplayPosition.getStringArray()); + textDirectionGroup = new UIButtonGroup(WTabTextDirection.getStringArray()); + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Inter.getLocText("FR-Designer_Tab_Style_Template")), templateStyleEditor}, + new Component[]{new UILabel("显示位置"), displayPositionGroup}, + new Component[]{new UILabel("背景"), backgroundEditor}, + new Component[]{fontLabel, frFontPane}, + new Component[]{new UILabel("文本方向"), textDirectionGroup} + }; + JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); + JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); + jPanel.add(panel, BorderLayout.CENTER); + UIExpandablePane advanceExpandablePane = new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), 280, 20, jPanel); + this.add(advanceExpandablePane, BorderLayout.CENTER); + } + + @Override + public String title4PopupWindow() { + return "tabFitLayout"; + } + + @Override + public void populateBean(WCardTagLayout ob) { + //标题背景和字体属性设置在WCardLayout上做兼容 + XLayoutContainer topLayout = creator.getTopLayout(); + LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout)topLayout).getCardPart().toData().getBorderStyle(); + + displayPositionGroup.setSelectedIndex(ob.getDisplayPosition().getType()); + textDirectionGroup.setSelectedIndex(ob.getTextDirection().getType()); + backgroundEditor.setValue(layoutBorderStyle.getTitle().getBackground()); + templateStyleEditor.setValue(ob.getTemplateStyle()); + FRFont frFont = layoutBorderStyle.getTitle().getFrFont(); + if (frFont != null) { + frFontPane.populateBean(frFont); + } + } + + @Override + public WCardTagLayout updateBean() { + //标题背景和字体属性设置在WCardLayout上做兼容 + XLayoutContainer topLayout = creator.getTopLayout(); + LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout)topLayout).getCardPart().toData().getBorderStyle(); + FRFont frFont = layoutBorderStyle.getTitle().getFrFont() == null ? FRFont.getInstance() : layoutBorderStyle.getTitle().getFrFont(); + layoutBorderStyle.getTitle().setBackground((Background) backgroundEditor.getValue()); + layoutBorderStyle.getTitle().setFrFont(frFontPane.update(frFont)); + WCardTagLayout layout = (WCardTagLayout) creator.toData(); + layout.setDisplayPosition(WTabDisplayPosition.parse(displayPositionGroup.getSelectedIndex())); + layout.setTextDirection(WTabTextDirection.parse(textDirectionGroup.getSelectedIndex())); + layout.setTemplateStyle((TemplateStyle) templateStyleEditor.getValue()); + + return layout; + } +} From 368e193b1352312dc9604fe814cffbe2bc2ed3d4 Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 12 Dec 2017 13:52:47 +0800 Subject: [PATCH 2/6] =?UTF-8?q?REPORT-2615=20=E5=A4=9A=E7=A7=8Dtab?= =?UTF-8?q?=E5=B8=83=E5=B1=80=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/locale/designer.properties | 3 ++- .../com/fr/design/locale/designer_en_US.properties | 1 + .../com/fr/design/locale/designer_ja_JP.properties | 3 ++- .../com/fr/design/locale/designer_ko_KR.properties | 3 ++- .../com/fr/design/locale/designer_zh_CN.properties | 3 ++- .../com/fr/design/locale/designer_zh_TW.properties | 3 ++- .../src/com/fr/design/mainframe/FormDesignerUI.java | 11 +++++++---- .../ui/designer/layout/WCardTagLayoutDefinePane.java | 6 +++--- 8 files changed, 21 insertions(+), 12 deletions(-) diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index 1475bb230..32d7aeae9 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -2159,4 +2159,5 @@ FR-Designer_Tab_Template_Two=Template Two FR-Designer_Tab_Template_Three=Template Three FR-Designer_Tab_Template_Four=Template Four FR-Designer_Tab_Template_Five=Template Five -FR-Designer_Tab_Template_Six=Template Six \ No newline at end of file +FR-Designer_Tab_Template_Six=Template Six +FR-Designer_Tab_Display_Position=Display Position \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index f77802a02..3fb8826af 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -2159,3 +2159,4 @@ FR-Designer_Tab_Template_Three=Template Three FR-Designer_Tab_Template_Four=Template Four FR-Designer_Tab_Template_Five=Template Five FR-Designer_Tab_Template_Six=Template Six +FR-Designer_Tab_Display_Position=Display Position \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties index 0dda67fe6..7f5462d23 100644 --- a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties +++ b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties @@ -2159,4 +2159,5 @@ FR-Designer_Tab_Template_Two= FR-Designer_Tab_Template_Three= FR-Designer_Tab_Template_Four= FR-Designer_Tab_Template_Five= -FR-Designer_Tab_Template_Six= \ No newline at end of file +FR-Designer_Tab_Template_Six= +FR-Designer_Tab_Display_Position= \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties index bff3b417f..e6d0c9d57 100644 --- a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties +++ b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties @@ -2159,4 +2159,5 @@ FR-Designer_Tab_Template_Two= FR-Designer_Tab_Template_Three= FR-Designer_Tab_Template_Four= FR-Designer_Tab_Template_Five= -FR-Designer_Tab_Template_Six= \ No newline at end of file +FR-Designer_Tab_Template_Six= +FR-Designer_Tab_Display_Position= \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index aea21175e..7a1252ab6 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -2159,4 +2159,5 @@ FR-Designer_Tab_Template_Two=\u6A21\u677F\u4E8C FR-Designer_Tab_Template_Three=\u6A21\u677F\u4E09 FR-Designer_Tab_Template_Four=\u6A21\u677F\u56DB FR-Designer_Tab_Template_Five=\u6A21\u677F\u4E94 -FR-Designer_Tab_Template_Six=\u6A21\u677F\u516D \ No newline at end of file +FR-Designer_Tab_Template_Six=\u6A21\u677F\u516D +FR-Designer_Tab_Display_Position=\u663E\u793A\u4F4D\u7F6E \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index 863601505..0cf4cf60a 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -2158,4 +2158,5 @@ FR-Designer_Tab_Template_Two=\u6A21\u677F\u4E8C FR-Designer_Tab_Template_Three=\u6A21\u677F\u4E09 FR-Designer_Tab_Template_Four=\u6A21\u677F\u56DB FR-Designer_Tab_Template_Five=\u6A21\u677F\u4E94 -FR-Designer_Tab_Template_Six=\u6A21\u677F\u516D \ No newline at end of file +FR-Designer_Tab_Template_Six=\u6A21\u677F\u516D +FR-Designer_Tab_Display_Position=\u986F\u793A\u4F4D\u7F6E \ No newline at end of file diff --git a/designer_form/src/com/fr/design/mainframe/FormDesignerUI.java b/designer_form/src/com/fr/design/mainframe/FormDesignerUI.java index dfbcfbb2f..c74ab8122 100644 --- a/designer_form/src/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer_form/src/com/fr/design/mainframe/FormDesignerUI.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe; import java.awt.AlphaComposite; +import java.awt.Color; import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; @@ -27,6 +28,8 @@ import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; +import com.fr.design.designer.creator.cardlayout.XWCardTitleLayout; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.utils.ComponentUtils; @@ -93,7 +96,7 @@ public class FormDesignerUI extends ComponentUI { if (hotspot_bounds != null) { // 当前区域选择框 - g.setColor(XCreatorConstants.SELECTION_COLOR); + g.setColor(new Color(254, 0, 0)); g.drawRect(hotspot_bounds.x - designer.getArea().getHorizontalValue(), hotspot_bounds.y - designer.getArea().getVerticalValue(), hotspot_bounds.width, hotspot_bounds.height); } @@ -266,7 +269,7 @@ public class FormDesignerUI extends ComponentUI { bounds.y -= designer.getArea().getVerticalValue(); drawResizingThumbs(g, selectionModel.getSelection().getDirections(), bounds.x, bounds.y, bounds.width, bounds.height); - g.setColor(XCreatorConstants.FORM_BORDER_COLOR); + g.setColor(new Color(254, 0, 0)); for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) { Rectangle creatorBounds = ComponentUtils.getRelativeBounds(creator); @@ -360,9 +363,9 @@ public class FormDesignerUI extends ComponentUI { * 画每一个小拖拽框 */ private void drawBox(Graphics g, int x, int y) { - g.setColor(XCreatorConstants.RESIZE_BOX_INNER_COLOR); + g.setColor(new Color(254, 0, 0)); g.fillRect(x, y, XCreatorConstants.RESIZE_BOX_SIZ, XCreatorConstants.RESIZE_BOX_SIZ); - g.setColor(XCreatorConstants.RESIZE_BOX_BORDER_COLOR); + g.setColor(new Color(254, 0, 0)); g.drawRect(x, y, XCreatorConstants.RESIZE_BOX_SIZ, XCreatorConstants.RESIZE_BOX_SIZ); } diff --git a/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java b/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java index 517846a2f..3e6dcb0ca 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java @@ -62,10 +62,10 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify textDirectionGroup = new UIButtonGroup(WTabTextDirection.getStringArray()); Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("FR-Designer_Tab_Style_Template")), templateStyleEditor}, - new Component[]{new UILabel("显示位置"), displayPositionGroup}, - new Component[]{new UILabel("背景"), backgroundEditor}, + new Component[]{new UILabel(Inter.getLocText("FR-Designer_Tab_Display_Position")), displayPositionGroup}, + new Component[]{new UILabel(Inter.getLocText("FR-Designer_Background")), backgroundEditor}, new Component[]{fontLabel, frFontPane}, - new Component[]{new UILabel("文本方向"), textDirectionGroup} + new Component[]{new UILabel(Inter.getLocText("FR-Designer_StyleAlignment_Text_Rotation")), textDirectionGroup} }; JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); From d305ac47b29aa166904c6a31ae81bc0361df2058 Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 12 Dec 2017 13:57:16 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=A4=9A=E6=8F=90=E4=BA=A4=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/FormDesignerUI.java | 65 +++++++++---------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormDesignerUI.java b/designer_form/src/com/fr/design/mainframe/FormDesignerUI.java index c74ab8122..8a40928c3 100644 --- a/designer_form/src/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer_form/src/com/fr/design/mainframe/FormDesignerUI.java @@ -1,7 +1,6 @@ package com.fr.design.mainframe; import java.awt.AlphaComposite; -import java.awt.Color; import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; @@ -28,8 +27,6 @@ import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWFitLayout; -import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; -import com.fr.design.designer.creator.cardlayout.XWCardTitleLayout; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.utils.ComponentUtils; @@ -96,7 +93,7 @@ public class FormDesignerUI extends ComponentUI { if (hotspot_bounds != null) { // 当前区域选择框 - g.setColor(new Color(254, 0, 0)); + g.setColor(XCreatorConstants.SELECTION_COLOR); g.drawRect(hotspot_bounds.x - designer.getArea().getHorizontalValue(), hotspot_bounds.y - designer.getArea().getVerticalValue(), hotspot_bounds.width, hotspot_bounds.height); } @@ -222,7 +219,7 @@ public class FormDesignerUI extends ComponentUI { if (subCreator instanceof XLayoutContainer) { paintAuthorityDetails(g, subCreator); } else { - if (subCreator.toData().isDirtyWidget(selectedRoles)) { + if (subCreator.toData().isDirtyWidget(selectedRoles)) { Rectangle creatorBounds = ComponentUtils.getRelativeBounds(subCreator); creatorBounds.x -= designer.getArea().getHorizontalValue(); creatorBounds.y -= designer.getArea().getVerticalValue(); @@ -269,50 +266,50 @@ public class FormDesignerUI extends ComponentUI { bounds.y -= designer.getArea().getVerticalValue(); drawResizingThumbs(g, selectionModel.getSelection().getDirections(), bounds.x, bounds.y, bounds.width, bounds.height); - g.setColor(new Color(254, 0, 0)); + g.setColor(XCreatorConstants.FORM_BORDER_COLOR); for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) { Rectangle creatorBounds = ComponentUtils.getRelativeBounds(creator); creatorBounds.x -= designer.getArea().getHorizontalValue(); creatorBounds.y -= designer.getArea().getVerticalValue(); if (creator.acceptType(XWFitLayout.class)) { - resetFitlayoutBounds(creatorBounds); + resetFitlayoutBounds(creatorBounds); } else if (designer.getRootComponent().acceptType(XWFitLayout.class)) { - resetCreatorBounds(creatorBounds); + resetCreatorBounds(creatorBounds); } GraphHelper.draw(g, creatorBounds, Constants.LINE_MEDIUM); } } - + /** * 初始为自适应时,处理选中的范围 * @param bound */ private void resetFitlayoutBounds( Rectangle bound) { - bound.x ++; - bound.width -= 2; - bound.y ++; - bound.height -= 2; + bound.x ++; + bound.width -= 2; + bound.y ++; + bound.height -= 2; } - + private void resetCreatorBounds( Rectangle bound) { - Rectangle rec = bound; - if (rec.x == 0) { - bound.x ++; - bound.width --; - } - if (rec.y == 0) { - bound.y ++; - bound.height --; - } - if (rec.x+rec.width == designer.getWidth()) { - bound.width --; - } - if (rec.y+rec.height == designer.getHeight()) { - bound.height --; - } + Rectangle rec = bound; + if (rec.x == 0) { + bound.x ++; + bound.width --; + } + if (rec.y == 0) { + bound.y ++; + bound.height --; + } + if (rec.x+rec.width == designer.getWidth()) { + bound.width --; + } + if (rec.y+rec.height == designer.getHeight()) { + bound.height --; + } } - + /** * 画出八个拖拽框 @@ -363,9 +360,9 @@ public class FormDesignerUI extends ComponentUI { * 画每一个小拖拽框 */ private void drawBox(Graphics g, int x, int y) { - g.setColor(new Color(254, 0, 0)); + g.setColor(XCreatorConstants.RESIZE_BOX_INNER_COLOR); g.fillRect(x, y, XCreatorConstants.RESIZE_BOX_SIZ, XCreatorConstants.RESIZE_BOX_SIZ); - g.setColor(new Color(254, 0, 0)); + g.setColor(XCreatorConstants.RESIZE_BOX_BORDER_COLOR); g.drawRect(x, y, XCreatorConstants.RESIZE_BOX_SIZ, XCreatorConstants.RESIZE_BOX_SIZ); } @@ -400,7 +397,7 @@ public class FormDesignerUI extends ComponentUI { ComponentUtils.resetBuffer(dbcomponents); designer.resetEditorComponentBounds(); } - + /** * 画参数面板 */ @@ -424,5 +421,5 @@ public class FormDesignerUI extends ComponentUI { // 恢复双缓冲 ComponentUtils.resetBuffer(dbcomponents); } - + } \ No newline at end of file From 69e8f1f79f5e11d3a35e7856a02998408e4f11e7 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Tue, 12 Dec 2017 14:12:26 +0800 Subject: [PATCH 4/6] =?UTF-8?q?REPORT-5908=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E8=8F=9C=E5=8D=95=E3=80=81=E5=8F=B3=E5=87=BB?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E8=A7=86=E8=A7=89=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/DeprecatedActionManager.java | 2 +- .../com/fr/grid/selection/FloatSelection.java | 3 +- .../com/fr/design/constants/UIConstants.java | 2 + .../com/fr/design/gui/imenu/UIHeadMenu.java | 274 ++++++++++++++++++ .../src/com/fr/design/gui/imenu/UIMenu.java | 237 ++++++++++++++- .../com/fr/design/gui/imenu/UIMenuItem.java | 2 +- .../src/com/fr/design/gui/imenu/UIMenuUI.java | 4 +- .../com/fr/design/gui/imenu/UIPopupMenu.java | 24 +- .../gui/imenu/UIPopupMenuSeparatorUI.java | 2 +- .../design/gui/imenu/UIScrollPopUpMenu.java | 9 +- .../com/fr/design/images/control/clear.png | Bin 0 -> 500 bytes .../com/fr/design/images/control/remove.png | Bin 511 -> 167 bytes .../mainframe/toolbar/ToolBarMenuDock.java | 5 + .../src/com/fr/design/menu/MenuDef.java | 12 +- .../fr/design/utils/gui/GUIPaintUtils.java | 37 +++ 15 files changed, 593 insertions(+), 20 deletions(-) create mode 100644 designer_base/src/com/fr/design/gui/imenu/UIHeadMenu.java create mode 100644 designer_base/src/com/fr/design/images/control/clear.png diff --git a/designer/src/com/fr/design/actions/utils/DeprecatedActionManager.java b/designer/src/com/fr/design/actions/utils/DeprecatedActionManager.java index 89bbd82bf..c072b620d 100644 --- a/designer/src/com/fr/design/actions/utils/DeprecatedActionManager.java +++ b/designer/src/com/fr/design/actions/utils/DeprecatedActionManager.java @@ -49,7 +49,7 @@ public class DeprecatedActionManager { */ public static UIMenu getClearMenu(ElementCasePane ePane) { UIMenu clearMenu = new UIMenu(Inter.getLocText("M_Edit-Clear")); - clearMenu.setIcon(UIConstants.BLACK_ICON); + clearMenu.setIcon(BaseUtils.readIcon("/com/fr/design/images/control/clear.png")); clearMenu.setMnemonic('a'); ClearAction ReportComponentAction = new ClearAllAction(ePane); diff --git a/designer/src/com/fr/grid/selection/FloatSelection.java b/designer/src/com/fr/grid/selection/FloatSelection.java index de44152f7..17b8ca7aa 100644 --- a/designer/src/com/fr/grid/selection/FloatSelection.java +++ b/designer/src/com/fr/grid/selection/FloatSelection.java @@ -15,6 +15,7 @@ import com.fr.design.cell.clipboard.CellElementsClip; import com.fr.design.cell.clipboard.ElementsTransferable; import com.fr.design.cell.clipboard.FloatElementsClip; import com.fr.design.designer.TargetComponent; +import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.CellElementPropertyPane; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; @@ -114,7 +115,7 @@ public class FloatSelection extends Selection { @Override public JPopupMenu createPopupMenu(ElementCasePane ePane) { - JPopupMenu popup = new JPopupMenu(); + UIPopupMenu popup = new UIPopupMenu(); if (BaseUtils.isAuthorityEditing()) { popup.add(new CleanAuthorityAction(ePane).createMenuItem()); return popup; diff --git a/designer_base/src/com/fr/design/constants/UIConstants.java b/designer_base/src/com/fr/design/constants/UIConstants.java index 5a35c98d4..c1aacd7c9 100644 --- a/designer_base/src/com/fr/design/constants/UIConstants.java +++ b/designer_base/src/com/fr/design/constants/UIConstants.java @@ -79,6 +79,8 @@ public interface UIConstants { public static final Color COMBOBOX_BTN_NORMAL = new Color(0xD9DADD); public static final Color COMBOBOX_BTN_ROLLOVER = new Color(0xC8C9CD); public static final Color COMBOBOX_BTN_PRESS = new Color(0xD8F2FD); + public static final Color UIPOPUPMENU_LINE_COLOR = new Color(0xC8C9CD); + public static final Color UIPOPUPMENU_BACKGROUND = new Color(0xEDEDEE); public static final Color LINE_COLOR = new Color(153, 153, 153); public static final Color FONT_COLOR = new Color(51, 51, 51); public static final Color LIGHT_BLUE = new Color(182, 217, 253); diff --git a/designer_base/src/com/fr/design/gui/imenu/UIHeadMenu.java b/designer_base/src/com/fr/design/gui/imenu/UIHeadMenu.java new file mode 100644 index 000000000..627982ffe --- /dev/null +++ b/designer_base/src/com/fr/design/gui/imenu/UIHeadMenu.java @@ -0,0 +1,274 @@ +package com.fr.design.gui.imenu; + +import com.fr.design.constants.UIConstants; +import com.fr.design.utils.gui.GUIPaintUtils; + +import javax.swing.*; +import javax.swing.border.Border; +import java.awt.*; + +public class UIHeadMenu extends UIMenu { + private static final float REC = 8f; + private JPopupMenu popupMenu; + + public UIHeadMenu(String name) { + super(name); + } + + public JPopupMenu getPopupMenu() { + ensurePopupMenuCreated(); + popupMenu.setBackground(UIConstants.NORMAL_BACKGROUND); + popupMenu.setBorder(new Border() { + + @Override + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + Graphics2D g2d = (Graphics2D) g; + int rec = (int) REC; + GUIPaintUtils.paintShapeBorder(g2d, x, y, width, height, rec); + if (!(UIHeadMenu.this.getParent() instanceof JPopupMenu)) { + g.setColor(UIConstants.NORMAL_BACKGROUND); + g.drawLine(1, 0, UIHeadMenu.this.getWidth() - 2, 0); + } + } + + @Override + public boolean isBorderOpaque() { + return false; + } + + @Override + public Insets getBorderInsets(Component c) { + return new Insets(5, 2, 10, 10); + } + }); + return popupMenu; + } + + protected void ensurePopupMenuCreated() { + if (popupMenu == null) { + this.popupMenu = new JPopupMenu() { + @Override + protected void paintComponent(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + float wdith = getWidth(); + float heigth = getHeight(); + + Shape shape = GUIPaintUtils.paintShape(g2d, wdith, heigth, REC); + g2d.setClip(shape); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + super.paintComponent(g2d); + } + }; + popupMenu.setInvoker(this); + popupListener = createWinListener(popupMenu); + } + } + + /** + *画界面 + */ + @Override + public void updateUI() { + setUI(new UIMenuUI()); + } + + /** + * 判断popupmeu是否隐藏 + * @return 如果隐藏 返回true + */ + public boolean isPopupMenuVisible() { + ensurePopupMenuCreated(); + return popupMenu.isVisible(); + } + + + /** + * 设置popupmenu位置 + * @param x + * @param y + */ + public void setMenuLocation(int x, int y) { + super.setMenuLocation(x, y); + if (popupMenu != null) { + popupMenu.setLocation(x, y); + } + } + + /** + * 向popupmenu添加 JMenuItem + * @param menuItem 菜单项 + * @return 菜单项 + */ + public JMenuItem add(JMenuItem menuItem) { + ensurePopupMenuCreated(); + return popupMenu.add(menuItem); + } + + /** + * 添加组件 + * @param c 组件 + * @return 组件 + */ + public Component add(Component c) { + ensurePopupMenuCreated(); + popupMenu.add(c); + return c; + } + + /** + * 向指定位置添加组件 + * @param c 组件 + * @param index 位置 + * @return 组件 + */ + public Component add(Component c, int index) { + ensurePopupMenuCreated(); + popupMenu.add(c, index); + return c; + } + + + /** + * 添加分隔符 + */ + public void addSeparator() { + ensurePopupMenuCreated(); + popupMenu.addSeparator(); + } + + /** + * 添加menuitem到指定位置 + * @param s 字符 + * @param pos 位置 + */ + public void insert(String s, int pos) { + if (pos < 0) { + throw new IllegalArgumentException("index less than zero."); + } + + ensurePopupMenuCreated(); + popupMenu.insert(new JMenuItem(s), pos); + } + + /** + * 添加么会特么到指定位置 + * @param mi 菜单项 + * @param pos 位置 + * @return 菜单项 + */ + public JMenuItem insert(JMenuItem mi, int pos) { + if (pos < 0) { + throw new IllegalArgumentException("index less than zero."); + } + ensurePopupMenuCreated(); + popupMenu.insert(mi, pos); + return mi; + } + + /** + * 添加到指定位置 + * @param a 事件 + * @param pos 位置 + * @return 菜单项 + */ + public JMenuItem insert(Action a, int pos) { + if (pos < 0) { + throw new IllegalArgumentException("index less than zero."); + } + + ensurePopupMenuCreated(); + JMenuItem mi = new JMenuItem(a); + mi.setHorizontalTextPosition(JButton.TRAILING); + mi.setVerticalTextPosition(JButton.CENTER); + popupMenu.insert(mi, pos); + return mi; + } + + /** + * 添加分隔符到指定位置 + * @param index 指定位置 + */ + public void insertSeparator(int index) { + if (index < 0) { + throw new IllegalArgumentException("index less than zero."); + } + + ensurePopupMenuCreated(); + popupMenu.insert(new JPopupMenu.Separator(), index); + } + + + /** + * 移除 + * @param item 菜单项 + */ + public void remove(JMenuItem item) { + if (popupMenu != null) { + popupMenu.remove(item); + } + } + + /** + * 移除指定位置菜单项 + * @param pos 指定位置 + */ + public void remove(int pos) { + if (pos < 0) { + throw new IllegalArgumentException("index less than zero."); + } + if (pos > getItemCount()) { + throw new IllegalArgumentException("index greater than the number of items."); + } + if (popupMenu != null) { + popupMenu.remove(pos); + } + } + + /** + * 移除组件 + * @param c 组件 + */ + public void remove(Component c) { + if (popupMenu != null) { + popupMenu.remove(c); + } + } + + /** + * 移除所有 + */ + public void removeAll() { + if (popupMenu != null) { + popupMenu.removeAll(); + } + } + + /** + * 组件总数 + * @return 组件总数 + */ + public int getMenuComponentCount() { + return (popupMenu == null) ? 0 : popupMenu.getComponentCount(); + } + + /** + * 指定位置组件 + * @param n 指定位置 + * @return 组件 + */ + public Component getMenuComponent(int n) { + return (popupMenu == null) ? null : popupMenu.getComponent(n); + } + + /** + * 所有组件 + * @return 所有组件 + */ + public Component[] getMenuComponents() { + return (popupMenu == null) ? new Component[0] : popupMenu.getComponents(); + } + + + + +} diff --git a/designer_base/src/com/fr/design/gui/imenu/UIMenu.java b/designer_base/src/com/fr/design/gui/imenu/UIMenu.java index 9c905a83f..bcdf2ab9f 100644 --- a/designer_base/src/com/fr/design/gui/imenu/UIMenu.java +++ b/designer_base/src/com/fr/design/gui/imenu/UIMenu.java @@ -6,8 +6,12 @@ import com.fr.stable.StringUtils; import javax.swing.*; import javax.swing.border.Border; import java.awt.*; +import java.awt.geom.RoundRectangle2D; public class UIMenu extends JMenu { + private static final float REC = 8f; + private JPopupMenu popupMenu; + public UIMenu(String name) { super(name); setName(name); @@ -24,14 +28,17 @@ public class UIMenu extends JMenu { } public JPopupMenu getPopupMenu() { - JPopupMenu popupMenu = super.getPopupMenu(); - popupMenu.setBackground(UIConstants.NORMAL_BACKGROUND); + ensurePopupMenuCreated(); + popupMenu.setOpaque(false); popupMenu.setBorder(new Border() { @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { - g.setColor(UIConstants.LINE_COLOR); - g.drawRect(x, y, width - 1, height - 1); + Graphics2D g2d = (Graphics2D) g; + int rec = (int) REC; + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); + g2d.setColor(UIConstants.UIPOPUPMENU_LINE_COLOR); + g2d.drawRoundRect(x, y, width - 1, height - 1,rec, rec); if (!(UIMenu.this.getParent() instanceof JPopupMenu)) { g.setColor(UIConstants.NORMAL_BACKGROUND); g.drawLine(1, 0, UIMenu.this.getWidth() - 2, 0); @@ -51,8 +58,230 @@ public class UIMenu extends JMenu { return popupMenu; } + protected void ensurePopupMenuCreated() { + if (popupMenu == null) { + this.popupMenu = new JPopupMenu() { + @Override + protected void paintComponent(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + int rec = (int) REC; + Shape shape = new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), REC, REC); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setColor(UIConstants.NORMAL_BACKGROUND); + g2d.fillRoundRect(0, 0, getWidth(), getHeight(), rec, rec); + g2d.setClip(shape); + super.paintComponent(g2d); + } + + }; + popupMenu.setInvoker(this); + + popupListener = createWinListener(popupMenu); + } + } + + /** + *画界面 + */ @Override public void updateUI() { setUI(new UIMenuUI()); } + + /** + * 判断popupmeu是否隐藏 + * @return 如果隐藏 返回true + */ + public boolean isPopupMenuVisible() { + ensurePopupMenuCreated(); + return popupMenu.isVisible(); + } + + + /** + * 设置popupmenu位置 + * @param x + * @param y + */ + public void setMenuLocation(int x, int y) { + super.setMenuLocation(x, y); + if (popupMenu != null) { + popupMenu.setLocation(x, y); + } + } + + /** + * 向popupmenu添加 JMenuItem + * @param menuItem 菜单项 + * @return 菜单项 + */ + public JMenuItem add(JMenuItem menuItem) { + ensurePopupMenuCreated(); + return popupMenu.add(menuItem); + } + + /** + * 添加组件 + * @param c 组件 + * @return 组件 + */ + public Component add(Component c) { + ensurePopupMenuCreated(); + popupMenu.add(c); + return c; + } + + /** + * 向指定位置添加组件 + * @param c 组件 + * @param index 位置 + * @return 组件 + */ + public Component add(Component c, int index) { + ensurePopupMenuCreated(); + popupMenu.add(c, index); + return c; + } + + + /** + * 添加分隔符 + */ + public void addSeparator() { + ensurePopupMenuCreated(); + popupMenu.addSeparator(); + } + + /** + * 添加menuitem到指定位置 + * @param s 字符 + * @param pos 位置 + */ + public void insert(String s, int pos) { + if (pos < 0) { + throw new IllegalArgumentException("index less than zero."); + } + + ensurePopupMenuCreated(); + popupMenu.insert(new JMenuItem(s), pos); + } + + /** + * 添加么会特么到指定位置 + * @param mi 菜单项 + * @param pos 位置 + * @return 菜单项 + */ + public JMenuItem insert(JMenuItem mi, int pos) { + if (pos < 0) { + throw new IllegalArgumentException("index less than zero."); + } + ensurePopupMenuCreated(); + popupMenu.insert(mi, pos); + return mi; + } + + /** + * 添加到指定位置 + * @param a 事件 + * @param pos 位置 + * @return 菜单项 + */ + public JMenuItem insert(Action a, int pos) { + if (pos < 0) { + throw new IllegalArgumentException("index less than zero."); + } + + ensurePopupMenuCreated(); + JMenuItem mi = new JMenuItem(a); + mi.setHorizontalTextPosition(JButton.TRAILING); + mi.setVerticalTextPosition(JButton.CENTER); + popupMenu.insert(mi, pos); + return mi; + } + + /** + * 添加分隔符到指定位置 + * @param index 指定位置 + */ + public void insertSeparator(int index) { + if (index < 0) { + throw new IllegalArgumentException("index less than zero."); + } + + ensurePopupMenuCreated(); + popupMenu.insert(new JPopupMenu.Separator(), index); + } + + + /** + * 移除 + * @param item 菜单项 + */ + public void remove(JMenuItem item) { + if (popupMenu != null) { + popupMenu.remove(item); + } + } + + /** + * 移除指定位置菜单项 + * @param pos 指定位置 + */ + public void remove(int pos) { + if (pos < 0) { + throw new IllegalArgumentException("index less than zero."); + } + if (pos > getItemCount()) { + throw new IllegalArgumentException("index greater than the number of items."); + } + if (popupMenu != null) { + popupMenu.remove(pos); + } + } + + /** + * 移除组件 + * @param c 组件 + */ + public void remove(Component c) { + if (popupMenu != null) { + popupMenu.remove(c); + } + } + + /** + * 移除所有 + */ + public void removeAll() { + if (popupMenu != null) { + popupMenu.removeAll(); + } + } + + /** + * 组件总数 + * @return 组件总数 + */ + public int getMenuComponentCount() { + return (popupMenu == null) ? 0 : popupMenu.getComponentCount(); + } + + /** + * 指定位置组件 + * @param n 指定位置 + * @return 组件 + */ + public Component getMenuComponent(int n) { + return (popupMenu == null) ? null : popupMenu.getComponent(n); + } + + /** + * 所有组件 + * @return 所有组件 + */ + public Component[] getMenuComponents() { + return (popupMenu == null) ? new Component[0] : popupMenu.getComponents(); + } + } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/imenu/UIMenuItem.java b/designer_base/src/com/fr/design/gui/imenu/UIMenuItem.java index e35f440a1..a0f164361 100644 --- a/designer_base/src/com/fr/design/gui/imenu/UIMenuItem.java +++ b/designer_base/src/com/fr/design/gui/imenu/UIMenuItem.java @@ -95,7 +95,7 @@ public class UIMenuItem extends JMenuItem{ } else { // *** paint the text normally if (model.isArmed()|| (menuItem instanceof JMenu && model.isSelected())) { - g.setColor(selectionForeground); // Uses protected field. + g.setColor(Color.WHITE); // Uses protected field. } SwingUtilities2.drawStringUnderlineCharAt(menuItem, g,text, -1, textRect.x, textRect.y + fm.getAscent()); diff --git a/designer_base/src/com/fr/design/gui/imenu/UIMenuUI.java b/designer_base/src/com/fr/design/gui/imenu/UIMenuUI.java index 9e79ecd65..33f86582f 100644 --- a/designer_base/src/com/fr/design/gui/imenu/UIMenuUI.java +++ b/designer_base/src/com/fr/design/gui/imenu/UIMenuUI.java @@ -72,8 +72,8 @@ public class UIMenuUI extends BasicMenuUI { } } else { // *** paint the text normally - if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { - g.setColor(selectionForeground); // Uses protected field. + if (model.isArmed() || (menuItem instanceof JMenu && menuItem.isSelected() && menuItem.getIcon() != null)) { + g.setColor(Color.WHITE); // Uses protected field. } SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent()); diff --git a/designer_base/src/com/fr/design/gui/imenu/UIPopupMenu.java b/designer_base/src/com/fr/design/gui/imenu/UIPopupMenu.java index 44b36ae11..9fcf821e0 100644 --- a/designer_base/src/com/fr/design/gui/imenu/UIPopupMenu.java +++ b/designer_base/src/com/fr/design/gui/imenu/UIPopupMenu.java @@ -1,23 +1,37 @@ package com.fr.design.gui.imenu; -import java.awt.Graphics; -import java.awt.Insets; +import java.awt.*; +import java.awt.geom.RoundRectangle2D; -import javax.swing.JPopupMenu; +import javax.swing.*; import com.fr.design.constants.UIConstants; public class UIPopupMenu extends JPopupMenu{ + private static final float REC = 8f; private boolean onlyText = false; public UIPopupMenu() { super(); setBackground(UIConstants.NORMAL_BACKGROUND); } + @Override + protected void paintComponent(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + Shape shape = null; + shape = new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), REC, REC); + g2d.setClip(shape); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + super.paintComponent(g2d); + } + @Override protected void paintBorder(Graphics g) { - g.setColor(UIConstants.LINE_COLOR); - g.drawRect(0, 0, getWidth() - 1, getHeight() - 1); + Graphics2D g2d = (Graphics2D) g; + int rec = (int) REC; + g2d.setColor(UIConstants.UIPOPUPMENU_LINE_COLOR); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, rec, rec); } @Override diff --git a/designer_base/src/com/fr/design/gui/imenu/UIPopupMenuSeparatorUI.java b/designer_base/src/com/fr/design/gui/imenu/UIPopupMenuSeparatorUI.java index df90a1bbe..b9497dcd1 100644 --- a/designer_base/src/com/fr/design/gui/imenu/UIPopupMenuSeparatorUI.java +++ b/designer_base/src/com/fr/design/gui/imenu/UIPopupMenuSeparatorUI.java @@ -23,7 +23,7 @@ public class UIPopupMenuSeparatorUI extends MetalSeparatorUI { public void paint(Graphics g, JComponent c) { Dimension s = c.getSize(); - g.setColor(UIConstants.FONT_COLOR); + g.setColor(UIConstants.UIPOPUPMENU_LINE_COLOR); g.drawLine(2, 1, s.width - 3, 1); } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/imenu/UIScrollPopUpMenu.java b/designer_base/src/com/fr/design/gui/imenu/UIScrollPopUpMenu.java index 3f8fd6a42..c2713fc26 100644 --- a/designer_base/src/com/fr/design/gui/imenu/UIScrollPopUpMenu.java +++ b/designer_base/src/com/fr/design/gui/imenu/UIScrollPopUpMenu.java @@ -1,6 +1,7 @@ package com.fr.design.gui.imenu; +import com.fr.design.constants.UIConstants; import com.fr.design.gui.iscrollbar.UIScrollBar; import java.awt.*; @@ -16,12 +17,13 @@ import java.awt.event.MouseWheelListener; */ public class UIScrollPopUpMenu extends UIPopupMenu { private static final int MAX_SHOW_NUM = 27; - + private static final float REC = 8f; private UIScrollBar scrollBar; public UIScrollPopUpMenu() { super(); + setOpaque(false); setLayout(new ScrollPopupMenuLayout()); super.add(getScrollBar()); addMouseWheelListener(new MouseWheelListener() { @@ -39,6 +41,11 @@ public class UIScrollPopUpMenu extends UIPopupMenu { public void paintChildren(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + int rec = (int) REC; + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setColor(UIConstants.NORMAL_BACKGROUND); + g2d.fillRoundRect(1, 1, getWidth() - 2, getHeight() - 2, rec, rec); Insets insets = getInsets(); g.clipRect(insets.left, insets.top, getWidth(), getHeight() - insets.top - insets.bottom); super.paintChildren(g); diff --git a/designer_base/src/com/fr/design/images/control/clear.png b/designer_base/src/com/fr/design/images/control/clear.png new file mode 100644 index 0000000000000000000000000000000000000000..6e6282a3f394a5916b3432cdc3da4f58a7620907 GIT binary patch literal 500 zcmVPx$u1Q2eR5%fpQN2sUKoq~1>sJV&*r8x4T|}@h3ay1wP(ctu1Rc6d2SHq11i{7G z&B;yw1gC;S2bUO$iK~Lr$tt)AYH1rx&UcXu*HWQ9NZ$K>z2xqIjJYb6N~YKAU1IFb zw(U)2oIDSAyY4k(q=dOio(%_7tJTpC zsmp@giy?$04=l?vWi1?F+opxWvnHY*Bg z$XN7HC={6hq5>%A0PF}4u7=z)V=#w9SMfSeky{czUi%JF2#onPG~c7#p_K0Hx;BNu qFMJk-N7SKzAjDDX&_5U@C_KN?QJ%F+E%$-|0000e`^%>Zm-AdO%X zaY?2mH6u zPXao-yYt4FZDO91e85CyBDxp=_9&mP_tx|ga4whXwA%*^Y=8EG;*_bUGTwMi?j9A&)nOiM8PN!N0KRj3(Lv-0kpqHdWw5Go*yuOYW z_A#?57GaCawyDZL8rRXrsZBl31iD-Ws7#`lyn3^L{$KEg^ zSvwxp|7y1L(9i_sa;-QgvG2x*hsm%~S=3)8fIyyS<9Qd!582-<{t$Tw3WBcZi@oK+ P00000NkvXXu0mjf+yUXr diff --git a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index f43419d47..4831c60f8 100644 --- a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -228,6 +228,11 @@ public abstract class ToolBarMenuDock { addAllUpdateActionsToList(menuList); UpdateActionManager.getUpdateActionManager().setUpdateActions(shortCutsList); + for (MenuDef menuDef : menuList + ) { + menuDef.setHasRecMenu(true); + } + return menuList.toArray(new MenuDef[menuList.size()]); } diff --git a/designer_base/src/com/fr/design/menu/MenuDef.java b/designer_base/src/com/fr/design/menu/MenuDef.java index 00dd2ff3a..bc5e3a8b7 100644 --- a/designer_base/src/com/fr/design/menu/MenuDef.java +++ b/designer_base/src/com/fr/design/menu/MenuDef.java @@ -2,10 +2,7 @@ package com.fr.design.menu; import com.fr.base.BaseUtils; import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.imenu.UIMenu; -import com.fr.design.gui.imenu.UIPopupEastAttrMenu; -import com.fr.design.gui.imenu.UIPopupMenu; -import com.fr.design.gui.imenu.UIScrollMenu; +import com.fr.design.gui.imenu.*; import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.StringUtils; @@ -41,6 +38,7 @@ public class MenuDef extends ShortCut { protected UIButton createdButton; protected JPopupMenu popupMenu; private boolean hasScrollSubMenu; + private boolean isHeadMenu; private String anchor; @@ -88,6 +86,10 @@ public class MenuDef extends ShortCut { this.hasScrollSubMenu = scrollSubMenu; } + public void setHasRecMenu(boolean headMenu) { + this.isHeadMenu = headMenu; + } + public String getIconPath() { return iconPath; } @@ -186,6 +188,8 @@ public class MenuDef extends ShortCut { if (createdJMenu == null) { if (hasScrollSubMenu) { createdJMenu = new UIScrollMenu(this.getName()); + } else if (isHeadMenu){ + createdJMenu = new UIHeadMenu(this.getName()); } else { createdJMenu = new UIMenu(this.getName()); } diff --git a/designer_base/src/com/fr/design/utils/gui/GUIPaintUtils.java b/designer_base/src/com/fr/design/utils/gui/GUIPaintUtils.java index 286e44cd6..fcff66e07 100644 --- a/designer_base/src/com/fr/design/utils/gui/GUIPaintUtils.java +++ b/designer_base/src/com/fr/design/utils/gui/GUIPaintUtils.java @@ -5,6 +5,7 @@ import com.fr.design.constants.UIConstants; import com.fr.stable.Constants; import java.awt.*; +import java.awt.geom.GeneralPath; import java.awt.geom.RoundRectangle2D; public class GUIPaintUtils { @@ -202,4 +203,40 @@ public class GUIPaintUtils { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } + /** + * 自定义popMenu画法,一种下面两圆角矩形 + * + */ + public static final Shape paintShape(Graphics2D g2, float width, float height, float REC) { + REC = REC / 2; + float recdir = (float) (REC - (REC / Math.sqrt(2))); + GeneralPath gp1 = new GeneralPath(); + gp1.moveTo(0f, 0f); + gp1.lineTo(width, 0f); + gp1.lineTo(width, height - REC); + gp1.quadTo(width - recdir, height - recdir, width - REC, height); + gp1.lineTo(REC, height); + gp1.quadTo(recdir, height - recdir, 0, height - REC); + gp1.closePath(); + return gp1; + } + + /** + * 自定义popMenu边框画法,一种下面两圆角矩形 + * + */ + public static final void paintShapeBorder(Graphics2D g2, int x, int y, int width, int height, int rec) { + g2.setColor(UIConstants.UIPOPUPMENU_LINE_COLOR); + width = width - 1; + height = height - 1; + rec = rec / 2; + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); + g2.drawLine(x, y, x + width, y); + g2.drawLine(x + width, y, x + width, y + height - rec); + g2.drawArc(x + width - (rec / 2), y + height - (rec / 2), rec / 2, rec / 2, 0, 90); + g2.drawLine(x + width - rec, y + height, x + rec, y + height); + g2.drawArc(x - (rec / 2), y + height - (rec / 2), rec / 2, rec / 2, 0, 90); + g2.drawLine(x, y + height - rec, x, y); + } + } \ No newline at end of file From e45eb353fec58446d637311f8d36c081aaecaaf9 Mon Sep 17 00:00:00 2001 From: MoMeak Date: Tue, 12 Dec 2017 14:19:49 +0800 Subject: [PATCH 5/6] =?UTF-8?q?REPORT-5840=20=E6=8E=A7=E4=BB=B6=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=92=8C=E4=BD=BF=E7=94=A8=E5=A1=AB=E6=8A=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/toolbar/ToolBarMenuDock.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 4831c60f8..24059928b 100644 --- a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -180,6 +180,7 @@ public abstract class ToolBarMenuDock { this.menus = menus(plus); for (int i = 0; i < menus.length; i++) { + menus[i].setHasRecMenu(true); UIMenu subMenu = menus[i].createJMenu(); jMenuBar.add(subMenu); menus[i].updateMenu(); @@ -228,11 +229,6 @@ public abstract class ToolBarMenuDock { addAllUpdateActionsToList(menuList); UpdateActionManager.getUpdateActionManager().setUpdateActions(shortCutsList); - for (MenuDef menuDef : menuList - ) { - menuDef.setHasRecMenu(true); - } - return menuList.toArray(new MenuDef[menuList.size()]); } From 4e9f8e1c335c84c69572d79bc812918b3c2cd9db Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 12 Dec 2017 14:37:08 +0800 Subject: [PATCH 6/6] =?UTF-8?q?REPORT-2615=20=E4=BF=AE=E6=94=B9class?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AccessibleTemplateStyleEditor.java | 2 +- .../widget/accessibles/TemplateStylePane.java | 16 ++++++++-------- .../accessibles/TemplateStylePreviewPane.java | 2 +- .../layout/WCardTagLayoutDefinePane.java | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTemplateStyleEditor.java b/designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTemplateStyleEditor.java index 5b92df50e..9e32a4d46 100644 --- a/designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTemplateStyleEditor.java +++ b/designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTemplateStyleEditor.java @@ -2,7 +2,7 @@ package com.fr.design.mainframe.widget.accessibles; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; -import com.fr.base.TemplateStyle; +import com.fr.general.cardtag.TemplateStyle; import com.fr.design.mainframe.widget.wrappers.TemplateStyleWrapper; import javax.swing.SwingUtilities; diff --git a/designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java b/designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java index 3a0a35b01..890e5dc5c 100644 --- a/designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java +++ b/designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java @@ -1,14 +1,14 @@ package com.fr.design.mainframe.widget.accessibles; -import com.fr.base.BannerTemplateStyle; -import com.fr.base.BookMarkTemplateStyle; -import com.fr.base.CardTemplateStyle; -import com.fr.base.DefaultTemplateStyle; -import com.fr.base.MenuTemplateStyle; -import com.fr.base.PentagonTemplateStyle; -import com.fr.base.TrapezoidTemplateStyle; +import com.fr.general.cardtag.BannerTemplateStyle; +import com.fr.general.cardtag.BookMarkTemplateStyle; +import com.fr.general.cardtag.CardTemplateStyle; +import com.fr.general.cardtag.DefaultTemplateStyle; +import com.fr.general.cardtag.MenuTemplateStyle; +import com.fr.general.cardtag.PentagonTemplateStyle; +import com.fr.general.cardtag.TrapezoidTemplateStyle; import com.fr.design.dialog.BasicPane; -import com.fr.base.TemplateStyle; +import com.fr.general.cardtag.TemplateStyle; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.Inter; diff --git a/designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java b/designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java index 24b9b393f..4871bfd1d 100644 --- a/designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java +++ b/designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.widget.accessibles; import com.fr.base.BaseUtils; -import com.fr.base.TemplateStyle; +import com.fr.general.cardtag.TemplateStyle; import javax.swing.JPanel; import java.awt.Graphics; diff --git a/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java b/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java index 3e6dcb0ca..3fe62fdac 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java @@ -1,6 +1,6 @@ package com.fr.design.widget.ui.designer.layout; -import com.fr.base.TemplateStyle; +import com.fr.general.cardtag.TemplateStyle; import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer;