use of org.eclipse.egit.ui.internal.repository.tree.RepositoryNode in project egit by eclipse.
the class GitFlowAdapterFactory method getAdapter.
@SuppressWarnings("unchecked")
@Override
public Repository getAdapter(Object adaptableObject, Class adapterType) {
Repository repository = null;
if (adaptableObject instanceof IResource) {
IResource resource = (IResource) adaptableObject;
repository = getRepository(resource);
} else if (adaptableObject instanceof IHistoryView) {
IHistoryView historyView = (IHistoryView) adaptableObject;
IHistoryPage historyPage = historyView.getHistoryPage();
Object input = historyPage.getInput();
if (input instanceof RepositoryNode) {
RepositoryNode node = (RepositoryNode) input;
repository = node.getRepository();
} else if (input instanceof IResource) {
repository = getRepository((IResource) input);
}
} else if (adaptableObject instanceof ISelection) {
IStructuredSelection structuredSelection = SelectionUtils.getStructuredSelection((ISelection) adaptableObject);
repository = SelectionUtils.getRepository(structuredSelection);
} else {
throw new IllegalStateException();
}
return repository;
}
use of org.eclipse.egit.ui.internal.repository.tree.RepositoryNode in project egit by eclipse.
the class GitFlowLightweightDecorator method getRepository.
@Nullable
private static GitFlowRepository getRepository(Object element) {
GitFlowRepository repository = null;
if (element instanceof GitFlowRepository) {
repository = (GitFlowRepository) element;
}
if (element instanceof RepositoryNode) {
RepositoryNode node = (RepositoryNode) element;
Repository repo = node.getObject();
if (repo != null) {
repository = new GitFlowRepository(repo);
}
}
return repository;
}
use of org.eclipse.egit.ui.internal.repository.tree.RepositoryNode 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;
}
use of org.eclipse.egit.ui.internal.repository.tree.RepositoryNode in project egit by eclipse.
the class PushConfiguredRemoteCommand method getRemoteConfig.
private RemoteConfig getRemoteConfig(RepositoryTreeNode node) {
if (node instanceof RepositoryNode)
return SimpleConfigurePushDialog.getConfiguredRemote(node.getRepository());
if (node instanceof RemoteNode || node instanceof PushNode) {
RemoteNode remoteNode;
if (node instanceof PushNode)
remoteNode = (RemoteNode) node.getParent();
else
remoteNode = (RemoteNode) node;
try {
RemoteConfig config = new RemoteConfig(remoteNode.getRepository().getConfig(), remoteNode.getObject());
boolean fetchConfigured = !config.getFetchRefSpecs().isEmpty();
boolean pushConfigured = !config.getPushRefSpecs().isEmpty();
if (fetchConfigured || pushConfigured)
return config;
else
return null;
} catch (URISyntaxException e) {
return null;
}
}
return null;
}
use of org.eclipse.egit.ui.internal.repository.tree.RepositoryNode in project egit by eclipse.
the class RemoveCommand method findProjectsToDelete.
private List<IProject> findProjectsToDelete(final List<RepositoryNode> selectedNodes) {
final List<IProject> projectsToDelete = new ArrayList<>();
for (RepositoryNode node : selectedNodes) {
if (node.getRepository().isBare())
continue;
File workDir = node.getRepository().getWorkTree();
final IPath wdPath = new Path(workDir.getAbsolutePath());
for (IProject prj : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
IPath location = prj.getLocation();
if (location != null && wdPath.isPrefixOf(location)) {
projectsToDelete.add(prj);
}
}
}
return projectsToDelete;
}
Aggregations