use of com.devonfw.cobigen.eclipse.generator.entity.ComparableIncrement in project cobigen by devonfw.
the class SelectFilesPage method loadSelection.
/**
* Loads the last package selection
*/
private void loadSelection() {
IEclipsePreferences preferences = ConfigurationScope.INSTANCE.getNode(Activator.PLUGIN_ID);
Preferences selection = preferences.node("selection");
TreeItem[] items = this.incrementSelector.getTree().getItems();
for (int i = 0; i < items.length; i++) {
ComparableIncrement element = (ComparableIncrement) items[i].getData();
if (element.getTriggerId() != null) {
String value = selection.node(element.getTriggerId()).get(element.getId(), CHECK_STATE.UNCHECKED.name());
if (value.equals(CHECK_STATE.CHECKED.name())) {
this.incrementSelector.setChecked(element, true);
}
} else if (element.getId().equals(CobiGenWrapper.ALL_INCREMENT_ID)) {
String value = selection.node(CobiGenWrapper.ALL_INCREMENT_NAME).get(element.getId(), CHECK_STATE.UNCHECKED.name());
if (value.equals(CHECK_STATE.CHECKED.name())) {
this.incrementSelector.setChecked(element, true);
}
}
}
}
use of com.devonfw.cobigen.eclipse.generator.entity.ComparableIncrement in project cobigen by devonfw.
the class CheckStateListener method performCheckLogicForALLIncrement.
/**
* Performs an intelligent check logic, e.g. check/uncheck all packages when selecting "all"
*
* @param incrementSelector the {@link CheckboxTableViewer} listing all increments
* @param selectedElements the {@link Set} of all elements checked by the user
*/
public void performCheckLogicForALLIncrement(CheckboxTreeViewer incrementSelector, Set<Object> selectedElements) {
Set<Object> addedDiff = new HashSet<>(selectedElements);
Set<? extends IncrementTo> removedDiff = new HashSet<>(this.selectedIncrements);
addedDiff.removeAll(this.selectedIncrements);
removedDiff.removeAll(selectedElements);
ComparableIncrement all = new ComparableIncrement(CobiGenWrapper.ALL_INCREMENT_ID, CobiGenWrapper.ALL_INCREMENT_NAME, null, Lists.<TemplateTo>newLinkedList(), Lists.<IncrementTo>newLinkedList());
if (!this.selectedIncrements.contains(all) && addedDiff.contains(all)) {
setStateOfAllIncrements(incrementSelector, true);
setSelectedIncrements(Arrays.asList((Object[]) incrementSelector.getInput()));
} else if (this.selectedIncrements.contains(all) && removedDiff.contains(all)) {
setStateOfAllIncrements(incrementSelector, false);
this.selectedIncrements.clear();
} else if (!removedDiff.isEmpty()) {
setSelectedIncrements(selectedElements);
this.selectedIncrements.remove(all);
incrementSelector.setChecked(all, false);
} else {
setSelectedIncrements(selectedElements);
}
}
use of com.devonfw.cobigen.eclipse.generator.entity.ComparableIncrement in project cobigen by devonfw.
the class SelectIncrementContentProvider method getElements.
@Override
public Object[] getElements(Object inputElement) {
if (inputElement instanceof ComparableIncrement[]) {
this.rootElements = new LinkedList<>();
ComparableIncrement[] rootIncrements = (ComparableIncrement[]) inputElement;
for (ComparableIncrement pkg : rootIncrements) {
if (!isChildOfAnyIncrement(rootIncrements, pkg)) {
this.rootElements.add(pkg);
}
}
return this.rootElements.toArray();
}
return new Object[0];
}
Aggregations