use of com.redhat.devtools.intellij.tektoncd.ui.UIConstants.NO_BORDER in project intellij-tekton by redhat-developer.
the class WorkspacesStep method updateWorkspaceModel.
private void updateWorkspaceModel(JPanel panel, String workspaceName, Workspace.Kind kind, String resource) {
Workspace workspace = model.getWorkspaces().get(workspaceName);
boolean isOptional = workspace.isOptional();
if (kind == PVC) {
JComboBox cmbWorkspaceTypeValues = (JComboBox) Arrays.stream(panel.getComponents()).filter(component -> "cmbWorkspaceTypeValues".equals(component.getName())).findFirst().get();
String valueSelected = cmbWorkspaceTypeValues.getSelectedItem().toString();
if (valueSelected.equals(NEW_PVC_TEXT)) {
JPanel newPVCNamePanel = (JPanel) Arrays.stream(panel.getComponents()).filter(component -> "newPVCNamePanel".equals(component.getName())).findFirst().get();
JTextField newPVCNameTextField = (JTextField) Arrays.stream(newPVCNamePanel.getComponents()).filter(component -> "txtNameNewPVC".equals(component.getName())).findFirst().get();
String nameNewPVC = newPVCNameTextField.getText();
newPVCNameTextField.setBorder(nameNewPVC.isEmpty() ? RED_BORDER_SHOW_ERROR : NO_BORDER);
workspace = saveNewVolume(workspaceName, nameNewPVC, PVC, panel, isOptional);
} else if (valueSelected.equals(NEW_VCT_TEXT)) {
workspace = saveNewVolume(workspaceName, workspaceName + "-vct", PVC, panel, true, isOptional);
} else {
workspace = new Workspace(workspaceName, kind, resource);
}
} else if (resource.isEmpty() && !isOptional && kind != EMPTYDIR) {
workspace = new Workspace(workspaceName, null, null, isOptional);
} else {
workspace = new Workspace(workspaceName, kind, resource, isOptional);
}
model.getWorkspaces().put(workspaceName, workspace);
fireStateChanged();
}
use of com.redhat.devtools.intellij.tektoncd.ui.UIConstants.NO_BORDER in project intellij-tekton by redhat-developer.
the class WorkspacesStep method saveNewVolume.
private Workspace saveNewVolume(String workspaceName, String name, Workspace.Kind kind, JPanel panel, boolean isVCT, boolean isOptional) {
JPanel accessModePanel = (JPanel) Arrays.stream(panel.getComponents()).filter(component -> "accessModePanel".equals(component.getName())).findFirst().get();
JComboBox accessModeComboBox = (JComboBox) Arrays.stream(accessModePanel.getComponents()).filter(component -> "cmbAccessMode".equals(component.getName())).findFirst().get();
JPanel sizePanel = (JPanel) Arrays.stream(panel.getComponents()).filter(component -> "sizePanel".equals(component.getName())).findFirst().get();
JSpinner sizeSpinner = (JSpinner) Arrays.stream(sizePanel.getComponents()).filter(component -> "txtSize".equals(component.getName())).findFirst().get();
JComboBox sizeUnitComboBox = (JComboBox) Arrays.stream(sizePanel.getComponents()).filter(component -> "cmbSizeMeasureUnit".equals(component.getName())).findFirst().get();
boolean isNewItemFormValid = !name.isEmpty();
String size = ((JSpinner.NumberEditor) sizeSpinner.getEditor()).getTextField().getText();
if (size.isEmpty() || size.equals("0")) {
sizeSpinner.setBorder(RED_BORDER_SHOW_ERROR);
isNewItemFormValid = false;
} else {
sizeSpinner.setBorder(NO_BORDER);
}
if (!isNewItemFormValid) {
return null;
}
Map<String, String> values = new HashMap<>();
values.put("name", name);
if (isVCT) {
values.put("type", KIND_VCT);
}
values.put("accessMode", ((Pair) accessModeComboBox.getSelectedItem()).getSecond().toString());
values.put("size", size);
values.put("unit", ((Pair) sizeUnitComboBox.getSelectedItem()).getSecond().toString());
return new Workspace(workspaceName, kind, "", values, isOptional);
}
Aggregations