use of com.devonfw.cobigen.eclipse.generator.entity.ComparableIncrement in project cobigen by devonfw.
the class SelectIncrementContentProvider method getAllPaths.
/**
* Returns all paths for the given element
*
* @param element for which all paths should be determined
* @return array of {@link TreePath}s ending on the given element
*/
public TreePath[] getAllPaths(Object element) {
Set<TreePath> paths = new HashSet<>();
if (element instanceof ComparableIncrement) {
for (ComparableIncrement increment : this.rootElements) {
TreePath path = TreePath.EMPTY.createChildPath(increment);
if (increment.equals(element)) {
paths.add(path);
}
addTreePaths(element, path, paths, false);
}
}
return paths.toArray(new TreePath[0]);
}
use of com.devonfw.cobigen.eclipse.generator.entity.ComparableIncrement in project cobigen by devonfw.
the class CobiGenWrapper method getOverridingFiles.
/**
* Returns project dependent paths of all resources which are marked to be overridable (just of
* {@link #getCurrentRepresentingInput()})
*
* @param increments to be considered
* @return The set of all overridable project dependent file paths
*/
public Set<String> getOverridingFiles(Collection<IncrementTo> increments) {
if (increments.contains(new ComparableIncrement(ALL_INCREMENT_ID, ALL_INCREMENT_NAME, null, Lists.<TemplateTo>newLinkedList(), Lists.<IncrementTo>newLinkedList()))) {
increments = this.cobiGen.getMatchingIncrements(getCurrentRepresentingInput());
}
Set<String> overridablePaths = Sets.newHashSet();
Map<String, Set<TemplateTo>> templateDestinationPaths = getTemplateDestinationPaths(increments);
for (Entry<String, Set<TemplateTo>> entry : templateDestinationPaths.entrySet()) {
if (isOverridableFile(entry.getValue())) {
overridablePaths.add(entry.getKey());
}
}
return overridablePaths;
}
use of com.devonfw.cobigen.eclipse.generator.entity.ComparableIncrement in project cobigen by devonfw.
the class CobiGenWrapper method getAllIncrements.
/**
* @return all available increments
*/
public ComparableIncrement[] getAllIncrements() {
Set<ComparableIncrement> result = Sets.newHashSet();
List<IncrementTo> matchingIncrements = Lists.newLinkedList();
if (this.inputs != null && this.inputs.size() != 0) {
for (Object input : this.cobiGen.resolveContainers(this.inputs.get(0))) {
matchingIncrements.addAll(this.cobiGen.getMatchingIncrements(input));
}
}
// convert to comparable increments
for (IncrementTo increment : matchingIncrements) {
result.add(new ComparableIncrement(increment.getId(), increment.getDescription(), increment.getTriggerId(), increment.getTemplates(), increment.getDependentIncrements()));
}
// add "all" increment, which should include all possible templates
ComparableIncrement all = new ComparableIncrement(ALL_INCREMENT_ID, ALL_INCREMENT_NAME, null, Lists.<TemplateTo>newLinkedList(), Lists.<IncrementTo>newLinkedList());
for (TemplateTo t : this.matchingTemplates) {
all.addTemplate(t);
}
result.add(all);
ComparableIncrement[] array = result.toArray(new ComparableIncrement[0]);
Arrays.sort(array);
LOG.debug("Available Increments: {}", result);
return array;
}
use of com.devonfw.cobigen.eclipse.generator.entity.ComparableIncrement in project cobigen by devonfw.
the class CobiGenWrapper method getMergeableFiles.
/**
* Returns project dependent paths of all resources which are marked to be mergeable (just of
* {@link #getCurrentRepresentingInput()})
*
* @param increments to be considered
* @return The set of all mergeable project dependent file paths
*/
public Set<String> getMergeableFiles(Collection<IncrementTo> increments) {
if (increments.contains(new ComparableIncrement(ALL_INCREMENT_ID, ALL_INCREMENT_NAME, null, Lists.<TemplateTo>newLinkedList(), Lists.<IncrementTo>newLinkedList()))) {
increments = this.cobiGen.getMatchingIncrements(getCurrentRepresentingInput());
}
Set<String> mergeablePaths = Sets.newHashSet();
Map<String, Set<TemplateTo>> templateDestinationPaths = getTemplateDestinationPaths(increments);
for (Entry<String, Set<TemplateTo>> entry : templateDestinationPaths.entrySet()) {
if (isMergableFile(entry.getValue())) {
mergeablePaths.add(entry.getKey());
}
}
return mergeablePaths;
}
use of com.devonfw.cobigen.eclipse.generator.entity.ComparableIncrement in project cobigen by devonfw.
the class SelectFilesPage method saveSelection.
/**
* Saves the current package selection
*/
public void saveSelection() {
if (!this.rememberSelection.getSelection()) {
return;
}
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) {
if (items[i].getChecked()) {
selection.node(element.getTriggerId()).put(element.getId(), CHECK_STATE.CHECKED.name());
} else {
selection.node(element.getTriggerId()).put(element.getId(), CHECK_STATE.UNCHECKED.name());
}
} else if (element.getId().equals(CobiGenWrapper.ALL_INCREMENT_ID)) {
if (items[i].getChecked()) {
selection.node(CobiGenWrapper.ALL_INCREMENT_NAME).put(element.getId(), CHECK_STATE.CHECKED.name());
} else {
selection.node(CobiGenWrapper.ALL_INCREMENT_NAME).put(element.getId(), CHECK_STATE.UNCHECKED.name());
}
}
}
try {
preferences.flush();
} catch (BackingStoreException e) {
LOG.error("Error while flushing last selection into preferences.", e);
}
}
Aggregations