Search in sources :

Example 1 with MapComboBoxModel

use of org.jdesktop.swingx.combobox.MapComboBoxModel in project Perl5-IDEA by Camelcade.

the class PerlRemoteDebuggingConfigurationEditor method getDebuggingComponent.

@Nullable
@Override
protected JComponent getDebuggingComponent() {
    JComponent debugPanel = super.getDebuggingComponent();
    if (debugPanel == null) {
        return null;
    }
    myWorkingDirectoryComponent = new JTextField();
    LabeledComponent<JTextField> workingDirectory = LabeledComponent.create(myWorkingDirectoryComponent, PerlBundle.message("perl.run.option.remote.root"));
    workingDirectory.setLabelLocation(BorderLayout.WEST);
    debugPanel.add(workingDirectory);
    // noinspection Since15
    myPerlRole = new ComboBox(new MapComboBoxModel<>(PerlDebugOptionsSets.ROLE_OPTIONS)) {

        @Override
        public void setRenderer(ListCellRenderer renderer) {
            super.setRenderer(new ColoredListCellRenderer<String>() {

                @Override
                protected void customizeCellRenderer(JList list, String value, int index, boolean selected, boolean hasFocus) {
                    append(PerlDebugOptionsSets.ROLE_OPTIONS.get(value));
                }
            });
        }
    };
    LabeledComponent<?> perlRole = LabeledComponent.create(myPerlRole, PerlBundle.message("perl.run.option.debugger.connection.mode"));
    perlRole.setLabelLocation(BorderLayout.WEST);
    debugPanel.add(perlRole);
    myDebuggingHost = new JTextField();
    LabeledComponent<JTextField> debuggingHost = LabeledComponent.create(myDebuggingHost, PerlBundle.message("perl.run.option.debugger.host"));
    debuggingHost.setLabelLocation(BorderLayout.WEST);
    debugPanel.add(debuggingHost);
    NumberFormat numberFormat = NumberFormat.getInstance();
    numberFormat.setMaximumIntegerDigits(6);
    numberFormat.setGroupingUsed(false);
    NumberFormatter formatter = new NumberFormatter(numberFormat);
    formatter.setAllowsInvalid(false);
    formatter.setMaximum(65535);
    formatter.setMinimum(0);
    myDebuggingPort = new JFormattedTextField(formatter);
    LabeledComponent<JFormattedTextField> debuggingPort = LabeledComponent.create(myDebuggingPort, PerlBundle.message("perl.run.option.debugger.port"));
    debuggingPort.setLabelLocation(BorderLayout.WEST);
    debugPanel.add(debuggingPort);
    return debugPanel;
}
Also used : ComboBox(com.intellij.openapi.ui.ComboBox) ColoredListCellRenderer(com.intellij.ui.ColoredListCellRenderer) MapComboBoxModel(org.jdesktop.swingx.combobox.MapComboBoxModel) ColoredListCellRenderer(com.intellij.ui.ColoredListCellRenderer) NumberFormat(java.text.NumberFormat) NumberFormatter(javax.swing.text.NumberFormatter) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with MapComboBoxModel

use of org.jdesktop.swingx.combobox.MapComboBoxModel in project Perl5-IDEA by Camelcade.

the class PerlConfigurationEditorBase method getDebuggingComponent.

@Nullable
protected JComponent getDebuggingComponent() {
    JPanel panel = new JPanel();
    panel.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 5, true, false));
    myScriptCharset = new JTextField();
    LabeledComponent<JTextField> scriptCharset = LabeledComponent.create(myScriptCharset, PerlBundle.message("perl.run.option.script.encoding"));
    scriptCharset.setLabelLocation(BorderLayout.WEST);
    panel.add(scriptCharset);
    myStartMode = new ComboBox(new MapComboBoxModel<>(PerlDebugOptionsSets.STARTUP_OPTIONS)) {

        @Override
        public void setRenderer(ListCellRenderer renderer) {
            super.setRenderer(new ColoredListCellRenderer<String>() {

                @Override
                protected void customizeCellRenderer(@NotNull JList list, String value, int index, boolean selected, boolean hasFocus) {
                    append(PerlDebugOptionsSets.STARTUP_OPTIONS.get(value));
                }
            });
        }
    };
    LabeledComponent<?> startMode = LabeledComponent.create(myStartMode, PerlBundle.message("perl.run.option.debugger.startup.mode"));
    startMode.setLabelLocation(BorderLayout.WEST);
    panel.add(startMode);
    myIsNonInteractiveModeEnabled = new JCheckBox(PerlBundle.message("perl.run.option.debugger.noninteractive.mode"));
    panel.add(myIsNonInteractiveModeEnabled);
    myIsCompileTimeBreakpointsEnabled = new JCheckBox(PerlBundle.message("perl.run.option.debugger.compile.time.breakpoints"));
    panel.add(myIsCompileTimeBreakpointsEnabled);
    PsiFile fileFromText = PsiFileFactory.getInstance(myProject).createFileFromText("file.dummy", PerlFileTypeScript.INSTANCE, "", 0, true);
    Document document = PsiDocumentManager.getInstance(myProject).getDocument(fileFromText);
    myInitCodeTextField = new EditorTextField(document, myProject, PerlFileTypeScript.INSTANCE);
    myInitCodeTextField.setOneLineMode(false);
    myInitCodeTextField.setPreferredSize(new Dimension(0, 100));
    LabeledComponent<EditorTextField> initCode = LabeledComponent.create(myInitCodeTextField, PerlBundle.message("perl.run.option.debugger.init.code"));
    initCode.setLabelLocation(BorderLayout.NORTH);
    panel.add(initCode);
    return panel;
}
Also used : ComboBox(com.intellij.openapi.ui.ComboBox) ColoredListCellRenderer(com.intellij.ui.ColoredListCellRenderer) Document(com.intellij.openapi.editor.Document) MapComboBoxModel(org.jdesktop.swingx.combobox.MapComboBoxModel) NotNull(org.jetbrains.annotations.NotNull) EditorTextField(com.intellij.ui.EditorTextField) ColoredListCellRenderer(com.intellij.ui.ColoredListCellRenderer) PsiFile(com.intellij.psi.PsiFile) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ComboBox (com.intellij.openapi.ui.ComboBox)2 ColoredListCellRenderer (com.intellij.ui.ColoredListCellRenderer)2 MapComboBoxModel (org.jdesktop.swingx.combobox.MapComboBoxModel)2 Nullable (org.jetbrains.annotations.Nullable)2 Document (com.intellij.openapi.editor.Document)1 VerticalFlowLayout (com.intellij.openapi.ui.VerticalFlowLayout)1 PsiFile (com.intellij.psi.PsiFile)1 EditorTextField (com.intellij.ui.EditorTextField)1 NumberFormat (java.text.NumberFormat)1 NumberFormatter (javax.swing.text.NumberFormatter)1 NotNull (org.jetbrains.annotations.NotNull)1