use of org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider in project n4js by eclipse.
the class ExternalLibraryPreferencePage method createContents.
@Override
protected Control createContents(final Composite parent) {
final Composite control = new Composite(parent, NONE);
control.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).create());
control.setLayoutData(fillDefaults().align(FILL, FILL).create());
viewer = new TreeViewerBuilder(singletonList(""), contentProvider.get()).setVirtual(true).setHeaderVisible(false).setHasBorder(true).setColumnWeights(asList(1)).setLabelProvider(new DelegatingStyledCellLabelProvider(new BuiltInLibrariesLabelProvider())).build(control);
setViewerInput();
final Composite subComposite = new Composite(control, NONE);
subComposite.setLayout(GridLayoutFactory.fillDefaults().create());
subComposite.setLayoutData(fillDefaults().align(END, TOP).create());
createEnabledPushButton(subComposite, "Add...", createSelectionListener(this::handleAddButtonSelectionListener));
final Button remove = createDisabledPushButton(subComposite, "Remove", createSelectionListener(this::handleRemoveButtonSelection));
createPlaceHolderLabel(subComposite);
final Button moveUp = createDisabledPushButton(subComposite, "Up", createSelectionListener(this::handleMoveUpButtonSelection));
final Button moveDown = createDisabledPushButton(subComposite, "Down", createSelectionListener(this::handleMoveDownButtonSelection));
createPlaceHolderLabel(subComposite);
createPlaceHolderLabel(subComposite);
createEnabledPushButton(subComposite, "Install npm...", new InstallNpmDependencyButtonListener(this::intallAndUpdate, () -> getPackageNameToInstallValidator(), () -> getPackageVersionValidator(), statusHelper));
createEnabledPushButton(subComposite, "Uninstall npm...", new UninstallNpmDependencyButtonListener(this::unintallAndUpdate, () -> getPackageNameToUninstallValidator(), statusHelper, this::getSelectedNpm));
createEnabledPushButton(subComposite, "Run maintenance actions...", new MaintenanceActionsButtonListener(this::runMaintananceActions));
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final /* @Nullable */
SelectionChangedEvent event) {
final Tree tree = viewer.getTree();
final TreeItem[] selection = tree.getSelection();
if (!Arrays2.isEmpty(selection) && 1 == selection.length && selection[0].getData() instanceof URI) {
final URI uri = (URI) selection[0].getData();
if (BUILT_IN_LIBS.containsKey(uri)) {
remove.setEnabled(false);
moveUp.setEnabled(false);
moveDown.setEnabled(false);
} else {
final int selectionIndex = tree.indexOf(selection[0]);
final int itemCount = tree.getItemCount();
remove.setEnabled(true);
if (selectionIndex > 0) {
moveUp.setEnabled(!BUILT_IN_LIBS.containsKey(tree.getItem(selectionIndex - 1).getData()));
} else {
moveUp.setEnabled(0 != selectionIndex);
}
moveDown.setEnabled(selectionIndex != itemCount - 1);
}
} else {
remove.setEnabled(false);
moveUp.setEnabled(false);
moveDown.setEnabled(false);
}
}
});
return control;
}
use of org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider in project statecharts by Yakindu.
the class SelectExamplePage method createTreeViewer.
protected void createTreeViewer(Composite container) {
viewer = new TableViewer(container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE);
GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl());
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new ExampleLabelProvider()));
viewer.addSelectionChangedListener(this);
}
use of org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider in project webtools.sourceediting by eclipse.
the class OccurrencesSearchViewPage method configureTableViewer.
/**
* @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#configureTableViewer(org.eclipse.jface.viewers.TableViewer)
*/
protected void configureTableViewer(TableViewer viewer) {
// sort results by line number, low to high
viewer.setComparator(new ViewerComparator() {
public int compare(Viewer v, Object obj1, Object obj2) {
BasicSearchMatchElement elem1 = (BasicSearchMatchElement) obj1;
BasicSearchMatchElement elem2 = (BasicSearchMatchElement) obj2;
return elem1.getLineNum() - elem2.getLineNum();
}
});
// allow for formated labels
viewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new BasicSearchLabelProvider(this)));
this.fContentProvider = new OccurrencesContentProvider();
viewer.setContentProvider(this.fContentProvider);
}
use of org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider in project epp.mpc by eclipse.
the class FeatureSelectionWizardPage method createControl.
public void createControl(Composite parent) {
container = new Composite(parent, SWT.NONE);
switchResultLayout = new StackLayout();
container.setLayout(switchResultLayout);
GridData data = new GridData(GridData.FILL_BOTH);
container.setLayoutData(data);
defaultComposite = new Composite(container, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(defaultComposite);
Composite treeContainer = new Composite(defaultComposite, SWT.NULL);
GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(treeContainer);
TreeColumnLayout columnLayout = new TreeColumnLayout();
treeContainer.setLayout(columnLayout);
viewer = new CheckboxTreeViewer(treeContainer, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
viewer.setUseHashlookup(true);
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
if (e1 == e2) {
return 0;
}
String s1;
String s2;
if (e1 instanceof CatalogItemEntry) {
s1 = ((CatalogItemEntry) e1).getItem().getName();
s2 = ((CatalogItemEntry) e2).getItem().getName();
} else {
FeatureEntry fe1 = (FeatureEntry) e1;
FeatureEntry fe2 = (FeatureEntry) e2;
if (fe1.getInstallableUnitItem().isOptional() != fe2.getInstallableUnitItem().isOptional()) {
// required items first
return fe1.getInstallableUnitItem().isOptional() ? 1 : -1;
}
s1 = fe1.getFeatureDescriptor().getName();
s2 = fe2.getFeatureDescriptor().getName();
}
int i = s1.compareToIgnoreCase(s2);
if (i == 0) {
i = s1.compareTo(s2);
if (i == 0) {
i = new Integer(System.identityHashCode(e1)).compareTo(System.identityHashCode(e2));
}
}
return i;
}
});
viewer.setContentProvider(new ContentProvider());
viewer.setInput(getWizard().getSelectionModel());
viewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
boolean checked = event.getChecked();
if (event.getElement() instanceof CatalogItemEntry) {
CatalogItemEntry entry = (CatalogItemEntry) event.getElement();
for (FeatureEntry child : entry.getChildren()) {
child.setChecked(checked);
}
} else if (event.getElement() instanceof FeatureEntry) {
FeatureEntry featureEntry = (FeatureEntry) event.getElement();
featureEntry.setChecked(checked);
}
refreshState();
}
});
column = new TreeViewerColumn(viewer, SWT.NONE);
column.setLabelProvider(new DelegatingStyledCellLabelProvider(new LabelProvider()));
columnLayout.setColumnData(column.getColumn(), new ColumnWeightData(100, 100, true));
detailsControl = new Group(defaultComposite, SWT.SHADOW_IN);
detailsControl.setText(Messages.FeatureSelectionWizardPage_details);
GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 300).exclude(true).applyTo(detailsControl);
GridLayoutFactory.fillDefaults().applyTo(detailsControl);
detailStatusText = new Text(detailsControl, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
GridDataFactory.fillDefaults().grab(true, true).applyTo(detailStatusText);
setControl(container);
Dialog.applyDialogFont(container);
MarketplaceClientUi.setDefaultHelp(getControl());
flipToDefaultComposite();
}
use of org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider in project liferay-ide by liferay.
the class AbstractCheckboxCustomPart method createPresentation.
@Override
public FormComponentPresentation createPresentation(SwtPresentation parent, Composite composite) {
return new FormComponentPresentation(this, parent, composite) {
@Override
public void render() {
final Composite parent = SWTUtil.createComposite(composite(), 2, 2, GridData.FILL_BOTH);
checkBoxViewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
checkBoxViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
handleCheckStateChangedEvent(event);
}
});
checkBoxViewer.setContentProvider(new CheckboxContentProvider());
checkBoxViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(getLableProvider()));
final Table table = checkBoxViewer.getTable();
final GridData tableData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4);
tableData.heightHint = 225;
tableData.widthHint = 400;
table.setLayoutData(tableData);
final Button selectAllButton = new Button(parent, SWT.NONE);
selectAllButton.setText("Select All");
selectAllButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
selectAllButton.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
handleSelectAllEvent();
}
});
final Button deselectAllButton = new Button(parent, SWT.NONE);
deselectAllButton.setText("Deselect All");
deselectAllButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
deselectAllButton.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
handleDeSelectAllEvent();
}
});
final Button refreshButton = new Button(parent, SWT.NONE);
refreshButton.setText("Refresh");
refreshButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
refreshButton.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
checkAndUpdateCheckboxElement();
}
});
_startCheckThread();
}
private void _startCheckThread() {
final Thread t = new Thread() {
@Override
public void run() {
checkAndUpdateCheckboxElement();
}
};
t.start();
}
};
}
Aggregations