Search in sources :

Example 1 with Converter

use of org.eclipse.core.databinding.conversion.Converter in project jbosstools-openshift by jbosstools.

the class ApplicationSourceListPage method doCreateControls.

@Override
protected void doCreateControls(Composite parent, DataBindingContext dbc) {
    super.doCreateControls(parent, dbc);
    IObservableValue selectedEclipseProject = createEclipseProjectControls(parent, dbc);
    SashForm listAndDetailsContainer = new SashForm(parent, SWT.VERTICAL);
    GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(listAndDetailsContainer);
    GridLayoutFactory.fillDefaults().applyTo(listAndDetailsContainer);
    TabFolder tabContainer = new TabFolder(listAndDetailsContainer, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(tabContainer);
    tabContainer.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            // JBIDE-21072: force re-layout of the parent upon tab switching
            parent.layout(true, true);
        }
    });
    IObservableValue useLocalTemplateObservable = BeanProperties.value(IApplicationSourceListPageModel.PROPERTY_USE_LOCAL_APP_SOURCE).observe(model);
    ValueBindingBuilder.bind(new TabFolderSelectionProperty().observe(tabContainer)).converting(new Converter(Integer.class, Boolean.class) {

        @Override
        public Object convert(Object fromObject) {
            return Integer.valueOf(LOCAL_TEMPLATE_TAB_INDEX).equals(fromObject);
        }
    }).to(useLocalTemplateObservable).converting(new Converter(Boolean.class, Integer.class) {

        @Override
        public Object convert(Object fromObject) {
            return (fromObject != null && (Boolean) fromObject) ? LOCAL_TEMPLATE_TAB_INDEX : 0;
        }
    }).in(dbc);
    model.setUseLocalAppSource(false);
    TabFolderTraverseListener tabFolderTraverseListener = new TabFolderTraverseListener(tabContainer);
    IObservableValue serverTemplate = createServerTemplateControls(tabContainer, tabFolderTraverseListener, useLocalTemplateObservable, dbc);
    IObservableValue localTemplateFilename = createLocalTemplateControls(tabContainer, tabFolderTraverseListener, useLocalTemplateObservable, dbc);
    dbc.addValidationStatusProvider(new MultiValidator() {

        @Override
        protected IStatus validate() {
            return (IStatus) BeanProperties.value(IApplicationSourceListPageModel.PROPERTY_APP_SOURCE_STATUS, IStatus.class).observe(model).getValue();
        }
    });
    createDetailsGroup(listAndDetailsContainer, dbc);
    // template list initially takes twice the height of the details pane
    listAndDetailsContainer.setWeights(new int[] { 2, 1 });
    // validate required template
    IObservableValue selectedTemplate = BeanProperties.value(IApplicationSourceListPageModel.PROPERTY_SELECTED_APP_SOURCE).observe(model);
    TemplateListPageValidator pageValidator = new TemplateListPageValidator(useLocalTemplateObservable, localTemplateFilename, serverTemplate, selectedTemplate, selectedEclipseProject, parent);
    dbc.addValidationStatusProvider(pageValidator);
    ControlDecorationSupport.create(pageValidator, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
    ProjectNameValidator projectNameValidator = new ProjectNameValidator(selectedEclipseProject, parent);
    dbc.addValidationStatusProvider(projectNameValidator);
    ControlDecorationSupport.create(projectNameValidator, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) SelectionListener(org.eclipse.swt.events.SelectionListener) IValueChangeListener(org.eclipse.core.databinding.observable.value.IValueChangeListener) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) KeyListener(org.eclipse.swt.events.KeyListener) TabFolder(org.eclipse.swt.widgets.TabFolder) MultiValidator(org.eclipse.core.databinding.validation.MultiValidator) SashForm(org.eclipse.swt.custom.SashForm) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) KeyEvent(org.eclipse.swt.events.KeyEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) PageChangingEvent(org.eclipse.jface.dialogs.PageChangingEvent) ValueChangeEvent(org.eclipse.core.databinding.observable.value.ValueChangeEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Converter(org.eclipse.core.databinding.conversion.Converter) Model2ObservableTreeItemConverter(org.jboss.tools.openshift.internal.ui.treeitem.Model2ObservableTreeItemConverter) ObservableTreeItem2ModelConverter(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem2ModelConverter) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) TabFolderSelectionProperty(org.jboss.tools.openshift.internal.common.ui.databinding.TabFolderSelectionProperty)

Example 2 with Converter

use of org.eclipse.core.databinding.conversion.Converter in project jbosstools-openshift by jbosstools.

the class ApplicationSourceListPage method createDetailsGroup.

private void createDetailsGroup(Composite parent, DataBindingContext dbc) {
    // details
    Group detailsGroup = new Group(parent, SWT.NONE);
    detailsGroup.setText("Details");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(detailsGroup);
    // TODO fix margins
    GridLayoutFactory.fillDefaults().margins(10, 6).spacing(2, 2).applyTo(detailsGroup);
    Composite detailsContainer = new Composite(detailsGroup, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(detailsContainer);
    new ApplicationSourceDetailViews(BeanProperties.value(IApplicationSourceListPageModel.PROPERTY_SELECTED_APP_SOURCE).observe(model), null, detailsContainer, dbc).createControls();
    // detail resources button
    Button btnDetails = new Button(detailsGroup, SWT.NONE);
    btnDetails.setText("Defined Resources...");
    GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(btnDetails);
    IObservableValue selectedTemplate = BeanProperties.value(IApplicationSourceListPageModel.PROPERTY_SELECTED_APP_SOURCE).observe(model);
    ValueBindingBuilder.bind(WidgetProperties.visible().observe(btnDetails)).notUpdatingParticipant().to(selectedTemplate).converting(new Converter(Object.class, Boolean.class) {

        @Override
        public Object convert(Object fromObject) {
            return fromObject != null && ResourceKind.TEMPLATE.equals(((IApplicationSource) fromObject).getSource().getKind());
        }
    }).in(dbc);
    btnDetails.addSelectionListener(onDefinedResourcesClicked());
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) Converter(org.eclipse.core.databinding.conversion.Converter) Model2ObservableTreeItemConverter(org.jboss.tools.openshift.internal.ui.treeitem.Model2ObservableTreeItemConverter) ObservableTreeItem2ModelConverter(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem2ModelConverter) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue)

Example 3 with Converter

use of org.eclipse.core.databinding.conversion.Converter in project jbosstools-openshift by jbosstools.

the class SelectProjectComponentBuilder method build.

public void build(Composite container, DataBindingContext dbc) {
    Label existingProjectLabel = new Label(container, SWT.NONE);
    existingProjectLabel.setText("Eclipse Project: ");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(existingProjectLabel);
    final Text existingProjectNameText = new Text(container, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(hSpan, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(existingProjectNameText);
    projectNameTextObservable = WidgetProperties.text(SWT.Modify).observe(existingProjectNameText);
    Binding eclipseProjectBinding = ValueBindingBuilder.bind(projectNameTextObservable).validatingAfterConvert(new IValidator() {

        @Override
        public IStatus validate(Object value) {
            if (value instanceof String) {
                return ValidationStatus.ok();
            } else if (value == null) {
                if (required) {
                    return ValidationStatus.error("Select an existing project");
                } else if (!StringUtils.isEmpty(existingProjectNameText.getText())) {
                    return ValidationStatus.error(NLS.bind("Project {0} does not exist", existingProjectNameText.getText()));
                }
            }
            return ValidationStatus.ok();
        }
    }).converting(new Converter(String.class, IProject.class) {

        @Override
        public Object convert(Object fromObject) {
            String name = (String) fromObject;
            return ProjectUtils.getProject(name);
        }
    }).to(eclipseProjectObservable).converting(new Converter(IProject.class, String.class) {

        @Override
        public Object convert(Object fromObject) {
            return fromObject == null ? "" : ((IProject) fromObject).getName();
        }
    }).in(dbc);
    ControlDecorationSupport.create(eclipseProjectBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
    // project name content assist
    ControlDecoration dec = new ControlDecoration(existingProjectNameText, SWT.TOP | SWT.RIGHT);
    FieldDecoration contentProposalFieldIndicator = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
    dec.setImage(contentProposalFieldIndicator.getImage());
    dec.setDescriptionText("Auto-completion is enabled when you start typing a project name.");
    dec.setShowOnlyOnFocus(true);
    new AutoCompleteField(existingProjectNameText, new TextContentAdapter(), ProjectUtils.getAllAccessibleProjectNames());
    // browse projects
    Button browseProjectsButton = new Button(container, SWT.NONE);
    browseProjectsButton.setText("Browse...");
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).indent(buttonIndent, 0).applyTo(browseProjectsButton);
    UIUtils.setDefaultButtonWidth(browseProjectsButton);
    browseProjectsButton.addSelectionListener(selectionListener);
}
Also used : Binding(org.eclipse.core.databinding.Binding) IStatus(org.eclipse.core.runtime.IStatus) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) TextContentAdapter(org.eclipse.jface.fieldassist.TextContentAdapter) AutoCompleteField(org.eclipse.jface.fieldassist.AutoCompleteField) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) IValidator(org.eclipse.core.databinding.validation.IValidator) Button(org.eclipse.swt.widgets.Button) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) Converter(org.eclipse.core.databinding.conversion.Converter)

Example 4 with Converter

use of org.eclipse.core.databinding.conversion.Converter in project jbosstools-openshift by jbosstools.

the class GitCloningWizardPage method createCloneGroup.

private Composite createCloneGroup(Composite parent, DataBindingContext dbc) {
    Group cloneGroup = new Group(parent, SWT.NONE);
    cloneGroup.setText("Clone destination");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(cloneGroup);
    GridLayoutFactory.fillDefaults().margins(10, 10).applyTo(cloneGroup);
    Composite cloneGroupComposite = new Composite(cloneGroup, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(cloneGroupComposite);
    GridLayoutFactory.fillDefaults().numColumns(3).applyTo(cloneGroupComposite);
    // use default clone destination path
    Button useDefaultCloneDestinationButton = new Button(cloneGroupComposite, SWT.CHECK);
    useDefaultCloneDestinationButton.setText("Use default clone destination");
    useDefaultCloneDestinationButton.setToolTipText("Uncheck if you want to use a custom location to clone to");
    GridDataFactory.fillDefaults().span(3, 1).align(SWT.LEFT, SWT.CENTER).applyTo(useDefaultCloneDestinationButton);
    final IObservableValue<Boolean> useDefaultCloneDestinationObservable = BeanProperties.value(IGitCloningPageModel.PROPERTY_USE_DEFAULT_CLONE_DESTINATION).observe(model);
    ValueBindingBuilder.bind(WidgetProperties.selection().observe(useDefaultCloneDestinationButton)).to(useDefaultCloneDestinationObservable).in(dbc);
    // clone destination
    Label repoPathLabel = new Label(cloneGroupComposite, SWT.NONE);
    repoPathLabel.setText("Git Clone Location:");
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(repoPathLabel);
    final Text cloneDestinationText = new Text(cloneGroupComposite, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(cloneDestinationText);
    final IObservableValue<String> cloneDestinationObservable = WidgetProperties.text(SWT.Modify).observe(cloneDestinationText);
    final IObservableValue<String> cloneDestinationModelObservable = BeanProperties.value(IGitCloningPageModel.PROPERTY_CLONE_DESTINATION).observe(model);
    ValueBindingBuilder.bind(cloneDestinationObservable).to(cloneDestinationModelObservable).in(dbc);
    Button browseCloneDestinationButton = new Button(cloneGroupComposite, SWT.PUSH);
    browseCloneDestinationButton.setText("Browse...");
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(browseCloneDestinationButton);
    browseCloneDestinationButton.addSelectionListener(onCloneDestination());
    ValueBindingBuilder.bind(WidgetProperties.enabled().observe(cloneDestinationText)).notUpdating(useDefaultCloneDestinationObservable).converting(new InvertingBooleanConverter()).in(dbc);
    ValueBindingBuilder.bind(WidgetProperties.enabled().observe(browseCloneDestinationButton)).notUpdating(useDefaultCloneDestinationObservable).converting(new InvertingBooleanConverter()).in(dbc);
    // move focus to the project location text control when not choosing the
    // 'Use default location' option.
    UIUtils.focusOnSelection(useDefaultCloneDestinationButton, cloneDestinationText);
    // Reuse git repository
    Button reuseRepositoryButton = new Button(cloneGroupComposite, SWT.CHECK);
    reuseRepositoryButton.setSelection(false);
    reuseRepositoryButton.setText("Do not clone - use existing repository");
    GridDataFactory.fillDefaults().span(3, 1).align(SWT.LEFT, SWT.CENTER).applyTo(reuseRepositoryButton);
    final IObservableValue<Boolean> reuseGitReposityObservable = WidgetProperties.selection().observe(reuseRepositoryButton);
    ValueBindingBuilder.bind(reuseGitReposityObservable).to(BeanProperties.value(IGitCloningPageModel.PROPERTY_REUSE_GIT_REPOSITORY).observe(model)).in(dbc);
    IObservableValue<File> repoPathObservable = BeanProperties.value(IGitCloningPageModel.PROPERTY_REPO_PATH).observe(model);
    ValueBindingBuilder.bind(WidgetProperties.enabled().observe(reuseRepositoryButton)).notUpdating(repoPathObservable).converting(new FileExistsConverter()).in(dbc);
    ISWTObservableValue reuseRepoButtonEnabled = WidgetProperties.enabled().observe(reuseRepositoryButton);
    ValueBindingBuilder.bind(reuseRepoButtonEnabled).notUpdating(repoPathObservable).converting(new Converter(File.class, Boolean.class) {

        @Override
        public Object convert(Object fromObject) {
            return fromObject instanceof File && EGitUtils.isRepository((File) fromObject);
        }
    }).in(dbc);
    this.cloneDestinationPathValidator = new CloneDestinationPathValidator(useDefaultCloneDestinationObservable, cloneDestinationObservable, reuseGitReposityObservable, repoPathObservable);
    dbc.addValidationStatusProvider(cloneDestinationPathValidator);
    ControlDecorationSupport.create(cloneDestinationPathValidator, SWT.LEFT | SWT.TOP);
    // checkout reused repo button
    Composite checkoutComposite = new Composite(cloneGroupComposite, SWT.NONE);
    GridDataFactory.fillDefaults().span(3, 1).indent(20, SWT.DEFAULT).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(checkoutComposite);
    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(checkoutComposite);
    Button checkoutBranchCheckbox = new Button(checkoutComposite, SWT.CHECK);
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(checkoutBranchCheckbox);
    ISWTObservableValue checkoutBranchCheckboxObservable = WidgetProperties.selection().observe(checkoutBranchCheckbox);
    ValueBindingBuilder.bind(checkoutBranchCheckboxObservable).validatingAfterConvert(new CheckoutBranchValidator()).to(BeanProperties.value(IGitCloningPageModel.PROPERTY_CHECKOUT_BRANCH_REUSED_REPO).observe(model)).validatingAfterConvert(new CheckoutBranchValidator()).in(dbc);
    IObservableValue<Boolean> isRepositoryBranchGitRefObservable = BeanProperties.value(IGitCloningPageModel.PROPERTY_IS_REPOSITORY_BRANCH_GIT_REF).observe(model);
    ComputedValue<Boolean> checkoutBranchEnablement = new ComputedValue<Boolean>() {

        @Override
        protected Boolean calculate() {
            // access all involved observables
            Boolean isReuseRepoButtonEnabled = (Boolean) reuseRepoButtonEnabled.getValue();
            Boolean isRepositoryBranchGitRef = isRepositoryBranchGitRefObservable.getValue();
            Boolean isReuseGitRepository = reuseGitReposityObservable.getValue();
            return isReuseRepoButtonEnabled && !isRepositoryBranchGitRef && isReuseGitRepository;
        }
    };
    // checkout branch label
    Label checkoutBranchLabel = new Label(checkoutComposite, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).grab(true, false).applyTo(checkoutBranchLabel);
    checkoutBranchLabel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent e) {
            checkoutBranchCheckboxObservable.setValue(!checkoutBranchCheckbox.getSelection());
        }
    });
    ValueBindingBuilder.bind(WidgetProperties.text().observe(checkoutBranchLabel)).notUpdating(BeanProperties.value(IGitCloningPageModel.PROPERTY_GIT_REF).observe(model)).converting(new Converter(String.class, String.class) {

        @Override
        public Object convert(Object fromObject) {
            return "Check out branch " + fromObject;
        }
    }).in(dbc);
    ValueBindingBuilder.bind(new WritableValue<Boolean>() {

        @Override
        public void doSetValue(Boolean value) {
            checkoutBranchCheckbox.setEnabled(value);
            checkoutBranchLabel.setEnabled(value);
        }
    }).notUpdating(checkoutBranchEnablement).in(dbc);
    return cloneGroup;
}
Also used : Group(org.eclipse.swt.widgets.Group) ComputedValue(org.eclipse.core.databinding.observable.value.ComputedValue) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) InvertingBooleanConverter(org.jboss.tools.common.ui.databinding.InvertingBooleanConverter) Label(org.eclipse.swt.widgets.Label) FileExistsConverter(org.jboss.tools.openshift.internal.common.ui.databinding.FileExistsConverter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Text(org.eclipse.swt.widgets.Text) Button(org.eclipse.swt.widgets.Button) ISWTObservableValue(org.eclipse.jface.databinding.swt.ISWTObservableValue) Converter(org.eclipse.core.databinding.conversion.Converter) FileExistsConverter(org.jboss.tools.openshift.internal.common.ui.databinding.FileExistsConverter) InvertingBooleanConverter(org.jboss.tools.common.ui.databinding.InvertingBooleanConverter) File(java.io.File)

Example 5 with Converter

use of org.eclipse.core.databinding.conversion.Converter in project jbosstools-openshift by jbosstools.

the class ServerSettingsWizardPage method createOCWarningControls.

@SuppressWarnings("unchecked")
private void createOCWarningControls(Composite container, ServerSettingsWizardPageModel model, DataBindingContext dbc) {
    Composite composite = new Composite(container, SWT.NONE);
    GridDataFactory.fillDefaults().applyTo(composite);
    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(composite);
    ValueBindingBuilder.bind(WidgetProperties.visible().observe(composite)).to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_OC_BINARY_STATUS).observe(model)).converting(new Converter(IStatus.class, Boolean.class) {

        @Override
        public Object convert(Object fromObject) {
            return !((IStatus) fromObject).isOK();
        }
    }).in(dbc);
    Label label = new Label(composite, SWT.NONE);
    ValueBindingBuilder.bind(WidgetProperties.image().observe(label)).to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_OC_BINARY_STATUS).observe(model)).converting(new Converter(IStatus.class, Image.class) {

        @Override
        public Object convert(Object fromObject) {
            switch(((IStatus) fromObject).getSeverity()) {
                case IStatus.WARNING:
                    return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
                case IStatus.ERROR:
                    return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
                default:
                    return null;
            }
        }
    }).in(dbc);
    Link link = new Link(composite, SWT.WRAP);
    ValueBindingBuilder.bind(WidgetProperties.text().observe(link)).to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_OC_BINARY_STATUS).observe(model)).converting(new Converter(IStatus.class, String.class) {

        @Override
        public Object convert(Object fromObject) {
            return ((IStatus) fromObject).getMessage();
        }
    }).in(dbc);
    link.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (DOWNLOAD_LINK_TEXT.equals(e.text)) {
                new BrowserUtility().checkedCreateExternalBrowser(DOWNLOAD_INSTRUCTIONS_URL, OpenShiftUIActivator.PLUGIN_ID, OpenShiftUIActivator.getDefault().getLog());
            } else {
                int rc = PreferencesUtil.createPreferenceDialogOn(getShell(), OPEN_SHIFT_PREFERENCE_PAGE_ID, new String[] { OPEN_SHIFT_PREFERENCE_PAGE_ID }, null).open();
                if (rc == Dialog.OK) {
                    new Job("Checking oc binary") {

                        @Override
                        protected IStatus run(IProgressMonitor monitor) {
                            IStatus stat = OCBinary.getInstance().getStatus(model.getConnection(), monitor);
                            model.setOCBinaryStatus(stat);
                            return stat;
                        }
                    }.schedule();
                }
            }
        }
    });
    GridDataFactory.fillDefaults().hint(LINK_DEFAULT_WIDTH, SWT.DEFAULT).applyTo(link);
    MultiValidator validator = new MultiValidator() {

        @Override
        protected IStatus validate() {
            IObservableValue<IStatus> observable = BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_OC_BINARY_STATUS).observe(model);
            Status status = (Status) observable.getValue();
            switch(status.getSeverity()) {
                case IStatus.ERROR:
                    return OpenShiftUIActivator.statusFactory().errorStatus(OpenShiftUIMessages.OCBinaryErrorMessage);
                case IStatus.WARNING:
                    return OpenShiftUIActivator.statusFactory().warningStatus(OpenShiftUIMessages.OCBinaryWarningMessage);
            }
            return status;
        }
    };
    dbc.addValidationStatusProvider(validator);
    BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_OC_BINARY_STATUS).observe(model).addValueChangeListener(event -> getShell().pack());
}
Also used : ValidationStatus(org.eclipse.core.databinding.validation.ValidationStatus) Status(org.eclipse.core.runtime.Status) RsyncStatus(org.jboss.tools.openshift.internal.core.util.RSyncValidator.RsyncStatus) IStatus(org.eclipse.core.runtime.IStatus) IStatus(org.eclipse.core.runtime.IStatus) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) MultiValidator(org.eclipse.core.databinding.validation.MultiValidator) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Converter(org.eclipse.core.databinding.conversion.Converter) Model2ObservableTreeItemConverter(org.jboss.tools.openshift.internal.ui.treeitem.Model2ObservableTreeItemConverter) ObservableTreeItem2ModelConverter(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem2ModelConverter) InvertingBooleanConverter(org.jboss.tools.common.ui.databinding.InvertingBooleanConverter) BrowserUtility(org.jboss.tools.foundation.ui.util.BrowserUtility) Job(org.eclipse.core.runtime.jobs.Job) Link(org.eclipse.swt.widgets.Link)

Aggregations

Converter (org.eclipse.core.databinding.conversion.Converter)6 Composite (org.eclipse.swt.widgets.Composite)4 Label (org.eclipse.swt.widgets.Label)4 Model2ObservableTreeItemConverter (org.jboss.tools.openshift.internal.ui.treeitem.Model2ObservableTreeItemConverter)4 ObservableTreeItem2ModelConverter (org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem2ModelConverter)4 MultiValidator (org.eclipse.core.databinding.validation.MultiValidator)3 IStatus (org.eclipse.core.runtime.IStatus)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 Button (org.eclipse.swt.widgets.Button)3 InvertingBooleanConverter (org.jboss.tools.common.ui.databinding.InvertingBooleanConverter)3 IObservableValue (org.eclipse.core.databinding.observable.value.IObservableValue)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Job (org.eclipse.core.runtime.jobs.Job)2 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 Group (org.eclipse.swt.widgets.Group)2 Link (org.eclipse.swt.widgets.Link)2 Text (org.eclipse.swt.widgets.Text)2 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)2 BrowserUtility (org.jboss.tools.foundation.ui.util.BrowserUtility)2