|
|
@ -6,6 +6,7 @@ import com.fr.design.gui.ibutton.UIRadioButton; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
|
|
|
|
import com.fr.general.data.index.Index; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.*; |
|
|
@ -19,7 +20,7 @@ import java.util.List; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class MobileRadioGroupPane extends BasicBeanPane<MobileFitAttrState>{ |
|
|
|
public class MobileRadioGroupPane extends BasicBeanPane<MobileFitAttrState>{ |
|
|
|
|
|
|
|
|
|
|
|
private List<RadioButton> radioButtons = new ArrayList<RadioButton>(); |
|
|
|
private List<IndexRadioButton> radioButtons = new ArrayList<IndexRadioButton>(); |
|
|
|
|
|
|
|
|
|
|
|
public MobileRadioGroupPane(String title) { |
|
|
|
public MobileRadioGroupPane(String title) { |
|
|
|
initComponents(title); |
|
|
|
initComponents(title); |
|
|
@ -30,23 +31,23 @@ public class MobileRadioGroupPane extends BasicBeanPane<MobileFitAttrState>{ |
|
|
|
double[] rowSize = {p}; |
|
|
|
double[] rowSize = {p}; |
|
|
|
double[] columnSize = {p, p, p, p, p, p}; |
|
|
|
double[] columnSize = {p, p, p, p, p, p}; |
|
|
|
|
|
|
|
|
|
|
|
RadioButton defaultRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.DEFAULT.description()), MobileFitAttrState.DEFAULT); |
|
|
|
IndexRadioButton defaultRadio = new IndexRadioButton(MobileFitAttrState.DEFAULT.description(), MobileFitAttrState.DEFAULT); |
|
|
|
defaultRadio.getRadioButton().setSelected(true); |
|
|
|
defaultRadio.setSelected(true); |
|
|
|
RadioButton horizonRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.HORIZONTAL.description()), MobileFitAttrState.HORIZONTAL); |
|
|
|
IndexRadioButton horizonRadio = new IndexRadioButton(MobileFitAttrState.HORIZONTAL.description(), MobileFitAttrState.HORIZONTAL); |
|
|
|
RadioButton verticalRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.VERTICAL.description()), MobileFitAttrState.VERTICAL); |
|
|
|
IndexRadioButton verticalRadio = new IndexRadioButton(MobileFitAttrState.VERTICAL.description(), MobileFitAttrState.VERTICAL); |
|
|
|
RadioButton bidirectionalRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.BIDIRECTIONAL.description()), MobileFitAttrState.BIDIRECTIONAL); |
|
|
|
IndexRadioButton bidirectionalRadio = new IndexRadioButton(MobileFitAttrState.BIDIRECTIONAL.description(), MobileFitAttrState.BIDIRECTIONAL); |
|
|
|
RadioButton notFitRadio = new RadioButton(new UIRadioButton(MobileFitAttrState.NONE.description()), MobileFitAttrState.NONE); |
|
|
|
IndexRadioButton notFitRadio = new IndexRadioButton(MobileFitAttrState.NONE.description(), MobileFitAttrState.NONE); |
|
|
|
|
|
|
|
|
|
|
|
addToButtonGroup(defaultRadio, horizonRadio, verticalRadio, notFitRadio, bidirectionalRadio); |
|
|
|
addToButtonGroup(defaultRadio, horizonRadio, verticalRadio, notFitRadio, bidirectionalRadio); |
|
|
|
|
|
|
|
|
|
|
|
Component[][] components = new Component[][]{ |
|
|
|
Component[][] components = new Component[][]{ |
|
|
|
new Component[] { |
|
|
|
new Component[] { |
|
|
|
new UILabel(title), |
|
|
|
new UILabel(title), |
|
|
|
defaultRadio.getRadioButton(), |
|
|
|
defaultRadio, |
|
|
|
horizonRadio.getRadioButton(), |
|
|
|
horizonRadio, |
|
|
|
verticalRadio.getRadioButton(), |
|
|
|
verticalRadio, |
|
|
|
bidirectionalRadio.getRadioButton(), |
|
|
|
bidirectionalRadio, |
|
|
|
notFitRadio.getRadioButton() |
|
|
|
notFitRadio |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
JPanel fitOpsPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
|
|
|
JPanel fitOpsPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
|
|
@ -54,11 +55,11 @@ public class MobileRadioGroupPane extends BasicBeanPane<MobileFitAttrState>{ |
|
|
|
this.add(fitOpsPane); |
|
|
|
this.add(fitOpsPane); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void addToButtonGroup(RadioButton... radios) { |
|
|
|
private void addToButtonGroup(IndexRadioButton... radios) { |
|
|
|
ButtonGroup buttonGroup = new ButtonGroup(); |
|
|
|
ButtonGroup buttonGroup = new ButtonGroup(); |
|
|
|
for (RadioButton radio : radios) { |
|
|
|
for (IndexRadioButton radio : radios) { |
|
|
|
radioButtons.add(radio); |
|
|
|
radioButtons.add(radio); |
|
|
|
buttonGroup.add(radio.getRadioButton()); |
|
|
|
buttonGroup.add(radio); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -66,8 +67,8 @@ public class MobileRadioGroupPane extends BasicBeanPane<MobileFitAttrState>{ |
|
|
|
* 设置按钮状态 |
|
|
|
* 设置按钮状态 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setEnabled(boolean enabled) { |
|
|
|
public void setEnabled(boolean enabled) { |
|
|
|
for (RadioButton radioButton : radioButtons) { |
|
|
|
for (IndexRadioButton radioButton : radioButtons) { |
|
|
|
radioButton.getRadioButton().setEnabled(enabled); |
|
|
|
radioButton.setEnabled(enabled); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -78,7 +79,7 @@ public class MobileRadioGroupPane extends BasicBeanPane<MobileFitAttrState>{ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public int getSelectRadioIndex() { |
|
|
|
public int getSelectRadioIndex() { |
|
|
|
for (int i = 0, len = radioButtons.size(); i < len; i++) { |
|
|
|
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(); |
|
|
|
return radioButtons.get(i).getRadioButtonIndex(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -94,9 +95,9 @@ public class MobileRadioGroupPane extends BasicBeanPane<MobileFitAttrState>{ |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (RadioButton radioButton : this.radioButtons) { |
|
|
|
for (IndexRadioButton radioButton : this.radioButtons) { |
|
|
|
if (radioButton.getRadioButtonIndex() == index) { |
|
|
|
if (radioButton.getRadioButtonIndex() == index) { |
|
|
|
radioButton.getRadioButton().setSelected(true); |
|
|
|
radioButton.setSelected(true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -105,8 +106,8 @@ public class MobileRadioGroupPane extends BasicBeanPane<MobileFitAttrState>{ |
|
|
|
* 给所有的按钮加上监听 |
|
|
|
* 给所有的按钮加上监听 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void addActionListener(ActionListener actionListener) { |
|
|
|
public void addActionListener(ActionListener actionListener) { |
|
|
|
for (RadioButton radioButton : radioButtons) { |
|
|
|
for (IndexRadioButton radioButton : radioButtons) { |
|
|
|
radioButton.getRadioButton().addActionListener(actionListener); |
|
|
|
radioButton.addActionListener(actionListener); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -131,23 +132,14 @@ public class MobileRadioGroupPane extends BasicBeanPane<MobileFitAttrState>{ |
|
|
|
* created by fanglei on 2017/1/16 |
|
|
|
* created by fanglei on 2017/1/16 |
|
|
|
* 不再用radioButtonGroup的数组下标作为index,而是给每个按钮传入MobileFitAttrState的枚举值 |
|
|
|
* 不再用radioButtonGroup的数组下标作为index,而是给每个按钮传入MobileFitAttrState的枚举值 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class RadioButton { |
|
|
|
class IndexRadioButton extends UIRadioButton { |
|
|
|
private UIRadioButton radioButton; |
|
|
|
|
|
|
|
private int index; |
|
|
|
private int index; |
|
|
|
|
|
|
|
|
|
|
|
RadioButton(UIRadioButton radioButton, MobileFitAttrState mobileFitAttrState) { |
|
|
|
IndexRadioButton(String text, MobileFitAttrState mobileFitAttrState) { |
|
|
|
this.radioButton = radioButton; |
|
|
|
super(text); |
|
|
|
this.index = mobileFitAttrState.getState(); |
|
|
|
this.index = mobileFitAttrState.getState(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public UIRadioButton getRadioButton() { |
|
|
|
|
|
|
|
return this.radioButton; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setUIReadioButton(UIRadioButton radioButton) { |
|
|
|
|
|
|
|
this.radioButton = radioButton; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getRadioButtonIndex() { |
|
|
|
public int getRadioButtonIndex() { |
|
|
|
return this.index; |
|
|
|
return this.index; |
|
|
|
} |
|
|
|
} |
|
|
|