use of com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace.Kind.SECRET in project intellij-tekton by redhat-developer.
the class WorkspacesStep method addListeners.
private void addListeners(String workspace, JPanel parent, int row) {
JComboBox cmbWorkspaceTypes = (JComboBox) Arrays.stream(parent.getComponents()).filter(component -> component.getName() != null && component.getName().equals("cmbWorkspaceTypes")).findFirst().get();
JComboBox cmbWorkspaceTypeValues = (JComboBox) Arrays.stream(parent.getComponents()).filter(component -> component.getName() != null && component.getName().equals("cmbWorkspaceTypeValues")).findFirst().get();
cmbWorkspaceTypes.addItemListener(itemEvent -> {
if (itemEvent.getStateChange() == 1) {
// when cmbWorkspaceTypes combo box value changes, a type (secret, emptyDir, pvcs ..) is chosen and cmbWorkspaceTypeValues combo box is filled with all existing resources of that kind
hidePVCAndVCTComponents(parent);
Workspace.Kind kindSelected = cmbWorkspaceTypes.getSelectedItem().equals("") ? null : (Workspace.Kind) cmbWorkspaceTypes.getSelectedItem();
setCmbWorkspaceTypeValues(workspace, kindSelected, cmbWorkspaceTypeValues, row);
String resource = getSelectedWorkspaceType(cmbWorkspaceTypeValues);
updateWorkspaceModel(parent, workspace, kindSelected, resource);
// reset error graphics if error occurred earlier
if (isValid(workspace, cmbWorkspaceTypes)) {
changeErrorTextVisibility(false);
cmbWorkspaceTypes.setBorder(new JComboBox().getBorder());
}
fireStateChanged();
}
});
cmbWorkspaceTypeValues.addItemListener(itemEvent -> {
if (itemEvent.getStateChange() == 1) {
changeErrorTextVisibility(false);
// when wsCB combo box value changes, wsTypesCB combo box is filled with all possible options
String itemSelected = itemEvent.getItem().toString();
hidePVCAndVCTComponents(parent);
if (itemSelected.equals(NEW_VCT_TEXT)) {
changeNewVCTComponentsVisibility(parent, true);
updateWorkspaceModel(parent, workspace, PVC, "");
} else if (itemSelected.equals(NEW_PVC_TEXT)) {
changeNewPVCComponentsVisibility(parent, true);
updateWorkspaceModel(parent, workspace, PVC, "");
} else {
updateWorkspaceModel(parent, workspace, (Workspace.Kind) cmbWorkspaceTypes.getSelectedItem(), itemEvent.getItem().toString());
}
fireStateChanged();
}
});
}
Aggregations