use of com.intellij.openapi.ui.ComboBox in project intellij-community by JetBrains.
the class ParameterTablePanel method init.
public void init(VariableData[] variableData, Project project, PsiElement... scopeElements) {
super.init(variableData);
myParameterTypeSelectors = new TypeSelector[getVariableData().length];
for (int i = 0; i < myParameterTypeSelectors.length; i++) {
final VariableData data = variableData[i];
final TypeSelector selector = createSelector(project, data, scopeElements);
myParameterTypeSelectors[i] = selector;
//reverse order
getVariableData()[i].type = myParameterTypeSelectors[i].getSelectedType();
}
myTypeRendererCombo = new ComboBox<>(getVariableData());
myTypeRendererCombo.setOpaque(true);
myTypeRendererCombo.setBorder(null);
myTypeRendererCombo.setRenderer(new ListCellRendererWrapper<VariableData>() {
@Override
public void customize(JList list, VariableData value, int index, boolean selected, boolean hasFocus) {
if (value != null) {
setText(value.type.getPresentableText());
}
}
});
final TableColumn typeColumn = myTable.getColumnModel().getColumn(1);
typeColumn.setCellEditor(new AbstractTableCellEditor() {
TypeSelector myCurrentSelector;
final JBComboBoxTableCellEditorComponent myEditorComponent = new JBComboBoxTableCellEditorComponent();
final JLabel myTypeLabel = new JLabel();
@Nullable
public Object getCellEditorValue() {
if (myCurrentSelector.getComponent() instanceof JLabel) {
return myCurrentSelector.getSelectedType();
}
return myEditorComponent.getEditorValue();
}
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) {
myCurrentSelector = myParameterTypeSelectors[row];
if (myParameterTypeSelectors[row].getComponent() instanceof JLabel) {
PsiType selectedType = myCurrentSelector.getSelectedType();
if (selectedType != null) {
myTypeLabel.setText(selectedType.getPresentableText());
}
return myTypeLabel;
}
myEditorComponent.setCell(table, row, column);
myEditorComponent.setOptions(myCurrentSelector.getTypes());
myEditorComponent.setDefaultValue(getVariableData()[row].type);
myEditorComponent.setToString(o -> ((PsiType) o).getPresentableText());
return myEditorComponent;
}
});
myTable.getColumnModel().getColumn(1).setCellRenderer(new DefaultTableCellRenderer() {
private final JBComboBoxLabel myLabel = new JBComboBoxLabel();
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (value != null) {
myLabel.setText(((PsiType) value).getPresentableText());
myLabel.setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
myLabel.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground());
if (isSelected) {
myLabel.setSelectionIcon();
} else {
myLabel.setRegularIcon();
}
}
return myLabel;
}
});
}
use of com.intellij.openapi.ui.ComboBox in project intellij-community by JetBrains.
the class FindPopupScopeUIImpl method initComponents.
public void initComponents() {
Module[] modules = ModuleManager.getInstance(myProject).getModules();
String[] names = new String[modules.length];
for (int i = 0; i < modules.length; i++) {
names[i] = modules[i].getName();
}
Arrays.sort(names, String.CASE_INSENSITIVE_ORDER);
myModuleComboBox = new ComboBox<>(names);
ActionListener restartSearchListener = e -> scheduleResultsUpdate();
myModuleComboBox.addActionListener(restartSearchListener);
myDirectoryChooser = new FindPopupDirectoryChooser(myFindPopupPanel);
myScopeCombo = new ScopeChooserCombo();
myScopeCombo.init(myProject, true, true, FindSettings.getInstance().getDefaultScopeName(), new Condition<ScopeDescriptor>() {
final String projectFilesScopeName = PsiBundle.message("psi.search.scope.project");
final String moduleFilesScopeName;
{
String moduleScopeName = PsiBundle.message("search.scope.module", "");
final int ind = moduleScopeName.indexOf(' ');
moduleFilesScopeName = moduleScopeName.substring(0, ind + 1);
}
@Override
public boolean value(ScopeDescriptor descriptor) {
final String display = descriptor.getDisplay();
return !projectFilesScopeName.equals(display) && !display.startsWith(moduleFilesScopeName);
}
});
myScopeCombo.setBrowseListener(new ScopeChooserCombo.BrowseListener() {
private FindModel myModelSnapshot;
@Override
public void onBeforeBrowseStarted() {
myModelSnapshot = myHelper.getModel();
myFindPopupPanel.getCanClose().set(false);
}
@Override
public void onAfterBrowseFinished() {
if (myModelSnapshot != null) {
SearchScope scope = myScopeCombo.getSelectedScope();
if (scope != null) {
myModelSnapshot.setCustomScope(scope);
}
myFindPopupPanel.getCanClose().set(true);
}
}
});
myScopeCombo.getComboBox().addActionListener(restartSearchListener);
Disposer.register(myFindPopupPanel.getDisposable(), myScopeCombo);
}
use of com.intellij.openapi.ui.ComboBox in project intellij-community by JetBrains.
the class GenerateGetterSetterHandlerBase method getHeaderPanel.
protected static JComponent getHeaderPanel(final Project project, final TemplatesManager templatesManager, final String templatesTitle) {
final JPanel panel = new JPanel(new BorderLayout());
final JLabel templateChooserLabel = new JLabel(templatesTitle);
panel.add(templateChooserLabel, BorderLayout.WEST);
final ComboBox comboBox = new ComboBox();
templateChooserLabel.setLabelFor(comboBox);
comboBox.setRenderer(new ListCellRendererWrapper<TemplateResource>() {
@Override
public void customize(JList list, TemplateResource value, int index, boolean selected, boolean hasFocus) {
setText(value.getName());
}
});
final ComponentWithBrowseButton<ComboBox> comboBoxWithBrowseButton = new ComponentWithBrowseButton<>(comboBox, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final TemplatesPanel ui = new TemplatesPanel(project, templatesManager) {
@Override
protected boolean onMultipleFields() {
return false;
}
@Nls
@Override
public String getDisplayName() {
return StringUtil.capitalizeWords(UIUtil.removeMnemonic(StringUtil.trimEnd(templatesTitle, ":")), true);
}
};
ui.setHint("Visibility is applied according to File | Settings | Editor | Code Style | Java | Code Generation");
ui.selectNodeInTree(templatesManager.getDefaultTemplate());
if (ShowSettingsUtil.getInstance().editConfigurable(panel, ui)) {
setComboboxModel(templatesManager, comboBox);
}
}
});
setComboboxModel(templatesManager, comboBox);
comboBox.addActionListener(new ActionListener() {
public void actionPerformed(@NotNull final ActionEvent M) {
templatesManager.setDefaultTemplate((TemplateResource) comboBox.getSelectedItem());
}
});
panel.add(comboBoxWithBrowseButton, BorderLayout.CENTER);
return panel;
}
use of com.intellij.openapi.ui.ComboBox in project intellij-community by JetBrains.
the class StudyNewProjectPanel method layoutPanel.
private void layoutPanel() {
myCoursesComboBox = new ComboBox<>();
final LabeledComponent<ComboBox> coursesCombo = LabeledComponent.create(myCoursesComboBox, "Courses:", BorderLayout.WEST);
myRefreshButton = new FixedSizeButton(coursesCombo);
if (SystemInfo.isMac && !UIUtil.isUnderDarcula())
myRefreshButton.putClientProperty("JButton.buttonType", null);
myRefreshButton.setIcon(AllIcons.Actions.Refresh);
myBrowseButton = new FixedSizeButton(coursesCombo);
final JPanel comboPanel = new JPanel(new BorderLayout());
comboPanel.add(coursesCombo, BorderLayout.CENTER);
comboPanel.add(myRefreshButton, BorderLayout.EAST);
final JPanel coursesPanel = new JPanel(new BorderLayout());
coursesPanel.add(comboPanel, BorderLayout.CENTER);
coursesPanel.add(myBrowseButton, BorderLayout.EAST);
add(coursesPanel);
myAnchor = coursesCombo;
final JPanel panel = new JPanel(new BorderLayout());
final JLabel invisibleLabel = new JLabel();
invisibleLabel.setPreferredSize(new JLabel("Location: ").getPreferredSize());
panel.add(invisibleLabel, BorderLayout.WEST);
myInfoPanel = new JPanel(new VerticalFlowLayout());
myAuthorLabel = new JLabel();
myDescriptionPane = new JTextPane();
myDescriptionPane.setEditable(true);
myDescriptionPane.setEnabled(true);
myAuthorLabel.setEnabled(true);
myDescriptionPane.setPreferredSize(new Dimension(150, 200));
myDescriptionPane.setFont(coursesCombo.getFont());
myInfoPanel.add(myAuthorLabel);
myInfoPanel.add(new JBScrollPane(myDescriptionPane));
panel.add(myInfoPanel, BorderLayout.CENTER);
add(panel);
}
use of com.intellij.openapi.ui.ComboBox in project intellij-community by JetBrains.
the class PyMethodParametersInspection method createOptionsPanel.
@Nullable
@Override
public JComponent createOptionsPanel() {
ComboBox comboBox = new ComboBox(new String[] { "mcs", "metacls" });
comboBox.setSelectedItem(MCS);
comboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ComboBox cb = (ComboBox) e.getSource();
MCS = (String) cb.getSelectedItem();
}
});
JPanel option = new JPanel(new BorderLayout());
option.add(new JLabel("Metaclass method first argument name"), BorderLayout.WEST);
option.add(comboBox, BorderLayout.EAST);
final JPanel root = new JPanel(new BorderLayout());
root.add(option, BorderLayout.PAGE_START);
return root;
}
Aggregations