Search in sources :

Example 1 with EnvironmentVarKeyValidator

use of org.jboss.tools.openshift.internal.ui.validator.EnvironmentVarKeyValidator in project jbosstools-openshift by jbosstools.

the class EnvironmentVariablePage method onAdd.

private SelectionListener onAdd() {
    return new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Set<String> usedKeys = model.getEnvironmentVariables().stream().filter(v -> !model.isEnvironmentVariableDeleted(v)).map(v -> v.getKey()).collect(Collectors.toSet());
            IKeyValueWizardModel<KeyValueItem> dialogModel = new KeyValueWizardModelBuilder<KeyValueItem>().windowTitle(ENVIRONMENT_VARIABLE_LABEL).title("Add " + ENVIRONMENT_VARIABLE_LABEL).description(NLS.bind("Add an {0}.", ENVIRONMENT_VARIABLE_LABEL.toLowerCase())).keyLabel(ENVIRONMENT_VARIABLE_KEY_LABEL).groupLabel(ENVIRONMENT_VARIABLE_LABEL).keyAfterConvertValidator(new EnvironmentVarKeyValidator(usedKeys)).build();
            OkCancelButtonWizardDialog dialog = new OkCancelButtonWizardDialog(getShell(), new KeyValueWizard<>(dialogModel));
            if (OkCancelButtonWizardDialog.OK == dialog.open()) {
                model.addEnvironmentVariable(dialogModel.getKey(), dialogModel.getValue());
                selectEnvVarByKey(dialogModel.getKey());
            }
        }
    };
}
Also used : EnvironmentVarKeyValidator(org.jboss.tools.openshift.internal.ui.validator.EnvironmentVarKeyValidator) TableViewer(org.eclipse.jface.viewers.TableViewer) IWizard(org.eclipse.jface.wizard.IWizard) DataBindingContext(org.eclipse.core.databinding.DataBindingContext) ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) Table(org.eclipse.swt.widgets.Table) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IColumnLabelProvider(org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder.IColumnLabelProvider) TableViewerBuilder(org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder) WidgetProperties(org.eclipse.jface.databinding.swt.WidgetProperties) UIUtils(org.jboss.tools.openshift.internal.common.ui.utils.UIUtils) KeyValueWizard(org.jboss.tools.openshift.internal.common.ui.wizard.KeyValueWizard) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ValueBindingBuilder(org.jboss.tools.common.ui.databinding.ValueBindingBuilder) KeyValueItem(org.jboss.tools.openshift.internal.common.ui.wizard.KeyValueItem) IDeploymentConfigPageModel(org.jboss.tools.openshift.internal.ui.wizard.deployimage.IDeploymentConfigPageModel) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) AbstractOpenShiftWizardPage(org.jboss.tools.openshift.internal.common.ui.wizard.AbstractOpenShiftWizardPage) IKeyValueItem(org.jboss.tools.openshift.internal.common.ui.wizard.IKeyValueItem) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Viewer(org.eclipse.jface.viewers.Viewer) Button(org.eclipse.swt.widgets.Button) NLS(org.eclipse.osgi.util.NLS) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) Set(java.util.Set) ViewerProperties(org.eclipse.jface.databinding.viewers.ViewerProperties) Collectors(java.util.stream.Collectors) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) List(java.util.List) IKeyValueWizardModel(org.jboss.tools.openshift.internal.common.ui.wizard.IKeyValueWizardModel) KeyValueWizardModelBuilder(org.jboss.tools.openshift.internal.common.ui.wizard.KeyValueWizardModelBuilder) BeanProperties(org.eclipse.core.databinding.beans.BeanProperties) SWT(org.eclipse.swt.SWT) IsNotNull2BooleanConverter(org.jboss.tools.openshift.internal.common.ui.databinding.IsNotNull2BooleanConverter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) OkCancelButtonWizardDialog(org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog) Label(org.eclipse.swt.widgets.Label) SelectionListener(org.eclipse.swt.events.SelectionListener) KeyValueItem(org.jboss.tools.openshift.internal.common.ui.wizard.KeyValueItem) IKeyValueItem(org.jboss.tools.openshift.internal.common.ui.wizard.IKeyValueItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) EnvironmentVarKeyValidator(org.jboss.tools.openshift.internal.ui.validator.EnvironmentVarKeyValidator) OkCancelButtonWizardDialog(org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog)

Aggregations

List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 DataBindingContext (org.eclipse.core.databinding.DataBindingContext)1 BeanProperties (org.eclipse.core.databinding.beans.BeanProperties)1 WidgetProperties (org.eclipse.jface.databinding.swt.WidgetProperties)1 ObservableListContentProvider (org.eclipse.jface.databinding.viewers.ObservableListContentProvider)1 ViewerProperties (org.eclipse.jface.databinding.viewers.ViewerProperties)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 GridDataFactory (org.eclipse.jface.layout.GridDataFactory)1 GridLayoutFactory (org.eclipse.jface.layout.GridLayoutFactory)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1 IWizard (org.eclipse.jface.wizard.IWizard)1 NLS (org.eclipse.osgi.util.NLS)1 SWT (org.eclipse.swt.SWT)1