From 768035300aa9ed5887d003aa3f8ce89cb2b6f23c Mon Sep 17 00:00:00 2001 From: fanglei <294531121> Date: Tue, 17 Jan 2017 10:53:06 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E5=8F=8C?= =?UTF-8?q?=E5=90=91=E8=87=AA=E9=80=82=E5=BA=94=E5=92=8C=E4=B8=8D=E8=87=AA?= =?UTF-8?q?=E9=80=82=E5=BA=94=E6=8C=89=E9=92=AE=E7=9A=84=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/mobile/MobileRadioGroupPane.java | 78 ++++++++++++++----- 1 file changed, 59 insertions(+), 19 deletions(-) diff --git a/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java b/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java index f03b72626..7878451cf 100644 --- a/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java +++ b/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java @@ -19,7 +19,7 @@ import java.util.List; */ public class MobileRadioGroupPane extends BasicBeanPane{ - private List radioButtons = new ArrayList(); + private List radioButtons = new ArrayList(); public MobileRadioGroupPane(String title) { initComponents(title); @@ -30,28 +30,35 @@ public class MobileRadioGroupPane extends BasicBeanPane{ double[] rowSize = {p}; double[] columnSize = {p, p, p, p, p, p}; - UIRadioButton defaultRadio = new UIRadioButton(MobileFitAttrState.DEFAULT.description()); - defaultRadio.setSelected(true); - UIRadioButton horizonRadio = new UIRadioButton(MobileFitAttrState.HORIZONTAL.description()); - UIRadioButton verticalRadio = new UIRadioButton(MobileFitAttrState.VERTICAL.description()); - UIRadioButton bidirectionalRadio = new UIRadioButton(MobileFitAttrState.BIDIRECTIONAL.description()); - UIRadioButton notFitRadio = new UIRadioButton(MobileFitAttrState.NONE.description()); + RadioButton defaultRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.DEFAULT.description()), MobileFitAttrState.DEFAULT.getState()); + defaultRadio.getRadioButton().setSelected(true); + RadioButton horizonRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.HORIZONTAL.description()), MobileFitAttrState.HORIZONTAL.getState()); + RadioButton verticalRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.VERTICAL.description()), MobileFitAttrState.VERTICAL.getState()); + RadioButton bidirectionalRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.BIDIRECTIONAL.description()), MobileFitAttrState.BIDIRECTIONAL.getState()); + RadioButton notFitRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.NONE.description()), MobileFitAttrState.NONE.getState()); addToButtonGroup(defaultRadio, horizonRadio, verticalRadio, notFitRadio, bidirectionalRadio); Component[][] components = new Component[][]{ - new Component[]{new UILabel(title), defaultRadio, horizonRadio, verticalRadio, notFitRadio, bidirectionalRadio} + new Component[] { + new UILabel(title), + defaultRadio.getRadioButton(), + horizonRadio.getRadioButton(), + verticalRadio.getRadioButton(), + bidirectionalRadio.getRadioButton(), + notFitRadio.getRadioButton() + } }; JPanel fitOpsPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); fitOpsPane.setBorder(BorderFactory.createEmptyBorder(10, 13, 10, 10)); this.add(fitOpsPane); } - private void addToButtonGroup(UIRadioButton... radios) { + private void addToButtonGroup(RadioButton... radios) { ButtonGroup buttonGroup = new ButtonGroup(); - for (UIRadioButton radio : radios) { + for (RadioButton radio : radios) { radioButtons.add(radio); - buttonGroup.add(radio); + buttonGroup.add(radio.getRadioButton()); } } @@ -59,8 +66,8 @@ public class MobileRadioGroupPane extends BasicBeanPane{ * 设置按钮状态 */ public void setEnabled(boolean enabled) { - for (UIRadioButton radioButton : radioButtons) { - radioButton.setEnabled(enabled); + for (RadioButton radioButton : radioButtons) { + radioButton.getRadioButton().setEnabled(enabled); } } @@ -71,8 +78,8 @@ public class MobileRadioGroupPane extends BasicBeanPane{ */ public int getSelectRadioIndex() { for (int i = 0, len = radioButtons.size(); i < len; i++) { - if (radioButtons.get(i).isSelected()) { - return i; + if (radioButtons.get(i).getRadioButton().isSelected()) { + return radioButtons.get(i).getRadioButtonIndex(); } } @@ -87,16 +94,19 @@ public class MobileRadioGroupPane extends BasicBeanPane{ return; } - UIRadioButton button = radioButtons.get(index); - button.setSelected(true); + for (RadioButton radioButton : this.radioButtons) { + if (radioButton.getRadioButtonIndex() == index) { + radioButton.getRadioButton().setSelected(true); + } + } } /** * 给所有的按钮加上监听 */ public void addActionListener(ActionListener actionListener) { - for (UIRadioButton radioButton : radioButtons) { - radioButton.addActionListener(actionListener); + for (RadioButton radioButton : radioButtons) { + radioButton.getRadioButton().addActionListener(actionListener); } } @@ -116,3 +126,33 @@ public class MobileRadioGroupPane extends BasicBeanPane{ return StringUtils.EMPTY; } } + +/** + * created by fanglei on 2017/1/16 + * 不再用radioButtonGroup的数组下标作为index,而是给每个按钮传入MobileFitAttrState的枚举值 + */ +class RadioButton { + private UIRadioButton radioButton; + private int index; + + RadioButton(UIRadioButton radioButton, int index) { + this.radioButton = radioButton; + this.index = index; + } + + public UIRadioButton getRadioButton() { + return this.radioButton; + } + + public void setUIReadioButton(UIRadioButton radioButton) { + this.radioButton = radioButton; + } + + public int getRadioButtonIndex() { + return this.index; + } + + public void setRadioButtonIndex(int index) { + this.index = index; + } +} From 47a758f0b1c12d3dd9d0d1c715db2ac210d24668 Mon Sep 17 00:00:00 2001 From: fanglei <294531121> Date: Tue, 17 Jan 2017 17:13:15 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=A1=A8=E5=8D=95=E7=9A=84=E5=8F=8C?= =?UTF-8?q?=E5=90=91=E8=87=AA=E9=80=82=E5=BA=94=E5=92=8C=E4=B8=8D=E8=87=AA?= =?UTF-8?q?=E9=80=82=E5=BA=94=E9=A1=BA=E5=BA=8F=E5=BF=98=E8=AE=B0=E6=94=B9?= =?UTF-8?q?=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../properties/mobile/MobileFitAlignmentItems.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java index 552589b71..8926befde 100644 --- a/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java +++ b/designer_form/src/com/fr/design/designer/properties/mobile/MobileFitAlignmentItems.java @@ -9,12 +9,14 @@ public class MobileFitAlignmentItems implements ItemProvider { private static Item[] VALUE_ITEMS; static { - MobileFitAttrState[] allStates = MobileFitAttrState.values(); - int len = allStates.length; - VALUE_ITEMS = new Item[len]; - for (int i = 0; i < len ; i++) { - VALUE_ITEMS[i] = new Item(allStates[i].description(), allStates[i]); - } +// 此处不能循环根据MobileFitAttrState的枚举顺序创建items,否则不自适应选项就会跑到双向自适应选项前面。 + VALUE_ITEMS = new Item[]{ + new Item(MobileFitAttrState.DEFAULT.description(), MobileFitAttrState.DEFAULT), + new Item(MobileFitAttrState.HORIZONTAL.description(), MobileFitAttrState.HORIZONTAL), + new Item(MobileFitAttrState.VERTICAL.description(), MobileFitAttrState.VERTICAL), + new Item(MobileFitAttrState.BIDIRECTIONAL.description(), MobileFitAttrState.BIDIRECTIONAL), + new Item(MobileFitAttrState.NONE.description(), MobileFitAttrState.NONE) + }; } @Override From c32b292e35eedeacc11a53659bd2a34e962b20d3 Mon Sep 17 00:00:00 2001 From: fanglei <294531121> Date: Tue, 17 Jan 2017 17:21:50 +0800 Subject: [PATCH 3/4] =?UTF-8?q?RadioButton=E7=9A=84=E6=9E=84=E9=80=A0?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E7=9A=84=E7=AC=AC=E4=BA=8C=E4=B8=AA=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=BF=AE=E6=94=B9=E4=B8=BAMobileFitAttrState?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/report/mobile/MobileRadioGroupPane.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java b/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java index 7878451cf..638abc768 100644 --- a/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java +++ b/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java @@ -30,12 +30,12 @@ public class MobileRadioGroupPane extends BasicBeanPane{ double[] rowSize = {p}; double[] columnSize = {p, p, p, p, p, p}; - RadioButton defaultRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.DEFAULT.description()), MobileFitAttrState.DEFAULT.getState()); + RadioButton defaultRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.DEFAULT.description()), MobileFitAttrState.DEFAULT); defaultRadio.getRadioButton().setSelected(true); - RadioButton horizonRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.HORIZONTAL.description()), MobileFitAttrState.HORIZONTAL.getState()); - RadioButton verticalRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.VERTICAL.description()), MobileFitAttrState.VERTICAL.getState()); - RadioButton bidirectionalRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.BIDIRECTIONAL.description()), MobileFitAttrState.BIDIRECTIONAL.getState()); - RadioButton notFitRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.NONE.description()), MobileFitAttrState.NONE.getState()); + RadioButton horizonRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.HORIZONTAL.description()), MobileFitAttrState.HORIZONTAL); + RadioButton verticalRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.VERTICAL.description()), MobileFitAttrState.VERTICAL); + RadioButton bidirectionalRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.BIDIRECTIONAL.description()), MobileFitAttrState.BIDIRECTIONAL); + RadioButton notFitRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.NONE.description()), MobileFitAttrState.NONE); addToButtonGroup(defaultRadio, horizonRadio, verticalRadio, notFitRadio, bidirectionalRadio); @@ -135,9 +135,9 @@ class RadioButton { private UIRadioButton radioButton; private int index; - RadioButton(UIRadioButton radioButton, int index) { + RadioButton(UIRadioButton radioButton, MobileFitAttrState mobileFitAttrState) { this.radioButton = radioButton; - this.index = index; + this.index = mobileFitAttrState.getState(); } public UIRadioButton getRadioButton() { From ecdb72d4f4aa276443b18bb52e63d206ad0dbb2f Mon Sep 17 00:00:00 2001 From: fanglei <294531121> Date: Wed, 18 Jan 2017 10:31:06 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=B8=8D=E5=86=8D=E7=8B=AC=E8=87=AA?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=B8=A6index=E7=9A=84=E9=80=89=E9=A1=B9?= =?UTF-8?q?=E6=8C=89=E9=92=AE=EF=BC=8C=E8=80=8C=E6=98=AF=E7=BB=A7=E6=89=BF?= =?UTF-8?q?=E8=87=AAUIRadioButton?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/mobile/MobileRadioGroupPane.java | 60 ++++++++----------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java b/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java index 638abc768..68446abc9 100644 --- a/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java +++ b/designer/src/com/fr/design/report/mobile/MobileRadioGroupPane.java @@ -6,6 +6,7 @@ import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.general.data.index.Index; import com.fr.stable.StringUtils; import javax.swing.*; @@ -19,7 +20,7 @@ import java.util.List; */ public class MobileRadioGroupPane extends BasicBeanPane{ - private List radioButtons = new ArrayList(); + private List radioButtons = new ArrayList(); public MobileRadioGroupPane(String title) { initComponents(title); @@ -30,23 +31,23 @@ public class MobileRadioGroupPane extends BasicBeanPane{ double[] rowSize = {p}; double[] columnSize = {p, p, p, p, p, p}; - RadioButton defaultRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.DEFAULT.description()), MobileFitAttrState.DEFAULT); - defaultRadio.getRadioButton().setSelected(true); - RadioButton horizonRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.HORIZONTAL.description()), MobileFitAttrState.HORIZONTAL); - RadioButton verticalRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.VERTICAL.description()), MobileFitAttrState.VERTICAL); - RadioButton bidirectionalRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.BIDIRECTIONAL.description()), MobileFitAttrState.BIDIRECTIONAL); - RadioButton notFitRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.NONE.description()), MobileFitAttrState.NONE); + IndexRadioButton defaultRadio = new IndexRadioButton(MobileFitAttrState.DEFAULT.description(), MobileFitAttrState.DEFAULT); + defaultRadio.setSelected(true); + IndexRadioButton horizonRadio = new IndexRadioButton(MobileFitAttrState.HORIZONTAL.description(), MobileFitAttrState.HORIZONTAL); + IndexRadioButton verticalRadio = new IndexRadioButton(MobileFitAttrState.VERTICAL.description(), MobileFitAttrState.VERTICAL); + IndexRadioButton bidirectionalRadio = new IndexRadioButton(MobileFitAttrState.BIDIRECTIONAL.description(), MobileFitAttrState.BIDIRECTIONAL); + IndexRadioButton notFitRadio = new IndexRadioButton(MobileFitAttrState.NONE.description(), MobileFitAttrState.NONE); addToButtonGroup(defaultRadio, horizonRadio, verticalRadio, notFitRadio, bidirectionalRadio); Component[][] components = new Component[][]{ new Component[] { new UILabel(title), - defaultRadio.getRadioButton(), - horizonRadio.getRadioButton(), - verticalRadio.getRadioButton(), - bidirectionalRadio.getRadioButton(), - notFitRadio.getRadioButton() + defaultRadio, + horizonRadio, + verticalRadio, + bidirectionalRadio, + notFitRadio } }; JPanel fitOpsPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); @@ -54,11 +55,11 @@ public class MobileRadioGroupPane extends BasicBeanPane{ this.add(fitOpsPane); } - private void addToButtonGroup(RadioButton... radios) { + private void addToButtonGroup(IndexRadioButton... radios) { ButtonGroup buttonGroup = new ButtonGroup(); - for (RadioButton radio : radios) { + for (IndexRadioButton radio : radios) { radioButtons.add(radio); - buttonGroup.add(radio.getRadioButton()); + buttonGroup.add(radio); } } @@ -66,8 +67,8 @@ public class MobileRadioGroupPane extends BasicBeanPane{ * 设置按钮状态 */ public void setEnabled(boolean enabled) { - for (RadioButton radioButton : radioButtons) { - radioButton.getRadioButton().setEnabled(enabled); + for (IndexRadioButton radioButton : radioButtons) { + radioButton.setEnabled(enabled); } } @@ -78,7 +79,7 @@ public class MobileRadioGroupPane extends BasicBeanPane{ */ public int getSelectRadioIndex() { for (int i = 0, len = radioButtons.size(); i < len; i++) { - if (radioButtons.get(i).getRadioButton().isSelected()) { + if (radioButtons.get(i).isSelected()) { return radioButtons.get(i).getRadioButtonIndex(); } } @@ -94,9 +95,9 @@ public class MobileRadioGroupPane extends BasicBeanPane{ return; } - for (RadioButton radioButton : this.radioButtons) { + for (IndexRadioButton radioButton : this.radioButtons) { if (radioButton.getRadioButtonIndex() == index) { - radioButton.getRadioButton().setSelected(true); + radioButton.setSelected(true); } } } @@ -105,8 +106,8 @@ public class MobileRadioGroupPane extends BasicBeanPane{ * 给所有的按钮加上监听 */ public void addActionListener(ActionListener actionListener) { - for (RadioButton radioButton : radioButtons) { - radioButton.getRadioButton().addActionListener(actionListener); + for (IndexRadioButton radioButton : radioButtons) { + radioButton.addActionListener(actionListener); } } @@ -131,23 +132,14 @@ public class MobileRadioGroupPane extends BasicBeanPane{ * created by fanglei on 2017/1/16 * 不再用radioButtonGroup的数组下标作为index,而是给每个按钮传入MobileFitAttrState的枚举值 */ -class RadioButton { - private UIRadioButton radioButton; +class IndexRadioButton extends UIRadioButton { private int index; - RadioButton(UIRadioButton radioButton, MobileFitAttrState mobileFitAttrState) { - this.radioButton = radioButton; + IndexRadioButton(String text, MobileFitAttrState mobileFitAttrState) { + super(text); this.index = mobileFitAttrState.getState(); } - public UIRadioButton getRadioButton() { - return this.radioButton; - } - - public void setUIReadioButton(UIRadioButton radioButton) { - this.radioButton = radioButton; - } - public int getRadioButtonIndex() { return this.index; }