Search in sources :

Example 6 with FileNode

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

the class RepositoriesView method createCommonViewer.

@Override
protected CommonViewer createCommonViewer(Composite aParent) {
    CommonViewer viewer = super.createCommonViewer(aParent);
    // handle the double-click event for tags and branches
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            TreeSelection sel = (TreeSelection) event.getSelection();
            RepositoryTreeNode element = (RepositoryTreeNode) sel.getFirstElement();
            // Disable checkout for bare repositories
            if (element.getRepository().isBare()) {
                return;
            }
            if (element instanceof RefNode) {
                executeOpenCommandWithConfirmation(element, ((RefNode) element).getObject().getName());
            } else if (element instanceof TagNode) {
                executeOpenCommandWithConfirmation(element, ((TagNode) element).getObject().getName());
            }
        }
    });
    // handle open event for the working directory
    viewer.addOpenListener(new IOpenListener() {

        @Override
        public void open(OpenEvent event) {
            TreeSelection sel = (TreeSelection) event.getSelection();
            RepositoryTreeNode element = (RepositoryTreeNode) sel.getFirstElement();
            if (element instanceof FileNode || element instanceof StashedCommitNode)
                executeOpenCommand(element);
        }
    });
    // react on selection changes
    ISelectionService srv = CommonUtils.getService(getSite(), ISelectionService.class);
    srv.addPostSelectionListener(selectionChangedListener);
    // react on changes in the configured repositories
    repositoryUtil.getPreferences().addPreferenceChangeListener(configurationListener);
    initRepositoriesAndListeners();
    activateContextService();
    emptyArea.setBackground(viewer.getControl().getBackground());
    if (!repositories.isEmpty())
        layout.topControl = viewer.getControl();
    else
        layout.topControl = emptyArea;
    return viewer;
}
Also used : CommonViewer(org.eclipse.ui.navigator.CommonViewer) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) RefNode(org.eclipse.egit.ui.internal.repository.tree.RefNode) IOpenListener(org.eclipse.jface.viewers.IOpenListener) RepositoryTreeNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) TreeSelection(org.eclipse.jface.viewers.TreeSelection) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ISelectionService(org.eclipse.ui.ISelectionService) StashedCommitNode(org.eclipse.egit.ui.internal.repository.tree.StashedCommitNode) TagNode(org.eclipse.egit.ui.internal.repository.tree.TagNode) FileNode(org.eclipse.egit.ui.internal.repository.tree.FileNode) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Example 7 with FileNode

use of org.eclipse.egit.ui.internal.repository.tree.FileNode 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;
}
Also used : FolderNode(org.eclipse.egit.ui.internal.repository.tree.FolderNode) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) RemoteNode(org.eclipse.egit.ui.internal.repository.tree.RemoteNode) RepositoryNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryNode) PushNode(org.eclipse.egit.ui.internal.repository.tree.PushNode) RefNode(org.eclipse.egit.ui.internal.repository.tree.RefNode) FetchNode(org.eclipse.egit.ui.internal.repository.tree.FetchNode) RepositoryTreeNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) WorkingDirNode(org.eclipse.egit.ui.internal.repository.tree.WorkingDirNode) FileNode(org.eclipse.egit.ui.internal.repository.tree.FileNode) IResource(org.eclipse.core.resources.IResource) TagNode(org.eclipse.egit.ui.internal.repository.tree.TagNode)

Aggregations

FileNode (org.eclipse.egit.ui.internal.repository.tree.FileNode)7 File (java.io.File)4 FolderNode (org.eclipse.egit.ui.internal.repository.tree.FolderNode)4 RefNode (org.eclipse.egit.ui.internal.repository.tree.RefNode)4 RepositoryTreeNode (org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode)4 ArrayList (java.util.ArrayList)3 StashedCommitNode (org.eclipse.egit.ui.internal.repository.tree.StashedCommitNode)3 TagNode (org.eclipse.egit.ui.internal.repository.tree.TagNode)3 WorkingDirNode (org.eclipse.egit.ui.internal.repository.tree.WorkingDirNode)3 Repository (org.eclipse.jgit.lib.Repository)3 IPath (org.eclipse.core.runtime.IPath)2 FetchNode (org.eclipse.egit.ui.internal.repository.tree.FetchNode)2 PushNode (org.eclipse.egit.ui.internal.repository.tree.PushNode)2 RemoteNode (org.eclipse.egit.ui.internal.repository.tree.RemoteNode)2 RepositoryNode (org.eclipse.egit.ui.internal.repository.tree.RepositoryNode)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Entry (java.util.Map.Entry)1