Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Radio widgets instead of combos for options less than 4
  • Loading branch information
samuell committed Aug 22, 2011
1 parent b5e3eb4 commit f315210
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Expand Up @@ -24,10 +24,12 @@
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Widget;
Expand Down Expand Up @@ -123,9 +125,15 @@ private void createWidgetsForParam(Parameter parameter) {
}

// This is a way to recognize fields for specifying "input data file"
// TODO Use more different kinds of widgets here

int optionsCnt = parameter.getSelectOptions().size();

if (type.equals("data")) {
createSelectRemoteFileForParam(parameter);
} else if (type.equals("select")) {
} else if (type.equals("select") && optionsCnt < 4) {
createRadioButtonsForParam(parameter, 2);
} else if (type.equals("select") && optionsCnt >= 4) {
createComboBoxForParam(parameter, 2);
} else {
createTextFieldForParam(parameter, 2);
Expand All @@ -135,6 +143,26 @@ private void createWidgetsForParam(Parameter parameter) {
}
}

private void createRadioButtonsForParam(Parameter parameter, int i) {
List<String> selectOptions = parameter.getSelectOptionValues();
Group radioGroup = new Group(composite, SWT.HORIZONTAL);
radioGroup.setLayout(new RowLayout());
// radioGroup.setText(parameter.getName());

GridData layoutData = new GridData();
layoutData.horizontalSpan = i;
radioGroup.setLayoutData(layoutData);

for (String optionValue : selectOptions) {

Button btn = new Button(radioGroup, SWT.RADIO);
btn.setText(optionValue);
// Event handling stuff
btn.addListener(SWT.Selection, this);
btn.setData(parameter);
}
}

private void createLabel(String labelText) {
StyledText fieldLabel = new StyledText(this.composite, SWT.RIGHT | SWT.WRAP | SWT.READ_ONLY );
labelText = HPCUtils.ensureEndsWithColon(labelText);
Expand Down
Expand Up @@ -4,6 +4,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.internal.RadioMenu;

public class Utils {

Expand All @@ -15,5 +16,5 @@ public static Combo createCombo(Composite composite) {
combo.setLayoutData(gridData);
return combo;
}

}

0 comments on commit f315210

Please sign in to comment.