List of usage examples for org.eclipse.jface.databinding.dialog TitleAreaDialogSupport create
public static TitleAreaDialogSupport create(TitleAreaDialog dialog, DataBindingContext dbc)
From source file:com.google.cloud.tools.eclipse.appengine.deploy.ui.DeployPreferencesDialog.java
License:Apache License
@Override protected Control createDialogArea(final Composite parent) { Composite dialogArea = (Composite) super.createDialogArea(parent); Composite container = new Composite(dialogArea, SWT.NONE); content = new StandardDeployPreferencesPanel(container, project, loginService, getLayoutChangedHandler(), true /* requireValues */); GridDataFactory.fillDefaults().grab(true, false).applyTo(content); // we pull in Dialog's content margins which are zeroed out by TitleAreaDialog GridDataFactory.fillDefaults().grab(true, true).applyTo(container); GridLayoutFactory.fillDefaults()//from ww w . j a v a2 s. c om .margins(convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN), convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN)) .spacing(convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING), convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING)) .generateLayout(container); TitleAreaDialogSupport.create(this, content.getDataBindingContext()) .setValidationMessageProvider(new ValidationMessageProvider() { @Override public int getMessageType(ValidationStatusProvider statusProvider) { int type = super.getMessageType(statusProvider); setValid(type != IMessageProvider.ERROR); return type; } }); return dialogArea; }
From source file:com.htmlhifive.tools.jslint.dialog.CreateEngineDialog.java
License:Apache License
/** * ??.//w ww . j av a 2 s .c om */ private void initialDataBinding() { DataBindingContext context = new DataBindingContext(); // Validator MultiValidator validator = new MultiValidator() { @Override protected IStatus validate() { StringBuilder sb = new StringBuilder(); if ((Boolean) wvJshint.getValue() && (Boolean) wvJslint.getValue()) { sb.append(Messages.EM0014.getText()); } String outputPath = (String) wvOutputDir.getValue(); if (StringUtils.isEmpty(outputPath)) { sb.append(Messages.EM0009.format(Messages.DL0020.getText())); } else { IPath path = new Path(outputPath); if (!ResourcesPlugin.getWorkspace().getRoot().exists(path)) { sb.append(Messages.EM0000.format(Messages.DL0020.getText())); } } if (StringUtils.isEmpty(sb.toString())) { getButton(IDialogConstants.OK_ID).setEnabled(true); return ValidationStatus.info(Messages.DL0027.getText()); } if (getButton(IDialogConstants.OK_ID) != null) { getButton(IDialogConstants.OK_ID).setEnabled(false); } return ValidationStatus.error(sb.toString()); } }; // ?? IObservableValue obsOutputDirText = SWTObservables.observeText(textOutputDir, SWT.Modify); context.bindValue(obsOutputDirText, wvOutputDir, null, null); // JSLint??? IObservableValue obsSelectJslint = WidgetProperties.selection().observe(btnRadioJSLint); context.bindValue(obsSelectJslint, wvJslint, null, null); // JSHint??? IObservableValue obsSelectJsHint = WidgetProperties.selection().observe(btnRadioJSHint); context.bindValue(obsSelectJsHint, wvJshint); // ?? context.addValidationStatusProvider(validator); TitleAreaDialogSupport.create(this, context); }
From source file:com.htmlhifive.tools.jslint.dialog.CreateOptionFileDialog.java
License:Apache License
/** * ???.//w w w .j ava 2 s . com */ private void initializeDataBindings() { DataBindingContext context = new DataBindingContext(); // validator MultiValidator validator = new MultiValidator() { @Override protected IStatus validate() { StringBuilder sb = new StringBuilder(); String optionFileName = (String) wvOptionFileName.getValue(); if (StringUtils.isEmpty(optionFileName)) { sb.append(Messages.EM0009.format(Messages.DL0021.getText())); } else if (!FilenameUtils.isExtension(optionFileName, "xml")) { optionFileName += ".xml"; } String outputDir = (String) wvOutpuDir.getValue(); if (StringUtils.isEmpty(outputDir)) { sb.append(Messages.EM0009.format(Messages.DL0020.getText())); } else { IPath path = new Path(outputDir); if (!ResourcesPlugin.getWorkspace().getRoot().exists(path)) { sb.append(Messages.EM0000.format(Messages.DL0020.getText())); } } if (StringUtils.isNotEmpty(optionFileName) && StringUtils.isNotEmpty(outputDir)) { IPath path = new Path(outputDir + "/" + optionFileName); if (ResourcesPlugin.getWorkspace().getRoot().exists(path)) { sb.append(Messages.EM0013.getText()); } } if (StringUtils.isEmpty(sb.toString())) { getButton(IDialogConstants.OK_ID).setEnabled(true); return ValidationStatus.info(Messages.DL0019.getText()); } if (getButton(IDialogConstants.OK_ID) != null) { getButton(IDialogConstants.OK_ID).setEnabled(false); } return ValidationStatus.error(sb.toString()); } }; // IObservableValue outputDir = SWTObservables.observeText(textOutputDir, SWT.Modify); context.bindValue(outputDir, wvOutpuDir, null, null); // ?? IObservableValue optionFileName = SWTObservables.observeText(textOptionFileName, SWT.Modify); context.bindValue(optionFileName, wvOptionFileName, null, null); context.addValidationStatusProvider(validator); TitleAreaDialogSupport.create(this, context); }
From source file:org.eclipse.egit.gitflow.ui.internal.dialogs.InitDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite area = (Composite) super.createDialogArea(parent); Composite container = new Composite(area, SWT.NONE); container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); GridLayoutFactory.swtDefaults().numColumns(4).applyTo(container); createInputs(container);// w w w. ja va 2 s . c om DataBindingContext bindingContext = initDataBinding(); TitleAreaDialogSupport.create(this, bindingContext) .setValidationMessageProvider(new ValidationMessageProvider() { @Override public String getMessage(ValidationStatusProvider statusProvider) { if (statusProvider == null) { return InitDialog_chooseBranchNamesAndPrefixes; } return super.getMessage(statusProvider); } @Override public int getMessageType(ValidationStatusProvider statusProvider) { int type = super.getMessageType(statusProvider); Button okButton = getButton(OK_ID); if (okButton != null) { okButton.setEnabled(type != ERROR); } return type; } }); return area; }
From source file:org.eclipse.emf.example.databinding.project.ui.rcp.dialogs.CommitterShipDialog.java
License:Open Source License
private Control createForm(final Composite comp) { Composite container = new Composite(comp, SWT.NONE); container.setLayout(new GridLayout(3, false)); {/*from ww w.j a v a 2 s .c o m*/ Label l = new Label(container, SWT.NONE); l.setText("Committer"); IEMFEditValueProperty mprop = EMFEditProperties.value(resource.getEditingDomain(), ProjectPackage.Literals.COMMITTER_SHIP__PERSON); ViewForm form = new ViewForm(container, SWT.BORDER | SWT.FLAT); form.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); CLabel label = new CLabel(form, SWT.NONE); form.setContent(label); ctx.bindValue(WidgetProperties.text().observe(label), mprop.observe(committership), null, new EMFUpdateValueStrategy().setConverter(new PersonToStringConverter())); Button b = new Button(container, SWT.PUSH); b.setText("..."); b.setEnabled(isnew); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FilteredItemsSelectionDialog dialog = new PersonFilterDialog(comp.getShell(), resource); dialog.open(); Person p = (Person) dialog.getFirstResult(); if (p != null) { Command cmd = SetCommand.create(resource.getEditingDomain(), committership, ProjectPackage.Literals.COMMITTER_SHIP__PERSON, p); if (cmd.canExecute()) { resource.executeCmd(cmd); } } } }); } IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify); { Label l = new Label(container, SWT.NONE); l.setText("Startdate"); IEMFEditValueProperty mprop = EMFEditProperties.value(resource.getEditingDomain(), ProjectPackage.Literals.COMMITTER_SHIP__START); Text t = new Text(container, SWT.BORDER); t.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1)); ctx.bindValue(textProp.observe(t), mprop.observe(committership), UpdateStrategyFactory.stringToDateNotNull("Can't convert start date value into a valid date", "The start date can not be null"), UpdateStrategyFactory.dateToString()); } { Label l = new Label(container, SWT.NONE); l.setText("Enddate"); IEMFEditValueProperty mprop = EMFEditProperties.value(resource.getEditingDomain(), ProjectPackage.Literals.COMMITTER_SHIP__END); Text t = new Text(container, SWT.BORDER); t.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1)); ctx.bindValue(textProp.observe(t), mprop.observe(committership), UpdateStrategyFactory.stringToDate("Can't convert end date value into a valid date"), UpdateStrategyFactory.dateToString()); } TitleAreaDialogSupport.create(this, ctx); return container; }
From source file:org.eclipse.emf.example.databinding.project.ui.rcp.dialogs.PersonDialog.java
License:Open Source License
private Composite createForm(Composite parent) { final Composite container = new Composite(parent, SWT.NONE); container.setLayout(new GridLayout(2, false)); final Composite imgContainer = new Composite(container, SWT.NONE); {//w w w . j a va2 s . c om imgContainer.setLayout(new GridLayout()); GridData gd = new GridData(200, SWT.DEFAULT); gd.verticalAlignment = SWT.TOP; imgContainer.setLayoutData(gd); final Label l = new Label(imgContainer, SWT.BORDER); gd = new GridData(SWT.CENTER, SWT.FILL, false, false); l.setLayoutData(gd); IEMFEditValueProperty mprop = EMFEditProperties.value(editingDomain, ProjectPackage.Literals.PERSON__IMAGE); ctx.bindValue(WidgetProperties.image().observe(l), mprop.observe(person), null, new EMFUpdateValueStrategy().setConverter(new Base64ToImageConverter(container.getDisplay()))); l.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { if (l.getImage() != null) { l.getImage().dispose(); } } }); final Button button = new Button(imgContainer, SWT.PUSH); button.setText("Select Image ..."); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { showImageSelectionDialog(container.getShell(), container); } }); } FormBuilder<IEMFEditValueProperty> builder = new FormBuilder<IEMFEditValueProperty>(); builder.addTextEntry("Firstname", EMFEditProperties.value(editingDomain, ProjectPackage.Literals.PERSON__FIRSTNAME), "Firstname must not be empty"); builder.addTextEntry("Lastname", EMFEditProperties.value(editingDomain, ProjectPackage.Literals.PERSON__LASTNAME), "Lastname must not be empty"); builder.addTextEntry("E-Mail", EMFEditProperties.value(editingDomain, ProjectPackage.Literals.PERSON__EMAIL), "E-Mail must not be empty"); Composite formContainer = builder.build(ctx, container, person); formContainer.setLayoutData(new GridData(GridData.FILL_BOTH)); TitleAreaDialogSupport.create(this, ctx); return container; }
From source file:org.kalypso.commons.databinding.dialog.DatabindingTitleAreaDialog.java
License:Open Source License
/** * The constructor./*from w ww .j a va2 s . c om*/ * * @param dialog * The dialog. * @param toolkit * The toolkit. */ public DatabindingTitleAreaDialog(final TitleAreaDialog dialog, final FormToolkit toolkit) { super(toolkit); m_support = TitleAreaDialogSupport.create(dialog, getBindingContext()); }