use of org.eclipse.jface.viewers.ViewerCell in project org.csstudio.display.builder by kasemir.
the class ArchiveListGUI method createGUI.
/**
* Create GUI elements
* @param parent Parent widget
*/
private void createGUI(final Composite parent) {
final GridLayout layout = new GridLayout(3, false);
parent.setLayout(layout);
// URL: ___urls___ [info]
Label l;
l = new Label(parent, 0);
l.setText(Messages.Search_URL);
l.setLayoutData(new GridData());
urls = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
urls.setToolTipText(Messages.Search_URL_TT);
for (ArchiveServerURL url : server_urls) urls.add(url.getDisplayName());
urls.setLayoutData(new GridData(SWT.FILL, 0, true, false));
if (urls.getItemCount() <= 0) {
urls.add(Messages.ArchiveListGUI_NoArchives);
urls.setEnabled(false);
}
urls.select(0);
info = new Button(parent, SWT.PUSH);
info.setText(Messages.ArchiveServerInfo);
info.setToolTipText(Messages.ArchiveServerInfoTT);
info.setEnabled(false);
// Table for archives, displaying array of ArchiveDataSource entries
// TableColumnLayout requires table in its own container
final Composite table_parent = new Composite(parent, 0);
table_parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, layout.numColumns, 1));
final TableColumnLayout table_layout = new MinSizeTableColumnLayout(10);
table_parent.setLayout(table_layout);
archive_table = new TableViewer(table_parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
archive_table.setContentProvider(new ArrayContentProvider());
TableViewerColumn col = TableHelper.createColumn(table_layout, archive_table, Messages.ArchiveName, 150, 100);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ArchiveDataSource archive = (ArchiveDataSource) cell.getElement();
cell.setText(archive.getName());
}
});
new TableColumnSortHelper<ArchiveDataSource>(archive_table, col) {
@Override
public int compare(final ArchiveDataSource item1, final ArchiveDataSource item2) {
return item1.getName().compareTo(item2.getName());
}
};
col = TableHelper.createColumn(table_layout, archive_table, Messages.ArchiveDescription, 50, 100);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ArchiveDataSource archive = (ArchiveDataSource) cell.getElement();
cell.setText(archive.getDescription());
}
});
new TableColumnSortHelper<ArchiveDataSource>(archive_table, col) {
@Override
public int compare(final ArchiveDataSource item1, final ArchiveDataSource item2) {
return item1.getDescription().compareTo(item2.getDescription());
}
};
col = TableHelper.createColumn(table_layout, archive_table, Messages.ArchiveKey, 35, 5);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ArchiveDataSource archive = (ArchiveDataSource) cell.getElement();
cell.setText(Integer.toString(archive.getKey()));
}
});
new TableColumnSortHelper<ArchiveDataSource>(archive_table, col) {
@Override
public int compare(final ArchiveDataSource item1, final ArchiveDataSource item2) {
return item1.getKey() - item2.getKey();
}
};
final Table table = archive_table.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
}
use of org.eclipse.jface.viewers.ViewerCell in project org.csstudio.display.builder by kasemir.
the class ArchivesTableHandler method createColumns.
/**
* Create table columns: Auto-sizable, with label provider and editor
* @param table_layout
* @param operations_manager
* @param archives_table
*/
public void createColumns(TableColumnLayout table_layout, final UndoableActionManager operations_manager, final TableViewer archives_table) {
table_viewer = archives_table;
TableViewerColumn col;
// Archive Name Column ----------
col = TableHelper.createColumn(table_layout, archives_table, Messages.ArchiveName, 100, 20);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ArchiveDataSource archive = (ArchiveDataSource) cell.getElement();
cell.setText(archive.getName());
}
});
// Archive Key Column ----------
col = TableHelper.createColumn(table_layout, archives_table, Messages.ArchiveKey, 20, 5);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ArchiveDataSource archive = (ArchiveDataSource) cell.getElement();
cell.setText(Integer.toString(archive.getKey()));
}
});
// Archive Server URL Column ----------
col = TableHelper.createColumn(table_layout, archives_table, Messages.URL, 50, 100);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ArchiveDataSource archive = (ArchiveDataSource) cell.getElement();
cell.setText(archive.getUrl());
}
});
}
use of org.eclipse.jface.viewers.ViewerCell in project netxms by netxms.
the class TableValueViewer method showDataComparisonChart.
/**
* Show line chart
*/
private void showDataComparisonChart(int chartType) {
if (currentData == null)
return;
ViewerCell[] cells = cellSelectionManager.getSelectedCells();
if (cells.length == 0)
return;
// $NON-NLS-1$
String id = Long.toString(uniqueId++) + "&" + Integer.toString(chartType);
for (int i = 0; i < cells.length; i++) {
TableColumnDefinition column = currentData.getColumnDefinition(cells[i].getColumnIndex());
String instance = buildInstanceString(cells[i].getViewerRow());
int source = currentData.getSource();
id += // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"&" + Long.toString(objectId) + "@" + Long.toString(dciId) + "@" + Integer.toString(source) + "@" + Integer.toString(column.getDataType().getValue()) + "@" + safeEncode(currentData.getTitle()) + // $NON-NLS-1$ //$NON-NLS-2$
"@" + safeEncode(column.getDisplayName() + ": " + instance.replace("~~~", " / ")) + "@" + safeEncode(instance) + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"@" + safeEncode(column.getName());
}
final IWorkbenchPage page = (viewPart != null) ? viewPart.getSite().getPage() : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
page.showView(DataComparisonView.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 TableValueViewer method showLineChart.
/**
* Show line chart
*/
private void showLineChart() {
if (currentData == null)
return;
ViewerCell[] cells = cellSelectionManager.getSelectedCells();
if (cells.length == 0)
return;
StringBuilder sb = new StringBuilder();
sb.append(uniqueId++);
for (int i = 0; i < cells.length; i++) {
TableColumnDefinition column = currentData.getColumnDefinition(cells[i].getColumnIndex());
final String instance = buildInstanceString(cells[i].getViewerRow());
sb.append("&");
sb.append(ChartDciConfig.TABLE);
sb.append("@");
sb.append(objectId);
sb.append("@");
sb.append(dciId);
sb.append("@");
sb.append(safeEncode(column.getDisplayName() + ": " + instance.replace("~~~", " / ")));
sb.append("@");
sb.append(safeEncode(instance));
sb.append("@");
sb.append(safeEncode(column.getName()));
}
final IWorkbenchPage page = (viewPart != null) ? viewPart.getSite().getPage() : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
page.showView(HistoricalGraphView.ID, sb.toString(), 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 GalleryTreeViewer method editElement.
public void editElement(Object element, int column) {
if (element instanceof TreePath) {
setSelection(new TreeSelection((TreePath) element));
GalleryItem[] items = gallery.getSelection();
if (items.length == 1) {
ViewerRow row = getViewerRowFromItem(items[0]);
if (row != null) {
ViewerCell cell = row.getCell(column);
if (cell != null) {
getControl().setRedraw(false);
triggerEditorActivationEvent(new ColumnViewerEditorActivationEvent(cell));
getControl().setRedraw(true);
}
}
}
} else {
super.editElement(element, column);
}
}
Aggregations