List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeSelection
@Deprecated public static ISWTObservableValue observeSelection(Control control)
control
. From source file:org.kalypso.ui.wizards.lengthsection.ConfigureLengthSectionWizardPage.java
License:Open Source License
@Override public void createControl(final Composite parent) { m_binding = new DatabindingWizardPage(this, null); final int comboWidth1 = 75; final int comboWidth2 = 50; final Composite composite = new Composite(parent, SWT.NONE); setControl(composite);// ww w . j a va 2 s . c om composite.setLayout(new GridLayout()); /* Status */ final IStatus status = m_data.getStatus(); if (!status.isOK()) { final StatusComposite statusComposite = new StatusComposite(composite, SWT.NONE); statusComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); statusComposite.setStatus(status); } /* river line selection group */ final Group riverLineGroup = new Group(composite, SWT.NONE); riverLineGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); riverLineGroup.setLayout(new GridLayout(2, false)); riverLineGroup.setText( Messages.getString("org.kalypso.ui.wizards.lengthsection.ConfigureLengthSectionWizardPage.4")); //$NON-NLS-1$ final Label riverLineText = new Label(riverLineGroup, SWT.NONE); riverLineText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); riverLineText.setText( Messages.getString("org.kalypso.ui.wizards.lengthsection.ConfigureLengthSectionWizardPage.5")); //$NON-NLS-1$ final ComboViewer comboRiverLine = new ComboViewer(riverLineGroup, SWT.DROP_DOWN | SWT.READ_ONLY); final GridData gridDatacomboRiverLine = new GridData(SWT.FILL, SWT.CENTER, true, false); gridDatacomboRiverLine.widthHint = comboWidth1; comboRiverLine.getControl().setLayoutData(gridDatacomboRiverLine); comboRiverLine.setContentProvider(new ArrayContentProvider()); comboRiverLine.setLabelProvider(new LabelProvider()); comboRiverLine.setInput(m_data.getRiverThemes()); final IViewerObservableValue targetRiverLine = ViewersObservables .observeSinglePostSelection(comboRiverLine); final IObservableValue modelRiverLine = BeansObservables.observeValue(m_data, CreateLengthSectionData.PROPERTY_RIVER_LINE); final IValidator riverLineNotNullValidator = new NotNullValidator<>(IKalypsoFeatureTheme.class, IStatus.WARNING, Messages.getString("ConfigureLengthSectionWizardPage.0")); //$NON-NLS-1$ m_binding.bindValue(targetRiverLine, modelRiverLine, riverLineNotNullValidator); /* * define properties page ( river name field selection combo river name selection combo, delta station spinner, * station field select combo) */ final Group propertyGroup = new Group(composite, SWT.NONE); propertyGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); propertyGroup.setLayout(new GridLayout(2, false)); propertyGroup.setText( Messages.getString("org.kalypso.ui.wizards.lengthsection.ConfigureLengthSectionWizardPage.6")); //$NON-NLS-1$ /* Water Body Name */ final Label riverNameText = new Label(propertyGroup, SWT.NONE); riverNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); riverNameText.setText( Messages.getString("org.kalypso.ui.wizards.lengthsection.ConfigureLengthSectionWizardPage.7")); //$NON-NLS-1$ final ComboViewer comboRiverNameField = new ComboViewer(propertyGroup, SWT.NONE | SWT.READ_ONLY); final GridData gridDataComboRiverName = new GridData(SWT.FILL, SWT.END, true, false); gridDataComboRiverName.widthHint = comboWidth2; comboRiverNameField.getControl().setLayoutData(gridDataComboRiverName); comboRiverNameField.setContentProvider(new ArrayContentProvider()); comboRiverNameField.setLabelProvider(new PropertyNameLabelProvider()); final IObservableValue targetRiverNameInput = ViewersObservables.observeInput(comboRiverNameField); final IObservableValue modelRiverNameInput = BeansObservables.observeValue(m_data, CreateLengthSectionData.PROPERTY_RIVER_NAME_INPUT); m_binding.bindValue(targetRiverNameInput, modelRiverNameInput); final IViewerObservableValue targetRiverName = ViewersObservables .observeSinglePostSelection(comboRiverNameField); final IObservableValue modelRiverName = BeansObservables.observeValue(m_data, CreateLengthSectionData.PROPERTY_RIVER_NAME_PROPERTY); final IValidator riverNameNotNullValidator = new NotNullValidator<>(IValuePropertyType.class, IStatus.ERROR, Messages.getString("ConfigureLengthSectionWizardPage.1")); //$NON-NLS-1$ m_binding.bindValue(targetRiverName, modelRiverName, riverNameNotNullValidator); /* Selected water body */ final Label selectedRiverText = new Label(propertyGroup, SWT.NONE); selectedRiverText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); selectedRiverText.setText( Messages.getString("org.kalypso.ui.wizards.lengthsection.ConfigureLengthSectionWizardPage.8")); //$NON-NLS-1$ final ComboViewer comboSelectedRiverNameField = new ComboViewer(propertyGroup, SWT.NONE | SWT.READ_ONLY); final GridData gridDataComboSelectedRiverField = new GridData(SWT.FILL, SWT.END, true, false); gridDataComboSelectedRiverField.widthHint = comboWidth2; comboSelectedRiverNameField.getControl().setLayoutData(gridDataComboSelectedRiverField); comboSelectedRiverNameField.setContentProvider(new ArrayContentProvider()); comboSelectedRiverNameField.setLabelProvider(new LabelProvider()); final IObservableValue targetSelectedRiverNameInput = ViewersObservables .observeInput(comboSelectedRiverNameField); final IObservableValue modelSelectedRiverNameInput = BeansObservables.observeValue(m_data, CreateLengthSectionData.PROPERTY_RIVER_NAMES); m_binding.bindValue(targetSelectedRiverNameInput, modelSelectedRiverNameInput); final IViewerObservableValue targetSelectedRiverName = ViewersObservables .observeSinglePostSelection(comboSelectedRiverNameField); final IObservableValue modelSelectedRiverName = BeansObservables.observeValue(m_data, CreateLengthSectionData.PROPERTY_SELECTED_RIVER_NAME); final IValidator selectedRiverNameNotNullValidator = new NotNullValidator<>(String.class, IStatus.ERROR, Messages.getString("ConfigureLengthSectionWizardPage.2")); //$NON-NLS-1$ m_binding.bindValue(targetSelectedRiverName, modelSelectedRiverName, selectedRiverNameNotNullValidator); /* Station from */ final Label stationFromFieldText = new Label(propertyGroup, SWT.NONE); stationFromFieldText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); stationFromFieldText.setText( Messages.getString("org.kalypso.ui.wizards.lengthsection.ConfigureLengthSectionWizardPage.9")); //$NON-NLS-1$ final ComboViewer comboStationFromField = new ComboViewer(propertyGroup, SWT.NONE | SWT.READ_ONLY); final GridData gridDatacomboStationFromField = new GridData(SWT.FILL, SWT.END, true, false); gridDatacomboStationFromField.widthHint = comboWidth2; comboStationFromField.getControl().setLayoutData(gridDatacomboStationFromField); comboStationFromField.setContentProvider(new ArrayContentProvider()); comboStationFromField.setLabelProvider(new PropertyNameLabelProvider()); final IObservableValue targetStationFromInput = ViewersObservables.observeInput(comboStationFromField); final IObservableValue modelStationFromInput = BeansObservables.observeValue(m_data, CreateLengthSectionData.PROPERTY_STATION_FROM_INPUT); m_binding.bindValue(targetStationFromInput, modelStationFromInput); final IViewerObservableValue targetStationFrom = ViewersObservables .observeSinglePostSelection(comboStationFromField); final IObservableValue modelStationFrom = BeansObservables.observeValue(m_data, CreateLengthSectionData.PROPERTY_STATION_FROM_PROPERTY); m_binding.bindValue(targetStationFrom, modelStationFrom); /* Station to */ final Label stationToFieldText = new Label(propertyGroup, SWT.NONE); stationToFieldText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); stationToFieldText.setText( Messages.getString("org.kalypso.ui.wizards.lengthsection.ConfigureLengthSectionWizardPage.10")); //$NON-NLS-1$ final ComboViewer comboStationToField = new ComboViewer(propertyGroup, SWT.NONE | SWT.READ_ONLY); final GridData gridDatacomboStationToField = new GridData(SWT.FILL, SWT.END, true, false); gridDatacomboStationToField.widthHint = comboWidth2; comboStationToField.getControl().setLayoutData(gridDatacomboStationToField); comboStationToField.setContentProvider(new ArrayContentProvider()); comboStationToField.setLabelProvider(new PropertyNameLabelProvider()); final IObservableValue targetStationToInput = ViewersObservables.observeInput(comboStationToField); final IObservableValue modelStationToInput = BeansObservables.observeValue(m_data, CreateLengthSectionData.PROPERTY_STATION_TO_INPUT); m_binding.bindValue(targetStationToInput, modelStationToInput); final IViewerObservableValue targetStationTo = ViewersObservables .observeSinglePostSelection(comboStationToField); final IObservableValue modelStationTo = BeansObservables.observeValue(m_data, CreateLengthSectionData.PROPERTY_STATION_TO_PROPERTY); m_binding.bindValue(targetStationTo, modelStationTo); /* km or m checkbox */ final Label dummy1 = new Label(propertyGroup, SWT.NONE); dummy1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final Button buttonKmValues = new Button(propertyGroup, SWT.CHECK); buttonKmValues.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); buttonKmValues.setText( Messages.getString("org.kalypso.ui.wizards.lengthsection.ConfigureLengthSectionWizardPage.11")); //$NON-NLS-1$ final ISWTObservableValue targetUseKmValues = SWTObservables.observeSelection(buttonKmValues); final IObservableValue modelUseKmValues = BeansObservables.observeValue(m_data, CreateLengthSectionData.PROPERTY_USE_KM_VALUES); m_binding.bindValue(targetUseKmValues, modelUseKmValues); /* sampling distance */ final Label samplingDistanceText = new Label(propertyGroup, SWT.NONE); samplingDistanceText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); samplingDistanceText.setText( Messages.getString("org.kalypso.ui.wizards.lengthsection.ConfigureLengthSectionWizardPage.12")); //$NON-NLS-1$ final Spinner samplingDistanceSpinner = new Spinner(propertyGroup, SWT.BORDER | SWT.TRAIL); final GridData gridDatastationSpinner = new GridData(SWT.FILL, SWT.END, true, false); gridDatastationSpinner.widthHint = 30; samplingDistanceSpinner.setLayoutData(gridDatastationSpinner); samplingDistanceSpinner.setValues(0, 1, 1000, 0, 1, 100); final ISWTObservableValue targetSamplingDistance = SWTObservables.observeSelection(samplingDistanceSpinner); final IObservableValue modelSamplingDistance = BeansObservables.observeValue(m_data, CreateLengthSectionData.PROPERTY_SAMPLING_DISTANCE); m_binding.bindValue(targetSamplingDistance, modelSamplingDistance); }
From source file:org.kalypso.zml.ui.imports.ImportObservationSourcePage.java
License:Open Source License
private void createTimeZoneControl(final Composite parent) { final Label timezoneLabel = new Label(parent, SWT.NONE); timezoneLabel.setText(Messages.getString("ImportObservationSelectionWizardPage.0")); //$NON-NLS-1$ final String[] tz = TimezoneUtilities.getSupportedTimezones(); final ComboViewer comboTimeZones = new ComboViewer(parent, SWT.BORDER | SWT.SINGLE | SWT.DROP_DOWN | SWT.READ_ONLY); comboTimeZones.getControl().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); comboTimeZones.setContentProvider(new ArrayContentProvider()); comboTimeZones.setLabelProvider(new LabelProvider()); comboTimeZones.setInput(tz);/*from ww w. ja v a 2 s .co m*/ comboTimeZones.addFilter(new TimezoneEtcFilter()); new Label(parent, SWT.NONE); /* Binding */ final IViewerObservableValue targetSelection = ViewersObservables .observeSinglePostSelection(comboTimeZones); final ISWTObservableValue targetModification = SWTObservables.observeSelection(comboTimeZones.getControl()); final IObservableValue model = BeansObservables.observeValue(m_data, ImportObservationData.PROPERTY_TIMEZONE); final DataBinder modificationBinder = new DataBinder(targetModification, model); modificationBinder.addTargetAfterConvertValidator(new TimezoneStringValidator()); m_binding.bindValue(targetSelection, model); m_binding.bindValue(modificationBinder); }
From source file:org.marketcetera.photon.internal.strategy.engine.ui.DeployedStrategyConfigurationComposite.java
/** * Constructor. Creates the UI widgets and binds them to the provided model. * /*from w ww . ja v a 2s . c om*/ * @param parent * parent composite in which to create the widgets * @param dataBindingContext * the data binding context to use for model-UI bindings * @param strategy * the strategy model object */ public DeployedStrategyConfigurationComposite(Composite parent, DataBindingContext dataBindingContext, final DeployedStrategy strategy) { super(parent); mStrategy = strategy; GridLayoutFactory.swtDefaults().spacing(10, 5).numColumns(2).applyTo(this); List<Control> tabControls = Lists.newLinkedList(); Messages.DEPLOYED_STRATEGY_CONFIGURATION_COMPOSITE_INSTANCE_NAME.createLabel(this); { Text instanceNameText = new Text(this, SWT.READ_ONLY); DataBindingUtils.bindValue(dataBindingContext, SWTObservables.observeText(instanceNameText, SWT.Modify), observe(StrategyEngineCorePackage.Literals.STRATEGY__INSTANCE_NAME)); } Messages.DEPLOYED_STRATEGY_CONFIGURATION_COMPOSITE_CLASS.createLabel(this); { Text classText = new Text(this, SWT.READ_ONLY); DataBindingUtils.bindValue(dataBindingContext, SWTObservables.observeText(classText, SWT.Modify), observe(StrategyEngineCorePackage.Literals.STRATEGY__CLASS_NAME)); } Messages.DEPLOYED_STRATEGY_CONFIGURATION_COMPOSITE_LANGUAGE.createLabel(this); { Text languageText = new Text(this, SWT.READ_ONLY); DataBindingUtils.bindValue(dataBindingContext, SWTObservables.observeText(languageText, SWT.Modify), observe(StrategyEngineCorePackage.Literals.STRATEGY__LANGUAGE)); } Messages.DEPLOYED_STRATEGY_CONFIGURATION_COMPOSITE_SCRIPT.createLabel(this); { Text scriptText = new Text(this, SWT.READ_ONLY); DataBindingUtils.bindValue(dataBindingContext, SWTObservables.observeText(scriptText, SWT.Modify), observe(StrategyEngineCorePackage.Literals.STRATEGY__SCRIPT_PATH)); } { Button routeButton = new Button(this, SWT.CHECK); routeButton.setText(Messages.STRATEGY_DEPLOYMENT_COMPOSITE_ROUTE.getRawLabel()); routeButton.setToolTipText(Messages.STRATEGY_DEPLOYMENT_COMPOSITE_ROUTE.getTooltip()); dataBindingContext.bindValue(SWTObservables.observeSelection(routeButton), observe(StrategyEngineCorePackage.Literals.STRATEGY__ROUTE_ORDERS_TO_SERVER)); GridDataFactory.swtDefaults().span(2, 1).applyTo(routeButton); if (strategy.getState() == StrategyState.RUNNING) { routeButton.setEnabled(false); tabControls.add(routeButton); } } setTabList(tabControls.toArray(new Control[tabControls.size()])); }
From source file:org.marketcetera.photon.internal.strategy.engine.ui.DeployStrategyComposite.java
/** * Constructor. Creates the UI widgets and binds them to the provided model. * /*w ww .ja va 2s . c o m*/ * @param parent * parent composite in which to create the widgets * @param dataBindingContext * the data binding context to use for model-UI bindings * @param strategy * the strategy model object * @param availableEngines * the engines available for selection * @param selectedEngine * the selected engine model * @param scriptSelectionButtons * controls the creation of script selection buttons */ public DeployStrategyComposite(Composite parent, DataBindingContext dataBindingContext, final Strategy strategy, StrategyEngine[] availableEngines, final IObservableValue selectedEngine, ScriptSelectionButton... scriptSelectionButtons) { super(parent); mDataBindingContext = dataBindingContext; mStrategy = strategy; GridLayoutFactory.swtDefaults().spacing(10, 5).numColumns(3).applyTo(this); Messages.STRATEGY_DEPLOYMENT_COMPOSITE_SCRIPT.createLabel(this); final IObservableValue script = observe(StrategyEngineCorePackage.Literals.STRATEGY__SCRIPT_PATH); { Text text = new Text(this, SWT.BORDER); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(text); bindRequiredField(SWTObservables.observeText(text, SWT.Modify), script, Messages.STRATEGY_DEPLOYMENT_COMPOSITE_SCRIPT.getRawLabel()); script.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(ValueChangeEvent event) { scriptValueChanged(); } }); scriptValueChanged(); } { final Composite buttons = new Composite(this, SWT.NONE); for (ScriptSelectionButton scriptSelectionButton : scriptSelectionButtons) { final ScriptSelectionButton current = scriptSelectionButton; Button button = new Button(buttons, SWT.NONE); button.setText(scriptSelectionButton.getText()); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { final String selected = current.selectScript(getShell(), (String) script.getValue()); if (StringUtils.isNotBlank(selected)) { script.setValue(selected.trim()); } } }); } GridDataFactory.fillDefaults().applyTo(buttons); GridLayoutFactory.swtDefaults().numColumns(scriptSelectionButtons.length).generateLayout(buttons); } Messages.STRATEGY_DEPLOYMENT_COMPOSITE_LANGUAGE.createLabel(this); { Combo combo = new Combo(this, SWT.NONE); combo.setItems(Language.getValues()); GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(combo); bindRequiredField(SWTObservables.observeText(combo), observe(StrategyEngineCorePackage.Literals.STRATEGY__LANGUAGE), Messages.STRATEGY_DEPLOYMENT_COMPOSITE_LANGUAGE.getRawLabel()); } new Label(this, SWT.NONE); Messages.STRATEGY_DEPLOYMENT_COMPOSITE_CLASS.createLabel(this); { Text classText = new Text(this, SWT.BORDER); GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).hint(180, SWT.DEFAULT).applyTo(classText); bindRequiredField(SWTObservables.observeText(classText, SWT.Modify), observe(StrategyEngineCorePackage.Literals.STRATEGY__CLASS_NAME), Messages.STRATEGY_DEPLOYMENT_COMPOSITE_CLASS.getRawLabel()); } new Label(this, SWT.NONE); Messages.STRATEGY_DEPLOYMENT_COMPOSITE_INSTANCE_NAME.createLabel(this); { Text instanceNameText = new Text(this, SWT.BORDER); GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).hint(180, SWT.DEFAULT) .applyTo(instanceNameText); bindRequiredField(SWTObservables.observeText(instanceNameText, SWT.Modify), observe(StrategyEngineCorePackage.Literals.STRATEGY__INSTANCE_NAME), Messages.DEPLOYED_STRATEGY_CONFIGURATION_COMPOSITE_INSTANCE_NAME.getRawLabel()); } new Label(this, SWT.NONE); { Group configurationGroup = new Group(this, SWT.NONE); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).indent(5, SWT.DEFAULT) .span(3, 1).applyTo(configurationGroup); GridLayoutFactory.swtDefaults().applyTo(configurationGroup); configurationGroup.setText(Messages.STRATEGY_DEPLOYMENT_COMPOSITE_CONFIGURATION_GROUP__LABEL.getText()); { Button routeButton = new Button(configurationGroup, SWT.CHECK); routeButton.setText(Messages.STRATEGY_DEPLOYMENT_COMPOSITE_ROUTE.getRawLabel()); routeButton.setToolTipText(Messages.STRATEGY_DEPLOYMENT_COMPOSITE_ROUTE.getTooltip()); dataBindingContext.bindValue(SWTObservables.observeSelection(routeButton), observe(StrategyEngineCorePackage.Literals.STRATEGY__ROUTE_ORDERS_TO_SERVER)); } } { Label selectionEnginesLabel = new Label(this, SWT.NONE); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(3, 1) .applyTo(selectionEnginesLabel); selectionEnginesLabel .setText(Messages.STRATEGY_DEPLOYMENT_COMPOSITE_ENGINE_SELECTION_TABLE__LABEL.getText()); } { final CheckboxTableViewer selectEnginesTableViewer = CheckboxTableViewer.newCheckList(this, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, true).indent(6, SWT.DEFAULT).span(3, 1) .applyTo(selectEnginesTableViewer.getTable()); selectEnginesTableViewer.setContentProvider(new ArrayContentProvider()); selectEnginesTableViewer.setLabelProvider(new StrategyEnginesLabelProvider()); selectEnginesTableViewer.setInput(availableEngines); /* * Typically, checkbox tables allow multiple selection. In this * case, we are using the widget for a single selection so we need a * custom listener. It is also a WritableValue and IViewerObservable * for data binding and RequiredFieldSupport. */ class FirstAndOnly extends WritableValue implements IViewerObservable, ICheckStateListener { public FirstAndOnly() { super(selectedEngine.getValue(), StrategyEngine.class); } @Override public Viewer getViewer() { return selectEnginesTableViewer; } @Override public void checkStateChanged(CheckStateChangedEvent event) { // simulate single selection if (event.getChecked()) { for (Object object : selectEnginesTableViewer.getCheckedElements()) { if (object != event.getElement()) { selectEnginesTableViewer.setChecked(object, false); } else { setValue(object); } } } else { setValue(null); } } } // if an engine has been pre-selected, check it and disable the // table if (selectedEngine.getValue() != null) { selectEnginesTableViewer.getTable().setEnabled(false); selectEnginesTableViewer.setChecked(selectedEngine.getValue(), true); } FirstAndOnly firstAndOnly = new FirstAndOnly(); selectEnginesTableViewer.addCheckStateListener(firstAndOnly); getObservablesManager().addObservable(firstAndOnly); bindRequiredField(firstAndOnly, selectedEngine, Messages.STRATEGY_DEPLOYMENT_COMPOSITE_ENGINE__LABEL.getText()); } }
From source file:org.marketcetera.photon.internal.strategy.ruby.RegisterRubyStrategyWizardPage.java
@Override public void createControl(Composite parent) { DataBindingContext dbc = new DataBindingContext(); Composite composite = new Composite(parent, SWT.NONE); composite.setFont(parent.getFont()); Text file = StrategyUI.createFileText(composite); file.setText(mFile);/*from ww w. j a va 2 s .co m*/ final Text className = StrategyUI.createClassNameText(composite, false); dbc.bindValue(SWTObservables.observeText(className, SWT.Modify), mClassName, null, null); final Text name = StrategyUI.createDisplayNameText(composite); dbc.bindValue(SWTObservables.observeText(name, SWT.Modify), mName, null, null); final Group configuration = new Group(composite, SWT.NONE); configuration.setFont(composite.getFont()); configuration.setText(Messages.REGISTER_RUBY_STRATEGY_CONFIGURATION_GROUP_LABEL.getText()); GridDataFactory.defaultsFor(configuration).span(2, 1).applyTo(configuration); final Button routeToServer = StrategyUI.createRoutingCheckBox(configuration); dbc.bindValue(SWTObservables.observeSelection(routeToServer), mRouteToServer, null, null); mRouteToServer.setValue(Boolean.FALSE); GridLayoutFactory.swtDefaults().generateLayout(configuration); composite.setTabList(new Control[] { className, name, configuration }); mClassName.addValueChangeListener(new IValueChangeListener() { boolean mSynchronizing; @Override public void handleValueChange(ValueChangeEvent event) { String currentName = name.getText(); String oldValue = (String) event.diff.getOldValue(); if (StringUtils.isBlank(oldValue) && StringUtils.isBlank(currentName)) { mSynchronizing = true; } else if (!ObjectUtils.equals(currentName, event.diff.getOldValue())) { mSynchronizing = false; } if (mSynchronizing) { mName.setValue(event.diff.getNewValue()); } } }); dbc.addValidationStatusProvider( new NotBlankValidator(mClassName, Messages.STRATEGYUI_CLASS_LABEL.getText())); dbc.addValidationStatusProvider( new NotBlankValidator(mName, Messages.STRATEGYUI_DISPLAY_NAME_LABEL.getText())); dbc.addValidationStatusProvider(new UniqueNameValidator()); WizardPageSupport.create(this, dbc); GridLayoutFactory.swtDefaults().numColumns(2).generateLayout(composite); setControl(composite); }
From source file:org.marketcetera.photon.views.CurrencyOrderTicketView.java
@Override protected void bindMessage() { super.bindMessage(); final DataBindingContext dbc = getDataBindingContext(); final CurrencyOrderTicketModel model = getModel(); final ICurrencyOrderTicket ticket = getXSWTView(); //Symbol// w ww . ja v a 2 s . c o m final IObservableValue symbolTarget = SWTObservables.observeText(ticket.getSymbolText(), SWT.Modify); MultiValidator currencySymbolValidator = new MultiValidator() { @Override protected IStatus validate() { String symbol = (String) symbolTarget.getValue(); if (symbol == null || symbol.isEmpty()) { return ValidationStatus.ok(); } try { CurrencyValidationHandler.validateCurrencySymbol(symbol); return ValidationStatus.ok(); } catch (OrderValidationException e) { return ValidationStatus.error(e.getLocalizedMessage(), e); } } }; DataBindingUtils.initControlDecorationSupportFor(currencySymbolValidator, SWT.BOTTOM | SWT.LEFT); dbc.addValidationStatusProvider(currencySymbolValidator); //Near Tenor final IObservableValue nearTenorTarget = SWTObservables.observeText(ticket.getNearTenorText(), SWT.Modify); dbc.bindValue(nearTenorTarget, model.getNearTenor()); MultiValidator nearTenorValidator = new MultiValidator() { @Override protected IStatus validate() { String tenor = (String) nearTenorTarget.getValue(); tenor = StringUtils.trimToNull(tenor); if (tenor == null || tenor.isEmpty()) { return ValidationStatus.ok(); } try { CurrencyValidationHandler.validateTenor(tenor); return ValidationStatus.ok(); } catch (OrderValidationException e) { return ValidationStatus.error(e.getLocalizedMessage(), e); } } }; DataBindingUtils.initControlDecorationSupportFor(nearTenorValidator, SWT.BOTTOM | SWT.LEFT); dbc.addValidationStatusProvider(nearTenorValidator); enableForNewOrderOnly(ticket.getNearTenorText()); enableForNewOrderOnly(ticket.getSelectNearTenorButton()); //Far Tenor final IObservableValue farTenorTarget = SWTObservables.observeText(ticket.getFarTenorText(), SWT.Modify); dbc.bindValue(farTenorTarget, model.getFarTenor()); MultiValidator farTenorValidator = new MultiValidator() { @Override protected IStatus validate() { String tenor = (String) farTenorTarget.getValue(); tenor = StringUtils.trimToNull(tenor); if (tenor == null || tenor.isEmpty()) { return ValidationStatus.ok(); } try { CurrencyValidationHandler.validateTenor(tenor); return ValidationStatus.ok(); } catch (OrderValidationException e) { return ValidationStatus.error(e.getLocalizedMessage(), e); } } }; DataBindingUtils.initControlDecorationSupportFor(farTenorValidator, SWT.BOTTOM | SWT.LEFT); dbc.addValidationStatusProvider(farTenorValidator); final IObservableValue leftCCYTarget = SWTObservables.observeSelection(ticket.getRadioButtonCCY1()); dbc.bindValue(leftCCYTarget, model.getLeftCCY()); final IObservableValue rightCCYTarget = SWTObservables.observeSelection(ticket.getRadioButtonCCY2()); dbc.bindValue(rightCCYTarget, model.getRightCCY()); enableForNewOrderOnly(ticket.getFarTenorText()); enableForNewOrderOnly(ticket.getSelectFarTenorButton()); enableForNewOrderOnly(ticket.getRadioButtonCCY1()); enableForNewOrderOnly(ticket.getRadioButtonCCY2()); }
From source file:org.nabucco.framework.common.dynamiccode.ui.rcp.component.multipage.masterdetail.widgetcreators.code.WidgetCreatorForCode.java
License:Open Source License
@Override protected Control createWidget(Composite parent, Code code, Method method, Object object, boolean readOnly, ViewModel externalViewModel, NabuccoMessageManager messageManager, String propertyName) { final String codePathGetterName = deriveCodePathGetterNameFromSetterName(method.getName()); final CodePath codePath = getCodePathViaReflection(object, codePathGetterName); final CodeContentProvider codeContentProvider = new CodeContentProvider(codePath); final ElementPickerComboParameter params = new ElementPickerComboParameter(codeContentProvider, new CodeLabelProvider()); // ElementPickerCombo elementCombo = new ElementPickerCombo(parent, params); ElementPickerCombo elementCombo = super.getFormToolkit().createElementPickerCombo(parent, params, readOnly, true);// w w w . j a v a 2s . c o m // combo.setLayoutData(gridData); final DataBindingContext bindingContext = new DataBindingContext(); final IObservableValue uiElement = SWTObservables.observeSelection(elementCombo.getCombo()); if (object instanceof Datatype) { final CodeMiniModel model = new CodeMiniModel(codeContentProvider, method, (Datatype) object, externalViewModel, code); final IObservableValue modelElement = BeansObservables.observeValue(model, CodeMiniModel.PROPERTY_VALUE); bindingContext.bindValue(uiElement, modelElement, null, null); elementCombo.addSelectionListener(new CodeComboBoxHandler(model)); } return elementCombo; }
From source file:org.nabucco.framework.exporting.ui.rcp.wizard.ExportWizardPage.java
License:Open Source License
/** * Layout the export all checkbox.//from w w w. j a v a 2 s.c o m * * @param parent * the parent composite */ private Button layoutExportAll(Composite parent) { Button exportAll = new Button(parent, SWT.CHECK); exportAll.setText(I18N.i18n(CHECKBOX_EXPORT_ALL)); DataBindingContext bindingContext = new DataBindingContext(); IObservableValue uiElement = SWTObservables.observeSelection(exportAll); IObservableValue modelElement = BeansObservables.observeValue(this.model, ExportWizardModel.PROPERTY_EXPORTALL); bindingContext.bindValue(uiElement, modelElement); return exportAll; }
From source file:org.nabucco.framework.exporting.ui.rcp.wizard.ExportWizardPage.java
License:Open Source License
/** * Create the export options specification widgets. * /*from www .j a v a 2 s . c o m*/ * @param parent * the parent composite */ private void layoutOptionsGroup(Composite parent) { Composite optionsGroup = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; optionsGroup.setLayout(layout); optionsGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL)); Button checkbox = new Button(optionsGroup, SWT.CHECK | SWT.LEFT); checkbox.setText(I18N.i18n(CHECKBOX_OVERWRITE)); DataBindingContext bindingContext = new DataBindingContext(); IObservableValue uiElement = SWTObservables.observeSelection(checkbox); IObservableValue modelElement = BeansObservables.observeValue(this.model, ExportWizardModel.PROPERTY_OVERWRITE); bindingContext.bindValue(uiElement, modelElement); }
From source file:org.nabucco.framework.exporting.ui.rcp.wizard.ExportWizardPage.java
License:Open Source License
/** * Create the export destination specification widgets * /*from w ww . j a v a2 s. com*/ * @param parent * the parent composite */ private void layoutDestinationGroup(Composite parent) { Composite group = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 3; group.setLayout(layout); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); group.setLayoutData(data); Label dest = new Label(group, SWT.NONE); dest.setText(I18N.i18n(LABEL_DESTINATION)); // Destination Field Combo combo = new Combo(group, SWT.SINGLE | SWT.BORDER); combo.setFocus(); for (String history : this.model.getDestinationNames()) { combo.add(history); } DataBindingContext bindingContext = new DataBindingContext(); IObservableValue uiElement = SWTObservables.observeSelection(combo); IObservableValue modelElement = BeansObservables.observeValue(this.model, ExportWizardModel.PROPERTY_DESTINATION); bindingContext.bindValue(uiElement, modelElement); data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); combo.setLayoutData(data); // Browse Button Button button = new Button(group, SWT.PUSH); button.setText(I18N.i18n(BUTTON_BROWSE)); setButtonLayoutData(button); button.addSelectionListener(new ExportBrowseButtonListener(super.getContainer().getShell(), this.model)); // Vertical Spacer new Label(parent, SWT.NONE); }