com.intellij.ui.SimpleListCellRenderer Java Examples
The following examples show how to use
com.intellij.ui.SimpleListCellRenderer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GtForm.java From GitToolBox with Apache License 2.0 | 5 votes |
private ListCellRenderer<AuthorNameType> createAuthorNameTypeRenderer() { return new SimpleListCellRenderer<AuthorNameType>() { @Override public void customize(JList list, AuthorNameType value, int index, boolean selected, boolean hasFocus) { setText(value.getDisplayLabel()); } }; }
Example #2
Source File: ReferencePointTab.java From saros with GNU General Public License v2.0 | 5 votes |
/** * Initializes the project combo box. * * @param gbc the basic grid bag constraints object used to define the layout */ private void initProjectComboBox(@NotNull GridBagConstraints gbc) { gbc.gridwidth = 2; JLabel projectLabel = new JBLabel(); projectLabel.setText(Messages.ReferencePointTab_project_label); referencePointTabPanel.add(projectLabel, gbc); gbc.gridwidth = 1; projectComboBox.setRenderer( new SimpleListCellRenderer<Project>() { @Override public void customize( @NotNull JList list, Project value, int index, boolean selected, boolean hasFocus) { if (value != null) { setText(value.getName()); } } }); referencePointTabPanel.add(projectComboBox, gbc); gbc.gridy++; referencePointTabPanel.add(Box.createVerticalStrut(5), gbc); gbc.gridy++; }
Example #3
Source File: BrowserSelector.java From consulo with Apache License 2.0 | 5 votes |
public BrowserSelector(@Nonnull final Condition<WebBrowser> browserCondition) { myModel = createBrowsersComboModel(browserCondition); myBrowserComboWithBrowse = new ComboboxWithBrowseButton(new ComboBox(myModel)); myBrowserComboWithBrowse.addActionListener(e -> { WebBrowserManager browserManager = WebBrowserManager.getInstance(); long modificationCount = browserManager.getModificationCount(); ShowSettingsUtil.getInstance().editConfigurable(myBrowserComboWithBrowse, new BrowserSettings()); WebBrowser selectedItem = getSelected(); if (modificationCount != browserManager.getModificationCount()) { myModel = createBrowsersComboModel(browserCondition); //noinspection unchecked myBrowserComboWithBrowse.getComboBox().setModel(myModel); } if (selectedItem != null) { setSelected(selectedItem); } }); //noinspection unchecked myBrowserComboWithBrowse.getComboBox().setRenderer(SimpleListCellRenderer.<WebBrowser>create((label, value, index) -> { Image baseIcon; if (value == null) { WebBrowser firstBrowser = WebBrowserManager.getInstance().getFirstActiveBrowser(); baseIcon = firstBrowser == null ? AllIcons.Nodes.PpWeb : firstBrowser.getIcon(); } else { baseIcon = value.getIcon(); } label.setIcon(TargetAWT.to(myBrowserComboWithBrowse.isEnabled() ? baseIcon : ImageEffects.grayed(baseIcon))); label.setText(value != null ? value.getName() : "Default"); })); }
Example #4
Source File: BrowserSettingsPanel.java From consulo with Apache License 2.0 | 5 votes |
BrowserSettingsPanel() { alternativeBrowserPathField.addBrowseFolderListener(IdeBundle.message("title.select.path.to.browser"), null, null, APP_FILE_CHOOSER_DESCRIPTOR); defaultBrowserPanel.setBorder(TitledSeparator.createEmptyBorder()); ArrayList<DefaultBrowserPolicy> defaultBrowserPolicies = new ArrayList<>(); if (BrowserLauncherAppless.canUseSystemDefaultBrowserPolicy()) { defaultBrowserPolicies.add(DefaultBrowserPolicy.SYSTEM); } defaultBrowserPolicies.add(DefaultBrowserPolicy.FIRST); defaultBrowserPolicies.add(DefaultBrowserPolicy.ALTERNATIVE); defaultBrowserPolicyComboBox.setModel(new CollectionComboBoxModel<>(defaultBrowserPolicies)); defaultBrowserPolicyComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(@Nonnull ItemEvent e) { boolean customPathEnabled = e.getItem() == DefaultBrowserPolicy.ALTERNATIVE; if (e.getStateChange() == ItemEvent.DESELECTED) { if (customPathEnabled) { customPathValue = alternativeBrowserPathField.getText(); } } else if (e.getStateChange() == ItemEvent.SELECTED) { alternativeBrowserPathField.setEnabled(customPathEnabled); updateCustomPathTextFieldValue((DefaultBrowserPolicy)e.getItem()); } } }); defaultBrowserPolicyComboBox.setRenderer(SimpleListCellRenderer.create("", value -> { String text = value == DefaultBrowserPolicy.SYSTEM ? "System default" : value == DefaultBrowserPolicy.FIRST ? "First listed" : value == DefaultBrowserPolicy.ALTERNATIVE ? "Custom path" : null; if (text == null) throw new IllegalStateException(String.valueOf(value)); return text; })); }