List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeEnabled
@Deprecated public static ISWTObservableValue observeEnabled(Control control)
From source file:org.eclipse.rcptt.ui.report.ReportMainPage.java
License:Open Source License
private void createGenerateWorkspace(Composite panel) { Button generateToWorkspace = new Button(panel, SWT.RADIO); GridDataFactory.swtDefaults().span(2, 1).applyTo(generateToWorkspace); generateToWorkspace.setText(Messages.ReportMainPage_GenerateInWorkspaceButton); Composite sPanelWorkspace = new Composite(panel, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(3).extendedMargins(20, 0, 0, 0).applyTo(sPanelWorkspace); GridDataFactory.fillDefaults().span(2, 1).applyTo(sPanelWorkspace); Label sWorkspaceLanel = new Label(sPanelWorkspace, SWT.NONE); sWorkspaceLanel.setText(Messages.ReportMainPage_LocationLabel); Text workspaceLocation = new Text(sPanelWorkspace, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(workspaceLocation); final ControlDecoration controlDecoration = new ControlDecoration(workspaceLocation, SWT.LEFT | SWT.TOP); controlDecoration.setDescriptionText(""); //$NON-NLS-1$ FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); controlDecoration.setImage(fieldDecoration.getImage()); controlDecoration.hide();// w w w . jav a2s . c o m Button browseWorkspace = new Button(sPanelWorkspace, SWT.PUSH); browseWorkspace.setText(Messages.ReportMainPage_BrowseButton); browseWorkspace.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FolderSelectionDialog dialog = new FolderSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()) { @Override protected TreeViewer createTreeViewer(Composite parent) { TreeViewer viewer = super.createTreeViewer(parent); viewer.setFilters(new ViewerFilter[] { new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { if (element instanceof IResource) { if (((IResource) element).getType() == IResource.FILE) { return false; } } return true; } } }); return viewer; } }; dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); dialog.setAllowMultiple(false); dialog.setMessage(Messages.ReportMainPage_SelectLocationDialogText); dialog.setBlockOnOpen(true); if (dialog.open() == ResourceSelectionDialog.OK) { Object[] result = dialog.getResult(); if (result.length == 1) { ReportMainPage.this.workspaceLocation .setValue(((IResource) result[0]).getFullPath().toString()); } } } }); setButtonLayoutData(browseWorkspace); dbc.bindValue(SWTObservables.observeEnabled(browseWorkspace), this.generateToWorkspace); dbc.bindValue(SWTObservables.observeEnabled(workspaceLocation), this.generateToWorkspace); dbc.bindValue(SWTObservables.observeEnabled(sWorkspaceLanel), this.generateToWorkspace); dbc.bindValue(SWTObservables.observeSelection(generateToWorkspace), this.generateToWorkspace); dbc.bindValue(SWTObservables.observeText(workspaceLocation, SWT.Modify), this.workspaceLocation); this.workspaceLocation.addValueChangeListener(new IValueChangeListener() { public void handleValueChange(ValueChangeEvent event) { if (!isValidWorkspaceLocation()) { controlDecoration.show(); controlDecoration.showHoverText(Messages.ReportMainPage_IncorrectLocationMsg); validate(); return; } controlDecoration.hide(); validate(); } }); this.generateToWorkspace.addValueChangeListener(new IValueChangeListener() { public void handleValueChange(ValueChangeEvent event) { validate(); } }); }
From source file:org.eclipse.rcptt.ui.wizards.plain.DestinationsBox.java
License:Open Source License
public Composite create(Composite tab) { this.shell = tab.getShell(); Composite cp = new Composite(tab, SWT.NONE); GridLayoutFactory.swtDefaults().numColumns(2).applyTo(cp); GridDataFactory.fillDefaults().grab(true, false).applyTo(cp); Button clipboardRadio = new Button(cp, SWT.RADIO); clipboardRadio.setText(getClipboardTitle()); clipboardRadio.setSelection(true);//from w w w . ja v a2s.c om GridDataFactory.fillDefaults().span(2, 1).applyTo(clipboardRadio); Button filesystemRadio = new Button(cp, SWT.RADIO); filesystemRadio.setText(getFileTitle()); GridDataFactory.fillDefaults().span(2, 1).applyTo(filesystemRadio); Text filesystemPath = new Text(cp, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(filesystemPath); Button browseFilesystem = new Button(cp, SWT.PUSH); browseFilesystem.setText("Browse..."); browseFilesystem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleBrowseFilesystem(); } }); GridDataFactory.swtDefaults().applyTo(browseFilesystem); SWTFactory.setButtonDimensionHint(browseFilesystem); dbc.bindValue(SWTObservables.observeSelection(filesystemRadio), fsSelected, new SelectionToModel(Selection.Filesystem), null); dbc.bindValue(SWTObservables.observeSelection(clipboardRadio), fsSelected, new SelectionToModel(Selection.Clipboard), null); dbc.bindValue(SWTObservables.observeEnabled(browseFilesystem), fsSelected, null, new ModelToSelection(Selection.Filesystem)); dbc.bindValue(SWTObservables.observeEnabled(filesystemPath), fsSelected, null, new ModelToSelection(Selection.Filesystem)); dbc.bindValue(SWTObservables.observeText(filesystemPath, SWT.Modify), filesystemPathValue); return cp; }
From source file:org.kalypso.gml.ui.internal.feature.editProperties.EditFeaturePropertiesPage.java
License:Open Source License
private void createValueControl(final Composite parent) { final Label label = new Label(parent, SWT.NONE); /* Label binding */ final ISWTObservableValue targetLabel = SWTObservables.observeText(label); final IObservableValue modelLabel = BeansObservables.observeValue(m_data, EditFeaturePropertiesData.PROPERTY_VALUE_LABEL); m_binding.bindValue(targetLabel, modelLabel); /* Value binding */ final Text text = new Text(parent, SWT.BORDER); text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final ISWTObservableValue targetValue = SWTObservables.observeText(text, SWT.Modify); final IObservableValue modelValue = BeansObservables.observeValue(m_data, EditFeaturePropertiesData.PROPERTY_VALUE); final DataBinder valueBinder = new DataBinder(targetValue, modelValue); valueBinder.setTargetToModelConverter(new StringToFeaturePropertyConverter(m_data)); valueBinder.setModelToTargetConverter(new FeaturePropertyToStringConverter(m_data)); m_binding.bindValue(valueBinder);/*from ww w .j a v a 2s . c om*/ /* Enabled only, if the current property can be edited as a string */ final ISWTObservableValue targetEnabled = SWTObservables.observeEnabled(text); final IObservableValue modelEnabled = BeansObservables.observeValue(m_data, EditFeaturePropertiesData.PROPERTY_ENABLED); final DataBinder enabledBinder = new DataBinder(targetEnabled, modelEnabled); m_binding.bindValue(enabledBinder); }
From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.BankOptionsSection.java
License:Open Source License
private void createNumberOfSegmentsSpinner(final FormToolkit toolkit, final Composite parent, final ChannelEditData data, final DatabindingForm binding, final int spinnerWidth, final String label, final String tooltip, final String enabledProperty, final String numberProperty, final Color background) { final Label labelNumIntersSegment = toolkit.createLabel(parent, label); labelNumIntersSegment.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); labelNumIntersSegment.setToolTipText(tooltip); /* spinner for specifiying the number of intersection points for the current segment */ final Spinner spinnerNumProfileSegments = new Spinner(parent, SWT.BORDER); toolkit.adapt(spinnerNumProfileSegments); spinnerNumProfileSegments.setBackground(background); final GridData gridDataNumProfileSegmentsSpinner = new GridData(SWT.RIGHT, SWT.CENTER, true, false); gridDataNumProfileSegmentsSpinner.widthHint = spinnerWidth; spinnerNumProfileSegments.setLayoutData(gridDataNumProfileSegmentsSpinner); spinnerNumProfileSegments.setToolTipText(tooltip); spinnerNumProfileSegments.setValues(1, 2, 99, 0, 1, 10); /* disable AND hide spinner if not enabled */ final ISWTObservableValue targetNumSegmentsVisible = SWTObservables .observeVisible(spinnerNumProfileSegments); final IObservableValue modelProfileEditingVisible = BeansObservables.observeValue(data, enabledProperty); binding.bindValue(targetNumSegmentsVisible, modelProfileEditingVisible); final ISWTObservableValue targetNumSegmentsEnabled = SWTObservables .observeEnabled(spinnerNumProfileSegments); final IObservableValue modelProfileEditingEnabled = BeansObservables.observeValue(data, enabledProperty); binding.bindValue(targetNumSegmentsEnabled, modelProfileEditingEnabled); final ISWTObservableValue targetNumSegmentsValue = SWTObservables .observeSelection(spinnerNumProfileSegments); final IObservableValue modelNumProfileSegments = BeansObservables.observeValue(data, numberProperty); binding.bindValue(targetNumSegmentsValue, modelNumProfileSegments); }
From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.BankSelectionComposite.java
License:Open Source License
private void createBankSelectionLine(final FormToolkit toolkit, final Composite parent, final ChannelEditData data, final DatabindingForm binding, final SIDE side, final String selectedBankThemeProperty) { final ComboViewer themeChooser = new ComboViewer(parent, SWT.DROP_DOWN | SWT.READ_ONLY); toolkit.adapt(themeChooser.getControl(), true, false); themeChooser.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); themeChooser.setContentProvider(new ArrayContentProvider()); themeChooser.setLabelProvider(new LabelProvider()); final IObservableValue targetInput = ViewersObservables.observeInput(themeChooser); final IObservableValue modelInput = BeansObservables.observeValue(data, ChannelEditData.PROPERTY_BANK_THEME_INPUT); binding.bindValue(targetInput, modelInput); final IObservableValue targetSelection = ViewersObservables.observeSinglePostSelection(themeChooser); final IObservableValue modelSelection = BeansObservables.observeValue(data, selectedBankThemeProperty); binding.bindValue(targetSelection, modelSelection); final IObservableValue targetEnabled = SWTObservables.observeEnabled(themeChooser.getControl()); final IObservableValue modelEnabled = BeansObservables.observeValue(data, ChannelEditData.PROPERTY_BANK_THEME_SELECTION_ENABLED); binding.bindValue(targetEnabled, modelEnabled); /* Button for the bank selection */ final IWidget selectFromThemeWidget = new SelectionWidget(StringUtils.EMPTY, StringUtils.EMPTY, new BankSelectorFunction(data, side, modelSelection)); final SetWidgetAction selectFromThemeAction = new SetWidgetAction(data, selectFromThemeWidget); selectFromThemeAction.setImageDescriptor(KalypsoModel1D2DPlugin.getImageProvider() .getImageDescriptor(KalypsoModel1D2DUIImages.IMGKEY.SELECT)); final Button selectFromThemeButton = ChannelEditUtil.createWidgetSelectionButton(toolkit, parent, data, binding, selectFromThemeAction, ChannelEditData.PROPERTY_BANK_THEME_SELECTION_ENABLED); selectFromThemeButton.setToolTipText(Messages .getString("org.kalypso.kalypsomodel1d2d.ui.map.channeledit.CreateMainChannelComposite.19")); //$NON-NLS-1$ selectFromThemeButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); /* Button for the bank drawing */ final IWidget drawBankWidget = new DrawBanklineWidget(data, side); final SetWidgetAction drawBankAction = new SetWidgetAction(data, drawBankWidget); drawBankAction.setImageDescriptor(//from w ww . j a v a2 s.co m KalypsoModel1D2DPlugin.getImageProvider().getImageDescriptor(KalypsoModel1D2DUIImages.IMGKEY.EDIT)); final Button drawBankButton = ChannelEditUtil.createWidgetSelectionButton(toolkit, parent, data, binding, drawBankAction, null); drawBankButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); }
From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.ProfileSection.java
License:Open Source License
private void createProfileSelector(final FormToolkit toolkit, final Composite parent, final ChannelEditData data, final DatabindingForm binding) { /* prev button */ final Action prevProfileAction = new SwitchProfileAction(data, -1); ActionButton.createButton(toolkit, parent, prevProfileAction, SWT.ARROW | SWT.LEFT); /* selector */ final ComboViewer profileChooser = new ComboViewer(parent, SWT.READ_ONLY | SWT.DROP_DOWN); final Control profileChooserControl = profileChooser.getControl(); toolkit.adapt(profileChooserControl, true, true); profileChooser.setContentProvider(new ArrayContentProvider()); profileChooser.setLabelProvider(new LabelProvider()); final IObservableValue targetChooserInput = ViewersObservables.observeInput(profileChooser); final IObservableValue modelChooserInput = BeansObservables.observeValue(data, ChannelEditData.PROPERTY_PROFILE_DATA_CHOOSER_INPUT); binding.bindValue(targetChooserInput, modelChooserInput); final IObservableValue targetChooserEnabled = SWTObservables.observeEnabled(profileChooserControl); final IObservableValue modelProfileEditingEnabled = BeansObservables.observeValue(data, ChannelEditData.PROPERTY_PROFILE_EDITING_ENABLED); binding.bindValue(targetChooserEnabled, modelProfileEditingEnabled); final IObservableValue targetChooserSelection = ViewersObservables .observeSinglePostSelection(profileChooser); final IObservableValue modelChooserSelection = BeansObservables.observeValue(data, ChannelEditData.PROPERTY_ACTIVE_PROFILE); binding.bindValue(targetChooserSelection, modelChooserSelection); /* next button */ final Action nextProfileAction = new SwitchProfileAction(data, +1); ActionButton.createButton(toolkit, parent, nextProfileAction, SWT.ARROW | SWT.RIGHT); }
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 Control createThemeCombo(final FormToolkit toolkit, final Composite parent, final ChannelEditData data, final DatabindingForm binding) { final ComboViewer themeChooser = new ComboViewer(parent, SWT.DROP_DOWN | SWT.READ_ONLY); toolkit.adapt(themeChooser.getControl(), true, false); themeChooser.setContentProvider(new ArrayContentProvider()); themeChooser.setLabelProvider(new LabelProvider()); /* Binding */ final IObservableValue targetInput = ViewersObservables.observeInput(themeChooser); final IObservableValue modelInput = BeansObservables.observeValue(data, ChannelEditData.PROPERTY_PROFILE_THEME_INPUT); binding.bindValue(targetInput, modelInput); final IObservableValue targetSelection = ViewersObservables.observeSinglePostSelection(themeChooser); final IObservableValue modelSelection = BeansObservables.observeValue(data, ChannelEditData.PROPERTY_PROFILE_THEME_SELECTED); binding.bindValue(targetSelection, modelSelection); final IObservableValue targetEnablement = SWTObservables.observeEnabled(themeChooser.getCombo()); final IObservableValue modelEnablement = BeansObservables.observeValue(data, ChannelEditData.PROPERTY_PROFILE_THEME_SELECTION_ENABLED); binding.bindValue(targetEnablement, modelEnablement); return themeChooser.getControl(); }
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.admin.gaf.AddWaterLevelPage.java
License:Open Source License
private void createEventControls(final Composite panel) { final Group group = new Group(panel, SWT.NONE); group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); group.setText(Messages.getString("AddWaterLevelPage.3")); //$NON-NLS-1$ group.setLayout(new FillLayout()); final Event event = m_data.getWaterlevelEvent(); final IEditEventPageData data = new DefaultEditEventPageData(null, event, null, false); m_waterlevelComposite = new WaterlevelComposite(group, SWT.NONE, data, m_binding, null); final ISWTObservableValue targetVisible = SWTObservables.observeVisible(group); final IObservableValue modelVisible = BeansObservables.observeValue(m_data, ImportGafData.PROPERTY_HAS_WATERLEVELS); m_binding.bindValue(targetVisible, modelVisible); final ISWTObservableValue targetEnablement = SWTObservables.observeEnabled(m_waterlevelComposite); final IObservableValue modelEnablement = BeansObservables.observeValue(m_data, ImportGafData.PROPERTY_IMPORT_WATERLEVELS); m_binding.bindValue(targetEnablement, modelEnablement); }