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.gumtree.gumnix.sics.batch.ui.views.LineScriptView.java
License:Open Source License
@Override public void createPartControl(Composite parent, LineScriptCommand command) { GridLayoutFactory.fillDefaults().margins(0, 0).applyTo(parent); text = getToolkit().createText(parent, "", SWT.BORDER); text.setToolTipText("Enter script"); GridDataFactory.fillDefaults().grab(true, false).applyTo(text); /********************************************************************* * Data binding/*from w ww.ja v a2 s .c om*/ *********************************************************************/ Realm.runWithDefault(SWTObservables.getRealm(Display.getDefault()), new Runnable() { public void run() { bindingContext = new DataBindingContext(); bindingContext.bindValue(SWTObservables.observeText(text, SWT.Modify), BeansObservables.observeValue(getCommand(), "text"), new UpdateValueStrategy(), new UpdateValueStrategy()); } }); }
From source file:org.gumtree.gumnix.sics.batch.ui.views.ScriptView.java
License:Open Source License
@Override public void createPartControl(Composite parent, ScriptCommand command) { GridLayoutFactory.fillDefaults().margins(0, 0).applyTo(parent); text = getToolkit().createText(parent, "", SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); text.setToolTipText("Enter script"); GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, HEIGHT_TEXT).applyTo(text); /********************************************************************* * Data binding/* ww w.j a v a 2s. c o m*/ *********************************************************************/ Realm.runWithDefault(SWTObservables.getRealm(Display.getDefault()), new Runnable() { public void run() { bindingContext = new DataBindingContext(); bindingContext.bindValue(SWTObservables.observeText(text, SWT.Modify), BeansObservables.observeValue(getCommand(), "text"), new UpdateValueStrategy(), new UpdateValueStrategy()); } }); }
From source file:org.gumtree.gumnix.sics.batch.ui.views.SicsVariableView.java
License:Open Source License
@Override public void createPartControl(Composite parent, SicsVariableCommand command) { GridLayoutFactory.fillDefaults().margins(0, 0).spacing(10, SWT.DEFAULT).numColumns(2).applyTo(parent); /********************************************************************* * Sics variable selection//from w w w .j a v a 2 s . co m *********************************************************************/ final String[] sicsVariables = SicsBatchUIUtils.getSicsVariables(); comboViewer = new ComboViewer(parent, SWT.READ_ONLY); comboViewer.setContentProvider(new ArrayContentProvider()); comboViewer.setLabelProvider(new LabelProvider()); comboViewer.setInput(sicsVariables); comboViewer.setSorter(new ViewerSorter()); comboViewer.getCombo().setVisibleItemCount(20); GridDataFactory.swtDefaults().hint(WIDTH_COMBO, SWT.DEFAULT).indent(0, 2).applyTo(comboViewer.getCombo()); /********************************************************************* * Argument *********************************************************************/ text = getToolkit().createText(parent, "", SWT.BORDER); text.setToolTipText("Enter sics variable argument"); GridDataFactory.fillDefaults().indent(0, 2).grab(true, false).applyTo(text); // Check empty field final ControlDecoration controlDec = new ControlDecoration(text, SWT.LEFT | SWT.BOTTOM); final FieldDecoration fieldDec = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); text.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if ((text.getText() == null) || text.getText().length() == 0) { controlDec.setImage(fieldDec.getImage()); controlDec.setDescriptionText("SICS variable argument is empty"); controlDec.show(); } else { controlDec.hide(); } } }); /********************************************************************* * Data binding *********************************************************************/ Realm.runWithDefault(SWTObservables.getRealm(Display.getDefault()), new Runnable() { public void run() { bindingContext = new DataBindingContext(); bindingContext.bindValue(SWTObservables.observeSelection(comboViewer.getCombo()), BeansObservables.observeValue(getCommand(), "sicsVariable"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(text, SWT.Modify), BeansObservables.observeValue(getCommand(), "value"), new UpdateValueStrategy(), new UpdateValueStrategy()); // Set Default selection (only works after the binding is set) if (getCommand().getSicsVariable() == null) { if (comboViewer.getCombo().getItemCount() > 0) { comboViewer.setSelection(new StructuredSelection( comboViewer.getCombo().getItem(comboViewer.getCombo().getItemCount() - 1))); } } } }); }
From source file:org.gumtree.gumnix.sics.internal.ui.batch.ValidationDialog.java
License:Open Source License
private void createConnnectionConfigArea(Composite parent) { parent.setLayout(new GridLayout(2, false)); Label label = new Label(parent, SWT.NONE); label.setText("Host: "); hostText = new Text(parent, SWT.SINGLE | SWT.BORDER); hostText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // getBindingContext().bind(hostText, new Property(getConnectionContext(), "host"), null); label = new Label(parent, SWT.NONE); label.setText("Port: "); portText = new Text(parent, SWT.SINGLE | SWT.BORDER); portText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // getBindingContext().bind(portText, new Property(getConnectionContext(), "port"), null); label = new Label(parent, SWT.NONE); label.setText("Login: "); loginText = new Text(parent, SWT.SINGLE | SWT.BORDER); loginText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // getBindingContext().bind(loginText, new Property(getConnectionContext(), "login"), null); Label passwordLabel = new Label(parent, SWT.NONE); passwordLabel.setText("Password: "); passwordText = new Text(parent, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD); passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // getBindingContext().bind(passwordText, new Property(getConnectionContext(), "password"), null); // Eclipse 3.3 databinding Realm.runWithDefault(SWTObservables.getRealm(PlatformUI.getWorkbench().getDisplay()), new Runnable() { public void run() { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(SWTObservables.observeText(hostText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "host"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(portText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "port"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(loginText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "login"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(passwordText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "password"), new UpdateValueStrategy(), new UpdateValueStrategy()); }/*w w w .jav a2 s . c om*/ }); }
From source file:org.gumtree.gumnix.sics.internal.ui.login.InstrumentSpecificLoginDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { mainComposite = (Composite) super.createDialogArea(parent); Composite imageArea = new Composite(mainComposite, SWT.NONE); imageArea.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true)); createImage(imageArea);/*from w w w .j av a 2 s.com*/ Composite optionArea = new Composite(mainComposite, SWT.NONE); optionArea.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); createHiddenOptions(optionArea); Composite loginArea = new Composite(mainComposite, SWT.NONE); loginArea.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); createLoginBar(loginArea); // Bind GUI for Eclipse 3.3 Realm.runWithDefault(SWTObservables.getRealm(PlatformUI.getWorkbench().getDisplay()), new Runnable() { public void run() { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(SWTObservables.observeText(hostText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "host"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(portText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "port"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(passwordText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "password"), new UpdateValueStrategy(), new UpdateValueStrategy()); } }); passwordText.setFocus(); getShell().setText("Login"); setTitle("Welcome to the " + SicsCoreProperties.INSTRUMENT_NAME.getValue() + " instrument server!"); if (getInitialErrorMessage() != null) { setErrorMessage(getInitialErrorMessage()); } return mainComposite; }
From source file:org.gumtree.gumnix.sics.internal.ui.SicsTelnetConfigPart.java
License:Open Source License
public void createControlPart(Composite parent) { super.createControlPart(parent); Label label = new Label(parent, SWT.NONE); label.setText("Login: "); final Text loginText = new Text(parent, SWT.BORDER); loginText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // getBindingContext().bind(loginText, new Property(getConnectionContext(), "login"), null); label = new Label(parent, SWT.NONE); label.setText("Password: "); final Text passwordText = new Text(parent, SWT.BORDER | SWT.PASSWORD); passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // getBindingContext().bind(passwordText, new Property(getConnectionContext(), "password"), null); // Eclipse 3.3 databinding Realm.runWithDefault(SWTObservables.getRealm(PlatformUI.getWorkbench().getDisplay()), new Runnable() { public void run() { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(SWTObservables.observeText(loginText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "login"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(passwordText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "password"), new UpdateValueStrategy(), new UpdateValueStrategy()); }//from www . jav a 2 s .c o m }); }
From source file:org.gumtree.ui.terminal.support.telnet.TelnetConfigPart.java
License:Open Source License
public void createControlPart(Composite parent) { this.parent = parent; parent.setLayout(new GridLayout(2, false)); Label label = new Label(parent, SWT.NONE); label.setText("Host: "); final Text hostText = new Text(parent, SWT.BORDER); hostText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // getBindingContext().bind(hostText, new Property(getConnectionContext(), "host"), null); label = new Label(parent, SWT.NONE); label.setText("Port: "); final Text portText = new Text(parent, SWT.BORDER); portText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // getBindingContext().bind(portText, new Property(getConnectionContext(), "port"), null); // Databinding in Eclipse 3.3 Realm.runWithDefault(SWTObservables.getRealm(PlatformUI.getWorkbench().getDisplay()), new Runnable() { public void run() { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(SWTObservables.observeText(hostText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "host"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(portText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "port"), new UpdateValueStrategy(), new UpdateValueStrategy()); }//from w ww. j a v a2 s . c o m }); }
From source file:org.gumtree.workflow.ui.views.ParametersBasedTaskView.java
License:Open Source License
public void createPartControl(final Composite parent) { Realm.runWithDefault(SWTObservables.getRealm(Display.getDefault()), new Runnable() { public void run() { DataBindingContext bindingContext = new DataBindingContext(); GridLayoutFactory.swtDefaults().numColumns(3).applyTo(parent); for (Entry<String, Object> entry : parameters.entrySet()) { if (entry.getValue() instanceof Number || entry.getValue() instanceof String) { // Support number and text createLabel(parent, entry.getKey()); Text text = getToolkit().createText(parent, ""); if (units.containsKey(entry.getKey())) { GridDataFactory.fillDefaults().grab(true, false).applyTo(text); getToolkit().createLabel(parent, " " + units.get(entry.getKey())); } else { GridDataFactory.fillDefaults().grab(true, false).span(2, 0).applyTo(text); }/*from w ww . ja va 2s .c om*/ bindingContext.bindValue(SWTObservables.observeText(text, SWT.Modify), ParametersObservables.observeValue(parameters, entry.getKey()), new UpdateValueStrategy(), new UpdateValueStrategy()); } else if (entry.getValue().getClass().isEnum()) { // Support enum createLabel(parent, entry.getKey()); ComboViewer comboViewer = new ComboViewer(parent, SWT.READ_ONLY); comboViewer.setContentProvider(new ArrayContentProvider()); comboViewer.setLabelProvider(new LabelProvider()); comboViewer.setInput(entry.getValue().getClass().getEnumConstants()); GridDataFactory.fillDefaults().grab(true, false).span(2, 0) .applyTo(comboViewer.getControl()); bindingContext.bindValue(SWTObservables.observeSelection(comboViewer.getControl()), ParametersObservables.observeValue(parameters, entry.getKey()), new UpdateValueStrategy(), new UpdateValueStrategy()); } } } }); }
From source file:org.jboss.bpmn2.editor.ui.property.AbstractBpmn2PropertiesComposite.java
License:Open Source License
protected void bind(final EStructuralFeature a, final Text text) { Object eGet = be.eGet(a);/*from w w w . ja v a 2 s. c o m*/ if (eGet != null) { text.setText(eGet.toString()); } IObservableValue textObserver = SWTObservables.observeText(text, SWT.Modify); textObserver.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(final ValueChangeEvent e) { if (!text.getText().equals(be.eGet(a))) { TransactionalEditingDomain editingDomain = bpmn2Editor.getEditingDomain(); editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) { @Override protected void doExecute() { be.eSet(a, e.diff.getNewValue()); } }); } } }); }
From source file:org.jboss.bpmn2.editor.ui.property.AbstractBpmn2PropertiesComposite.java
License:Open Source License
protected void bindInt(final EStructuralFeature a, final Text text) { text.addVerifyListener(new VerifyListener() { /**//from www. jav a 2 s .co m * taken from * http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets * /Snippet19.java?view=co */ @Override public void verifyText(VerifyEvent e) { String string = e.text; char[] chars = new char[string.length()]; string.getChars(0, chars.length, chars, 0); for (int i = 0; i < chars.length; i++) { if (!('0' <= chars[i] && chars[i] <= '9')) { e.doit = false; return; } } } }); Object eGet = be.eGet(a); if (eGet != null) { text.setText(eGet.toString()); } IObservableValue textObserveTextObserveWidget = SWTObservables.observeText(text, SWT.Modify); textObserveTextObserveWidget.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(ValueChangeEvent event) { try { final int i = Integer.parseInt(text.getText()); if (!be.eGet(a).equals(i)) { setFeatureValue(i); } } catch (NumberFormatException e) { Activator.logError(e); } } @SuppressWarnings("restriction") private void setFeatureValue(final int i) { RecordingCommand command = new RecordingCommand(bpmn2Editor.getEditingDomain()) { @Override protected void doExecute() { be.eSet(a, i); } }; bpmn2Editor.getEditingDomain().getCommandStack().execute(command); } }); }