use of org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode in project egit by eclipse.
the class GitSelectWizardPage method checkPage.
/**
* check routine
*/
protected void checkPage() {
// we save the selected radio button in the preferences
IDialogSettings settings = Activator.getDefault().getDialogSettings();
settings.put(PREF_WIZ, getWizardSelection());
setErrorMessage(null);
if (newProjectWizard.getSelection()) {
setPageComplete(true);
return;
}
IStructuredSelection sel = (IStructuredSelection) tv.getSelection();
try {
if (sel.isEmpty()) {
setErrorMessage(UIText.GitImportWithDirectoriesPage_SelectFolderMessage);
return;
}
RepositoryTreeNode node = (RepositoryTreeNode) sel.getFirstElement();
if (node.getType() != RepositoryTreeNodeType.FOLDER && node.getType() != RepositoryTreeNodeType.WORKINGDIR) {
setErrorMessage(UIText.GitImportWithDirectoriesPage_SelectFolderMessage);
return;
}
} finally {
setPageComplete(getErrorMessage() == null);
}
}
use of org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode in project egit by eclipse.
the class GitSelectWizardPage method getPath.
/**
* @return the selected path
*/
public String getPath() {
IStructuredSelection sel = (IStructuredSelection) tv.getSelection();
RepositoryTreeNode node = (RepositoryTreeNode) sel.getFirstElement();
if (node != null && node.getType() == RepositoryTreeNodeType.FOLDER)
return ((File) node.getObject()).getPath();
if (node != null && node.getType() == RepositoryTreeNodeType.WORKINGDIR)
return node.getRepository().getWorkTree().getPath();
return null;
}
use of org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode 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.RepositoryTreeNode in project egit by eclipse.
the class ReflogView 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;
showReflogFor(node.getRepository());
return true;
}
}
}
return false;
}
use of org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode 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