Search in sources :

Example 26 with RepositoryTreeNode

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);
    }
}
Also used : RepositoryTreeNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 27 with RepositoryTreeNode

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;
}
Also used : RepositoryTreeNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 28 with RepositoryTreeNode

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());
    }
}
Also used : AdditionalRefNode(org.eclipse.egit.ui.internal.repository.tree.AdditionalRefNode) RefNode(org.eclipse.egit.ui.internal.repository.tree.RefNode) AdditionalRefNode(org.eclipse.egit.ui.internal.repository.tree.AdditionalRefNode) Repository(org.eclipse.jgit.lib.Repository) Ref(org.eclipse.jgit.lib.Ref) RepositoryTreeNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) RepositoryMapping(org.eclipse.egit.core.project.RepositoryMapping) RevObject(org.eclipse.jgit.revwalk.RevObject) File(java.io.File) IResource(org.eclipse.core.resources.IResource) TagNode(org.eclipse.egit.ui.internal.repository.tree.TagNode) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Example 29 with RepositoryTreeNode

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;
}
Also used : RepositoryTreeNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 30 with RepositoryTreeNode

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;
}
Also used : FolderNode(org.eclipse.egit.ui.internal.repository.tree.FolderNode) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) RemoteNode(org.eclipse.egit.ui.internal.repository.tree.RemoteNode) RepositoryNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryNode) PushNode(org.eclipse.egit.ui.internal.repository.tree.PushNode) RefNode(org.eclipse.egit.ui.internal.repository.tree.RefNode) FetchNode(org.eclipse.egit.ui.internal.repository.tree.FetchNode) RepositoryTreeNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) WorkingDirNode(org.eclipse.egit.ui.internal.repository.tree.WorkingDirNode) FileNode(org.eclipse.egit.ui.internal.repository.tree.FileNode) IResource(org.eclipse.core.resources.IResource) TagNode(org.eclipse.egit.ui.internal.repository.tree.TagNode)

Aggregations

RepositoryTreeNode (org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode)46 Repository (org.eclipse.jgit.lib.Repository)17 Ref (org.eclipse.jgit.lib.Ref)13 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)11 ArrayList (java.util.ArrayList)10 TagNode (org.eclipse.egit.ui.internal.repository.tree.TagNode)10 IOException (java.io.IOException)9 File (java.io.File)8 IResource (org.eclipse.core.resources.IResource)7 RefNode (org.eclipse.egit.ui.internal.repository.tree.RefNode)6 IPath (org.eclipse.core.runtime.IPath)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 RevCommit (org.eclipse.jgit.revwalk.RevCommit)4 RevObject (org.eclipse.jgit.revwalk.RevObject)4 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)3 Path (org.eclipse.core.runtime.Path)3 Job (org.eclipse.core.runtime.jobs.Job)3 FileNode (org.eclipse.egit.ui.internal.repository.tree.FileNode)3 RemoteNode (org.eclipse.egit.ui.internal.repository.tree.RemoteNode)3 StashedCommitNode (org.eclipse.egit.ui.internal.repository.tree.StashedCommitNode)3