Search in sources :

Example 11 with ColoredListCellRenderer

use of com.intellij.ui.ColoredListCellRenderer 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)

Example 12 with ColoredListCellRenderer

use of com.intellij.ui.ColoredListCellRenderer in project sonarlint-intellij by SonarSource.

the class SonarQubeServerMgmtPanel method create.

private void create() {
    Application app = ApplicationManager.getApplication();
    serverManager = app.getComponent(SonarLintEngineManager.class);
    serverChangeListener = app.getMessageBus().syncPublisher(GlobalConfigurationListener.TOPIC);
    serverList = new JBList();
    serverList.getEmptyText().setText(LABEL_NO_SERVERS);
    serverList.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent evt) {
            if (evt.getClickCount() == 2) {
                editServer();
            }
        }
    });
    serverList.addListSelectionListener(e -> {
        if (!e.getValueIsAdjusting()) {
            onServerSelect();
        }
    });
    serversPanel = new JPanel(new BorderLayout());
    ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(serverList).setEditActionName("Edit").setEditAction(e -> editServer()).disableUpDownActions();
    toolbarDecorator.setAddAction(new AddServerAction());
    toolbarDecorator.setRemoveAction(new RemoveServerAction());
    serversPanel.add(toolbarDecorator.createPanel(), BorderLayout.CENTER);
    splitter = new Splitter(true);
    splitter.setFirstComponent(serversPanel);
    splitter.setSecondComponent(createServerStatus());
    JBLabel emptyLabel = new JBLabel("No server selected", SwingConstants.CENTER);
    emptyPanel = new JPanel(new BorderLayout());
    emptyPanel.add(emptyLabel, BorderLayout.CENTER);
    Border b = IdeBorderFactory.createTitledBorder("SonarQube servers");
    panel = new JPanel(new BorderLayout());
    panel.setBorder(b);
    panel.add(splitter);
    serverList.setCellRenderer(new ColoredListCellRenderer() {

        @Override
        protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
            SonarQubeServer server = (SonarQubeServer) value;
            if (server.isSonarCloud()) {
                setIcon(SonarLintIcons.ICON_SONARCLOUD_16);
            } else {
                setIcon(SonarLintIcons.ICON_SONARQUBE_16);
            }
            append(server.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
            if (!server.isSonarCloud()) {
                append("    (" + server.getHostUrl() + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES, false);
            }
        }
    });
}
Also used : AllIcons(com.intellij.icons.AllIcons) Application(com.intellij.openapi.application.Application) HyperlinkEvent(javax.swing.event.HyperlinkEvent) SonarLintEngineManager(org.sonarlint.intellij.core.SonarLintEngineManager) JBLabel(com.intellij.ui.components.JBLabel) HyperlinkLabel(com.intellij.ui.HyperlinkLabel) GlobalConfigurationListener(org.sonarlint.intellij.messages.GlobalConfigurationListener) Border(javax.swing.border.Border) ProjectManager(com.intellij.openapi.project.ProjectManager) JBUI(com.intellij.util.ui.JBUI) Map(java.util.Map) AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) MouseAdapter(java.awt.event.MouseAdapter) Messages(com.intellij.openapi.ui.Messages) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) BorderLayout(java.awt.BorderLayout) AnActionButton(com.intellij.ui.AnActionButton) ConnectedSonarLintEngine(org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine) ProgressManager(com.intellij.openapi.progress.ProgressManager) HintUtil(com.intellij.codeInsight.hint.HintUtil) Set(java.util.Set) SQServerWizard(org.sonarlint.intellij.config.global.wizard.SQServerWizard) GridBagConstraints(java.awt.GridBagConstraints) Collectors(java.util.stream.Collectors) List(java.util.List) ConfigurationPanel(org.sonarlint.intellij.config.ConfigurationPanel) AbstractAction(javax.swing.AbstractAction) ColoredListCellRenderer(com.intellij.ui.ColoredListCellRenderer) ApplicationManager(com.intellij.openapi.application.ApplicationManager) GridBagLayout(java.awt.GridBagLayout) RelativePoint(com.intellij.ui.awt.RelativePoint) JPanel(javax.swing.JPanel) DateUtils(org.sonarsource.sonarlint.core.client.api.util.DateUtils) HashMap(java.util.HashMap) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) SwingConstants(javax.swing.SwingConstants) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) SonarLintIcons(icons.SonarLintIcons) Project(com.intellij.openapi.project.Project) LinkedList(java.util.LinkedList) Nullable(javax.annotation.Nullable) Splitter(com.intellij.openapi.ui.Splitter) JComponent(javax.swing.JComponent) SonarLintUtils(org.sonarlint.intellij.util.SonarLintUtils) JBList(com.intellij.ui.components.JBList) FlowLayout(java.awt.FlowLayout) SonarLintProjectSettings(org.sonarlint.intellij.config.project.SonarLintProjectSettings) HyperlinkAdapter(com.intellij.ui.HyperlinkAdapter) JButton(javax.swing.JButton) JList(javax.swing.JList) CollectionListModel(com.intellij.ui.CollectionListModel) ActionEvent(java.awt.event.ActionEvent) Disposable(com.intellij.openapi.Disposable) MouseEvent(java.awt.event.MouseEvent) StateListener(org.sonarsource.sonarlint.core.client.api.connected.StateListener) ServerUpdateTask(org.sonarlint.intellij.tasks.ServerUpdateTask) IdeBorderFactory(com.intellij.ui.IdeBorderFactory) JLabel(javax.swing.JLabel) GlobalStorageStatus(org.sonarsource.sonarlint.core.client.api.connected.GlobalStorageStatus) HintManager(com.intellij.codeInsight.hint.HintManager) Collections(java.util.Collections) JPanel(javax.swing.JPanel) MouseEvent(java.awt.event.MouseEvent) Splitter(com.intellij.openapi.ui.Splitter) MouseAdapter(java.awt.event.MouseAdapter) SonarLintEngineManager(org.sonarlint.intellij.core.SonarLintEngineManager) ColoredListCellRenderer(com.intellij.ui.ColoredListCellRenderer) RelativePoint(com.intellij.ui.awt.RelativePoint) BorderLayout(java.awt.BorderLayout) JBLabel(com.intellij.ui.components.JBLabel) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) JBList(com.intellij.ui.components.JBList) Application(com.intellij.openapi.application.Application) Border(javax.swing.border.Border) JList(javax.swing.JList)

Aggregations

ColoredListCellRenderer (com.intellij.ui.ColoredListCellRenderer)12 JBList (com.intellij.ui.components.JBList)5 ArrayList (java.util.ArrayList)5 NotNull (org.jetbrains.annotations.NotNull)5 List (java.util.List)4 HintManager (com.intellij.codeInsight.hint.HintManager)2 AllIcons (com.intellij.icons.AllIcons)2 Disposable (com.intellij.openapi.Disposable)2 Document (com.intellij.openapi.editor.Document)2 Project (com.intellij.openapi.project.Project)2 ProjectManager (com.intellij.openapi.project.ProjectManager)2 JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)2 PopupStep (com.intellij.openapi.ui.popup.PopupStep)2 BaseListPopupStep (com.intellij.openapi.ui.popup.util.BaseListPopupStep)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 PsiFile (com.intellij.psi.PsiFile)2 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)2 JBLabel (com.intellij.ui.components.JBLabel)2 ListPopupImpl (com.intellij.ui.popup.list.ListPopupImpl)2 ActionEvent (java.awt.event.ActionEvent)2