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.kalypsomodel1d2d.ui.map.channeledit.BankSelectionComposite.java
License:Open Source License
private void createNumberSegmentsControl(final FormToolkit toolkit, final Composite parent, final ChannelEditData data, final DatabindingForm binding, final int spinnerWidth) { final Label label = toolkit.createLabel(parent, Messages .getString("org.kalypso.kalypsomodel1d2d.ui.map.channeledit.CreateMainChannelComposite.28")); //$NON-NLS-1$ label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final Spinner spinNumberSegments = new Spinner(parent, SWT.BORDER); toolkit.adapt(spinNumberSegments);//from www . j av a2 s.c o m final GridData gridDataSpin = new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1); gridDataSpin.widthHint = spinnerWidth; spinNumberSegments.setLayoutData(gridDataSpin); spinNumberSegments.setToolTipText(Messages .getString("org.kalypso.kalypsomodel1d2d.ui.map.channeledit.CreateMainChannelComposite.29")); //$NON-NLS-1$ spinNumberSegments.setValues(1, 2, 99, 0, 1, 10); final ISWTObservableValue targetNumBankSegments = SWTObservables.observeSelection(spinNumberSegments); final IObservableValue modelNumBankSegments = BeansObservables.observeValue(data, ChannelEditData.PROPERTY_NUM_BANK_SEGMENTS); binding.bindValue(targetNumBankSegments, modelNumBankSegments); }
From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.ChannelEditUtil.java
License:Open Source License
public static Button createWidgetSelectionButton(final FormToolkit toolkit, final Composite parent, final ChannelEditData data, final IDataBinding binding, final SetWidgetAction action, final String enabledPropertyName) { final Button selectButton = ActionButton.createButton(toolkit, parent, action, SWT.TOGGLE); final IWidget delegate = action.getDelegate(); final ISWTObservableValue targetActionSelection = SWTObservables.observeSelection(selectButton); final IObservableValue modelActionSelection = BeansObservables.observeValue(data, ChannelEditData.PROPERTY_DELEGATE); final DataBinder selectionActionBinder = new DataBinder(targetActionSelection, modelActionSelection); selectionActionBinder.setModelToTargetConverter(new DelegateActionSelectionConverter(delegate)); binding.bindValue(selectionActionBinder); if (enabledPropertyName != null) { final IValueProperty enabledProperty = JFaceProperties.value(IAction.class, IAction.ENABLED, IAction.ENABLED);//from w w w. jav a 2 s .c o m final IObservableValue targetActionEnablement = enabledProperty.observe(action); final IObservableValue modelProfileSelectionEnablement = BeansObservables.observeValue(data, enabledPropertyName); binding.bindValue(targetActionEnablement, modelProfileSelectionEnablement); } return selectButton; }
From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.ProfileSection.java
License:Open Source License
private void createAutoZoomCheckbox(final FormToolkit toolkit, final Composite parent, final ChannelEditData data, final DatabindingForm binding) { /* zoom to extent button */ final String checkboxAutoZoomLabel = Messages .getString("org.kalypso.kalypsomodel1d2d.ui.map.channeledit.CreateMainChannelComposite.2"); //$NON-NLS-1$ final Button checkboxAutoZoom = toolkit.createButton(parent, checkboxAutoZoomLabel, SWT.CHECK); checkboxAutoZoom.setToolTipText(Messages .getString("org.kalypso.kalypsomodel1d2d.ui.map.channeledit.CreateMainChannelComposite.43")); //$NON-NLS-1$ final ISWTObservableValue targetAutoZoom = SWTObservables.observeSelection(checkboxAutoZoom); final IObservableValue modelAutoZoom = BeansObservables.observeValue(data, ChannelEditData.PROPERTY_PROFILE_AUTO_ZOOM); binding.bindValue(targetAutoZoom, modelAutoZoom); final IObservableValue targetAutoZoomEnabled = SWTObservables.observeEnabled(checkboxAutoZoom); final IObservableValue modelProfileEditingEnabled = BeansObservables.observeValue(data, ChannelEditData.PROPERTY_PROFILE_EDITING_ENABLED); binding.bindValue(targetAutoZoomEnabled, modelProfileEditingEnabled); }
From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.ProfileSelectionSection.java
License:Open Source License
private void createSegmentSpinner(final FormToolkit toolkit, final Composite parent, final ChannelEditData data, final DatabindingForm binding, final int spinnerWidth) { final Label spinnerLabel = toolkit.createLabel(parent, Messages .getString("org.kalypso.kalypsomodel1d2d.ui.map.channeledit.CreateMainChannelComposite.36")); //$NON-NLS-1$ spinnerLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final Spinner spinNumProfIntersections = new Spinner(parent, SWT.BORDER); toolkit.adapt(spinNumProfIntersections); final GridData gridDataSpinner = new GridData(SWT.FILL, SWT.CENTER, false, false); gridDataSpinner.widthHint = spinnerWidth; spinNumProfIntersections.setLayoutData(gridDataSpinner); spinNumProfIntersections.setToolTipText(Messages .getString("org.kalypso.kalypsomodel1d2d.ui.map.channeledit.CreateMainChannelComposite.37")); //$NON-NLS-1$ spinNumProfIntersections.setValues(1, 4, 99, 0, 1, 10); final ISWTObservableValue targetNumProfileSegments = SWTObservables .observeSelection(spinNumProfIntersections); final IObservableValue modelNumProfileSegments = BeansObservables.observeValue(data, ChannelEditData.PROPERTY_NUM_PROFILE_SEGMENTS); binding.bindValue(targetNumProfileSegments, modelNumProfileSegments); }
From source file:org.kalypso.kalypsomodel1d2d.ui.map.TriangulateGeometryComposite.java
License:Open Source License
private void createContents(final FormToolkit toolkit, final Composite parent) { final Section section = toolkit.createSection(parent, Section.EXPANDED | Section.DESCRIPTION | Section.TITLE_BAR); section.setText(Messages.getString("TriangulateGeometryWidget.5")); //$NON-NLS-1$ section.setDescription(Messages.getString("TriangulateGeometryWidget.6")); //$NON-NLS-1$ section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); final Composite sectionComposite = toolkit.createComposite(section, SWT.NONE); GridLayoutFactory.swtDefaults().numColumns(2).applyTo(sectionComposite); section.setClient(sectionComposite); /* Check for triangle.exe */ final IStatus statusTriangleExe = checkForTriangleExe(); if (!statusTriangleExe.isOK()) { final StatusComposite triangleStatusComposite = new StatusComposite(sectionComposite, SWT.NONE); triangleStatusComposite.setStatus(statusTriangleExe); triangleStatusComposite.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1)); }//from w ww .ja v a 2 s .c o m final IValueChangeListener valueChangedListener = new IValueChangeListener() { @Override public void handleValueChange(final ValueChangeEvent event) { try { m_triangulationBuilder.finish(); } catch (final Exception e) { final Shell shell = parent.getShell(); final IStatus result = StatusUtilities.statusFromThrowable(e); StatusDialog.open(shell, result, event.getObservableValue().toString()); } } }; /* maximal Area */ toolkit.createLabel(sectionComposite, Messages.getString("TriangulateGeometryWidget.7")); //$NON-NLS-1$ final Text maxArea = toolkit.createText(sectionComposite, StringUtils.EMPTY, SWT.SINGLE | SWT.BORDER); maxArea.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); final ISWTObservableValue targetMaxArea = SWTObservables.observeText(maxArea, SWT.FocusOut); final IObservableValue modelMaxArea = BeansObservables.observeValue(m_triangulationBuilder, TriangulationBuilder.PROPERTY_MAX_AREA); final DataBinder maxAreaBinder = new DataBinder(targetMaxArea, modelMaxArea); maxAreaBinder.addTargetAfterConvertValidator( new NumberNotNegativeValidator(IStatus.ERROR, Messages.getString("TriangulateGeometryWidget.8"))); //$NON-NLS-1$ m_binding.bindValue(maxAreaBinder); targetMaxArea.addValueChangeListener(valueChangedListener); /* Minimum Angle */ toolkit.createLabel(sectionComposite, Messages.getString("TriangulateGeometryWidget.10")); //$NON-NLS-1$ final Text minAngle = toolkit.createText(sectionComposite, "22", SWT.SINGLE | SWT.BORDER); //$NON-NLS-1$ minAngle.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); final ISWTObservableValue targetMinAngle = SWTObservables.observeText(minAngle, SWT.FocusOut); final IObservableValue modelMinAngle = BeansObservables.observeValue(m_triangulationBuilder, TriangulationBuilder.PROPERTY_MIN_ANGLE); final DataBinder minAngleBinder = new DataBinder(targetMinAngle, modelMinAngle); minAngleBinder.addTargetAfterConvertValidator( new NumberRangeValidator(IStatus.ERROR, 0, 32, Messages.getString("TriangulateGeometryWidget.12"))); //$NON-NLS-1$ m_binding.bindValue(minAngleBinder); targetMinAngle.addValueChangeListener(valueChangedListener); /* Steiner checkbox */ final Button noSteinerButton = toolkit.createButton(sectionComposite, Messages.getString("TriangulateGeometryWidget.14"), SWT.CHECK); //$NON-NLS-1$ noSteinerButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1)); final ISWTObservableValue targetSteiner = SWTObservables.observeSelection(noSteinerButton); final IObservableValue modelSteiner = BeansObservables.observeValue(m_triangulationBuilder, TriangulationBuilder.PROPERTY_NO_STEINER_ON_BOUNDARY); m_binding.bindValue(targetSteiner, modelSteiner); targetSteiner.addValueChangeListener(valueChangedListener); /* 'Apply To' button */ final Composite buttonPanel = toolkit.createComposite(parent); GridLayoutFactory.swtDefaults().applyTo(buttonPanel); buttonPanel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final TriangulateGeometryApplyToAction convertToModelAction = new TriangulateGeometryApplyToAction( m_triangulationBuilder, m_workspace); final Button buttonConvertToModel = ActionButton.createButton(toolkit, buttonPanel, convertToModelAction); buttonConvertToModel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); }
From source file:org.kalypso.model.wspm.pdb.ui.internal.admin.gaf.AddWaterLevelPage.java
License:Open Source License
private void createDoImportCheck(final Composite parent) { final Button checkbox = new Button(parent, SWT.CHECK); checkbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); checkbox.setText(Messages.getString("AddWaterLevelPage.2")); //$NON-NLS-1$ final ISWTObservableValue targetSelection = SWTObservables.observeSelection(checkbox); final IObservableValue modelSelection = BeansObservables.observeValue(m_data, ImportGafData.PROPERTY_IMPORT_WATERLEVELS); m_binding.bindValue(targetSelection, modelSelection); final ISWTObservableValue targetEnablement = SWTObservables.observeEnabled(checkbox); final IObservableValue modelEnablement = BeansObservables.observeValue(m_data, ImportGafData.PROPERTY_HAS_WATERLEVELS); m_binding.bindValue(targetEnablement, modelEnablement); }
From source file:org.kalypso.model.wspm.pdb.ui.internal.checkout.CheckoutPdbPreviewPage.java
License:Open Source License
private void addWarning(final Composite panel, final IStatus status, final String confirmProperty) { if (status.isOK()) return;// ww w.j a va 2 s . c o m if (confirmProperty != null) { final Button confirmCheck = new Button(panel, SWT.CHECK); confirmCheck.setToolTipText(Messages.getString("CheckoutPdbPreviewPage.2")); //$NON-NLS-1$ confirmCheck.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); final ISWTObservableValue target = SWTObservables.observeSelection(confirmCheck); final IObservableValue model = BeansObservables.observeValue(m_data, confirmProperty); final DataBinder binder = new DataBinder(target, model); binder.addTargetAfterGetValidator(new CheckoutPdbConfirmValidator()); m_binding.bindValue(binder); } final StatusComposite statusComposite = new StatusComposite(panel, StatusComposite.HIDE_TEXT); statusComposite.setStatus(status); statusComposite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); final String message = status.getMessage(); final Label text = new Label(panel, SWT.WRAP); text.setText(message); text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); }
From source file:org.kalypso.model.wspm.pdb.ui.internal.content.NonConnectedControl.java
License:Open Source License
private void createAutoConnectCheck(final FormToolkit toolkit, final Composite parent) { final Button button = toolkit.createButton(parent, Messages.getString("NonConnectedControl.2"), SWT.CHECK); //$NON-NLS-1$ button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final ISWTObservableValue target = SWTObservables.observeSelection(button); final IObservableValue model = BeansObservables.observeValue(m_data, OpenConnectionData.PROPERTY_AUTOCONNECT); m_binding.bindValue(target, model);/*from w w w . ja v a 2 s.c o m*/ }
From source file:org.kalypso.model.wspm.pdb.ui.internal.tin.DhmIndexComposite.java
License:Open Source License
private void createDateControl(final Composite main, final IDataBinding dataBinding, final String displayLabel, final String property, final boolean editable) { final Label label = new Label(main, SWT.NONE); label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); label.setText(displayLabel);/* w ww.j a va 2 s . c o m*/ final DateTime dateTime = new DateTime(main, SWT.DATE | SWT.DROP_DOWN | SWT.BORDER); dateTime.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); dateTime.setEnabled(editable); final ISWTObservableValue targetValue = SWTObservables.observeSelection(dateTime); final IObservableValue modelValue = BeansObservables.observeValue(m_dhmIndex, property); dataBinding.bindValue(targetValue, modelValue); }
From source file:org.kalypso.model.wspm.pdb.ui.internal.tin.imports.SearchDhmIndexPage.java
License:Open Source License
@Override public void createControl(final Composite parent) { /* Create the databinding. */ final DatabindingWizardPage dataBinding = new DatabindingWizardPage(this, null); /* Create the main composite. */ final Composite main = new Composite(parent, SWT.NONE); final GridLayout mainLayout = new GridLayout(1, false); mainLayout.marginHeight = 0;/*from w w w . j a v a2 s . c om*/ mainLayout.marginWidth = 0; main.setLayout(mainLayout); /* Create the filter group. */ final Group filterGroup = new Group(main, SWT.NONE); filterGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); filterGroup.setLayout(new GridLayout(1, false)); filterGroup.setText(Messages.getString("SearchDhmIndexPage_2")); //$NON-NLS-1$ /* Create the filter textbox. */ final Text filterText = new Text(filterGroup, SWT.BORDER | SWT.SEARCH); filterText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); /* Create the filter button. */ final Button filterButton = new Button(filterGroup, SWT.CHECK); filterButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); filterButton.setText(Messages.getString("SearchDhmIndexPage_3")); //$NON-NLS-1$ /* Create a tree viewer. */ m_searchViewer = new TreeViewer(main, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL); final GridData treeData = new GridData(SWT.FILL, SWT.FILL, true, true); treeData.heightHint = 200; final Tree tree = m_searchViewer.getTree(); tree.setLayoutData(treeData); tree.setLinesVisible(true); tree.setHeaderVisible(true); configureTreeViewer(m_searchViewer); m_searchViewer.setContentProvider(new SearchDhmIndexContentProvider()); /* Add the column resize control listener. */ tree.addControlListener(new ColumnsResizeControlListener()); /* Create a scrolled form. */ final ScrolledForm scrolledForm = new ScrolledForm(main); scrolledForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); scrolledForm.setExpandHorizontal(true); scrolledForm.setExpandVertical(true); /* Get the body. */ final Composite body = scrolledForm.getBody(); final GridLayout bodyLayout = new GridLayout(1, false); bodyLayout.marginHeight = 0; bodyLayout.marginWidth = 0; body.setLayout(bodyLayout); /* Add the dhm index composite. */ m_dhmIndexComposite = new DhmIndexComposite(body, SWT.NONE, m_settingsData.getDhmIndex(), false, dataBinding); m_dhmIndexComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); /* Reflow. */ scrolledForm.reflow(true); /* Create the filter. */ final String dbCoordinateSystem = m_settingsData.getDbCoordinateSystem(); final DhmIndexFilter filter = new DhmIndexFilter(m_searchViewer, dbCoordinateSystem, StringUtils.EMPTY, false); m_searchViewer.setFilters(new ViewerFilter[] { filter }); /* Do the data binding. */ final ISWTObservableValue textTarget = SWTObservables.observeText(filterText, new int[] { SWT.Modify }); final IObservableValue textModel = PojoObservables.observeValue(filter, DhmIndexFilter.PROPERTY_FILTER_TEXT); dataBinding.bindValue(textTarget, textModel); /* Do the data binding. */ final ISWTObservableValue buttonTarget = SWTObservables.observeSelection(filterButton); final IObservableValue buttonModel = PojoObservables.observeValue(filter, DhmIndexFilter.PROPERTY_FILTER_QUERY); dataBinding.bindValue(buttonTarget, buttonModel); /* Do the data binding. */ final IObservableValue targetViewer = ViewersObservables.observeInput(m_searchViewer); final IObservableValue modelViewer = BeansObservables.observeValue(m_settingsData, PdbImportConnectionChooserData.PROPERTY_DHM_INDEXES); dataBinding.bindValue(targetViewer, modelViewer); /* Do the data binding. */ final IObservableValue targetIndex = ViewersObservables.observeSinglePostSelection(m_searchViewer); final IObservableValue modelIndex = BeansObservables.observeValue(m_settingsData, PdbImportConnectionChooserData.PROPERTY_DHM_INDEX); final DataBinder dhmIndexBinder = new DataBinder(targetIndex, modelIndex); dhmIndexBinder.addTargetBeforeSetValidator( new NotNullValidator<>(DhmIndex.class, IStatus.ERROR, Messages.getString("SearchDhmIndexPage.0"))); //$NON-NLS-1$ dhmIndexBinder.addTargetBeforeSetValidator(new ExistsValidator(DhmIndex.class, IStatus.ERROR, Messages.getString("SearchDhmIndexPage.1"), m_settingsData, m_dataContainer)); //$NON-NLS-1$ dataBinding.bindValue(dhmIndexBinder); /* Add a listener. */ modelIndex.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(final ValueChangeEvent event) { /* Parent is disposed. */ if (body.isDisposed()) return; /* Get the dhm index from the selection. */ final DhmIndex dhmIndex = (DhmIndex) event.getObservableValue().getValue(); /* The dhm index composite needs to get the new object set. */ if (m_dhmIndexComposite != null && !m_dhmIndexComposite.isDisposed()) m_dhmIndexComposite.dispose(); /* Add the dhm index composite. */ m_dhmIndexComposite = new DhmIndexComposite(body, SWT.NONE, dhmIndex, false, dataBinding); m_dhmIndexComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); ColumnsResizeControlListener.refreshColumnsWidth(tree); /* Reflow. */ scrolledForm.reflow(true); } }); /* Set the control to the page. */ setControl(main); /* the user needs to do something first! */ setPageComplete(false); }