use of org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode in project egit by eclipse.
the class RepositoriesViewCommandHandler method getSelectedFileAndFolderPaths.
protected Collection<IPath> getSelectedFileAndFolderPaths(ExecutionEvent event) throws ExecutionException {
Collection<IPath> paths = new ArrayList<>();
for (Object selectedNode : getSelectedNodes(event)) {
RepositoryTreeNode treeNode = (RepositoryTreeNode) selectedNode;
IPath path = treeNode.getPath();
paths.add(path);
}
return paths;
}
use of org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode in project egit by eclipse.
the class CopyPathCommand method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
RepositoryTreeNode node = getSelectedNodes(event).get(0);
String path;
switch(node.getType()) {
case REPO:
path = node.getRepository().getDirectory().toString();
break;
case WORKINGDIR:
if (node.getRepository().isBare())
return null;
path = node.getRepository().getWorkTree().toString();
break;
case FILE:
path = ((FileNode) node).getObject().getPath().toString();
break;
case FOLDER:
path = ((FolderNode) node).getObject().getPath().toString();
break;
default:
return null;
}
Clipboard clipboard = new Clipboard(null);
try {
TextTransfer textTransfer = TextTransfer.getInstance();
Transfer[] transfers = new Transfer[] { textTransfer };
Object[] data = new Object[] { path };
clipboard.setContents(data, transfers);
} finally {
clipboard.dispose();
}
return null;
}
use of org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode in project egit by eclipse.
the class CreateBranchCommand method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final RepositoryTreeNode node = getSelectedNodes(event).get(0);
if (node.getType() == RepositoryTreeNodeType.ADDITIONALREF) {
Ref ref = (Ref) node.getObject();
try (RevWalk rw = new RevWalk(node.getRepository())) {
RevCommit baseCommit = rw.parseCommit(ref.getLeaf().getObjectId());
WizardDialog dlg = new WizardDialog(getShell(event), new CreateBranchWizard(node.getRepository(), baseCommit.name()));
dlg.setHelpAvailable(false);
dlg.open();
} catch (IOException e) {
Activator.handleError(e.getMessage(), e, true);
}
return null;
}
String base = null;
if (node.getObject() instanceof Ref)
base = ((Ref) node.getObject()).getName();
new WizardDialog(getShell(event), new CreateBranchWizard(node.getRepository(), base)).open();
return null;
}
use of org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode in project egit by eclipse.
the class DeleteBranchCommand method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final List<RepositoryTreeNode> nodes = getSelectedNodes(event);
final Map<Ref, Repository> refs = getRefsToDelete(nodes);
final AtomicReference<Map<Ref, Repository>> unmergedNodesRef = new AtomicReference<>();
final Shell shell = getShell(event);
try {
new ProgressMonitorDialog(shell).run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
Map<Ref, Repository> unmergedNodes = deleteBranches(refs, false, monitor);
unmergedNodesRef.set(unmergedNodes);
}
});
} catch (InvocationTargetException e1) {
Activator.handleError(UIText.RepositoriesView_BranchDeletionFailureMessage, e1.getCause(), true);
} catch (InterruptedException e1) {
// ignore
}
if (unmergedNodesRef.get().isEmpty())
return null;
MessageDialog messageDialog = new UnmergedBranchDialog<>(shell, new ArrayList<>(unmergedNodesRef.get().keySet()));
if (messageDialog.open() != Window.OK)
return null;
try {
new ProgressMonitorDialog(shell).run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
deleteBranches(unmergedNodesRef.get(), true, monitor);
}
});
} catch (InvocationTargetException e1) {
Activator.handleError(UIText.RepositoriesView_BranchDeletionFailureMessage, e1.getCause(), true);
} catch (InterruptedException e1) {
// ignore
}
return null;
}
use of org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode in project egit by eclipse.
the class ConfigureFetchCommand method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
RepositoryTreeNode selectedNode = getFirstOrNull(getSelectedNodes(event));
final String configName;
if (selectedNode instanceof RemoteNode)
configName = ((RemoteNode) selectedNode).getObject();
else if (selectedNode instanceof FetchNode)
configName = ((RemoteNode) selectedNode.getParent()).getObject();
else
return null;
Dialog dlg = SimpleConfigureFetchDialog.getDialog(getShell(event), selectedNode.getRepository(), configName);
dlg.open();
return null;
}
Aggregations