use of com.devonfw.cobigen.eclipse.wizard.common.model.SelectIncrementContentProvider in project cobigen by devonfw.
the class SelectFilesPage method createControl.
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.FILL);
container.setLayout(new GridLayout());
SashForm sash = new SashForm(container, SWT.HORIZONTAL);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
sash.setLayoutData(gd);
Composite containerLeft = new Composite(sash, SWT.FILL);
containerLeft.setLayout(new GridLayout(1, false));
Label label = new Label(containerLeft, SWT.NONE);
label.setText("Filter (increments):");
this.incrementSelector = new CustomizedCheckboxTreeViewer(containerLeft);
this.incrementSelector.setContentProvider(new SelectIncrementContentProvider());
this.incrementSelector.setInput(this.cobigenWrapper.getAllIncrements());
gd = new GridData(GridData.FILL_BOTH);
gd.grabExcessVerticalSpace = true;
this.incrementSelector.getTree().setLayoutData(gd);
this.incrementSelector.expandAll();
this.containerRight = new Composite(sash, SWT.FILL);
this.containerRight.setLayout(new GridLayout(1, false));
boolean initiallyCustomizable = false;
buildResourceTreeViewer(initiallyCustomizable);
CheckStateListener checkListener = new CheckStateListener(this.cobigenWrapper, this, this.batch);
this.incrementSelector.addCheckStateListener(checkListener);
sash.setWeights(new int[] { 1, 3 });
this.rememberSelection = new Button(container, SWT.CHECK);
this.rememberSelection.setText("Remember my selection");
gd = new GridData();
gd.horizontalAlignment = SWT.BEGINNING;
this.rememberSelection.setLayoutData(gd);
this.rememberSelection.addSelectionListener(checkListener);
Button but = new Button(container, SWT.PUSH);
but.setText("Customize");
gd = new GridData();
gd.horizontalAlignment = SWT.END;
but.setLayoutData(gd);
but.addListener(SWT.Selection, new ButtonListener(initiallyCustomizable, this));
setControl(container);
loadSelection();
}
use of com.devonfw.cobigen.eclipse.wizard.common.model.SelectIncrementContentProvider in project cobigen by devonfw.
the class CheckStateListener method performCheckLogic.
/**
* Performs an intelligent check logic such that the same element in different paths will be checked simultaneously,
* parents will be unselected if at least one child is not selected, and parents will be automatically selected if all
* children of the parent are selected
*
* @param event triggering {@link CheckStateChangedEvent}
* @param packageSelector current {@link CheckboxTreeViewer} for the package selection
*/
public void performCheckLogic(CheckStateChangedEvent event, CheckboxTreeViewer packageSelector) {
if (event.getSource().equals(packageSelector)) {
SelectIncrementContentProvider cp = (SelectIncrementContentProvider) packageSelector.getContentProvider();
TreePath[] paths = cp.getAllPaths(event.getElement());
for (TreePath path : paths) {
packageSelector.setSubtreeChecked(path, event.getChecked());
}
TreePath[] parents = cp.getParents(event.getElement());
if (event.getChecked()) {
for (TreePath parent : parents) {
boolean allChecked = true;
for (Object child : cp.getChildren(parent)) {
if (!packageSelector.getChecked(parent.createChildPath(child))) {
allChecked = false;
break;
}
}
if (allChecked) {
packageSelector.setChecked(parent, true);
}
}
if (event.getElement().toString().contains("All")) {
packageSelector.setAllChecked(true);
}
// checks if all child increments are checked and checks All-Checkbox
boolean allChecked = true;
for (TreeItem item : packageSelector.getTree().getItems()) {
if (!item.getChecked() && !item.getText().contains("All")) {
allChecked = false;
break;
}
}
if (allChecked) {
packageSelector.getTree().getItem(0).setChecked(true);
}
} else {
for (TreePath parent : parents) {
if (parent.getSegmentCount() > 0) {
packageSelector.setChecked(parent, false);
}
}
}
}
}
Aggregations