public ActionManagerDialogForm()

in src/main/java/org/apache/openwhisk/intellij/explorer/dialog/action/ui/ActionManagerDialogForm.java [82:292]


    public ActionManagerDialogForm(Project project, WhiskAuth auth, ExecutableWhiskAction action, List<WhiskActionMetaData> actions) {
        this.project = project;
        this.whiskAuth = auth;
        this.action = action;

        // add linked actions panel
        linkedActionsForm = new LinkedActionsForm(project, action.getNamespace().split("/")[0], actions, action.getExec().getComponents());
        linkedActionsJPanel.add(linkedActionsForm.getContent(), BorderLayout.CENTER);

        // add docker image panel
        dockerImageForm = new DockerImageForm();
        dockerImageJPanel.add(dockerImageForm.getContent(), BorderLayout.CENTER);

        // add code type panel
        codeTypeForm = new CodeTypeForm();
        codeTypeJPanel.add(codeTypeForm.getContent(), BorderLayout.CENTER);

        // add default parameter panel
        defaultParameterForm = new DefaultParameterForm();
        defaultParameterJPanel.add(defaultParameterForm.getContent(), BorderLayout.CENTER);

        switch (action.getKind()) {
            case "sequence":
                // remove docker image panel
                mainJPanel.remove(dockerImageJPanel);
                mainJPanel.remove(dockerImageJSeparator);

                // remove code type panel
                mainJPanel.remove(codeTypeJPanel);
                mainJPanel.remove(codeTypeJSeparator);

                // remove default parameter panel
                mainJPanel.remove(defaultParameterJPanel);
                mainJPanel.remove(defaultParameterJSeparator);
                break;
            case "blackbox":
                // remove linked actions panel
                mainJPanel.remove(linkedActionsJPanel);
                mainJPanel.remove(linkedActionsJSeparator);
                break;
            default: // normal
                // remove linked actions panel
                mainJPanel.remove(linkedActionsJPanel);
                mainJPanel.remove(linkedActionsJSeparator);

                // remove docker image panel
                mainJPanel.remove(dockerImageJPanel);
                mainJPanel.remove(dockerImageJSeparator);

                // remove code type panel
                mainJPanel.remove(codeTypeJPanel);
                mainJPanel.remove(codeTypeJSeparator);
        }

        runtimeJComboBox.setModel(new ComboBoxModel<Runtime>() {
            private Runtime selected;

            @Override
            public void setSelectedItem(Object anItem) {
                selected = (Runtime) anItem;
            }

            @Override
            public Runtime getSelectedItem() {
                return this.selected;
            }

            @Override
            public int getSize() {
                return Runtime.values().length;
            }

            @Override
            public Runtime getElementAt(int index) {
                return Runtime.toRuntime(index);
            }

            @Override
            public void addListDataListener(ListDataListener l) {
                // nothing to do
            }

            @Override
            public void removeListDataListener(ListDataListener l) {
                // nothing to do
            }
        });

        if (!webactionJCheckBox.isSelected()) {
            // raw http
            rawHttpJCheckBox.setEnabled(false);
            // custom option header
            customOptionHeaderJCheckBox.setEnabled(false);
            // final option
            finalOptionJCheckBox.setEnabled(false);
        }

        webactionJCheckBox.addChangeListener(e -> {
            AbstractButton abstractButton = (AbstractButton) e.getSource();
            ButtonModel buttonModel = abstractButton.getModel();

            if (buttonModel.isSelected()) {
                // raw http
                rawHttpJCheckBox.setEnabled(true);
                // custom option header
                customOptionHeaderJCheckBox.setEnabled(true);
                // final option
                finalOptionJCheckBox.setEnabled(true);
            } else {
                // raw http
                rawHttpJCheckBox.setSelected(false);
                rawHttpJCheckBox.setEnabled(false);
                // custom option header
                customOptionHeaderJCheckBox.setSelected(false);
                customOptionHeaderJCheckBox.setEnabled(false);
                // final option
                finalOptionJCheckBox.setSelected(false);
                finalOptionJCheckBox.setEnabled(false);
            }
        });

        /**
         * Set Value
         */
        // runtime
        runtimeJComboBox.setSelectedItem(Runtime.toRuntime(action.getKind()));
        // timeout
        timeoutJSpinner.setValue(action.getLimits().getTimeout());
        // memory
        memoryJSpinner.setValue(action.getLimits().getMemory());
        // webaction
        webactionJCheckBox.setSelected(action.isWebAction());
        // raw http
        rawHttpJCheckBox.setSelected(action.isRawHttp());
        // custom option header
        customOptionHeaderJCheckBox.setSelected(action.isCustomOptions());
        // final option
        finalOptionJCheckBox.setSelected(action.isFinalDefaultParameter());

        try {
            // default parameter
            defaultParameterForm.setDefaultParameter(JsonParserUtils.writeParameterToJson(action.getParameters()));
        } catch (IOException e) {
            LOG.error("Failed to parse json: " + action.getFullyQualifiedName(), e);
        }
        // docker image url
        dockerImageForm.setDockerImage(action.getExec().getImage());
        // code type
        action.getCodeType().ifPresent(codeType -> codeTypeForm.setCodeType(codeType));

        /**
         * Set runtime event
         */
        runtimeJComboBox.addItemListener(e -> {
            if (e.getStateChange() != ItemEvent.SELECTED) {
                return;
            }

            switch ((Runtime) e.getItem()) {
                case SEQUENCE:
                    removeAllPanel();

                    mainJPanel.add(linkedActionsJPanel, new GridConstraints(7, 0, 1, 1,
                            SIZEPOLICY_FIXED, SIZEPOLICY_CAN_GROW | SIZEPOLICY_CAN_SHRINK, FILL_NONE, ANCHOR_CENTER,
                            new Dimension(-1, -1), new Dimension(-1, 150), new Dimension(-1, -1), 0));
                    mainJPanel.add(linkedActionsJSeparator, new GridConstraints(8, 0, 1, 1,
                            SIZEPOLICY_FIXED, SIZEPOLICY_CAN_GROW | SIZEPOLICY_CAN_SHRINK, FILL_NONE, ANCHOR_CENTER,
                            new Dimension(-1, -1), new Dimension(-1, -1), new Dimension(-1, 5), 0));

                    mainJPanel.updateUI();
                    break;
                case DOCKER:
                    removeAllPanel();

                    mainJPanel.add(dockerImageJPanel, new GridConstraints(7, 0, 1, 1,
                            SIZEPOLICY_FIXED, SIZEPOLICY_CAN_GROW | SIZEPOLICY_CAN_SHRINK, FILL_NONE, ANCHOR_CENTER,
                            new Dimension(-1, -1), new Dimension(-1, -1), new Dimension(-1, -1), 0));
                    mainJPanel.add(dockerImageJSeparator, new GridConstraints(8, 0, 1, 1,
                            SIZEPOLICY_FIXED, SIZEPOLICY_CAN_GROW | SIZEPOLICY_CAN_SHRINK, FILL_NONE, ANCHOR_CENTER,
                            new Dimension(-1, -1), new Dimension(-1, -1), new Dimension(-1, 5), 0));

                    mainJPanel.add(codeTypeJPanel, new GridConstraints(9, 0, 1, 1,
                            SIZEPOLICY_FIXED, SIZEPOLICY_CAN_GROW | SIZEPOLICY_CAN_SHRINK, FILL_NONE, ANCHOR_CENTER,
                            new Dimension(-1, -1), new Dimension(-1, -1), new Dimension(-1, -1), 0));
                    mainJPanel.add(codeTypeJSeparator, new GridConstraints(10, 0, 1, 1,
                            SIZEPOLICY_FIXED, SIZEPOLICY_CAN_GROW | SIZEPOLICY_CAN_SHRINK, FILL_NONE, ANCHOR_CENTER,
                            new Dimension(-1, -1), new Dimension(-1, -1), new Dimension(-1, 5), 0));

                    mainJPanel.add(defaultParameterJPanel, new GridConstraints(11, 0, 1, 1,
                            SIZEPOLICY_FIXED, SIZEPOLICY_CAN_GROW | SIZEPOLICY_CAN_SHRINK, FILL_NONE, ANCHOR_CENTER,
                            new Dimension(-1, -1), new Dimension(-1, -1), new Dimension(-1, -1), 0));
                    mainJPanel.add(defaultParameterJSeparator, new GridConstraints(12, 0, 1, 1,
                            SIZEPOLICY_FIXED, SIZEPOLICY_CAN_GROW | SIZEPOLICY_CAN_SHRINK, FILL_NONE, ANCHOR_CENTER,
                            new Dimension(-1, -1), new Dimension(-1, -1), new Dimension(-1, 5), 0));

                    mainJPanel.updateUI();
                    break;
                default: // normal
                    removeAllPanel();

                    mainJPanel.add(defaultParameterJPanel, new GridConstraints(7, 0, 1, 1,
                            SIZEPOLICY_FIXED, SIZEPOLICY_CAN_GROW | SIZEPOLICY_CAN_SHRINK, FILL_NONE, ANCHOR_CENTER,
                            new Dimension(-1, -1), new Dimension(-1, -1), new Dimension(-1, -1), 0));
                    mainJPanel.add(defaultParameterJSeparator, new GridConstraints(8, 0, 1, 1,
                            SIZEPOLICY_FIXED, SIZEPOLICY_CAN_GROW | SIZEPOLICY_CAN_SHRINK, FILL_NONE, ANCHOR_CENTER,
                            new Dimension(-1, -1), new Dimension(-1, -1), new Dimension(-1, 5), 0));

                    mainJPanel.updateUI();
            }
        });
    }