List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeText
@Deprecated public static ISWTObservableValue observeText(Control control, int event)
control
. From source file:org.eclipse.emf.editor.ui.binding.EmfSwtBindingFactory.java
License:Open Source License
private Control bindValue(EStructuralFeature feature) { Control retVal = null;//from w w w. j a v a 2 s .com IObservableValue source = EMFEditObservables.observeValue(domain, owner, feature); IObservableValue target = null; if (feature.getEType().equals(EcorePackage.Literals.EBOOLEAN) || feature.getEType().equals(EcorePackage.Literals.EBOOLEAN_OBJECT) || (feature.getEType() instanceof EDataType && (feature.getEType().getInstanceClass() == Boolean.class || feature.getEType().getInstanceClass() == Boolean.TYPE))) { Button b = toolkit.createButton(parent, "", SWT.CHECK); target = SWTObservables.observeSelection(b); retVal = b; } else { List<?> proposals = proposalcreator.proposals(feature); if (feature instanceof EReference || feature.getEType() instanceof EEnumImpl) { ComboViewer combo = new ComboViewer(parent, SWT.READ_ONLY); toolkit.adapt(combo.getCombo()); combo.setContentProvider(new ArrayContentProvider()); combo.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); combo.setInput(proposals); target = ViewersObservables.observeSingleSelection(combo); retVal = combo.getCombo(); } else { Text t = toolkit.createText(parent, ""); t.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER); if (proposals != null && !proposals.isEmpty()) { // TODO prevent adding null to a list, for example a Collection // Type while (proposals.remove(null)) { // clear null entries } ControlDecoration field = new ControlDecoration(t, SWT.BORDER); FieldDecoration requiredFieldIndicator = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); field.setImage(requiredFieldIndicator.getImage()); field.setDescriptionText(requiredFieldIndicator.getDescription()); KeyStroke keyStroke = null; String string = "Ctrl+Space"; try { keyStroke = KeyStroke.getInstance(string); } catch (ParseException e) { EEPlugin.getDefault().getLog().log( new Status(IStatus.ERROR, EEPlugin.PLUGIN_ID, "Error while parse: " + string, e)); } new ContentProposalAdapter(t, new TextContentAdapter(), new SimpleContentProposalProvider(proposals.toArray(new String[] {})), keyStroke, null); } target = SWTObservables.observeText(t, SWT.Modify); retVal = t; } } edbc.bindValue(target, source, null, null); return retVal; }
From source file:org.eclipse.etrice.ui.common.dialogs.AbstractPropertyDialog.java
License:Open Source License
protected Text createText(Composite parent, String label, EObject obj, EStructuralFeature feat, IValidator validator, IConverter s2m, IConverter m2s, boolean multiline) { Label l = toolkit.createLabel(parent, label, SWT.NONE); l.setLayoutData(new GridData(SWT.NONE)); int style = SWT.BORDER; if (multiline) style |= SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL; Text text = toolkit.createText(parent, "", style); GridData gd = new GridData(multiline ? GridData.FILL_BOTH : GridData.FILL_HORIZONTAL); text.setLayoutData(gd);/* www . j a va 2 s . c o m*/ UpdateValueStrategy t2m = null; UpdateValueStrategy m2t = null; if (validator != null || s2m != null || m2s != null) { t2m = new UpdateValueStrategy(); if (s2m != null) t2m.setConverter(s2m); if (validator != null) { t2m.setAfterConvertValidator(validator); t2m.setBeforeSetValidator(validator); } m2t = new UpdateValueStrategy(); if (m2s != null) m2t.setConverter(m2s); if (validator != null) { m2t.setAfterConvertValidator(validator); m2t.setBeforeSetValidator(validator); } } bindingContext.bindValue(SWTObservables.observeText(text, SWT.Modify), PojoObservables.observeValue(obj, feat.getName()), t2m, m2t); return text; }
From source file:org.eclipse.gmf.runtime.diagram.ui.printing.render.dialogs.JobAttributesBlock.java
License:Open Source License
public Control createContents(Composite parent) { final Realm realm = bindings.getValidationRealm(); Composite result = group(parent, DiagramUIPrintingMessages.JPSOptionsDialog_JobAttributes); layout(result, 2);//from www . ja v a 2s . c om layoutHorizontalIndent(layoutAlignRight(label(result, DiagramUIPrintingMessages.JPSOptionsDialog_JobName))); Text jobName = text(result, 80); jobNameBinding = bindings.bindValue(SWTObservables.observeText(jobName, SWT.Modify), BeansObservables.observeValue(realm, options, PrintOptions.PROPERTY_JOB_NAME), null, null); return result; }
From source file:org.eclipse.gmf.runtime.diagram.ui.printing.render.dialogs.RangeBlock.java
License:Open Source License
public Control createContents(Composite parent) { final Realm realm = bindings.getValidationRealm(); Composite result = group(parent, DiagramUIPrintingMessages.JPSPrintDialog_PrintRange); layout(result, 4);//from ww w .ja v a 2 s.c om Button allRadio = radio(result, DiagramUIPrintingMessages.JPSPrintDialog_All); layoutSpanHorizontal(allRadio, 4); final IObservableValue allValue = BeansObservables.observeValue(realm, options, PrintOptions.PROPERTY_ALL_PAGES); bindings.bindValue(SWTObservables.observeSelection(allRadio), allValue, null, null); Button rangeRadio = radio(result, DiagramUIPrintingMessages.JPSPrintDialog_Pages); layoutSpanHorizontal(rangeRadio, 4); IObservableValue rangeValue = new ComputedValue(realm) { protected Object calculate() { return Boolean.valueOf(!((Boolean) allValue.getValue()).booleanValue()); } }; bindings.bindValue(SWTObservables.observeSelection(rangeRadio), rangeValue, null, null); layoutHorizontalIndent(label(result, DiagramUIPrintingMessages.JPSPrintDialog_From)); Text textFrom = text(result, 20); layoutHorizontalIndent(label(result, DiagramUIPrintingMessages.JPSPrintDialog_To)); Text textTo = text(result, 20); bindings.bindValue(SWTObservables.observeText(textFrom, SWT.Modify), BeansObservables.observeValue(realm, options, PrintOptions.PROPERTY_RANGE_FROM), null, null); bindings.bindValue(SWTObservables.observeEnabled(textFrom), rangeValue, null, null); bindings.bindValue(SWTObservables.observeText(textTo, SWT.Modify), BeansObservables.observeValue(realm, options, PrintOptions.PROPERTY_RANGE_TO), null, null); bindings.bindValue(SWTObservables.observeEnabled(textTo), rangeValue, null, null); return result; }
From source file:org.eclipse.gmf.runtime.diagram.ui.printing.render.dialogs.ScalingBlock.java
License:Open Source License
public Control createContents(Composite parent) { final Realm realm = bindings.getValidationRealm(); Composite result = group(parent, DiagramUIPrintingMessages.JPSPrintDialog_Scaling); layout(result, 5);/* ww w .jav a 2s . c o m*/ Button adjustRadio = radio(result, DiagramUIPrintingMessages.JPSPrintDialog_Adjust); layoutSpanHorizontal(adjustRadio, 2); Text textScale = text(result, 20); layoutSpanHorizontal(blank(result), 2); final IObservableValue scalingValue = BeansObservables.observeValue(realm, options, PrintOptions.PROPERTY_PERCENT_SCALING); bindings.bindValue(SWTObservables.observeSelection(adjustRadio), scalingValue, null, null); bindings.bindValue(SWTObservables.observeText(textScale, SWT.Modify), BeansObservables.observeValue(realm, options, PrintOptions.PROPERTY_SCALE_FACTOR), null, null); bindings.bindValue(SWTObservables.observeEnabled(textScale), scalingValue, null, null); Button fitToRadio = radio(result, DiagramUIPrintingMessages.JPSPrintDialog_FitTo); IObservableValue fitToValue = new ComputedValue(realm) { protected Object calculate() { return Boolean.valueOf(!((Boolean) scalingValue.getValue()).booleanValue()); } }; bindings.bindValue(SWTObservables.observeSelection(fitToRadio), fitToValue, null, null); layoutHorizontalIndent(layoutAlignRight(label(result, DiagramUIPrintingMessages.JPSPrintDialog_PagesWide))); Text textWide = text(result, 20); layoutHorizontalIndent(layoutAlignRight(label(result, DiagramUIPrintingMessages.JPSPrintDialog_PagesTall))); Text textTall = text(result, 20); bindings.bindValue(SWTObservables.observeText(textWide, SWT.Modify), BeansObservables.observeValue(realm, options, PrintOptions.PROPERTY_FIT_TO_WIDTH), null, null); bindings.bindValue(SWTObservables.observeEnabled(textWide), fitToValue, null, null); bindings.bindValue(SWTObservables.observeText(textTall, SWT.Modify), BeansObservables.observeValue(realm, options, PrintOptions.PROPERTY_FIT_TO_HEIGHT), null, null); bindings.bindValue(SWTObservables.observeEnabled(textTall), fitToValue, null, null); return result; }
From source file:org.eclipse.jubula.client.autagent.preferences.ui.EmbeddedAutAgentPreferencePage.java
License:Open Source License
@Override protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(composite); m_dbc = new DataBindingContext(); UIComponentHelper.createLabel(composite, I18n.getString("DatabaseConnection.HostBased.Port"), SWT.NONE); //$NON-NLS-1$ Text portText = new Text(composite, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(portText); m_portNumber = new WritableValue( getPreferenceStore().getInt(PreferenceInitializer.PREF_EMBEDDED_AGENT_PORT), int.class); UpdateValueStrategy portTargetToModelUpdateStrategy = new UpdateValueStrategy(); portTargetToModelUpdateStrategy.setConverter(new SimpleStringToIntegerConverter()).setAfterGetValidator( new StringToPortValidator(I18n.getString("DatabaseConnection.HostBased.Port"))); //$NON-NLS-1$ m_dbc.bindValue(SWTObservables.observeText(portText, SWT.Modify), m_portNumber, portTargetToModelUpdateStrategy, new UpdateValueStrategy().setConverter(new SimpleIntegerToStringConverter())); PreferencePageSupport.create(this, m_dbc); // context sensitive help PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ContextHelpIds.PREFPAGE_EMBEDDED_AGENT); return composite; }
From source file:org.eclipse.jubula.client.ui.dialogs.EnterCommentAndDetailsDialog.java
License:Open Source License
@Override protected void createDialogAdditionalArea(Composite area) { GridData gridData;// w w w . j a v a2 s .c o m Text commentDetailField = createCommentDetailText(area); gridData = new GridData(SWT.FILL, SWT.FILL, true, true); LayoutUtil.addToolTipAndMaxWidth(gridData, commentDetailField); commentDetailField.setLayoutData(gridData); IObservableValue commentDetailFieldText = SWTObservables.observeText(commentDetailField, SWT.Modify); m_commentDetail = WritableValue.withValueType(String.class); getValidationContext().bindValue(commentDetailFieldText, m_commentDetail, new UpdateValueStrategy().setAfterGetValidator(getValidator()), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE)); if (!StringUtils.isEmpty(m_initialDetail)) { m_commentDetail.setValue(m_initialDetail); } LayoutUtil.setMaxChar(commentDetailField, IPersistentObject.MAX_STRING_LENGTH); }
From source file:org.eclipse.jubula.client.ui.dialogs.EnterCommentDialog.java
License:Open Source License
/** * @param area the parent area/*www . j a v a 2 s .c om*/ */ private void createCommentTitleField(Composite area) { GridData gridData; Text commentTitleField = createCommentTitleText(area); gridData = new GridData(SWT.FILL, SWT.FILL, true, false); LayoutUtil.addToolTipAndMaxWidth(gridData, commentTitleField); commentTitleField.setLayoutData(gridData); IObservableValue commentTitleFieldText = SWTObservables.observeText(commentTitleField, SWT.Modify); m_commentTitle = WritableValue.withValueType(String.class); getValidationContext().bindValue(commentTitleFieldText, m_commentTitle, new UpdateValueStrategy().setAfterGetValidator(getValidator()), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE)); if (!StringUtils.isEmpty(m_initialTitle)) { m_commentTitle.setValue(m_initialTitle); } LayoutUtil.setMaxChar(commentTitleField, IPersistentObject.MAX_STRING_LENGTH); commentTitleField.selectAll(); }
From source file:org.eclipse.jubula.client.ui.rcp.dialogs.EnterLogicalCompNameDialog.java
License:Open Source License
/** * {@inheritDoc}/* ww w .j a va 2 s . c om*/ */ protected Control createDialogArea(Composite parent) { GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); Composite area = new Composite(parent, SWT.BORDER); area.setLayoutData(gridData); area.setLayout(new GridLayout(2, false)); Text componentNameField = createComponentName(area); gridData = new GridData(SWT.FILL, SWT.FILL, true, false); LayoutUtil.addToolTipAndMaxWidth(gridData, componentNameField); componentNameField.setLayoutData(gridData); LayoutUtil.setMaxChar(componentNameField); IObservableValue nameFieldText = SWTObservables.observeText(componentNameField, SWT.Modify); m_name = WritableValue.withValueType(String.class); getValidationContext().bindValue(nameFieldText, m_name, new UpdateValueStrategy().setAfterGetValidator(new ComponentNameValidator(m_initialName)), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE)); if (m_initialName != null) { setName(m_initialName); } componentNameField.selectAll(); return area; }
From source file:org.eclipse.jubula.client.ui.rcp.dialogs.EnterTestDataManagerDialog.java
License:Open Source License
/** * {@inheritDoc}//from www.j av a 2s . c o m */ protected Control createDialogArea(Composite parent) { GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); Composite area = new Composite(parent, SWT.BORDER); area.setLayoutData(gridData); area.setLayout(new GridLayout(2, false)); Text testDataCubeNameField = createTestDataManagerName(area); gridData = new GridData(SWT.FILL, SWT.FILL, true, false); LayoutUtil.addToolTipAndMaxWidth(gridData, testDataCubeNameField); testDataCubeNameField.setLayoutData(gridData); LayoutUtil.setMaxChar(testDataCubeNameField); IObservableValue nameFieldText = SWTObservables.observeText(testDataCubeNameField, SWT.Modify); m_name = WritableValue.withValueType(String.class); getValidationContext().bindValue(nameFieldText, m_name, new UpdateValueStrategy() .setAfterGetValidator(new TestDataManagerNameValidator(m_initialName, m_alreadyUsedNames)), new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE)); if (m_initialName != null) { setName(m_initialName); } testDataCubeNameField.selectAll(); return area; }