use of org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider in project jbosstools-openshift by jbosstools.
the class ResourceLabelsPage method createTable.
protected TableViewer createTable(Composite tableContainer) {
Table table = new Table(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
table.setLinesVisible(true);
table.setHeaderVisible(true);
this.viewer = new TableViewerBuilder(table, tableContainer).contentProvider(new ArrayContentProvider()).<Label>column(new DelegatingStyledCellLabelProvider(new LabelTextProvider() {
@Override
public String getValue(Label label) {
return label.getName();
}
})).name(LABEL_KEY).align(SWT.LEFT).weight(2).minWidth(100).buildColumn().<Label>column(new DelegatingStyledCellLabelProvider(new LabelTextProvider() {
@Override
public String getValue(Label label) {
return label.getValue();
}
})).name("Value").align(SWT.LEFT).weight(2).minWidth(100).buildColumn().buildViewer();
viewer.addDoubleClickListener(e -> editLabel((Label) ((IStructuredSelection) e.getSelection()).getFirstElement()));
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
Label first = (Label) e1;
Label other = (Label) e2;
return first.getName().compareTo(other.getName());
}
});
return viewer;
}
use of org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider in project usbdm-eclipse-plugins by podonoghue.
the class TreeEditor method createControl.
public Control createControl(Composite parent, int style) {
// parent.setLayoutData(new FillLayout());
fViewer = new TreeViewer(parent, SWT.FULL_SELECTION | style);
ColumnViewerToolTipSupport.enableFor(fViewer);
Tree tree = fViewer.getTree();
tree.setLinesVisible(true);
tree.setHeaderVisible(true);
fViewer.setContentProvider(new ViewContentProvider());
ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(fViewer) {
@Override
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
return event.eventType == ColumnViewerEditorActivationEvent.MOUSE_CLICK_SELECTION;
}
};
TreeViewerEditor.create(fViewer, actSupport, ColumnViewerEditor.DEFAULT);
final TreeColumnInformation[] fColumnInformation = getColumnInformation(fViewer);
fColumns = new TreeViewerColumn[fColumnInformation.length];
for (int index = 0; index < fColumnInformation.length; index++) {
fColumns[index] = new TreeViewerColumn(fViewer, SWT.NONE);
fColumns[index].getColumn().setWidth(fColumnInformation[index].width);
fColumns[index].setLabelProvider(new DelegatingStyledCellLabelProvider(fColumnInformation[index].labelProvider));
fColumns[index].getColumn().setText(fColumnInformation[index].name);
if (fColumnInformation[index].editingSupport != null) {
fColumns[index].setEditingSupport(fColumnInformation[index].editingSupport);
}
}
return fViewer.getControl();
}
use of org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider in project egit by eclipse.
the class RevertFailureDialog method createCustomArea.
@Override
protected Control createCustomArea(Composite parent) {
if (reasons == null || reasons.isEmpty())
return null;
Composite fileArea = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 80).applyTo(fileArea);
GridLayoutFactory.fillDefaults().applyTo(fileArea);
TreeViewer viewer = new TreeViewer(fileArea);
viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl());
viewer.setContentProvider(new WorkbenchContentProvider() {
@Override
public Object[] getElements(Object element) {
return ((Collection) element).toArray();
}
});
final IStyledLabelProvider styleProvider = new WorkbenchStyledLabelProvider() {
@Override
public StyledString getStyledText(Object element) {
// supported
if (element instanceof RevertFailure)
return ((RevertFailure) element).getStyledText(element);
if (element instanceof Path)
return ((Path) element).getStyledText(element);
return super.getStyledText(element);
}
};
viewer.setLabelProvider(new DelegatingStyledCellLabelProvider(styleProvider));
viewer.setComparator(new ViewerComparator());
Map<MergeFailureReason, RevertFailure> failures = new HashMap<>();
for (Entry<String, MergeFailureReason> reason : reasons.entrySet()) {
RevertFailure failure = failures.get(reason.getValue());
if (failure == null) {
failure = new RevertFailure(reason.getValue());
failures.put(reason.getValue(), failure);
}
failure.add(reason.getKey());
}
viewer.setInput(failures.values());
return fileArea;
}
use of org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider in project webtools.sourceediting by eclipse.
the class ConfigurableContentOutlinePage method setConfiguration.
/**
* Configures (or reconfigures) the page according to the given
* configuration.
*
* @param configuration
*/
public void setConfiguration(ContentOutlineConfiguration configuration) {
// intentionally do not check to see if the new configuration != old
// configuration
unconfigure();
fConfiguration = configuration;
if (getTreeViewer() != null && getControl() != null && !getControl().isDisposed()) {
// (re)set the providers
ILabelProvider labelProvider = getConfiguration().getLabelProvider(getTreeViewer());
if (labelProvider instanceof IStyledLabelProvider) {
getTreeViewer().setLabelProvider(new DelegatingStyledCellLabelProvider((IStyledLabelProvider) labelProvider));
} else {
getTreeViewer().setLabelProvider(labelProvider);
}
getTreeViewer().setContentProvider(getConfiguration().getContentProvider(getTreeViewer()));
// view toolbar
IContributionManager toolbar = getSite().getActionBars().getToolBarManager();
if (toolbar != null) {
IContributionItem[] toolbarItems = getConfiguration().getToolbarContributions(getTreeViewer());
if (toolbarItems != null) {
for (int i = 0; i < toolbarItems.length; i++) {
toolbar.add(toolbarItems[i]);
}
toolbar.update(true);
}
}
// view menu
IContributionManager menu = getSite().getActionBars().getMenuManager();
if (menu != null) {
IContributionItem[] menuItems = getConfiguration().getMenuContributions(getTreeViewer());
if (menuItems != null) {
for (int i = 0; i < menuItems.length; i++) {
menuItems[i].setVisible(true);
menu.add(menuItems[i]);
menuItems[i].update();
}
menu.update(true);
}
}
// add the allowed DnD listeners and types
TransferDragSourceListener[] dragListeners = getConfiguration().getTransferDragSourceListeners(getTreeViewer());
if (fDragAdapter != null && dragListeners.length > 0) {
for (int i = 0; i < dragListeners.length; i++) {
fDragAdapter.addDragSourceListener(dragListeners[i]);
}
fActiveDragListeners = dragListeners;
fDragSource.addDragListener(fDragAdapter);
fDragSource.setTransfer(fDragAdapter.getTransfers());
}
TransferDropTargetListener[] dropListeners = getConfiguration().getTransferDropTargetListeners(getTreeViewer());
if (fDropAdapter != null && dropListeners.length > 0) {
for (int i = 0; i < dropListeners.length; i++) {
fDropAdapter.addDropTargetListener(dropListeners[i]);
}
fActiveDropListeners = dropListeners;
fDropTarget.addDropListener(fDropAdapter);
fDropTarget.setTransfer(fDropAdapter.getTransfers());
}
// add the key listeners
KeyListener[] listeners = getConfiguration().getKeyListeners(getTreeViewer());
if (listeners != null) {
for (int i = 0; i < listeners.length; i++) {
getControl().addKeyListener(listeners[i]);
}
}
}
if (fInput != null) {
setInput(fInput);
}
}
use of org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider in project n4js by eclipse.
the class WorkingSetConfigurationDialog method createTableViewer.
private void createTableViewer(final Composite parent) {
tableViewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER | SWT.MULTI);
tableViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(final CheckStateChangedEvent event) {
syncSelectionAndButtonStates();
}
});
final GridData data = new GridData(GridData.FILL_BOTH);
data.heightHint = convertHeightInCharsToPixels(20);
data.widthHint = convertWidthInCharsToPixels(50);
tableViewer.getTable().setLayoutData(data);
tableViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(WorkingSetLabelProvider.INSTANCE));
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
handleSelectionChanged();
}
});
tableViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(final DoubleClickEvent event) {
if (editButton != null && editButton.isEnabled()) {
editSelectedWorkingSet();
}
}
});
}
Aggregations