List of usage examples for org.eclipse.jface.databinding.swt WidgetProperties enabled
public static IWidgetValueProperty enabled()
From source file:org.jboss.tools.openshift.internal.ui.server.ServerSettingsWizardPage.java
License:Open Source License
private void createRouteControls(Composite container, ServerSettingsWizardPageModel model, DataBindingContext dbc) {//from w ww.ja v a 2s .co m Group routeGroup = new Group(container, SWT.NONE); routeGroup.setText("Route"); GridDataFactory.fillDefaults().span(4, 1).align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(routeGroup); GridLayoutFactory.fillDefaults().applyTo(routeGroup); // additional nesting required because of https://bugs.eclipse.org/bugs/show_bug.cgi?id=478618 Composite routeContainer = new Composite(routeGroup, SWT.None); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(routeContainer); GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(2).applyTo(routeContainer); Button promptRouteButton = new Button(routeContainer, SWT.CHECK); promptRouteButton.setSelection(true); promptRouteButton.setText("Prompt for route when multiple routes available to show in browser"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(2, 1).applyTo(promptRouteButton); Label routeLabel = new Label(routeContainer, SWT.NONE); routeLabel.setText("Use Route: "); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(routeLabel); StructuredViewer routesViewer = new ComboViewer(routeContainer); GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).grab(true, false) .applyTo(routesViewer.getControl()); routesViewer.setContentProvider(new ObservableListContentProvider()); routesViewer.setLabelProvider(new RouteLabelProvider()); routesViewer.setInput(BeanProperties.list(ServerSettingsWizardPageModel.PROPERTY_ROUTES).observe(model)); // routesViewer.setComparer(new IElementComparer() { // // @Override // public boolean equals(Object object1, Object object2) { // if (object1 instanceof IRoute) { // if (!(object2 instanceof IRoute)) { // return false; // } // // IRoute route1 = (IRoute) object1; // IRoute route2 = (IRoute) object2; // // return Objects.equals(route1.getServiceName(), route2.getServiceName()) // && Objects.equals(route1.getURL(), route2.getURL()); // } else if (object2 instanceof IRoute) { // return false; // } else { // return Objects.equals(object1, object2); // } // } // // @Override // public int hashCode(Object element) { // if (element instanceof IRoute) { // IRoute route = (IRoute) element; // return new HashCodeBuilder() // .append(route.getServiceName()) // .append(route.getURL()) // .toHashCode(); // } // return element.hashCode(); // } // }); IObservableValue<IResource> selectedRouteObservable = ViewerProperties.singleSelection() .observe(routesViewer); ValueBindingBuilder.bind(selectedRouteObservable) .to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_ROUTE).observe(model)).in(dbc); final IObservableValue<Boolean> isSelectDefaultRouteObservable = WidgetProperties.selection() .observe(promptRouteButton); final IObservableValue<Boolean> selectDefaultRouteModelObservable = BeanProperties .value(ServerSettingsWizardPageModel.PROPERTY_SELECT_DEFAULT_ROUTE).observe(model); ValueBindingBuilder.bind(isSelectDefaultRouteObservable).converting(new InvertingBooleanConverter()) .to(selectDefaultRouteModelObservable).converting(new InvertingBooleanConverter()).in(dbc); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(routesViewer.getControl())) .notUpdating(selectDefaultRouteModelObservable).in(dbc); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(routeLabel)) .notUpdating(selectDefaultRouteModelObservable).in(dbc); RouteValidator routeValidator = new RouteValidator(isSelectDefaultRouteObservable, selectedRouteObservable); dbc.addValidationStatusProvider(routeValidator); ControlDecorationSupport.create(routeValidator, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true)); }
From source file:org.jboss.tools.openshift.internal.ui.wizard.common.EnvironmentVariablePage.java
License:Open Source License
@SuppressWarnings("unchecked") protected void createEnvVariableControl(Composite parent, DataBindingContext dbc, String label, String tooltip) {/* w ww .ja va 2 s .c o m*/ Composite envContainer = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(envContainer); GridLayoutFactory.fillDefaults().numColumns(2).margins(2, 2).applyTo(envContainer); Label lblEnvVars = new Label(envContainer, SWT.NONE); lblEnvVars.setText(label); lblEnvVars.setToolTipText(tooltip); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(2, 1).applyTo(lblEnvVars); Composite tableContainer = envTableContainer = new Composite(envContainer, SWT.NONE); this.envViewer = createEnvVarTable(tableContainer); GridDataFactory.fillDefaults().span(1, 5).align(SWT.FILL, SWT.FILL).grab(true, true).hint(SWT.DEFAULT, 150) .applyTo(tableContainer); ValueBindingBuilder .bind(ViewerProperties.singleSelection().observe(envViewer)).to(BeanProperties .value(IDeploymentConfigPageModel.PROPERTY_SELECTED_ENVIRONMENT_VARIABLE).observe(model)) .in(dbc); envViewer.setContentProvider(new ObservableListContentProvider()); envViewer.setInput( BeanProperties.list(IDeploymentConfigPageModel.PROPERTY_ENVIRONMENT_VARIABLES).observe(model)); Button addButton = new Button(envContainer, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).applyTo(addButton); addButton.setText("Add..."); addButton.setToolTipText("Add an environment variable declared by the docker image."); addButton.addSelectionListener(onAdd()); UIUtils.setDefaultButtonWidth(addButton); heightScale = addButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; Button editExistingButton = new Button(envContainer, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).applyTo(editExistingButton); editExistingButton.setText("Edit..."); editExistingButton.setToolTipText("Edit the environment variable declared by the docker image."); editExistingButton.addSelectionListener(new EditHandler()); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(editExistingButton)).notUpdatingParticipant() .to(BeanProperties.value(IDeploymentConfigPageModel.PROPERTY_SELECTED_ENVIRONMENT_VARIABLE) .observe(model)) .converting(new IsNotNull2BooleanConverter()).in(dbc); UIUtils.setDefaultButtonWidth(editExistingButton); Button btnReset = new Button(envContainer, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).applyTo(btnReset); btnReset.setText("Reset"); btnReset.setToolTipText("Reset to the value declared by the docker image."); btnReset.addSelectionListener(onResetEnvVar()); ValueBindingBuilder .bind(WidgetProperties.enabled().observe(btnReset)).notUpdatingParticipant().to(BeanProperties .value(IDeploymentConfigPageModel.PROPERTY_SELECTED_ENVIRONMENT_VARIABLE).observe(model)) .converting(new IsNotNull2BooleanConverter() { @Override public Object convert(Object fromObject) { Boolean notNull = (Boolean) super.convert(fromObject); return notNull && !((EnvironmentVariable) fromObject).isNew() && model.isEnvironmentVariableModified((EnvironmentVariable) fromObject); } }).in(dbc); UIUtils.setDefaultButtonWidth(btnReset); Button btnResetAll = new Button(envContainer, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).applyTo(btnResetAll); btnResetAll.setText("Reset All"); btnResetAll.setToolTipText("Reset all variables to the value declared by the docker image."); btnResetAll.addSelectionListener(onResetEnvVars()); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(btnResetAll)).notUpdatingParticipant() //This may look like a hack, but this property do change at each change to variables, so that button refresh will be consistent. .to(BeanProperties.value(IDeploymentConfigPageModel.PROPERTY_SELECTED_ENVIRONMENT_VARIABLE) .observe(model)) .converting(new IsNotNull2BooleanConverter() { @Override public Object convert(Object fromObject) { List<EnvironmentVariable> vars = model.getEnvironmentVariables(); return vars != null && !vars.isEmpty() && vars.stream() .anyMatch(v -> !v.isNew() && model.isEnvironmentVariableModified(v)); } }).in(dbc); UIUtils.setDefaultButtonWidth(btnResetAll); Button btnRemove = new Button(envContainer, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).applyTo(btnRemove); btnRemove.setText("Remove"); btnRemove.setToolTipText("Remove the environment variable added here."); btnRemove.addSelectionListener(onRemoveEnvVar()); ValueBindingBuilder .bind(WidgetProperties.enabled().observe(btnRemove)).notUpdatingParticipant().to(BeanProperties .value(IDeploymentConfigPageModel.PROPERTY_SELECTED_ENVIRONMENT_VARIABLE).observe(model)) .converting(new IsNotNull2BooleanConverter() { @Override public Object convert(Object fromObject) { Boolean notNull = (Boolean) super.convert(fromObject); return notNull && (canDeleteAnyVar || ((EnvironmentVariable) fromObject).isNew()) && !model.isEnvironmentVariableDeleted((EnvironmentVariable) fromObject); } }).in(dbc); UIUtils.setDefaultButtonWidth(btnRemove); }
From source file:org.jboss.tools.openshift.internal.ui.wizard.common.ResourceLabelsPage.java
License:Open Source License
@Override protected void doCreateControls(Composite container, DataBindingContext dbc) { GridLayoutFactory.fillDefaults().margins(10, 10).applyTo(container); org.eclipse.swt.widgets.Label lblLabel = new org.eclipse.swt.widgets.Label(container, SWT.NONE); lblLabel.setText("Labels"); Composite labelsGroup = new Composite(container, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(labelsGroup); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(labelsGroup); Composite tableContainer = new Composite(labelsGroup, SWT.NONE); this.viewer = createTable(tableContainer); GridDataFactory.fillDefaults().span(1, 5).align(SWT.FILL, SWT.FILL).grab(true, true) .applyTo(tableContainer);//from w ww.j a va2 s . c o m ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(viewer)) .to(BeanProperties.value(IResourceLabelsPageModel.PROPERTY_SELECTED_LABEL).observe(model)).in(dbc); viewer.setContentProvider(new ObservableListContentProvider()); viewer.setInput(BeanProperties.list(IResourceLabelsPageModel.PROPERTY_LABELS).observe(model)); Button addButton = new Button(labelsGroup, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(addButton); addButton.setText("Add..."); addButton.addSelectionListener(onAdd()); UIUtils.setDefaultButtonWidth(addButton); Button editExistingButton = new Button(labelsGroup, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(editExistingButton); editExistingButton.setText("Edit..."); editExistingButton.addSelectionListener(onEdit()); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(editExistingButton)).notUpdatingParticipant() .to(BeanProperties.value(IResourceLabelsPageModel.PROPERTY_SELECTED_LABEL).observe(model)) .converting(new IsNotNullOrReadOnlyBooleanConverter()).in(dbc); UIUtils.setDefaultButtonWidth(editExistingButton); Button removeButton = new Button(labelsGroup, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(removeButton); removeButton.setText("Remove..."); removeButton.addSelectionListener(onRemove()); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(removeButton)).notUpdatingParticipant() .to(BeanProperties.value(IResourceLabelsPageModel.PROPERTY_SELECTED_LABEL).observe(model)) .converting(new IsNotNullOrReadOnlyBooleanConverter()).in(dbc); UIUtils.setDefaultButtonWidth(removeButton); }
From source file:org.jboss.tools.openshift.internal.ui.wizard.deployimage.DeployImagePage.java
License:Open Source License
private void createImageNameControls(final Composite parent, final DataBindingContext dbc) { //Image//from w ww . jav a2 s.co m final Label imageNameLabel = new Label(parent, SWT.NONE); imageNameLabel.setText("Image Name: "); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(imageNameLabel); final Text imageNameText = new Text(parent, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(imageNameText); final IObservableValue<String> imageNameTextObservable = WidgetProperties.text(SWT.Modify) .observeDelayed(500, imageNameText); final IObservableValue<String> imageNameObservable = BeanProperties .value(IDeployImagePageModel.PROPERTY_IMAGE_NAME).observe(model); Binding imageBinding = ValueBindingBuilder.bind(imageNameTextObservable) .converting(new TrimmingStringConverter()).validatingAfterConvert(new DockerImageValidator()) .to(imageNameObservable).in(dbc); ControlDecorationSupport.create(imageBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true)); imageNameProposalAdapter = new ContentProposalAdapter(imageNameText, // override the text value before content assist was invoked and // move the cursor to the end of the selected value new TextContentAdapter() { @Override public void insertControlContents(Control control, String text, int cursorPosition) { final Text imageNameText = (Text) control; final Point selection = imageNameText.getSelection(); imageNameText.setText(text); selection.x = text.length(); selection.y = selection.x; imageNameText.setSelection(selection); } }, getImageNameContentProposalProvider(imageNameText), null, null); // List local Docker images Button btnDockerBrowse = new Button(parent, SWT.NONE); btnDockerBrowse.setText("Browse..."); btnDockerBrowse.setToolTipText("Look-up an image by browsing the Docker daemon"); btnDockerBrowse.addSelectionListener(onBrowseImage()); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(btnDockerBrowse); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(btnDockerBrowse)).notUpdatingParticipant() .to(BeanProperties.value(IDeployImagePageModel.PROPERTY_DOCKER_CONNECTION).observe(model)) .converting(new IsNotNull2BooleanConverter()).in(dbc); // search on Docker registry (Docker Hub) Button btnDockerSearch = new Button(parent, SWT.NONE); btnDockerSearch.setText("Search..."); btnDockerSearch.setToolTipText("Search an image on the Docker registry"); btnDockerSearch.addSelectionListener(onSearchImage(imageNameText)); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(btnDockerSearch); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(btnDockerSearch)).notUpdatingParticipant() .to(BeanProperties.value(IDeployImagePageModel.PROPERTY_DOCKER_CONNECTION).observe(model)) .converting(new IsNotNull2BooleanConverter()).in(dbc); }
From source file:org.jboss.tools.openshift.internal.ui.wizard.deployimage.DeployImagePage.java
License:Open Source License
@SuppressWarnings("unchecked") private void createPushToRegistrySettings(final Composite parent, final DataBindingContext dbc) { // checkbox/*from w w w . j a v a 2s . c o m*/ final Button pushImageToRegistryButton = new Button(parent, SWT.CHECK); pushImageToRegistryButton.setText("Push Image to Registry"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(NUM_COLUMS, 1) .applyTo(pushImageToRegistryButton); final IObservableValue<Boolean> pushImageToRegistryButtonObservable = BeanProperties .value(IDeployImagePageModel.PROPERTY_PUSH_IMAGE_TO_REGISTRY).observe(model); ValueBindingBuilder.bind(WidgetProperties.selection().observe(pushImageToRegistryButton)) .to(pushImageToRegistryButtonObservable).in(dbc); // registry location final Label registryLocationLabel = new Label(parent, SWT.NONE); registryLocationLabel.setText("Image Registry URL:"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).indent(30, 0) .applyTo(registryLocationLabel); final Text registryLocationText = new Text(parent, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(NUM_COLUMS - 1, 1) .applyTo(registryLocationText); final IObservableValue<String> registryLocationObservable = BeanProperties .value(IDeployImagePageModel.PROPERTY_TARGET_REGISTRY_LOCATION).observe(model); ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(registryLocationText)) .to(registryLocationObservable).in(dbc); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(registryLocationText)) .to(pushImageToRegistryButtonObservable).in(dbc); // username to authenticate on registry final Label registryUsernameLabel = new Label(parent, SWT.NONE); registryUsernameLabel.setText("Username:"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).indent(30, 0) .applyTo(registryUsernameLabel); final Text registryUsernameText = new Text(parent, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(NUM_COLUMS - 1, 1) .applyTo(registryUsernameText); final IObservableValue<String> registryUsernameObservable = BeanProperties .value(IDeployImagePageModel.PROPERTY_TARGET_REGISTRY_USERNAME).observe(model); ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(registryUsernameText)) .to(registryUsernameObservable).in(dbc); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(registryUsernameText)) .to(pushImageToRegistryButtonObservable).in(dbc); // password to authenticate on registry final Label registryPasswordLabel = new Label(parent, SWT.NONE); registryPasswordLabel.setText("Password:"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).indent(30, 0) .applyTo(registryPasswordLabel); final Text registryPasswordText = new Text(parent, SWT.BORDER + SWT.PASSWORD); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(NUM_COLUMS - 1, 1) .applyTo(registryPasswordText); final IObservableValue<String> registryPasswordObservable = BeanProperties .value(IDeployImagePageModel.PROPERTY_TARGET_REGISTRY_PASSWORD).observe(model); ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(registryPasswordText)) .to(registryPasswordObservable).in(dbc); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(registryPasswordText)) .to(pushImageToRegistryButtonObservable).in(dbc); // validation final PushImageToRegistryStatusProvider validator = new PushImageToRegistryStatusProvider( pushImageToRegistryButtonObservable, registryLocationObservable, registryUsernameObservable, registryPasswordObservable); dbc.addValidationStatusProvider(validator); }
From source file:org.jboss.tools.openshift.internal.ui.wizard.deployimage.ServicesAndRoutingPage.java
License:Open Source License
private void createExposedPortsControl(Composite parent, DataBindingContext dbc) { Composite container = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(container); GridLayoutFactory.fillDefaults().numColumns(2).margins(6, 6).applyTo(container); Label label = new Label(container, SWT.NONE); label.setText("Service Ports:"); label.setToolTipText("The exposed ports of the image."); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(2, 1).applyTo(label); Composite tableContainer = new Composite(container, SWT.NONE); portsViewer = createTable(tableContainer); GridDataFactory.fillDefaults().span(1, 5).align(SWT.FILL, SWT.FILL).grab(true, true) .applyTo(tableContainer);/*from w w w.j a va 2s . co m*/ ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(portsViewer)) .to(BeanProperties.value(IServiceAndRoutingPageModel.PROPERTY_SELECTED_SERVICE_PORT).observe(model)) .in(dbc); portsViewer.setContentProvider(new ObservableListContentProvider()); IObservableList portsObservable = BeanProperties.list(IServiceAndRoutingPageModel.PROPERTY_SERVICE_PORTS) .observe(model); portsViewer.setInput(portsObservable); dbc.addValidationStatusProvider(new MultiValidator() { @Override protected IStatus validate() { if (portsObservable.isEmpty()) { return ValidationStatus.error( "At least 1 port is required when generating the service for the deployed image"); } return Status.OK_STATUS; } }); Button btnAdd = new Button(container, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(btnAdd); btnAdd.setText("Add..."); btnAdd.setToolTipText( "Add a port to be exposed by the service which is not explicilty declared by the image."); btnAdd.addSelectionListener(onAdd()); UIUtils.setDefaultButtonWidth(btnAdd); Button btnEdit = new Button(container, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(btnEdit); btnEdit.setText("Edit..."); btnEdit.setToolTipText("Edit a port to be exposed by the service."); btnEdit.addSelectionListener(new EditHandler()); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(btnEdit)).notUpdatingParticipant() .to(BeanProperties.value(IServiceAndRoutingPageModel.PROPERTY_SELECTED_SERVICE_PORT).observe(model)) .converting(new IsNotNull2BooleanConverter()).in(dbc); UIUtils.setDefaultButtonWidth(btnEdit); Button removeButton = new Button(container, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(removeButton); removeButton.setText("Remove..."); removeButton.setToolTipText("Remove a port that will be exposed by the service."); removeButton.addSelectionListener(onRemove()); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(removeButton)).notUpdatingParticipant() .to(BeanProperties.value(IServiceAndRoutingPageModel.PROPERTY_SELECTED_SERVICE_PORT).observe(model)) .converting(new IsNotNull2BooleanConverter()).in(dbc); UIUtils.setDefaultButtonWidth(removeButton); Button btnReset = new Button(container, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(btnReset); btnReset.setText("Reset"); btnReset.setToolTipText("Resets the list of ports to the exposed ports of the image."); btnReset.addSelectionListener(onReset()); UIUtils.setDefaultButtonWidth(btnReset); }
From source file:org.jboss.tools.openshift.internal.ui.wizard.importapp.GitCloningWizardPage.java
License:Open Source License
private Composite createCloneGroup(Composite parent, DataBindingContext dbc) { Group cloneGroup = new Group(parent, SWT.NONE); cloneGroup.setText("Cloning settings"); cloneGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).margins(10, 10).applyTo(cloneGroup); Composite composite = new Composite(cloneGroup, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(composite); GridLayoutFactory.fillDefaults().numColumns(3).margins(15, 15).applyTo(composite); // Repo Path Management useDefaultRepoPathButton = new Button(composite, SWT.CHECK); useDefaultRepoPathButton.setText("Use default clone destination"); useDefaultRepoPathButton.setToolTipText("Uncheck if you want to use a custom location to clone to"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(3, 1).applyTo(useDefaultRepoPathButton); Label labelForRepoPath = new Label(composite, SWT.NONE); labelForRepoPath.setText("Git Clone Location:"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).grab(false, false).indent(10, 0) .applyTo(labelForRepoPath);/* w ww .java2 s . c o m*/ final Text repoPathText = new Text(composite, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).align(SWT.FILL, SWT.CENTER).grab(true, false) .applyTo(repoPathText); final IObservableValue repoPathObservable = WidgetProperties.text(SWT.Modify).observe(repoPathText); final IObservableValue repoPathModelObservable = BeanProperties .value(IGitCloningPageModel.PROPERTY_REPOSITORY_PATH).observe(model); ValueBindingBuilder.bind(repoPathObservable).to(repoPathModelObservable).in(dbc); Button browseRepoPathButton = new Button(composite, SWT.PUSH); browseRepoPathButton.setText("Browse..."); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT) .applyTo(browseRepoPathButton); browseRepoPathButton.addSelectionListener(onRepoPath()); final IObservableValue isDefaultRepoObservable = WidgetProperties.selection() .observe(useDefaultRepoPathButton); final IObservableValue useDefaultRepoModelObservable = BeanProperties .value(IGitCloningPageModel.PROPERTY_USE_DEFAULT_REPOSITORY_PATH).observe(model); ValueBindingBuilder.bind(isDefaultRepoObservable).to(useDefaultRepoModelObservable).in(dbc); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(repoPathText)) .notUpdating(useDefaultRepoModelObservable).converting(new InvertingBooleanConverter()).in(dbc); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(browseRepoPathButton)) .notUpdating(useDefaultRepoModelObservable).converting(new InvertingBooleanConverter()).in(dbc); // move focus to the project location text control when not choosing the // 'Use default location' option. UIUtils.focusOnSelection(useDefaultRepoPathButton, repoPathText); // Skip clone skipCloneOnlyImportButton = new Button(composite, SWT.CHECK); skipCloneOnlyImportButton.setSelection(false); skipCloneOnlyImportButton.setText("Reuse existing repository"); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(3, 1).applyTo(skipCloneOnlyImportButton); final IObservableValue skipCloneObservable = WidgetProperties.selection() .observe(skipCloneOnlyImportButton); final IObservableValue skipCloneModelObservable = BeanProperties .value(IGitCloningPageModel.PROPERTY_SKIP_CLONE_ONLY_IMPORT).observe(model); skipCloneOnlyImportButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { model.setSkipClone(skipCloneOnlyImportButton.getSelection()); } }); IObservableValue projectNameObservable = BeanProperties.value(IGitCloningPageModel.PROPERTY_PROJECT_NAME) .observe(model); this.repoPathValidator = new RepoPathValidationStatusProvider(repoPathObservable, projectNameObservable, skipCloneObservable); dbc.addValidationStatusProvider(repoPathValidator); ControlDecorationSupport.create(repoPathValidator, SWT.LEFT | SWT.TOP); return cloneGroup; }
From source file:org.jboss.tools.openshift.internal.ui.wizard.newapp.fromtemplate.TemplateParametersPage.java
License:Open Source License
@Override protected void doCreateControls(Composite container, DataBindingContext dbc) { GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).applyTo(container); // parameters table Composite tableContainer = new Composite(container, SWT.NONE); IObservableList<IParameter> parametersObservable = BeanProperties .list(ITemplateParametersPageModel.PROPERTY_PARAMETERS).observe(model); this.viewer = createTable(tableContainer, parametersObservable, dbc); GridDataFactory.fillDefaults().span(1, 5).align(SWT.FILL, SWT.FILL).grab(true, true).hint(500, 300) .applyTo(tableContainer);// w ww . ja v a 2s . c o m viewer.setInput(parametersObservable); IObservableValue<IParameter> selectedParameter = BeanProperties .value(ITemplateParametersPageModel.PROPERTY_SELECTED_PARAMETER).observe(model); ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(viewer)).to(selectedParameter).in(dbc); viewer.addDoubleClickListener(onDoubleClick()); // edit button Button editExistingButton = new Button(container, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(editExistingButton); editExistingButton.setText("Edit..."); UIUtils.setDefaultButtonWidth(editExistingButton); editExistingButton.addSelectionListener(onEdit()); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(editExistingButton)).notUpdatingParticipant() .to(selectedParameter).converting(new IsNotNull2BooleanConverter()).in(dbc); // reset button Button resetButton = new Button(container, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(resetButton); resetButton.setText("Reset"); UIUtils.setDefaultButtonWidth(resetButton); resetButton.addSelectionListener(onReset()); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(resetButton)).notUpdatingParticipant() .to(selectedParameter).converting(new IsNotNull2BooleanConverter() { @Override public Object convert(Object fromObject) { return fromObject instanceof IParameter && ((ApplicationSourceFromTemplateModel) model) .isParameterModified((IParameter) fromObject); } }).in(dbc); // reset all button Button resetAllButton = new Button(container, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(resetAllButton); resetAllButton.setText("Reset All"); UIUtils.setDefaultButtonWidth(resetAllButton); resetAllButton.addSelectionListener(onResetAll()); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(resetAllButton)).notUpdatingParticipant() .to(selectedParameter).converting(new IsNotNull2BooleanConverter() { @Override public Object convert(Object fromObject) { return model.getParameters().stream() .anyMatch(p -> ((ApplicationSourceFromTemplateModel) model).isParameterModified(p)); } }).in(dbc); // required explanation Label requiredExplanationLabel = new Label(container, SWT.None); requiredExplanationLabel .setText("* = value required, click the 'Edit...' button or double-click on a value to edit it."); GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.FILL).span(2, 1) .applyTo(requiredExplanationLabel); // selected parameter details final Group detailsContainer = new Group(container, SWT.NONE); detailsContainer.setText("Details"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(2, 1).hint(SWT.DEFAULT, 106) .applyTo(detailsContainer); new TemplateParameterDetailViews(selectedParameter, detailsContainer, dbc).createControls(); ((ApplicationSourceFromTemplateModel) model).addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (ApplicationSourceFromTemplateModel.PROPERTY_MODIFIED_PARAMETER.equals(evt.getPropertyName())) { viewer.refresh(evt.getNewValue()); } } }); }
From source file:org.jboss.tools.openshift.internal.ui.wizard.newapp.ResourceLabelsPage.java
License:Open Source License
@Override protected void doCreateControls(Composite container, DataBindingContext dbc) { GridLayoutFactory.fillDefaults().margins(10, 10).applyTo(container); Group labelsGroup = new Group(container, SWT.NONE); labelsGroup.setText("Labels"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(labelsGroup); GridLayoutFactory.fillDefaults().numColumns(2).margins(6, 6).applyTo(labelsGroup); Composite tableContainer = new Composite(labelsGroup, SWT.NONE); this.viewer = createTable(tableContainer); GridDataFactory.fillDefaults().span(1, 5).align(SWT.FILL, SWT.FILL).grab(true, true) .applyTo(tableContainer);// ww w . j a v a 2 s. com ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(viewer)) .to(BeanProperties.value(IResourceLabelsPageModel.PROPERTY_SELECTED_LABEL).observe(model)).in(dbc); viewer.setContentProvider(new ObservableListContentProvider()); viewer.setInput(BeanProperties.list(IResourceLabelsPageModel.PROPERTY_LABELS).observe(model)); Button addButton = new Button(labelsGroup, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(addButton); addButton.setText("Add"); addButton.addSelectionListener(onAdd()); Button editExistingButton = new Button(labelsGroup, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(editExistingButton); editExistingButton.setText("Edit"); editExistingButton.addSelectionListener(onEdit()); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(editExistingButton)).notUpdatingParticipant() .to(BeanProperties.value(IResourceLabelsPageModel.PROPERTY_SELECTED_LABEL).observe(model)) .converting(new IsNotNullOrReadOnlyBooleanConverter()).in(dbc); Button removeButton = new Button(labelsGroup, SWT.PUSH); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(removeButton); removeButton.setText("Remove"); removeButton.addSelectionListener(onRemove()); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(removeButton)).notUpdatingParticipant() .to(BeanProperties.value(IResourceLabelsPageModel.PROPERTY_SELECTED_LABEL).observe(model)) .converting(new IsNotNullOrReadOnlyBooleanConverter()).in(dbc); }
From source file:org.jboss.tools.openshift.internal.ui.wizard.newapp.TemplateListPage.java
License:Open Source License
private void createDetailsGroup(Composite parent, DataBindingContext dbc) { // details//from ww w .java 2s . c om Group detailsGroup = new Group(parent, SWT.NONE); detailsGroup.setText("Template details"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).span(3, 1).hint(SWT.DEFAULT, 106) .applyTo(detailsGroup); GridLayoutFactory.fillDefaults().margins(10, 6).spacing(2, 2) //TODO fix margins .applyTo(detailsGroup); Composite detailsContainer = new Composite(detailsGroup, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(detailsContainer); new TemplateDetailViews( BeanProperties.value(ITemplateListPageModel.PROPERTY_SELECTED_TEMPLATE).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(ITemplateListPageModel.PROPERTY_SELECTED_TEMPLATE) .observe(model); ValueBindingBuilder.bind(WidgetProperties.enabled().observe(btnDetails)).notUpdatingParticipant() .to(selectedTemplate).converting(new IsNotNull2BooleanConverter()).in(dbc); btnDetails.addSelectionListener(onDefinedResourcesClicked()); }