use of org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater in project jbosstools-openshift by jbosstools.
the class BuildConfigWizardPage method doCreateControls.
@Override
protected void doCreateControls(Composite parent, DataBindingContext dbc) {
GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(parent);
GridLayoutFactory.fillDefaults().applyTo(parent);
Group buildConfigsGroup = new Group(parent, SWT.NONE);
buildConfigsGroup.setText("Existing Build Configs:");
GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).applyTo(buildConfigsGroup);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(buildConfigsGroup);
// build configs tree
TreeViewer buildConfigsViewer = createBuildConfigsViewer(new Tree(buildConfigsGroup, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL), model, dbc);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(SWT.DEFAULT, 200).span(1, 2).applyTo(buildConfigsViewer.getControl());
final IObservableValue selectedItem = BeanProperties.value(IBuildConfigPageModel.PROPERTY_SELECTED_ITEM).observe(model);
Binding selectedBuildConfigBinding = ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(buildConfigsViewer)).converting(new ObservableTreeItem2ModelConverter()).to(selectedItem).converting(new Model2ObservableTreeItemConverter()).in(dbc);
dbc.addValidationStatusProvider(new MultiValidator() {
@Override
protected IStatus validate() {
if (!(selectedItem.getValue() instanceof IBuildConfig)) {
return ValidationStatus.cancel("Please select the existing build config that you want to import");
} else {
return ValidationStatus.ok();
}
}
});
IObservableValue connectionObservable = BeanProperties.value(IBuildConfigPageModel.PROPERTY_CONNECTION).observe(model);
DataBindingUtils.addDisposableValueChangeListener(onConnectionChanged(buildConfigsViewer, model), connectionObservable, buildConfigsViewer.getTree());
ControlDecorationSupport.create(selectedBuildConfigBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
// refresh button
Button refreshButton = new Button(buildConfigsGroup, SWT.PUSH);
refreshButton.setText("&Refresh");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(100, SWT.DEFAULT).applyTo(refreshButton);
refreshButton.addSelectionListener(onRefresh(buildConfigsViewer, model));
// filler
Label fillerLabel = new Label(buildConfigsGroup, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(false, true).applyTo(fillerLabel);
// details
ExpandableComposite expandable = new ExpandableComposite(buildConfigsGroup, SWT.None);
GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, false).hint(SWT.DEFAULT, 150).applyTo(expandable);
expandable.setText("Build config Details");
expandable.setExpanded(true);
GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).spacing(0, 0).applyTo(expandable);
GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, false).hint(SWT.DEFAULT, 150).applyTo(expandable);
Composite detailsContainer = new Composite(expandable, SWT.NONE);
GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, false).hint(SWT.DEFAULT, 150).applyTo(detailsContainer);
IObservableValue selectedService = new WritableValue();
ValueBindingBuilder.bind(selectedItem).to(selectedService).notUpdatingParticipant().in(dbc);
new BuildConfigDetailViews(selectedService, detailsContainer, dbc).createControls();
expandable.setClient(detailsContainer);
expandable.addExpansionListener(new IExpansionListener() {
@Override
public void expansionStateChanging(ExpansionEvent e) {
}
@Override
public void expansionStateChanged(ExpansionEvent e) {
buildConfigsGroup.update();
buildConfigsGroup.layout(true);
}
});
loadBuildConfigs(model);
}
use of org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater in project jbosstools-openshift by jbosstools.
the class KeyValueWizardPage method doCreateControls.
@Override
protected void doCreateControls(Composite parent, DataBindingContext dbc) {
GridLayoutFactory.fillDefaults().margins(10, 10).applyTo(parent);
Group group = new Group(parent, SWT.NONE);
group.setText(model.getGroupLabel());
group.setLayout(new GridLayout());
GridDataFactory.fillDefaults().hint(KEYVALUE_GROUP_WIDTH, SWT.DEFAULT).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(group);
Composite composite = new Composite(group, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(composite);
GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).applyTo(composite);
Label nameLabel = new Label(composite, SWT.NONE);
// $NON-NLS-1$
nameLabel.setText(model.getKeyLabel() + ":");
if (model.getKeyDescription() != null) {
nameLabel.setToolTipText(model.getKeyDescription());
}
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(nameLabel);
Text keyText = new Text(composite, SWT.BORDER);
keyText.setEditable(model.isKeyEditable());
IObservableValue<String> keyTextObservable = WidgetProperties.text(SWT.Modify).observe(keyText);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(keyText);
Binding keyBinding = ValueBindingBuilder.bind(keyTextObservable).validatingAfterConvert(model.getKeyAfterConvertValidator()).to(BeanProperties.value(IKeyValueWizardModel.PROPERTY_KEY).observe(model)).in(dbc);
ControlDecorationSupport.create(keyBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
Label valueLabel = new Label(composite, SWT.NONE);
// $NON-NLS-1$
valueLabel.setText(model.getValueLabel() + ":");
if (model.getValueDescription() != null) {
valueLabel.setToolTipText(model.getValueDescription());
}
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(valueLabel);
Text valueText = new Text(composite, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(valueText);
IObservableValue<String> valueTextObservable = WidgetProperties.text(SWT.Modify).observe(valueText);
Binding valeuBinding = ValueBindingBuilder.bind(valueTextObservable).validatingAfterConvert(model.getValueAfterConvertValidator()).to(BeanProperties.value(IKeyValueWizardModel.PROPERTY_VALUE).observe(model)).in(dbc);
ControlDecorationSupport.create(valeuBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
if (!StringUtils.isEmpty(initialKey)) {
DataChangedValidator validator = new DataChangedValidator(keyTextObservable, valueTextObservable);
dbc.addValidationStatusProvider(validator);
}
initFocus(keyText, valueText);
}
use of org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater in project jbosstools-openshift by jbosstools.
the class DeployImagePage method createProjectControl.
private void createProjectControl(Composite parent, DataBindingContext dbc) {
Label lblProject = new Label(parent, SWT.NONE);
lblProject.setText("OpenShift Project: ");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(lblProject);
StructuredViewer cmboProject = new ComboViewer(parent);
GridDataFactory.fillDefaults().span(NUM_COLUMS - 2, 1).applyTo(cmboProject.getControl());
final OpenShiftExplorerLabelProvider labelProvider = new OpenShiftExplorerLabelProvider();
cmboProject.setContentProvider(new ObservableListContentProvider());
cmboProject.setLabelProvider(labelProvider);
cmboProject.setInput(BeanProperties.list(IDeployImagePageModel.PROPERTY_PROJECTS).observe(model));
ProjectViewerComparator comparator = new ProjectViewerComparator(labelProvider);
cmboProject.setComparator(comparator);
model.setProjectsComparator(comparator.asProjectComparator());
IObservableValue<IProject> projectObservable = BeanProperties.value(IDeployImagePageModel.PROPERTY_PROJECT).observe(model);
ProjectStatusProvider validator = new ProjectStatusProvider(projectObservable);
IObservableValue selectedProjectObservable = ViewerProperties.singleSelection().observe(cmboProject);
Binding selectedProjectBinding = ValueBindingBuilder.bind(selectedProjectObservable).converting(new ObservableTreeItem2ModelConverter(IProject.class)).validatingAfterConvert(validator).to(projectObservable).in(dbc);
ControlDecorationSupport.create(selectedProjectBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
Button newProjectButton = new Button(parent, SWT.PUSH);
newProjectButton.setText("New...");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(newProjectButton);
UIUtils.setDefaultButtonWidth(newProjectButton);
newProjectButton.addSelectionListener(onNewProjectClicked());
dbc.addValidationStatusProvider(validator);
cmboProject.getControl().forceFocus();
}
use of org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater in project jbosstools-openshift by jbosstools.
the class AdvancedConnectionEditor method createControls.
@SuppressWarnings("unchecked")
@Override
public Composite createControls(Composite parent, Object context, DataBindingContext dbc) {
this.pageModel = (ConnectionWizardPageModel) context;
this.selectedConnection = BeanProperties.value(ConnectionWizardPageModel.PROPERTY_SELECTED_CONNECTION).observe(pageModel);
this.model = new AdvancedConnectionEditorModel();
Composite composite = setControl(new Composite(parent, SWT.None));
GridLayoutFactory.fillDefaults().applyTo(composite);
DialogAdvancedPart part = new DialogAdvancedPart() {
@Override
protected void createAdvancedContent(Composite advancedComposite) {
Label lblRegistry = new Label(advancedComposite, SWT.NONE);
lblRegistry.setText("Image Registry URL:");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(lblRegistry);
Text txtRegistry = new Text(advancedComposite, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(1, 1).applyTo(txtRegistry);
Button registryDiscover = new Button(advancedComposite, SWT.PUSH);
registryDiscover.setText("Discover...");
registryDiscover.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
discoverRegistryPressed(registryDiscover.getShell());
}
});
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(registryDiscover);
UIUtils.setDefaultButtonWidth(registryDiscover);
registryURLObservable = WidgetProperties.text(SWT.Modify).observeDelayed(DELAY, txtRegistry);
Binding registryURLBinding = ValueBindingBuilder.bind(registryURLObservable).validatingAfterConvert(new URLValidator(VALIDATOR_URL_TYPE, true)).converting(new TrimTrailingSlashConverter()).to(BeanProperties.value(AdvancedConnectionEditorModel.PROP_REGISTRY_URL).observe(model)).in(dbc);
ControlDecorationSupport.create(registryURLBinding, SWT.LEFT | SWT.TOP);
Label lblNamespace = new Label(advancedComposite, SWT.NONE);
lblNamespace.setText("Cluster namespace:");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(lblNamespace);
Text txtClusterNamespace = new Text(advancedComposite, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(txtClusterNamespace);
clusterNamespaceObservable = WidgetProperties.text(SWT.Modify).observeDelayed(DELAY, txtClusterNamespace);
ValueBindingBuilder.bind(clusterNamespaceObservable).converting(new TrimmingStringConverter()).to(BeanProperties.value(AdvancedConnectionEditorModel.PROP_CLUSTER_NAMESPACE).observe(model)).in(dbc);
Link ocWorkspace = new Link(advancedComposite, SWT.PUSH);
ocWorkspace.setText("<a>Workspace OC Settings</a>");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(3, 1).applyTo(ocWorkspace);
// Override OC location widgets
Button overrideOC = new Button(advancedComposite, SWT.CHECK);
overrideOC.setText("Override 'oc' location: ");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(lblRegistry);
IObservableValue<Boolean> overrideOCObservable = WidgetProperties.selection().observe(overrideOC);
ValueBindingBuilder.bind(overrideOCObservable).to(BeanProperties.value(AdvancedConnectionEditorModel.PROP_OC_OVERRIDE).observe(model)).in(dbc);
final Text ocText = new Text(advancedComposite, SWT.SINGLE | SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(ocText);
IObservableValue<String> ocLocationObservable = WidgetProperties.text(SWT.Modify).observe(ocText);
Binding ocLocationBinding = ValueBindingBuilder.bind(ocLocationObservable).converting(new TrimmingStringConverter()).to(BeanProperties.value(AdvancedConnectionEditorModel.PROP_OC_OVERRIDE_LOCATION).observe(model)).in(dbc);
overrideOCObservable.addValueChangeListener(new IValueChangeListener<Boolean>() {
@Override
public void handleValueChange(ValueChangeEvent<? extends Boolean> event) {
updateOcObservables();
}
});
ocLocationBinding.getValidationStatus().addValueChangeListener(new IValueChangeListener<IStatus>() {
@Override
public void handleValueChange(ValueChangeEvent<? extends IStatus> event) {
updateOcObservables();
}
});
ValueBindingBuilder.bind(overrideOCObservable).to(WidgetProperties.enabled().observe(ocText)).notUpdatingParticipant().in(dbc);
Button ocBrowse = new Button(advancedComposite, SWT.PUSH);
ocBrowse.setText("Browse...");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(ocBrowse);
UIUtils.setDefaultButtonWidth(ocBrowse);
ocWorkspace.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
PreferenceDialog pd = PreferencesUtil.createPreferenceDialogOn(null, IOpenShiftCoreConstants.OPEN_SHIFT_PREFERENCE_PAGE_ID, new String[] {}, null);
pd.open();
if (!overrideOC.getSelection()) {
String ocLoc = OpenShiftCorePreferences.INSTANCE.getOCBinaryLocation();
String nullsafe = ocLoc == null ? "" : ocLoc;
ocText.setText(nullsafe);
}
updateOcObservables();
}
});
// Validation here is done via a listener rather than dbc validators
// because dbc validators will validate in the UI thread, but validation
// of this field requires a background job.
ocBrowse.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
FileDialog fd = new FileDialog(ocBrowse.getShell());
fd.setText(ocText.getText());
IPath p = new Path(ocText.getText());
if (p.segmentCount() > 1) {
fd.setFilterPath(p.removeLastSegments(1).toOSString());
}
String result = fd.open();
if (result != null) {
ocLocationObservable.setValue(result);
}
}
});
ValueBindingBuilder.bind(overrideOCObservable).to(WidgetProperties.enabled().observe(ocBrowse)).notUpdatingParticipant().in(dbc);
ValidationStatusProvider ocValidator = new MultiValidator() {
public IObservableList getTargets() {
WritableList targets = new WritableList();
targets.add(ocLocationObservable);
targets.add(ocLocationValidity);
targets.add(ocVersionValidity);
return targets;
}
@Override
protected IStatus validate() {
// access all observables that the framework should listen to
IStatus ocLocationStatus = ocLocationValidity.getValue();
IStatus ocVersionStatus = ocVersionValidity.getValue();
IStatus status;
if (!ocLocationStatus.isOK()) {
status = ocLocationStatus;
} else {
status = ocVersionStatus;
}
return status;
}
};
dbc.addValidationStatusProvider(ocValidator);
ControlDecorationSupport.create(ocValidator, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater());
}
protected GridLayoutFactory adjustAdvancedCompositeLayout(GridLayoutFactory gridLayoutFactory) {
return gridLayoutFactory.numColumns(3);
}
};
part.createAdvancedGroup(composite, 1);
this.connectionAdvancedPropertiesProvider = new ConnectionAdvancedPropertiesProvider();
updateOcObservables();
return composite;
}
use of org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater in project jbosstools-openshift by jbosstools.
the class BuildConfigPage method createSourceControls.
@SuppressWarnings({ "unchecked" })
private void createSourceControls(Composite root, DataBindingContext dbc) {
Composite parent = new Composite(root, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(parent);
GridLayoutFactory.fillDefaults().numColumns(3).applyTo(parent);
// url
Label gitUrlLabel = new Label(parent, SWT.NONE);
gitUrlLabel.setText("Git Repository URL:");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(gitUrlLabel);
final Text gitUrlText = new Text(parent, SWT.BORDER);
gitUrlText.setToolTipText("The URL to the Git repository.");
// TODO add 'try it' link here
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(gitUrlText);
Binding gitUrlBinding = ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observeDelayed(500, gitUrlText)).validatingAfterConvert(new IValidator() {
@Override
public IStatus validate(Object value) {
if (UrlUtils.isValid((String) value)) {
return Status.OK_STATUS;
}
return ValidationStatus.error("A valid URL to a Git repository is required");
}
}).to(BeanProperties.value(IBuildConfigPageModel.PROPERTY_GIT_REPOSITORY_URL).observe(model)).in(dbc);
ControlDecorationSupport.create(gitUrlBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
// reference
Label gitReferenceLabel = new Label(parent, SWT.NONE);
gitReferenceLabel.setText("Git Reference:");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(gitReferenceLabel);
gitReferenceLabel.setToolTipText("Optional branch, tag, or commit.");
final Text gitReferenceText = new Text(parent, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(gitReferenceText);
IObservableValue gitReferenceTextObservable = WidgetProperties.text(SWT.Modify).observe(gitReferenceText);
GitReferenceValidator validator = new GitReferenceValidator(gitReferenceTextObservable);
Binding gitReferenceBinding = ValueBindingBuilder.bind(gitReferenceTextObservable).validatingAfterConvert(validator).to(BeanProperties.value(IBuildConfigPageModel.PROPERTY_GIT_REFERENCE).observe(model)).in(dbc);
dbc.addValidationStatusProvider(validator);
ControlDecorationSupport.create(gitReferenceBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
// context dir
Label contextDirLabel = new Label(parent, SWT.NONE);
contextDirLabel.setText("Context Directory:");
contextDirLabel.setToolTipText("Optional subdirectory for the application source code, used as the context directory for the build.");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(contextDirLabel);
final Text contextDirText = new Text(parent, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(contextDirText);
ValueBindingBuilder.bind(WidgetProperties.text(SWT.Modify).observe(contextDirText)).to(BeanProperties.value(IBuildConfigPageModel.PROPERTY_CONTEXT_DIR).observe(model)).in(dbc);
}
Aggregations