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.ctx.debug.ui.DebugContextEditor.java
License:Open Source License
public Control create(Composite parent, FormToolkit toolkit, IWorkbenchSite site, EditorHeader header) { Section section = new SectionWithComposite("Options", Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED).grabVertical(false).create(parent, toolkit); GridDataFactory.fillDefaults().grab(true, false).applyTo(section); Composite composite = (Composite) section.getClient(); GridLayoutFactory.fillDefaults().numColumns(1).applyTo(composite); Button noLaunches = toolkit.createButton(composite, "Terminate existing launches", SWT.CHECK); dbc.bindValue(SWTObservables.observeSelection(noLaunches), EMFObservables.observeValue(getContextElement(), DebugPackage.Literals.DEBUG_CONTEXT__NO_LAUNCHES)); toolkit.createLabel(composite, "Do not terminate launches of following configurations:"); Text exceptions = toolkit.createText(composite, "", SWT.BORDER); GridDataFactory.fillDefaults().hint(300, SWT.DEFAULT).applyTo(exceptions); dbc.bindValue(SWTObservables.observeText(exceptions, SWT.Modify), EMFObservables .observeValue(getContextElement(), DebugPackage.Literals.DEBUG_CONTEXT__LAUNCH_EXCEPTIONS)); dbc.bindValue(SWTObservables.observeEnabled(exceptions), SWTObservables.observeSelection(noLaunches)); Button noLaunchShortcuts = toolkit.createButton(composite, "Clear launch configurations", SWT.CHECK); dbc.bindValue(SWTObservables.observeSelection(noLaunchShortcuts), EMFObservables .observeValue(getContextElement(), DebugPackage.Literals.DEBUG_CONTEXT__NO_LAUNCH_SHORTCUTS)); GridDataFactory.fillDefaults().grab(true, false).applyTo(composite); toolkit.createLabel(composite, "Do not delete following configurations:"); exceptions = toolkit.createText(composite, "", SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(exceptions); dbc.bindValue(SWTObservables.observeText(exceptions, SWT.Modify), EMFObservables.observeValue( getContextElement(), DebugPackage.Literals.DEBUG_CONTEXT__LAUNCH_SHORTCUT_EXCEPTIONS)); dbc.bindValue(SWTObservables.observeEnabled(exceptions), SWTObservables.observeSelection(noLaunchShortcuts)); Button noBreakpoints = toolkit.createButton(composite, "Clear breakpoints", SWT.CHECK); GridDataFactory.fillDefaults().span(2, 1).applyTo(noBreakpoints); dbc.bindValue(SWTObservables.observeSelection(noBreakpoints), EMFObservables .observeValue(getContextElement(), DebugPackage.Literals.DEBUG_CONTEXT__NO_BREAKPOINTS)); Section section5 = new SectionWithToolbar(new EditableTree("Launch configurations", new ContentProvider()), Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED).create(parent, toolkit); GridDataFactory.fillDefaults().grab(true, true).applyTo(section5); return section; }
From source file:org.eclipse.rcptt.ctx.filesystem.ui.FilesystemContextEditor.java
License:Open Source License
private void createRootControls(final FormToolkit toolkit, final Composite client) { Composite panel = toolkit.createComposite(client); GridDataFactory.fillDefaults().span(2, 1).applyTo(panel); GridLayoutFactory.fillDefaults().numColumns(3).spacing(10, 10).applyTo(panel); Label rootLabel = toolkit.createLabel(panel, "Root path:"); rootLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); rootLabel.setBackground(null);/*from w w w. j a v a2 s .c om*/ Text rootText = toolkit.createText(panel, "", SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).hint(1, SWT.DEFAULT).applyTo(rootText); Binding rootBinding = dbc.bindValue(SWTObservables.observeText(rootText, SWT.Modify), EMFObservables .observeValue(getContextElement(), FilesystemPackage.Literals.FILESYSTEM_CONTEXT__PATH), rootStrategy, rootStrategy); ControlDecorationSupport.create(rootBinding, SWT.TOP | SWT.LEFT, panel, new ControlDecorationUpdater() { @Override protected void update(ControlDecoration decoration, IStatus status) { decoration.setMarginWidth(2); super.update(decoration, status); } }); Button browseButton = toolkit.createButton(panel, "Browse...", SWT.PUSH); browseButton.addSelectionListener(new OneSelectionListener() { @Override public void selected(SelectionEvent e) { AutLaunch launch = LaunchUtils.selectAutLaunch(client.getShell()); if (launch == null) return; DirectoryDialog dialog = new DirectoryDialog(client.getShell()); String result = dialog.open(); if (result != null) { getContextElement().setPath(makeRootPath(result, launch)); } } }); }
From source file:org.eclipse.rcptt.ctx.workbench.ui.views.WorkbenchContextEditor.java
License:Open Source License
private void createPerspective(Composite parent, FormToolkit toolkit) { Label label = toolkit.createLabel(parent, "Perspective id: "); label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); String id = getContextElement().getPerspectiveId(); if (id == null) { id = "";//w w w. j a va2 s .co m } perspective = toolkit.createText(parent, id, SWT.BORDER); perspective.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); dbc.bindValue(SWTObservables.observeText(perspective, SWT.Modify), EMFObservables.observeValue(getContextElement(), ScenarioPackage.eINSTANCE.getWorkbenchContext_PerspectiveId()), new PerspectiveChangeListener(), new PerspectiveChangeListener()); Button button = toolkit.createButton(parent, "Browse...", SWT.PUSH); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Shell shell = perspective.getShell(); ModernElementListSelectionDialog dialog = new ModernElementListSelectionDialog(shell, new PerspectiveLabelProvider()); PerspectivesList perspectives = getPerspectives(shell); if (perspectives == null) { return; } dialog.setElements(perspectives.getPerspectives().toArray()); dialog.setTitle("Select a perspective"); dialog.setMessage("Select a perspective which should be opened"); dialog.setMultipleSelection(false); dialog.setBlockOnOpen(true); int result = dialog.open(); if (result == Window.OK) { PerspectiveInfo p = (PerspectiveInfo) dialog.getFirstResult(); getContextElement().setPerspectiveId(p.getId()); } } }); }
From source file:org.eclipse.rcptt.internal.launching.ext.ui.wizards.NewAUTPage.java
License:Open Source License
private void createControlLocation(Composite parent) { // Label and Field Label locationLabel = new Label(parent, SWT.NONE); locationLabel.setText("Location:"); Text locationField = new Text(parent, SWT.BORDER); GridDataFactory.swtDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER) .hint(IDialogConstants.ENTRY_FIELD_WIDTH, SWT.DEFAULT).applyTo(locationField); // On change sets page complete = false ISWTObservableValue locationModifyObservable = SWTObservables.observeText(locationField, SWT.Modify); locationModifyObservable.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { setPageComplete(false);// w w w . ja va 2s . c om } }); dbc.bindValue(Observables.observeDelayedValue(FIELD_TIMEOUT, locationModifyObservable), locationValue); // ... and runs validation after delay locationValue.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { validate(true); } }); // Browse button Button fileLocationButton = new Button(parent, SWT.PUSH); fileLocationButton.setText("&Browse..."); fileLocationButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleSelectLocation(); } }); GridDataFactory.fillDefaults().grab(false, false).applyTo(fileLocationButton); SWTFactory.setButtonDimensionHint(fileLocationButton); }
From source file:org.eclipse.rcptt.internal.launching.ext.ui.wizards.NewAUTPage.java
License:Open Source License
private void createControlName(Composite parent) { // Label and Field Label nameLabel = new Label(parent, SWT.NONE); nameLabel.setText("Name:"); Text nameField = new Text(parent, SWT.BORDER); GridDataFactory.swtDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER) .hint(IDialogConstants.ENTRY_FIELD_WIDTH, SWT.DEFAULT).span(2, 1).applyTo(nameField); // On change sets page complete = false ISWTObservableValue nameModifyObservable = SWTObservables.observeText(nameField, SWT.Modify); nameModifyObservable.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { setPageComplete(false);/*from ww w . jav a 2s . c o m*/ } }); dbc.bindValue(Observables.observeDelayedValue(FIELD_TIMEOUT, nameModifyObservable), nameValue); // ... and runs validation after delay nameValue.addChangeListener(new IChangeListener() { public void handleChange(ChangeEvent event) { validatePlatform(); } }); }
From source file:org.eclipse.rcptt.ui.editors.EditorContent.java
License:Open Source License
public void update(IQ7NamedElement model, NamedElement element) { if (externalRefBinding != null) { externalRefBinding.dispose();// w w w . j ava2 s . c o m } if (externalRefControl != null) { externalRefBinding = header.getDataBindingContext() .bindValue(SWTObservables.observeText(externalRefControl, SWT.Modify), EMFProperties .value(ScenarioPackage.Literals.SCENARIO__EXTERNAL_REFERENCE).observe(getElement())); } descriptionComposite.update(element); if (contextTable != null) { contextTable.update(element); } if (verificationsTable != null) { verificationsTable.update(element); } }
From source file:org.eclipse.rcptt.ui.editors.EditorHeader.java
License:Open Source License
public void update(final IQ7NamedElement model, NamedElement element) { this.model = model; this.element = element; if (nameText != null) { if (nameBinding != null) { nameBinding.dispose();//from ww w.j av a 2s .c o m } UpdateValueStrategy strategy = new UpdateValueStrategy(); strategy.setBeforeSetValidator(new IValidator() { public IStatus validate(Object value) { String text = (String) value; if (StringUtils.isBlank(text)) return nameFail("Name must be non-blank string."); // that is toooo slooooow // IQ7NamedElement[] found = Q7SearchCore.findByName(text, // new OneProjectScope(model.getQ7Project()), // new NullProgressMonitor()); // for (IQ7NamedElement e : found) // if (e != model && e.getClass() == model.getClass()) // return nameFail("Name is already in use."); return nameWin(); } }); nameBinding = dbc.bindValue(SWTObservables.observeText(nameText, SWT.Modify), EMFObservables.observeValue(element, ScenarioPackage.eINSTANCE.getNamedElement_Name()), strategy, null); } if (tagsControl != null) { if (tagsBinging != null) { tagsBinging.dispose(); } tagsBinging = dbc.bindValue(SWTObservables.observeText(tagsControl, SWT.Modify), EMFProperties.value(ScenarioPackage.Literals.NAMED_ELEMENT__TAGS).observe(element)); } }
From source file:org.eclipse.rcptt.ui.navigator.Q7Explorer.java
License:Open Source License
@Override public void createPartControl(Composite parent) { final Composite composite = new Composite(parent, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 1).applyTo(composite); final SearchControl searchControl = new SearchControl(composite); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).indent(1, 2) .applyTo(searchControl);//from w ww .j a va 2 s. c o m searchControl.getFilterControl().addFocusListener(new TextFocusListener(searchControl.getFilterControl())); final Composite container = new Composite(composite, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(container); container.setLayout(new FillLayout()); super.createPartControl(container); // viewer is created now // set search result control for search control can pass focus after // enter or down arrow searchControl.setSearchResultControl(viewer.getControl()); final IObservableValue searchObservable = SWTObservables.observeDelayedValue(400, SWTObservables.observeText(searchControl.getFilterControl(), SWT.Modify)); job.addResultListener(new ResultListener() { public void resultAdded(IQ7NamedElement result) { final SearchFilter filter = findFilter(); if (filter == null) { return; } filter.add(result); refreshViewerJob.cancel(); refreshViewerJob.schedule(400); } }); searchObservable.addValueChangeListener(new IValueChangeListener() { public void handleValueChange(ValueChangeEvent event) { final SearchFilter filter = findFilter(); if (filter == null) { return; } job.cancel(); refreshViewerJob.cancel(); final String newValue = (String) event.diff.getNewValue(); if ("".equals(newValue.trim())) { //$NON-NLS-1$ filter.setEnabled(false); filter.clear(); viewer.refresh(false); } else { filter.setEnabled(true); filter.clear(); viewer.refresh(false); job.setQuery(newValue); job.setUser(false); job.setPriority(Job.LONG); job.schedule(); } } }); }
From source file:org.eclipse.rcptt.ui.report.ReportMainPage.java
License:Open Source License
public void createControl(Composite parent) { Composite panel = new Composite(parent, SWT.NONE); GridLayoutFactory.swtDefaults().numColumns(2).applyTo(panel); // Report name Label l = new Label(panel, SWT.NONE); l.setText(Messages.ReportMainPage_NameLabel); final Text reportName = new Text(panel, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(reportName); final ControlDecoration controlDecoration = new ControlDecoration(reportName, SWT.LEFT | SWT.TOP); controlDecoration.setDescriptionText(""); //$NON-NLS-1$ FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); controlDecoration.setImage(fieldDecoration.getImage()); controlDecoration.hide();//from w ww . j a v a 2s . c om dbc.bindValue(SWTObservables.observeText(reportName, SWT.Modify), this.reportName); this.reportName.addValueChangeListener(new IValueChangeListener() { public void handleValueChange(ValueChangeEvent event) { String name = (String) event.getObservableValue().getValue(); if (name.trim().length() == 0) { controlDecoration.show(); controlDecoration.showHoverText(Messages.ReportMainPage_EmptyReportNameMsg); validate(); return; } controlDecoration.hide(); validate(); } }); // Output format: l = new Label(panel, SWT.NONE); l.setText(Messages.ReportMainPage_FormatLabel); Combo reportFormat = new Combo(panel, SWT.BORDER | SWT.READ_ONLY); GridDataFactory.swtDefaults().grab(false, false).applyTo(reportFormat); dbc.bindList(SWTObservables.observeItems(reportFormat), this.reports, new UpdateListStrategy() { @Override public Object convert(Object value) { return convertReport(value); } }, new UpdateListStrategy() { @Override public Object convert(Object value) { return ((ReportRenderer) value).getName(); } }); dbc.bindValue(SWTObservables.observeSelection(reportFormat), this.reportFormat, new UpdateValueStrategy() { @Override public Object convert(Object value) { return convertReport(value); } }, new UpdateValueStrategy() { @Override public Object convert(Object value) { if (value != null) { return ((ReportRenderer) value).getName(); } return null; } }); ReportRenderer defaultRenderer = null; for (int i = 0; i < reports.size(); i++) { ReportRenderer rr = (ReportRenderer) reports.get(i); if (rr.getExtension().equals("html")) { //$NON-NLS-1$ defaultRenderer = rr; break; } } if (defaultRenderer != null) { this.reportFormat.setValue(defaultRenderer); } else { this.reportFormat.setValue(reports.get(0)); } // Output location l = new Label(panel, SWT.NONE); GridDataFactory.fillDefaults().span(2, 1).applyTo(l); Composite sPanel = new Composite(panel, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(sPanel); GridDataFactory.fillDefaults().span(2, 1).applyTo(sPanel); l = new Label(sPanel, SWT.NONE); l.setText(Messages.ReportMainPage_OutputLabel); l = new Label(sPanel, SWT.HORIZONTAL | SWT.SEPARATOR); GridDataFactory.fillDefaults().grab(true, false).applyTo(l); // Generate to workspace createGenerateWorkspace(panel); // Generate to file system createGenerateToFilesystem(panel); setControl(panel); IDialogSettings ds = getDialogSettings(); if (ds != null) { String loc = ds.get("report.dialog.workspace.location"); //$NON-NLS-1$ if (loc != null) { workspaceLocation.setValue(loc); } } if (initialWorkspaceLocation != null) { workspaceLocation.setValue(initialWorkspaceLocation); } validate(); }
From source file:org.eclipse.rcptt.ui.report.ReportMainPage.java
License:Open Source License
private void createGenerateToFilesystem(Composite panel) { Button generateToFilesystem = new Button(panel, SWT.RADIO); generateToFilesystem.setText(Messages.ReportMainPage_GenerateInFileSystemButton); GridDataFactory.swtDefaults().span(2, 1).applyTo(generateToFilesystem); Composite sPanelFileSystem = new Composite(panel, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(3).extendedMargins(20, 0, 0, 0).applyTo(sPanelFileSystem); GridDataFactory.fillDefaults().span(2, 1).applyTo(sPanelFileSystem); Label sFileSystemLabel = new Label(sPanelFileSystem, SWT.NONE); sFileSystemLabel.setText(Messages.ReportMainPage_LocationLabel); Text filesystemLocation = new Text(sPanelFileSystem, SWT.BORDER); final ControlDecoration controlDecoration = new ControlDecoration(filesystemLocation, SWT.LEFT | SWT.TOP); controlDecoration.setDescriptionText(""); //$NON-NLS-1$ FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); controlDecoration.setImage(fieldDecoration.getImage()); controlDecoration.hide();/*from w w w . j a v a 2 s .c o m*/ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(filesystemLocation); Button browseFilesystem = new Button(sPanelFileSystem, SWT.PUSH); browseFilesystem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DirectoryDialog dialog = new DirectoryDialog(getShell()); dialog.setMessage(Messages.ReportMainPage_SelectLocationDialogText); dialog.setFilterPath( ResourcesPlugin.getWorkspace().getRoot().getLocation().removeFirstSegments(1).toString()); dialog.setText(Messages.ReportMainPage_SelectLocationDialogText); String location = dialog.open(); if (location != null) { ReportMainPage.this.filesystemLocation.setValue(location); } } }); browseFilesystem.setText(Messages.ReportMainPage_BrowseButton); setButtonLayoutData(browseFilesystem); dbc.bindValue(SWTObservables.observeEnabled(browseFilesystem), this.generateToWorkspace, new UpdateValueStrategy(), new InverseBooleanConverter()); dbc.bindValue(SWTObservables.observeEnabled(filesystemLocation), this.generateToWorkspace, new UpdateValueStrategy(), new InverseBooleanConverter()); dbc.bindValue(SWTObservables.observeEnabled(sFileSystemLabel), this.generateToWorkspace, new UpdateValueStrategy(), new InverseBooleanConverter()); dbc.bindValue(SWTObservables.observeText(filesystemLocation, SWT.Modify), this.filesystemLocation); this.filesystemLocation.addValueChangeListener(new IValueChangeListener() { public void handleValueChange(ValueChangeEvent event) { if (!isValidFileLocation()) { controlDecoration.show(); controlDecoration.showHoverText(Messages.ReportMainPage_NoOutputLocationMsg); validate(); return; } controlDecoration.hide(); validate(); } }); }