use of org.eclipse.jface.viewers.ViewerCell in project tdq-studio-se by Talend.
the class GridTableViewer method editElement.
/**
* {@inheritDoc}
*/
public void editElement(Object element, int column) {
try {
getControl().setRedraw(false);
Widget item = findItem(element);
if (item != null) {
ViewerRow row = getViewerRowFromItem(item);
if (row != null) {
ViewerCell cell = row.getCell(column);
if (cell != null) {
triggerEditorActivationEvent(new ColumnViewerEditorActivationEvent(cell));
}
}
}
} finally {
getControl().setRedraw(true);
}
// }
}
use of org.eclipse.jface.viewers.ViewerCell in project tdq-studio-se by Talend.
the class GridTableViewer method updateRowHeader.
private void updateRowHeader(Widget widget) {
if (rowHeaderLabelProvider != null) {
ViewerCell cell = getViewerRowFromItem(widget).getCell(Integer.MAX_VALUE);
rowHeaderLabelProvider.update(cell);
}
}
use of org.eclipse.jface.viewers.ViewerCell in project jbosstools-openshift by jbosstools.
the class TemplateParametersPage method buildTableViewer.
private TableViewer buildTableViewer(Table table, Composite tableContainer, ObservableMap<String, IStatus> cellsValidationStatusObservable, TableViewerCellDecorationManager decorations) {
final TableViewerBuilder builder = new TableViewerBuilder(table, tableContainer);
TableViewer tableViewer = builder.contentProvider(new ObservableListContentProvider()).column(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
Assert.isLegal(cell.getElement() instanceof IParameter, CELL_NOT_PARAMETER_ERROR);
IParameter parameter = (IParameter) cell.getElement();
String label = parameter.getName();
if (parameter.isRequired()) {
label = markRequired(label);
}
cell.setText(label);
}
private String markRequired(String label) {
return label += " *";
}
@Override
public String getToolTipText(Object object) {
Assert.isLegal(object instanceof IParameter, CELL_NOT_PARAMETER_ERROR);
return ((IParameter) object).getDescription();
}
@Override
public int getToolTipDisplayDelayTime(Object object) {
return 0;
}
}).name("Name").align(SWT.LEFT).weight(1).minWidth(180).buildColumn().column(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
Assert.isLegal(cell.getElement() instanceof IParameter, CELL_NOT_PARAMETER_ERROR);
final IParameter parameter = (IParameter) cell.getElement();
String label = TemplateParameterViewerUtils.getValueLabel(parameter);
cell.setText(label);
boolean italic = ((ApplicationSourceFromTemplateModel) model).isParameterModified(parameter);
builder.applyFont(cell, italic);
IStatus validationStatus = validate(parameter);
cellsValidationStatusObservable.put(parameter.getName(), validationStatus);
decorations.toggle(!validationStatus.isOK(), cell);
}
private IStatus validate(IParameter parameter) {
if (parameter.isRequired() && StringUtils.isEmpty(parameter.getValue()) && StringUtils.isEmpty(parameter.getGeneratorName())) {
return ValidationStatus.error(NLS.bind("Parameter {0} is required, please provide a value.", parameter.getName()));
}
IStatus status = gitSourceValidator.validate(parameter);
if (!status.isOK()) {
return status;
}
return ValidationStatus.ok();
}
@Override
public String getToolTipText(Object object) {
Assert.isLegal(object instanceof IParameter, CELL_NOT_PARAMETER_ERROR);
return ((IParameter) object).getDescription();
}
@Override
public int getToolTipDisplayDelayTime(Object object) {
return 0;
}
}).name("Value").align(SWT.LEFT).weight(1).buildColumn().buildViewer();
tableViewer.setComparator(new TemplateParameterViewerUtils.ParameterNameViewerComparator());
return tableViewer;
}
use of org.eclipse.jface.viewers.ViewerCell in project netxms by netxms.
the class TableValueViewer method showHistory.
/**
* Show history
*/
private void showHistory() {
if (currentData == null)
return;
ViewerCell[] cells = cellSelectionManager.getSelectedCells();
if (cells.length == 0)
return;
for (int i = 0; i < cells.length; i++) {
TableColumnDefinition column = currentData.getColumnDefinition(cells[i].getColumnIndex());
final String instance = buildInstanceString(cells[i].getViewerRow());
String id = // $NON-NLS-1$ //$NON-NLS-2$
Long.toString(objectId) + "&" + Long.toString(dciId) + "@" + safeEncode(column.getDisplayName() + ": " + instance.replace("~~~", " / ")) + // $NON-NLS-1$
"@" + safeEncode(instance) + "@" + // $NON-NLS-1$ //$NON-NLS-2$
safeEncode(column.getName());
final IWorkbenchPage page = (viewPart != null) ? viewPart.getSite().getPage() : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
page.showView(HistoricalDataView.ID, id, IWorkbenchPage.VIEW_ACTIVATE);
} catch (Exception e) {
MessageDialogHelper.openError(page.getWorkbenchWindow().getShell(), Messages.get().TableValue_Error, String.format(Messages.get().TableValue_ErrorOpeningView, e.getLocalizedMessage()));
}
}
}
use of org.eclipse.jface.viewers.ViewerCell in project netxms by netxms.
the class CellSelectionManager method setFocusCell.
/**
* @param focusCell
*/
void setFocusCell(ViewerCell focusCell, boolean clearSelection) {
if (clearSelection) {
for (ViewerCell cell : selectedCells) cellHighlighter.unmarkCell(cell);
selectedCells.clear();
if (focusCell != null) {
selectedCells.add(focusCell);
cellHighlighter.markCell(focusCell);
}
} else if (focusCell != null) {
if (selectedCells.contains(focusCell)) {
selectedCells.remove(focusCell);
cellHighlighter.unmarkCell(focusCell);
} else {
selectedCells.add(focusCell);
cellHighlighter.markCell(focusCell);
}
}
ViewerCell oldCell = this.focusCell;
if (this.focusCell != null && !this.focusCell.getItem().isDisposed()) {
this.focusCell.getItem().removeDisposeListener(itemDeletionListener);
}
this.focusCell = focusCell;
if (this.focusCell != null && !this.focusCell.getItem().isDisposed()) {
this.focusCell.getItem().addDisposeListener(itemDeletionListener);
}
if (focusCell != null) {
focusCell.scrollIntoView();
}
cellHighlighter.focusCellChanged(focusCell, oldCell);
viewer.getControl().getAccessible().setFocus(ACC.CHILDID_SELF);
}
Aggregations