use of org.csstudio.apputil.time.RelativeTime in project org.csstudio.display.builder by kasemir.
the class TraceTableHandler method createColumns.
/**
* Create table columns: Auto-sizable, with label provider and editor
* @param table_layout
* @param operations_manager
* @param table_viewer
*/
public void createColumns(final TableColumnLayout table_layout, final UndoableActionManager operations_manager, final TableViewer table_viewer) {
color_registry = new LocalResourceManager(JFaceResources.getResources(), table_viewer.getTable());
final Shell shell = table_viewer.getTable().getShell();
// Visible Column ----------
TableViewerColumn view_col = TableHelper.createColumn(table_layout, table_viewer, Messages.TraceVisibility, 45, 1);
view_col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ModelItem item = (ModelItem) cell.getElement();
cell.setImage(item.isVisible() ? Activator.getDefault().getImage(Activator.ICON_CHECKED) : Activator.getDefault().getImage(Activator.ICON_UNCHECKED));
}
@Override
public String getToolTipText(Object element) {
return Messages.TraceVisibilityTT;
}
});
new TableColumnSortHelper<ModelItem>(table_viewer, view_col) {
@Override
public int compare(final ModelItem item1, final ModelItem item2) {
final int v1 = item1.isVisible() ? 1 : 0;
final int v2 = item2.isVisible() ? 1 : 0;
final int cmp = v1 - v2;
if (cmp != 0)
return cmp;
return item1.getName().compareTo(item2.getName());
}
};
view_col.setEditingSupport(new EditSupportBase(table_viewer) {
@Override
protected CellEditor getCellEditor(final Object element) {
editing = true;
return new CheckboxCellEditor(((TableViewer) getViewer()).getTable());
}
@Override
protected Object getValue(final Object element) {
return ((ModelItem) element).isVisible();
}
@Override
protected void setValue(final Object element, final Object value) {
final ModelItem item = (ModelItem) element;
final boolean visible = ((Boolean) value).booleanValue();
if (!visible && prompt_for_not_visible) {
if (!MessageDialog.openQuestion(shell, Messages.HideTraceWarning, Messages.HideTraceWarningDetail))
return;
prompt_for_not_visible = false;
}
new ChangeVisibilityCommand(operations_manager, item, visible);
editing = false;
}
});
// Trace PV/Formula Column ----------
view_col = TableHelper.createColumn(table_layout, table_viewer, Messages.ItemName, 70, 70);
view_col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ModelItem item = (ModelItem) cell.getElement();
cell.setText(item.getName());
}
@Override
public String getToolTipText(Object element) {
return Messages.ItemNameTT;
}
});
new TableColumnSortHelper<ModelItem>(table_viewer, view_col) {
@Override
public int compare(final ModelItem item1, final ModelItem item2) {
return item1.getName().compareTo(item2.getName());
}
};
view_col.setEditingSupport(new EditSupportBase(table_viewer) {
@Override
protected Object getValue(final Object element) {
return ((ModelItem) element).getName();
}
@Override
protected CellEditor getCellEditor(Object element) {
editing = true;
return super.getCellEditor(element);
}
@Override
protected void setValue(final Object element, final Object value) {
final String new_name = value.toString().trim();
final ModelItem item = (ModelItem) element;
if (new_name.equals(item.getName()))
return;
new ChangeNameCommand(shell, operations_manager, item, new_name);
editing = false;
}
});
// Display Name Column ----------
view_col = TableHelper.createColumn(table_layout, table_viewer, Messages.TraceDisplayName, 70, 70);
view_col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ModelItem item = (ModelItem) cell.getElement();
cell.setText(item.getDisplayName());
}
@Override
public String getToolTipText(Object element) {
return Messages.TraceDisplayNameTT;
}
});
new TableColumnSortHelper<ModelItem>(table_viewer, view_col) {
@Override
public int compare(final ModelItem item1, final ModelItem item2) {
return item1.getDisplayName().compareTo(item2.getDisplayName());
}
};
view_col.setEditingSupport(new EditSupportBase(table_viewer) {
@Override
protected Object getValue(final Object element) {
return ((ModelItem) element).getDisplayName();
}
@Override
protected CellEditor getCellEditor(Object element) {
editing = true;
return super.getCellEditor(element);
}
@Override
protected void setValue(final Object element, final Object value) {
final String new_name = value.toString().trim();
final ModelItem item = (ModelItem) element;
if (new_name.equals(item.getDisplayName()))
return;
new ChangeDisplayNameCommand(operations_manager, item, new_name);
editing = false;
}
});
// Color Column ----------
view_col = TableHelper.createColumn(table_layout, table_viewer, Messages.Color, 40, 10);
view_col.setLabelProvider(new ColorCellLabelProvider<ModelItem>() {
@Override
protected Color getColor(ModelItem item) {
return color_registry.createColor(SWTMediaPool.getRGB(item.getPaintColor()));
}
});
view_col.setEditingSupport(new EditSupportBase(table_viewer) {
@Override
protected CellEditor getCellEditor(final Object element) {
editing = true;
return new RGBCellEditor(table_viewer.getTable());
}
@Override
protected Object getValue(final Object element) {
return ((ModelItem) element).getRGBColor();
}
@Override
protected void setValue(final Object element, final Object value) {
new ChangeColorCommand(operations_manager, (ModelItem) element, SWTMediaPool.getJFX((RGB) value));
editing = false;
}
});
// Selected sample time stamp and value
view_col = TableHelper.createColumn(table_layout, table_viewer, Messages.CursorTimestamp, 150, 30);
view_col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ModelItem item = (ModelItem) cell.getElement();
final Optional<PlotDataItem<Instant>> sample = item.getSelectedSample();
if (sample.isPresent())
cell.setText(TimeHelper.format(sample.get().getPosition()));
else
cell.setText(Messages.NotApplicable);
}
@Override
public String getToolTipText(Object element) {
return Messages.CursorTimestampTT;
}
});
view_col = TableHelper.createColumn(table_layout, table_viewer, Messages.CursorValue, 40, 30);
view_col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ModelItem item = (ModelItem) cell.getElement();
final Optional<PlotDataItem<Instant>> sample = item.getSelectedSample();
if (sample.isPresent()) {
final PlotSample plot_sample = (PlotSample) sample.get();
String text = DefaultVTypeFormat.get().format(plot_sample.getVType());
final String units = item.getUnits();
if (units != null)
// $NON-NLS-1$
text += " " + units;
cell.setText(text);
} else
cell.setText(Messages.NotApplicable);
}
@Override
public String getToolTipText(Object element) {
return Messages.CursorValueTT;
}
});
// Scan Period Column (only applies to PVItems) ----------
view_col = TableHelper.createColumn(table_layout, table_viewer, Messages.ScanPeriod, 70, 10);
view_col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ModelItem item = (ModelItem) cell.getElement();
if (item instanceof PVItem)
cell.setText(Double.toString(((PVItem) item).getScanPeriod()));
else
cell.setText(Messages.NotApplicable);
}
@Override
public String getToolTipText(final Object element) {
if (!(element instanceof PVItem))
return null;
return Messages.ScanPeriodTT;
}
});
view_col.setEditingSupport(new EditSupportBase(table_viewer) {
@Override
protected boolean canEdit(Object element) {
return element instanceof PVItem;
}
@Override
protected CellEditor getCellEditor(Object element) {
editing = true;
return super.getCellEditor(element);
}
@Override
protected Object getValue(final Object element) {
if (element instanceof PVItem)
return Double.toString(((PVItem) element).getScanPeriod());
else
return Messages.NotApplicable;
}
@Override
protected void setValue(final Object element, final Object value) {
if (!(element instanceof PVItem))
return;
final PVItem pv = (PVItem) element;
try {
final double period = Double.parseDouble(value.toString().trim());
if (period != pv.getScanPeriod())
new ChangeSamplePeriodCommand(shell, operations_manager, pv, period);
editing = false;
} catch (NumberFormatException ex) {
// Display will revert to original value
return;
}
}
});
// Buffer size Column (only applies to PVItems) ----------
view_col = TableHelper.createColumn(table_layout, table_viewer, Messages.LiveSampleBufferSize, 70, 10);
view_col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ModelItem item = (ModelItem) cell.getElement();
if (item instanceof PVItem)
cell.setText(Integer.toString(((PVItem) item).getLiveCapacity()));
else
cell.setText(Messages.NotApplicable);
}
@Override
public String getToolTipText(final Object element) {
if (!(element instanceof PVItem))
return null;
final PVItem pv = (PVItem) element;
return NLS.bind(Messages.LiveBufferSizeInfoFmt, pv.getLiveCapacity(), new RelativeTime(pv.getLiveCapacity()).toString());
}
});
view_col.setEditingSupport(new EditSupportBase(table_viewer) {
@Override
protected boolean canEdit(Object element) {
return element instanceof PVItem;
}
@Override
protected Object getValue(final Object element) {
if (element instanceof PVItem)
return Integer.toString(((PVItem) element).getLiveCapacity());
else
return Messages.NotApplicable;
}
@Override
protected CellEditor getCellEditor(Object element) {
editing = true;
return super.getCellEditor(element);
}
@Override
protected void setValue(final Object element, final Object value) {
if (!(element instanceof PVItem))
return;
final PVItem pv = (PVItem) element;
try {
final int size = Integer.parseInt(value.toString().trim());
if (size != pv.getLiveCapacity())
new ChangeLiveCapacityCommand(shell, operations_manager, pv, size);
editing = false;
} catch (NumberFormatException ex) {
// Display will revert to original value
return;
}
}
});
// Axis Column ----------
view_col = TableHelper.createColumn(table_layout, table_viewer, Messages.Axis, 60, 30);
view_col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ModelItem item = (ModelItem) cell.getElement();
cell.setText(item.getAxis().getName());
}
@Override
public String getToolTipText(Object element) {
return Messages.AxisTT;
}
});
new TableColumnSortHelper<ModelItem>(table_viewer, view_col) {
@Override
public int compare(final ModelItem item1, final ModelItem item2) {
final int cmp = item1.getAxis().getName().compareTo(item2.getAxis().getName());
if (cmp != 0)
return cmp;
return item1.getDisplayName().compareTo(item2.getDisplayName());
}
};
view_col.setEditingSupport(new EditSupportBase(table_viewer) {
// Thread-safe copy of model axes as this editor is invoked
final List<AxisConfig> axes = new ArrayList<>();
@Override
protected CellEditor getCellEditor(final Object element) {
editing = true;
final List<String> axis_names = new ArrayList<>();
axes.clear();
for (AxisConfig axis : model.getAxes()) {
axes.add(axis);
axis_names.add(axis.getName());
}
final ComboBoxCellEditor combo = new ComboBoxCellEditor(table_viewer.getTable(), axis_names.toArray(new String[axis_names.size()]), SWT.READ_ONLY);
combo.setValue(getValue(element));
return combo;
}
@Override
protected Object getValue(final Object element) {
return model.getAxisIndex(((ModelItem) element).getAxis());
}
@Override
protected void setValue(final Object element, final Object value) {
final int axis_index = ((Integer) value).intValue();
final AxisConfig axis = axes.get(axis_index);
final ModelItem item = (ModelItem) element;
if (axis != item.getAxis())
new ChangeAxisCommand(operations_manager, item, axis);
editing = false;
}
});
// Trace Type Column ----------
view_col = TableHelper.createColumn(table_layout, table_viewer, Messages.TraceType, 75, 10);
view_col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ModelItem item = (ModelItem) cell.getElement();
cell.setText(item.getTraceType().toString());
}
@Override
public String getToolTipText(Object element) {
return Messages.TraceTypeTT;
}
});
view_col.setEditingSupport(new EditSupportBase(table_viewer) {
@Override
protected CellEditor getCellEditor(final Object element) {
editing = true;
final ComboBoxCellEditor combo = new ComboBoxCellEditor(table_viewer.getTable(), TraceType.getDisplayNames(), SWT.READ_ONLY);
combo.setValue(getValue(element));
return combo;
}
@Override
protected Object getValue(final Object element) {
return ((ModelItem) element).getTraceType().ordinal();
}
@Override
protected void setValue(final Object element, final Object value) {
final TraceType trace_type = TraceType.values()[(((Integer) value).intValue())];
final ModelItem item = (ModelItem) element;
if (trace_type != item.getTraceType())
new ChangeTraceTypeCommand(operations_manager, item, trace_type);
editing = false;
}
});
// Line Width Column ----------
view_col = TableHelper.createColumn(table_layout, table_viewer, Messages.TraceLineWidth, 40, 10);
view_col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ModelItem item = (ModelItem) cell.getElement();
cell.setText(Integer.toString(item.getLineWidth()));
}
@Override
public String getToolTipText(Object element) {
return Messages.TraceLineWidthTT;
}
});
view_col.setEditingSupport(new EditSupportBase(table_viewer) {
@Override
protected Object getValue(final Object element) {
return Integer.toString(((ModelItem) element).getLineWidth());
}
@Override
protected CellEditor getCellEditor(Object element) {
editing = true;
return super.getCellEditor(element);
}
@Override
protected void setValue(final Object element, final Object value) {
int width;
try {
width = Integer.parseInt(value.toString().trim());
} catch (NumberFormatException ex) {
width = 0;
}
final ModelItem item = (ModelItem) element;
if (width != item.getLineWidth())
new ChangeLineWidthCommand(operations_manager, item, width);
editing = false;
}
});
// Point Type Column ----------
view_col = TableHelper.createColumn(table_layout, table_viewer, Messages.PointType, 75, 10);
view_col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ModelItem item = (ModelItem) cell.getElement();
cell.setText(item.getPointType().toString());
}
@Override
public String getToolTipText(Object element) {
return Messages.PointTypeTT;
}
});
view_col.setEditingSupport(new EditSupportBase(table_viewer) {
@Override
protected CellEditor getCellEditor(final Object element) {
editing = true;
final ComboBoxCellEditor combo = new ComboBoxCellEditor(table_viewer.getTable(), PointType.getDisplayNames(), SWT.READ_ONLY);
combo.setValue(getValue(element));
return combo;
}
@Override
protected Object getValue(final Object element) {
return ((ModelItem) element).getPointType().ordinal();
}
@Override
protected void setValue(final Object element, final Object value) {
final PointType point_type = PointType.values()[((Integer) value).intValue()];
final ModelItem item = (ModelItem) element;
if (point_type != item.getPointType())
new ChangePointTypeCommand(operations_manager, item, point_type);
editing = false;
}
});
// Point Size Column ----------
view_col = TableHelper.createColumn(table_layout, table_viewer, Messages.PointSize, 40, 10);
view_col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ModelItem item = (ModelItem) cell.getElement();
cell.setText(Integer.toString(item.getPointSize()));
}
@Override
public String getToolTipText(Object element) {
return Messages.PointSizeTT;
}
});
view_col.setEditingSupport(new EditSupportBase(table_viewer) {
@Override
protected Object getValue(final Object element) {
return Integer.toString(((ModelItem) element).getPointSize());
}
@Override
protected CellEditor getCellEditor(Object element) {
editing = true;
return super.getCellEditor(element);
}
@Override
protected void setValue(final Object element, final Object value) {
int size;
try {
size = Integer.parseInt(value.toString().trim());
} catch (NumberFormatException ex) {
size = 0;
}
final ModelItem item = (ModelItem) element;
if (size != item.getPointSize())
new ChangePointSizeCommand(operations_manager, item, size);
editing = false;
}
});
// Request Type Column ----------
view_col = TableHelper.createColumn(table_layout, table_viewer, Messages.RequestType, 75, 10);
view_col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ModelItem item = (ModelItem) cell.getElement();
if (item instanceof PVItem)
cell.setText(((PVItem) item).getRequestType().toString());
else
cell.setText(Messages.NotApplicable);
}
@Override
public String getToolTipText(Object element) {
return Messages.RequestTypeTT;
}
});
// Edit as boolean: Raw == false, Optimized == true
view_col.setEditingSupport(new EditSupportBase(table_viewer) {
@Override
protected boolean canEdit(final Object element) {
return element instanceof PVItem;
}
@Override
protected CellEditor getCellEditor(final Object element) {
editing = true;
return new CheckboxCellEditor(((TableViewer) getViewer()).getTable());
}
@Override
protected Object getValue(final Object element) {
return ((PVItem) element).getRequestType() == RequestType.OPTIMIZED;
}
@Override
protected void setValue(final Object element, final Object value) {
final PVItem item = (PVItem) element;
final RequestType request_type = ((Boolean) value).booleanValue() ? RequestType.OPTIMIZED : RequestType.RAW;
if (request_type == RequestType.RAW && prompt_for_raw_data_request) {
if (!MessageDialog.openQuestion(shell, Messages.RequestTypeWarning, Messages.RequestTypeWarningDetail))
return;
prompt_for_raw_data_request = false;
}
new ChangeRequestTypeCommand(operations_manager, item, request_type);
editing = false;
}
});
// Waveform Index Column ----------
view_col = TableHelper.createColumn(table_layout, table_viewer, Messages.WaveformIndexCol, 40, 10);
view_col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ModelItem item = (ModelItem) cell.getElement();
cell.setText(Integer.toString(item.getWaveformIndex()));
}
@Override
public String getToolTipText(Object element) {
return Messages.WaveformIndexColTT;
}
});
view_col.setEditingSupport(new EditSupportBase(table_viewer) {
@Override
protected Object getValue(final Object element) {
return Integer.toString(((ModelItem) element).getWaveformIndex());
}
@Override
protected CellEditor getCellEditor(Object element) {
editing = true;
return super.getCellEditor(element);
}
@Override
protected void setValue(final Object element, final Object value) {
int index;
try {
index = Integer.parseInt(value.toString().trim());
if (index < 0)
return;
final ModelItem item = (ModelItem) element;
if (index != item.getWaveformIndex())
new ChangeWaveformIndexCommand(operations_manager, item, index);
} catch (NumberFormatException ex) {
return;
} finally {
editing = false;
}
}
});
ColumnViewerToolTipSupport.enableFor(table_viewer);
}
use of org.csstudio.apputil.time.RelativeTime in project org.csstudio.display.builder by kasemir.
the class ExportView method doCreatePartControl.
/**
* {@inheritDoc}
*/
@Override
protected void doCreatePartControl(final Composite real_parent) {
final Composite parent = ScrolledContainerHelper.create(real_parent, 700, 320);
parent.setLayout(new GridLayout());
// * Samples To Export *
// Start: ___start_______________________________________________________________ [select]
// End : ___end_________________________________________________________________ [x] Use start/end time of Plot
// Source: ( ) Plot (*) Raw Archived Data ( ) Averaged Archived Data __time__ ( ) Linear __linear__ {ghost}
// * Format *
// (*) Spreadsheet ( ) Matlab
// [x] Tabular [x] ... with min/max column [x] ... with Severity/Status
// (*) Default format ( ) decimal notation ( ) exponential notation _digits_ fractional digits
// * Output *
// Filename: ______________ [Browse] [EXPORT]
// * Samples To Export *
Group group = new Group(parent, 0);
group.setText(Messages.ExportGroupSource);
group.setLayoutData(new GridData(SWT.FILL, 0, true, false));
GridLayout layout = new GridLayout(8, false);
group.setLayout(layout);
// Start: ___start____________________________________________________ [select]
Label l = new Label(group, 0);
l.setText(Messages.StartTimeLbl);
l.setLayoutData(new GridData());
start = new Text(group, SWT.BORDER);
start.setToolTipText(Messages.StartTimeTT);
start.setLayoutData(new GridData(SWT.FILL, 0, true, false, layout.numColumns - 2, 1));
start.setText(new RelativeTime(-TimeDuration.toSecondsDouble(Preferences.getTimeSpan())).toString());
start.setEnabled(false);
sel_times = new Button(group, SWT.PUSH);
sel_times.setText(Messages.StartEndDialogBtn);
sel_times.setToolTipText(Messages.StartEndDialogTT);
sel_times.setLayoutData(new GridData());
sel_times.setEnabled(false);
sel_times.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
promptForTimerange();
}
});
// End : ___end______________________________________________________ [x] Use start/end time of Plot
l = new Label(group, 0);
l.setText(Messages.EndTimeLbl);
l.setLayoutData(new GridData());
end = new Text(group, SWT.BORDER);
end.setToolTipText(Messages.EndTimeTT);
end.setLayoutData(new GridData(SWT.FILL, 0, true, false, layout.numColumns - 2, 1));
end.setText(RelativeTime.NOW);
end.setEnabled(false);
use_plot_times = new Button(group, SWT.CHECK);
use_plot_times.setText(Messages.ExportPlotStartEnd);
use_plot_times.setToolTipText(Messages.ExportPlotStartEndTT);
use_plot_times.setLayoutData(new GridData());
use_plot_times.setSelection(true);
use_plot_times.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateStartEnd();
}
});
// Source: ( ) Plot (*) Raw Archived Data (*) Averaged Archived Data __time__
l = new Label(group, 0);
l.setText(Messages.ExportSource);
l.setLayoutData(new GridData());
final Button source_plot = new Button(group, SWT.RADIO);
source_plot.setText(Messages.ExportSource_Plot);
source_plot.setToolTipText(Messages.ExportSource_PlotTT);
source_plot.setLayoutData(new GridData());
source_raw = new Button(group, SWT.RADIO);
source_raw.setText(Messages.ExportSource_RawArchive);
source_raw.setToolTipText(Messages.ExportSource_RawArchiveTT);
source_raw.setLayoutData(new GridData());
source_raw.setSelection(true);
source_opt = new Button(group, SWT.RADIO);
source_opt.setText(Messages.ExportSource_OptimizedArchive);
source_opt.setToolTipText(Messages.ExportSource_OptimizedArchiveTT);
source_opt.setLayoutData(new GridData());
optimize = new Text(group, SWT.BORDER);
optimize.setText(Messages.ExportDefaultOptimization);
optimize.setToolTipText(Messages.ExportOptimizationTT);
optimize.setLayoutData(new GridData());
// Enable only when using optimized export
optimize.setEnabled(source_opt.getSelection());
source_lin = new Button(group, SWT.RADIO);
source_lin.setText(Messages.ExportSource_Linear);
source_lin.setToolTipText(Messages.ExportSource_LinearTT);
source_lin.setLayoutData(new GridData());
linear = new Text(group, SWT.BORDER);
linear.setText(Messages.ExportDefaultLinearInterpolation);
linear.setToolTipText(Messages.ExportDefaultLinearInterpolationTT);
linear.setLayoutData(new GridData());
// Enable only when using linear interpolation
linear.setEnabled(source_lin.getSelection());
source_plot.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
min_max_col.setEnabled(minMaxAllowed());
}
});
source_raw.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
min_max_col.setEnabled(minMaxAllowed());
}
});
source_opt.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final boolean use_optimized = source_opt.getSelection();
optimize.setEnabled(use_optimized);
linear.setEnabled(!use_optimized);
min_max_col.setEnabled(minMaxAllowed());
if (use_optimized)
optimize.setFocus();
}
});
source_lin.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final boolean use_linear = source_lin.getSelection();
optimize.setEnabled(!use_linear);
linear.setEnabled(use_linear);
min_max_col.setEnabled(minMaxAllowed());
if (use_linear)
linear.setFocus();
}
});
// Default traversal gets confused because text boxes interleave the radio buttons
group.setTabList(new Control[] { start, sel_times, end, use_plot_times, source_plot, source_raw, source_opt, optimize, source_lin, linear });
// Ghost label to fill the last column
l = new Label(group, 0);
l.setLayoutData(new GridData());
// * Format *
// Since there are actually 2 sets of radio buttons, use
// one Composite per row.
group = new Group(parent, 0);
group.setText(Messages.ExportGroupFormat);
group.setLayoutData(new GridData(SWT.FILL, 0, true, false));
group.setLayout(new RowLayout(SWT.VERTICAL));
// (*) Spreadsheet ( ) Matlab
Composite box = new Composite(group, 0);
box.setLayout(new RowLayout());
final Button type_spreadsheet = new Button(box, SWT.RADIO);
type_spreadsheet.setText(Messages.ExportTypeSpreadsheet);
type_spreadsheet.setToolTipText(Messages.ExportTypeSpreadsheetTT);
type_spreadsheet.setSelection(true);
type_matlab = new Button(box, SWT.RADIO);
type_matlab.setText(Messages.ExportTypeMatlab);
type_matlab.setToolTipText(Messages.ExportTypeMatlabTT);
box.setTabList(new Control[] { type_spreadsheet, type_matlab });
// [x] Tabular [x] ... with min/max column [x] ... with Severity/Status
box = new Composite(group, 0);
box.setLayout(new RowLayout());
tabular = new Button(box, SWT.CHECK);
tabular.setText(Messages.ExportTabular);
tabular.setToolTipText(Messages.ExportTabularTT);
tabular.setSelection(true);
min_max_col = new Button(box, SWT.CHECK);
min_max_col.setText(Messages.ExportMinMaxCol);
min_max_col.setToolTipText(Messages.ExportMinMaxColTT);
min_max_col.setSelection(true);
min_max_col.setEnabled(false);
sev_stat = new Button(box, SWT.CHECK);
sev_stat.setText(Messages.ExportValueInfo);
sev_stat.setToolTipText(Messages.ExportValueInfoTT);
sev_stat.setSelection(true);
// ( ) Default format (*) decimal notation ( ) exponential notation _digits_ fractional digits
box = new Composite(group, 0);
box.setLayout(new RowLayout());
final Button format_default = new Button(box, SWT.RADIO);
format_default.setText(Messages.Format_Default);
format_default.setToolTipText(Messages.ExportFormat_DefaultTT);
format_decimal = new Button(box, SWT.RADIO);
format_decimal.setText(Messages.Format_Decimal);
format_decimal.setToolTipText(Messages.ExportFormat_DecimalTT);
format_decimal.setSelection(true);
format_expo = new Button(box, SWT.RADIO);
format_expo.setText(Messages.Format_Exponential);
format_expo.setToolTipText(Messages.ExportFormat_ExponentialTT);
format_digits = new Text(box, SWT.BORDER);
// Note that text starts with some spaces like " 6" to get initial minimum text field size
format_digits.setText(Messages.ExportDefaultDigits);
format_digits.setToolTipText(Messages.ExportDigitsTT);
format_digits.setEnabled(true);
box.setTabList(new Control[] { format_default, format_decimal, format_expo, format_digits });
l = new Label(box, 0);
l.setText(Messages.ExportDigits);
// Selection and enablement handling of the buttons
type_spreadsheet.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
tabular.setEnabled(true);
sev_stat.setEnabled(true);
format_default.setEnabled(true);
format_decimal.setEnabled(true);
format_expo.setEnabled(true);
format_digits.setEnabled(!format_default.getSelection());
min_max_col.setEnabled(!source_raw.getSelection());
}
});
type_matlab.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
tabular.setEnabled(false);
sev_stat.setEnabled(false);
format_default.setEnabled(false);
format_decimal.setEnabled(false);
format_expo.setEnabled(false);
format_digits.setEnabled(false);
min_max_col.setEnabled(minMaxAllowed());
}
});
final SelectionAdapter digit_enabler = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final boolean use_digits = !format_default.getSelection();
format_digits.setEnabled(use_digits);
if (use_digits)
format_digits.setFocus();
}
};
format_default.addSelectionListener(digit_enabler);
format_decimal.addSelectionListener(digit_enabler);
format_expo.addSelectionListener(digit_enabler);
// * Output *
group = new Group(parent, 0);
group.setText(Messages.ExportGroupOutput);
group.setLayoutData(new GridData(SWT.FILL, 0, true, false));
layout = new GridLayout(4, false);
group.setLayout(layout);
// Filename: ______________ [Browse]
l = new Label(group, 0);
l.setText(Messages.ExportFilename);
l.setLayoutData(new GridData());
filename = new Text(group, SWT.BORDER);
filename.setToolTipText(Messages.ExportFilenameTT);
filename.setText(Messages.ExportDefaultFilename);
filename.setLayoutData(new GridData(SWT.FILL, 0, true, false));
filename.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(final KeyEvent e) {
if (e.character == '\r')
startExportJob();
}
});
final Button sel_filename = new Button(group, SWT.PUSH);
sel_filename.setText(Messages.ExportBrowse);
sel_filename.setToolTipText(Messages.ExportBrowseTT);
sel_filename.setLayoutData(new GridData());
sel_filename.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
final String name = SingleSourcePlugin.getUIHelper().openOutsideWorkspaceDialog(parent.getShell(), SWT.SAVE, null, null);
if (name != null)
filename.setText(name.toString());
}
});
export = new Button(group, SWT.PUSH);
export.setText(Messages.ExportStartExport);
export.setToolTipText(Messages.ExportStartExportTT);
export.setLayoutData(new GridData(SWT.RIGHT, 0, true, true));
export.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
startExportJob();
}
});
}
Aggregations