use of org.csstudio.autocomplete.ui.AutoCompleteWidget 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.autocomplete.ui.AutoCompleteWidget in project org.csstudio.display.builder by kasemir.
the class AddPVDialog method createDialogArea.
/**
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(final Composite parent_widget) {
final Composite parent_composite = (Composite) super.createDialogArea(parent_widget);
// Title & Image
setTitle(formula ? Messages.AddFormula : Messages.AddPV);
setMessage(formula ? Messages.AddFormulaMsg : Messages.AddPVMsg);
// $NON-NLS-1$
setTitleImage(Activator.getDefault().getImage("icons/config_image.png"));
// Scroll pane for the box
final ScrolledComposite scroll = new ScrolledComposite(parent_composite, SWT.H_SCROLL | SWT.V_SCROLL);
scroll.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
scroll.setExpandHorizontal(true);
scroll.setExpandVertical(true);
scroll.setLayout(new FillLayout());
// Create box for widgets we're about to add
final Composite box = new Composite(scroll, 0);
box.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
final GridLayout layout = new GridLayout(3, false);
box.setLayout(layout);
final ModifyListener update_on_modify = (e) -> updateAndValidate();
for (int i = 0; i < name.length; ++i) {
if (i > 0) {
Label sep = new Label(box, SWT.SEPARATOR | SWT.HORIZONTAL);
sep.setLayoutData(new GridData(SWT.FILL, 0, true, false, layout.numColumns, 1));
}
// PV Name : _____________________
Label l = new Label(box, 0);
l.setText(Messages.Name);
l.setLayoutData(new GridData());
txt_name[i] = new Text(box, SWT.BORDER);
txt_name[i].setToolTipText(formula ? Messages.AddFormula_NameTT : Messages.AddPV_NameTT);
txt_name[i].setLayoutData(new GridData(SWT.FILL, 0, true, false, layout.numColumns - 1, 1));
autoCompleteWidget[i] = new AutoCompleteWidget(txt_name[i], AutoCompleteTypes.PV);
if (!formula) {
// Scan Period [seconds]: _____ [x] on change
l = new Label(box, 0);
l.setText(Messages.AddPV_Period);
l.setLayoutData(new GridData());
txt_period[i] = new Text(box, SWT.BORDER);
txt_period[i].setToolTipText(Messages.AddPV_PeriodTT);
txt_period[i].setLayoutData(new GridData(SWT.FILL, 0, true, false));
btn_monitor[i] = new Button(box, SWT.CHECK);
btn_monitor[i].setText(Messages.AddPV_OnChange);
btn_monitor[i].setToolTipText(Messages.AddPV_OnChangeTT);
btn_monitor[i].setLayoutData(new GridData());
// Initialize to default period
final double period = Preferences.getScanPeriod();
if (period > 0.0)
txt_period[i].setText(Double.toString(period));
else {
// 'monitor'
// $NON-NLS-1$
txt_period[i].setText("1.0");
txt_period[i].setEnabled(false);
btn_monitor[i].setSelection(true);
}
// Hook listener after initial value has been set
txt_period[i].addModifyListener(update_on_modify);
// In 'monitor' mode, the period entry is disabled
final int index = i;
btn_monitor[i].addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
txt_period[index].setEnabled(!btn_monitor[index].getSelection());
updateAndValidate();
}
});
}
// Value Axis: _____
// If there are axes to select, add related GUI
l = new Label(box, 0);
l.setText(Messages.AddPV_Axis);
l.setLayoutData(new GridData());
axis[i] = new Combo(box, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.SINGLE);
axis[i].setToolTipText(Messages.AddPV_AxisTT);
axis[i].setLayoutData(new GridData(SWT.FILL, 0, true, false));
// First entry is 'new axis', rest actual axis names
axis[i].add(Messages.AddPV_NewOrEmptyAxis);
for (String name : axes) axis[i].add(name);
// Suggest multiple PVs are all placed on the same axis, the last one
if (name.length > 1) {
axis[i].select(axes.size());
axis_index[i] = axes.size() - 1;
} else {
axis[i].select(0);
axis_index[i] = -1;
}
// Empty label to fill last column
l = new Label(box, 0);
l.setLayoutData(new GridData());
// Set initial text
if (name[i] != null)
txt_name[i].setText(name[i]);
// and _then_ connect modify listener so it's not called for initial text
txt_name[i].addModifyListener(update_on_modify);
}
scroll.setContent(box);
scroll.setMinSize(box.computeSize(SWT.DEFAULT, SWT.DEFAULT));
// Perform initial validation
updateAndValidate();
return parent_composite;
}
Aggregations