Search in sources :

Example 1 with KeyValueWizardModelBuilder

use of org.jboss.tools.openshift.internal.common.ui.wizard.KeyValueWizardModelBuilder 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)

Example 2 with KeyValueWizardModelBuilder

use of org.jboss.tools.openshift.internal.common.ui.wizard.KeyValueWizardModelBuilder in project jbosstools-openshift by jbosstools.

the class ResourceLabelsPage method onAdd.

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            IKeyValueWizardModel<Label> dialogModel = new KeyValueWizardModelBuilder<Label>().windowTitle(RESOURCE_LABEL).title("Add Label").description("Add a resource label.").keyLabel(LABEL_KEY).keyDescription(LabelKeyValidator.keyDescription).valueDescription(NLS.bind(LabelValueValidator.valueDescription, LabelValueValidator.defaultType)).groupLabel(LABEL_GROUP).keyAfterConvertValidator(new LabelKeyValidator(model.getReadOnlyLabels(), getUsedKeys())).valueAfterConvertValidator(new LabelValueValidator()).build();
            OkCancelButtonWizardDialog dialog = new OkCancelButtonWizardDialog(getShell(), new KeyValueWizard<>(UIUtils.getFirstElement(viewer.getSelection(), Label.class), dialogModel));
            if (OkCancelButtonWizardDialog.OK == dialog.open()) {
                model.addLabel(dialogModel.getKey(), dialogModel.getValue());
            }
        }
    };
}
Also used : KeyValueWizardModelBuilder(org.jboss.tools.openshift.internal.common.ui.wizard.KeyValueWizardModelBuilder) LabelValueValidator(org.jboss.tools.openshift.internal.ui.validator.LabelValueValidator) LabelKeyValidator(org.jboss.tools.openshift.internal.ui.validator.LabelKeyValidator) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Label(org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label) OkCancelButtonWizardDialog(org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog)

Example 3 with KeyValueWizardModelBuilder

use of org.jboss.tools.openshift.internal.common.ui.wizard.KeyValueWizardModelBuilder in project jbosstools-openshift by jbosstools.

the class ResourceLabelsPage method editLabel.

private void editLabel(Label label) {
    if (label == null || isReadOnly(label)) {
        return;
    }
    Set<String> usedKeys = getUsedKeys();
    usedKeys.remove(label.getKey());
    IKeyValueWizardModel<Label> dialogModel = new KeyValueWizardModelBuilder<>(label).windowTitle(RESOURCE_LABEL).title("Edit Label").description("Edit the resource label.").keyLabel(LABEL_KEY).keyDescription(LabelKeyValidator.keyDescription).valueDescription(NLS.bind(LabelValueValidator.valueDescription, LabelValueValidator.defaultType)).groupLabel(LABEL_GROUP).keyAfterConvertValidator(new LabelKeyValidator(model.getReadOnlyLabels(), usedKeys)).valueAfterConvertValidator(new LabelValueValidator()).build();
    OkCancelButtonWizardDialog dialog = new OkCancelButtonWizardDialog(getShell(), new KeyValueWizard<>(label, dialogModel));
    if (OkCancelButtonWizardDialog.OK == dialog.open()) {
        model.updateLabel(label, dialogModel.getKey(), dialogModel.getValue());
    }
}
Also used : KeyValueWizardModelBuilder(org.jboss.tools.openshift.internal.common.ui.wizard.KeyValueWizardModelBuilder) LabelValueValidator(org.jboss.tools.openshift.internal.ui.validator.LabelValueValidator) LabelKeyValidator(org.jboss.tools.openshift.internal.ui.validator.LabelKeyValidator) Label(org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label) StyledString(org.eclipse.jface.viewers.StyledString) OkCancelButtonWizardDialog(org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog)

Aggregations

KeyValueWizardModelBuilder (org.jboss.tools.openshift.internal.common.ui.wizard.KeyValueWizardModelBuilder)3 OkCancelButtonWizardDialog (org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 LabelKeyValidator (org.jboss.tools.openshift.internal.ui.validator.LabelKeyValidator)2 LabelValueValidator (org.jboss.tools.openshift.internal.ui.validator.LabelValueValidator)2 Label (org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label)2 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