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

项目:intellij-ce-playground    文件:LibrariesDownloadUiUtil.java   
public static void initAsyncComboBoxModel(@NotNull final JComboBox jComboBox,
                                          @NotNull final String groupId,
                                          final URL... localUrls) {
  final List<Object> items = new ArrayList<Object>();

  new UiNotifyConnector.Once(jComboBox, new Activatable() {
    @Override
    public void showNotify() {
      loadItems(jComboBox, items, groupId, localUrls);
    }

    @Override
    public void hideNotify() {
    }
  });

  items.add("loading...");
  jComboBox.setModel(new CollectionComboBoxModel(items, items.get(0)));
  jComboBox.setEnabled(false);
}
项目:intellij-ce-playground    文件:RestConfigurationEditor.java   
public RestConfigurationEditor(final Project project,
                               AbstractPythonRunConfiguration configuration,
                               CollectionComboBoxModel model) {
  myCommonOptionsForm = PyCommonOptionsFormFactory.getInstance().createForm(configuration.getCommonOptionsFormData());
  myCommonOptionsPlaceholder.add(myCommonOptionsForm.getMainPanel());
  myProject = project;
  myTasks.setModel(model);
  myTasks.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent actionEvent) {
      Object task = myTasks.getSelectedItem();
      if (task != null &&
          (task.toString().equals("rst2latex") ||
           task.toString().equals("rst2odt")))
        myOpenInBrowser.setEnabled(false);
      else
        myOpenInBrowser.setEnabled(true);
    }
  });
  myOpenInBrowser.setSelected(false);

  setAnchor(myCommonOptionsForm.getAnchor());
}
项目:intellij-ce-playground    文件:PythonSdkChooserCombo.java   
private void showOptions(final Project project) {
  final PyConfigurableInterpreterList interpreterList = PyConfigurableInterpreterList.getInstance(project);
  final Sdk[] sdks = interpreterList.getModel().getSdks();
  PythonSdkDetailsStep.show(project, sdks, null, this, getButton().getLocationOnScreen(), new NullableConsumer<Sdk>() {
    @Override
    public void consume(@Nullable Sdk sdk) {
      if (sdk == null) return;
      final PySdkService sdkService = PySdkService.getInstance();
      sdkService.restoreSdk(sdk);

      final ProjectSdksModel projectSdksModel = interpreterList.getModel();
      if (projectSdksModel.findSdk(sdk) == null) {
        projectSdksModel.addSdk(sdk);
        try {
          projectSdksModel.apply();
        }
        catch (ConfigurationException e) {
          LOG.error("Error adding new python interpreter " + e.getMessage());
        }
      }
      //noinspection unchecked
      getComboBox().setModel(new CollectionComboBoxModel(interpreterList.getAllPythonSdks(), sdk));
    }
  }, true);
}
项目:intellij-ce-playground    文件:RepositoryLibraryPropertiesEditor.java   
private void initVersionKindSelector() {
  List<String> versionKinds = Arrays.asList(
    ProjectBundle.message("maven.version.kind.selector.release"),
    ProjectBundle.message("maven.version.kind.selector.latest"),
    ProjectBundle.message("maven.version.kind.selector.select"));
  CollectionComboBoxModel<String> versionKindSelectorModel = new CollectionComboBoxModel<String>(versionKinds);
  //noinspection unchecked
  versionKindSelector.setModel(versionKindSelectorModel);
  versionKindSelector.addItemListener(new ItemListener() {
    @Override
    public void itemStateChanged(ItemEvent e) {
      VersionKind newVersionKind = getSelectedVersionKind();
      if (newVersionKind != versionKind) {
        versionKind = newVersionKind;
        versionKindChanged();
      }
    }
  });
  setSelectedVersionKind(getVersionKind(model.getVersion()));
}
项目:intellij-ocaml    文件:OCamlToolWindowSettingsForm.java   
public OCamlToolWindowSettingsForm(@NotNull final Project project) {
    myProject = project;

    final List<Sdk> allSdks = ProjectJdkTable.getInstance().getSdksOfType(OCamlSdkType.getInstance());
    allSdks.add(0, null);
    mySdkComboBox.setModel(new CollectionComboBoxModel(allSdks, null));
    mySdkComboBox.setRenderer(new SdkListCellRenderer("<Project Default>"));

    myConfigureButton.addActionListener(new ActionListener() {
        public void actionPerformed(@NotNull final ActionEvent e) {
            final ProjectJdksEditor editor = new ProjectJdksEditor((Sdk) mySdkComboBox.getSelectedItem(),
                myProject, mySdkComboBox);
            editor.show();
            if (editor.isOK()) {
                setSelectedSdk(editor.getSelectedJdk());
            }
        }
    });

    final FileChooserDescriptor workingDirChooserDescriptor = new FileChooserDescriptor(false, true, false, false, false, false);
    workingDirChooserDescriptor.setRoot(myProject.getBaseDir());
    myWorkingDirectoryEditor.addBrowseFolderListener("Select Working Directory", "", myProject, workingDirChooserDescriptor);
}
项目:defrac-plugin-intellij    文件:NewDefracSdkDialog.java   
public NewDefracSdkDialog(@Nullable final Project project,
                          @NotNull final List<Sdk> jdks,
                          @NotNull final Sdk selectedJdk,
                          @NotNull final List<DefracVersion> defracVersions,
                          @NotNull final DefracVersion selectedDefracVersion) {
  super(project);

  setTitle("Create New Defrac SDK");

  jdkLabel.setLabelFor(jdkComboBox);
  defracVersionLabel.setLabelFor(defracVersionComboBox);

  //noinspection unchecked
  jdkComboBox.setModel(new CollectionComboBoxModel(jdks, selectedJdk));
  jdkComboBox.setRenderer(new SdkRenderer());

  //noinspection unchecked
  defracVersionComboBox.setModel(new CollectionComboBoxModel(defracVersions, selectedDefracVersion));
  defracVersionComboBox.setRenderer(new DefracVersionRenderer());

  init();
}
项目:tools-idea    文件:LibrariesDownloadUiUtil.java   
public static void initAsyncComboBoxModel(@NotNull final JComboBox jComboBox,
                                          @NotNull final String groupId,
                                          final URL... localUrls) {
  final List<Object> items = new ArrayList<Object>();

  new UiNotifyConnector.Once(jComboBox, new Activatable() {
    @Override
    public void showNotify() {
      loadItems(jComboBox, items, groupId, localUrls);
    }

    @Override
    public void hideNotify() {
    }
  });

  items.add("loading...");
  jComboBox.setModel(new CollectionComboBoxModel(items, items.get(0)));
  jComboBox.setEnabled(false);
}
项目:module-code-style    文件:ModuleCodeStyleConfigurable.java   
private void loadAvailableCodeStyleSchemes() {
    final CodeStyleSchemes schemes = PersistableCodeStyleSchemes.getInstance();
    if (schemes != null) {
        final List<String> schemesList = new ArrayList<String>(schemes.getSchemes().length);

        String selectedCodeStyleSchemeName = getModuleCodeStyleSchemeName();
        boolean schemeExists = false;
        for (CodeStyleScheme scheme : schemes.getSchemes()) {
            schemesList.add(scheme.getName());
            if (scheme.getName().equals(selectedCodeStyleSchemeName))
                schemeExists = true;
        }

        if (!schemeExists)
            selectedCodeStyleSchemeName = ModuleCodeStyleState.defaultState().getCodeStyleSchemeName();

        final ComboBoxModel model = new CollectionComboBoxModel(schemesList, selectedCodeStyleSchemeName);
        codeStyleSchemesComboBox.setModel(model);
    } else {
        mainPanel.setEnabled(false);
    }
}
项目: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;
}
项目:intellij-ce-playground    文件:SaveProjectAsTemplateDialog.java   
protected SaveProjectAsTemplateDialog(@NotNull Project project, @Nullable VirtualFile descriptionFile) {
  super(project);
  myProject = project;

  setTitle("Save Project As Template");
  myName.setText(project.getName());

  Module[] modules = ModuleManager.getInstance(project).getModules();
  if (modules.length < 2) {
    myModuleLabel.setVisible(false);
    myModuleCombo.setVisible(false);
  }
  else {
    List<String> items = new ArrayList<String>(ContainerUtil.map(modules, new Function<Module, String>() {
      @Override
      public String fun(Module module) {
        return module.getName();
      }
    }));
    items.add(WHOLE_PROJECT);
    myModuleCombo.setModel(new CollectionComboBoxModel(items, WHOLE_PROJECT));
  }
  myDescription.setFileType(FileTypeManager.getInstance().getFileTypeByExtension(".html"));
  if (descriptionFile != null) {
    try {
      String s = VfsUtilCore.loadText(descriptionFile);
      myDescription.setText(s);
    }
    catch (IOException e) {
      LOG.error(e);
    }
  }
  init();
}
项目:intellij-ce-playground    文件:VersionsComponent.java   
private JComboBox createComboBox(String ri) {
  final JComboBox comboBox = new JComboBox();

  List<Artifact> versions = getSupportedVersions(ri);
  comboBox.setModel(new CollectionComboBoxModel(versions, null));

  comboBox.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      updateCurrentVersion(comboBox);
    }
  });

  return comboBox;
}
项目:intellij-ce-playground    文件:DetectedRootsChooser.java   
@Override
public TableCellEditor getEditor(DetectedRootData o) {
  final ComboBox comboBox = new ComboBox(new CollectionComboBoxModel(Arrays.asList(o.getAllRoots()), o.getSelectedRoot()));
  comboBox.setRenderer(new ListCellRendererWrapper<DetectedProjectRoot>() {
    @Override
    public void customize(JList list, DetectedProjectRoot value, int index, boolean selected, boolean hasFocus) {
      setText(value.getRootTypeName());
    }
  });
  return new DefaultCellEditor(comboBox);
}
项目:intellij-ce-playground    文件:FileTypeChooser.java   
private FileTypeChooser(@NotNull List<String> patterns, @NotNull String fileName) {
  super(true);
  myFileName = fileName;

  myOpenInIdea.setText("Open matching files in " + ApplicationNamesInfo.getInstance().getFullProductName() + ":");

  FileType[] fileTypes = FileTypeManager.getInstance().getRegisteredFileTypes();
  Arrays.sort(fileTypes, new Comparator<FileType>() {
    @Override
    public int compare(final FileType fileType1, final FileType fileType2) {
      if (fileType1 == null) {
        return 1;
      }
      if (fileType2 == null) {
        return -1;
      }
      return fileType1.getDescription().compareToIgnoreCase(fileType2.getDescription());
    }
  });

  final DefaultListModel model = new DefaultListModel();
  for (FileType type : fileTypes) {
    if (!type.isReadOnly() && type != FileTypes.UNKNOWN && !(type instanceof NativeFileType)) {
      model.addElement(type);
    }
  }
  myList.setModel(model);
  myPattern.setModel(new CollectionComboBoxModel(ContainerUtil.map(patterns, FunctionUtil.<String>id()), patterns.get(0)));

  setTitle(FileTypesBundle.message("filetype.chooser.title"));
  init();
}
项目:intellij-ce-playground    文件:LibrariesDownloadUiUtil.java   
private static void loadItems(@NotNull final JComboBox jComboBox,
                              final List<Object> items,
                              final String groupId,
                              final URL... localUrls) {
  final ModalityState state = ModalityState.current();
  ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
    @Override
    public void run() {
      final List<Object> newItems = new ArrayList<Object>();
      newItems.addAll(Arrays.asList(LibrariesDownloadAssistant.getVersions(groupId, localUrls)));

      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          items.clear();
          if (!newItems.isEmpty()) {
            items.addAll(newItems);
            final CollectionComboBoxModel model = (CollectionComboBoxModel)jComboBox.getModel();
            model.update();
            jComboBox.setSelectedIndex(0);
          }
          jComboBox.setEnabled(true);
        }
      }, state);
    }
  }

  );
}
项目:intellij-ce-playground    文件:PyPluginCommonOptionsForm.java   
public void setSdkHome(String sdkHome) {
  List<Sdk> sdkList = new ArrayList<Sdk>();
  sdkList.add(null);
  final List<Sdk> allSdks = PythonSdkType.getAllSdks();
  Collections.sort(allSdks, new PreferredSdkComparator());
  Sdk selection = null;
  for (Sdk sdk : allSdks) {
    String homePath = sdk.getHomePath();
    if (homePath != null && sdkHome != null && FileUtil.pathsEqual(homePath, sdkHome)) selection = sdk;
    sdkList.add(sdk);
  }

  myInterpreterComboBox.setModel(new CollectionComboBoxModel(sdkList, selection));
}
项目:intellij-ce-playground    文件:BuildoutConfigPanel.java   
public void reset() {
  final List<File> scriptFiles = BuildoutFacet.getScripts(BuildoutFacet.getInstance(myModule), myModule.getProject().getBaseDir());
  final List<String> scripts = ContainerUtil.map(scriptFiles, new Function<File, String>() {
    @Override
    public String fun(File file) {
      return file.getPath();
    }
  });
  myScript.getComboBox().setModel(new CollectionComboBoxModel(scripts, myConfiguration.getScriptName()));
  myScript.getComboBox().getEditor().setItem(myConfiguration.getScriptName());
}
项目:intellij-ce-playground    文件:PyIntegratedToolsConfigurable.java   
public PyIntegratedToolsConfigurable(@NotNull Module module) {
  myModule = module;
  myProject = myModule.getProject();
  myDocumentationSettings = PyDocumentationSettings.getInstance(myModule);
  //noinspection unchecked
  myDocstringFormatComboBox.setModel(new CollectionComboBoxModel<DocStringFormat>(Arrays.asList(DocStringFormat.values()),
                                                                                  myDocumentationSettings.getFormat()));
  myDocstringFormatComboBox.setRenderer(new ListCellRendererWrapper<DocStringFormat>() {
    @Override
    public void customize(JList list, DocStringFormat value, int index, boolean selected, boolean hasFocus) {
      setText(value.getName());
    }
  });

  final FileChooserDescriptor fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  myWorkDir.addBrowseFolderListener("Please choose working directory:", null, myProject, fileChooserDescriptor);
  ReSTService service = ReSTService.getInstance(myModule);
  myWorkDir.setText(service.getWorkdir());
  txtIsRst.setSelected(service.txtIsRst());
  analyzeDoctest.setSelected(myDocumentationSettings.isAnalyzeDoctest());
  myRequirementsPathField.addBrowseFolderListener("Choose path to the package requirements file:", null, myProject,
                                                  FileChooserDescriptorFactory.createSingleLocalFileDescriptor());
  myRequirementsPathField.setText(getRequirementsPath());

  myDocStringsPanel.setBorder(IdeBorderFactory.createTitledBorder("Docstrings"));
  myRestPanel.setBorder(IdeBorderFactory.createTitledBorder("reStructuredText"));
}
项目:intellij-ce-playground    文件:CreateCondaEnvDialog.java   
protected void setupDialog(Project project, final List<Sdk> allSdks) {
  super.setupDialog(project, allSdks);
  setTitle(PyBundle.message("sdk.create.venv.conda.dialog.title"));
  final List<String> pythonVersions = UnsupportedFeaturesUtil.ALL_LANGUAGE_LEVELS;
  Collections.reverse(pythonVersions);
  mySdkCombo.setModel(new CollectionComboBoxModel<String>(pythonVersions));
  mySdkCombo.setSelectedItem("3.5");
  checkValid();
}
项目:intellij-ce-playground    文件:PyActiveSdkConfigurable.java   
private void updateSdkList(boolean preserveSelection) {
  final List<Sdk> sdkList = myInterpreterList.getAllPythonSdks(myProject);
  Sdk selection = preserveSelection ? (Sdk)mySdkCombo.getSelectedItem() : null;
  if (!sdkList.contains(selection)) {
    selection = null;
  }
  VirtualEnvProjectFilter.removeNotMatching(myProject, sdkList);
  // if the selection is a non-matching virtualenv, show it anyway
  if (selection != null && !sdkList.contains(selection)) {
    sdkList.add(0, selection);
  }
  List<Object> items = new ArrayList<Object>();
  items.add(null);

  boolean remoteSeparator = true;
  boolean separator = true;
  boolean detectedSeparator = true;
  for (Sdk sdk : sdkList) {
    if (!PythonSdkType.isVirtualEnv(sdk) && !PythonSdkType.isRemote(sdk) && !(sdk instanceof PyDetectedSdk) && separator) {
      items.add(PySdkListCellRenderer.SEPARATOR);
      separator = false;
    }
    if (PythonSdkType.isRemote(sdk) && remoteSeparator) {
      items.add(PySdkListCellRenderer.SEPARATOR);
      remoteSeparator = false;
    }
    if (sdk instanceof PyDetectedSdk && detectedSeparator) {
      items.add(PySdkListCellRenderer.SEPARATOR);
      detectedSeparator = false;
    }
    items.add(sdk);
  }

  items.add(PySdkListCellRenderer.SEPARATOR);
  items.add(SHOW_ALL);

  mySdkCombo.setRenderer(new PySdkListCellRenderer(false));
  //noinspection unchecked
  mySdkCombo.setModel(new CollectionComboBoxModel(items, selection));
}
项目:intellij-ce-playground    文件:PyIdeCommonOptionsForm.java   
public void updateSdkList(boolean preserveSelection, PyConfigurableInterpreterList myInterpreterList) {
  myPythonSdks = myInterpreterList.getAllPythonSdks(myProject);
  Sdk selection = preserveSelection ? (Sdk)myInterpreterComboBox.getSelectedItem() : null;
  if (!myPythonSdks.contains(selection)) {
    selection = null;
  }
  myPythonSdks.add(0, null);
  myInterpreterComboBox.setModel(new CollectionComboBoxModel(myPythonSdks, selection));
}
项目:intellij-ce-playground    文件:AndroidNewSdkDialog.java   
protected AndroidNewSdkDialog(@Nullable Project project,
                              @NotNull List<String> javaSdkNames,
                              @NotNull String selectedJavaSdkName,
                              @NotNull List<String> targetNames,
                              @NotNull String selectedTargetName) {
  super(project);
  setTitle("Create New Android SDK");
  myInternalJdkComboBox.setModel(new CollectionComboBoxModel(javaSdkNames, selectedJavaSdkName));
  myBuildTargetComboBox.setModel(new CollectionComboBoxModel(targetNames, selectedTargetName));

  init();
}
项目:intellij-ce-playground    文件:ChooseKeyDialog.java   
public ChooseKeyDialog(@NotNull Project project,
                       @NotNull String keyStorePath,
                       @NotNull char[] password,
                       @NotNull List<String> existingKeys,
                       @Nullable String keyToSelect) {
  super(project);
  myProject = project;
  myKeyStorePath = keyStorePath;
  myKeyStorePassword = password;
  myExistingKeys = existingKeys;
  myKeyCombo.setModel(new CollectionComboBoxModel(existingKeys, existingKeys.get(0)));

  if (keyToSelect != null && existingKeys.contains(keyToSelect)) {
    myKeyCombo.setSelectedItem(keyToSelect);
  }
  myNewKeyPanel.add(myNewKeyForm.getContentPanel(), BorderLayout.CENTER);

  final ActionListener listener = new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      UIUtil.setEnabled(myNewKeyPanel, myCreateNewKeyRadioButton.isSelected(), true);
    }
  };
  myCreateNewKeyRadioButton.addActionListener(listener);
  myUseExistingKeyRadioButton.addActionListener(listener);

  final boolean useExisting = existingKeys.size() > 0;
  myUseExistingKeyRadioButton.setSelected(useExisting);
  myCreateNewKeyRadioButton.setSelected(!useExisting);
  UIUtil.setEnabled(myNewKeyPanel, !useExisting, true);

  setTitle("Choose Key");
  init();
}
项目:intellij-ce-playground    文件:MavenDependencyLookupDialog.java   
/**
 * Prepares the search string and initiates the search in a worker thread.
 */
private void startSearch() {
  if (myProgressIcon.isRunning()) {
    return;
  }
  myProgressIcon.resume();
  synchronized (myShownItems) {
    myResultList.clearSelection();
    myShownItems.clear();
    ((CollectionComboBoxModel)myResultList.getModel()).update();
  }
  String text = mySearchTextField.getText();
  if (StringUtil.isEmpty(text)) {
    return;
  }
  String override = SEARCH_OVERRIDES.get(text.toLowerCase(Locale.US));
  if (override != null) {
    text = override;
  }
  final String finalText = text;
  mySearchWorker.submit(new Runnable() {
    @Override
    public void run() {
      searchAllRepositories(finalText);
    }
  });
}
项目:intellij-ce-playground    文件:ServicePanelBuilder.java   
public JComboBox addComboBox(@NotNull final ObservableList<String> backingList) {
  final CollectionComboBoxModel<String> model = new CollectionComboBoxModel<String>(backingList) {
    @NotNull
    @Override
    public List<String> getItems() {
      return backingList;
    }
  };

  final ComboBox comboBox = new ComboBox(model);

  InvalidationListener onListModified = new InvalidationListener() {
    @Override
    protected void onInvalidated(@NotNull Observable sender) {
      model.update();
      if (backingList.size() > 0 && comboBox.getSelectedIndex() < 0) {
        comboBox.setSelectedIndex(0);
      }
    }
  };

  addComponent(comboBox);
  backingList.addWeakListener(onListModified);
  // Keep weak listener alive as long as the combobox is alive
  comboBox.putClientProperty("onListModified", onListModified);
  return comboBox;
}
项目:consulo-nodejs    文件:NodeJSConfigurationPanelBase.java   
@Override
@RequiredDispatchThread
public void reset(CommonProgramRunConfigurationParameters configuration)
{
    super.reset(configuration);
    NodeJSConfigurationBase nodeJSConfiguration = (NodeJSConfigurationBase) configuration;

    myVmParametersComponent.getComponent().setText(nodeJSConfiguration.getVmParameters());
    myModuleBox.setModel(new CollectionComboBoxModel(nodeJSConfiguration.getValidModules()));
    myModuleBox.setSelectedItem(nodeJSConfiguration.getConfigurationModule().getModule());
    myUseAlternativeBundleCheckBox.setSelected(nodeJSConfiguration.isUseAlternativeBundle());
    myAlternativeBundleComboBox.setSelectedSdk(nodeJSConfiguration.getAlternativeBundleName());
}
项目:consulo-nodejs    文件:NodeJSModuleExtensionPanel.java   
@RequiredDispatchThread
public NodeJSModuleExtensionPanel(final NodeJSMutableModuleExtension extension, Runnable runnable)
{
    super(new VerticalFlowLayout(true, false));

    add(ModuleExtensionSdkBoxBuilder.createAndDefine(extension, runnable).build());

    List<JavaScriptLanguageVersion> validLanguageVersions = StandardJavaScriptVersions.getInstance().getValidLanguageVersions();

    ComboBox languageVersionComboBox = new ComboBox(new CollectionComboBoxModel(validLanguageVersions, extension.getLanguageVersion()));
    languageVersionComboBox.addItemListener(new ItemListener()
    {
        @Override
        public void itemStateChanged(ItemEvent e)
        {
            if(e.getStateChange() == ItemEvent.SELECTED)
            {
                //noinspection unchecked
                extension.setLanguageVersion((LanguageVersion) e.getItem());
            }
        }
    });
    languageVersionComboBox.setRenderer(new ColoredListCellRenderer<BaseJavaScriptLanguageVersion>()
    {
        @Override
        protected void customizeCellRenderer(JList list, BaseJavaScriptLanguageVersion value, int index, boolean selected, boolean hasFocus)
        {
            append(value.getPresentableName());
        }
    });

    add(LabeledComponent.create(languageVersionComboBox, "Language Version"));
}
项目:tools-idea    文件:SaveProjectAsTemplateDialog.java   
protected SaveProjectAsTemplateDialog(@NotNull Project project, @Nullable VirtualFile descriptionFile) {
  super(project);
  myProject = project;

  setTitle("Save Project As Template");
  myName.setText(project.getName());

  Module[] modules = ModuleManager.getInstance(project).getModules();
  if (modules.length < 2) {
    myModuleLabel.setVisible(false);
    myModuleCombo.setVisible(false);
  }
  else {
    List<String> items = new ArrayList<String>(ContainerUtil.map(modules, new Function<Module, String>() {
      @Override
      public String fun(Module module) {
        return module.getName();
      }
    }));
    items.add(WHOLE_PROJECT);
    myModuleCombo.setModel(new CollectionComboBoxModel(items, WHOLE_PROJECT));
  }
  myDescription.setFileType(FileTypeManager.getInstance().getFileTypeByExtension(".html"));
  if (descriptionFile != null) {
    try {
      String s = VfsUtilCore.loadText(descriptionFile);
      myDescription.setText(s);
    }
    catch (IOException e) {
      LOG.error(e);
    }
  }
  init();
}
项目:tools-idea    文件:VersionsComponent.java   
private JComboBox createComboBox(String ri) {
  final JComboBox comboBox = new JComboBox();

  List<Artifact> versions = getSupportedVersions(ri);
  comboBox.setModel(new CollectionComboBoxModel(versions, null));

  comboBox.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      updateCurrentVersion(comboBox);
    }
  });

  return comboBox;
}
项目:tools-idea    文件:DetectedRootsChooser.java   
@Override
public TableCellEditor getEditor(DetectedRootData o) {
  final ComboBox comboBox = new ComboBox(new CollectionComboBoxModel(Arrays.asList(o.getAllRoots()), o.getSelectedRoot()));
  comboBox.setRenderer(new ListCellRendererWrapper<DetectedProjectRoot>() {
    @Override
    public void customize(JList list, DetectedProjectRoot value, int index, boolean selected, boolean hasFocus) {
      setText(value.getRootTypeName());
    }
  });
  return new DefaultCellEditor(comboBox);
}
项目:tools-idea    文件:FileTypeChooser.java   
private FileTypeChooser(@NotNull String[] patterns, @NotNull String fileName) {
  super(true);
  myFileName = fileName;

  myOpenInIdea.setText("Open matching files in " + ApplicationNamesInfo.getInstance().getProductName() + ":");

  FileType[] fileTypes = FileTypeManager.getInstance().getRegisteredFileTypes();
  Arrays.sort(fileTypes, new Comparator<FileType>() {
    @Override
    public int compare(final FileType fileType1, final FileType fileType2) {
      if (fileType1 == null) {
        return 1;
      }
      if (fileType2 == null) {
        return -1;
      }
      return fileType1.getDescription().compareToIgnoreCase(fileType2.getDescription());
    }
  });

  final DefaultListModel model = new DefaultListModel();
  for (FileType type : fileTypes) {
    if (!type.isReadOnly() && type != FileTypes.UNKNOWN && !(type instanceof NativeFileType)) {
      model.addElement(type);
    }
  }
  myList.setModel(model);
  myPattern.setModel(new CollectionComboBoxModel(ContainerUtil.map(patterns, com.intellij.util.FunctionUtil.<String>id()), patterns[0]));

  setTitle(FileTypesBundle.message("filetype.chooser.title"));
  init();
}
项目:tools-idea    文件:LibrariesDownloadUiUtil.java   
private static void loadItems(@NotNull final JComboBox jComboBox,
                              final List<Object> items,
                              final String groupId,
                              final URL... localUrls) {
  final ModalityState state = ModalityState.current();
  ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
    @Override
    public void run() {
      final List<Object> newItems = new ArrayList<Object>();
      newItems.addAll(Arrays.asList(LibrariesDownloadAssistant.getVersions(groupId, localUrls)));

      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          items.clear();
          if (!newItems.isEmpty()) {
            items.addAll(newItems);
            final CollectionComboBoxModel model = (CollectionComboBoxModel)jComboBox.getModel();
            model.update();
            jComboBox.setSelectedIndex(0);
          }
          jComboBox.setEnabled(true);
        }
      }, state);
    }
  }

  );
}
项目:consulo    文件:FileTypeChooser.java   
private FileTypeChooser(@Nonnull List<String> patterns, @Nonnull String fileName) {
  super(true);
  myFileName = fileName;

  FileType[] fileTypes = FileTypeManager.getInstance().getRegisteredFileTypes();
  Arrays.sort(fileTypes, (fileType1, fileType2) -> {
    if (fileType1 == null) {
      return 1;
    }
    if (fileType2 == null) {
      return -1;
    }
    return fileType1.getDescription().compareToIgnoreCase(fileType2.getDescription());
  });

  final DefaultListModel<FileType> model = new DefaultListModel<>();
  for (FileType type : fileTypes) {
    if (!type.isReadOnly() && type != UnknownFileType.INSTANCE && !(type instanceof NativeFileType)) {
      model.addElement(type);
    }
  }
  myList.setModel(model);
  myPattern.setModel(new CollectionComboBoxModel<>(ContainerUtil.map(patterns, FunctionUtil.<String>id()), patterns.get(0)));

  UnknownExtension fileFeatureForChecking = new UnknownExtension(FileTypeFactory.FILE_TYPE_FACTORY_EP.getName(), fileName);
  List<IdeaPluginDescriptor> allPlugins = PluginsAdvertiserHolder.getLoadedPluginDescriptors();
  myFeaturePlugins = PluginsAdvertiser.findByFeature(allPlugins, fileFeatureForChecking);

  if (!myFeaturePlugins.isEmpty()) {
    myInstallPluginFromRepository.setSelected(true);
    myInstallPluginFromRepository.setText(FileTypesBundle.message("filetype.chooser.install.plugin"));
  }
  else {
    myInstallPluginFromRepository.setVisible(false);
  }

  setTitle(FileTypesBundle.message("filetype.chooser.title"));
  init();
}
项目:consulo-javascript    文件:ClientJavaScriptModuleExtensionPanel.java   
public ClientJavaScriptModuleExtensionPanel(final JavaScriptMutableModuleExtension<?> extension)
{
    super(new VerticalFlowLayout(true, false));

    List<JavaScriptLanguageVersion> validLanguageVersions = StandardJavaScriptVersions.getInstance().getValidLanguageVersions();

    ComboBox languageVersionComboBox = new ComboBox(new CollectionComboBoxModel(validLanguageVersions, extension.getLanguageVersion()));
    languageVersionComboBox.addItemListener(new ItemListener()
    {
        @Override
        public void itemStateChanged(ItemEvent e)
        {
            if(e.getStateChange() == ItemEvent.SELECTED)
            {
                //noinspection unchecked
                extension.setLanguageVersion((LanguageVersion) e.getItem());
            }
        }
    });
    languageVersionComboBox.setRenderer(new ColoredListCellRenderer<BaseJavaScriptLanguageVersion>()
    {
        @Override
        protected void customizeCellRenderer(@NotNull JList list, BaseJavaScriptLanguageVersion value, int index, boolean selected, boolean hasFocus)
        {
            append(value.getPresentableName());
        }
    });

    add(LabeledComponent.left(languageVersionComboBox, "Language Version"));
}
项目:MultiHighlight    文件:ColorChooserPanel.java   
public ColorChooserPanel() {
    super(new BorderLayout());
    add(myPanel, BorderLayout.CENTER);

    setBorder(JBUI.Borders.empty(4, 0, 4, 4));
    myEffectsModel = new CollectionComboBoxModel<>(new ArrayList<>(myEffectsMap.keySet()));
    //noinspection unchecked
    myEffectsCombo.setModel(myEffectsModel);
    //noinspection unchecked
    myEffectsCombo.setRenderer(new ListCellRendererWrapper<String>() {

        @Override
        public void customize(JList list, String value, int index, boolean selected,
                boolean hasFocus) {
            setText(value != null ? value : "<invalid>");
        }
    });

    ActionListener actionListener = e -> {
        myForegroundChooser.setEnabled(myCbForeground.isSelected());
        myBackgroundChooser.setEnabled(myCbBackground.isSelected());
        myEffectsColorChooser.setEnabled(myCbEffects.isSelected());
        myEffectsCombo.setEnabled(myCbEffects.isSelected());
        myErrorStripeColorChooser.setEnabled(myCbErrorStripe.isSelected());

        myDispatcher.getMulticaster().onColorChanged(e);
    };

    myCbBold.addActionListener(actionListener);
    myCbItalic.addActionListener(actionListener);

    myCbForeground.addActionListener(actionListener);
    myCbBackground.addActionListener(actionListener);
    myCbErrorStripe.addActionListener(actionListener);
    myCbEffects.addActionListener(actionListener);

    myForegroundChooser.addActionListener(actionListener);
    myBackgroundChooser.addActionListener(actionListener);
    myErrorStripeColorChooser.addActionListener(actionListener);
    myEffectsColorChooser.addActionListener(actionListener);

    myEffectsCombo.addActionListener(actionListener);
}
项目:catberry-idea-plugin    文件:CatberryProjectSettingsPanel.java   
public CatberryProjectSettingsPanel(CatberryProjectSettings settings) {
  this.settings = settings;
  //TODO: ???
  templateEngineField.setModel(new CollectionComboBoxModel(Arrays.asList(TemplateEngine.values())));
}
项目:intellij-ce-playground    文件:UpdateSettingsConfigurable.java   
public UpdatesSettingsPanel(boolean checkNowEnabled) {
  mySettings = UpdateSettings.getInstance();

  ApplicationInfo appInfo = ApplicationInfo.getInstance();
  String majorVersion = appInfo.getMajorVersion();
  String versionNumber = "";
  if (majorVersion != null && majorVersion.trim().length() > 0) {
    String minorVersion = appInfo.getMinorVersion();
    if (minorVersion != null && minorVersion.trim().length() > 0) {
      versionNumber = majorVersion + "." + minorVersion;
    }
    else {
      versionNumber = majorVersion + ".0";
    }
  }
  myVersionNumber.setText(appInfo.getVersionName() + " " + versionNumber);
  myBuildNumber.setText(appInfo.getBuild().asString());

  LabelTextReplacingUtil.replaceText(myPanel);

  if (checkNowEnabled) {
    myCheckNow.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myCheckNow));
        UpdateSettings settings = new UpdateSettings();
        settings.loadState(mySettings.getState());
        settings.setUpdateChannelType(getSelectedChannelType().getCode());
        settings.setSecureConnection(myUseSecureConnection.isSelected());
        UpdateChecker.updateAndShowResult(project, settings);
        updateLastCheckedLabel();
      }
    });
  }
  else {
    myCheckNow.setVisible(false);
  }

  ChannelStatus current = ChannelStatus.fromCode(mySettings.getUpdateChannelType());
  //noinspection unchecked
  myUpdateChannels.setModel(new CollectionComboBoxModel<ChannelStatus>(Arrays.asList(ChannelStatus.values()), current));
}
项目:intellij-ce-playground    文件:CreateVirtualEnvDialog.java   
private void updateSdkList(final List<Sdk> allSdks, @Nullable Sdk initialSelection) {
  mySdkCombo.setRenderer(new PySdkListCellRenderer(false));
  mySdkCombo.setModel(new CollectionComboBoxModel<Sdk>(allSdks, initialSelection));
  checkValid();
}
项目:intellij-ce-playground    文件:PyIdeCommonOptionsForm.java   
public PyIdeCommonOptionsForm(PyCommonOptionsFormData data) {
  myProject = data.getProject();
  myWorkingDirectoryTextField.addBrowseFolderListener("Select Working Directory", "", data.getProject(),
                                                      FileChooserDescriptorFactory.createSingleFolderDescriptor());

  myPythonSdks = new ArrayList<Sdk>(PythonSdkType.getAllSdks());
  myPythonSdks.add(0, null);

  myInterpreterComboBox.setModel(new CollectionComboBoxModel(myPythonSdks, null));

  final Module[] modules = ModuleManager.getInstance(data.getProject()).getModules();
  if (modules.length == 1) {
    setModule(modules[0]);
    myProjectLabel.setVisible(false);
    myModuleCombo.setVisible(false);
  }
  else {
    final List<Module> validModules = data.getValidModules();
    Module selection = validModules.size() > 0 ? validModules.get(0) : null;
    myModuleCombo.setModules(validModules);
    myModuleCombo.setSelectedModule(selection);
    myModuleCombo.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        updateDefaultInterpreter(myModuleCombo.getSelectedModule());
      }
    });
    updateDefaultInterpreter(myModuleCombo.getSelectedModule());
  }

  setAnchor(myEnvsComponent.getLabel());
  myPathMappingsComponent.setAnchor(myEnvsComponent.getLabel());

  if (data.showConfigureInterpretersLink()) {
    myConfigureInterpretersPanel.add(new PyConfigureInterpretersLinkPanel(myMainPanel));
  }

  addInterpreterComboBoxActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent event) {
      updateRemoteInterpreterMode();
    }
  }
  );

  updateRemoteInterpreterMode();

  myDecorator = new HideableDecorator(myHideablePanel, "Environment", false) {
    @Override
    protected void on() {
      super.on();
      storeState();
    }

    @Override
    protected void off() {
      super.off();
      storeState();
    }
    private void storeState() {
      PropertiesComponent.getInstance().setValue(EXPAND_PROPERTY_KEY, String.valueOf(isExpanded()), "true");
    }
  };
  myDecorator.setOn(PropertiesComponent.getInstance().getBoolean(EXPAND_PROPERTY_KEY, true));
  myDecorator.setContentComponent(myMainPanel);
}
项目:intellij-ce-playground    文件:SkinChooser.java   
private void setItems(List<File> items) {
  getComboBox().setModel(new CollectionComboBoxModel(items));
}
项目:intellij-ce-playground    文件:RepositoryAttachDialog.java   
private void updateComboboxSelection(boolean force) {
  final String prevFilter = myFilterString;
  final JTextComponent field = (JTextComponent)myCombobox.getEditor().getEditorComponent();
  final int caret = field.getCaretPosition();
  myFilterString = field.getText();

  if (!force && Comparing.equal(myFilterString, prevFilter)) return;
  int prevSize = myShownItems.size();
  myShownItems.clear();

  myInUpdate = true;
  final boolean itemSelected = myCoordinates.containsKey(myFilterString) &&
                               Comparing.strEqual((String)myCombobox.getSelectedItem(), myFilterString, false);
  final boolean filtered;
  if (itemSelected) {
    myShownItems.addAll(myCoordinates.keySet());
    filtered = false;
  }
  else {
    final String[] parts = myFilterString.split(" ");
    main:
    for (String coordinate : myCoordinates.keySet()) {
      for (String part : parts) {
        if (!StringUtil.containsIgnoreCase(coordinate, part)) continue main;
      }
      myShownItems.add(coordinate);
    }
    filtered = !myShownItems.isEmpty();
    if (!filtered) {
      myShownItems.addAll(myCoordinates.keySet());
    }
    myCombobox.setSelectedItem(null);
  }

  // use maven version sorter
  ArrayList<Comparable> comparables = new ArrayList<Comparable>(myShownItems.size());
  for (String item : myShownItems) {
    comparables.add(new MavenVersionComparable(item));
  }
  Collections.sort(comparables);
  myShownItems.clear();
  for (Comparable comparable : comparables) {
    myShownItems.add(comparable.toString());
  }

  ((CollectionComboBoxModel)myCombobox.getModel()).update();
  myInUpdate = false;
  field.setText(myFilterString);
  field.setCaretPosition(caret);
  updateInfoLabel();
  if (filtered) {
    if (prevSize < 10 && myShownItems.size() > prevSize && myCombobox.isPopupVisible()) {
      myCombobox.setPopupVisible(false);
    }
    if (!myCombobox.isPopupVisible()) {
      myCombobox.setPopupVisible(true);
    }
  }
}