public LambdaInputPanel()

in jetbrains-core/src/software/aws/toolkits/jetbrains/services/lambda/execution/LambdaInputPanel.java [59:135]


    public LambdaInputPanel(Project project) {
        this.project = project;

        useInputText.addActionListener(e -> updateComponents());
        useInputFile.addActionListener(e -> updateComponents());

        eventComboBox.addActionListener(e -> {
            LambdaSampleEvent selectedSample = eventComboBoxModel.getSelectedItem();
            if (selectedSample != null && selectedSample != selected) {
                if (inputText.getText().length() > 0 && !inputText.getText().equals(selectedTemplate)) {
                    int result = Messages.showOkCancelDialog(project,
                                                             message("lambda.run_configuration.input.samples.confirm"),
                                                             message("lambda.run_configuration.input.samples.confirm.title"),
                                                             Messages.getOkButton(),
                                                             Messages.getCancelButton(),
                                                             AllIcons.General.WarningDialog);
                    if (result == Messages.CANCEL) {
                        eventComboBoxModel.setSelectedItem(selected);
                        if (selectedSample instanceof LocalLambdaSampleEvent) {
                            eventComboBoxModel.remove(selectedSample);
                        }
                        return;
                    }
                }

                selectedSample.getContent().thenAccept(selectedSampleContent -> {
                    String cleanedUp = StringUtil.convertLineSeparators(selectedSampleContent);
                    runInEdt(ModalityState.any(), () -> {
                        formatAndSet(inputText, cleanedUp, JsonLanguage.INSTANCE);
                        selectedTemplate = inputText.getText();
                        return null;
                    });
                });
            }
            selected = selectedSample;
        });

        addQuickSelect(inputFile.getTextField(), useInputFile, this::updateComponents);
        addQuickSelect(inputTemplates.getComboBox(), useInputText, this::updateComponents);
        addQuickSelect(inputTemplates.getButton(), useInputText, this::updateComponents);
        addQuickSelect(inputText.getComponent(), useInputText, this::updateComponents);

        ProjectFileBrowseListenerKt.installTextFieldProjectFileBrowseListener(
            project,
            inputFile,
            FileChooserDescriptorFactory.createSingleFileDescriptor(JsonFileType.INSTANCE)
        );

        LambdaSampleEventProvider eventProvider = new LambdaSampleEventProvider(RemoteResourceResolverProvider.Companion.getInstance().get());

        eventProvider.get().thenAccept(events -> runInEdt(ModalityState.any(), () -> {
            eventComboBoxModel.setAll(events);
            eventComboBox.setSelectedItem(null);
            return null;
        }));

        ProjectFileBrowseListenerKt.installComboBoxProjectFileBrowseListener(
            project,
            inputTemplates,
            FileChooserDescriptorFactory.createSingleFileDescriptor(JsonFileType.INSTANCE),
            chosenFile -> {
                try {
                    String contents = VfsUtil.loadText(chosenFile);
                    String cleanedUp = StringUtil.convertLineSeparators(contents);
                    LambdaSampleEvent fileEvent = new LocalLambdaSampleEvent(chosenFile.getName(), cleanedUp);
                    eventComboBoxModel.add(fileEvent);
                    eventComboBoxModel.setSelectedItem(fileEvent);
                } catch (IOException e) {
                    LOG.error(e);
                }

                return null; // Required since lambda is defined in Kotlin
            }
        );

        updateComponents();
    }