use of org.eclipse.jgit.events.RefsChangedEvent in project egit by eclipse.
the class StashDropOperation method execute.
@Override
public void execute(IProgressMonitor monitor) throws CoreException {
IWorkspaceRunnable action = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor pm) throws CoreException {
StashDropCommand command = Git.wrap(repo).stashDrop();
command.setStashRef(index);
try {
command.call();
repo.fireEvent(new RefsChangedEvent());
} catch (JGitInternalException e) {
throw new TeamException(e.getLocalizedMessage(), e.getCause());
} catch (GitAPIException e) {
throw new TeamException(e.getLocalizedMessage(), e.getCause());
}
}
};
ResourcesPlugin.getWorkspace().run(action, getSchedulingRule(), IWorkspace.AVOID_UPDATE, monitor);
}
use of org.eclipse.jgit.events.RefsChangedEvent in project egit by eclipse.
the class RepositoriesViewContentProvider method getRefs.
private synchronized Map<String, Ref> getRefs(final Repository repo, final String prefix) throws IOException {
Map<String, Ref> allRefs = branchRefs.get(repo);
if (allRefs == null) {
allRefs = repo.getRefDatabase().getRefs(RefDatabase.ALL);
branchRefs.put(repo, allRefs);
if (refsChangedListeners.get(repo) == null) {
RefsChangedListener listener = new RefsChangedListener() {
@Override
public void onRefsChanged(RefsChangedEvent event) {
synchronized (RepositoriesViewContentProvider.this) {
branchRefs.remove(repo);
}
}
};
refsChangedListeners.put(repo, repo.getListenerList().addRefsChangedListener(listener));
}
}
if (prefix.equals(RefDatabase.ALL))
return allRefs;
Map<String, Ref> filtered = new HashMap<>();
for (Map.Entry<String, Ref> entry : allRefs.entrySet()) {
if (entry.getKey().startsWith(prefix))
filtered.put(entry.getKey(), entry.getValue());
}
return filtered;
}
Aggregations