use of org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode in project egit by eclipse.
the class AbstractHistoryCommandHandler method getRepository.
protected Repository getRepository(ExecutionEvent event) throws ExecutionException {
IStructuredSelection selection = getSelection(event);
if (!selection.isEmpty()) {
IRepositoryCommit commit = AdapterUtils.adapt(selection.getFirstElement(), IRepositoryCommit.class);
if (commit != null) {
return commit.getRepository();
}
}
Object input = getInput(event);
if (input == null) {
return null;
}
if (input instanceof HistoryPageInput) {
return ((HistoryPageInput) input).getRepository();
}
if (input instanceof RepositoryTreeNode) {
return ((RepositoryTreeNode) input).getRepository();
}
Repository repo = AdapterUtils.adapt(input, Repository.class);
if (repo != null) {
return repo;
}
IResource resource = AdapterUtils.adaptToAnyResource(input);
if (resource != null) {
Repository repository = ResourceUtil.getRepository(resource);
if (repository != null) {
return repository;
}
}
throw new ExecutionException(UIText.AbstractHistoryCommanndHandler_CouldNotGetRepositoryMessage);
}
use of org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode in project egit by eclipse.
the class StagingView method reactOnSelection.
private void reactOnSelection(StructuredSelection selection) {
if (selection.size() != 1 || isDisposed()) {
return;
}
if (!shouldUpdateSelection()) {
// Remember it all the same to be able to update the view when it
// becomes active again
lastSelection = reactOnSelection ? selection : null;
return;
}
lastSelection = null;
Object firstElement = selection.getFirstElement();
if (firstElement instanceof RepositoryTreeNode) {
RepositoryTreeNode repoNode = (RepositoryTreeNode) firstElement;
if (currentRepository != repoNode.getRepository()) {
reload(repoNode.getRepository());
}
} else if (firstElement instanceof Repository) {
Repository repo = (Repository) firstElement;
if (currentRepository != repo) {
reload(repo);
}
} else {
Repository repo = AdapterUtils.adapt(firstElement, Repository.class);
if (repo != null) {
if (currentRepository != repo) {
reload(repo);
}
} else {
IResource resource = AdapterUtils.adaptToAnyResource(firstElement);
if (resource != null) {
showResource(resource);
}
}
}
}
use of org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode in project egit by eclipse.
the class StagingView method show.
@Override
public boolean show(ShowInContext context) {
ISelection selection = context.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
for (Object element : structuredSelection.toList()) {
if (element instanceof RepositoryTreeNode) {
RepositoryTreeNode node = (RepositoryTreeNode) element;
reload(node.getRepository());
return true;
}
}
}
return false;
}
use of org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode in project egit by eclipse.
the class AbstractBranchSelectionDialog method refNameFromDialog.
/**
* @return the selected ref name from the tree, may be null
*/
protected String refNameFromDialog() {
IStructuredSelection sel = (IStructuredSelection) branchTree.getSelection();
if (sel.size() != 1)
return null;
RepositoryTreeNode node = (RepositoryTreeNode) sel.getFirstElement();
if (node.getType() == RepositoryTreeNodeType.REF || node.getType() == RepositoryTreeNodeType.TAG || node.getType() == RepositoryTreeNodeType.ADDITIONALREF)
return ((Ref) node.getObject()).getName();
return null;
}
use of org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode in project egit by eclipse.
the class PushCommand method createPushTagsWizard.
private PushTagsWizard createPushTagsWizard(List<RepositoryTreeNode> nodes) {
List<String> tagNames = new ArrayList<>();
for (RepositoryTreeNode node : nodes) {
if (node instanceof TagNode) {
TagNode tagNode = (TagNode) node;
tagNames.add(tagNode.getObject().getName());
}
}
Repository repository = nodes.get(0).getRepository();
return new PushTagsWizard(repository, tagNames);
}
Aggregations