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;
}
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);
}
}
});
}
Aggregations