use of org.csstudio.ui.util.MinSizeTableColumnLayout in project org.csstudio.display.builder by kasemir.
the class SearchView method createSearchSash.
/**
* Create the 'lower' sash for searching archives
* @param sashform
*/
private void createSearchSash(final SashForm sashform) {
final Composite parent = new Composite(sashform, SWT.BORDER);
final GridLayout layout = new GridLayout(3, false);
parent.setLayout(layout);
// Pattern: ___pattern___ [x] [search]
Label l = new Label(parent, 0);
l.setText(Messages.SearchPattern);
l.setLayoutData(new GridData());
// On OS X, a 'search' box might look a little better:
// pattern = new Text(parent, SWT.SEARCH | SWT.ICON_CANCEL);
// ... except:
// a) only takes effect on OS X
// b) doesn't support drop-down for recent searches
pattern = new Text(parent, SWT.BORDER);
pattern.setToolTipText(Messages.SearchPatternTT);
pattern.setLayoutData(new GridData(SWT.FILL, 0, true, false));
pattern.setEnabled(false);
pattern.addListener(SWT.DefaultSelection, new Listener() {
@Override
public void handleEvent(Event e) {
searchForChannels();
}
});
AutoCompleteWidget acw = new AutoCompleteWidget(pattern, AutoCompleteTypes.PV);
search = new Button(parent, SWT.PUSH);
search.setText(Messages.Search);
search.setToolTipText(Messages.SearchTT);
search.setLayoutData(new GridData());
search.setEnabled(false);
AutoCompleteUIHelper.handleSelectEvent(search, acw);
// ( ) Add (*) Replace [ ] Reg.Exp.
final Button result_append = new Button(parent, SWT.RADIO);
result_append.setText(Messages.AppendSearchResults);
result_append.setToolTipText(Messages.AppendSearchResultsTT);
result_append.setLayoutData(new GridData());
result_replace = new Button(parent, SWT.RADIO);
result_replace.setText(Messages.ReplaceSearchResults);
result_replace.setToolTipText(Messages.ReplaceSearchResultsTT);
result_replace.setLayoutData(new GridData(SWT.LEFT, 0, true, false));
result_replace.setSelection(true);
regex = new Button(parent, SWT.CHECK);
regex.setText(Messages.RegularExpression);
regex.setToolTipText(Messages.RegularExpressionTT);
regex.setLayoutData(new GridData());
// Table for channel names, displaying array of ChannelInfo entries
// TableColumnLayout requires table in its own composite
final Composite table_parent = new Composite(parent, 0);
final TableColumnLayout table_layout = new MinSizeTableColumnLayout(10);
table_parent.setLayout(table_layout);
table_parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, layout.numColumns, 1));
channel_table = new TableViewer(table_parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
channel_table.setContentProvider(new ArrayContentProvider());
TableViewerColumn col = TableHelper.createColumn(table_layout, channel_table, Messages.PVName, 200, 100);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ChannelInfo channel = (ChannelInfo) cell.getElement();
cell.setText(channel.getProcessVariable().getName());
}
});
new TableColumnSortHelper<ChannelInfo>(channel_table, col) {
@Override
public int compare(final ChannelInfo item1, final ChannelInfo item2) {
return item1.getProcessVariable().getName().compareTo(item2.getProcessVariable().getName());
}
};
col = TableHelper.createColumn(table_layout, channel_table, Messages.ArchiveName, 50, 100);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ChannelInfo channel = (ChannelInfo) cell.getElement();
cell.setText(channel.getArchiveDataSource().getName());
}
});
new TableColumnSortHelper<ChannelInfo>(channel_table, col) {
@Override
public int compare(final ChannelInfo item1, final ChannelInfo item2) {
return item1.getArchiveDataSource().getName().compareTo(item2.getArchiveDataSource().getName());
}
};
final Table table = channel_table.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
// searchForChannels() relies on non-null content
channel_table.setInput(new ChannelInfo[0]);
// Restore settings from memento
if (memento != null) {
if (memento.getBoolean(TAG_REGEX) != null)
regex.setSelection(memento.getBoolean(TAG_REGEX));
if (memento.getBoolean(TAG_REPLACE) != null) {
final boolean replace = memento.getBoolean(TAG_REPLACE);
result_append.setSelection(!replace);
result_replace.setSelection(replace);
}
}
}
use of org.csstudio.ui.util.MinSizeTableColumnLayout in project org.csstudio.display.builder by kasemir.
the class SampleView method doCreatePartControl.
/**
* {@inheritDoc}
*/
@Override
protected void doCreatePartControl(final Composite parent) {
final GridLayout layout = new GridLayout(3, false);
parent.setLayout(layout);
// Item: pvs [Refresh]
Label l = new Label(parent, 0);
l.setText(Messages.SampleView_Item);
l.setLayoutData(new GridData());
items = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
items.setLayoutData(new GridData(SWT.FILL, 0, true, false));
items.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(final SelectionEvent e) {
widgetDefaultSelected(e);
}
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
// Configure table to display samples of the selected model item
if (items.getSelectionIndex() == 0) {
sample_table.setInput(null);
return;
}
// / Skip initial "Select item" entry
final int selected = items.getSelectionIndex() - 1;
int index = 0;
for (ModelItem item : model.getItems()) {
if (index == selected) {
sample_table.setInput(item);
return;
}
++index;
}
Activator.getLogger().log(Level.WARNING, "Invalid item index " + selected);
}
});
final Button refresh = new Button(parent, SWT.PUSH);
refresh.setText(Messages.SampleView_Refresh);
refresh.setToolTipText(Messages.SampleView_RefreshTT);
refresh.setLayoutData(new GridData());
refresh.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
// Trigger GUI update
update(false);
}
});
// Sample Table
// TableColumnLayout requires this to be 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);
sample_table = new TableViewer(table_parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL);
sample_table.setContentProvider(new SampleTableContentProvider());
final Table table = sample_table.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
// Time column
TableViewerColumn col = TableHelper.createColumn(table_layout, sample_table, Messages.TimeColumn, 90, 100);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final PlotSample sample = (PlotSample) cell.getElement();
cell.setText(TimestampHelper.format(sample.getPosition()));
}
});
// Value column
col = TableHelper.createColumn(table_layout, sample_table, Messages.ValueColumn, 50, 100);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final PlotSample sample = (PlotSample) cell.getElement();
cell.setText(format.format(sample.getVType()));
}
@Override
public String getToolTipText(Object element) {
final PlotSample sample = (PlotSample) element;
final VType value = sample.getVType();
// Show numbers in their 'natural' format which may differ from the Display settings
if (value instanceof VStatistics) {
final VStatistics mmd = (VStatistics) value;
return NLS.bind(Messages.SampleView_MinMaxValueTT, new String[] { Double.toString(mmd.getAverage()), Double.toString(mmd.getMin()), Double.toString(mmd.getMax()) });
} else if (value instanceof VNumber) {
final VNumber dbl = (VNumber) value;
return Double.toString(dbl.getValue().doubleValue());
} else
return VTypeHelper.toString(value);
}
});
// Severity column
col = TableHelper.createColumn(table_layout, sample_table, Messages.SeverityColumn, 90, 50);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final PlotSample sample = (PlotSample) cell.getElement();
final VType value = sample.getVType();
final AlarmSeverity severity = VTypeHelper.getSeverity(value);
cell.setText(severity.toString());
if (severity == AlarmSeverity.NONE) {
cell.setBackground(null);
return;
}
final Display display = cell.getControl().getDisplay();
if (severity == AlarmSeverity.MAJOR)
cell.setBackground(display.getSystemColor(SWT.COLOR_RED));
else if (severity == AlarmSeverity.MINOR)
cell.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
else
cell.setBackground(display.getSystemColor(SWT.COLOR_GRAY));
}
});
// Status column
col = TableHelper.createColumn(table_layout, sample_table, Messages.StatusColumn, 90, 50);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final PlotSample sample = (PlotSample) cell.getElement();
final VType value = sample.getVType();
cell.setText(VTypeHelper.getMessage(value));
}
});
// Sample Source column
col = TableHelper.createColumn(table_layout, sample_table, Messages.SampleView_Source, 90, 10);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final PlotSample sample = (PlotSample) cell.getElement();
cell.setText(sample.getSource());
}
});
ColumnViewerToolTipSupport.enableFor(sample_table);
// Be ignorant of any change of the current model after this view
// is disposed.
parent.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (model != null)
model.removeListener(model_listener);
}
});
}
use of org.csstudio.ui.util.MinSizeTableColumnLayout 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.csstudio.ui.util.MinSizeTableColumnLayout in project org.csstudio.display.builder by kasemir.
the class DataBrowserPropertySheetPage method createTracesTabItemPanel.
/**
* Within SashForm of the "Traces" tab, create the Model Item table
* @param sashform
*/
private void createTracesTabItemPanel(final SashForm sashform) {
// TableColumnLayout requires the TableViewer to be in its own Composite!
final Composite model_item_top = new Composite(sashform, SWT.BORDER);
final TableColumnLayout table_layout = new MinSizeTableColumnLayout(10);
model_item_top.setLayout(table_layout);
// Would like to _not_ use FULL_SELECTION so that only the currently selected
// cell gets highlighted, allowing the 'color' to still be visible
// -> On Linux, you only get FULL_SELECTION behavior.
// -> On Windows, editing is really odd, need to select a column before anything
// can be edited, plus color still invisible
// ---> Using FULL_SELECTION
trace_table = new TableViewer(model_item_top, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
final Table table = trace_table.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
final TraceTableHandler tth = new TraceTableHandler();
tth.createColumns(table_layout, operations_manager, trace_table);
trace_table.setContentProvider(tth);
trace_table.setInput(model);
new ControlSystemDragSource(trace_table.getControl()) {
@Override
public Object getSelection() {
final IStructuredSelection selection = (IStructuredSelection) trace_table.getSelection();
final Object[] objs = selection.toArray();
final ModelItem[] items = Arrays.copyOf(objs, objs.length, ModelItem[].class);
return items;
}
};
}
use of org.csstudio.ui.util.MinSizeTableColumnLayout in project org.csstudio.display.builder by kasemir.
the class DataBrowserPropertySheetPage method createValueAxesTab.
/**
* Create tab for traces (PVs, Formulas)
* @param tabs
*/
private void createValueAxesTab(final TabFolder tab_folder) {
final TabItem axes_tab = new TabItem(tab_folder, 0);
axes_tab.setText(Messages.ValueAxes);
final Composite parent = new Composite(tab_folder, 0);
parent.setLayout(new GridLayout());
// Rescale options
final Composite rescale = new Composite(parent, 0);
rescale.setLayout(new RowLayout());
rescale.setLayoutData(new GridData(SWT.FILL, 0, true, false));
final Label l = new Label(rescale, 0);
l.setText(Messages.ArchiveRescale_Label);
final ArchiveRescale[] rescale_items = ArchiveRescale.values();
rescales = new Button[rescale_items.length];
for (int i = 0; i < rescales.length; ++i) {
final ArchiveRescale item = rescale_items[i];
if (item.ordinal() != i)
// $NON-NLS-1$
throw new Error("ArchiveRescale items out of order");
rescales[i] = new Button(rescale, SWT.RADIO);
rescales[i].setText(item.toString());
if (model.getArchiveRescale() == item)
rescales[i].setSelection(true);
rescales[i].addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
// Only react to the selected button
if (model.getArchiveRescale() == item)
return;
new ChangeArchiveRescaleCommand(model, operations_manager, item);
}
});
}
// TableColumnLayout requires the TableViewer to be in its own Composite!
final Composite table_parent = new Composite(parent, 0);
table_parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
final TableColumnLayout table_layout = new MinSizeTableColumnLayout(10);
table_parent.setLayout(table_layout);
final AxesTableHandler ath = new AxesTableHandler(table_parent, table_layout, operations_manager);
ath.getAxesTable().setInput(model);
axes_tab.setControl(parent);
}
Aggregations