Example usage for org.eclipse.jface.dialogs Dialog applyDialogFont

List of usage examples for org.eclipse.jface.dialogs Dialog applyDialogFont

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs Dialog applyDialogFont.

Prototype

public static void applyDialogFont(Control control) 

Source Link

Document

Applies the dialog font to all controls that currently have the default font.

Usage

From source file:gov.nasa.ensemble.common.ui.wizard.EnsembleBasicNewProjectResourceWizard.java

License:Open Source License

private WizardNewProjectCreationPage getWizardNewProjectCreationPage() {
    WizardNewProjectCreationPage mainPage = new WizardNewProjectCreationPage("wizardnewProjectCreationPage") {
        @Override/*ww w.  j a  va 2s.  c om*/
        public void createControl(Composite parent) {
            super.createControl(parent);
            createWorkingSetGroup((Composite) getControl(), getSelection(),
                    new String[] { "org.eclipse.ui.resourceWorkingSetPage" });
            Dialog.applyDialogFont(getControl());
        }
    };

    String title = getNewProjectTitle();
    String description = getDescription();

    mainPage.setTitle(title);
    mainPage.setDescription(description);

    return mainPage;
}

From source file:gov.nasa.ensemble.core.plan.editor.search.PlanSearchPage.java

License:Open Source License

/**
 * Creates the initial set-up of the dialog page and stores the
 * composite for this page. //w ww . j a v  a  2  s. c  om
 */
@Override
public void createControl(Composite parent) {
    initializeDialogUnits(parent);
    parent.setLayout(new GridLayout(1, false));
    pageComposite = parent;

    Composite result = new Composite(parent, SWT.NONE);
    result.setFont(parent.getFont());
    GridLayout layout = new GridLayout(4, false);
    result.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
    result.setLayout(layout);

    addTextPatternControls(result);

    setControl(pageComposite);
    Dialog.applyDialogFont(pageComposite);

    addSearchPlanQuery();
}

From source file:gov.redhawk.ide.codegen.ui.internal.GeneratorDialog.java

License:Open Source License

/**
 * {@inheritDoc}/*from  w w  w  . j a v  a  2s. c  o  m*/
 */
@Override
protected Control createDialogArea(final Composite parent) {
    // create composite
    final Composite composite = (Composite) super.createDialogArea(parent);
    final GridLayout layout = (GridLayout) composite.getLayout();
    layout.numColumns = GeneratorDialog.NUM_COLUMNS;

    Label label = new Label(composite, SWT.WRAP);
    label.setText("Port RepID:");
    label.setFont(parent.getFont());
    this.repIdViewer = new ComboViewer(composite, getInputTextStyle() | SWT.READ_ONLY);
    this.repIdViewer.getCombo().setEnabled(this.value == null);
    this.repIdViewer.getCombo().addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            final String key = GeneratorDialog.this.repIdViewer.getCombo().getText();
            IPortTemplateDesc gen = null;
            // Get all the generators for this rep
            final IPortTemplateDesc[] gens = RedhawkCodegenActivator.getCodeGeneratorPortTemplatesRegistry()
                    .findTemplatesByRepId(key, GeneratorDialog.this.language);
            GeneratorDialog.this.generatorViewer.setInput(gens);

            // If we have a saved value, try to reselect it
            if (GeneratorDialog.this.value != null) {
                gen = CodegenUtil.getPortTemplate(GeneratorDialog.this.value.getGenerator(), null);
            }

            // If we couldn't find the value, or none is selected, choose the first
            if ((gen == null) && (gens.length > 0)) {
                gen = gens[0];
            }

            // If we have something to select, select it
            if (gen != null) {
                GeneratorDialog.this.generatorViewer
                        .setSelection(new StructuredSelection(Collections.singletonList(gen)));
                GeneratorDialog.this.descriptionText
                        .setText((gen.getDescription() == null) ? "" : gen.getDescription().trim()); // SUPPRESS CHECKSTYLE AvoidInline
            }

            // Validate the dialog
            validate();
        }

    });

    this.repIdViewer.setContentProvider(new ArrayContentProvider());
    this.repIdViewer.getControl()
            .setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));

    this.descriptionText = new Text(composite,
            SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.BORDER);
    this.descriptionText.setEditable(false);
    this.descriptionText.setEnabled(false);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true, 1, GeneratorDialog.NUM_COLUMNS);
    data.widthHint = 200; // SUPPRESS CHECKSTYLE MagicNumber
    data.heightHint = (int) (data.widthHint * 0.75); // SUPPRESS CHECKSTYLE MagicNumber
    this.descriptionText.setLayoutData(data);

    label = new Label(composite, SWT.WRAP);
    label.setText("Generator:");
    label.setFont(parent.getFont());
    this.generatorViewer = new ComboViewer(composite, getInputTextStyle() | SWT.READ_ONLY);
    this.generatorViewer.getCombo().addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(final SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(final SelectionEvent e) {
            final IPortTemplateDesc gen = (IPortTemplateDesc) ((IStructuredSelection) GeneratorDialog.this.generatorViewer
                    .getSelection()).getFirstElement();
            GeneratorDialog.this.descriptionText
                    .setText((gen.getDescription() == null) ? "" : gen.getDescription().trim()); // SUPPRESS CHECKSTYLE AvoidInline
            validate();
        }

    });
    this.generatorViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(final Object element) {
            return ((IPortTemplateDesc) element).getName();
        }
    });
    this.generatorViewer.setContentProvider(new ArrayContentProvider());
    this.generatorViewer.getControl()
            .setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));

    this.errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.WRAP);
    data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
    data.horizontalSpan = GeneratorDialog.NUM_COLUMNS;
    this.errorMessageText.setLayoutData(data);
    this.errorMessageText
            .setBackground(this.errorMessageText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    // Set the error message text
    // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=66292
    setErrorMessage(this.errorMessage);

    Dialog.applyDialogFont(composite);
    return composite;
}

From source file:gov.redhawk.ide.codegen.ui.internal.PropertyDialog.java

License:Open Source License

/**
 * {@inheritDoc}/*from w  w w.  j  av  a  2  s  . c  o m*/
 */
@Override
protected Control createDialogArea(final Composite parent) {

    // create composite
    final Composite composite = (Composite) super.createDialogArea(parent);
    final GridLayout layout = (GridLayout) composite.getLayout();
    layout.numColumns = 3; // SUPPRESS CHECKSTYLE MagicNumber

    Label label = new Label(composite, SWT.WRAP);
    label.setText("ID:");
    label.setFont(parent.getFont());
    this.idText = new ComboViewer(composite, getInputTextStyle() | SWT.READ_ONLY);
    this.idText.getCombo().addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            final String key = PropertyDialog.this.idText.getCombo().getText();
            String v = null;
            for (final IPropertyDescriptor pDesc : PropertyDialog.this.desc.getPropertyDescriptors()) {
                if (pDesc.getKey().equals(key)) {
                    v = pDesc.getDescription();
                    if (PropertyDialog.this.valueText.getText().length() == 0) {
                        PropertyDialog.this.valueText.setText(pDesc.getDefaultValue());
                    }
                    break;
                }
            }
            if (v == null) {
                v = "";
            }
            PropertyDialog.this.descriptionText.setText(v.trim());
            validate();
        }

    });
    this.idText.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(final Object element) {
            final IPropertyDescriptor prop = (IPropertyDescriptor) element;
            return prop.getKey();
        }
    });
    this.idText.setContentProvider(new ArrayContentProvider());
    this.idText.getControl()
            .setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));

    this.descriptionText = new Text(composite,
            SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.BORDER);
    this.descriptionText.setEditable(false);
    this.descriptionText.setEnabled(false);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2);
    data.widthHint = 200; // SUPPRESS CHECKSTYLE MagicNumber
    data.heightHint = (int) (data.widthHint * 0.75); // SUPPRESS CHECKSTYLE MagicNumber
    this.descriptionText.setLayoutData(data);

    label = new Label(composite, SWT.WRAP);
    label.setText("Value:");
    label.setFont(parent.getFont());
    label.setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.TOP).grab(false, true).create());
    this.valueText = new Text(composite, getInputTextStyle());
    this.valueText
            .setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).create());
    this.valueText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            validate();
        }

    });

    this.errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.WRAP);
    data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
    data.horizontalSpan = layout.numColumns;
    this.errorMessageText.setLayoutData(data);
    this.errorMessageText
            .setBackground(this.errorMessageText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    // Set the error message text
    // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=66292
    setErrorMessage(this.errorMessage);

    Dialog.applyDialogFont(composite);
    return composite;
}

From source file:gov.redhawk.ide.sdr.ui.internal.handlers.LaunchDomainManagerWithOptionsDialog.java

License:Open Source License

@Override
protected Control createDialogArea(final Composite root) {
    final Composite composite = new Composite(root, SWT.NONE);
    final GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);//from  w  ww  .ja v  a 2 s  . co m
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    final GridLayout gridLayout = new GridLayout(3, false);
    final GridDataFactory textFactory = GridDataFactory.fillDefaults().grab(true, false).span(2, 1);
    final GridData data;

    final Group domainManagerGroup = new Group(composite, SWT.NULL);

    domainManagerGroup.setText("Domain Manager");
    domainManagerGroup.setLayout(gridLayout);
    domainManagerGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    Label label = new Label(domainManagerGroup, SWT.NULL);
    label.setText("Domain Name: ");
    Text text = new Text(domainManagerGroup, SWT.BORDER);
    data = textFactory.create();
    data.horizontalSpan = 2;
    text.setLayoutData(data);
    this.nameBinding = this.context.bindValue(SWTObservables.observeText(text, SWT.Modify),
            PojoObservables.observeValue(this.model, DomainManagerLaunchConfiguration.PROP_DOMAIN_NAME),
            new UpdateValueStrategy().setAfterConvertValidator(this.nameValidator), null);
    text.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            updateButtonsEnableState((IStatus) LaunchDomainManagerWithOptionsDialog.this.nameBinding
                    .getValidationStatus().getValue());
        }
    });

    ControlDecorationSupport.create(this.nameBinding, SWT.TOP | SWT.LEFT);

    label = new Label(domainManagerGroup, SWT.NULL);
    label.setText("Debug Level: ");
    ComboViewer debugViewer = new ComboViewer(domainManagerGroup,
            SWT.READ_ONLY | SWT.SINGLE | SWT.DROP_DOWN | SWT.BORDER);
    debugViewer.setLabelProvider(new LabelProvider());
    debugViewer.setContentProvider(new ArrayContentProvider());
    debugViewer.setInput(DebugLevel.values());
    debugViewer.getControl().setLayoutData(data);
    this.context.bindValue(ViewersObservables.observeSingleSelection(debugViewer),
            PojoObservables.observeValue(this.model, DomainManagerLaunchConfiguration.PROP_DEBUG_LEVEL));

    label = new Label(domainManagerGroup, SWT.NULL);
    label.setText("Arguments:");
    text = new Text(domainManagerGroup, SWT.BORDER);
    text.setLayoutData(data);
    this.context.bindValue(SWTObservables.observeText(text, SWT.Modify),
            PojoObservables.observeValue(this.model, DomainManagerLaunchConfiguration.PROP_ARGUMENTS));

    final Group deviceManagerGroup = new Group(composite, SWT.NULL);

    deviceManagerGroup.setText("Device Manager");
    deviceManagerGroup.setLayout(GridLayoutFactory.fillDefaults().create());
    deviceManagerGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    deviceManagerGroup.setVisible(!this.sdrRoot.getNodesContainer().getNodes().isEmpty());

    final CheckboxTreeViewer treeViewer = createTreeViewer(deviceManagerGroup);
    treeViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    final Control buttonComposite = createSelectionButtons(deviceManagerGroup);
    buttonComposite.setLayoutData(GridDataFactory.fillDefaults().create());

    context.bindSet(ViewersObservables.observeCheckedElements(treeViewer, DeviceConfiguration.class), nodes);

    // Insert a progress monitor
    this.progressMonitorPart = createProgressMonitorPart(composite, new GridLayout());
    final GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    this.progressMonitorPart.setLayoutData(gridData);
    this.progressMonitorPart.setVisible(false);

    // Build the separator line
    final Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
    separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Dialog.applyDialogFont(composite);

    getShell().getDisplay().asyncExec(new Runnable() {
        @Override
        public void run() {
            try {
                LaunchDomainManagerWithOptionsDialog.this.run(true, true, scanForTakenDomainNames);
                updateButtonsEnableState(Status.OK_STATUS);
            } catch (final InvocationTargetException e) {
                SdrUiPlugin.getDefault().getLog().log(
                        new Status(IStatus.ERROR, SdrUiPlugin.PLUGIN_ID, "Error scanning for domain names", e));
            } catch (final InterruptedException e) {
                updateButtonsEnableState(Status.OK_STATUS);
            }
        }
    });

    return composite;
}

From source file:gov.redhawk.ide.ui.wizard.RedhawkImportWizardPage1.java

License:Open Source License

public void createControl(Composite parent) {

    initializeDialogUnits(parent);//w w w  .j av  a  2 s.  com

    Composite workArea = new Composite(parent, SWT.NONE);
    setControl(workArea);

    workArea.setLayout(new GridLayout());
    workArea.setLayoutData(
            new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));

    createProjectsRoot(workArea);
    createProjectsList(workArea);
    createOptionsArea(workArea);
    createWorkingSetGroup(workArea);
    restoreWidgetValues();
    Dialog.applyDialogFont(workArea);

}

From source file:gov.redhawk.ide.ui.wizard.RedhawkImportWizardPage1.java

License:Open Source License

/**
 * Create the selection buttons in the listComposite.
 * // w ww  . java  2s.c  o  m
 * @param listComposite
 */
private void createSelectionButtons(Composite listComposite) {
    Composite buttonsComposite = new Composite(listComposite, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    buttonsComposite.setLayout(layout);

    buttonsComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));

    Button selectAll = new Button(buttonsComposite, SWT.PUSH);
    selectAll.setText(DataTransferMessages.DataTransfer_selectAll);
    selectAll.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            for (int i = 0; i < selectedProjects.length; i++) {
                if (selectedProjects[i].hasConflicts) {
                    projectsList.setChecked(selectedProjects[i], false);
                } else {
                    projectsList.setChecked(selectedProjects[i], true);
                }
            }
            setPageComplete(projectsList.getCheckedElements().length > 0);
        }
    });
    Dialog.applyDialogFont(selectAll);
    setButtonLayoutData(selectAll);

    Button deselectAll = new Button(buttonsComposite, SWT.PUSH);
    deselectAll.setText(DataTransferMessages.DataTransfer_deselectAll);
    deselectAll.addSelectionListener(new SelectionAdapter() {
        /*
         * (non-Javadoc)
         * 
         * @see
         * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
         * .swt.events.SelectionEvent)
         */
        public void widgetSelected(SelectionEvent e) {

            projectsList.setCheckedElements(new Object[0]);
            setPageComplete(false);
        }
    });
    Dialog.applyDialogFont(deselectAll);
    setButtonLayoutData(deselectAll);

    Button refresh = new Button(buttonsComposite, SWT.PUSH);
    refresh.setText(DataTransferMessages.DataTransfer_refresh);
    refresh.addSelectionListener(new SelectionAdapter() {
        /*
         * (non-Javadoc)
         * 
         * @see
         * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
         * .swt.events.SelectionEvent)
         */
        public void widgetSelected(SelectionEvent e) {
            if (projectFromDirectoryRadio.getSelection()) {
                updateProjectsList(directoryPathField.getText().trim());
            } else {
                updateProjectsList(archivePathField.getText().trim());
            }
        }
    });
    Dialog.applyDialogFont(refresh);
    setButtonLayoutData(refresh);
}

From source file:gov.redhawk.internal.ui.port.nxmplot.FftParameterEntryDialog.java

License:Open Source License

@Override
protected Control createDialogArea(final Composite parent) {
    final Composite container = (Composite) super.createDialogArea(parent);
    final GridLayout gridLayout = new GridLayout(2, false);
    container.setLayout(gridLayout);/*from   w ww  .j  a v  a 2 s .  com*/

    this.errorMessageText = new Text(container, SWT.READ_ONLY | SWT.WRAP);
    this.errorMessageText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
    this.errorMessageText
            .setBackground(this.errorMessageText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    this.errorMessageText.setForeground(this.errorMessageText.getDisplay().getSystemColor(SWT.COLOR_RED));
    // Set the error message text
    // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=66292
    setErrorMessage(this.errorMessage);

    final Label transformSizeLabel = new Label(container, SWT.NONE);
    transformSizeLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    transformSizeLabel.setText("Transform Size:");

    this.transformSizeField = new Text(container, SWT.BORDER);
    this.transformSizeField.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    this.transformSizeField.setText(String.valueOf(this.fftSettings.getTransformSize()));
    this.transformSizeField.setToolTipText("Performance is best if factorable by 2, 3, 4 and 5.");
    this.transformSizeField.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(final ModifyEvent e) {
            String transformSizeString = FftParameterEntryDialog.this.transformSizeField.getText().trim();
            Integer transformSize = null;
            try {
                transformSize = Integer.parseInt(transformSizeString);
            } catch (NumberFormatException ex) {
                // PASS
            }
            if (transformSize != null) {
                FftParameterEntryDialog.this.fftSettings.setTransformSize(transformSize);
            }
            validateInputs();
        }
    });

    final Label percentOverlapLabel = new Label(container, SWT.NONE);
    percentOverlapLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    percentOverlapLabel.setText("Percent Overlap:");

    this.overlapField = new Text(container, SWT.BORDER);
    this.overlapField.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    this.overlapField.setText(String.valueOf(this.fftSettings.getOverlap()));
    this.overlapField.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(final ModifyEvent e) {
            final String newText = FftParameterEntryDialog.this.overlapField.getText();
            Integer overlap = null;
            try {
                overlap = Integer.parseInt(newText.trim());
            } catch (NumberFormatException ex) {
                // PASS
            }
            if (overlap != null) {
                FftParameterEntryDialog.this.fftSettings.setOverlap(overlap);
            }
            validateInputs();
        }
    });

    final Label numAveragesLabel = new Label(container, SWT.NONE);
    numAveragesLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    numAveragesLabel.setText("Num Averages:");

    this.numAveragesField = new Text(container, SWT.BORDER);
    this.numAveragesField.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1));
    this.numAveragesField.setText(String.valueOf(this.fftSettings.getNumAverages()));
    this.numAveragesField
            .setToolTipText("Avoid using large value as it will cause highlighted energy to remain longer.");
    this.numAveragesField.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(final ModifyEvent e) {
            Integer numAverages = null;
            try {
                numAverages = Integer.parseInt(FftParameterEntryDialog.this.numAveragesField.getText().trim());
            } catch (NumberFormatException ex) {
                //PASS
            }
            if (numAverages != null) {
                FftParameterEntryDialog.this.fftSettings.setNumAverages(numAverages);
            }
            validateInputs();
        }
    });

    final Label typeLabel = new Label(container, SWT.NONE);
    typeLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    typeLabel.setText("FFT Output Type:");

    final ComboViewer type = new ComboViewer(container, SWT.READ_ONLY);
    type.getCombo().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1));
    type.setContentProvider(ArrayContentProvider.getInstance()); // ArrayContentProvider does not store any state, therefore can re-use instances
    type.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            return ((FftNxmBlockSettings.OutputType) element).getLabel();
        }
    });
    OutputType currentOutputType = this.fftSettings.getOutputType();
    if (currentOutputType == null) {
        currentOutputType = FftNxmBlockSettings.OutputType.PSD; // default to PSD
    }
    type.setInput(FftNxmBlockSettings.OutputType.values());
    type.setSelection(new StructuredSelection(currentOutputType));
    if (disableChangeOutputType) {
        type.getCombo().setEnabled(false); // disable changing output type
    } else {
        type.addSelectionChangedListener(new ISelectionChangedListener() {
            @Override
            public void selectionChanged(final SelectionChangedEvent event) {
                FftParameterEntryDialog.this.fftSettings.setOutputType(
                        (FftNxmBlockSettings.OutputType) ((IStructuredSelection) event.getSelection())
                                .getFirstElement());
            }
        });
    }

    final Label windowLabel = new Label(container, SWT.NONE);
    windowLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    windowLabel.setText("Window:");

    final ComboViewer window = new ComboViewer(container, SWT.READ_ONLY);
    window.getCombo().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1));
    window.setContentProvider(ArrayContentProvider.getInstance()); // ArrayContentProvider does not store any state, therefore can re-use instances
    window.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            return ((FftNxmBlockSettings.WindowType) element).getLabel();
        }
    });
    window.setInput(FftNxmBlockSettings.WindowType.values());
    WindowType currentWindowType = this.fftSettings.getWindow();
    if (currentWindowType == null) {
        currentWindowType = FftNxmBlockSettings.WindowType.HANNING;
    }
    window.setSelection(new StructuredSelection(currentWindowType));
    window.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            FftParameterEntryDialog.this.fftSettings
                    .setWindow((FftNxmBlockSettings.WindowType) ((IStructuredSelection) event.getSelection())
                            .getFirstElement());
        }
    });

    Dialog.applyDialogFont(container);

    return container;
}

From source file:gov.redhawk.internal.ui.port.nxmplot.PlotSettingsDialog.java

License:Open Source License

@SuppressWarnings("deprecation")
@Override//from w  w  w  .j ava  2s  . c  om
protected Control createDialogArea(final Composite parent) {
    final Composite container = (Composite) super.createDialogArea(parent);
    final GridLayout gridLayout = new GridLayout(2, false);
    container.setLayout(gridLayout);
    Label label;

    // === error message ===
    this.errorMessageText = new Text(container, SWT.READ_ONLY | SWT.WRAP);
    this.errorMessageText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 2, 4));
    this.errorMessageText
            .setBackground(this.errorMessageText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    this.errorMessageText.setForeground(this.errorMessageText.getDisplay().getSystemColor(SWT.COLOR_RED));
    setErrorMessage(this.errorMessage); // Set the error message text - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=66292

    // === frame size ===
    final Label frameSizeLabel = new Label(container, SWT.NONE);
    frameSizeLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    frameSizeLabel.setText("Frame Size:");
    this.frameSizeField = new ComboViewer(container, SWT.BORDER); // writable
    this.frameSizeField.getCombo()
            .setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1));
    this.frameSizeField.setContentProvider(ArrayContentProvider.getInstance()); // ArrayContentProvider does not store any state, therefore can re-use instances
    this.frameSizeField.setLabelProvider(new LabelProvider());
    final String otherValidFSValue = FRAME_SIZE_VALIDATOR.getOtherAllowedValue();
    Assert.isTrue(otherValidFSValue != null);
    Object currentFS = otherValidFSValue;
    final Object[] fsComboInputs;
    final Integer fs = this.plotSettings.getFrameSize();
    if (fs != null) {
        currentFS = fs;
        fsComboInputs = new Object[] { currentFS, otherValidFSValue, 512, 1024, 2048, 4096, 8192 };
    } else {
        fsComboInputs = new Object[] { otherValidFSValue, 512, 1024, 2048, 4096, 8192 };
    }
    this.frameSizeField.setInput(fsComboInputs);
    this.frameSizeField.setSelection(new StructuredSelection(currentFS));
    final Combo fsCombo = this.frameSizeField.getCombo();
    fsCombo.addModifyListener(new ComboVerifyAndSetListener(fsCombo, FRAME_SIZE_VALIDATOR, this) {
        @Override
        void updateSettings(Double newValue) {
            Integer newIntValue = (newValue == null) ? null : newValue.intValue();
            PlotSettingsDialog.this.plotSettings.setFrameSize(newIntValue);
        }
    });
    this.frameSizeField.addSelectionChangedListener(new SelectComboTextListener(fsCombo));

    // === sample rate ===
    final Label sampleRateValueLabel = new Label(container, SWT.NONE);
    sampleRateValueLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    sampleRateValueLabel.setText("Sample rate:");
    this.sampleRateField = new ComboViewer(container, SWT.BORDER); // writable
    this.sampleRateField.getCombo()
            .setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1));
    this.sampleRateField.setContentProvider(ArrayContentProvider.getInstance()); // ArrayContentProvider does not store any state, therefore can re-use instances
    this.sampleRateField.setLabelProvider(new LabelProvider());
    final String otherValidSRateValue = SAMPLE_RATE_VALIDATOR.getOtherAllowedValue();
    Assert.isTrue(otherValidSRateValue != null);
    Object currentSRate = otherValidSRateValue;
    final Object[] srateComboInputs;
    final Double srate = this.plotSettings.getSampleRate();
    if (srate != null) {
        currentSRate = srate;
        srateComboInputs = new Object[] { currentSRate, otherValidSRateValue };
    } else {
        srateComboInputs = new Object[] { otherValidSRateValue };
    }
    this.sampleRateField.setInput(srateComboInputs);
    this.sampleRateField.setSelection(new StructuredSelection(currentSRate));
    final Combo sRateCombo = this.sampleRateField.getCombo();
    sRateCombo.addModifyListener(new ComboVerifyAndSetListener(sRateCombo, SAMPLE_RATE_VALIDATOR, this) {
        @Override
        void updateSettings(Double newValue) {
            PlotSettingsDialog.this.plotSettings.setSampleRate(newValue);
        }
    });
    this.sampleRateField.addSelectionChangedListener(new SelectComboTextListener(sRateCombo));

    // === Min Value ===
    final Label minValueLabel = new Label(container, SWT.NONE);
    minValueLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    minValueLabel.setText("Min value:");
    this.minField = new ComboViewer(container, SWT.BORDER); // writable
    this.minField.getCombo().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1));
    this.minField.setContentProvider(ArrayContentProvider.getInstance()); // ArrayContentProvider does not store any state, therefore can re-use instances
    this.minField.setLabelProvider(new LabelProvider());
    final String otherValidMinValue = MIN_VALUE_VALIDATOR.getOtherAllowedValue();
    Assert.isTrue(otherValidMinValue != null);
    Object currentMinVal = otherValidMinValue;
    final Object[] minValComboInputs;
    final Double minVal = this.plotSettings.getMinValue();
    if (minVal != null) {
        currentMinVal = minVal;
        minValComboInputs = new Object[] { currentMinVal, otherValidMinValue };
    } else {
        minValComboInputs = new Object[] { otherValidMinValue };
    }
    this.minField.setInput(minValComboInputs);
    this.minField.setSelection(new StructuredSelection(currentMinVal));
    final Combo minValCombo = this.minField.getCombo();
    minValCombo.addModifyListener(new ComboVerifyAndSetListener(minValCombo, MIN_VALUE_VALIDATOR, this) {
        @Override
        void updateSettings(Double newValue) {
            PlotSettingsDialog.this.plotSettings.setMinValue(newValue);
        }
    });
    this.minField.addSelectionChangedListener(new SelectComboTextListener(minValCombo));

    // === Max Value ===
    final Label maxValueLabel = new Label(container, SWT.NONE);
    maxValueLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    maxValueLabel.setText("Max value:");
    this.maxField = new ComboViewer(container, SWT.BORDER); // writable
    this.maxField.getCombo().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1));
    this.maxField.setContentProvider(ArrayContentProvider.getInstance()); // ArrayContentProvider does not store any state, therefore can re-use instances
    this.maxField.setLabelProvider(new LabelProvider());
    final String otherValidMaxValue = MAX_VALUE_VALIDATOR.getOtherAllowedValue();
    Assert.isTrue(otherValidMaxValue != null);
    Object currentMaxVal = otherValidMaxValue;
    final Object[] maxValComboInputs;
    final Double maxVal = this.plotSettings.getMaxValue();
    if (maxVal != null) {
        currentMaxVal = maxVal;
        maxValComboInputs = new Object[] { currentMaxVal, otherValidMaxValue };
    } else {
        maxValComboInputs = new Object[] { otherValidMaxValue };
    }
    this.maxField.setInput(maxValComboInputs);
    this.maxField.setSelection(new StructuredSelection(currentMaxVal));
    final Combo maxValCombo = this.maxField.getCombo();
    maxValCombo.addModifyListener(new ComboVerifyAndSetListener(maxValCombo, MAX_VALUE_VALIDATOR, this) {
        @Override
        void updateSettings(Double newValue) {
            PlotSettingsDialog.this.plotSettings.setMaxValue(newValue);
        }
    });
    this.maxField.addSelectionChangedListener(new SelectComboTextListener(maxValCombo));

    // === plot type ===
    final Label typeLabel = new Label(container, SWT.NONE);
    typeLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    typeLabel.setText("Plot Type:");
    this.plotTypeField = new ComboViewer(container, SWT.READ_ONLY);
    this.plotTypeField.getCombo()
            .setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1));
    this.plotTypeField.setContentProvider(ArrayContentProvider.getInstance()); // ArrayContentProvider does not store any state, therefore can re-use instances
    this.plotTypeField.setLabelProvider(new LabelProvider());
    this.plotTypeField.addFilter(new ViewerFilter() {
        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            switch ((PlotType) element) {
            case CONTOUR:
            case MESH:
                return false;
            default:
                return true;
            }
        }
    });
    this.plotTypeField.setInput(PlotType.values());
    this.plotTypeField.setSelection(new StructuredSelection(this.plotSettings.getPlotType()));
    this.plotTypeField.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            Object newVal = ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (newVal instanceof PlotType) {
                PlotSettingsDialog.this.plotSettings.setPlotType((PlotType) newVal);
            }
        }
    });

    // === blocking option ===
    final Button blockingButton = new Button(container, SWT.CHECK);
    blockingButton.setText("Blocking");
    blockingButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
    blockingButton.setToolTipText(
            "On/checked to block pushPacket when Plot is not able to keep up; Off to drop packets in this scenario.");
    dataBindingContext.bindValue(WidgetProperties.selection().observe(blockingButton),
            PojoProperties.value("blockingOption").observe(this.plotSettings));

    // === plot mode / complex mode ===
    label = new Label(container, SWT.NONE);
    label.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    label.setText("Plot Mode:");
    final ComboViewer complexModeWidget = new ComboViewer(container, SWT.READ_ONLY);
    complexModeWidget.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    complexModeWidget.getCombo().setToolTipText("Custom plot mode / complex mode.");
    complexModeWidget.setContentProvider(ArrayContentProvider.getInstance()); // ArrayContentProvider does not store any state, therefore can re-use instances
    complexModeWidget.setLabelProvider(new LabelProvider());
    complexModeWidget.setInput(PlotMode.values());
    dataBindingContext.bindValue(ViewerProperties.singleSelection().observe(complexModeWidget),
            PojoProperties.value("plotMode").observe(this.plotSettings));

    // === enable Plot configure menu ===
    final Button enablePlotMenuButton = new Button(parent, SWT.CHECK);
    enablePlotMenuButton.setText("Enable Plot Configure Menu");
    enablePlotMenuButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
    dataBindingContext.bindValue(WidgetProperties.selection().observe(enablePlotMenuButton),
            PojoProperties.value("enablePlotMenu").observe(this.plotSettings));

    // === enable quick access control widgets ===
    final Button enableQuickControlsButton = new Button(parent, SWT.CHECK);
    enableQuickControlsButton.setText("Enable Quick Access Controls");
    enableQuickControlsButton
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
    dataBindingContext.bindValue(WidgetProperties.selection().observe(enableQuickControlsButton),
            PojoProperties.value("enablePageBookQuickControls").observe(this));

    Dialog.applyDialogFont(container);

    return container;
}

From source file:gov.redhawk.sca.ui.EventDetailsDialog.java

License:Open Source License

@Override
public void create() {
    super.create();

    final int SHELL_WIDTH = 500;
    final int SHELL_HEIGHT = 550;
    getShell().setSize(SHELL_WIDTH, SHELL_HEIGHT);
    getShell().setText("Event Details");

    Dialog.applyDialogFont(this.buttonBar);
    getButton(IDialogConstants.OK_ID).setFocus();
}