Search in sources :

Example 1 with DeleteTagOperation

use of org.eclipse.egit.core.op.DeleteTagOperation in project egit by eclipse.

the class DeleteTagCommand method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final List<TagNode> tags = getSelectedNodes(event);
    if (tags.isEmpty())
        return null;
    // Confirm deletion of selected tags
    final AtomicBoolean confirmed = new AtomicBoolean();
    final Shell shell = getActiveShell(event);
    shell.getDisplay().syncExec(new Runnable() {

        @Override
        public void run() {
            String message;
            if (tags.size() > 1)
                message = MessageFormat.format(UIText.DeleteTagCommand_messageConfirmMultipleTag, Integer.valueOf(tags.size()));
            else
                message = MessageFormat.format(UIText.DeleteTagCommand_messageConfirmSingleTag, Repository.shortenRefName(tags.get(0).getObject().getName()));
            confirmed.set(MessageDialog.openConfirm(shell, UIText.DeleteTagCommand_titleConfirm, message));
        }
    });
    if (!confirmed.get())
        return null;
    Job job = new Job(UIText.DeleteTagCommand_taskName) {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            monitor.beginTask(UIText.DeleteTagCommand_taskName, tags.size());
            for (TagNode tag : tags) {
                final Repository repo = tag.getRepository();
                final String tagName = tag.getObject().getName();
                final DeleteTagOperation op = new DeleteTagOperation(repo, tagName);
                monitor.subTask(tagName);
                try {
                    op.execute(monitor);
                } catch (CoreException e) {
                    Activator.logError(e.getLocalizedMessage(), e);
                }
                monitor.worked(1);
            }
            monitor.done();
            return Status.OK_STATUS;
        }

        @Override
        public boolean belongsTo(Object family) {
            if (JobFamilies.TAG.equals(family))
                return true;
            return super.belongsTo(family);
        }
    };
    job.setUser(true);
    job.schedule();
    return null;
}
Also used : DeleteTagOperation(org.eclipse.egit.core.op.DeleteTagOperation) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Repository(org.eclipse.jgit.lib.Repository) CoreException(org.eclipse.core.runtime.CoreException) Job(org.eclipse.core.runtime.jobs.Job) TagNode(org.eclipse.egit.ui.internal.repository.tree.TagNode)

Example 2 with DeleteTagOperation

use of org.eclipse.egit.core.op.DeleteTagOperation in project egit by eclipse.

the class DeleteTagOnCommitHandler method deleteTag.

private void deleteTag(Repository repository, String tagName) throws CoreException {
    DeleteTagOperation operation = new DeleteTagOperation(repository, tagName);
    operation.execute(null);
}
Also used : DeleteTagOperation(org.eclipse.egit.core.op.DeleteTagOperation)

Aggregations

DeleteTagOperation (org.eclipse.egit.core.op.DeleteTagOperation)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1 TagNode (org.eclipse.egit.ui.internal.repository.tree.TagNode)1 Repository (org.eclipse.jgit.lib.Repository)1 Shell (org.eclipse.swt.widgets.Shell)1