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());
}
}
};
}
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());
}
}
};
}
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());
}
}
Aggregations