use of org.eclipse.egit.ui.internal.repository.tree.TagNode in project egit by eclipse.
the class RepositoriesView method createCommonViewer.
@Override
protected CommonViewer createCommonViewer(Composite aParent) {
CommonViewer viewer = super.createCommonViewer(aParent);
// handle the double-click event for tags and branches
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
TreeSelection sel = (TreeSelection) event.getSelection();
RepositoryTreeNode element = (RepositoryTreeNode) sel.getFirstElement();
// Disable checkout for bare repositories
if (element.getRepository().isBare()) {
return;
}
if (element instanceof RefNode) {
executeOpenCommandWithConfirmation(element, ((RefNode) element).getObject().getName());
} else if (element instanceof TagNode) {
executeOpenCommandWithConfirmation(element, ((TagNode) element).getObject().getName());
}
}
});
// handle open event for the working directory
viewer.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
TreeSelection sel = (TreeSelection) event.getSelection();
RepositoryTreeNode element = (RepositoryTreeNode) sel.getFirstElement();
if (element instanceof FileNode || element instanceof StashedCommitNode)
executeOpenCommand(element);
}
});
// react on selection changes
ISelectionService srv = CommonUtils.getService(getSite(), ISelectionService.class);
srv.addPostSelectionListener(selectionChangedListener);
// react on changes in the configured repositories
repositoryUtil.getPreferences().addPreferenceChangeListener(configurationListener);
initRepositoriesAndListeners();
activateContextService();
emptyArea.setBackground(viewer.getControl().getBackground());
if (!repositories.isEmpty())
layout.topControl = viewer.getControl();
else
layout.topControl = emptyArea;
return viewer;
}
use of org.eclipse.egit.ui.internal.repository.tree.TagNode in project egit by eclipse.
the class PushTagsPage method initiallySelectTags.
private void initiallySelectTags(Object[] tagNodes, CheckboxTreeViewer viewer) {
List<TagNode> checkedTags = new ArrayList<>();
for (Object node : tagNodes) {
if (node instanceof TagNode) {
TagNode tagNode = (TagNode) node;
Ref ref = tagNode.getObject();
if (tagRefNamesToSelect.contains(ref.getName()))
checkedTags.add(tagNode);
}
}
TagNode[] checkedTagsArray = checkedTags.toArray(new TagNode[checkedTags.size()]);
viewer.setCheckedElements(checkedTagsArray);
if (checkedTagsArray.length > 0) {
// Reveal tags (just using reveal does not work on some platforms)
viewer.setSelection(new StructuredSelection(checkedTagsArray), true);
// Clear selection, we don't want to highlight the rows that much
viewer.setSelection(StructuredSelection.EMPTY);
}
setSelectedTags(checkedTagsArray);
}
use of org.eclipse.egit.ui.internal.repository.tree.TagNode in project egit by eclipse.
the class AbstractBranchSelectionDialog method markRef.
/**
* Set the selection to a {@link Ref} if possible
*
* @param refName
* the name of the {@link Ref}
* @return <code>true</code> if the {@link Ref} with the given name was
* found
*/
protected boolean markRef(String refName) {
// selects the entry specified by the name
if (refName == null)
return false;
RepositoryTreeNode node;
try {
if (refName.startsWith(Constants.R_HEADS)) {
Ref ref = repo.exactRef(refName);
if (ref == null)
return false;
node = createRefNode(localBranches, repo, ref);
} else if (refName.startsWith(Constants.R_REMOTES)) {
Ref ref = repo.exactRef(refName);
if (ref == null)
return false;
node = createRefNode(remoteBranches, repo, ref);
} else if (Constants.HEAD.equals(refName)) {
Ref ref = repo.exactRef(refName);
if (ref == null)
return false;
node = new AdditionalRefNode(references, repo, ref);
} else {
String mappedRef = Activator.getDefault().getRepositoryUtil().mapCommitToRef(repo, refName, false);
if (mappedRef != null && mappedRef.startsWith(Constants.R_REMOTES)) {
Ref ref = repo.exactRef(mappedRef);
if (ref == null)
return false;
node = createRefNode(remoteBranches, repo, ref);
} else if (mappedRef != null && mappedRef.startsWith(Constants.R_TAGS)) {
Ref ref = repo.exactRef(mappedRef);
if (ref == null)
return false;
node = new TagNode(tags, repo, ref);
} else
return false;
}
} catch (IOException e) {
return false;
}
branchTree.setSelection(new StructuredSelection(node), true);
return true;
}
use of org.eclipse.egit.ui.internal.repository.tree.TagNode in project egit by eclipse.
the class GitHistoryPage method inputSet.
@Override
public boolean inputSet() {
try {
if (trace)
GitTraceLocation.getTrace().traceEntry(GitTraceLocation.HISTORYVIEW.getLocation());
if (this.input != null)
return true;
Object o = super.getInput();
if (o == null) {
setErrorMessage(UIText.GitHistoryPage_NoInputMessage);
return false;
}
boolean showHead = false;
boolean showRef = false;
boolean showTag = false;
Repository repo = null;
RevCommit selection = null;
Ref ref = null;
if (o instanceof IResource) {
RepositoryMapping mapping = RepositoryMapping.getMapping((IResource) o);
if (mapping != null) {
repo = mapping.getRepository();
input = new HistoryPageInput(repo, new IResource[] { (IResource) o });
showHead = true;
}
} else if (o instanceof RepositoryTreeNode) {
RepositoryTreeNode repoNode = (RepositoryTreeNode) o;
repo = repoNode.getRepository();
switch(repoNode.getType()) {
case FILE:
File file = ((FileNode) repoNode).getObject();
input = new HistoryPageInput(repo, new File[] { file });
showHead = true;
break;
case FOLDER:
File folder = ((FolderNode) repoNode).getObject();
input = new HistoryPageInput(repo, new File[] { folder });
showHead = true;
break;
case REF:
input = new HistoryPageInput(repo);
ref = ((RefNode) repoNode).getObject();
showRef = true;
break;
case ADDITIONALREF:
input = new HistoryPageInput(repo);
ref = ((AdditionalRefNode) repoNode).getObject();
showRef = true;
break;
case TAG:
input = new HistoryPageInput(repo);
ref = ((TagNode) repoNode).getObject();
showTag = true;
break;
default:
input = new HistoryPageInput(repo);
showHead = true;
break;
}
} else if (o instanceof HistoryPageInput) {
input = (HistoryPageInput) o;
} else {
IResource resource = AdapterUtils.adaptToAnyResource(o);
if (resource != null) {
RepositoryMapping mapping = RepositoryMapping.getMapping(resource);
if (mapping != null) {
repo = mapping.getRepository();
input = new HistoryPageInput(repo, new IResource[] { resource });
}
}
}
if (repo == null) {
repo = AdapterUtils.adapt(o, Repository.class);
if (repo != null) {
File file = AdapterUtils.adapt(o, File.class);
if (file == null) {
input = new HistoryPageInput(repo);
} else {
input = new HistoryPageInput(repo, new File[] { file });
}
}
}
selection = AdapterUtils.adapt(o, RevCommit.class);
if (input == null) {
// $NON-NLS-1$
this.name = "";
setErrorMessage(UIText.GitHistoryPage_NoInputMessage);
return false;
}
final IResource[] inResources = input.getItems();
final File[] inFiles = input.getFileList();
this.name = calculateName(input);
// disable the filters if we have a Repository as input
boolean filtersActive = inResources != null || inFiles != null;
actions.showAllRepoVersionsAction.setEnabled(filtersActive);
actions.showAllProjectVersionsAction.setEnabled(filtersActive);
// the repository itself has no notion of projects
actions.showAllFolderVersionsAction.setEnabled(inResources != null);
actions.showAllResourceVersionsAction.setEnabled(filtersActive);
setErrorMessage(null);
try {
initAndStartRevWalk(false);
} catch (IllegalStateException e) {
Activator.handleError(e.getMessage(), e, true);
return false;
}
if (showHead)
showHead(repo);
if (showRef)
showRef(ref, repo);
if (showTag)
showTag(ref, repo);
if (selection != null)
graph.selectCommitStored(selection);
return true;
} finally {
if (trace)
GitTraceLocation.getTrace().traceExit(GitTraceLocation.HISTORYVIEW.getLocation());
}
}
use of org.eclipse.egit.ui.internal.repository.tree.TagNode in project egit by eclipse.
the class RepositoriesView method getShowInElements.
private static List<Object> getShowInElements(IStructuredSelection selection) {
List<Object> elements = new ArrayList<>();
for (Object element : selection.toList()) {
if (element instanceof FileNode || element instanceof FolderNode || element instanceof WorkingDirNode) {
RepositoryTreeNode treeNode = (RepositoryTreeNode) element;
IPath path = treeNode.getPath();
IResource resource = ResourceUtil.getResourceForLocation(path, false);
if (resource != null)
elements.add(resource);
} else if (element instanceof RepositoryNode) {
// Can be shown in History, Reflog and Properties views
elements.add(element);
} else if (element instanceof RepositoryNode || element instanceof RemoteNode || element instanceof FetchNode || element instanceof PushNode || element instanceof TagNode || element instanceof RefNode) {
// These can be shown in Properties view directly
elements.add(element);
}
}
return elements;
}
Aggregations