Example usage for org.eclipse.jface.databinding.fieldassist ControlDecorationSupport create

List of usage examples for org.eclipse.jface.databinding.fieldassist ControlDecorationSupport create

Introduction

In this page you can find the example usage for org.eclipse.jface.databinding.fieldassist ControlDecorationSupport create.

Prototype

public static ControlDecorationSupport create(ValidationStatusProvider validationStatusProvider, int position,
        Composite composite, ControlDecorationUpdater updater) 

Source Link

Document

Creates a ControlDecorationSupport which observes the validation status of the specified ValidationStatusProvider , and displays a ControlDecoration over the underlying SWT control of all target observables that implement ISWTObservable or IViewerObservable .

Usage

From source file:net.sf.jasperreports.eclipse.ui.validator.ValidatorUtil.java

License:Open Source License

public static void controlDecorator(Binding binding, final Button okButton) {
    ControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT, null, new ControlDecorationUpdater() {
        @Override/*from w w  w.  j  av  a  2  s.c om*/
        protected void update(ControlDecoration decoration, IStatus status) {
            super.update(decoration, status);
            if (okButton != null)
                okButton.setEnabled(status.isOK());
        }
    });
}

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 ww  . jav  a 2  s  .co m*/

    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.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);/*from ww  w. j a  va 2  s .  co 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.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 ava  2 s  . co m*/
    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.jboss.tools.common.launcher.ui.wizard.NewLauncherProjectWizardPage.java

License:Open Source License

@Override
protected void doCreateControls(final Composite parent, DataBindingContext dbc) {
    GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(2).applyTo(parent);

    //  explanation
    Label explanation = new Label(parent, SWT.WRAP);
    explanation.setText("Launcher will generate an application for you."
            + " By picking a mission you determine what this application will do."
            + " The runtime then picks the software stack that's used to implement this aim.");
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(explanation);

    // missions//from www. j ava 2  s .  c  o m
    Label lblMissions = new Label(parent, SWT.NONE);
    lblMissions.setText("Mission:");
    lblMissions.setToolTipText("A specification that describes what your application will do.");
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(lblMissions);
    Combo comboMissions = new Combo(parent, SWT.SINGLE | SWT.DROP_DOWN | SWT.READ_ONLY);
    GridDataFactory.fillDefaults().indent(0, 10).align(SWT.LEFT, SWT.CENTER).hint(300, SWT.DEFAULT)
            .applyTo(comboMissions);
    ComboViewer comboMissionsViewer = new ComboViewer(comboMissions);
    comboMissionsViewer.setContentProvider(new ObservableListContentProvider());
    comboMissionsViewer.setInput(BeanProperties.list(NewLauncherProjectModel.MISSIONS_PROPERTY).observe(model));
    comboMissionsViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            Mission mission = (Mission) element;
            return mission.getId();
        }
    });
    IObservableValue selectedMissionObservable = BeanProperties
            .value(NewLauncherProjectModel.SELECTED_MISSION_PROPERTY).observe(model);
    ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(comboMissionsViewer))
            .to(selectedMissionObservable).in(dbc);

    new Label(parent, SWT.None); // filler
    StyledText missionDescription = createStyledText(parent);
    IObservableValue missionDescriptionObservable = PojoProperties
            .value(NewLauncherProjectModel.DESCRIPTION_PROPERTY).observeDetail(selectedMissionObservable);
    ValueBindingBuilder.bind(WidgetProperties.text().observe(missionDescription)).notUpdatingParticipant()
            .to(missionDescriptionObservable).in(dbc);
    missionDescriptionObservable.addValueChangeListener(event -> setToPreferredVerticalSize(getShell()));

    // boosters
    Label lblBoosters = new Label(parent, SWT.NONE);
    lblBoosters.setText("Runtime:");
    lblBoosters.setToolTipText("The framework software used in the application's process.");
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(lblBoosters);
    Combo comboBoosters = new Combo(parent, SWT.SINGLE | SWT.DROP_DOWN | SWT.READ_ONLY);
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(300, SWT.DEFAULT).applyTo(comboBoosters);
    ComboViewer comboBoostersViewer = new ComboViewer(comboBoosters);
    comboBoostersViewer.setContentProvider(new ObservableListContentProvider());
    comboBoostersViewer.setInput(BeanProperties.list(NewLauncherProjectModel.BOOSTERS_PROPERTY).observe(model));
    comboBoostersViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            Booster booster = (Booster) element;
            return booster.getRuntime() + " " + booster.getVersion();
        }
    });
    IObservableValue<Booster> selectedBoosterObservable = BeanProperties
            .value(NewLauncherProjectModel.SELECTED_BOOSTER_PROPERTY).observe(model);
    ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(comboBoostersViewer))
            .to(selectedBoosterObservable).in(dbc);

    new Label(parent, SWT.None); // filler
    StyledText boosterDescription = createStyledText(parent);
    IObservableValue boosterDescriptionObservable = PojoProperties
            .value(NewLauncherProjectModel.DESCRIPTION_PROPERTY).observeDetail(selectedBoosterObservable);
    ValueBindingBuilder.bind(WidgetProperties.text().observe(boosterDescription)).notUpdatingParticipant()
            .to(boosterDescriptionObservable).in(dbc);
    boosterDescriptionObservable.addValueChangeListener(event -> setToPreferredVerticalSize(getShell()));

    // separator
    Label mavenSeparator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).applyTo(mavenSeparator);

    // project name
    createTextWidget(parent, dbc, "Project name:", NewLauncherProjectModel.PROJECT_NAME_PROPERTY,
            new EclipseProjectValidator("Please specify an Eclipse project", "Project already exists"));
    //use default location
    Button buttonUseDefaultLocation = new Button(parent, SWT.CHECK);
    buttonUseDefaultLocation.setText("Use default location");
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.LEFT, SWT.CENTER).applyTo(buttonUseDefaultLocation);
    IObservableValue<Boolean> useDefaultLocationButtonObservable = WidgetProperties.selection()
            .observe(buttonUseDefaultLocation);
    ValueBindingBuilder.bind(useDefaultLocationButtonObservable)
            .to(BeanProperties.value(NewLauncherProjectModel.USE_DEFAULT_LOCATION_PROPERTY).observe(model))
            .in(dbc);

    // location
    Label lblLocation = new Label(parent, SWT.NONE);
    lblLocation.setText("Location:");
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(lblLocation);

    Text txtLocation = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(txtLocation);
    Binding locationBinding = ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(txtLocation))
            .validatingAfterGet(new MandatoryStringValidator("Please specify a location for you project"))
            .converting(
                    IConverter.create(String.class, IPath.class, NewLauncherProjectWizardPage::string2IPath))
            .to(BeanProperties.value(NewLauncherProjectModel.LOCATION_PROPERTY).observe(model)).in(dbc);
    ValueBindingBuilder.bind(WidgetProperties.enabled().observe(txtLocation)).notUpdatingParticipant()
            .to(BeanProperties.value(NewLauncherProjectModel.USE_DEFAULT_LOCATION_PROPERTY).observe(model))
            .converting(new InvertingBooleanConverter()).in(dbc);
    ControlDecorationSupport.create(locationBinding, SWT.LEFT | SWT.TOP, null,
            new RequiredControlDecorationUpdater());

    // separator
    Label launcherSeparator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
    GridDataFactory.fillDefaults().indent(0, 10).span(2, 1).align(SWT.FILL, SWT.CENTER)
            .applyTo(launcherSeparator);

    // maven artifact
    Label mavenArtifactExplanation = new Label(parent, SWT.None);
    mavenArtifactExplanation.setText("Maven Artifact:");
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).applyTo(mavenArtifactExplanation);
    createTextWidget(parent, dbc, "Artifact id:", NewLauncherProjectModel.ARTIFACTID_PROPERTY,
            new MandatoryStringValidator("Please specify an artifact id"));
    createTextWidget(parent, dbc, "Group id:", NewLauncherProjectModel.GROUPID_PROPERTY,
            new MandatoryStringValidator("Please specify a group id"));
    createTextWidget(parent, dbc, "Version:", NewLauncherProjectModel.VERSION_PROPERTY,
            new MandatoryStringValidator("Please specify a version"));

    loadCatalog();
}

From source file:org.jboss.tools.common.launcher.ui.wizard.NewLauncherProjectWizardPage.java

License:Open Source License

private Text createTextWidget(Composite parent, DataBindingContext dbc, String label, String property,
        IValidator<String> validator) {
    Label lbl = new Label(parent, SWT.NONE);
    lbl.setText(label);/*from   w w w. j ava2  s . c  o m*/
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(lbl);

    Text text = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(text);
    Binding binding = ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(text))
            .validatingAfterConvert(validator).to(BeanProperties.value(property).observe(model)).in(dbc);
    ControlDecorationSupport.create(binding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
    return text;
}

From source file:org.jboss.tools.openshift.express.internal.ui.wizard.application.ApplicationConfigurationWizardPage.java

License:Open Source License

private Composite createApplicationSelectionGroup(Composite container, DataBindingContext dbc) {
    Composite existingAppSelectionGroup = new Composite(container, SWT.NONE);
    // projectGroup.setText("Project");
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true, false)
            .applyTo(existingAppSelectionGroup);
    GridLayoutFactory.fillDefaults().numColumns(3).margins(6, 6).applyTo(existingAppSelectionGroup);

    // existing app checkbox
    useExistingAppBtn = new Button(existingAppSelectionGroup, SWT.CHECK);
    useExistingAppBtn.setText("Use existing application:");
    useExistingAppBtn.setToolTipText("Select an existing application or uncheck to create a new one.");
    useExistingAppBtn.setFocus();/*from   w  w  w  . ja  v a2  s  . c  o  m*/
    GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).grab(false, false)
            .applyTo(useExistingAppBtn);
    IObservableValue useExistingAppObservable = BeanProperties
            .value(ApplicationConfigurationWizardPageModel.PROPERTY_USE_EXISTING_APPLICATION)
            .observe(pageModel);
    final IObservableValue useExistingAppBtnSelection = WidgetProperties.selection().observe(useExistingAppBtn);
    dbc.bindValue(useExistingAppBtnSelection, useExistingAppObservable);

    // existing app name
    this.existingAppNameText = new Text(existingAppSelectionGroup, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true, false)
            .applyTo(existingAppNameText);
    IObservableValue existingAppNameTextObservable = WidgetProperties.text(SWT.Modify)
            .observe(existingAppNameText);
    IObservableValue existingAppNameModelObservable = BeanProperties
            .value(ApplicationConfigurationWizardPageModel.PROPERTY_EXISTING_APPLICATION_NAME)
            .observe(pageModel);
    ValueBindingBuilder.bind(existingAppNameTextObservable).to(existingAppNameModelObservable).in(dbc);
    UIUtils.focusOnSelection(useExistingAppBtn, existingAppNameText);
    createExistingAppNameContentAssist();
    useExistingAppBtnSelection.addValueChangeListener(
            onUseExistingApplication(newAppConfigurationGroup, existingAppNameText, browseAppsButton));

    this.browseAppsButton = new Button(existingAppSelectionGroup, SWT.NONE);
    browseAppsButton.setText("Browse...");
    browseAppsButton.addSelectionListener(onBrowseApps(dbc));
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).span(1, 1)
            .grab(false, false).applyTo(browseAppsButton);
    // observe the list of application, get notified once they have been
    IObservableValue existingApplicationsLoaded = BeanProperties
            .value(ApplicationConfigurationWizardPageModel.PROPERTY_EXISTING_APPLICATIONS_LOADED)
            .observe(pageModel);
    final ApplicationToSelectNameValidator existingAppValidator = new ApplicationToSelectNameValidator(
            useExistingAppBtnSelection, existingAppNameTextObservable, existingApplicationsLoaded);
    dbc.addValidationStatusProvider(existingAppValidator);
    ControlDecorationSupport.create(existingAppValidator, SWT.LEFT | SWT.TOP, null,
            new RequiredControlDecorationUpdater(false));
    return existingAppSelectionGroup;
}

From source file:org.jboss.tools.openshift.express.internal.ui.wizard.application.ApplicationConfigurationWizardPage.java

License:Open Source License

private void createApplicationConfigurationGroup(Composite parent, DataBindingContext dbc) {
    this.newAppConfigurationGroup = new Group(parent, SWT.NONE);
    newAppConfigurationGroup.setText("New application");
    GridLayoutFactory.fillDefaults().numColumns(3).margins(6, 6).applyTo(newAppConfigurationGroup);
    GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(newAppConfigurationGroup);

    final Label newAppNameLabel = new Label(newAppConfigurationGroup, SWT.NONE);
    newAppNameLabel.setText("Name:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(newAppNameLabel);

    // application name
    this.newAppNameText = new Text(newAppConfigurationGroup, SWT.BORDER);
    GridDataFactory.fillDefaults().grab(true, false).span(2, 1).align(SWT.FILL, SWT.FILL)
            .applyTo(newAppNameText);//  w  w  w .  j  av  a2s  .  c o m
    UIUtils.selectAllOnFocus(newAppNameText);
    final IObservableValue applicationNameTextObservable = WidgetProperties.text(SWT.Modify)
            .observe(newAppNameText);
    final IObservableValue applicationNameModelObservable = BeanProperties
            .value(ApplicationConfigurationWizardPageModel.PROPERTY_APPLICATION_NAME).observe(pageModel);
    ValueBindingBuilder.bind(applicationNameTextObservable).to(applicationNameModelObservable).in(dbc);

    final ISWTObservableValue useExistingAppBtnSelection = WidgetProperties.selection()
            .observe(useExistingAppBtn);
    final NewApplicationNameValidator newApplicationNameValidator = new NewApplicationNameValidator(
            useExistingAppBtnSelection, applicationNameTextObservable);
    dbc.addValidationStatusProvider(newApplicationNameValidator);
    ControlDecorationSupport.create(newApplicationNameValidator, SWT.LEFT | SWT.TOP, null,
            new RequiredControlDecorationUpdater());

    // application type
    final Label newAppTypeLabel = new Label(newAppConfigurationGroup, SWT.NONE);
    newAppTypeLabel.setText("Type:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).applyTo(newAppTypeLabel);
    this.newAppCartridgeCombo = new Combo(newAppConfigurationGroup, SWT.BORDER | SWT.READ_ONLY);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(2, 1).grab(true, false)
            .applyTo(newAppCartridgeCombo);

    dbc.bindList(WidgetProperties.items().observe(newAppCartridgeCombo),
            BeanProperties.list(ApplicationConfigurationWizardPageModel.PROPERTY_CARTRIDGES).observe(pageModel),
            new UpdateListStrategy(UpdateListStrategy.POLICY_NEVER),
            new UpdateListStrategy().setConverter(new CartridgeToStringConverter()));

    final ISWTObservableValue selectedCartridgeIndexObservable = WidgetProperties.singleSelectionIndex()
            .observe(newAppCartridgeCombo);
    final IObservableValue selectedCartridgeModelObservable = BeanProperties
            .value(ApplicationConfigurationWizardPageModel.PROPERTY_SELECTED_CARTRIDGE).observe(pageModel);
    ValueBindingBuilder.bind(selectedCartridgeIndexObservable).converting(new CartridgesIndexToCartridge())
            .to(selectedCartridgeModelObservable).converting(new CartridgeToCartridgesIndex()).in(dbc);

    // gear profile
    final Label gearProfileLabel = new Label(newAppConfigurationGroup, SWT.NONE);
    gearProfileLabel.setText("Gear profile:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).applyTo(gearProfileLabel);
    this.gearProfilesCombo = new Combo(newAppConfigurationGroup, SWT.BORDER | SWT.READ_ONLY);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true, false)
            .applyTo(gearProfilesCombo);
    dbc.bindList(WidgetProperties.items().observe(gearProfilesCombo),
            BeanProperties.list(ApplicationConfigurationWizardPageModel.PROPERTY_GEAR_PROFILES)
                    .observe(pageModel),
            new UpdateListStrategy(UpdateListStrategy.POLICY_NEVER), new UpdateListStrategy() {

                /**
                * Needed to avoid buggy list update strategy in
                * ListBinding. The bug appears if the model list changes
                * its ordering and the strategy then tries to apply the
                * move in the target (widget). It does not apply the
                * conversion and ends up in a class cast exception when
                * updating the target (widget) items list.
                * 
                * @see https://issues.jboss.org/browse/JBIDE-11954
                */
                protected boolean useMoveAndReplace() {
                    return false;
                }

            }.setConverter(new GearProfileToStringConverter()));

    final ISWTObservableValue selectedGearProfileComboObservable = WidgetProperties.selection()
            .observe(gearProfilesCombo);
    final IObservableValue selectedGearProfileModelObservable = BeanProperties
            .value(ApplicationConfigurationWizardPageModel.PROPERTY_SELECTED_GEAR_PROFILE).observe(pageModel);
    ValueBindingBuilder.bind(selectedGearProfileComboObservable).converting(new StringToGearProfileConverter())
            .to(selectedGearProfileModelObservable).converting(new GearProfileToStringConverter()).in(dbc);

    // scaling
    this.enableScalingButton = new Button(newAppConfigurationGroup, SWT.CHECK);
    enableScalingButton.setText("Enable scaling");
    IObservableValue enableScalingModelObservable = BeanProperties
            .value(ApplicationConfigurationWizardPageModel.PROPERTY_APPLICATION_SCALE).observe(pageModel);
    final IObservableValue enableScalingButtonSelection = WidgetProperties.selection()
            .observe(enableScalingButton);
    ValueBindingBuilder.bind(enableScalingButtonSelection).converting(new BooleanToApplicationScaleConverter())
            .to(enableScalingModelObservable).converting(new ApplicationScaleToBooleanConverter()).in(dbc);

    final NewApplicationTypeValidator newApplicationTypeValidator = new NewApplicationTypeValidator(
            useExistingAppBtnSelection, selectedCartridgeIndexObservable);
    dbc.addValidationStatusProvider(newApplicationTypeValidator);
    ControlDecorationSupport.create(newApplicationTypeValidator, SWT.LEFT | SWT.TOP, null,
            new RequiredControlDecorationUpdater());

    // embeddable cartridges
    this.newAppEmbeddableCartridgesGroup = new Group(newAppConfigurationGroup, SWT.NONE);
    newAppEmbeddableCartridgesGroup.setText("Embeddable Cartridges");
    GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).span(3, 1)
            .applyTo(newAppEmbeddableCartridgesGroup);
    GridLayoutFactory.fillDefaults().numColumns(2).margins(6, 6).applyTo(newAppEmbeddableCartridgesGroup);

    Composite tableContainer = new Composite(newAppEmbeddableCartridgesGroup, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(1, 2).hint(400, 250)
            .applyTo(tableContainer);
    this.viewer = createTable(tableContainer);
    dbc.bindSet(ViewerProperties.checkedElements(IEmbeddableCartridge.class).observe(viewer),
            BeanProperties.set(ApplicationConfigurationWizardPageModel.PROPERTY_SELECTED_EMBEDDABLE_CARTRIDGES)
                    .observe(pageModel));
    // strategy has to be attached after the binding, so that the binding
    // can still add the checked cartridge and the strategy can correct
    viewer.addCheckStateListener(new EmbedCartridgeStrategyAdapter(pageModel, this));

    this.checkAllButton = new Button(newAppEmbeddableCartridgesGroup, SWT.PUSH);
    checkAllButton.setText("&Select All");
    GridDataFactory.fillDefaults().hint(110, SWT.DEFAULT).grab(false, false).align(SWT.FILL, SWT.TOP)
            .applyTo(checkAllButton);
    checkAllButton.addSelectionListener(onCheckAll());

    this.uncheckAllButton = new Button(newAppEmbeddableCartridgesGroup, SWT.PUSH);
    uncheckAllButton.setText("&Deselect All");
    GridDataFactory.fillDefaults().hint(110, SWT.DEFAULT).grab(false, true).align(SWT.FILL, SWT.TOP)
            .applyTo(uncheckAllButton);
    uncheckAllButton.addSelectionListener(onUncheckAll());

    // bottom filler
    Composite spacer = new Composite(newAppConfigurationGroup, SWT.NONE);
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(spacer);
}

From source file:org.jboss.tools.openshift.express.internal.ui.wizard.application.ApplicationTemplateWizardPage.java

License:Open Source License

private void createExistingApplicationControls(Composite parent, SelectObservableValue useExitingApplication,
        IObservableValue useExistingApplication, DataBindingContext dbc) {
    // existing app radio
    Button useExistingApplicationButton = new Button(parent, SWT.RADIO);
    useExistingApplicationButton.setText("Use my existing OpenShift application:");
    useExistingApplicationButton.setToolTipText("If selected we will import your existing application.");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(2, 1).grab(true, false)
            .applyTo(useExistingApplicationButton);

    useExitingApplication.addOption(Boolean.TRUE,
            WidgetProperties.selection().observe(useExistingApplicationButton));

    // existing app explanatory label
    Label existingAppLabel = new Label(parent, SWT.None);
    existingAppLabel.setText("We will clone and import your existing application to a workspace project.");
    existingAppLabel.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND));
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false)
            .applyTo(existingAppLabel);/*w  w  w. jav  a2s  . c  o  m*/

    // existing app name
    this.existingAppNameText = new Text(parent, SWT.BORDER);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(existingAppNameText);
    IObservableValue existingAppNameTextObservable = WidgetProperties.text(SWT.Modify)
            .observe(existingAppNameText);
    ValueBindingBuilder.bind(existingAppNameTextObservable).to(BeanProperties
            .value(ApplicationTemplateWizardPageModel.PROPERTY_EXISTING_APPLICATION_NAME).observe(pageModel))
            .in(dbc);
    ValueBindingBuilder.bind(WidgetProperties.enabled().observe(existingAppNameText)).notUpdatingParticipant()
            .to(useExistingApplication).in(dbc);
    createExistingAppNameContentAssist(existingAppNameText);

    IObservableValue existingApplicationsLoaded = BeanProperties
            .value(ApplicationTemplateWizardPageModel.PROPERTY_RESOURCES_LOADED).observe(pageModel);
    IObservableValue existingApplicationObservable = BeanProperties
            .value(ApplicationTemplateWizardPageModel.PROPERTY_EXISTING_APPLICATION).observe(pageModel);
    final ExistingApplicationNameValidator existingAppValidator = new ExistingApplicationNameValidator(
            useExitingApplication, existingAppNameTextObservable, existingApplicationObservable,
            existingApplicationsLoaded);
    dbc.addValidationStatusProvider(existingAppValidator);
    ControlDecorationSupport.create(existingAppValidator, SWT.LEFT | SWT.TOP, null,
            new RequiredControlDecorationUpdater(true));

    // browse button
    Button browseAppsButton = new Button(parent, SWT.NONE);
    browseAppsButton.setText("Browse...");
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).grab(false, false)
            .applyTo(browseAppsButton);
    ValueBindingBuilder.bind(WidgetProperties.enabled().observe(browseAppsButton)).notUpdatingParticipant()
            .to(useExistingApplication).in(dbc);
    browseAppsButton.addSelectionListener(onBrowseExistingApps(dbc));
}

From source file:org.jboss.tools.openshift.express.internal.ui.wizard.application.ApplicationTemplateWizardPage.java

License:Open Source License

private void createNewApplicationControls(Composite parent, SelectObservableValue useExitingApplication,
        IObservableValue useExistingApplication, DataBindingContext dbc) {
    // existing app radio
    Button newApplicationButton = new Button(parent, SWT.RADIO);
    newApplicationButton.setText("Create a new OpenShift application:");
    newApplicationButton.setToolTipText("If selected we will create a new application in OpenShift.");
    GridDataFactory.fillDefaults().span(2, 1).indent(0, 8).align(SWT.FILL, SWT.CENTER).grab(true, false)
            .applyTo(newApplicationButton);

    useExitingApplication.addOption(Boolean.FALSE, WidgetProperties.selection().observe(newApplicationButton));

    // new app explanatory label
    Label existingAppLabel = new Label(parent, SWT.None);
    existingAppLabel.setText(/*from w  w w .j a  v  a 2  s.c om*/
            "You can create an application form scratch or handpick from existing cartridges you need.");
    existingAppLabel.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND));
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).grab(true, false)
            .applyTo(existingAppLabel);

    Composite applicationTemplatesTreeComposite = new Composite(parent, SWT.NONE);
    GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, true)
            .applyTo(applicationTemplatesTreeComposite);
    GridLayoutFactory.fillDefaults().spacing(2, 2).applyTo(applicationTemplatesTreeComposite);

    // filter text
    Text templateFilterText = UIUtils.createSearchText(applicationTemplatesTreeComposite);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(templateFilterText);
    ValueBindingBuilder.bind(WidgetProperties.enabled().observe(templateFilterText)).notUpdatingParticipant()
            .to(useExistingApplication).converting(new InvertingBooleanConverter()).in(dbc);

    // application templates tree
    final TreeViewer applicationTemplatesViewer = createApplicationTemplatesViewer(
            applicationTemplatesTreeComposite, templateFilterText);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(400, 180)
            .applyTo(applicationTemplatesViewer.getControl());
    ValueBindingBuilder.bind(WidgetProperties.enabled().observe(applicationTemplatesViewer.getControl()))
            .notUpdatingParticipant().to(useExistingApplication).converting(new InvertingBooleanConverter())
            .in(dbc);
    templateFilterText.addModifyListener(onFilterTextModified(applicationTemplatesViewer));

    IObservableValue selectedApplicationTemplateViewerObservable = ViewerProperties.singleSelection()
            .observe(applicationTemplatesViewer);
    IObservableValue selectedApplicationTemplateModelObservable = BeanProperties
            .value(ApplicationTemplateWizardPageModel.PROPERTY_SELECTED_APPLICATION_TEMPLATE)
            .observe(pageModel);
    ValueBindingBuilder.bind(selectedApplicationTemplateViewerObservable)
            .to(selectedApplicationTemplateModelObservable).in(dbc);

    ApplicationTemplateValidator selectedApplicationTemplateValidator = new ApplicationTemplateValidator(
            useExitingApplication, selectedApplicationTemplateViewerObservable);
    dbc.addValidationStatusProvider(selectedApplicationTemplateValidator);
    ControlDecorationSupport.create(selectedApplicationTemplateValidator, SWT.LEFT | SWT.TOP, null,
            new RequiredControlDecorationUpdater(true));

    // selected application template details
    final Group detailsContainer = new Group(applicationTemplatesTreeComposite, SWT.NONE);
    detailsContainer.setText("Details");
    enableTemplateDetailsControls(detailsContainer, !pageModel.isUseExistingApplication());
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(SWT.DEFAULT, 106).applyTo(detailsContainer);
    useExistingApplication.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            final Boolean enabled = Boolean.FALSE.equals(event.diff.getNewValue());
            enableTemplateDetailsControls(detailsContainer, enabled);
        }

    });

    new ApplicationTemplateDetailViews(selectedApplicationTemplateModelObservable, useExitingApplication,
            detailsContainer, dbc).createControls();
}