use of org.eclipse.jface.viewers.ViewerCell in project netxms by netxms.
the class CellSelectionManager method handleSelection.
/**
* @param event
*/
private void handleSelection(Event event) {
if ((event.detail & SWT.CHECK) == 0 && focusCell != null && focusCell.getItem() != event.item && event.item != null && !event.item.isDisposed()) {
ViewerRow row = viewer.getViewerRowFromItem(event.item);
// $NON-NLS-1$
Assert.isNotNull(row, "Internal Structure invalid. Row item has no row ViewerRow assigned");
ViewerCell tmp = row.getCell(focusCell.getColumnIndex());
if (!focusCell.equals(tmp)) {
setFocusCell(tmp, true);
}
}
}
use of org.eclipse.jface.viewers.ViewerCell in project eclipse-integration-commons by spring-projects.
the class SwtConnect method boldMatchedElements.
/**
* Decorate a basic LabelProvider so that it bolds matched elements based on a text-based filter applied to its labels.
*/
public static StyledCellLabelProvider boldMatchedElements(Stylers stylers, ILabelProvider baseLabels, Filter<String> filter) {
return new StyledCellLabelProvider() {
@Override
public void update(ViewerCell cell) {
Object element = cell.getElement();
// image
cell.setImage(baseLabels.getImage(element));
// styled label
String label = baseLabels.getText(element);
StyledString styledLabel = new StyledString(label);
if (filter.accept(label)) {
Styler bold = stylers.bold();
for (IRegion r : filter.getHighlights(label)) {
styledLabel.setStyle(r.getOffset(), r.getLength(), bold);
}
}
cell.setStyleRanges(styledLabel.getStyleRanges());
cell.setText(styledLabel.getString());
cell.getControl().redraw();
// ^^^ Sigh... Yes, this is needed. It seems SWT/Jface isn't smart enough to itself figure out that if
// the styleranges change a redraw is needed to make the change visible.
}
};
}
use of org.eclipse.jface.viewers.ViewerCell in project webtools.sourceediting by eclipse.
the class OutputPropertiesBlock method createControl.
public void createControl(Composite parent) {
TabItem item = new TabItem((TabFolder) parent, SWT.NONE);
// $NON-NLS-1$
item.setText(Messages.getString("OutputPropertiesBlock_0"));
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginBottom = 0;
layout.marginWidth = 0;
composite.setLayout(layout);
item.setControl(composite);
table = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.MULTI);
table.setHeaderVisible(true);
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
table.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
if (event.character == SWT.DEL && event.stateMask == 0) {
performRemove();
}
}
});
TableColumn tc1 = new TableColumn(table, SWT.NONE);
// $NON-NLS-1$
tc1.setText(Messages.getString("OutputPropertiesBlock_1"));
tc1.setWidth(350);
tc1.setResizable(true);
TableColumn tc2 = new TableColumn(table, SWT.NONE);
// $NON-NLS-1$
tc2.setText(Messages.getString("OutputPropertiesBlock_2"));
tc2.setWidth(50);
tc2.setResizable(true);
Composite buttonComp = new Composite(composite, SWT.FILL);
buttonComp.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
GridLayout gl = new GridLayout();
gl.marginWidth = 0;
buttonComp.setLayout(gl);
Button addButton = new Button(buttonComp, SWT.PUSH);
// $NON-NLS-1$
addButton.setText(Messages.getString("OutputPropertiesBlock_3"));
addButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
addButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
OutputPropertyDialog dialog = new OutputPropertyDialog(getShell(), properties);
if (dialog.open() == Window.OK) {
List<IOutputProperty> newProperties = dialog.getOutpuProperties();
String first = null;
for (IOutputProperty property : newProperties) {
String att = property.getURI();
if (first == null)
first = att;
properties.setProperty(property.getURI(), null);
}
if (newProperties.size() > 0) {
tViewer.refresh();
tViewer.setSelection(new StructuredSelection(first), true);
tViewer.editElement(first, 1);
updateLaunchConfigurationDialog();
}
}
}
});
removeButton = new Button(buttonComp, SWT.PUSH);
// $NON-NLS-1$
removeButton.setText(Messages.getString("OutputPropertiesBlock_4"));
removeButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
removeButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
performRemove();
}
});
setControl(table);
tViewer = new TableViewer(table);
tViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
return properties.getProperties().keySet().toArray(new String[0]);
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tViewer.setSorter(new ViewerSorter());
tViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
updateRemoveButton();
}
});
TableViewerColumn tvc1 = new TableViewerColumn(tViewer, tc1);
tvc1.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
String tv = (String) cell.getElement();
cell.setText(tv);
}
@Override
public int getToolTipTimeDisplayed(Object object) {
return 5000;
}
@Override
public String getToolTipText(Object element) {
String tv = (String) element;
return propertyUris.get(tv).getDescription();
}
});
// ColumnViewerToolTipSupport.enableFor(tViewer);
TableViewerColumn tvc2 = new TableViewerColumn(tViewer, tc2);
tvc2.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
String tv = (String) cell.getElement();
String val = properties.getProperty(tv);
// $NON-NLS-1$
cell.setText(val == null ? "" : val);
}
});
tvc2.setEditingSupport(new EditingSupport(tViewer) {
@Override
protected boolean canEdit(Object element) {
return true;
}
@Override
protected CellEditor getCellEditor(Object element) {
return new TextCellEditor(table);
}
@Override
protected Object getValue(Object element) {
String tv = (String) element;
String val = properties.getProperty(tv);
// $NON-NLS-1$
return val == null ? "" : val;
}
@Override
protected void setValue(Object element, Object value) {
String tv = (String) element;
properties.setProperty(tv, (String) value);
updateLaunchConfigurationDialog();
tViewer.update(tv, null);
}
});
restoreColumnSettings();
}
use of org.eclipse.jface.viewers.ViewerCell in project bndtools by bndtools.
the class RunBundlesPart method getLabelProvider.
@Override
protected IBaseLabelProvider getLabelProvider() {
return new VersionedClauseLabelProvider() {
@Override
public void update(ViewerCell cell) {
Object element = cell.getElement();
if (element instanceof String) {
String builder = (String) element;
StyledString label = new StyledString(builder, StyledString.QUALIFIER_STYLER);
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(projectImg);
} else {
super.update(cell);
}
}
};
}
use of org.eclipse.jface.viewers.ViewerCell in project bndtools by bndtools.
the class WorkspacePreviewPage method createControl.
@Override
public void createControl(Composite parent) {
setTitle("Preview Changes");
// $NON-NLS-1$
setImageDescriptor(Plugin.imageDescriptorFromPlugin("icons/bndtools-wizban.png"));
imgAdded = AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/incoming.gif").createImage(parent.getDisplay());
imgOverwrite = AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/conflict.gif").createImage(parent.getDisplay());
imgError = AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/error_obj.gif").createImage(parent.getDisplay());
int columns = 4;
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(columns, false);
composite.setLayout(layout);
setControl(composite);
Label lblTitle = new Label(composite, SWT.NONE);
lblTitle.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, columns, 1));
// Table
tblOutputs = new Table(composite, SWT.BORDER | SWT.CHECK);
tblOutputs.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, columns, 1));
vwrOutputs = new CheckboxTableViewer(tblOutputs);
vwrOutputs.setContentProvider(ArrayContentProvider.getInstance());
vwrOutputs.setLabelProvider(new StyledCellLabelProvider() {
@Override
public void update(ViewerCell cell) {
StyledString label;
Image icon;
String path = (String) cell.getElement();
String error = resourceErrors.get(path);
if (error != null) {
label = new StyledString(path, ItalicStyler.INSTANCE_ERROR);
icon = imgError;
} else {
label = new StyledString(path);
icon = existingFiles.contains(path) ? imgOverwrite : imgAdded;
}
cell.setText(path);
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(icon);
}
});
vwrOutputs.setSorter(new ViewerSorter(Collator.getInstance()));
// Details display
final Label lblDetails = new Label(composite, SWT.NONE);
lblDetails.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, columns, 1));
lblDetails.setText(MSG_NOTHING_SELECTED);
// Button Panel
Label spacer1 = new Label(composite, SWT.NONE);
spacer1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
Button btnSelectNonConflict = new Button(composite, SWT.PUSH);
btnSelectNonConflict.setText("Select Non-Conflicting");
btnSelectNonConflict.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
modifyLock.modifyOperation(new Runnable() {
@Override
public void run() {
checkedPaths.clear();
for (Entry<String, Resource> entry : templateOutputs.entries()) {
String path = entry.getKey();
if (!existingFiles.contains(path))
checkedPaths.add(path);
}
vwrOutputs.setCheckedElements(checkedPaths.toArray());
}
});
}
});
Button btnSelectAll = new Button(composite, SWT.PUSH);
btnSelectAll.setText("Select All");
btnSelectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
vwrOutputs.setAllChecked(true);
}
});
Button btnSelectNone = new Button(composite, SWT.PUSH);
btnSelectNone.setText("Select None");
btnSelectNone.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
vwrOutputs.setAllChecked(false);
}
});
// Listeners
vwrOutputs.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) vwrOutputs.getSelection();
if (sel.isEmpty()) {
lblDetails.setText(MSG_NOTHING_SELECTED);
} else {
String path = (String) sel.getFirstElement();
String resourceError = resourceErrors.get(path);
if (resourceError != null) {
lblDetails.setText(resourceError);
} else if (existingFiles.contains(path)) {
lblDetails.setText("This file already exists and will be overwritten");
} else {
lblDetails.setText("This file will be created");
}
}
}
});
vwrOutputs.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(final CheckStateChangedEvent event) {
modifyLock.ifNotModifying(new Runnable() {
@Override
public void run() {
final String updatedPath = (String) event.getElement();
if (event.getChecked()) {
checkedPaths.add(updatedPath);
// Check any directories that are parents of this path
modifyLock.modifyOperation(new Runnable() {
@Override
public void run() {
for (Entry<String, Resource> entry : templateOutputs.entries()) {
String path = entry.getKey();
if (path.endsWith("/") && updatedPath.startsWith(path)) {
checkedPaths.add(path);
vwrOutputs.setChecked(path, true);
}
}
}
});
} else {
checkedPaths.remove(updatedPath);
// Uncheck any paths that are descendants of this path
if (updatedPath.endsWith("/")) {
modifyLock.modifyOperation(new Runnable() {
@Override
public void run() {
for (Entry<String, Resource> entry : templateOutputs.entries()) {
String path = entry.getKey();
if (path.startsWith(updatedPath)) {
checkedPaths.remove(path);
vwrOutputs.setChecked(path, false);
}
}
}
});
}
}
}
});
}
});
}
Aggregations