use of org.eclipse.egit.ui.internal.staging.StagingView.StagingViewUpdate in project egit by eclipse.
the class StagingViewContentProvider method inputChanged.
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if (!(newInput instanceof StagingViewUpdate))
return;
StagingViewUpdate update = (StagingViewUpdate) newInput;
if (update.repository == null || update.indexDiff == null) {
content = new StagingEntry[0];
treeRoots = new Object[0];
compactTreeRoots = new Object[0];
return;
}
if (update.repository != repository) {
treeRoots = null;
compactTreeRoots = null;
}
repository = update.repository;
Set<StagingEntry> nodes = new TreeSet<>(new Comparator<StagingEntry>() {
@Override
public int compare(StagingEntry o1, StagingEntry o2) {
return o1.getPath().compareTo(o2.getPath());
}
});
if (update.changedResources != null && !update.changedResources.isEmpty()) {
nodes.addAll(Arrays.asList(content));
for (String res : update.changedResources) for (StagingEntry entry : content) if (entry.getPath().equals(res))
nodes.remove(entry);
}
final IndexDiffData indexDiff = update.indexDiff;
if (unstagedSection) {
for (String file : indexDiff.getMissing()) if (indexDiff.getChanged().contains(file))
nodes.add(new StagingEntry(repository, MISSING_AND_CHANGED, file));
else
nodes.add(new StagingEntry(repository, MISSING, file));
for (String file : indexDiff.getModified()) if (indexDiff.getChanged().contains(file))
nodes.add(new StagingEntry(repository, MODIFIED_AND_CHANGED, file));
else if (indexDiff.getAdded().contains(file))
nodes.add(new StagingEntry(repository, MODIFIED_AND_ADDED, file));
else
nodes.add(new StagingEntry(repository, MODIFIED, file));
for (String file : indexDiff.getUntracked()) nodes.add(new StagingEntry(repository, UNTRACKED, file));
for (String file : indexDiff.getConflicting()) nodes.add(new StagingEntry(repository, CONFLICTING, file));
} else {
for (String file : indexDiff.getAdded()) nodes.add(new StagingEntry(repository, ADDED, file));
for (String file : indexDiff.getChanged()) nodes.add(new StagingEntry(repository, CHANGED, file));
for (String file : indexDiff.getRemoved()) nodes.add(new StagingEntry(repository, REMOVED, file));
}
setSymlinkFileMode(indexDiff, nodes);
setSubmoduleFileMode(indexDiff, nodes);
content = nodes.toArray(new StagingEntry[nodes.size()]);
Arrays.sort(content, comparator);
treeRoots = null;
compactTreeRoots = null;
}
Aggregations