Search in sources :

Example 1 with KIND_VCT

use of com.redhat.devtools.intellij.tektoncd.Constants.KIND_VCT 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);
}
Also used : Color(java.awt.Color) ActionToRunModel(com.redhat.devtools.intellij.tektoncd.utils.model.actions.ActionToRunModel) Arrays(java.util.Arrays) KIND_VCT(com.redhat.devtools.intellij.tektoncd.Constants.KIND_VCT) TIMES_PLAIN_14(com.redhat.devtools.intellij.tektoncd.ui.UIConstants.TIMES_PLAIN_14) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager) MatteBorder(javax.swing.border.MatteBorder) NumberFormatter(javax.swing.text.NumberFormatter) Border(javax.swing.border.Border) RED_BORDER_SHOW_ERROR(com.redhat.devtools.intellij.tektoncd.ui.UIConstants.RED_BORDER_SHOW_ERROR) ROW_DIMENSION(com.redhat.devtools.intellij.tektoncd.ui.UIConstants.ROW_DIMENSION) ColorKey(com.intellij.openapi.editor.colors.ColorKey) Map(java.util.Map) TIMES_PLAIN_10(com.redhat.devtools.intellij.tektoncd.ui.UIConstants.TIMES_PLAIN_10) TIMES_PLAIN_12(com.redhat.devtools.intellij.tektoncd.ui.UIConstants.TIMES_PLAIN_12) JComboBox(javax.swing.JComboBox) BorderLayout(java.awt.BorderLayout) Font(java.awt.Font) BorderFactory(javax.swing.BorderFactory) BasicComboBoxRenderer(javax.swing.plaf.basic.BasicComboBoxRenderer) GridBagConstraints(java.awt.GridBagConstraints) Component(java.awt.Component) Dimension(java.awt.Dimension) List(java.util.List) EmptyBorder(javax.swing.border.EmptyBorder) PVC(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace.Kind.PVC) NotNull(org.jetbrains.annotations.NotNull) GridBagLayout(java.awt.GridBagLayout) DocumentAdapter(com.intellij.ui.DocumentAdapter) CONFIGMAP(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace.Kind.CONFIGMAP) JPanel(javax.swing.JPanel) NO_BORDER(com.redhat.devtools.intellij.tektoncd.ui.UIConstants.NO_BORDER) JTextField(javax.swing.JTextField) SpinnerNumberModel(javax.swing.SpinnerNumberModel) SECRET(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace.Kind.SECRET) HashMap(java.util.HashMap) ROW_DIMENSION_ERROR(com.redhat.devtools.intellij.tektoncd.ui.UIConstants.ROW_DIMENSION_ERROR) ArrayList(java.util.ArrayList) Strings(com.google.common.base.Strings) DocumentEvent(javax.swing.event.DocumentEvent) MARGIN_TOP_35(com.redhat.devtools.intellij.tektoncd.ui.UIConstants.MARGIN_TOP_35) BORDER_LABEL_NAME(com.redhat.devtools.intellij.tektoncd.ui.UIConstants.BORDER_LABEL_NAME) ComboBox(com.intellij.openapi.ui.ComboBox) JComponent(javax.swing.JComponent) EMPTYDIR(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace.Kind.EMPTYDIR) JFormattedTextField(javax.swing.JFormattedTextField) JSpinner(javax.swing.JSpinner) JList(javax.swing.JList) Workspace(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace) ListCellRenderer(javax.swing.ListCellRenderer) JLabel(javax.swing.JLabel) Pair(com.intellij.openapi.util.Pair) JPanel(javax.swing.JPanel) JComboBox(javax.swing.JComboBox) HashMap(java.util.HashMap) JSpinner(javax.swing.JSpinner) Pair(com.intellij.openapi.util.Pair) Workspace(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace)

Aggregations

Strings (com.google.common.base.Strings)1 ColorKey (com.intellij.openapi.editor.colors.ColorKey)1 EditorColorsManager (com.intellij.openapi.editor.colors.EditorColorsManager)1 ComboBox (com.intellij.openapi.ui.ComboBox)1 Pair (com.intellij.openapi.util.Pair)1 DocumentAdapter (com.intellij.ui.DocumentAdapter)1 KIND_VCT (com.redhat.devtools.intellij.tektoncd.Constants.KIND_VCT)1 Workspace (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace)1 CONFIGMAP (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace.Kind.CONFIGMAP)1 EMPTYDIR (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace.Kind.EMPTYDIR)1 PVC (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace.Kind.PVC)1 SECRET (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Workspace.Kind.SECRET)1 BORDER_LABEL_NAME (com.redhat.devtools.intellij.tektoncd.ui.UIConstants.BORDER_LABEL_NAME)1 MARGIN_TOP_35 (com.redhat.devtools.intellij.tektoncd.ui.UIConstants.MARGIN_TOP_35)1 NO_BORDER (com.redhat.devtools.intellij.tektoncd.ui.UIConstants.NO_BORDER)1 RED_BORDER_SHOW_ERROR (com.redhat.devtools.intellij.tektoncd.ui.UIConstants.RED_BORDER_SHOW_ERROR)1 ROW_DIMENSION (com.redhat.devtools.intellij.tektoncd.ui.UIConstants.ROW_DIMENSION)1 ROW_DIMENSION_ERROR (com.redhat.devtools.intellij.tektoncd.ui.UIConstants.ROW_DIMENSION_ERROR)1 TIMES_PLAIN_10 (com.redhat.devtools.intellij.tektoncd.ui.UIConstants.TIMES_PLAIN_10)1 TIMES_PLAIN_12 (com.redhat.devtools.intellij.tektoncd.ui.UIConstants.TIMES_PLAIN_12)1