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.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 ww .j av a 2 s . c om 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.resources.viewers.WorkspaceContextEditor.java
License:Open Source License
private void createOptionsControls(Composite parent, FormToolkit toolkit) { Button clearWorkspace = toolkit.createButton(parent, "Clear workspace", SWT.CHECK); GridDataFactory.fillDefaults().span(2, 1).applyTo(clearWorkspace); ignoreByClearPatternLabel = new Label(parent, SWT.NONE); ignoreByClearPatternLabel/* ww w. ja v a2 s . c o m*/ .setText("Do not clear following folders or files (use comma as separator, * = any string):"); ignoreByClearPatternLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); ignoreByClearPatternLabel.setBackground(null); GridDataFactory.fillDefaults().span(2, 1).hint(100, SWT.DEFAULT).applyTo(ignoreByClearPatternLabel); ignoreByClearPattern = toolkit.createText(parent, "", SWT.BORDER); ignoreByClearPattern.setBackground(null); GridDataFactory.fillDefaults().grab(true, false).span(2, 1).hint(100, SWT.DEFAULT) .applyTo(ignoreByClearPattern); dbc.bindValue(SWTObservables.observeSelection(clearWorkspace), EMFObservables.observeValue(getContextElement(), WorkspacePackage.Literals.WORKSPACE_CONTEXT__CLEAR_WORKSPACE), new ClearWorkspaceChangeListener(), new ClearWorkspaceChangeListener()); dbc.bindValue(SWTObservables.observeText(ignoreByClearPattern, SWT.Modify), EMFObservables.observeValue( getContextElement(), WorkspacePackage.Literals.WORKSPACE_CONTEXT__IGNORED_BY_CLEAR_PATTERN)); }
From source file:org.eclipse.rcptt.ui.verification.WidgetVerificationEditor.java
License:Open Source License
protected Control createWidgetControls(Composite parent, FormToolkit toolkit, IWorkbenchSite site, final EditorHeader header) { this.header = header; Composite box = toolkit.createComposite(parent); GridDataFactory.fillDefaults().grab(true, false).applyTo(box); GridLayoutFactory.fillDefaults().numColumns(3).applyTo(box); Label label = toolkit.createLabel(box, "Widget:"); label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); label.setBackground(null);/* w w w .ja v a 2 s . c o m*/ selectorText = new StyledText(box, SWT.SINGLE | SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).hint(1, SWT.DEFAULT).applyTo(selectorText); selectorText.setFont(JFaceResources.getTextFont()); new EclStyledTextHighlighter().install(selectorText); Binding selectorBinding = dbc.bindValue(SWTObservables.observeText(selectorText, SWT.Modify), EMFObservables.observeValue(getWidgetVerification(), ScenarioPackage.Literals.WIDGET_VERIFICATION__SELECTOR), selectorStrategy, selectorStrategy); ControlDecorationSupport.create(selectorBinding, SWT.TOP | SWT.LEFT, box, new ControlDecorationUpdater() { @Override protected void update(ControlDecoration decoration, IStatus status) { decoration.setMarginWidth(2); super.update(decoration, status); } }); final Button button = toolkit.createButton(box, "Pick...", SWT.NONE); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { AutLaunch launch = LaunchUtils.selectAutLaunch(); if (launch == null) return; VerificationType type = VerificationTypeManager.getInstance() .getTypeByVerification(getWidgetVerification()); String selector = WidgetPicker.activate(null, (BaseAutLaunch) launch, type); if (selector != null) { selectorText.setText(selector); header.getRecordButton().notifyListeners(SWT.Selection, new Event()); } } }); return box; }
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 a 2 s . com 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.eclipse.rcptt.ui.wizards.plain.Q7PortableFormatExportPage.java
License:Open Source License
public void createControl(Composite parent) { Composite cp = new Composite(parent, SWT.NONE); GridLayoutFactory.swtDefaults().applyTo(cp); Group preview = new Group(cp, SWT.NONE); preview.setText("Preview"); GridDataFactory.fillDefaults().hint(200, 200).grab(true, true).applyTo(preview); GridLayoutFactory.swtDefaults().applyTo(preview); StyledText text = new StyledText(preview, SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); text.setCaret(null);//from w ww .j ava 2 s . c o m FontData dt = new FontData("monospace", 10, 0); text.setFont(new Font(text.getDisplay(), dt)); dbc.bindValue(SWTObservables.observeText(text, SWT.Modify), previewValue); GridDataFactory.fillDefaults().grab(true, true).applyTo(text); destinations = new DestinationsBox(dbc) { @Override protected String getFileTitle() { return "Export to File"; } @Override protected String getClipboardTitle() { return "Export to Clipboard"; } @Override protected int getFileKind() { return SWT.SAVE; } }; destinations.create(cp); setControl(cp); updateExport(); destinations.addChangeListener(new Runnable() { public void run() { Selection kind = destinations.getKind(); switch (kind) { case Clipboard: setErrorMessage(null); setPageComplete(true); break; case Filesystem: String path = destinations.getFileSystemPath(); if (path == null || path.trim().length() == 0) { setErrorMessage("Please specify correct file name to export testcase"); setPageComplete(false); } /* * else if ((new File(path).exists())) { * setErrorMessage("Specified file doesn't exist"); * setPageComplete(false); } */else if ((new File(path).isDirectory())) { setErrorMessage("Please specify correct file name to export "); setPageComplete(false); } else if (!(new File(path).getParentFile().exists())) { setErrorMessage("Please specify correct folder to store file in"); setPageComplete(false); } else { setPageComplete(true); setErrorMessage(null); } break; default: break; } } }); }
From source file:org.eclipse.rcptt.ui.wizards.plain.Q7PortableFormatImportPage.java
License:Open Source License
public void createControl(Composite parent) { Composite cp = new Composite(parent, SWT.NONE); GridLayoutFactory.swtDefaults().applyTo(cp); Composite infoGroup = new Composite(cp, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).applyTo(infoGroup); GridLayoutFactory.fillDefaults().numColumns(3).applyTo(infoGroup); Label label = new Label(infoGroup, SWT.LEFT); label.setText(Messages.WizardExecutablePage_LocationLabel); Text locationText = new Text(infoGroup, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(locationText); dbc.bindValue(SWTObservables.observeText(locationText, SWT.Modify), locationValue); Button browse = new Button(infoGroup, SWT.PUSH); browse.setText(Messages.WizardExecutablePage_BrowseButton); browse.addSelectionListener(new SelectionAdapter() { @Override//from ww w. ja v a 2 s. c o m public void widgetSelected(SelectionEvent e) { browseLocation(); } }); setButtonLayoutData(browse); Label l = new Label(infoGroup, SWT.NONE); l.setText("Testcase name:"); Text testCaseName = new Text(infoGroup, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(testCaseName); dbc.bindValue(SWTObservables.observeText(testCaseName, SWT.Modify), testcaseNameValue); destinations = new DestinationsBox(dbc) { @Override protected String getFileTitle() { return "Import from File"; } @Override protected String getClipboardTitle() { return "Import from Clipboard"; } @Override protected int getFileKind() { return SWT.OPEN; } }; destinations.create(cp); Group preview = new Group(cp, SWT.NONE); preview.setText("Preview"); GridDataFactory.fillDefaults().hint(200, 200).grab(true, true).applyTo(preview); GridLayoutFactory.swtDefaults().applyTo(preview); StyledText text = new StyledText(preview, SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); text.setCaret(null); FontData dt = new FontData("monospace", 10, 0); text.setFont(new Font(text.getDisplay(), dt)); dbc.bindValue(SWTObservables.observeText(text, SWT.Modify), previewValue); GridDataFactory.fillDefaults().grab(true, true).applyTo(text); setControl(cp); updateImport(); locationValue.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { validate(); } }); testcaseNameValue.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { validate(); } }); destinations.addChangeListener(new Runnable() { public void run() { Selection kind = destinations.getKind(); switch (kind) { case Clipboard: setErrorMessage(null); setPageComplete(true); updateImport(); break; case Filesystem: String path = destinations.getFileSystemPath(); if (path == null || path.trim().length() == 0 || (new File(path).isDirectory()) || !(new File(path).exists())) { setErrorMessage("Please specify correct file name to import testcase"); setPageComplete(false); } else { setPageComplete(true); setErrorMessage(null); updateImport(); } break; default: break; } } }); }
From source file:org.eclipse.rcptt.verifications.text.ui.TextVerificationEditor.java
License:Open Source License
private void createControls(final FormToolkit toolkit, final Composite client) { Label introLabel = toolkit.createLabel(client, "Text should be:"); introLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); introLabel.setBackground(null);/*from www.j av a 2 s .c o m*/ // -- final StyledText text = new StyledText(client, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); text.setFont(JFaceResources.getTextFont()); GridDataFactory.fillDefaults().grab(true, true).hint(1, 1).applyTo(text); final Button ignoreStylingCheckbox = toolkit.createButton(client, "Ignore text styling and colors", SWT.CHECK); dbc.bindValue(SWTObservables.observeText(text, SWT.Modify), EMFObservables.observeValue(getVerification(), TextPackage.Literals.TEXT_VERIFICATION__TEXT)); IObservableList observableStyles = EMFObservables.observeList(getVerification(), TextPackage.Literals.TEXT_VERIFICATION__STYLES); observableStyles.addListChangeListener(new IListChangeListener() { @Override public void handleListChange(ListChangeEvent event) { updateStyling(text, ignoreStylingCheckbox); } }); // -- final Binding binding = dbc.bindValue(SWTObservables.observeSelection(ignoreStylingCheckbox), EMFObservables .observeValue(getVerification(), TextPackage.Literals.TEXT_VERIFICATION__IGNORE_STYLING)); binding.getModel().addChangeListener(new IChangeListener() { @Override public void handleChange(ChangeEvent event) { updateStyling(text, ignoreStylingCheckbox); } }); updateStyling(text, ignoreStylingCheckbox); }
From source file:org.eclipse.rcptt.verifications.time.ui.TimeVerificationEditor.java
License:Open Source License
private void createMinutesAndSecondsControls(final FormToolkit toolkit, final Composite client) { Label introLabel = toolkit.createLabel(client, "Test case execution time should be less than:"); introLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); introLabel.setBackground(null);//from w w w. j a va 2 s . c om GridDataFactory.fillDefaults().span(4, 1).applyTo(introLabel); Text minutesText = toolkit.createText(client, "00" /* for computeSize */, SWT.BORDER | SWT.RIGHT); GridDataFactory.fillDefaults().hint(minutesText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x, SWT.DEFAULT) .indent(32, 0).applyTo(minutesText); Binding minutesBinding = dbc.bindValue(SWTObservables.observeText(minutesText, SWT.Modify), EMFObservables.observeValue(getVerification(), TimePackage.Literals.TIME_VERIFICATION__MINUTES), minutesStrategy, new EMFUpdateValueStrategy()); ControlDecorationSupport.create(minutesBinding, SWT.TOP | SWT.LEFT, client, new ControlDecorationUpdater() { @Override protected void update(ControlDecoration decoration, IStatus status) { decoration.setMarginWidth(2); super.update(decoration, status); } }); Label minutesLabel = toolkit.createLabel(client, "minute(s) and"); minutesLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); minutesLabel.setBackground(null); Text secondsText = toolkit.createText(client, "00" /* for computeSize */, SWT.BORDER | SWT.RIGHT); GridDataFactory.fillDefaults().hint(secondsText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x, SWT.DEFAULT) .applyTo(secondsText); Binding secondsBinding = dbc.bindValue(SWTObservables.observeText(secondsText, SWT.Modify), EMFObservables.observeValue(getVerification(), TimePackage.Literals.TIME_VERIFICATION__SECONDS), secondsStrategy, new EMFUpdateValueStrategy()); ControlDecorationSupport.create(secondsBinding, SWT.TOP | SWT.LEFT, client, new ControlDecorationUpdater() { @Override protected void update(ControlDecoration decoration, IStatus status) { decoration.setMarginWidth(2); super.update(decoration, status); } }); Label secondsLabel = toolkit.createLabel(client, "second(s)"); secondsLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); secondsLabel.setBackground(null); }
From source file:org.eclipse.ui.tests.manual.TestBackgroundSaveEditor.java
License:Open Source License
private void createOutputGroup(Composite parent, final DataBindingContext dbc, final IObservableValue outputObservable) { Group outputGroup = new Group(parent, SWT.NONE); outputGroup.setText("Output"); Text outputText = new Text(outputGroup, SWT.BORDER | SWT.READ_ONLY | SWT.MULTI); GridDataFactory.fillDefaults().grab(true, true).applyTo(outputText); dbc.bindValue(SWTObservables.observeText(outputText, SWT.NONE), outputObservable, null, null); GridLayoutFactory.swtDefaults().generateLayout(outputGroup); }
From source file:org.eclipse.ui.tests.manual.TestBackgroundSaveEditor.java
License:Open Source License
private void createOptionsGroup(Composite parent, Realm realm, final DataBindingContext dbc) { Group optionsGroup = new Group(parent, SWT.NONE); optionsGroup.setText("Options"); Button dirtyButton = new Button(optionsGroup, SWT.CHECK); new Label(optionsGroup, SWT.NONE).setText("Editor is dirty"); IObservableValue dirtyObservable = BeansObservables.observeValue(realm, mySaveable, "dirty"); dbc.bindValue(SWTObservables.observeSelection(dirtyButton), dirtyObservable, null, null); // IObservableValue inputAndOutputDiffer = new ComputedValue(realm) { // protected Object calculate() { // return new Boolean(!Util.equals(inputObservable.getValue(), // outputObservable.getValue())); // }//from www . j av a 2 s.c o m // }; // dbc.bindValue(dirtyObservable, inputAndOutputDiffer, null); Button saveInBackgroundButton = new Button(optionsGroup, SWT.CHECK); new Label(optionsGroup, SWT.NONE).setText("Do part of the save in the background"); dbc.bindValue(SWTObservables.observeSelection(saveInBackgroundButton), BeansObservables.observeValue(realm, data, "saveInBackground"), null, null); Button foregroundExceptionButton = new Button(optionsGroup, SWT.CHECK); new Label(optionsGroup, SWT.NONE).setText("Throw exception while saving in the foreground"); dbc.bindValue(SWTObservables.observeSelection(foregroundExceptionButton), BeansObservables.observeValue(realm, data, "throwExceptionInForeground"), null, null); Button backgroundExceptionButton = new Button(optionsGroup, SWT.CHECK); new Label(optionsGroup, SWT.NONE).setText("Throw exception while saving in the background"); dbc.bindValue(SWTObservables.observeSelection(backgroundExceptionButton), BeansObservables.observeValue(realm, data, "throwExceptionInBackground"), null, null); new Label(optionsGroup, SWT.NONE).setText("Foreground save time:"); Text optionsForegroundTime = new Text(optionsGroup, SWT.BORDER); dbc.bindValue(SWTObservables.observeText(optionsForegroundTime, SWT.Modify), BeansObservables.observeValue(realm, data, "foregroundSaveTime"), null, null); new Label(optionsGroup, SWT.NONE).setText("Background save time:"); Text optionsBackgroundTime = new Text(optionsGroup, SWT.BORDER); dbc.bindValue(SWTObservables.observeText(optionsBackgroundTime, SWT.Modify), BeansObservables.observeValue(realm, data, "backgroundSaveTime"), null, null); GridLayoutFactory.swtDefaults().numColumns(2).generateLayout(optionsGroup); }