Search in sources :

Example 1 with RepositoryTreeNodeType

use of org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNodeType 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);
}
Also used : RepositoryTreeNodeType(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNodeType) Repository(org.eclipse.jgit.lib.Repository) RepositoryTreeNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) CompositeImageDescriptor(org.eclipse.jface.resource.CompositeImageDescriptor) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Image(org.eclipse.swt.graphics.Image) File(java.io.File) TagNode(org.eclipse.egit.ui.internal.repository.tree.TagNode)

Example 2 with RepositoryTreeNodeType

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

the class AbstractBranchSelectionDialog method createDialogArea.

@Override
protected final Composite createDialogArea(Composite base) {
    Composite parent = (Composite) super.createDialogArea(base);
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    int selectionModel = -1;
    if ((settings & ALLOW_MULTISELECTION) != 0)
        selectionModel = SWT.MULTI;
    else
        selectionModel = SWT.SINGLE;
    FilteredTree tree = new FilteredTree(composite, selectionModel | SWT.BORDER, new PatternFilter(), true);
    branchTree = tree.getViewer();
    branchTree.setUseHashlookup(true);
    branchTree.setLabelProvider(new RepositoriesViewStyledCellLabelProvider());
    branchTree.setContentProvider(new RepositoriesViewContentProvider());
    ColumnViewerToolTipSupport.enableFor(branchTree);
    GridDataFactory.fillDefaults().grab(true, true).hint(500, 300).applyTo(tree);
    branchTree.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            String refName = refNameFromDialog();
            refNameSelected(refName);
        }
    });
    // double-click support
    branchTree.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            RepositoryTreeNode node = (RepositoryTreeNode) ((IStructuredSelection) branchTree.getSelection()).getFirstElement();
            if (node == null)
                return;
            final RepositoryTreeNodeType type = node.getType();
            if (type != RepositoryTreeNodeType.REF && type != RepositoryTreeNodeType.TAG && type != RepositoryTreeNodeType.ADDITIONALREF)
                branchTree.setExpandedState(node, !branchTree.getExpandedState(node));
            else if (isOkButtonEnabled())
                buttonPressed(OK);
        }
    });
    branchTree.setComparator(new ViewerComparator(STRING_ASCENDING_COMPARATOR));
    createCustomArea(composite);
    setTitle(getTitle());
    setMessage(getMessageText());
    getShell().setText(getWindowTitle());
    applyDialogFont(composite);
    return composite;
}
Also used : RepositoryTreeNodeType(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNodeType) PatternFilter(org.eclipse.ui.dialogs.PatternFilter) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FilteredTree(org.eclipse.ui.dialogs.FilteredTree) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoriesViewContentProvider(org.eclipse.egit.ui.internal.repository.RepositoriesViewContentProvider) RepositoriesViewStyledCellLabelProvider(org.eclipse.egit.ui.internal.repository.RepositoriesViewStyledCellLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) RepositoryTreeNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener)

Aggregations

RepositoryTreeNode (org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode)2 RepositoryTreeNodeType (org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNodeType)2 File (java.io.File)1 RepositoriesViewContentProvider (org.eclipse.egit.ui.internal.repository.RepositoriesViewContentProvider)1 RepositoriesViewStyledCellLabelProvider (org.eclipse.egit.ui.internal.repository.RepositoriesViewStyledCellLabelProvider)1 TagNode (org.eclipse.egit.ui.internal.repository.tree.TagNode)1 CompositeImageDescriptor (org.eclipse.jface.resource.CompositeImageDescriptor)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1 Repository (org.eclipse.jgit.lib.Repository)1 Image (org.eclipse.swt.graphics.Image)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 FilteredTree (org.eclipse.ui.dialogs.FilteredTree)1 PatternFilter (org.eclipse.ui.dialogs.PatternFilter)1