Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,67 @@ public void createControl(Composite parent) {

Tree tree = new Tree(composite, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL
| SWT.H_SCROLL);
tree.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
tree.setLayoutData(new GridData(GridData.FILL_BOTH));

TreeItem selectAllItem = new TreeItem(tree, SWT.NONE);
selectAllItem.setText(WizardsMessages.GenerateStepsCheckboxAllScenarios);
selectAllItem.setChecked(false);

for (NewStep step : steps()) {
TreeItem item = new TreeItem(tree, SWT.NONE);
TreeItem item = new TreeItem(selectAllItem, SWT.NONE);
item.setData(step);
item.setText(step.asString());
item.setChecked(false);
}
tree.setSize(100, 100);
selectAllItem.setExpanded(true);

tree.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem item = (TreeItem) e.item;
NewStep step = (NewStep) item.getData();
if ( item.getChecked() ) {
selectedSteps.add(step);

if (item.getParentItem() != null) {
// Leaf item selected

if (item.getChecked()) {
selectedSteps.add(step);

TreeItem selectAllItem = item.getParentItem();
TreeItem[] childItems = selectAllItem.getItems();

boolean allChecked = true;
// Verify if "All Scenarios" checkbox needs selection
for (int i = 0; i < childItems.length; i++) {
if(!childItems[i].getChecked()) {
allChecked = false;
break;
}
}

selectAllItem.setChecked(allChecked);
} else {
selectedSteps.remove(step);

// Uncheck "All Scenarios" checkbox
item.getParentItem().setChecked(false);
}
} else {
selectedSteps.remove(step);
// Root item selected

TreeItem[] childItems = item.getItems();
TreeItem child = null;

for (int i = 0; i < childItems.length; i++) {
child = childItems[i];

if (item.getChecked()) {
selectedSteps.add((NewStep) child.getData());
} else {
selectedSteps.remove((NewStep) child.getData());
}
child.setChecked(item.getChecked());
}
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class WizardsMessages extends NLS {
public static String NewStoryWizardPageFileName;
public static String NewStoryWizardPageFileExtension;
public static String NewStoryWizardPageInitialContents;
public static String GenerateStepsCheckboxAllScenarios;

static {
// initialize resource bundle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
GenerateStepsPageTitle=Generate Steps
GenerateStepsPageDescription=This wizard generate stubs for missing steps
GenerateStepsPageName=generateStepsPage
GenerateStepsCheckboxAllScenarios=All Scenarios
NewStepsWizardTitle=Steps
NewStepsWizardPageName=newStepsPage
NewStepsWizardPageTitle=Steps
Expand Down