Column controlGroupsColumn = new Column();
controlGroupsColumn.setCellSpacing(new Extent(5));
controlGroupsColumn.setStyleName("TestControlsColumn");
add(controlGroupsColumn);
final TestGrid testGrid = new TestGrid();
splitPaneLayoutData = new SplitPaneLayoutData();
splitPaneLayoutData.setInsets(new Insets(15));
testGrid.setLayoutData(splitPaneLayoutData);
add(testGrid);
buttonList = new ArrayList();
Button button;
testGrid.addHeaderRow("Button");
button = new Button();
testGrid.addTestRow("No Content", button);
buttonList.add(button);
button = new Button("Test Button");
testGrid.addTestRow("Text", button);
buttonList.add(button);
button = new Button(Styles.ICON_LOGO);
testGrid.addTestRow("Icon", button);
buttonList.add(button);
button = new Button("Test Button", Styles.ICON_LOGO);
testGrid.addTestRow("Text and Icon", button);
buttonList.add(button);
CheckBox checkBox;
testGrid.addHeaderRow("CheckBox");
checkBox = new CheckBox();
testGrid.addTestRow("No Content", checkBox);
buttonList.add(checkBox);
checkBox = new CheckBox("Test CheckBox");
testGrid.addTestRow("Text", checkBox);
buttonList.add(checkBox);
checkBox = new CheckBox(Styles.ICON_LOGO);
testGrid.addTestRow("Icon", checkBox);
buttonList.add(checkBox);
checkBox = new CheckBox("Test CheckBox", Styles.ICON_LOGO);
testGrid.addTestRow("Text and Icon", checkBox);
buttonList.add(checkBox);
RadioButton radioButton;
testGrid.addHeaderRow("RadioButton");
ButtonGroup buttonGroup = new ButtonGroup();
radioButton = new RadioButton();
radioButton.setGroup(buttonGroup);
testGrid.addTestRow("No Content", radioButton);
buttonList.add(radioButton);
radioButton = new RadioButton("Test RadioButton");
radioButton.setGroup(buttonGroup);
testGrid.addTestRow("Text", radioButton);
buttonList.add(radioButton);
radioButton = new RadioButton(Styles.ICON_LOGO);
radioButton.setGroup(buttonGroup);
testGrid.addTestRow("Icon", radioButton);
buttonList.add(radioButton);
radioButton = new RadioButton("Test RadioButton", Styles.ICON_LOGO);
radioButton.setGroup(buttonGroup);
testGrid.addTestRow("Text and Icon", radioButton);
buttonList.add(radioButton);
buttonGroup = new ButtonGroup();
Grid radioGrid = new Grid();
radioGrid.setInsets(new Insets(10));
for (int i = 1; i <= 4; ++i) {
radioButton = new RadioButton(Integer.toString(i));
radioButton.setGroup(buttonGroup);
radioGrid.add(radioButton);
buttonList.add(radioButton);
}
testGrid.addTestRow("Separate ButtonGroup", radioGrid);
radioButton = new RadioButton("Test");
buttonList.add(radioButton);
testGrid.addTestRow("Null ButtonGroup", radioButton);
ButtonColumn controlsColumn;
// Create 'AbstractButton Controls Group'
controlsColumn = new ButtonColumn();
controlGroupsColumn.add(controlsColumn);
controlsColumn.add(new Label("General Settings"));
controlsColumn.addButton("Toggle Container Cell Spacing", new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (testGrid.getInsets() != null && testGrid.getInsets().getTop().equals(new Extent(5))) {
testGrid.setInsets(new Insets(0));
} else {
testGrid.setInsets(new Insets(5));
}
}
});
controlsColumn.addButton("Add ActionListener", new ActionListener() {
public void actionPerformed(ActionEvent e) {
apply(new Applicator() {
public void apply(AbstractButton button) {
button.addActionListener(actionListener);
}
});
}
});
controlsColumn.addButton("Remove ActionListener", new ActionListener() {
public void actionPerformed(ActionEvent e) {
apply(new Applicator() {
public void apply(AbstractButton button) {
button.removeActionListener(actionListener);
}
});
}
});
controlsColumn.addButton("Add ChangeListener", new ActionListener() {
public void actionPerformed(ActionEvent e) {
apply(new Applicator() {
public void apply(AbstractButton button) {
if (button instanceof ToggleButton) {
((ToggleButton) button).addChangeListener(changeListener);
}
}
});
}
});
controlsColumn.addButton("Remove ChangeListener", new ActionListener() {
public void actionPerformed(ActionEvent e) {
apply(new Applicator() {
public void apply(AbstractButton button) {
if (button instanceof ToggleButton) {
((ToggleButton) button).removeChangeListener(changeListener);
}
}
});
}
});
controlsColumn.addButton("Set StyleName = Null", new ActionListener() {
public void actionPerformed(ActionEvent e) {
apply(new Applicator() {
public void apply(AbstractButton button) {
button.setStyleName(null);
}
});
}
});
controlsColumn.addButton("Set StyleName = Default", new ActionListener() {
public void actionPerformed(ActionEvent e) {
apply(new Applicator() {
public void apply(AbstractButton button) {
button.setStyleName("Default");
}
});
}
});
controlsColumn.addButton("Set Text = Short", new ActionListener() {
public void actionPerformed(ActionEvent e) {
apply(new Applicator() {
public void apply(AbstractButton button) {
if (button.getText() != null) {
button.setText("Test Button");
}
}
});
}
});
controlsColumn.addButton("Set Text = Long", new ActionListener() {
public void actionPerformed(ActionEvent e) {
apply(new Applicator() {
public void apply(AbstractButton button) {
if (button.getText() != null) {
button.setText("This button has a longer label. The quick brown fox jumps over the lazy brown dog.");
}
}
});
}
});
controlsColumn.addButton("Toggle ToolTip Text", new ActionListener(){
public void actionPerformed(ActionEvent e) {
apply(new Applicator() {
public void apply(AbstractButton button) {
if (button.getToolTipText() == null) {
button.setToolTipText("This is a tool tip.");
} else {
button.setToolTipText(null);
}
}
});
}
});
controlsColumn.addButton("Toggle Enabled State", new ActionListener() {
public void actionPerformed(ActionEvent e) {
apply(new Applicator() {
public void apply(AbstractButton button) {
button.setEnabled(!button.isEnabled());
}
});
}
});
controlsColumn.addButton("Toggle Enabled State (Container)", new ActionListener() {
public void actionPerformed(ActionEvent e) {
testGrid.setEnabled(!testGrid.isEnabled());
}
});
controlsColumn = new ButtonColumn();
controlGroupsColumn.add(controlsColumn);