From 5fd24993b919aaa2595ad99ba4d974ccbf5b2811 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 29 Jan 2018 15:54:47 +0800 Subject: [PATCH] =?UTF-8?q?tab=E6=8C=89=E9=92=AE=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=B8=90=E5=8F=98=E8=89=B2=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AccessibleImgBackgroundEditor.java | 7 +- .../AccessibleTabBackgroundEditor.java | 39 ++------ .../AccessibleTabPaneBackgroundEditor.java | 40 ++++++++ .../BackgroundCardSwitchButtonPane.java | 95 +++++++++++++++++++ .../widget/component/BackgroundCompPane.java | 10 +- .../component/TabFitLayoutBackgroundPane.java | 8 ++ .../layout/WCardTagLayoutDefinePane.java | 6 +- 7 files changed, 167 insertions(+), 38 deletions(-) create mode 100644 designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabPaneBackgroundEditor.java create mode 100644 designer_base/src/com/fr/design/style/background/BackgroundCardSwitchButtonPane.java diff --git a/designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleImgBackgroundEditor.java b/designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleImgBackgroundEditor.java index 931793aab2..71cc16bdce 100644 --- a/designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleImgBackgroundEditor.java +++ b/designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleImgBackgroundEditor.java @@ -18,7 +18,7 @@ public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor { @Override protected void showEditorPane() { - choosePane = new BackgroundButtonPane(); + choosePane = initBackgroundPane(); choosePane.setPreferredSize(new Dimension(600, 400)); BasicDialog dlg = choosePane.showWindow(SwingUtilities.getWindowAncestor(this)); dlg.addDialogActionListener(new DialogActionAdapter() { @@ -32,4 +32,9 @@ public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor { choosePane.populate(getValue() instanceof Background ? (Background) getValue() : new ColorBackground()); dlg.setVisible(true); } + + protected BackgroundButtonPane initBackgroundPane(){ + return new BackgroundButtonPane(); + } + } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabBackgroundEditor.java b/designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabBackgroundEditor.java index ade9208565..d4d8a5493c 100644 --- a/designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabBackgroundEditor.java +++ b/designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabBackgroundEditor.java @@ -1,40 +1,17 @@ package com.fr.design.mainframe.widget.accessibles; -import com.fr.base.background.ColorBackground; -import com.fr.design.dialog.BasicDialog; -import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.mainframe.widget.wrappers.BackgroundWrapper; -import com.fr.design.style.background.BackgroundTabPane; -import com.fr.general.Background; - -import javax.swing.SwingUtilities; -import java.awt.Dimension; - +import com.fr.design.style.background.BackgroundButtonPane; +import com.fr.design.style.background.BackgroundCardSwitchButtonPane; /** * @author kerry - * @date 2018/1/17 + * @date 2018/1/29 */ -public class AccessibleTabBackgroundEditor extends UneditableAccessibleEditor { - private BackgroundTabPane choosePane; - +public class AccessibleTabBackgroundEditor extends AccessibleImgBackgroundEditor { public AccessibleTabBackgroundEditor() { - super(new BackgroundWrapper()); + super(); } - @Override - protected void showEditorPane() { - choosePane = new BackgroundTabPane(); - choosePane.setPreferredSize(new Dimension(600, 400)); - BasicDialog dlg = choosePane.showWindow(SwingUtilities.getWindowAncestor(this)); - dlg.addDialogActionListener(new DialogActionAdapter() { - - @Override - public void doOk() { - setValue(choosePane.update()); - fireStateChanged(); - } - }); - choosePane.populate(getValue() instanceof Background ? (Background) getValue() : new ColorBackground()); - dlg.setVisible(true); + protected BackgroundButtonPane initBackgroundPane(){ + return new BackgroundCardSwitchButtonPane(); } -} \ No newline at end of file +} diff --git a/designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabPaneBackgroundEditor.java b/designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabPaneBackgroundEditor.java new file mode 100644 index 0000000000..ee0d7634f7 --- /dev/null +++ b/designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabPaneBackgroundEditor.java @@ -0,0 +1,40 @@ +package com.fr.design.mainframe.widget.accessibles; + +import com.fr.base.background.ColorBackground; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.widget.wrappers.BackgroundWrapper; +import com.fr.design.style.background.BackgroundTabPane; +import com.fr.general.Background; + +import javax.swing.SwingUtilities; +import java.awt.Dimension; + +/** + * @author kerry + * @date 2018/1/17 + */ +public class AccessibleTabPaneBackgroundEditor extends UneditableAccessibleEditor { + private BackgroundTabPane choosePane; + + public AccessibleTabPaneBackgroundEditor() { + super(new BackgroundWrapper()); + } + + @Override + protected void showEditorPane() { + choosePane = new BackgroundTabPane(); + choosePane.setPreferredSize(new Dimension(600, 400)); + BasicDialog dlg = choosePane.showWindow(SwingUtilities.getWindowAncestor(this)); + dlg.addDialogActionListener(new DialogActionAdapter() { + + @Override + public void doOk() { + setValue(choosePane.update()); + fireStateChanged(); + } + }); + choosePane.populate(getValue() instanceof Background ? (Background) getValue() : new ColorBackground()); + dlg.setVisible(true); + } +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/style/background/BackgroundCardSwitchButtonPane.java b/designer_base/src/com/fr/design/style/background/BackgroundCardSwitchButtonPane.java new file mode 100644 index 0000000000..b5a2aeffad --- /dev/null +++ b/designer_base/src/com/fr/design/style/background/BackgroundCardSwitchButtonPane.java @@ -0,0 +1,95 @@ +package com.fr.design.style.background; + +import com.fr.base.background.ColorBackground; +import com.fr.base.background.GradientBackground; +import com.fr.base.background.ImageBackground; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.style.background.gradient.GradientBackgroundPane; +import com.fr.design.style.background.impl.ColorBackgroundPane; +import com.fr.design.style.background.impl.ImageBackgroundPane; +import com.fr.design.style.background.impl.NullBackgroundPane; +import com.fr.general.Background; +import com.fr.general.Inter; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * @author kerry + * @date 2018/1/29 + */ +public class BackgroundCardSwitchButtonPane extends BackgroundButtonPane { + + private static Map, BackgroundUIWrapper> cardSwitchButton = new LinkedHashMap<>(); + + static { + registerCardSwitchBtnBackground(cardSwitchButton); + } + + + private static void registerCardSwitchBtnBackground(Map, BackgroundUIWrapper> map) { + map.put(ColorBackground.class, BackgroundUIWrapper.create() + .setType(ColorBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Color"))); + map.put(ImageBackground.class, BackgroundUIWrapper.create() + .setType(ImageBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Image"))); + map.put(GradientBackground.class, BackgroundUIWrapper.create() + .setType(GradientBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Gradient_Color"))); + + } + + public BackgroundCardSwitchButtonPane() { + super(); + } + + @Override + protected void initTabPane() { + int index = 0; + for (Class key : cardSwitchButton.keySet()) { + BackgroundUIWrapper wrapper = cardSwitchButton.get(key); + wrapper.setIndex(index++); + tabbedPane.addTab(Inter.getLocText(wrapper.getTitle()), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); + } + } + + @Override + protected BackgroundUIWrapper getBackgroundUIWrapper(Background background) { + return cardSwitchButton.get(background == null ? null : background.getClass()); + } + + + @Override + protected BackgroundDetailPane getTabItemPane(Background background, int index) { + BackgroundDetailPane quickPane = cacheMap.get(index); + if (quickPane == null) { + BackgroundUIWrapper uiWrapper = getBackgroundUIWrapper(background); + quickPane = BackgroundFactory.createByWrapper(uiWrapper); + quickPane.addChangeListener(backgroundChangeListener); + cacheMap.put(index, quickPane); + } + tabbedPane.setComponentAt(index, quickPane); + tabbedPane.setSelectedIndex(index); + return quickPane; + } + + @Override + protected BackgroundDetailPane getTabItemPaneByIndex(int index) { + BackgroundDetailPane quickPane = cacheMap.get(index); + if (quickPane == null) { + quickPane = createDetailPaneByIndex(index); + tabbedPane.setComponentAt(index, quickPane); + cacheMap.put(index, quickPane); + quickPane.addChangeListener(backgroundChangeListener); + } + return quickPane; + } + + public BackgroundDetailPane createDetailPaneByIndex(int index) { + for (BackgroundUIWrapper wrapper : cardSwitchButton.values()) { + if (wrapper.getIndex() == index) { + return BackgroundFactory.createByWrapper(wrapper); + } + } + return new NullBackgroundPane(); + } + +} diff --git a/designer_base/src/com/fr/design/widget/component/BackgroundCompPane.java b/designer_base/src/com/fr/design/widget/component/BackgroundCompPane.java index 41d316145f..645abdf18a 100644 --- a/designer_base/src/com/fr/design/widget/component/BackgroundCompPane.java +++ b/designer_base/src/com/fr/design/widget/component/BackgroundCompPane.java @@ -31,9 +31,7 @@ public abstract class BackgroundCompPane extends BasicPane { public void initComponent() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); UILabel headLabel = createUILable(); - initalBackgroundEditor = new AccessibleImgBackgroundEditor(); - overBackgroundEditor = new AccessibleImgBackgroundEditor(); - clickBackgroundEditor = new AccessibleImgBackgroundEditor(); + initBackgroundEditor(); String [] titles = new String[]{Inter.getLocText("FR-Designer_DEFAULT"), Inter.getLocText("FR-Designer_Custom")}; double f = TableLayout.FILL; @@ -57,6 +55,12 @@ public abstract class BackgroundCompPane extends BasicPane { } + protected void initBackgroundEditor(){ + initalBackgroundEditor = new AccessibleImgBackgroundEditor(); + overBackgroundEditor = new AccessibleImgBackgroundEditor(); + clickBackgroundEditor = new AccessibleImgBackgroundEditor(); + } + protected UILabel createUILable(){ return new UILabel(Inter.getLocText("FR-Designer_Background")); } diff --git a/designer_form/src/com/fr/design/widget/ui/designer/component/TabFitLayoutBackgroundPane.java b/designer_form/src/com/fr/design/widget/ui/designer/component/TabFitLayoutBackgroundPane.java index 12a6e3c26a..8bd816293a 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/component/TabFitLayoutBackgroundPane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/component/TabFitLayoutBackgroundPane.java @@ -1,6 +1,7 @@ package com.fr.design.widget.ui.designer.component; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.mainframe.widget.accessibles.AccessibleTabBackgroundEditor; import com.fr.design.widget.component.BackgroundCompPane; import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.container.cardlayout.WTabFitLayout; @@ -16,6 +17,13 @@ public class TabFitLayoutBackgroundPane extends BackgroundCompPane { - private AccessibleTabBackgroundEditor backgroundEditor; + private AccessibleTabPaneBackgroundEditor backgroundEditor; private FRFontPane frFontPane; private UIButtonGroup displayPositionGroup; private UIButtonGroup textDirectionGroup; @@ -51,7 +51,7 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify public void initComponent() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); - backgroundEditor = new AccessibleTabBackgroundEditor(); + backgroundEditor = new AccessibleTabPaneBackgroundEditor(); templateStyleEditor = new AccessibleTemplateStyleEditor(); double f = TableLayout.FILL; double p = TableLayout.PREFERRED;