From 3e336de89112134b56027d55542717a26f04e6a2 Mon Sep 17 00:00:00 2001 From: lee <854954082@qq.com> Date: Thu, 12 Jan 2017 17:16:24 +0800 Subject: [PATCH] 1 1 --- .../creator/cardlayout/XCardAddButton.java | 3 +- .../creator/cardlayout/XCardSwitchButton.java | 3 +- .../creator/cardlayout/XWCardLayout.java | 90 ++++++++++++++----- 3 files changed, 73 insertions(+), 23 deletions(-) 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 2c6a0036b5..caf259f3e2 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 @@ -146,7 +146,8 @@ public class XCardAddButton extends XButton{ //设置标题 titleButton.setText(getTabTitleName()); titleButton.setInitialBackground(ColorBackground.getInstance(Color.WHITE)); - XCardSwitchButton showButton = new XCardSwitchButton(titleButton,dimension,cardLayout,tagLayout); + XCardSwitchButton showButton = new XCardSwitchButton(titleButton, dimension, cardLayout, tagLayout); + titleButton.setCustomStyle(true); titleButton.setShowButton(true); showButton.setBackupParent(tagLayout); 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 9116b36441..f7e610483f 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 @@ -11,6 +11,7 @@ import java.util.*; import javax.swing.*; import com.fr.base.BaseUtils; +import com.fr.base.GraphHelper; import com.fr.base.background.ColorBackground; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.ComponentAdapter; @@ -353,7 +354,7 @@ public class XCardSwitchButton extends XButton { CardSwitchButton tempCard = (CardSwitchButton) temp.toData(); String tempText = tempCard.getText(); Font f = ((CardSwitchButton)this.toData()).getFont(); - FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics(f); + FontMetrics fm = GraphHelper.getFontMetrics(f); cardWidth.put(i,fm.stringWidth(tempText)); cardHeight.put(i,fm.getHeight()); } 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 d008ccd521..d98e6a35b0 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 @@ -6,13 +6,16 @@ package com.fr.design.designer.creator.cardlayout; import com.fr.base.background.ColorBackground; 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.form.layout.FRCardLayout; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.mainframe.FormDesigner; +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.renderer.LayoutBorderStyleRenderer; +import com.fr.design.mainframe.widget.editors.DoubleEditor; import com.fr.form.ui.*; import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WCardLayout; @@ -22,6 +25,7 @@ import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTitleLayout; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; +import com.fr.stable.ArrayUtils; import com.fr.stable.Constants; import com.fr.stable.core.PropertyChangeAdapter; @@ -39,6 +43,8 @@ public class XWCardLayout extends XLayoutContainer { private CardLayout cardLayout; private boolean initFlag = true; private static final int NORTH = 0; + private FormDesigner designer; + //默认蓝色标题背景 private static final Color TITLE_COLOR = new Color(51, 132, 240); @@ -197,6 +203,7 @@ public class XWCardLayout extends XLayoutContainer { CardSwitchButton firstBtn = new CardSwitchButton(widgetName); firstBtn.setText(Inter.getLocText("FR-Designer_Title") + 0); firstBtn.setInitialBackground(ColorBackground.getInstance(Color.WHITE)); + firstBtn.setCustomStyle(true); xTag.setCurrentCard(firstBtn); XCardSwitchButton xFirstBtn = new XCardSwitchButton(firstBtn, new Dimension(CardSwitchButton.DEF_WIDTH, -1), this, xTag); xFirstBtn.setBackupParent(xTag); @@ -271,27 +278,68 @@ public class XWCardLayout extends XLayoutContainer { * @throws IntrospectionException */ public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { - return new CRPropertyDescriptor[] { - new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Inter - .getLocText("FR-Designer_Form-Widget_Name")).setPropertyChangeListener(new PropertyChangeAdapter(){ - - @Override - public void propertyChange(){ - WCardLayout cardLayout = toData(); - changeRalateSwitchCardname(cardLayout.getWidgetName()); - } - }), - new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass( - CardTagWLayoutBorderStyleEditor.class).setI18NName( - Inter.getLocText("FR-Engine_Style")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") - .setPropertyChangeListener(new PropertyChangeAdapter() { + CRPropertyDescriptor[] crp = ((WCardLayout) data).isCarousel() ? getisCarousel() : getisnotCarousel(); + return ArrayUtils.addAll(getDefaultDescriptor(), crp); + } + + public CRPropertyDescriptor[] getisCarousel() throws IntrospectionException { + return new CRPropertyDescriptor[] { + new CRPropertyDescriptor("carousel", this.data.getClass()) + .setEditorClass(BooleanEditor.class) + .setI18NName(Inter.getLocText("FR-Designer_setCarousel")) + .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "FR-Designer_Tab_carousel") + .setPropertyChangeListener(new PropertyChangeAdapter() { + @Override + public void propertyChange() { + designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); + } + }), + new CRPropertyDescriptor("carouselInterval", this.data.getClass()) + .setEditorClass(DoubleEditor.class) + .setI18NName(Inter.getLocText("FR-Designer_carouselInterval")) + .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "FR-Designer_Tab_carousel") + }; + } + + public CRPropertyDescriptor[] getisnotCarousel() throws IntrospectionException { + return new CRPropertyDescriptor[] { + new CRPropertyDescriptor("carousel", this.data.getClass()) + .setEditorClass(BooleanEditor.class) + .setI18NName(Inter.getLocText("FR-Designer_setCarousel")) + .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "FR-Designer_Tab_carousel") + .setPropertyChangeListener(new PropertyChangeAdapter() { + @Override + public void propertyChange() { + designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); + } + }) + }; + } + + public CRPropertyDescriptor[] getDefaultDescriptor() throws IntrospectionException { + return new CRPropertyDescriptor[] { + new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Inter + .getLocText("FR-Designer_Form-Widget_Name")).setPropertyChangeListener(new PropertyChangeAdapter(){ + + @Override + public void propertyChange(){ + WCardLayout cardLayout = toData(); + changeRalateSwitchCardname(cardLayout.getWidgetName()); + } + }), + new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass( + CardTagWLayoutBorderStyleEditor.class).setI18NName( + Inter.getLocText("FR-Engine_Style")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") + .setPropertyChangeListener(new PropertyChangeAdapter() { - @Override - public void propertyChange() { - initStyle(); - } - }), - }; + @Override + public void propertyChange() { + initStyle(); + } + }) + }; } //初始化样式