use of com.intellij.ui.ListCellRendererWrapper in project idea-handlebars by dmarcotte.
the class HbConfigurationPage method resetCommentLanguageCombo.
private void resetCommentLanguageCombo(Language commentLanguage) {
final DefaultComboBoxModel model = (DefaultComboBoxModel) myCommenterLanguage.getModel();
final List<Language> languages = TemplateDataLanguageMappings.getTemplateableLanguages();
// add using the native Handlebars commenter as an option
languages.add(HbLanguage.INSTANCE);
Collections.sort(languages, new Comparator<Language>() {
@Override
public int compare(final Language o1, final Language o2) {
return o1.getID().compareTo(o2.getID());
}
});
for (Language language : languages) {
model.addElement(language);
}
myCommenterLanguage.setRenderer(new ListCellRendererWrapper() {
@Override
public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
setText(value == null ? "" : ((Language) value).getDisplayName());
if (value != null) {
final FileType type = ((Language) value).getAssociatedFileType();
if (type != null) {
setIcon(type.getIcon());
}
}
}
});
myCommenterLanguage.setSelectedItem(commentLanguage);
}
use of com.intellij.ui.ListCellRendererWrapper in project intellij-community by JetBrains.
the class ExecutionHelper method selectContentDescriptor.
public static void selectContentDescriptor(@NotNull final DataContext dataContext, @NotNull final Project project, @NotNull Collection<RunContentDescriptor> consoles, String selectDialogTitle, final Consumer<RunContentDescriptor> descriptorConsumer) {
if (consoles.size() == 1) {
RunContentDescriptor descriptor = consoles.iterator().next();
descriptorConsumer.consume(descriptor);
descriptorToFront(project, descriptor);
} else if (consoles.size() > 1) {
final JList list = new JBList(consoles);
final Icon icon = DefaultRunExecutor.getRunExecutorInstance().getIcon();
list.setCellRenderer(new ListCellRendererWrapper<RunContentDescriptor>() {
@Override
public void customize(final JList list, final RunContentDescriptor value, final int index, final boolean selected, final boolean hasFocus) {
setText(value.getDisplayName());
setIcon(icon);
}
});
final PopupChooserBuilder builder = new PopupChooserBuilder(list);
builder.setTitle(selectDialogTitle);
builder.setItemChoosenCallback(() -> {
final Object selectedValue = list.getSelectedValue();
if (selectedValue instanceof RunContentDescriptor) {
RunContentDescriptor descriptor = (RunContentDescriptor) selectedValue;
descriptorConsumer.consume(descriptor);
descriptorToFront(project, descriptor);
}
}).createPopup().showInBestPositionFor(dataContext);
}
}
use of com.intellij.ui.ListCellRendererWrapper in project intellij-community by JetBrains.
the class FullyQualifiedNamesInJavadocOptionProvider method composePanel.
private void composePanel() {
myPanel = new JPanel(new GridBagLayout());
myComboBox = new ComboBox();
for (QualifyJavadocOptions options : QualifyJavadocOptions.values()) {
myComboBox.addItem(options);
}
myComboBox.setRenderer(new ListCellRendererWrapper() {
@Override
public void customize(final JList list, final Object value, final int index, final boolean selected, final boolean hasFocus) {
if (value instanceof QualifyJavadocOptions) {
setText(((QualifyJavadocOptions) value).getPresentableText());
}
}
});
JLabel title = new JLabel(ApplicationBundle.message("radio.use.fully.qualified.class.names.in.javadoc"));
myPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
GridBagConstraints left = new GridBagConstraints();
left.anchor = GridBagConstraints.WEST;
GridBagConstraints right = new GridBagConstraints();
right.anchor = GridBagConstraints.WEST;
right.weightx = 1.0;
right.insets = JBUI.insetsLeft(5);
myPanel.add(title, left);
myPanel.add(myComboBox, right);
}
use of com.intellij.ui.ListCellRendererWrapper in project intellij-community by JetBrains.
the class IdeaJdkConfigurable method createComponent.
public JComponent createComponent() {
mySandboxHome.setHistorySize(5);
JPanel wholePanel = new JPanel(new GridBagLayout());
wholePanel.add(mySandboxHomeLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.emptyInsets(), 0, 0));
wholePanel.add(GuiUtils.constructFieldWithBrowseButton(mySandboxHome, new ActionListener() {
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
descriptor.setTitle(DevKitBundle.message("sandbox.home"));
descriptor.setDescription(DevKitBundle.message("sandbox.purpose"));
VirtualFile file = FileChooser.chooseFile(descriptor, mySandboxHome, null, null);
if (file != null) {
mySandboxHome.setText(FileUtil.toSystemDependentName(file.getPath()));
}
myModified = true;
}
}), new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, JBUI.insets(0, 30, 0, 0), 0, 0));
wholePanel.add(myInternalJreLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.emptyInsets(), 0, 0));
wholePanel.add(myInternalJres, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1, 1, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, JBUI.insets(0, 30, 0, 0), 0, 0));
myInternalJres.setRenderer(new ListCellRendererWrapper() {
@Override
public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof Sdk) {
setText(((Sdk) value).getName());
}
}
});
myInternalJres.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent e) {
if (myFreeze)
return;
final Sdk javaJdk = (Sdk) e.getItem();
for (OrderRootType type : OrderRootType.getAllTypes()) {
if (!((SdkType) javaJdk.getSdkType()).isRootTypeApplicable(type)) {
continue;
}
final VirtualFile[] internalRoots = javaJdk.getSdkModificator().getRoots(type);
final VirtualFile[] configuredRoots = mySdkModificator.getRoots(type);
for (VirtualFile file : internalRoots) {
if (e.getStateChange() == ItemEvent.DESELECTED) {
mySdkModificator.removeRoot(file, type);
} else {
if (ArrayUtil.find(configuredRoots, file) == -1) {
mySdkModificator.addRoot(file, type);
}
}
}
}
}
});
mySandboxHome.addDocumentListener(new DocumentAdapter() {
protected void textChanged(DocumentEvent e) {
myModified = true;
}
});
mySandboxHome.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
myModified = true;
}
});
mySandboxHome.setText("");
myModified = true;
return wholePanel;
}
use of com.intellij.ui.ListCellRendererWrapper in project android by JetBrains.
the class SourceSetComboProvider method createComponent.
@NotNull
@Override
public JComboBox createComponent() {
DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel();
for (AndroidSourceSet sourceSet : mySourceSets) {
comboBoxModel.addElement(sourceSet);
}
JComboBox sourceSetCombo = new JComboBox(comboBoxModel);
sourceSetCombo.setRenderer(new ListCellRendererWrapper() {
@Override
public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
setText(((AndroidSourceSet) value).getName());
}
});
sourceSetCombo.setToolTipText("<html>The source set within which to generate new project files.<br>" + "If you specify a source set that does not yet exist on disk, a folder will be created for it.</html>");
return sourceSetCombo;
}
Aggregations