Search in sources :

Example 11 with RequiredControlDecorationUpdater

use of org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater 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 12 with RequiredControlDecorationUpdater

use of org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater in project jbosstools-openshift by jbosstools.

the class ConnectionWizardPage method doCreateControls.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected void doCreateControls(final Composite parent, DataBindingContext dbc) {
    GridLayoutFactory.fillDefaults().numColumns(3).margins(10, 10).applyTo(parent);
    // userdoc link (JBIDE-20401)
    // text set in #showHideUserdocLink
    this.userdocLink = new StyledText(parent, SWT.WRAP);
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(3, 1).applyTo(userdocLink);
    showHideUserdocLink();
    IObservableValue userdocUrlObservable = BeanProperties.value(ConnectionWizardPageModel.PROPERTY_USERDOCURL).observe(pageModel);
    StyledTextUtils.emulateLinkAction(userdocLink, r -> onUserdocLinkClicked(userdocUrlObservable));
    userdocUrlObservable.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(ValueChangeEvent event) {
            showHideUserdocLink();
        }
    });
    IObservableValue connectionFactoryObservable = BeanProperties.value(ConnectionWizardPageModel.PROPERTY_CONNECTION_FACTORY).observe(pageModel);
    // filler
    Label fillerLabel = new Label(parent, SWT.NONE);
    GridDataFactory.fillDefaults().span(3, 3).hint(SWT.DEFAULT, 6).applyTo(fillerLabel);
    // existing connections combo
    Label connectionLabel = new Label(parent, SWT.NONE);
    connectionLabel.setText("Connection:");
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(connectionLabel);
    Combo connectionCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
    // disable the connection combo if we're editing a connection or creating a new one from scratch
    connectionCombo.setEnabled(pageModel.isAllowConnectionChange());
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(connectionCombo);
    ComboViewer connectionComboViewer = new ComboViewer(connectionCombo);
    connectionComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    connectionComboViewer.setLabelProvider(new ConnectionColumLabelProvider());
    connectionComboViewer.setInput(pageModel.getAllConnections());
    Binding selectedConnectionBinding = ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(connectionComboViewer)).validatingAfterGet(new IsNotNullValidator(ValidationStatus.cancel("You have to select or create a new connection."))).to(BeanProperties.value(ConnectionWizardPageModel.PROPERTY_SELECTED_CONNECTION, IConnection.class).observe(pageModel)).in(dbc);
    ControlDecorationSupport.create(selectedConnectionBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
    // server type
    Label connectionFactoryLabel = new Label(parent, SWT.NONE);
    connectionFactoryLabel.setText("Server type:");
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(connectionFactoryLabel);
    Combo connectionFactoryCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(connectionFactoryCombo);
    ComboViewer connectionFactoriesViewer = new ComboViewer(connectionFactoryCombo);
    connectionFactoriesViewer.setContentProvider(ArrayContentProvider.getInstance());
    connectionFactoriesViewer.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            if (!(element instanceof IConnectionFactory)) {
                return element.toString();
            } else {
                return ((IConnectionFactory) element).getName();
            }
        }
    });
    connectionFactoriesViewer.setInput(pageModel.getAllConnectionFactories());
    // Disable the server type when editing a connection
    if (!pageModel.isAllowConnectionChange() && pageModel.getSelectedConnection() != null) {
        IConnection c = pageModel.getSelectedConnection();
        if (!(c instanceof NewConnectionMarker)) {
            connectionFactoryCombo.setEnabled(false);
        }
    }
    final IViewerObservableValue selectedServerType = ViewerProperties.singleSelection().observe(connectionFactoriesViewer);
    ValueBindingBuilder.bind(selectedServerType).to(connectionFactoryObservable).in(dbc);
    // server
    Button useDefaultServerCheckbox = new Button(parent, SWT.CHECK);
    useDefaultServerCheckbox.setText("Use default server");
    GridDataFactory.fillDefaults().span(3, 1).align(SWT.FILL, SWT.FILL).applyTo(useDefaultServerCheckbox);
    ValueBindingBuilder.bind(WidgetProperties.selection().observe(useDefaultServerCheckbox)).to(BeanProperties.value(ConnectionWizardPageModel.PROPERTY_USE_DEFAULT_HOST, IConnection.class).observe(pageModel)).in(dbc);
    IObservableValue hasDefaultHostObservable = BeanProperties.value(ConnectionWizardPageModel.PROPERTY_HAS_DEFAULT_HOST).observe(pageModel);
    ValueBindingBuilder.bind(WidgetProperties.enabled().observe(useDefaultServerCheckbox)).notUpdating(hasDefaultHostObservable).in(dbc);
    Label serverLabel = new Label(parent, SWT.NONE);
    serverLabel.setText("Server:");
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).applyTo(serverLabel);
    Combo serversCombo = new Combo(parent, SWT.BORDER);
    ComboViewer serversViewer = new ComboViewer(serversCombo);
    serversViewer.setContentProvider(new ObservableListContentProvider());
    serversViewer.setInput(BeanProperties.list(ConnectionWizardPageModel.PROPERTY_ALL_HOSTS).observe(pageModel));
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(serversCombo);
    final IObservableValue serverUrlObservable = WidgetProperties.text().observe(serversCombo);
    serversCombo.addFocusListener(onServerFocusLost(serverUrlObservable));
    ValueBindingBuilder.bind(serverUrlObservable).converting(new TrimTrailingSlashConverter()).to(BeanProperties.value(ConnectionWizardPageModel.PROPERTY_HOST).observe(pageModel)).in(dbc);
    MultiValidator serverUrlValidator = new MultiValidator() {

        @Override
        protected IStatus validate() {
            Object value = serverUrlObservable.getValue();
            if (!(value instanceof String) || StringUtils.isEmpty((String) value)) {
                return ValidationStatus.cancel("Please provide an OpenShift server url.");
            } else if (!UrlUtils.isValid((String) value)) {
                return ValidationStatus.error("Please provide a valid OpenShift server url.");
            }
            return ValidationStatus.ok();
        }
    };
    ControlDecorationSupport.create(serverUrlValidator, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
    dbc.addValidationStatusProvider(serverUrlValidator);
    ValueBindingBuilder.bind(WidgetProperties.enabled().observe(serversCombo)).notUpdatingParticipant().to(BeanProperties.value(ConnectionWizardPageModel.PROPERTY_USE_DEFAULT_HOST).observe(pageModel)).converting(new InvertingBooleanConverter()).in(dbc);
    // connect error
    dbc.addValidationStatusProvider(new MultiValidator() {

        IObservableValue observable = BeanProperties.value(ConnectionWizardPageModel.PROPERTY_CONNECTED_STATUS, IStatus.class).observe(pageModel);

        @Override
        protected IStatus validate() {
            return (IStatus) observable.getValue();
        }
    });
    // connection editors
    Group authenticationDetailsGroup = new Group(parent, SWT.NONE);
    authenticationDetailsGroup.setText("Authentication");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(3, 1).applyTo(authenticationDetailsGroup);
    GridLayoutFactory.fillDefaults().margins(0, 0).applyTo(authenticationDetailsGroup);
    // additional nesting required because of https://bugs.eclipse.org/bugs/show_bug.cgi?id=478618
    Composite authenticationDetailsContainer = new Composite(authenticationDetailsGroup, SWT.None);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(authenticationDetailsContainer);
    this.connectionEditors = new ConnectionEditorsStackedView(connectionFactoryObservable, this, authenticationDetailsContainer, dbc);
    connectionEditors.createControls();
    // adv editors
    Composite advEditorContainer = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().margins(0, 0).applyTo(authenticationDetailsGroup);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(3, 1).grab(true, true).applyTo(advEditorContainer);
    this.advConnectionEditors = new AdvancedConnectionEditorsStackedView(connectionFactoryObservable, pageModel, advEditorContainer, dbc);
    advConnectionEditors.createControls();
}
Also used : IValueChangeListener(org.eclipse.core.databinding.observable.value.IValueChangeListener) Group(org.eclipse.swt.widgets.Group) ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) IStatus(org.eclipse.core.runtime.IStatus) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) Button(org.eclipse.swt.widgets.Button) IConnectionFactory(org.jboss.tools.openshift.common.core.connection.IConnectionFactory) TrimTrailingSlashConverter(org.jboss.tools.openshift.internal.common.ui.databinding.TrimTrailingSlashConverter) IViewerObservableValue(org.eclipse.jface.databinding.viewers.IViewerObservableValue) Binding(org.eclipse.core.databinding.Binding) NewConnectionMarker(org.jboss.tools.openshift.common.core.connection.NewConnectionMarker) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) InvertingBooleanConverter(org.jboss.tools.common.ui.databinding.InvertingBooleanConverter) MultiValidator(org.eclipse.core.databinding.validation.MultiValidator) ValueChangeEvent(org.eclipse.core.databinding.observable.value.ValueChangeEvent) ComboViewer(org.eclipse.jface.viewers.ComboViewer) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) IsNotNullValidator(org.jboss.tools.openshift.internal.common.ui.databinding.IsNotNullValidator)

Example 13 with RequiredControlDecorationUpdater

use of org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater 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 14 with RequiredControlDecorationUpdater

use of org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater in project jbosstools-openshift by jbosstools.

the class AbstractProjectPage method createProjectControls.

private void createProjectControls(Composite parent, DataBindingContext dbc) {
    Label projectLabel = new Label(parent, SWT.NONE);
    projectLabel.setText("OpenShift project: ");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(projectLabel);
    StructuredViewer projectsViewer = new ComboViewer(parent);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(projectsViewer.getControl());
    final OpenShiftExplorerLabelProvider labelProvider = new OpenShiftExplorerLabelProvider();
    projectsViewer.setContentProvider(new ObservableListContentProvider());
    projectsViewer.setLabelProvider(new ObservableTreeItemLabelProvider());
    projectsViewer.setInput(BeanProperties.list(IProjectPageModel.PROPERTY_PROJECT_ITEMS).observe(model));
    projectsViewer.setComparator(ProjectViewerComparator.createProjectTreeSorter(labelProvider));
    model.setProjectsComparator(new ProjectViewerComparator(labelProvider).asItemComparator());
    IObservableValue selectedProjectObservable = ViewerProperties.singleSelection().observe(projectsViewer);
    Binding selectedProjectBinding = ValueBindingBuilder.bind(selectedProjectObservable).converting(new ObservableTreeItem2ModelConverter(IProject.class)).validatingAfterConvert(new IValidator() {

        @Override
        public IStatus validate(Object value) {
            if (value instanceof IProject) {
                return ValidationStatus.ok();
            }
            return ValidationStatus.cancel("Please choose an OpenShift project.");
        }
    }).to(BeanProperties.value(IProjectPageModel.PROPERTY_PROJECT).observe(model)).converting(new Model2ObservableTreeItemConverter(null)).in(dbc);
    ControlDecorationSupport.create(selectedProjectBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
    IObservableValue connectionObservable = BeanProperties.value(IProjectPageModel.PROPERTY_CONNECTION).observe(model);
    DataBindingUtils.addDisposableValueChangeListener(onConnectionChanged(), connectionObservable, projectsViewer.getControl());
    Button newProjectButton = new Button(parent, SWT.PUSH);
    newProjectButton.setText("New...");
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.FILL).applyTo(newProjectButton);
    UIUtils.setDefaultButtonWidth(newProjectButton);
    newProjectButton.addSelectionListener(onNewProjectClicked());
}
Also used : Binding(org.eclipse.core.databinding.Binding) ObservableTreeItemLabelProvider(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItemLabelProvider) ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) Label(org.eclipse.swt.widgets.Label) ObservableTreeItem2ModelConverter(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem2ModelConverter) ProjectViewerComparator(org.jboss.tools.openshift.internal.ui.comparators.ProjectViewerComparator) IProject(com.openshift.restclient.model.IProject) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) IValidator(org.eclipse.core.databinding.validation.IValidator) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Model2ObservableTreeItemConverter(org.jboss.tools.openshift.internal.ui.treeitem.Model2ObservableTreeItemConverter) Button(org.eclipse.swt.widgets.Button) OpenShiftExplorerLabelProvider(org.jboss.tools.openshift.internal.ui.explorer.OpenShiftExplorerLabelProvider) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue)

Example 15 with RequiredControlDecorationUpdater

use of org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater in project jbosstools-openshift by jbosstools.

the class NewProjectWizardPage method doCreateControls.

@Override
protected void doCreateControls(Composite parent, DataBindingContext dbc) {
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.TOP).applyTo(parent);
    GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(2).applyTo(parent);
    // project name
    Label lblName = new Label(parent, SWT.NONE);
    lblName.setText(OpenShiftUIMessages.Name);
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(lblName);
    lblName.setToolTipText(ProjectNameValidator.projectNameDescription);
    Text txtName = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(txtName);
    IObservableValue nameTextObservable = WidgetProperties.text(SWT.Modify).observe(txtName);
    Binding nameBinding = ValueBindingBuilder.bind(nameTextObservable).validatingAfterConvert(new ProjectNameValidator(getDescription(), model.getUnavailableNames())).to(BeanProperties.value(NewProjectWizardModel.PROPERTY_PROJECT_NAME).observe(model)).in(dbc);
    ControlDecorationSupport.create(nameBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
    // display name
    Label lblDisplayName = new Label(parent, SWT.NONE);
    lblDisplayName.setText(OpenShiftUIMessages.DisplayName);
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(lblDisplayName);
    Text txtDispalayName = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(txtDispalayName);
    ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(txtDispalayName)).validatingAfterConvert(new ProjectDisplayNameValidator()).to(BeanProperties.value(NewProjectWizardModel.PROPERTY_DISPLAY_NAME).observe(model)).in(dbc);
    // description
    Label lblDescription = new Label(parent, SWT.NONE);
    lblDescription.setText(OpenShiftUIMessages.Description);
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(lblDisplayName);
    Text txtDescription = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(txtDescription);
    ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(txtDescription)).to(BeanProperties.value(NewProjectWizardModel.PROPERTY_DESCRIPTION).observe(model)).in(dbc);
}
Also used : Binding(org.eclipse.core.databinding.Binding) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) Label(org.eclipse.swt.widgets.Label) ProjectDisplayNameValidator(org.jboss.tools.openshift.internal.ui.validator.ProjectDisplayNameValidator) Text(org.eclipse.swt.widgets.Text) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) ProjectNameValidator(org.jboss.tools.openshift.internal.ui.validator.ProjectNameValidator)

Aggregations

RequiredControlDecorationUpdater (org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater)23 Label (org.eclipse.swt.widgets.Label)18 Button (org.eclipse.swt.widgets.Button)15 Binding (org.eclipse.core.databinding.Binding)14 Text (org.eclipse.swt.widgets.Text)13 IObservableValue (org.eclipse.core.databinding.observable.value.IObservableValue)9 IStatus (org.eclipse.core.runtime.IStatus)8 Composite (org.eclipse.swt.widgets.Composite)8 IValidator (org.eclipse.core.databinding.validation.IValidator)5 MultiValidator (org.eclipse.core.databinding.validation.MultiValidator)5 ObservableListContentProvider (org.eclipse.jface.databinding.viewers.ObservableListContentProvider)5 ComboViewer (org.eclipse.jface.viewers.ComboViewer)5 InvertingBooleanConverter (org.jboss.tools.common.ui.databinding.InvertingBooleanConverter)5 ObservableTreeItem2ModelConverter (org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem2ModelConverter)5 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)4 Group (org.eclipse.swt.widgets.Group)4 ValidationStatusProvider (org.eclipse.core.databinding.ValidationStatusProvider)3 TrimmingStringConverter (org.jboss.tools.openshift.internal.common.ui.databinding.TrimmingStringConverter)3 IProject (com.openshift.restclient.model.IProject)2 Converter (org.eclipse.core.databinding.conversion.Converter)2