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);
}
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;
}
Aggregations