Search in sources :

Example 1 with CommonProgramParametersPanel

use of com.intellij.execution.ui.CommonProgramParametersPanel in project Perl5-IDEA by Camelcade.

the class PerlConfigurationEditor method getGeneralComponent.

@Nullable
@Override
protected JComponent getGeneralComponent() {
    myScriptField = new TextFieldWithBrowseButton();
    myScriptField.addBrowseFolderListener(PerlBundle.message("perl.run.config.select.script.header"), PerlBundle.message("perl.run.config.select.script.prompt"), myProject, FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor().withFileFilter(PerlConfigurationProducer::isExecutableFile), TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
    myConsoleCharset = new ComboBox(new CollectionComboBoxModel(new ArrayList<>(Charset.availableCharsets().keySet())));
    myScriptField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent documentEvent) {
            VirtualFile file = LocalFileSystem.getInstance().findFileByPath(myScriptField.getText());
            if (file != null) {
                myConsoleCharset.setSelectedItem(file.getCharset().displayName());
            } else {
                myConsoleCharset.setSelectedItem(null);
            }
        }
    });
    myAlternativeSdkPanel = new PerlAlternativeSdkPanel();
    myParametersPanel = new CommonProgramParametersPanel() {

        @Override
        protected void addComponents() {
            LabeledComponent<?> scriptLabel = LabeledComponent.create(myScriptField, PerlBundle.message("perl.run.option.script"));
            scriptLabel.setLabelLocation(BorderLayout.WEST);
            add(scriptLabel);
            LabeledComponent<?> consoleEncoding = LabeledComponent.create(myConsoleCharset, PerlBundle.message("perl.run.option.output.encoding"));
            consoleEncoding.setLabelLocation(BorderLayout.WEST);
            add(consoleEncoding);
            myPerlParametersPanel = new RawCommandLineEditor();
            LabeledComponent<RawCommandLineEditor> perlParametersPanel = LabeledComponent.create(myPerlParametersPanel, PerlBundle.message("perl.run.option.perl.parameters"));
            perlParametersPanel.setLabelLocation(BorderLayout.WEST);
            copyDialogCaption(perlParametersPanel);
            add(perlParametersPanel);
            super.addComponents();
            add(myAlternativeSdkPanel);
            setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 5, true, false));
        }
    };
    myParametersPanel.setProgramParametersLabel(PerlBundle.message("perl.run.option.script.parameters"));
    return myParametersPanel;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent) CommonProgramParametersPanel(com.intellij.execution.ui.CommonProgramParametersPanel) RawCommandLineEditor(com.intellij.ui.RawCommandLineEditor) CollectionComboBoxModel(com.intellij.ui.CollectionComboBoxModel) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

CommonProgramParametersPanel (com.intellij.execution.ui.CommonProgramParametersPanel)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 CollectionComboBoxModel (com.intellij.ui.CollectionComboBoxModel)1 DocumentAdapter (com.intellij.ui.DocumentAdapter)1 RawCommandLineEditor (com.intellij.ui.RawCommandLineEditor)1 DocumentEvent (javax.swing.event.DocumentEvent)1 Nullable (org.jetbrains.annotations.Nullable)1