Search in sources :

Example 46 with RepositoryTreeNode

use of org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode in project egit by eclipse.

the class SubmoduleAddCommand method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    List<RepositoryTreeNode<?>> nodes = getSelectedNodes(event);
    if (nodes.isEmpty())
        return null;
    final Repository repo = nodes.get(0).getRepository();
    if (repo == null)
        return null;
    AddSubmoduleWizard wizard = new AddSubmoduleWizard(repo);
    WizardDialog dialog = new WizardDialog(getShell(event), wizard);
    if (dialog.open() == Window.OK) {
        final String path = wizard.getPath();
        final String uri = wizard.getUri().toPrivateASCIIString();
        final SubmoduleAddOperation op = new SubmoduleAddOperation(repo, path, uri);
        Job job = new WorkspaceJob(MessageFormat.format(UIText.SubmoduleAddCommand_JobTitle, path, uri)) {

            @Override
            public IStatus runInWorkspace(IProgressMonitor monitor) {
                // $NON-NLS-1$
                monitor.beginTask("", IProgressMonitor.UNKNOWN);
                try {
                    op.execute(monitor);
                } catch (CoreException e) {
                    Activator.logError(UIText.SubmoduleAddCommand_AddError, e);
                }
                return Status.OK_STATUS;
            }

            @Override
            public boolean belongsTo(Object family) {
                if (JobFamilies.SUBMODULE_ADD.equals(family))
                    return true;
                return super.belongsTo(family);
            }
        };
        job.setUser(true);
        job.setRule(op.getSchedulingRule());
        job.schedule();
    }
    return null;
}
Also used : AddSubmoduleWizard(org.eclipse.egit.ui.internal.submodule.AddSubmoduleWizard) Repository(org.eclipse.jgit.lib.Repository) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RepositoryTreeNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) CoreException(org.eclipse.core.runtime.CoreException) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) Job(org.eclipse.core.runtime.jobs.Job) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) WizardDialog(org.eclipse.jface.wizard.WizardDialog) SubmoduleAddOperation(org.eclipse.egit.core.op.SubmoduleAddOperation)

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