From 331d8a8b52893aa03d7cb48680e52f95e0e99360 Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 9 Aug 2017 15:10:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86UIHeadGroup=E6=8D=A2=E6=88=90=E7=94=A8?= =?UTF-8?q?UIButtonGroup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/widget/ui/CheckBoxDictPane.java | 14 +---- .../widget/component/BackgroundCompPane.java | 31 ++++------ .../component/ButtonBackgroundPane.java | 2 + .../ui/designer/CheckBoxGroupDefinePane.java | 23 ++------ .../ui/designer/ComboCheckBoxDefinePane.java | 23 ++------ .../ui/designer/DateEditorDefinePane.java | 9 +-- .../component/FormWidgetValuePane.java | 59 ++++++++++--------- .../component/TabFitLayoutBackgroundPane.java | 2 + 8 files changed, 65 insertions(+), 98 deletions(-) diff --git a/designer/src/com/fr/design/widget/ui/CheckBoxDictPane.java b/designer/src/com/fr/design/widget/ui/CheckBoxDictPane.java index 1dd028e6c3..355cb75085 100644 --- a/designer/src/com/fr/design/widget/ui/CheckBoxDictPane.java +++ b/designer/src/com/fr/design/widget/ui/CheckBoxDictPane.java @@ -1,14 +1,11 @@ package com.fr.design.widget.ui; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import com.fr.design.gui.ibutton.UIHeadGroup; +import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; import javax.swing.JPanel; -import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.DictionaryComboBox; import com.fr.design.gui.icombobox.DictionaryConstants; import com.fr.design.layout.FRGUIPaneFactory; @@ -20,7 +17,7 @@ import com.fr.general.Inter; public class CheckBoxDictPane extends JPanel { private DictionaryComboBox delimiterComboBox; - private UIHeadGroup returnTypeComboBox; + private UIButtonGroup returnTypeComboBox; private DictionaryComboBox startComboBox; private DictionaryComboBox endComboBox; @@ -46,12 +43,7 @@ public class CheckBoxDictPane extends JPanel { endPane.add(new UILabel(Inter.getLocText("ComboCheckBox-End_Symbol") + ":"), BorderLayout.WEST); endPane.add(endComboBox = new DictionaryComboBox(DictionaryConstants.symbols, DictionaryConstants.symbolDisplays), BorderLayout.CENTER); endComboBox.setEditable(true); - returnTypeComboBox = new UIHeadGroup(new String[]{Inter.getLocText("Widget-Array"), Inter.getLocText("String")}){ - protected void tabChanged(int newSelectedIndex) { -// checkVisible(newSelectedIndex); - //todo - } - }; + returnTypeComboBox = new UIButtonGroup(new String[]{Inter.getLocText("Widget-Array"), Inter.getLocText("String")}); returnTypePane.add(returnTypeComboBox, BorderLayout.CENTER); JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{new UILabel(Inter.getLocText("Widget-Date_Selector_Return_Type") + ":"), returnTypePane}}, TableLayoutHelper.FILL_LASTCOLUMN, 18, 7); this.add(jPanel); 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 b2de5c511e..49a931a6bb 100644 --- a/designer_base/src/com/fr/design/widget/component/BackgroundCompPane.java +++ b/designer_base/src/com/fr/design/widget/component/BackgroundCompPane.java @@ -1,14 +1,13 @@ package com.fr.design.widget.component; import com.fr.design.dialog.BasicPane; -import com.fr.design.gui.ibutton.UIHeadGroup; +import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; 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.AccessibleBackgroundEditor; import com.fr.form.ui.Widget; -import com.fr.general.Background; import com.fr.general.Inter; import javax.swing.*; @@ -18,11 +17,11 @@ import java.awt.*; * Created by ibm on 2017/8/6. */ public abstract class BackgroundCompPane extends BasicPane { - protected UIHeadGroup backgroundHead; + protected UIButtonGroup backgroundHead; protected AccessibleBackgroundEditor initalBackgroundEditor; protected AccessibleBackgroundEditor overBackgroundEditor; protected AccessibleBackgroundEditor clickBackgroundEditor; - + private JPanel panel; public BackgroundCompPane() { initComponent(); @@ -45,27 +44,23 @@ public abstract class BackgroundCompPane extends BasicPane { new Component[]{new UILabel(Inter.getLocText("FR-Designer_Background-Over")), overBackgroundEditor}, new Component[]{new UILabel(Inter.getLocText("FR-Designer_Background-Click")), clickBackgroundEditor}, }; - final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 7, 7); + panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 7, 7); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - backgroundHead = new UIHeadGroup(titles){ - @Override - public void tabChanged(int index) { - //todo - if (index == 1) { - panel.setVisible(true); - }else{ - panel.setVisible(false); - } - } - }; + backgroundHead = new UIButtonGroup(titles); this.add(backgroundHead, BorderLayout.NORTH); this.add(panel, BorderLayout.CENTER); } - public abstract void update(T e); + public void update(T e){ + } + + public void populate(T e){ + } - public abstract void populate(T e); + public void switchCard(){ + panel.setVisible(backgroundHead.getSelectedIndex() == 1); + } } diff --git a/designer_base/src/com/fr/design/widget/component/ButtonBackgroundPane.java b/designer_base/src/com/fr/design/widget/component/ButtonBackgroundPane.java index 35f7d3a077..d1ebfe0b9a 100644 --- a/designer_base/src/com/fr/design/widget/component/ButtonBackgroundPane.java +++ b/designer_base/src/com/fr/design/widget/component/ButtonBackgroundPane.java @@ -25,6 +25,7 @@ public class ButtonBackgroundPane extends BackgroundCompPane { freeButton.setOverBackground((Background) overBackgroundEditor.getValue()); freeButton.setClickBackground((Background)clickBackgroundEditor.getValue()); } + switchCard(); } public void populate(FreeButton freeButton){ @@ -39,6 +40,7 @@ public class ButtonBackgroundPane extends BackgroundCompPane { overBackgroundEditor.setValue(freeButton.getOverBackground()); clickBackgroundEditor.setValue(freeButton.getClickBackground()); } + switchCard(); } protected String title4PopupWindow() { diff --git a/designer_form/src/com/fr/design/widget/ui/designer/CheckBoxGroupDefinePane.java b/designer_form/src/com/fr/design/widget/ui/designer/CheckBoxGroupDefinePane.java index 89397358a0..9609d11feb 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/CheckBoxGroupDefinePane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/CheckBoxGroupDefinePane.java @@ -2,6 +2,7 @@ package com.fr.design.widget.ui.designer; import com.fr.design.data.DataCreatorUI; import com.fr.design.designer.creator.XCreator; +import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; @@ -17,7 +18,7 @@ import java.awt.*; public class CheckBoxGroupDefinePane extends ButtonGroupDefinePane { private DictionaryPane dictPane; - private UIHeadGroup returnType; + private UIButtonGroup returnType; private UICheckBox checkbox; public CheckBoxGroupDefinePane(XCreator xCreator) { @@ -42,18 +43,7 @@ public class CheckBoxGroupDefinePane extends ButtonGroupDefinePane { private UICheckBox supportTagCheckBox; - private UIHeadGroup returnType; + private UIButtonGroup returnType; private UITextField waterMarkDictPane; private UICheckBox removeRepeatCheckBox; @@ -40,18 +41,7 @@ public class ComboCheckBoxDefinePane extends DictEditorDefinePane supportTagCheckBox = new UICheckBox(Inter.getLocText("Form-SupportTag"), true); final String[] tabTitles = new String[]{Inter.getLocText("Widget-Array"), Inter.getLocText("String")}; - returnType = new UIHeadGroup(tabTitles) { - @Override - public void tabChanged(int index) { - ComboCheckBox combo = (ComboCheckBox) creator.toData(); - //todo - if (index == 1) { - combo.setReturnString(true); - } else { - combo.setReturnString(false); - } - } - }; + returnType = new UIButtonGroup(tabTitles) ; double f = TableLayout.FILL; double p = TableLayout.PREFERRED; @@ -68,11 +58,7 @@ public class ComboCheckBoxDefinePane extends DictEditorDefinePane } protected void populateSubDictionaryEditorBean(ComboCheckBox ob){ - if (ob.isReturnString()) { - returnType.setSelectedIndex(1); - } else { - returnType.setSelectedIndex(0); - } + returnType.setSelectedIndex(ob.isReturnString() ? 1 : 0); waterMarkDictPane.setText(ob.getWaterMark()); formWidgetValuePane.populate(ob); this.supportTagCheckBox.setSelected(ob.isSupportTag()); @@ -81,6 +67,7 @@ public class ComboCheckBoxDefinePane extends DictEditorDefinePane protected ComboCheckBox updateSubDictionaryEditorBean(){ ComboCheckBox combo = (ComboCheckBox) creator.toData(); + combo.setReturnString(returnType.getSelectedIndex() == 1); formWidgetValuePane.update(combo); combo.setWaterMark(waterMarkDictPane.getText()); combo.setSupportTag(this.supportTagCheckBox.isSelected()); diff --git a/designer_form/src/com/fr/design/widget/ui/designer/DateEditorDefinePane.java b/designer_form/src/com/fr/design/widget/ui/designer/DateEditorDefinePane.java index 885ede6fc5..ec735a9add 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/DateEditorDefinePane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/DateEditorDefinePane.java @@ -4,6 +4,7 @@ import com.fr.base.FRContext; import com.fr.base.Formula; import com.fr.data.core.FormatField; import com.fr.design.designer.creator.XCreator; +import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; @@ -28,7 +29,7 @@ import java.text.SimpleDateFormat; import java.util.Date; public class DateEditorDefinePane extends DirectWriteEditorDefinePane { - private UIHeadGroup returnTypeComboBox; + private UIButtonGroup returnTypeComboBox; private DateValuePane startDv; private DateValuePane endDv; private WaterMarkDictPane waterMarkDictPane; @@ -55,11 +56,7 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane(new String[] {Inter.getLocText("Date") , Inter.getLocText("String")}); JPanel formatHead = createFormatHead(); startDv = new DateValuePane(); diff --git a/designer_form/src/com/fr/design/widget/ui/designer/component/FormWidgetValuePane.java b/designer_form/src/com/fr/design/widget/ui/designer/component/FormWidgetValuePane.java index 90a5894a2e..9e8396e280 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/component/FormWidgetValuePane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/component/FormWidgetValuePane.java @@ -2,6 +2,7 @@ package com.fr.design.widget.ui.designer.component; import com.fr.design.constants.LayoutConstants; import com.fr.design.editor.editor.*; +import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.mainframe.widget.editors.DataBindingEditor; import com.fr.design.mainframe.widget.editors.DataTableEditor; @@ -19,46 +20,48 @@ import java.awt.*; * Created by ibm on 2017/7/27. */ public class FormWidgetValuePane extends JPanel { - private UIHeadGroup widgetValueHead; + private UIButtonGroup widgetValueHead; private Editor[] editor; + private JPanel customPane; + private CardLayout cardLayout; public FormWidgetValuePane(Object o, boolean onlyServer) { DataControl widget = (DataControl) o; editor = createWidgetValueEditor(widget, onlyServer); this.setLayout(new BorderLayout(0, LayoutConstants.VGAP_SMALL)); - final CardLayout cardLayout = new CardLayout(); - final JPanel customPane = new JPanel(cardLayout); - final String [] tabTitles = new String[editor.length]; - for(int i = 0; i < editor.length; i++){ + cardLayout = new CardLayout(); + customPane = new JPanel(cardLayout); + final String[] tabTitles = new String[editor.length]; + for (int i = 0; i < editor.length; i++) { customPane.add(editor[i], editor[i].getName()); tabTitles[i] = editor[i].getName(); } - widgetValueHead = new UIHeadGroup(tabTitles) { - @Override - public void tabChanged(int index) { - //todo - attributeChange(index, customPane, cardLayout, tabTitles); - } - }; + widgetValueHead = new UIButtonGroup(tabTitles); this.add(widgetValueHead, BorderLayout.NORTH); this.add(customPane, BorderLayout.CENTER); } - public void attributeChange(int index, JPanel customPane, CardLayout cardLayout, String[] tabTitles){ - if (ComparatorUtils.equals(tabTitles[index], Inter.getLocText("FR-Designer_Widget_Field"))) { + public void attributeChange() { + int index = widgetValueHead.getSelectedIndex(); + if (index == -1) { + index = 0; + widgetValueHead.setSelectedIndex(index); + } + if (ComparatorUtils.equals(editor[index].getName(), Inter.getLocText("FR-Designer_Widget_Field"))) { customPane.setPreferredSize(new Dimension(100, 47)); } else { customPane.setPreferredSize(new Dimension(100, 20)); } - cardLayout.show(customPane, tabTitles[index]); + cardLayout.show(customPane, editor[index].getName()); } /** * 根据类型创建 - * @param type 类型 + * + * @param type 类型 * @param onlyServer 是否是服务器 * @return 编辑器 */ @@ -73,7 +76,7 @@ public class FormWidgetValuePane extends JPanel { case DataControl.TYPE_STRING: return new com.fr.design.editor.editor.TextEditor(); case DataControl.TYPE_BOOLEAN: - return new BooleanEditor(false); + return new BooleanEditor(false); case DataControl.TYPE_DATE: return new DateEditor(true, Inter.getLocText("Date")); case DataControl.TYPE_TABLEDATA: @@ -86,13 +89,14 @@ public class FormWidgetValuePane extends JPanel { /** * 用DataControl构建 - * @param data 数据 + * + * @param data 数据 * @param onlyServer 是否是服务器 * @return 编辑器 */ public static Editor[] createWidgetValueEditor(DataControl data, boolean onlyServer) { int types[] = data.getValueType(); - Editor[] editor = new Editor[types.length ]; + Editor[] editor = new Editor[types.length]; for (int i = 0; i < types.length; i++) { editor[i] = createWidgetValueEditorByType(types[i], onlyServer); @@ -101,6 +105,7 @@ public class FormWidgetValuePane extends JPanel { } public void update(DataControl ob) { + attributeChange(); int index = widgetValueHead.getSelectedIndex(); Editor e = editor[index]; Object value = e.getValue(); @@ -109,18 +114,18 @@ public class FormWidgetValuePane extends JPanel { public void populate(DataControl ob) { WidgetValue widgetValue = ob.getWidgetValue(); - if(widgetValue == null){ - return; - } - for (int i = 0; i < editor.length; i++) { - if (editor[i].accept(widgetValue.getValue())) { - setCardValue(i, widgetValue.getValue()); - break; + if (widgetValue != null) { + for (int i = 0; i < editor.length; i++) { + if (editor[i].accept(widgetValue.getValue())) { + setCardValue(i, widgetValue.getValue()); + break; + } } } + attributeChange(); } - private void setCardValue(int i, Object object){ + private void setCardValue(int i, Object object) { widgetValueHead.setSelectedIndex(i); editor[i].setValue(object); // kunsnat: bug7861 所有的Editor值都要跟随改变, 因为populate的editor 从"" 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 2fde734f57..b52069b570 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 @@ -26,6 +26,7 @@ public class TabFitLayoutBackgroundPane extends BackgroundCompPane