Java 类com.intellij.ui.ComboboxSpeedSearch 实例源码

项目:PackageTemplates    文件:SelectFileTemplateDialog.java   
@NotNull
private ComboBox getSelector() {
    ArrayList<TemplateForSearch> listTemplateForSearch = FileTemplateHelper.getTemplates(
            project,
            cbAddInternal.isSelected(),
            cbAddJ2EE.isSelected(),
            ptWrapper.getPackageTemplate().getFileTemplateSource()
    );

    ComboBox comboBox = new ComboBox(listTemplateForSearch.toArray());
    comboBox.setRenderer(new ListCellRendererWrapper<TemplateForSearch>() {
        @Override
        public void customize(JList list, TemplateForSearch template, int index, boolean selected, boolean hasFocus) {
            if (template != null) {
                setIcon(FileTemplateUtil.getIcon(template.getTemplate()));
                setText(template.getTemplate().getName());
            }
        }
    });

    new ComboboxSpeedSearch(comboBox);
    return comboBox;
}
项目:intellij-ce-playground    文件:ConfigurationModuleSelector.java   
/**
 * @deprecated use {@link #ConfigurationModuleSelector(Project, ModulesComboBox, String)} instead
 */
public ConfigurationModuleSelector(final Project project, final JComboBox modulesList, final String noModule) {
  myProject = project;
  myModulesList = modulesList;
  new ComboboxSpeedSearch(modulesList){
    protected String getElementText(Object element) {
      if (element instanceof Module){
        return ((Module)element).getName();
      } else if (element == null) {
        return noModule;
      }
      return super.getElementText(element);
    }
  };
  myModulesList.setModel(new SortedComboBoxModel<Module>(ModulesAlphaComparator.INSTANCE));
  myModulesList.setRenderer(new ModuleListCellRenderer(noModule));
}
项目:intellij-ce-playground    文件:JarArtifactFromModulesDialog.java   
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() : "";
    }
  };
}
项目:intellij-ce-playground    文件:DetailsTabForm.java   
public DetailsTabForm(@Nullable Action analyzeAction, boolean internalMode) {
  myCommentsArea.setTitle(DiagnosticBundle.message("error.dialog.comment.prompt"));
  myDetailsPane.setBackground(UIUtil.getTextFieldBackground());
  myDetailsHolder.setPreferredSize(new Dimension(IdeErrorsDialog.COMPONENTS_WIDTH, internalMode ? 500 : 205));
  myDetailsHolder.setBorder(IdeBorderFactory.createBorder());
  if (analyzeAction != null) {
    myAnalyzeStacktraceButton.setAction(analyzeAction);
  }
  else {
    myAnalyzeStacktraceButton.setVisible(false);
  }
  myAssigneeComboBox.setRenderer(new DeveloperRenderer(myAssigneeComboBox.getRenderer()));
  myAssigneeComboBox.setPrototypeDisplayValue(new Developer(0, "Here Goes Some Very Long String"));
  myAssigneeComboBox.addActionListener(new ActionListenerProxy(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      myAssigneeId = getAssigneeId();
    }
  }));
  new ComboboxSpeedSearch(myAssigneeComboBox) {
    @Override
    protected String getElementText(Object element) {
      return element == null ? "" : ((Developer) element).getSearchableText();
    }
  };
}
项目:intellij-ce-playground    文件:ModulesComboBox.java   
private ModulesComboBox(final SortedComboBoxModel<Module> model) {
  super(model);
  myModel = model;
  new ComboboxSpeedSearch(this){
    @Override
    protected String getElementText(Object element) {
      if (element instanceof Module) {
        return ((Module)element).getName();
      } else if (element == null) {
        return "";
      }
      return super.getElementText(element);
    }
  };
  setRenderer(new ModuleListCellRenderer());
}
项目:intellij-ce-playground    文件:TemplateKindCombo.java   
public TemplateKindCombo() {
  //noinspection unchecked
  getComboBox().setRenderer(new ListCellRendererWrapper() {
    @Override
    public void customize(final JList list, final Object value, final int index, final boolean selected, final boolean cellHasFocus) {
      if (value instanceof Trinity) {
        setText((String)((Trinity)value).first);
        setIcon ((Icon)((Trinity)value).second);
      }
    }
  });

  new ComboboxSpeedSearch(getComboBox()) {
    @Override
    protected String getElementText(Object element) {
      if (element instanceof Trinity) {
        return (String)((Trinity)element).first;
      }
      return null;
    }
  }.setComparator(new SpeedSearchComparator(true));
  setButtonListener(null);
}
项目:tools-idea    文件:JarArtifactFromModulesDialog.java   
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() : "";
    }
  };
}
项目:tools-idea    文件:DetailsTabForm.java   
public DetailsTabForm(@Nullable Action analyzeAction, boolean internalMode) {
  myCommentsArea.setTitle(DiagnosticBundle.message("error.dialog.comment.prompt"));
  myDetailsPane.setBackground(UIUtil.getTextFieldBackground());
  myDetailsPane.setPreferredSize(new Dimension(IdeErrorsDialog.COMPONENTS_WIDTH, internalMode ? 500 : 205));
  myDetailsHolder.setBorder(IdeBorderFactory.createBorder());
  if (analyzeAction != null) {
    myAnalyzeStacktraceButton.setAction(analyzeAction);
  }
  else {
    myAnalyzeStacktraceButton.setVisible(false);
  }
  myAssigneeComboBox.setRenderer(new DeveloperRenderer(myAssigneeComboBox.getRenderer()));
  myAssigneeComboBox.setPrototypeDisplayValue(new Developer(0, "Here Goes Some Very Long String"));
  myAssigneeComboBox.addActionListener(new ActionListenerProxy(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      myAssigneeId = getAssigneeId();
    }
  }));
  new ComboboxSpeedSearch(myAssigneeComboBox) {
    @Override
    protected String getElementText(Object element) {
      return element == null ? "" : ((Developer) element).getSearchableText();
    }
  };
}
项目:tools-idea    文件:TemplateKindCombo.java   
public TemplateKindCombo() {
  getComboBox().setRenderer(new ListCellRendererWrapper() {
    @Override
    public void customize(final JList list, final Object value, final int index, final boolean selected, final boolean cellHasFocus) {
      if (value instanceof Trinity) {
        setText((String)((Trinity)value).first);
        setIcon ((Icon)((Trinity)value).second);
      }
    }
  });

  new ComboboxSpeedSearch(getComboBox()) {
    @Override
    protected String getElementText(Object element) {
      if (element instanceof Trinity) {
        return (String)((Trinity)element).first;
      }
      return null;
    }
  };
  setButtonListener(null);
}
项目:intellij-xquery    文件:DataSourceSelector.java   
public DataSourceSelector(JComboBox dataSourceList) {
    this.dataSourceList = dataSourceList;
    new ComboboxSpeedSearch(this.dataSourceList) {
        protected String getElementText(Object element) {
            if (element instanceof XQueryDataSourceConfiguration) {
                return ((XQueryDataSourceConfiguration) element).NAME;
            } else if (element == null) {
                return NO_DATA_SOURCE;
            }
            return super.getElementText(element);
        }
    };
    this.dataSourceList.setModel(dataSourcesModel);
    this.dataSourceList.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 XQueryDataSourceConfiguration) {
                final XQueryDataSourceConfiguration dataSourceConfiguration = (XQueryDataSourceConfiguration) value;
                setText(dataSourceConfiguration.NAME);
            } else if (value == null) {
                setText(NO_DATA_SOURCE);
            }
        }
    });
}
项目:intellij-xquery    文件:ConfigurationModuleSelector.java   
public ConfigurationModuleSelector(final Project project, final JComboBox<Module> modulesList, final String noModule) {
    myProject = project;
    myModulesList = modulesList;
    new ComboboxSpeedSearch(modulesList) {
        protected String getElementText(Object element) {
            if (element instanceof Module) {
                return ((Module) element).getName();
            } else if (element == null) {
                return noModule;
            }
            return super.getElementText(element);
        }
    };
    myModulesList.setModel(new SortedComboBoxModel<>(ModulesAlphaComparator.INSTANCE));
    myModulesList.setRenderer(new ModuleListCellRenderer(noModule));
}
项目:intellij-scratch    文件:NewScratchFileAction.java   
private JComboBox createCombo(List<Language> languages) {
  JComboBox jComboBox = new ComboBox(new CollectionComboBoxModel(languages));
  jComboBox.setRenderer(new ListCellRendererWrapper<Language>() {
    @Override
    public void customize(JList list, Language lang, int index, boolean selected, boolean hasFocus) {
      if (lang != null) {
        setText(lang.getDisplayName());
        LanguageFileType associatedLanguage = lang.getAssociatedFileType();
        if (associatedLanguage != null) setIcon(associatedLanguage.getIcon());
      }
    }
  });
  new ComboboxSpeedSearch(jComboBox) {
    @Override
    protected String getElementText(Object element) {
      return element instanceof Language ? ((Language) element).getDisplayName() : null;
    }
  };
  Language previous = myProject != null ? myProject.getUserData(SCRATCH_LANGUAGE) : null;
  if (previous != null) {
    jComboBox.setSelectedItem(previous);
  }

  return jComboBox;
}
项目:consulo    文件:ModulesComboBox.java   
private ModulesComboBox(final SortedComboBoxModel<Module> model) {
  super(model);
  myModel = model;
  new ComboboxSpeedSearch(this){
    @Override
    protected String getElementText(Object element) {
      if (element instanceof Module) {
        return ((Module)element).getName();
      } else if (element == null) {
        return "";
      }
      return super.getElementText(element);
    }
  };
  setRenderer(new ModuleListCellRenderer());
}
项目:consulo    文件:ModuleDescriptionsComboBox.java   
public ModuleDescriptionsComboBox() {
  myModel = new SortedComboBoxModel<>(Comparator.comparing(description -> description != null ? description.getName() : "",
                                                           String.CASE_INSENSITIVE_ORDER));
  setModel(myModel);
  new ComboboxSpeedSearch(this){
    @Override
    protected String getElementText(Object element) {
      if (element instanceof ModuleDescription) {
        return ((ModuleDescription)element).getName();
      }
      else {
        return "";
      }
    }
  };
  setRenderer(new ModuleDescriptionListCellRenderer());
}
项目:consulo    文件:TemplateKindCombo.java   
public TemplateKindCombo() {
  getComboBox().setRenderer(new ListCellRendererWrapper() {
    @Override
    public void customize(final JList list, final Object value, final int index, final boolean selected, final boolean cellHasFocus) {
      if (value instanceof Trinity) {
        setText((String)((Trinity)value).first);
        setIcon ((Icon)((Trinity)value).second);
      }
    }
  });

  new ComboboxSpeedSearch(getComboBox()) {
    @Override
    protected String getElementText(Object element) {
      if (element instanceof Trinity) {
        return (String)((Trinity)element).first;
      }
      return null;
    }
  };
  setButtonListener(null);
}
项目:consulo-java    文件:ConfigurationModuleSelector.java   
/**
 * @deprecated use {@link #ConfigurationModuleSelector(Project, ModulesComboBox, String)} instead
 */
public ConfigurationModuleSelector(final Project project, final JComboBox<Module> modulesList, final String noModule)
{
    myProject = project;
    myModulesList = modulesList;
    myModulesDescriptionsComboBox = null;
    new ComboboxSpeedSearch(modulesList)
    {
        protected String getElementText(Object element)
        {
            if(element instanceof Module)
            {
                return ((Module) element).getName();
            }
            else if(element == null)
            {
                return noModule;
            }
            return super.getElementText(element);
        }
    };
    myModulesList.setModel(new SortedComboBoxModel<>(ModulesAlphaComparator.INSTANCE));
    myModulesList.setRenderer(new ModuleListCellRenderer(noModule));
}
项目:consulo-java    文件:JarArtifactFromModulesDialog.java   
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() : "";
        }
    };
}
项目:idea-php-class-templates    文件:PhpNewExceptionClassDialog.java   
@Override
protected void subInit() {
    super.subInit();

    this.myMessageTextField = new EditorTextField("");
    this.myKindUpDownHint      = new JLabel();
    this.myKindUpDownHint.setIcon(PlatformIcons.UP_DOWN_ARROWS);
    this.myKindUpDownHint.setToolTipText(PhpBundle.message("actions.new.php.base.arrows.kind.tooltip"));


    this.myKindComboBox = new ComboBox<String>();
    this.myKindComboBox.setMinimumAndPreferredWidth(400);
    this.myKindComboBox.setRenderer(new ListCellRendererWrapper<Trinity>() {
        public void customize(JList list, Trinity value, int index, boolean selected, boolean hasFocus) {
            this.setText((String)value.first);
            this.setIcon((Icon)value.second);
        }
    });
    ComboboxSpeedSearch var10001 = new ComboboxSpeedSearch(this.myKindComboBox) {
        protected String getElementText(Object element) {
            return (String)((Trinity)element).first;
        }
    };
    KeyboardShortcut up = new KeyboardShortcut(KeyStroke.getKeyStroke(38, 0), (KeyStroke)null);
    KeyboardShortcut down = new KeyboardShortcut(KeyStroke.getKeyStroke(40, 0), (KeyStroke)null);
    AnAction kindArrow = PhpNewFileDialog.getCbArrowAction(this.myKindComboBox);
    kindArrow.registerCustomShortcutSet(new CustomShortcutSet(new Shortcut[]{up, down}), this.myNameTextField);
    List<Trinity> exceptionTypes = this.getExceptionTypes();

    for(Trinity type : exceptionTypes) {
        this.myKindComboBox.addItem(type);
    }
}
项目:intellij-ce-playground    文件:AttributesPanel.java   
public AttributesPanel() {
  myBackButton.setIcon(AllIcons.Actions.Back);
  myBackButton.setBorder(BORDER);

  myPaletteScrollPane.setVisible(false);
  myAdvancedFilterCheckBox.setVisible(false);
  myAttrGroupCombo.setVisible(false);

  new ComboboxSpeedSearch(myThemeCombo);

  myBackButton.setToolTipText("Back to the theme");

  myAttributesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myAttributesTable.setTableHeader(null);

  // TODO: TableSpeedSearch does not really support filtered tables since it incorrectly uses the model to calculate the number
  // of available cells. Fix this.
  new TableSpeedSearch(myAttributesTable) {
    @Override
    protected int getElementCount() {
      return myComponent.getRowCount() * myComponent.getColumnCount();
    }
  };

  mySubStyleLabel.setVisible(false);
  mySubStyleLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

  myPalette.setShowCheckeredBackground(true);

  // Stop the combo box long items from blocking the right panel from being able to be made small.
  myThemeCombo.setMinimumSize(new Dimension(10, myThemeCombo.getMinimumSize().height));
  myThemeCombo.setPreferredSize(new Dimension(10, myThemeCombo.getPreferredSize().height));
}
项目:tools-idea    文件:ConfigurationModuleSelector.java   
public ConfigurationModuleSelector(final Project project, final JComboBox modulesList, String noModule) {
  myNoModule = noModule;
  myProject = project;
  myModulesList = modulesList;
  new ComboboxSpeedSearch(modulesList){
    protected String getElementText(Object element) {
      if (element instanceof Module){
        return ((Module)element).getName();
      } else if (element == null) {
        return myNoModule;
      }
      return super.getElementText(element);
    }
  };
  myModulesList.setModel(myModules);
  myModulesList.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 Module) {
        final Module module = (Module)value;
        setIcon(ModuleType.get(module).getIcon());
        setText(module.getName());
      }
      else if (value == null) {
        setText(myNoModule);
      }
    }
  });
}
项目:tools-idea    文件:ModulesCombobox.java   
private ModulesCombobox(final SortedComboBoxModel<Module> model) {
  super(model);
  myModel = model;
  new ComboboxSpeedSearch(this){
    @Override
    protected String getElementText(Object element) {
      if (element instanceof Module) {
        return ((Module)element).getName();
      } else if (element == null) {
        return "";
      }
      return super.getElementText(element);
    }
  };
  setRenderer(new ListCellRendererWrapper<Module>() {
    @Override
    public void customize(JList list, Module value, int index, boolean selected, boolean hasFocus) {
      if (value != null) {
        setText(value.getName());
        setIcon(ModuleType.get(value).getIcon());
      }
      else {
        setText("[none]");
      }
    }
  });
}
项目:intellij-xquery    文件:VariableDialog.java   
public VariableDialog() {
    panel.setName(DIALOG_PANEL);
    name.getComponent().setName(NAME);
    namespace.getComponent().setName(NAMESPACE);
    value.getComponent().setRows(7);
    value.getComponent().setColumns(50);
    value.getComponent().setName(VALUE);
    type.getComponent().setModel(typesModel);
    populateTypesList();
    new ComboboxSpeedSearch(type.getComponent());
}
项目:consulo    文件:DetailsTabForm.java   
public DetailsTabForm(@Nullable Action analyzeAction, boolean internalMode) {
  myCommentsArea.setTitle(DiagnosticBundle.message("error.dialog.comment.prompt"));
  myCommentsArea.setLabelPosition(BorderLayout.NORTH);
  myDetailsPane.setBackground(UIUtil.getTextFieldBackground());
  myDetailsPane.setPreferredSize(new Dimension(IdeErrorsDialog.COMPONENTS_WIDTH, internalMode ? 500 : 205));
  myDetailsHolder.setBorder(IdeBorderFactory.createBorder());
  if (analyzeAction != null) {
    myAnalyzeStacktraceButton.setAction(analyzeAction);
  }
  else {
    myAnalyzeStacktraceButton.setVisible(false);
  }
  myAssigneeComboBox.setRenderer(new DeveloperRenderer(myAssigneeComboBox.getRenderer()));
  myAssigneeComboBox.setPrototypeDisplayValue(new Developer(0, "Here Goes Some Very Long String"));
  myAssigneeComboBox.addActionListener(new ActionListenerProxy(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      myAssigneeId = getAssigneeId();
    }
  }));
  new ComboboxSpeedSearch(myAssigneeComboBox) {
    @Override
    protected String getElementText(Object element) {
      return element == null ? "" : ((Developer) element).getSearchableText();
    }
  };
}
项目:consulo    文件:ScopeChooserCombo.java   
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 ComboBox<ScopeDescriptor> combo = (ComboBox<ScopeDescriptor>)getComboBox();
  combo.setMinimumAndPreferredWidth(JBUI.scale(300));
  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;
    }
  };
}
项目:idea-php-class-templates    文件:PhpNewTemplateClassDialog.java   
@Override
protected void subInit() {
    super.subInit();

    this.myTemplateAttributes = new FormBuilder();
    this.myTemplateAttributesFields = new Hashtable<String, EditorTextField>();

    this.myKindUpDownHint = new JLabel();
    this.myKindUpDownHint.setIcon(PlatformIcons.UP_DOWN_ARROWS);
    this.myKindUpDownHint.setToolTipText("Pressing Up or Down arrows while in editor changes the template");


    this.myKindComboBox = new ComboBox<String>();
    this.myKindComboBox.setMinimumAndPreferredWidth(400);
    this.myKindComboBox.setRenderer(new ListCellRendererWrapper<Trinity>() {
        public void customize(JList list, Trinity value, int index, boolean selected, boolean hasFocus) {
            this.setText((String) value.first);
            this.setIcon((Icon) value.second);
        }
    });
    ComboboxSpeedSearch var10001 = new ComboboxSpeedSearch(this.myKindComboBox) {
        protected String getElementText(Object element) {
            return (String) ((Trinity) element).first;
        }
    };
    KeyboardShortcut up = new KeyboardShortcut(KeyStroke.getKeyStroke(38, 0), (KeyStroke) null);
    KeyboardShortcut down = new KeyboardShortcut(KeyStroke.getKeyStroke(40, 0), (KeyStroke) null);
    AnAction kindArrow = PhpNewFileDialog.getCbArrowAction(this.myKindComboBox);
    kindArrow.registerCustomShortcutSet(new CustomShortcutSet(new Shortcut[]{up, down}), this.myNameTextField);
    List<Trinity> availableTemplates = this.getAvailableTemplates();

    for (Trinity type : availableTemplates) {
        this.myKindComboBox.addItem(type);
    }

    this.myKindComboBox.addActionListener(e -> {
        this.updateTemplateAttributes();
    });

    this.updateTemplateAttributes();
}