Search in sources :

Example 6 with ComparableIncrement

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);
            }
        }
    }
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) TreeItem(org.eclipse.swt.widgets.TreeItem) Preferences(org.osgi.service.prefs.Preferences) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ComparableIncrement(com.devonfw.cobigen.eclipse.generator.entity.ComparableIncrement)

Example 7 with ComparableIncrement

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);
    }
}
Also used : ComparableIncrement(com.devonfw.cobigen.eclipse.generator.entity.ComparableIncrement) HashSet(java.util.HashSet)

Example 8 with ComparableIncrement

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];
}
Also used : ComparableIncrement(com.devonfw.cobigen.eclipse.generator.entity.ComparableIncrement)

Aggregations

ComparableIncrement (com.devonfw.cobigen.eclipse.generator.entity.ComparableIncrement)8 HashSet (java.util.HashSet)4 IncrementTo (com.devonfw.cobigen.api.to.IncrementTo)3 TemplateTo (com.devonfw.cobigen.api.to.TemplateTo)3 Set (java.util.Set)2 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)2 TreeItem (org.eclipse.swt.widgets.TreeItem)2 Preferences (org.osgi.service.prefs.Preferences)2 TreePath (org.eclipse.jface.viewers.TreePath)1 BackingStoreException (org.osgi.service.prefs.BackingStoreException)1