Search in sources :

Example 1 with ComboboxSpeedSearch

use of com.intellij.ui.ComboboxSpeedSearch in project intellij-community by JetBrains.

the class JarArtifactFromModulesDialog method setupModulesCombobox.

private void setupModulesCombobox(PackagingElementResolvingContext context) {
    final Module[] modules = context.getModulesProvider().getModules().clone();
    Arrays.sort(modules, ModulesAlphaComparator.INSTANCE);
    if (modules.length > 1) {
        myModuleComboBox.addItem(null);
    }
    for (Module module : modules) {
        myModuleComboBox.addItem(module);
    }
    myModuleComboBox.setRenderer(new ModuleListRenderer(myModuleComboBox));
    new ComboboxSpeedSearch(myModuleComboBox) {

        @Override
        protected String getElementText(Object element) {
            return element instanceof Module ? ((Module) element).getName() : "";
        }
    };
}
Also used : Module(com.intellij.openapi.module.Module) ComboboxSpeedSearch(com.intellij.ui.ComboboxSpeedSearch)

Example 2 with ComboboxSpeedSearch

use of com.intellij.ui.ComboboxSpeedSearch in project intellij-community by JetBrains.

the class SearchDialog method buildOptions.

protected void buildOptions(JPanel searchOptions) {
    recursiveMatching = new JCheckBox(SSRBundle.message("recursive.matching.checkbox"), true);
    if (isRecursiveSearchEnabled()) {
        searchOptions.add(UIUtil.createOptionLine(recursiveMatching));
    }
    caseSensitiveMatch = new JCheckBox(FindBundle.message("find.options.case.sensitive"), true);
    searchOptions.add(UIUtil.createOptionLine(caseSensitiveMatch));
    final List<FileType> types = new ArrayList<>();
    for (FileType fileType : StructuralSearchUtil.getSuitableFileTypes()) {
        if (StructuralSearchUtil.getProfileByFileType(fileType) != null) {
            types.add(fileType);
        }
    }
    Collections.sort(types, (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName()));
    final DefaultComboBoxModel<FileType> comboBoxModel = new DefaultComboBoxModel<>(types.toArray(new FileType[types.size()]));
    fileTypes = new ComboBox<>(comboBoxModel);
    fileTypes.setRenderer(new FileTypeRenderer());
    new ComboboxSpeedSearch(fileTypes) {

        @Override
        protected String getElementText(Object element) {
            return ((FileType) element).getName();
        }
    };
    contexts = new ComboBox<>();
    contexts.setPreferredSize(new Dimension(60, -1));
    dialects = new ComboBox<>();
    dialects.setRenderer(new ListCellRendererWrapper<Language>() {

        @Override
        public void customize(JList list, Language value, int index, boolean selected, boolean hasFocus) {
            if (value == null) {
                setText("None");
            } else {
                setText(value.getDisplayName());
            }
        }
    });
    dialects.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            updateEditor();
        }
    });
    new ComboboxSpeedSearch(dialects);
    dialects.setPreferredSize(new Dimension(120, -1));
    final JLabel jLabel = new JLabel(SSRBundle.message("search.dialog.file.type.label"));
    final JLabel jLabel2 = new JLabel(SSRBundle.message("search.dialog.context.label"));
    final JLabel jLabel3 = new JLabel(SSRBundle.message("search.dialog.file.dialect.label"));
    searchOptions.add(UIUtil.createOptionLine(new JComponent[] { jLabel, fileTypes, (JComponent) Box.createHorizontalStrut(8), jLabel2, contexts, (JComponent) Box.createHorizontalStrut(8), jLabel3, dialects }));
    jLabel.setLabelFor(fileTypes);
    jLabel2.setLabelFor(contexts);
    jLabel3.setLabelFor(dialects);
    detectFileTypeAndDialect();
    fileTypes.setSelectedItem(ourFtSearchVariant);
    fileTypes.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateDialectsAndContexts();
                updateEditor();
                initiateValidation();
            }
        }
    });
    dialects.setSelectedItem(ourDialect);
    contexts.setSelectedItem(ourContext);
    updateDialectsAndContexts();
}
Also used : ItemEvent(java.awt.event.ItemEvent) Language(com.intellij.lang.Language) FileType(com.intellij.openapi.fileTypes.FileType) LanguageFileType(com.intellij.openapi.fileTypes.LanguageFileType) FileTypeRenderer(com.intellij.openapi.fileTypes.impl.FileTypeRenderer) ItemListener(java.awt.event.ItemListener) ComboboxSpeedSearch(com.intellij.ui.ComboboxSpeedSearch)

Example 3 with ComboboxSpeedSearch

use of com.intellij.ui.ComboboxSpeedSearch in project intellij-community by JetBrains.

the class FileColorConfigurationEditDialog method createNorthPanel.

@Override
protected JComponent createNorthPanel() {
    final List<NamedScope> scopeList = new ArrayList<>();
    final Project project = myManager.getProject();
    final NamedScopesHolder[] scopeHolders = NamedScopeManager.getAllNamedScopeHolders(project);
    for (final NamedScopesHolder scopeHolder : scopeHolders) {
        final NamedScope[] scopes = scopeHolder.getScopes();
        Collections.addAll(scopeList, scopes);
    }
    CustomScopesProviderEx.filterNoSettingsScopes(project, scopeList);
    for (final NamedScope scope : scopeList) {
        myScopeNames.put(scope.getName(), scope);
    }
    myScopeComboBox = new JComboBox(ArrayUtil.toStringArray(myScopeNames.keySet()));
    myScopeComboBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateCustomButton();
            updateOKButton();
        }
    });
    new ComboboxSpeedSearch(myScopeComboBox);
    final JLabel pathLabel = new JLabel("Scope:");
    pathLabel.setDisplayedMnemonic('S');
    pathLabel.setLabelFor(myScopeComboBox);
    final JLabel colorLabel = new JLabel("Color:");
    JPanel result = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = JBUI.insets(5);
    gbc.gridx = 0;
    result.add(pathLabel, gbc);
    result.add(colorLabel, gbc);
    gbc.gridx = 1;
    gbc.weightx = 1;
    result.add(myScopeComboBox, gbc);
    result.add(myColorSelectionComponent, gbc);
    return result;
}
Also used : ActionEvent(java.awt.event.ActionEvent) NamedScopesHolder(com.intellij.psi.search.scope.packageSet.NamedScopesHolder) ArrayList(java.util.ArrayList) Project(com.intellij.openapi.project.Project) NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) ActionListener(java.awt.event.ActionListener) ComboboxSpeedSearch(com.intellij.ui.ComboboxSpeedSearch)

Example 4 with ComboboxSpeedSearch

use of com.intellij.ui.ComboboxSpeedSearch in project intellij-community by JetBrains.

the class ScopeChooserCombo method init.

public void init(final Project project, final boolean suggestSearchInLibs, final boolean prevSearchWholeFiles, final String preselect, @Nullable Condition<ScopeDescriptor> scopeFilter) {
    mySuggestSearchInLibs = suggestSearchInLibs;
    myPrevSearchFiles = prevSearchWholeFiles;
    myProject = project;
    myScopeListener = () -> {
        final SearchScope selectedScope = getSelectedScope();
        rebuildModel();
        if (selectedScope != null) {
            selectScope(selectedScope.getDisplayName());
        }
    };
    myScopeFilter = scopeFilter;
    myNamedScopeManager = NamedScopeManager.getInstance(project);
    myNamedScopeManager.addScopeListener(myScopeListener);
    myValidationManager = DependencyValidationManager.getInstance(project);
    myValidationManager.addScopeListener(myScopeListener);
    addActionListener(createScopeChooserListener());
    final JComboBox<ScopeDescriptor> combo = getComboBox();
    combo.setRenderer(new ScopeDescriptionWithDelimiterRenderer());
    rebuildModel();
    selectScope(preselect);
    new ComboboxSpeedSearch(combo) {

        @Override
        protected String getElementText(Object element) {
            if (element instanceof ScopeDescriptor) {
                final ScopeDescriptor descriptor = (ScopeDescriptor) element;
                return descriptor.getDisplay();
            }
            return null;
        }
    };
}
Also used : SearchScope(com.intellij.psi.search.SearchScope) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) ComboboxSpeedSearch(com.intellij.ui.ComboboxSpeedSearch)

Aggregations

ComboboxSpeedSearch (com.intellij.ui.ComboboxSpeedSearch)4 Language (com.intellij.lang.Language)1 FileType (com.intellij.openapi.fileTypes.FileType)1 LanguageFileType (com.intellij.openapi.fileTypes.LanguageFileType)1 FileTypeRenderer (com.intellij.openapi.fileTypes.impl.FileTypeRenderer)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 SearchScope (com.intellij.psi.search.SearchScope)1 NamedScope (com.intellij.psi.search.scope.packageSet.NamedScope)1 NamedScopesHolder (com.intellij.psi.search.scope.packageSet.NamedScopesHolder)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 ArrayList (java.util.ArrayList)1