use of org.eclipse.egit.ui.internal.repository.tree.TagNode in project egit by eclipse.
the class PushCommand method createPushTagsWizard.
private PushTagsWizard createPushTagsWizard(List<RepositoryTreeNode> nodes) {
List<String> tagNames = new ArrayList<>();
for (RepositoryTreeNode node : nodes) {
if (node instanceof TagNode) {
TagNode tagNode = (TagNode) node;
tagNames.add(tagNode.getObject().getName());
}
}
Repository repository = nodes.get(0).getRepository();
return new PushTagsWizard(repository, tagNames);
}
use of org.eclipse.egit.ui.internal.repository.tree.TagNode 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;
}
use of org.eclipse.egit.ui.internal.repository.tree.TagNode in project egit by eclipse.
the class MergeCommand method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
RepositoryTreeNode node = getSelectedNodes(event).get(0);
final Repository repository = node.getRepository();
if (!MergeActionHandler.checkMergeIsPossible(repository, getShell(event)) || LaunchFinder.shouldCancelBecauseOfRunningLaunches(repository, null)) {
return null;
}
BasicConfigurationDialog.show(repository);
String targetRef;
if (node instanceof RefNode) {
String refName = ((RefNode) node).getObject().getName();
try {
if (refName.equals(repository.getFullBranch()))
targetRef = null;
else
targetRef = refName;
} catch (IOException e) {
targetRef = null;
}
} else if (node instanceof TagNode)
targetRef = ((TagNode) node).getObject().getName();
else
targetRef = null;
final String refName;
final MergeOperation op;
if (targetRef != null) {
refName = targetRef;
op = new MergeOperation(repository, refName);
} else {
MergeTargetSelectionDialog mergeTargetSelectionDialog = new MergeTargetSelectionDialog(getShell(event), repository);
if (mergeTargetSelectionDialog.open() != IDialogConstants.OK_ID)
return null;
refName = mergeTargetSelectionDialog.getRefName();
op = new MergeOperation(repository, refName);
op.setSquash(mergeTargetSelectionDialog.isMergeSquash());
op.setFastForwardMode(mergeTargetSelectionDialog.getFastForwardMode());
op.setCommit(mergeTargetSelectionDialog.isCommit());
}
String jobname = NLS.bind(UIText.MergeAction_JobNameMerge, refName);
Job job = new WorkspaceJob(jobname) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) {
try {
op.execute(monitor);
} catch (final CoreException e) {
return e.getStatus();
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.setRule(op.getSchedulingRule());
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent jobEvent) {
IStatus result = jobEvent.getJob().getResult();
if (result.getSeverity() == IStatus.CANCEL)
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
// don't use getShell(event) here since
// the active shell has changed since the
// execution has been triggered.
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
MessageDialog.openInformation(shell, UIText.MergeAction_MergeCanceledTitle, UIText.MergeAction_MergeCanceledMessage);
}
});
else if (!result.isOK())
Activator.handleError(result.getMessage(), result.getException(), true);
else
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
MergeResultDialog.getDialog(shell, repository, op.getResult()).open();
}
});
}
});
job.schedule();
return null;
}
use of org.eclipse.egit.ui.internal.repository.tree.TagNode in project egit by eclipse.
the class OpenCommand method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final List<RepositoryTreeNode> nodes = getSelectedNodes(event);
if (nodes.isEmpty())
return null;
final RepositoryTreeNode node = nodes.get(0);
if (node instanceof RefNode || node instanceof TagNode)
return new CheckoutCommand().execute(event);
if (node instanceof FileNode)
return new OpenInEditorCommand().execute(event);
if (node instanceof StashedCommitNode) {
RepositoryCommit repositoryCommit = new RepositoryCommit(node.getRepository(), ((StashedCommitNode) node).getObject());
repositoryCommit.setStash(true);
CommitEditor.openQuiet(repositoryCommit);
}
return null;
}
use of org.eclipse.egit.ui.internal.repository.tree.TagNode in project egit by eclipse.
the class RepositoriesViewLabelProvider method getImage.
@Override
public Image getImage(Object element) {
RepositoryTreeNode node = (RepositoryTreeNode) element;
RepositoryTreeNodeType type = node.getType();
if (type == RepositoryTreeNodeType.TAG) {
TagNode tagNode = (TagNode) node;
if (tagNode.isAnnotated())
return decorateImage(annotatedTagImage, element);
} else if (type == RepositoryTreeNodeType.FILE) {
Object object = node.getObject();
if (object instanceof File) {
ImageDescriptor descriptor = PlatformUI.getWorkbench().getEditorRegistry().getImageDescriptor(((File) object).getName());
return decorateImage((Image) resourceManager.get(descriptor), element);
}
} else if (type == RepositoryTreeNodeType.REPO) {
Object object = node.getObject();
if (object instanceof Repository) {
Repository r = (Repository) object;
if (ResourcePropertyTester.hasGerritConfiguration(r))
return gerritRepoImage;
}
}
return decorateImage(node.getType().getIcon(), element);
}
Aggregations