Search in sources :

Example 1 with ArchiveRescale

use of org.csstudio.trends.databrowser3.model.ArchiveRescale in project org.csstudio.display.builder by kasemir.

the class PreferencePage method createFieldEditors.

/**
 * {@inheritDoc}
 */
@Override
protected void createFieldEditors() {
    final Composite parent = getFieldEditorParent();
    // Time span: 60 seconds .. 1 month
    final IntegerFieldEditor timespan = new IntegerFieldEditor(Preferences.TIME_SPAN, Messages.PrefPage_TimeRange, parent);
    timespan.setValidRange(60, 60 * 60 * 24 * 30);
    addField(timespan);
    // Scan period: >=0
    final StringFieldEditor scanperiod = new StringFieldEditor(Preferences.SCAN_PERIOD, Messages.PrefPage_ScanPeriod, parent) {

        @Override
        protected boolean checkState() {
            final Text text = getTextControl();
            if (text == null)
                return false;
            try {
                final double period = Double.parseDouble(text.getText().trim());
                if (period < 0) {
                    showErrorMessage(Messages.ScanPeriodTT);
                    return false;
                }
                clearErrorMessage();
                return true;
            } catch (Exception ex) {
                showErrorMessage(Messages.ScanPeriodTT);
                return false;
            }
        }
    };
    addField(scanperiod);
    // Live sample buffer: 0 ... max int
    final IntegerFieldEditor buffersize = new IntegerFieldEditor(Preferences.BUFFER_SIZE, Messages.PrefPage_LiveBufferSize, parent);
    buffersize.setValidRange(0, Integer.MAX_VALUE);
    addField(buffersize);
    // Refresh period: >0 seconds
    final StringFieldEditor updateperiod = new StringFieldEditor(Preferences.UPDATE_PERIOD, Messages.PrefPage_UpdatePeriod, parent) {

        @Override
        protected boolean checkState() {
            final Text text = getTextControl();
            if (text == null)
                return false;
            try {
                final double period = Double.parseDouble(text.getText().trim());
                if (period <= 0) {
                    showErrorMessage(Messages.UpdatePeriodTT);
                    return false;
                }
                clearErrorMessage();
                return true;
            } catch (Exception ex) {
                showErrorMessage(Messages.UpdatePeriodTT);
                return false;
            }
        }
    };
    addField(updateperiod);
    // Line Width: Some pixel range
    final IntegerFieldEditor linewidth = new IntegerFieldEditor(Preferences.LINE_WIDTH, Messages.PrefPage_TraceLineWidth, parent);
    linewidth.setValidRange(0, 100);
    addField(linewidth);
    // Opacity: 0..100%
    final IntegerFieldEditor opacity = new IntegerFieldEditor(Preferences.OPACITY, Messages.PrefPage_TraceOpacity, parent);
    opacity.setValidRange(0, 100);
    addField(opacity);
    // Trace type options
    final TraceType[] trace_values = TraceType.values();
    final String[][] trace_labels_and_values = new String[trace_values.length][2];
    for (int i = 0; i < trace_values.length; ++i) {
        trace_labels_and_values[i][0] = trace_values[i].toString();
        trace_labels_and_values[i][1] = trace_values[i].name();
    }
    final ComboFieldEditor trace_types = new ComboFieldEditor(Preferences.TRACE_TYPE, Messages.TraceTypes_Label, trace_labels_and_values, parent);
    addField(trace_types);
    // Archive fetch delay:  0.1 .. 10 seconds
    final IntegerFieldEditor fetch_delay = new IntegerFieldEditor(Preferences.ARCHIVE_FETCH_DELAY, Messages.PrefPage_ArchiveFetchDelay, parent);
    fetch_delay.setValidRange(100, 10000);
    addField(fetch_delay);
    // Plot bins: 10 ... one bin per second for a year
    final IntegerFieldEditor plotbins = new IntegerFieldEditor(Preferences.PLOT_BINS, Messages.PrefPage_PlotBins, parent);
    plotbins.setValidRange(10, 365 * 24 * 60 * 60);
    addField(plotbins);
    // Future Buffer: 10 ...
    final IntegerFieldEditor scroll_step = new IntegerFieldEditor(Preferences.SCROLL_STEP, Messages.ScrollStepLbl, parent);
    scroll_step.setValidRange(1, (int) Duration.ofDays(1).getSeconds());
    ((Text) scroll_step.getTextControl(parent)).setToolTipText(Messages.ScrollStepTT);
    addField(scroll_step);
    // Archive rescale options
    final ArchiveRescale[] values = ArchiveRescale.values();
    final String[][] labels_and_values = new String[values.length][2];
    for (int i = 0; i < values.length; ++i) {
        labels_and_values[i][0] = values[i].toString();
        labels_and_values[i][1] = values[i].name();
    }
    final RadioGroupFieldEditor rescale = new RadioGroupFieldEditor(Preferences.ARCHIVE_RESCALE, Messages.ArchiveRescale_Label, 1, labels_and_values, parent, false);
    addField(rescale);
    // Server URLs
    final StringTableFieldEditor urls = new StringTableFieldEditor(parent, Preferences.URLS, Messages.PrefPage_DataServerURLs, new String[] { Messages.URL, Messages.ServerAlias }, new boolean[] { true, true }, new int[] { 500, 100 }, new ArchiveURLEditor(parent.getShell()));
    addField(urls);
    // Default archives
    final StringTableFieldEditor archives = new StringTableFieldEditor(parent, Preferences.ARCHIVES, Messages.PrefPage_Archives, new String[] { Messages.ArchiveName, Messages.ArchiveKey, Messages.URL }, new boolean[] { true, true, true }, new int[] { 100, 50, 500 }, new ArchiveDataSourceEditor(parent.getShell()));
    addField(archives);
    addField(new BooleanFieldEditor(Preferences.PROMPT_FOR_ERRORS, Messages.PromptForErrors_Label, parent));
    addField(new BooleanFieldEditor(Preferences.USE_DEFAULT_ARCHIVES, Messages.UseDefaultArchives_Label, parent));
    addField(new BooleanFieldEditor(Preferences.USE_AUTO_SCALE, Messages.UseAutoScale_Label, parent));
    addField(new BooleanFieldEditor(Preferences.AUTOMATIC_HISTORY_REFRESH, Messages.PrefPage_AutomaticHistoryRefresh, parent));
}
Also used : TraceType(org.csstudio.javafx.rtplot.TraceType) Composite(org.eclipse.swt.widgets.Composite) Text(org.eclipse.swt.widgets.Text) BooleanFieldEditor(org.eclipse.jface.preference.BooleanFieldEditor) ComboFieldEditor(org.eclipse.jface.preference.ComboFieldEditor) StringFieldEditor(org.eclipse.jface.preference.StringFieldEditor) RadioGroupFieldEditor(org.eclipse.jface.preference.RadioGroupFieldEditor) ArchiveRescale(org.csstudio.trends.databrowser3.model.ArchiveRescale) IntegerFieldEditor(org.eclipse.jface.preference.IntegerFieldEditor)

Example 2 with ArchiveRescale

use of org.csstudio.trends.databrowser3.model.ArchiveRescale 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);
}
Also used : MinSizeTableColumnLayout(org.csstudio.ui.util.MinSizeTableColumnLayout) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) ArchiveRescale(org.csstudio.trends.databrowser3.model.ArchiveRescale) MinSizeTableColumnLayout(org.csstudio.ui.util.MinSizeTableColumnLayout) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

ArchiveRescale (org.csstudio.trends.databrowser3.model.ArchiveRescale)2 Composite (org.eclipse.swt.widgets.Composite)2 TraceType (org.csstudio.javafx.rtplot.TraceType)1 MinSizeTableColumnLayout (org.csstudio.ui.util.MinSizeTableColumnLayout)1 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)1 BooleanFieldEditor (org.eclipse.jface.preference.BooleanFieldEditor)1 ComboFieldEditor (org.eclipse.jface.preference.ComboFieldEditor)1 IntegerFieldEditor (org.eclipse.jface.preference.IntegerFieldEditor)1 RadioGroupFieldEditor (org.eclipse.jface.preference.RadioGroupFieldEditor)1 StringFieldEditor (org.eclipse.jface.preference.StringFieldEditor)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 RowLayout (org.eclipse.swt.layout.RowLayout)1 Button (org.eclipse.swt.widgets.Button)1 Label (org.eclipse.swt.widgets.Label)1 TabItem (org.eclipse.swt.widgets.TabItem)1 Text (org.eclipse.swt.widgets.Text)1