List of usage examples for org.eclipse.jface.databinding.viewers ViewerProperties singleSelection
public static IViewerValueProperty singleSelection()
From source file:era.foss.typeeditor.view.ViewForm.java
License:Open Source License
/** * Create a Combo box for selecting the {@link SpecType} of the respective view * //ww w . j a v a 2s . com * @param parent parent composite */ private void createSpecTypeComboViewer(Composite parent) { final ComboViewer specTypeComboViewer = new ComboViewer(parent, SWT.READ_ONLY) { @Override protected void doUpdateItem(Widget data, Object element, boolean fullMap) { // memorize the selection before updating the item, as the // update routine removes the selection... ISelection currentSelection = this.getSelection(); super.doUpdateItem(data, element, fullMap); // set the selection to the previous value this.setSelection(currentSelection); } }; ObservableListContentProvider contentProvider = new ObservableListContentProvider(); specTypeComboViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // set content provider specTypeComboViewer.setContentProvider(contentProvider); // set label provider specTypeComboViewer.setLabelProvider( new ObservableMapLabelProvider(EMFProperties.value(ErfPackage.Literals.IDENTIFIABLE__LONG_NAME) .observeDetail(contentProvider.getKnownElements()))); // set input IEMFListProperty specTypeProperty = EMFProperties.list(ErfPackage.Literals.CONTENT__SPEC_TYPES); specTypeComboViewer.setInput(specTypeProperty.observe(this.erfModel.getCoreContent())); specTypeMaster = ViewerProperties.singleSelection().observe(specTypeComboViewer); if (erfModel.getCoreContent().getSpecTypes().size() > 0) { specTypeComboViewer .setSelection(new StructuredSelection(erfModel.getCoreContent().getSpecTypes().get(0))); } specTypeMaster.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(ValueChangeEvent event) { viewElementTableViewer.refresh(); viewLayoutViewer.refresh(); } }); }
From source file:era.foss.typeeditor.view.ViewForm.java
License:Open Source License
/** * Creates the table viewer for {@link ViewElements} * //from w ww .j a v a 2s. co m * @param parent parent composite */ private void createViewElementTableViewer(Composite parent) { this.viewElementTableViewer = new AddDeleteTableViewer(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION | AddDeleteTableViewer.NO_DESCRIPTION) { @Override public void addElement() { this.elementOwner = (EObject) viewMaster.getValue(); super.addElement(); // is_a ViewElement ViewElement addedViewElement = (ViewElement) super.getElementAt(super.doGetItemCount() - 1); // default placement of views' elements addedViewElement.setEditorRowPosition(getCurrentMaxRowIdx() + 1); addedViewElement.setEditorColumnPosition(0); addedViewElement.setEditorColumnSpan(2); addedViewElement.setEditorRowSpan(1); } /** * Calculates maximum row index of existing view elements * * @return maximum row index */ private int getCurrentMaxRowIdx() { int maxRowIdx = 0; for (int i = 0; i < super.doGetItemCount(); ++i) { ViewElement iterViewElement = (ViewElement) super.getElementAt(i); maxRowIdx = Math.max(maxRowIdx, iterViewElement.getEditorRowPosition() + (iterViewElement.getEditorRowSpan() - 1)); } return maxRowIdx; } @Override protected void createButtonBar() { super.createButtonBar(); // FIXME @cpn create "add all" button } }; // the owner is null as it is set in the overridden addElement() method viewElementTableViewer.setElementInformation((EObject) viewMaster.getValue(), ErfPackage.Literals.VIEW__VIEW_ELEMENTS, ErfPackage.Literals.VIEW_ELEMENT); viewElementTableViewer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2)); viewElementTableViewer.setEditingDomain(editingDomain); ObservableListContentProvider tableViewerContentProvider = new ObservableListContentProvider(); viewElementTableViewer.setContentProvider(tableViewerContentProvider); TableColumnLayout columnLayout = (TableColumnLayout) viewElementTableViewer.getTable().getParent() .getLayout(); // create column showing the Attribute Definition TableViewerColumn attributeDefinitionColumn = new TableViewerColumn(viewElementTableViewer, SWT.NONE); columnLayout.setColumnData(attributeDefinitionColumn.getColumn(), new ColumnWeightData(100, 70)); attributeDefinitionColumn.getColumn().setResizable(false); attributeDefinitionColumn.getColumn().setMoveable(false); attributeDefinitionColumn.getColumn() .setText(Ui.getUiName(ErfPackage.Literals.VIEW_ELEMENT__ATTRIBUTE_DEFINITION)); // label provider for column showing the AttributeDefintion IValueProperty elementProperty = EMFEditProperties.value(editingDomain, FeaturePath .fromList(new EStructuralFeature[] { ErfPackage.Literals.VIEW_ELEMENT__ATTRIBUTE_DEFINITION, ErfPackage.Literals.IDENTIFIABLE__LONG_NAME })); IObservableMap attributeMap = elementProperty.observeDetail(tableViewerContentProvider.getKnownElements()); attributeDefinitionColumn.setLabelProvider(new ObservableMapCellLabelProvider(attributeMap)); // editing support column showing the AttributeDefintion // Combo box: Create combo box to select choices for the reference ComboBoxViewerCellEditor combo = new ComboBoxViewerCellEditorSp( (Composite) viewElementTableViewer.getControl(), SWT.DROP_DOWN | SWT.READ_ONLY); // Combo box: Set Content Provider; ObservableListContentProvider comboBoxContentProvider = new ObservableListContentProvider(); combo.setContentProvider(comboBoxContentProvider); // Combo box: Set Label Provider combo.setLabelProvider( new ObservableMapLabelProvider(EMFProperties.value(ErfPackage.Literals.IDENTIFIABLE__LONG_NAME) .observeDetail(comboBoxContentProvider.getKnownElements()))); // Combo box: set input from selected specType IEMFListProperty specAttributesProperty = EMFProperties .list(ErfPackage.Literals.SPEC_TYPE__SPEC_ATTRIBUTES); combo.setInput(specAttributesProperty.observeDetail(specTypeMaster)); // Set editing support of table cell IValueProperty editorElementProperty = EMFEditProperties.value(editingDomain, ErfPackage.Literals.VIEW_ELEMENT__ATTRIBUTE_DEFINITION); IValueProperty cellEditorProperty = ViewerProperties.singleSelection(); attributeDefinitionColumn.setEditingSupport(ObservableValueEditingSupport.create(viewElementTableViewer, dataBindContext, combo, cellEditorProperty, editorElementProperty)); // provide input for the table IEMFListProperty viewsProperty = EMFProperties.list(ErfPackage.Literals.VIEW__VIEW_ELEMENTS); viewElementTableViewer.addFilter(new SpecTypeFilter()); viewElementTableViewer.setInput(viewsProperty.observeDetail(viewMaster)); viewElementMaster = ViewerProperties.singleSelection().observe(viewElementTableViewer); viewElementTableViewer.getTable().select(0); }
From source file:fr.univnantes.termsuite.ui.dialogs.ConfigureTaggerDialog.java
@Override protected Control createDialogArea(final Composite parent) { Composite container = (Composite) super.createDialogArea(parent); DataBindingContext dbc = new DataBindingContext(); FormToolkit toolkit = new FormToolkit(container.getDisplay()); form = toolkit.createScrolledForm(container); GridDataFactory.fillDefaults().grab(true, true).applyTo(container); GridDataFactory.fillDefaults().grab(true, true).applyTo(form); GridDataFactory.fillDefaults().grab(true, true).applyTo(form.getBody()); form.getBody().setLayout(new GridLayout()); // GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(2).applyTo(form.getBody()); Section helpSection = toolkit.createSection(form.getBody(), SWT.None); helpSection.setText("Help"); helpSection.setExpanded(true);/*from w w w .j a va 2 s .c o m*/ GridDataFactory.fillDefaults().grab(true, true).applyTo(helpSection); Section configureSection = toolkit.createSection(form.getBody(), Section.TITLE_BAR); configureSection.setText("Configure"); configureSection.setExpanded(true); GridDataFactory.fillDefaults().grab(false, false).span(1, 1).applyTo(configureSection); Section errorSection = toolkit.createSection(form.getBody(), SWT.None); errorSection.setText("Status"); errorSection.setExpanded(true); toolkit.decorateFormHeading(form.getForm()); toolkit.paintBordersFor(form.getBody()); GridDataFactory.fillDefaults().grab(false, false).span(1, 1).applyTo(errorSection); // Explaination notice Composite helpSectionClient = toolkit.createComposite(helpSection); helpSection.setClient(helpSectionClient); helpSectionClient.setLayout(new GridLayout()); FormText notice = toolkit.createFormText(helpSectionClient, true); GridDataFactory.fillDefaults().hint(400, SWT.DEFAULT).applyTo(notice); // notice.setLayoutData(new TableWrapData(TableWrapData.FILL)); // GridDataFactory.fillDefaults().grab(false, false).span(2, 1).applyTo(notice); StringBuffer buf = new StringBuffer(); buf.append("<form>"); buf.append( "<p>Due to license concerns, you need to install a 3rd party POS tagger to your computer. You need to have at least one of the two currently supported taggers installed:</p>"); buf.append( "<li>1. Tree Tagger (recommended) - download TreeTagger and its languages models. See official installation <a href=\"tt\">intructions</a></li>"); buf.append( "<li>2. Mate - download <a href=\"mate\">mate language models</a> (Mate's algorithm is already embedded in TermSuite) </li>"); buf.append( "<p>Once installed, pay a special attention to TermSuite's naming convention for TreeTagger and Mate models.</p>"); buf.append( "<p>For detailed information about 3rd party tagger installation, read TermSuite's official documentation on <a href=\"doc\">installing 3rd party tagger (and lemmatizer)</a></p>"); buf.append("</form>"); notice.setText(buf.toString(), true, false); FormTextUtil.bindToExternalLink(notice, "doc", TermSuiteUI.WEB_SITE_TAGGER_DOC_URL); FormTextUtil.bindToExternalLink(notice, "tt", TermSuiteUI.URL_TREE_TAGGER); FormTextUtil.bindToExternalLink(notice, "mate", TermSuiteUI.URL_MATE); Composite configureSectionClient = toolkit.createComposite(configureSection); configureSection.setClient(configureSectionClient); GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(2).applyTo(configureSectionClient); // Tagger type toolkit.createLabel(configureSectionClient, "3rd party tagger:"); ComboViewer taggerComboViewer = new ComboViewer(configureSectionClient, SWT.DROP_DOWN); // toolkit.adapt(taggerComboViewer.getControl(), true, true); taggerComboViewer.setContentProvider(ArrayContentProvider.getInstance()); taggerComboViewer.setLabelProvider(new LabelProvider() { public String getText(Object element) { ETagger tagger = (ETagger) element; return TaggerUtil.getTaggerName(tagger); }; }); taggerComboViewer.setInput(ETagger.VALUES); dbc.bindValue(ViewerProperties.singleSelection().observe(taggerComboViewer), EMFProperties .value(TermsuiteuiPackage.Literals.ETAGGER_CONFIG__TAGGER_TYPE).observe(this.taggerConfig)); // Tagger path toolkit.createLabel(configureSectionClient, "Path to tagger's installation directory:"); BrowseDirText taggerPath = new BrowseDirText(configureSectionClient, SWT.NONE); toolkit.adapt(taggerPath, true, true); GridDataFactory.fillDefaults().grab(true, false).applyTo(taggerPath); dbc.bindValue(new BrowseDirText.TextValueProperty().observe(taggerPath), EMFProperties.value(TermsuiteuiPackage.Literals.ETAGGER_CONFIG__PATH).observe(this.taggerConfig)); Composite errorSectionClient = toolkit.createComposite(errorSection); errorSection.setClient(errorSectionClient); GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(2).applyTo(errorSectionClient); GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(2).applyTo(errorSection); // Language viewer languageLabel = toolkit.createLabel(errorSectionClient, "Languages supported by your current tagger's installation:"); GridDataFactory.fillDefaults().minSize(0, 20).grab(true, true).span(2, 1).applyTo(languageLabel); languageViewer = new TableViewer(errorSectionClient, SWT.BORDER); GridDataFactory.fillDefaults().minSize(0, 100).grab(true, true).span(2, 1) .applyTo(languageViewer.getControl()); languageViewer.setContentProvider(new ArrayContentProvider()); TableViewerColumn column1 = new TableViewerColumn(languageViewer, SWT.LEFT); column1.getColumn().setWidth(200); column1.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return LangUtil.getTermsuiteLang((ELang) element).getName(); } @Override public Image getImage(Object element) { Image flag = TermsuiteImg.INSTANCE.getFlag((ELang) element); return flag; } }); toolkit.adapt(languageViewer.getControl(), true, true); dbc.updateTargets(); updateTaggerName(); return form.getBody(); }
From source file:gov.redhawk.datalist.ui.views.OptionsComposite.java
License:Open Source License
public void createControl(Composite main) { final Composite parent = new Composite(main, SWT.None); parent.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); parent.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).create()); final ComboViewer captureCombo = new ComboViewer(parent, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER); captureCombo.setContentProvider(new ArrayContentProvider()); captureCombo.setLabelProvider(new LabelProvider()); captureCombo.setInput(new Object[] { CaptureMethod.NUMBER, CaptureMethod.INDEFINITELY }); ctx.bindValue(ViewerProperties.singleSelection().observe(captureCombo), BeanProperties.value("processType").observe(settings)); samplesTxt = new Text(parent, SWT.BORDER); samplesTxt.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); ctx.bindValue(WidgetProperties.enabled().observe(samplesTxt), BeanProperties.value("processType").observe(settings), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), new UpdateValueStrategy().setConverter(new Converter(CaptureMethod.class, Boolean.class) { @Override/* www .j a v a 2s .c o m*/ public Object convert(Object fromObject) { if (fromObject == CaptureMethod.INDEFINITELY) { return false; } return true; } })); Binding binding = ctx.bindValue(WidgetProperties.text(SWT.Modify).observe(samplesTxt), BeanProperties.value("samples").observe(settings), new UpdateValueStrategy().setBeforeSetValidator(new IValidator() { @Override public IStatus validate(Object obj) { Double value = (Double) obj; if (Double.valueOf(value) <= 0) { return ValidationStatus.error(settings.getProcessType() + " must be greater than 0."); } if (value > Integer.MAX_VALUE) { return ValidationStatus.error(settings.getProcessType() + " must be less than or equal to " + Integer.MAX_VALUE + "."); } if ((value - value.intValue()) > 0) { return ValidationStatus .error(settings.getProcessType() + " must be a positive integer."); } if (value > 1000000) { return ValidationStatus.warning("For this sample size, you may run out of heap space."); } return ValidationStatus.ok(); } }), null); ControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT); final IObservableValue running = BeanProperties.value("running").observe(state); final IObservableValue pType = BeanProperties.value("processType").observe(settings); ComputedValue enabledSamples = new ComputedValue(Boolean.class) { @Override protected Object calculate() { return !(Boolean) running.getValue() && pType.getValue() != CaptureMethod.INDEFINITELY; } }; ctx.bindValue(WidgetProperties.enabled().observe(samplesTxt), enabledSamples, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); final Label unitsLabel = new Label(parent, SWT.None); unitsLabel.setText(""); GridData unitsLayout = new GridData(); unitsLayout.widthHint = 20; unitsLabel.setLayoutData(unitsLayout); settings.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if ("processType".equals(evt.getPropertyName())) { CaptureMethod method = (CaptureMethod) evt.getNewValue(); if (method == CaptureMethod.INDEFINITELY) { settings.setSamples(1); unitsLabel.setText(""); } else { if (method == CaptureMethod.CLOCK_TIME || method == CaptureMethod.SAMPLE_TIME) { unitsLabel.setText("(s)"); } else { unitsLabel.setText(""); } settings.setSamples(1024); } } } }); Label label = new Label(parent, SWT.None); label.setText("Number of Dimensions:"); Combo columnsCombo = new Combo(parent, SWT.BORDER | SWT.SINGLE | SWT.DROP_DOWN); columnsCombo.setText(REAL); columnsCombo.add(REAL, 0); columnsCombo.add(COMPLEX, 1); columnsCombo.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); ctx.bindValue(WidgetProperties.enabled().observe(columnsCombo), BeanProperties.value("running").observe(state), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), new UpdateValueStrategy().setConverter(new Converter(Boolean.class, Boolean.class) { @Override public Boolean convert(Object fromObject) { return !((Boolean) fromObject); } })); binding = ctx.bindValue(WidgetProperties.selection().observe(columnsCombo), BeanProperties.value("dimensions").observe(settings), new UpdateValueStrategy().setAfterGetValidator(new IValidator() { @Override public IStatus validate(Object value) { if (REAL.equalsIgnoreCase((String) value)) { return ValidationStatus.ok(); } else if (COMPLEX.equalsIgnoreCase((String) value)) { return ValidationStatus.ok(); } else { try { Integer intValue = Integer.valueOf((String) value); if (intValue > 0) { return ValidationStatus.ok(); } } catch (NumberFormatException e) { // PASS } } return ValidationStatus .error("Please enter a positive integer or choose one of the options below."); } }).setConverter(new Converter(String.class, Integer.class) { @Override public Object convert(Object fromObject) { if (REAL.equalsIgnoreCase((String) fromObject)) { return 1; } else if (COMPLEX.equalsIgnoreCase((String) fromObject)) { return 2; } else { return Integer.valueOf((String) fromObject); } } }), null); ControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT); button = new Button(parent, SWT.None); button.setLayoutData(GridDataFactory.fillDefaults().create()); button.setImage(resources.get("icons/start.gif")); button.setToolTipText("Start Acquire"); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (state.isRunning) { stopAcquire(); } else { startAcquire(); } } }); ctx.bindValue(WidgetProperties.enabled().observe(button), new AggregateValidationStatus(ctx, AggregateValidationStatus.MAX_SEVERITY), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), new UpdateValueStrategy().setConverter(new Converter(IStatus.class, Boolean.class) { @Override public Object convert(Object fromObject) { return ((IStatus) fromObject).getSeverity() != IStatus.ERROR; } })); }
From source file:gov.redhawk.frontend.ui.wizard.TunerAllocationWizardPage.java
License:Open Source License
private void addBindings() { // Tuner Type combo UpdateValueStrategy tunerTypeStrategy = new UpdateValueStrategy(); tunerTypeStrategy.setAfterGetValidator(new TargetableValidator(typeCombo.getControl())); ControlDecorationSupport.create(context.bindValue(ViewerProperties.singleSelection().observe(typeCombo), SCAObservables.observeSimpleProperty( tunerAllocationStruct.getSimple(TunerAllocationProperties.TUNER_TYPE.getId())), tunerTypeStrategy, null), SWT.TOP | SWT.LEFT); typeCombo.addSelectionChangedListener(tunerTypeListener); typeCombo.setInput(FrontEndUIActivator.SUPPORTED_TUNER_TYPES.toArray(new String[0])); if (tuner.getTunerType() != null) { typeCombo.setSelection(new StructuredSelection(tuner.getTunerType())); } else {/*w w w . ja va 2s.c om*/ typeCombo.setSelection(new StructuredSelection(FRONTEND.TUNER_TYPE_RX_DIGITIZER.value)); } // allocation ID Text UpdateValueStrategy allocIdStrategy = new UpdateValueStrategy() { @Override public Object convert(Object value) { return value; } }; allocIdStrategy.setAfterGetValidator(new TargetableValidator(allocIdText)); ControlDecorationSupport.create(context.bindValue(WidgetProperties.text(SWT.Modify).observe(allocIdText), SCAObservables.observeSimpleProperty( tunerAllocationStruct.getSimple(TunerAllocationProperties.ALLOCATION_ID.getId())), allocIdStrategy, null), SWT.TOP | SWT.LEFT); ControlDecorationSupport.create(context.bindValue(WidgetProperties.text(SWT.Modify).observe(allocIdText), SCAObservables.observeSimpleProperty(listenerAllocationStruct .getSimple(ListenerAllocationProperties.LISTENER_ALLOCATION_ID.getId())), allocIdStrategy, null), SWT.TOP | SWT.LEFT); allocIdText.setText(getUsername() + ":" + uuid.toString()); allocIdText.setBackground(allocIdText.getDisplay().getSystemColor(SWT.COLOR_CYAN)); allocIdText.addFocusListener(new TargetableFocusListener(allocIdText)); // Existing allocation ID Text UpdateValueStrategy existingAllocIdStrategy1 = new UpdateValueStrategy() { @Override public Object convert(Object value) { return value; } }; UpdateValueStrategy existingAllocIdStrategy2 = new UpdateValueStrategy() { @Override public Object convert(Object value) { return value; } }; existingAllocIdStrategy1.setAfterGetValidator(new TargetableValidator(targetAllocText)); existingAllocIdStrategy2.setAfterGetValidator(new TargetableValidator(targetAllocText)); ControlDecorationSupport .create(context.bindValue(WidgetProperties.text(SWT.Modify).observe(targetAllocText), SCAObservables.observeSimpleProperty(listenerAllocationStruct .getSimple(ListenerAllocationProperties.EXISTING_ALLOCATION_ID.getId())), existingAllocIdStrategy1, existingAllocIdStrategy2), SWT.TOP | SWT.LEFT); targetAllocText.addFocusListener(new TargetableFocusListener(targetAllocText)); targetAllocText.addModifyListener(allocIdListener); // CF Text UpdateValueStrategy cfStrategy1 = new UpdateValueStrategy() { @Override public Object convert(Object value) { try { Double.parseDouble((String) value); } catch (NumberFormatException e) { return null; } return Double.valueOf((String) value) * getUnitsConversionFactor(TunerAllocationProperties.CENTER_FREQUENCY); } }; UpdateValueStrategy cfStrategy2 = new UpdateValueStrategy() { @Override public Object convert(Object value) { if (value instanceof Double) { if (((Double) value).doubleValue() == 0.) { return ""; } double retVal = (Double) value / getUnitsConversionFactor(TunerAllocationProperties.CENTER_FREQUENCY); return String.valueOf(nf.format(retVal)); } return null; } }; cfStrategy1.setAfterGetValidator(new TargetableValidator(cfText)); cfStrategy2.setAfterConvertValidator(new TargetableValidator(cfText)); ControlDecorationSupport.create(context.bindValue(WidgetProperties.text(SWT.Modify).observe(cfText), SCAObservables.observeSimpleProperty( tunerAllocationStruct.getSimple(TunerAllocationProperties.CENTER_FREQUENCY.getId())), cfStrategy1, cfStrategy2), SWT.TOP | SWT.LEFT); cfText.addFocusListener(new TargetableFocusListener(cfText)); // BW Text UpdateValueStrategy bwStrategy1 = new UpdateValueStrategy() { @Override public Object convert(Object value) { try { Double.parseDouble((String) value); } catch (NumberFormatException e) { return null; } return Double.valueOf((String) value) * getUnitsConversionFactor(TunerAllocationProperties.BANDWIDTH); } }; UpdateValueStrategy bwStrategy2 = new UpdateValueStrategy() { @Override public Object convert(Object value) { if (value instanceof Double) { if (((Double) value).intValue() == 0) { return ""; } double retVal = (Double) value / getUnitsConversionFactor(TunerAllocationProperties.BANDWIDTH); return String.valueOf(nf.format(retVal)); } return null; } }; bwStrategy1.setAfterGetValidator(new TargetableValidator(bwText)); bwStrategy2.setAfterConvertValidator(new TargetableValidator(bwText)); ControlDecorationSupport.create(context.bindValue(WidgetProperties.text(SWT.Modify).observe(bwText), SCAObservables.observeSimpleProperty( tunerAllocationStruct.getSimple(TunerAllocationProperties.BANDWIDTH.getId())), bwStrategy1, bwStrategy2), SWT.TOP | SWT.LEFT); bwText.addFocusListener(new TargetableFocusListener(bwText)); // SR Text UpdateValueStrategy srStrategy1 = new UpdateValueStrategy() { @Override public Object convert(Object value) { try { Double.parseDouble((String) value); } catch (NumberFormatException e) { return null; } return Double.valueOf((String) value) * getUnitsConversionFactor(TunerAllocationProperties.SAMPLE_RATE); } }; UpdateValueStrategy srStrategy2 = new UpdateValueStrategy() { @Override public Object convert(Object value) { if (value instanceof Double) { if (((Double) value).intValue() == 0) { return ""; } double retVal = (Double) value / getUnitsConversionFactor(TunerAllocationProperties.SAMPLE_RATE); return String.valueOf(nf.format(retVal)); } return null; } }; srStrategy1.setAfterGetValidator(new TargetableValidator(srText)); srStrategy2.setAfterConvertValidator(new TargetableValidator(srText)); ControlDecorationSupport.create(context.bindValue(WidgetProperties.text(SWT.Modify).observe(srText), SCAObservables.observeSimpleProperty( tunerAllocationStruct.getSimple(TunerAllocationProperties.SAMPLE_RATE.getId())), srStrategy1, srStrategy2), SWT.TOP | SWT.LEFT); srText.addFocusListener(new TargetableFocusListener(srText)); // BW Tolerance Text UpdateValueStrategy bwTolStrategy1 = new UpdateValueStrategy() { @Override public Object convert(Object value) { try { Double.parseDouble((String) value); } catch (NumberFormatException e) { return null; } return Double.valueOf((String) value); } }; UpdateValueStrategy bwTolStrategy2 = new UpdateValueStrategy() { @Override public Object convert(Object value) { if (value instanceof Double) { if (((Double) value).doubleValue() == 0.) { return ""; } double retVal = (Double) value; return String.valueOf(nf.format(retVal)); } return null; } }; bwTolStrategy1.setAfterGetValidator(new TargetableValidator(bwTolText)); bwTolStrategy2.setAfterGetValidator(new TargetableValidator(bwTolText)); ControlDecorationSupport.create(context.bindValue(WidgetProperties.text(SWT.Modify).observe(bwTolText), SCAObservables.observeSimpleProperty( tunerAllocationStruct.getSimple(TunerAllocationProperties.BANDWIDTH_TOLERANCE.getId())), bwTolStrategy1, bwTolStrategy2), SWT.TOP | SWT.LEFT); bwTolText.setText("20"); bwTolText.addFocusListener(new TargetableFocusListener(bwTolText)); // SR Tolerance Text UpdateValueStrategy srTolStrategy1 = new UpdateValueStrategy() { @Override public Object convert(Object value) { try { Double.parseDouble((String) value); } catch (NumberFormatException e) { return null; } return Double.valueOf((String) value); } }; UpdateValueStrategy srTolStrategy2 = new UpdateValueStrategy() { @Override public Object convert(Object value) { if (value instanceof Double) { if (((Double) value).doubleValue() == 0.) { return ""; } double retVal = (Double) value; return String.valueOf(nf.format(retVal)); } return null; } }; srTolStrategy1.setAfterGetValidator(new TargetableValidator(srTolText)); srTolStrategy2.setAfterGetValidator(new TargetableValidator(srTolText)); ControlDecorationSupport.create(context.bindValue(WidgetProperties.text(SWT.Modify).observe(srTolText), SCAObservables.observeSimpleProperty( tunerAllocationStruct.getSimple(TunerAllocationProperties.SAMPLE_RATE_TOLERANCE.getId())), srTolStrategy1, srTolStrategy2), SWT.TOP | SWT.LEFT); srTolText.setText("20"); srTolText.addFocusListener(new TargetableFocusListener(srTolText)); // Listener Allocation Check Box UpdateValueStrategy listenerAllocStrategy1 = new UpdateValueStrategy() { @Override public Object convert(Object value) { // If selected, set device control to false if (value instanceof Boolean) { Boolean selected = (Boolean) value; return new Boolean(!selected); } return new Boolean(true); } }; UpdateValueStrategy listenerAllocStrategy2 = new UpdateValueStrategy() { @Override public Object convert(Object value) { // If selected, set device control to false if (value instanceof Boolean) { Boolean selected = (Boolean) value; return new Boolean(!selected); } return null; } }; context.bindValue(WidgetProperties.selection().observe(listenerAlloc), SCAObservables.observeSimpleProperty( tunerAllocationStruct.getSimple(TunerAllocationProperties.DEVICE_CONTROL.getId())), listenerAllocStrategy1, listenerAllocStrategy2); // RF FLow ID Text ControlDecorationSupport.create(context.bindValue(WidgetProperties.text(SWT.Modify).observe(rfFlowIdText), SCAObservables.observeSimpleProperty( tunerAllocationStruct.getSimple(TunerAllocationProperties.RF_FLOW_ID.getId())), null, null), SWT.TOP | SWT.LEFT); }
From source file:gov.redhawk.ide.snapshot.ui.BulkIOSnapshotWizardPage.java
License:Open Source License
@Override public void createControl(Composite main) { setupDialogSettingsStorage(); // for saving wizard page settings final Composite parent = new Composite(main, SWT.None); parent.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).create()); DataBindingContext dataBindingCtx = getContext(); // === capture method (how to capture samples) === final ComboViewer captureCombo = new ComboViewer(parent, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.SIMPLE); captureCombo.setLabelProvider(new LabelProvider()); captureCombo.setContentProvider(ArrayContentProvider.getInstance()); // ArrayContentProvider does not store any state, therefore can re-use instances captureCombo.setInput(CaptureMethod.values()); dataBindingCtx.bindValue(ViewerProperties.singleSelection().observe(captureCombo), BeansObservables.observeValue(bulkIOsettings, BulkIOSnapshotSettings.PROP_CAPTURE_METHOD)); // === number of samples === samplesTxt = new Text(parent, SWT.BORDER); samplesTxt.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(1, 1).create()); UpdateValueStrategy validateSamples = createSamplesValidatorStrategy(); // validator to ensure that invalid number of samples are caught and displayed samplesBinding = dataBindingCtx.bindValue( WidgetProperties.text(SWT.Modify).observeDelayed(UPDATE_DELAY_MS, samplesTxt), BeansObservables.observeValue(bulkIOsettings, BulkIOSnapshotSettings.PROP_SAMPLES), validateSamples, null);// w ww.j a v a 2 s . c o m // === units for number samples field === unitsLabel = new Label(parent, SWT.None); unitsLabel.setText(""); unitsLabel.setLayoutData( GridDataFactory.fillDefaults().grab(true, false).span(1, 1).hint(20, SWT.DEFAULT).create()); // update validator, set text field enable, and units as needed captureCombo.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { CaptureMethod method = bulkIOsettings.getCaptureMethod(); updateControls(method); } }); // === connection ID == Label label = new Label(parent, SWT.None); label.setText("Connection ID (Optional):"); Text connectionIDField = new Text(parent, SWT.BORDER); connectionIDField.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create()); connectionIDField.setToolTipText("Custom Port connection ID to use vs a generated one."); dataBindingCtx.bindValue(WidgetProperties.text(SWT.Modify).observe(connectionIDField), BeansObservables.observeValue(bulkIOsettings, BulkIOSnapshotSettings.PROP_CONNECTION_ID)); // === create output control widgets == createOutputControls(parent); bulkIOsettings.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (BulkIOSnapshotSettings.PROP_CAPTURE_METHOD.equals(evt.getPropertyName())) { updateControls((CaptureMethod) evt.getNewValue()); } } }); setPageComplete(false); setPageSupport(WizardPageSupport.create(this, dataBindingCtx)); setControl(parent); restoreWidgetValues(bulkIOsettings); }
From source file:gov.redhawk.ide.snapshot.ui.SnapshotWizardPage.java
License:Open Source License
protected void createOutputControls(final Composite parent) { Label label;/* w w w . j ava 2 s .c om*/ // Add Label and combo box to select file type label = new Label(parent, SWT.None); label.setText("File Type:"); ComboViewer fileTypeCombo = new ComboViewer(parent, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.SIMPLE); fileTypeCombo.getControl() .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create()); fileTypeCombo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((IDataWriterDesc) element).getName(); } }); fileTypeCombo.setContentProvider(ArrayContentProvider.getInstance()); // ArrayContentProvider does not store any state, therefore can re-use instances IDataWriterDesc[] input = SnapshotActivator.getDataReceiverRegistry().getRecieverDescs(); fileTypeCombo.setInput(input); fileTypeCombo.setSorter(new ViewerSorter()); // sort combo items alphabetically (this selects last item?) context.bindValue(ViewerProperties.singleSelection().observe(fileTypeCombo), BeansObservables.observeValue(settings, "dataWriter")); if (input.length > 0) { fileTypeCombo.setSelection(new StructuredSelection(fileTypeCombo.getElementAt(0))); // select first sorted element } // add check box to see if the user wants to save to their workspace workspaceCheck = new Button(parent, SWT.CHECK); workspaceCheck.setText("Save to Workspace"); // add check box to see if user wants to confirm overwrite of existing file(s) final Button confirmOverwrite = new Button(parent, SWT.CHECK); confirmOverwrite.setText("Confirm overwrite"); context.bindValue(WidgetProperties.selection().observe(confirmOverwrite), BeansObservables.observeValue(settings, "confirmOverwrite")); // region to hold the different pages for saving to the workspace or the file system fileFinder = new Group(parent, SWT.SHADOW_ETCHED_IN); fileFinder.setText("Save to"); fileFinder.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(3, 2).create()); fileFinderLayout = new StackLayout(); fileFinderLayout.marginHeight = 5; fileFinderLayout.marginWidth = 5; fileFinder.setLayout(fileFinderLayout); // the different pages: search file system, search workspace searchFileSystem = makeFileSystemSave(fileFinder); searchFileSystem.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(3, 2).create()); searchWorkbench = makeWorkbenchTree(fileFinder); searchWorkbench.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(3, 2).create()); // This binding must be defined after all controls have been configured, because its update strategy // implementation calls setSaveLocation(), which depends on the controls being already configured context.bindValue(WidgetProperties.selection().observe(workspaceCheck), BeansObservables.observeValue(settings, "saveToWorkspace"), createWsCheckUpdateStrategy(), createWsCheckUpdateStrategy()); restoreWidgetValues(settings); // determining which page starts on top setSaveLocationComposite(workspaceCheck.getSelection(), true); // switching pages workspaceCheck.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setSaveLocationComposite(workspaceCheck.getSelection(), true); } }); }
From source file:gov.redhawk.ide.snapshot.ui.SnapshotWizardPage.java
License:Open Source License
private Composite makeWorkbenchTree(Composite parent) { Composite comp = new Composite(parent, SWT.None); comp.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).create()); // create label and text field for inputing the file name Label fileNameLbl = new Label(comp, SWT.None); fileNameLbl.setText("Workspace File Name:"); final Text fileNameTxt = new Text(comp, SWT.BORDER); UpdateValueStrategy wkspFnameTargetToModelValidator = createFilenameT2MUpdateStrategy("Workspace File Name", true);//from w w w. j a v a2 s. c om context.bindValue(WidgetProperties.text(SWT.Modify).observeDelayed(UPDATE_DELAY_MS, fileNameTxt), BeansObservables.observeValue(settings, "path"), wkspFnameTargetToModelValidator, null); fileNameTxt.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create()); // create tree with which to navigate the workbench file system final TreeViewer workbenchTree = new TreeViewer(comp, SWT.BORDER | SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION); WorkbenchContentProvider contentProvider = new WorkbenchContentProvider(); workbenchTree.setContentProvider(contentProvider); final WorkbenchLabelProvider labels = new WorkbenchLabelProvider(); workbenchTree.setLabelProvider(labels); workbenchTree.setInput(ResourcesPlugin.getWorkspace().getRoot()); workbenchTree.getControl().setLayoutData( GridDataFactory.fillDefaults().grab(true, true).span(3, 1).hint(SWT.DEFAULT, 150).create()); UpdateValueStrategy wkspTreeTargetToModelValidator = createWorkspaceTreeT2MUpdateStrategy(workbenchTree); context.bindValue(ViewerProperties.singleSelection().observe(workbenchTree), BeansObservables.observeValue(settings, "resource"), wkspTreeTargetToModelValidator, null); Object[] elements = contentProvider.getElements(ResourcesPlugin.getWorkspace().getRoot()); if (elements.length > 0) { workbenchTree.setSelection(new StructuredSelection(elements[0])); } workbenchTree.addFilter(new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { if (element instanceof IResource) { IResource resource = (IResource) element; if (resource.getName().isEmpty() || resource.getName().charAt(0) == '.') { return false; } } return true; } }); IShellProvider shellProvider = new IShellProvider() { @Override public Shell getShell() { return SnapshotWizardPage.this.getShell(); } }; final CreateFolderAction folderAction = new CreateFolderAction(shellProvider); final DeleteResourceAction deleteAction = new DeleteResourceAction(shellProvider); final RefreshAction refreshAction = new RefreshAction(shellProvider); final RenameResourceAction renamAction = new RenameResourceAction(shellProvider); final NewProjectAction projectAction = new NewProjectAction(); workbenchTree.addSelectionChangedListener(folderAction); workbenchTree.addSelectionChangedListener(deleteAction); workbenchTree.addSelectionChangedListener(refreshAction); workbenchTree.addSelectionChangedListener(renamAction); // the menu for the tree items MenuManager contextMenuManager = new MenuManager(); contextMenuManager.setRemoveAllWhenShown(true); contextMenuManager.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager) { manager.add(projectAction); manager.add(folderAction); manager.add(renamAction); manager.add(refreshAction); manager.add(deleteAction); } }); Menu menu = contextMenuManager.createContextMenu(workbenchTree.getControl()); workbenchTree.getControl().setMenu(menu); return comp; }
From source file:gov.redhawk.internal.ui.port.nxmplot.handlers.PlotWizardPage.java
License:Open Source License
@Override public void createControl(Composite root) { Composite parent = new Composite(root, SWT.None); parent.setLayout(new GridLayout(2, false)); Label label;/*from w w w. jav a 2 s .co m*/ Group group; // == PLOT Block settings (e.g. plot type, plot mode, frame size, etc.) == group = new Group(parent, SWT.None); group.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create()); group.setText("PLOT"); label = new Label(group, SWT.None); label.setText("&Type:"); ComboViewer viewer = new ComboViewer(group, SWT.READ_ONLY); viewer.setLabelProvider(new LabelProvider()); viewer.setContentProvider(new ArrayContentProvider()); viewer.setInput(PlotType.getStandardPlotTypes()); viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); if (plotSettings.getPlotType() == null) { plotSettings.setPlotType(PlotType.LINE); } dataBindingContext.bindValue(ViewerProperties.singleSelection().observe(viewer), PojoProperties.value("plotType").observe(plotSettings)); label = new Label(group, SWT.None); label.setText("&Mode:"); viewer = new ComboViewer(group, SWT.READ_ONLY); viewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((PlotMode) element).getLabel(); } }); viewer.setContentProvider(new ArrayContentProvider()); viewer.setInput(PlotMode.getStandardModes()); viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); dataBindingContext.bindValue(ViewerProperties.singleSelection().observe(viewer), PojoProperties.value("plotMode").observe(plotSettings)); new PlotNxmBlockControls(plotBlockSettings, dataBindingContext).createControls(group); // === BULKIO settings === if (bulkIOBlockSettings != null) { group = new Group(parent, SWT.None); group.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create()); group.setText("BULKIO"); new BulkIONxmBlockControls(bulkIOBlockSettings, dataBindingContext).createControls(group); } // == BULKIO SDDS settings === if (sddsBlockSettings != null) { group = new Group(parent, SWT.None); group.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create()); group.setText("BULKIO SDDS"); new SddsNxmBlockControls(sddsBlockSettings, dataBindingContext).createControls(group); } // == FFT settings == final Group fftGroup = new Group(parent, SWT.None); final Button button = new Button(fftGroup, SWT.CHECK); button.setText("Take &FFT"); button.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create()); dataBindingContext.bindValue(WidgetProperties.selection().observe(button), PojoProperties.value("fft").observe(this)); fftGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create()); fftGroup.setText("FFT"); final List<Control> skip = Arrays.asList(fftGroup, button); new FftNxmBlockControls(fftBlockSettings, dataBindingContext).createControls(fftGroup); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setFftEnabled(fftGroup, button.getSelection(), skip); } }); setFftEnabled(fftGroup, button.getSelection(), skip); WizardPageSupport.create(this, dataBindingContext); setControl(parent); }
From source file:gov.redhawk.internal.ui.port.nxmplot.PlotSettingsDialog.java
License:Open Source License
@SuppressWarnings("deprecation") @Override//from w w w. j a v a 2s . c o m 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; }