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

项目: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    文件:CreateNewLibraryDialog.java   
public CreateNewLibraryDialog(@NotNull JComponent parent, @NotNull StructureConfigurableContext context, @NotNull NewLibraryEditor libraryEditor,
                               @NotNull List<LibraryTable> libraryTables, int selectedTable) {
  super(parent, new LibraryRootsComponent(context.getProject(), libraryEditor));
  myContext = context;
  myLibraryEditor = libraryEditor;
  final DefaultComboBoxModel model = new DefaultComboBoxModel();
  for (LibraryTable table : libraryTables) {
    model.addElement(table);
  }
  myLibraryLevelCombobox = new ComboBox(model);
  myLibraryLevelCombobox.setSelectedIndex(selectedTable);
  myLibraryLevelCombobox.setRenderer(new ListCellRendererWrapper() {
    @Override
    public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (value instanceof LibraryTable) {
        setText(((LibraryTable)value).getPresentation().getDisplayName(false));
      }
    }
  });
  init();
}
项目:intellij-ce-playground    文件:FrameworkSupportConfigurableBase.java   
public FrameworkSupportConfigurableBase(FrameworkSupportProviderBase frameworkSupportProvider, FrameworkSupportModel model,
                                        @NotNull List<FrameworkVersion> versions, @Nullable String versionLabelText) {
  myFrameworkSupportProvider = frameworkSupportProvider;
  myFrameworkSupportModel = model;
  myVersions = versions;
  myDescriptionLabel.setText(versionLabelText);
  myVersionComboBox.setRenderer(new ListCellRendererWrapper() {
    @Override
    public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (value instanceof FrameworkVersion) {
        setText(((FrameworkVersion)value).getVersionName());
      }
    }
  });
  updateAvailableVersions(versions);
  myVersionComboBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      fireFrameworkVersionChanged();
    }
  });
}
项目: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);
}
项目:intellij-ce-playground    文件:JsonCodeStylePanel.java   
@SuppressWarnings("unchecked")
public JsonCodeStylePanel(@NotNull CodeStyleSettings settings) {
  super(JsonLanguage.INSTANCE, null, settings);
  addPanelToWatch(myPanel);
  installPreviewPanel(myPreviewPanel);

  // Initialize combo box with property value alignment types
  for (PropertyAlignment alignment : PropertyAlignment.values()) {
    myPropertiesAlignmentCombo.addItem(alignment);
  }
  myPropertiesAlignmentCombo.setRenderer(new ListCellRendererWrapper<PropertyAlignment>() {
    @Override
    public void customize(JList list, PropertyAlignment value, int index, boolean selected, boolean hasFocus) {
      setText(value.getDescription());
    }
  });
  myPropertiesAlignmentCombo.addItemListener(new ItemListener() {
    @Override
    public void itemStateChanged(ItemEvent e) {
      if (e.getStateChange() == ItemEvent.SELECTED) {
        somethingChanged();
      }
    }
  });
}
项目:intellij-ce-playground    文件:DeveloperServicesPanel.java   
public DeveloperServicesPanel(@NotNull ComboBoxModel moduleList, @NotNull final ServiceCategory serviceCategory) {
  super(new BorderLayout());

  ListCellRendererWrapper<Module> renderer = new ListCellRendererWrapper<Module>() {
    @Override
    public void customize(JList list, Module value, int index, boolean selected, boolean hasFocus) {
      setText(value.getName());
    }
  };
  myModuleCombo.setModel(moduleList);
  myModuleCombo.setRenderer(renderer);

  myServicesPanel.setBorder(new TitledBorder(serviceCategory.getDisplayName()));
  updateServicePanels(serviceCategory);
  myModuleCombo.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent actionEvent) {
      updateServicePanels(serviceCategory);
    }
  });

  add(myRoot);
}
项目:intellij-ce-playground    文件:NewStringKeyDialog.java   
public NewStringKeyDialog(@NotNull final AndroidFacet facet, @NotNull Set<String> existing) {
  super(facet.getModule().getProject(), false);

  final VirtualFile baseDir = facet.getModule().getProject().getBaseDir();

  myResFolderCombo.setModel(new ListComboBoxModel(facet.getAllResourceDirectories()));
  myResFolderCombo.setRenderer(new ListCellRendererWrapper<VirtualFile>() {
    @Override
    public void customize(JList list, VirtualFile file, int index, boolean selected, boolean hasFocus) {
      setText(VfsUtilCore.getRelativePath(file, baseDir, File.separatorChar));
    }
  });
  myResFolderCombo.setSelectedIndex(0);

  myResourceNameValidator = ResourceNameValidator.create(false, existing, ResourceType.STRING);

  init();
}
项目:intellij-ce-playground    文件:AppEngineUtil.java   
public static void setupAppEngineArtifactCombobox(@NotNull Project project, final @NotNull JComboBox comboBox, final boolean withAppEngineFacetOnly) {
  comboBox.setRenderer(new ListCellRendererWrapper<Artifact>() {
    @Override
    public void customize(JList list, Artifact value, int index, boolean selected, boolean hasFocus) {
      if (value != null) {
        setIcon(value.getArtifactType().getIcon());
        setText(value.getName());
      }
    }
  });

  comboBox.removeAllItems();
  for (Artifact artifact : collectAppEngineArtifacts(project, withAppEngineFacetOnly)) {
    comboBox.addItem(artifact);
  }
}
项目:intellij-ce-playground    文件:GuiDesignerConfigurable.java   
public void reset() {
  final GuiDesignerConfiguration configuration = GuiDesignerConfiguration.getInstance(myProject);

  /*general*/
  if (configuration.INSTRUMENT_CLASSES) {
    myGeneralUI.myRbInstrumentClasses.setSelected(true);
  }
  else {
    myGeneralUI.myRbInstrumentSources.setSelected(true);
  }
  myGeneralUI.myChkCopyFormsRuntime.setSelected(configuration.COPY_FORMS_RUNTIME_TO_OUTPUT);

  myGeneralUI.myLayoutManagerCombo.setModel(new DefaultComboBoxModel(LayoutManagerRegistry.getNonDeprecatedLayoutManagerNames()));
  myGeneralUI.myLayoutManagerCombo.setRenderer(new ListCellRendererWrapper<String>() {
    @Override
    public void customize(JList list, String value, int index, boolean selected, boolean hasFocus) {
      setText(LayoutManagerRegistry.getLayoutManagerDisplayName(value));
    }
  });
  myGeneralUI.myLayoutManagerCombo.setSelectedItem(configuration.DEFAULT_LAYOUT_MANAGER);

  myGeneralUI.myDefaultFieldAccessibilityCombo.setSelectedItem(configuration.DEFAULT_FIELD_ACCESSIBILITY);

  myGeneralUI.myResizeHeaders.setSelected(configuration.RESIZE_HEADERS);
}
项目:intellij-ce-playground    文件:GitPullDialog.java   
/**
 * Create list cell renderer for remotes. It shows both name and url and highlights the default
 * remote for the branch with bold.
 *
 *
 * @param defaultRemote a default remote
 * @return a list cell renderer for virtual files (it renders presentable URL
 */
public ListCellRendererWrapper<GitRemote> getGitRemoteListCellRenderer(final String defaultRemote) {
  return new ListCellRendererWrapper<GitRemote>() {
    @Override
    public void customize(final JList list, final GitRemote remote, final int index, final boolean selected, final boolean hasFocus) {
      final String text;
      if (remote == null) {
        text = GitBundle.getString("util.remote.renderer.none");
      }
      else if (".".equals(remote.getName())) {
        text = GitBundle.getString("util.remote.renderer.self");
      }
      else {
        String key;
        if (defaultRemote != null && defaultRemote.equals(remote.getName())) {
          key = "util.remote.renderer.default";
        }
        else {
          key = "util.remote.renderer.normal";
        }
        text = GitBundle.message(key, remote.getName(), remote.getFirstUrl());
      }
      setText(text);
    }
  };
}
项目:intellij-ce-playground    文件:GitVcsPanel.java   
private void createUIComponents() {
  myProtectedBranchesButton = new TextFieldWithBrowseButton.NoPathCompletion(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      Messages.showTextAreaDialog(myProtectedBranchesButton.getTextField(), "Protected Branches", "Git.Force.Push.Protected.Branches",
                                  ParametersListUtil.COLON_LINE_PARSER, ParametersListUtil.COLON_LINE_JOINER);
    }
  });
  myProtectedBranchesButton.setButtonIcon(AllIcons.Actions.ShowViewer);
  myUpdateMethodComboBox = new ComboBox(new EnumComboBoxModel<UpdateMethod>(UpdateMethod.class));
  myUpdateMethodComboBox.setRenderer(new ListCellRendererWrapper<UpdateMethod>() {
    @Override
    public void customize(JList list, UpdateMethod value, int index, boolean selected, boolean hasFocus) {
      setText(StringUtil.capitalize(StringUtil.toLowerCase(value.name().replace('_', ' '))));
    }
  });
}
项目:intellij-ce-playground    文件:ParametersPerConstructorInspection.java   
@Override
public JComponent createOptionsPanel() {
  final JFormattedTextField valueField = prepareNumberEditor("m_limit");
  final JComboBox comboBox = new ComboBox(new Object[] {Scope.NONE, Scope.PRIVATE, Scope.PACKAGE_LOCAL, Scope.PROTECTED});
  comboBox.setRenderer(new ListCellRendererWrapper() {
    @Override
    public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (value instanceof Scope) setText(((Scope)value).getText());
    }
  });
  comboBox.setSelectedItem(ignoreScope);
  comboBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      ignoreScope = (Scope)comboBox.getSelectedItem();
    }
  });
  comboBox.setPrototypeDisplayValue(Scope.PROTECTED);

  final FormBuilder formBuilder = FormBuilder.createFormBuilder();
  formBuilder.addLabeledComponent(getConfigurationLabel(), valueField);
  formBuilder.addLabeledComponent(InspectionGadgetsBundle.message("constructor.visibility.option"), comboBox);
  final JPanel panel = new JPanel(new BorderLayout());
  panel.add(formBuilder.getPanel(), BorderLayout.NORTH);
  return panel;
}
项目:intellij    文件:BlazeIntellijPluginConfiguration.java   
public BlazeIntellijPluginConfigurationSettingsEditor(
    Iterable<Label> javaLabels,
    RunConfigurationStateEditor blazeFlagsEditor,
    RunConfigurationStateEditor exeFlagsEditor) {
  targetCombo =
      new ComboBox<>(
          new DefaultComboBoxModel<>(
              Ordering.usingToString().sortedCopy(javaLabels).toArray(new Label[0])));
  targetCombo.setRenderer(
      new ListCellRendererWrapper<Label>() {
        @Override
        public void customize(
            JList list, @Nullable Label value, int index, boolean selected, boolean hasFocus) {
          setText(value == null ? null : value.toString());
        }
      });
  this.blazeFlagsEditor = blazeFlagsEditor;
  this.exeFlagsEditor = exeFlagsEditor;
  ProjectSdksModel sdksModel = new ProjectSdksModel();
  sdksModel.reset(null);
  sdkCombo = new JdkComboBox(sdksModel, IdeaJdkHelper::isIdeaJdkType);

  keepInSyncCheckBox = new JBCheckBox("Keep in sync with source XML");
  keepInSyncCheckBox.addItemListener(e -> updateEnabledStatus());
}
项目:google-cloud-intellij    文件:AppEngineRunConfigurationEditor.java   
/**
 * Initializes the 'artifact to deploy' combobox with the eligible artifact deployment sources.
 */
private void initDeploymentSources() {
  myArtifactComboBox.setRenderer(
      new ListCellRendererWrapper<Artifact>() {
        @Override
        public void customize(
            JList list, Artifact value, int index, boolean selected, boolean hasFocus) {
          if (value != null) {
            setIcon(value.getArtifactType().getIcon());
            setText(value.getName());
          }
        }
      });

  List<AppEngineArtifactDeploymentSource> deploymentSources = Lists.newArrayList();
  deploymentSources.addAll(AppEngineUtil.createArtifactDeploymentSources(myProject));

  deploymentSources
      .stream()
      .map(ArtifactDeploymentSourceImpl::getArtifact)
      .forEach(myArtifactComboBox::addItem);
}
项目:defrac-plugin-intellij    文件:DefracRunConfigurationEditor.java   
private void createUIComponents() {
  moduleComboBox = new DefracModuleComboBox(project);
  mainClassTextField = new DefracMainClassTextFieldWithBrowseButton(project, moduleComboBox.moduleSelector);
  emulatorComboBox = new AvdComboBox(project, true, false) {
    @Nullable
    @Override
    public Module getModule() {
      return moduleComboBox.moduleSelector.getModule();
    }
  };
  emulatorComboBox.getComboBox().setRenderer(new ListCellRendererWrapper() {
    @Override
    public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if(value instanceof IdDisplay) {
        setText(((IdDisplay) value).getDisplay());
      }
    }
  });
}
项目:tools-idea    文件:CreateNewLibraryDialog.java   
public CreateNewLibraryDialog(@NotNull JComponent parent, @NotNull StructureConfigurableContext context, @NotNull NewLibraryEditor libraryEditor,
                               @NotNull List<LibraryTable> libraryTables, int selectedTable) {
  super(parent, new LibraryRootsComponent(context.getProject(), libraryEditor));
  myContext = context;
  myLibraryEditor = libraryEditor;
  final DefaultComboBoxModel model = new DefaultComboBoxModel();
  for (LibraryTable table : libraryTables) {
    model.addElement(table);
  }
  myLibraryLevelCombobox = new ComboBox(model);
  myLibraryLevelCombobox.setSelectedIndex(selectedTable);
  myLibraryLevelCombobox.setRenderer(new ListCellRendererWrapper() {
    @Override
    public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (value instanceof LibraryTable) {
        setText(((LibraryTable)value).getPresentation().getDisplayName(false));
      }
    }
  });
  init();
}
项目:tools-idea    文件:LanguageLevelCombo.java   
public LanguageLevelCombo() {
  for (LanguageLevel level : LanguageLevel.values()) {
    addItem(level);
  }
  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 LanguageLevel) {
        setText(((LanguageLevel)value).getPresentableText());
      }
      else if (value instanceof String) {
        setText((String)value);
      }
    }
  });
}
项目:tools-idea    文件:FrameworkSupportConfigurableBase.java   
public FrameworkSupportConfigurableBase(FrameworkSupportProviderBase frameworkSupportProvider, FrameworkSupportModel model,
                                        @NotNull List<FrameworkVersion> versions, @Nullable String versionLabelText) {
  myFrameworkSupportProvider = frameworkSupportProvider;
  myFrameworkSupportModel = model;
  myVersions = versions;
  myDescriptionLabel.setText(versionLabelText);
  myVersionComboBox.setRenderer(new ListCellRendererWrapper() {
    @Override
    public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (value instanceof FrameworkVersion) {
        setText(((FrameworkVersion)value).getVersionName());
      }
    }
  });
  updateAvailableVersions(versions);
  myVersionComboBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      fireFrameworkVersionChanged();
    }
  });
}
项目: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);
}
项目:tools-idea    文件:AppEngineUtil.java   
public static void setupAppEngineArtifactCombobox(@NotNull Project project, final @NotNull JComboBox comboBox, final boolean withAppEngineFacetOnly) {
  comboBox.setRenderer(new ListCellRendererWrapper<Artifact>() {
    @Override
    public void customize(JList list, Artifact value, int index, boolean selected, boolean hasFocus) {
      if (value != null) {
        setIcon(value.getArtifactType().getIcon());
        setText(value.getName());
      }
    }
  });

  comboBox.removeAllItems();
  for (Artifact artifact : collectWebArtifacts(project, withAppEngineFacetOnly)) {
    comboBox.addItem(artifact);
  }
}
项目:tools-idea    文件:GuiDesignerConfigurable.java   
public void reset() {
  final GuiDesignerConfiguration configuration = GuiDesignerConfiguration.getInstance(myProject);

  /*general*/
  if (configuration.INSTRUMENT_CLASSES) {
    myGeneralUI.myRbInstrumentClasses.setSelected(true);
  }
  else {
    myGeneralUI.myRbInstrumentSources.setSelected(true);
  }
  myGeneralUI.myChkCopyFormsRuntime.setSelected(configuration.COPY_FORMS_RUNTIME_TO_OUTPUT);

  myGeneralUI.myLayoutManagerCombo.setModel(new DefaultComboBoxModel(LayoutManagerRegistry.getNonDeprecatedLayoutManagerNames()));
  myGeneralUI.myLayoutManagerCombo.setRenderer(new ListCellRendererWrapper<String>() {
    @Override
    public void customize(JList list, String value, int index, boolean selected, boolean hasFocus) {
      setText(LayoutManagerRegistry.getLayoutManagerDisplayName(value));
    }
  });
  myGeneralUI.myLayoutManagerCombo.setSelectedItem(configuration.DEFAULT_LAYOUT_MANAGER);

  myGeneralUI.myDefaultFieldAccessibilityCombo.setSelectedItem(configuration.DEFAULT_FIELD_ACCESSIBILITY);

  myGeneralUI.myResizeHeaders.setSelected(configuration.RESIZE_HEADERS);
}
项目:tools-idea    文件:GitPullDialog.java   
/**
 * Create list cell renderer for remotes. It shows both name and url and highlights the default
 * remote for the branch with bold.
 *
 *
 * @param defaultRemote a default remote
 * @return a list cell renderer for virtual files (it renders presentable URL
 */
public ListCellRendererWrapper<GitRemote> getGitRemoteListCellRenderer(final String defaultRemote) {
  return new ListCellRendererWrapper<GitRemote>(myRemote) {
    @Override
    public void customize(final JList list, final GitRemote remote, final int index, final boolean selected, final boolean hasFocus) {
      final String text;
      if (remote == null) {
        text = GitBundle.getString("util.remote.renderer.none");
      }
      else if (".".equals(remote.getName())) {
        text = GitBundle.getString("util.remote.renderer.self");
      }
      else {
        String key;
        if (defaultRemote != null && defaultRemote.equals(remote.getName())) {
          key = "util.remote.renderer.default";
        }
        else {
          key = "util.remote.renderer.normal";
        }
        text = GitBundle.message(key, remote.getName(), remote.getFirstUrl());
      }
      setText(text);
    }
  };
}
项目:consulo-csharp    文件:CSharpChangeSignatureDialog.java   
@Override
protected VisibilityPanelBase<CSharpAccessModifier> createVisibilityControl()
{
    return new ComboBoxVisibilityPanel<CSharpAccessModifier>(CSharpAccessModifier.VALUES)
    {
        @Override
        protected ListCellRendererWrapper<CSharpAccessModifier> getRenderer()
        {
            return new ListCellRendererWrapper<CSharpAccessModifier>()
            {
                @Override
                public void customize(JList list, CSharpAccessModifier value, int index, boolean selected, boolean hasFocus)
                {
                    setText(value.getPresentableText());
                }
            };
        }
    };
}
项目: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-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;
}
项目:nuxeo-intellij    文件:NuxeoProjectSettingsPanel.java   
public NuxeoProjectSettingsPanel(Project project) {
    this.project = project;
    nuxeoSDKManager = NuxeoSDKManager.getInstance(project);
    fillSDKs();
    nuxeoSDKsComboBox.setRenderer(new ListCellRendererWrapper<NuxeoSDK>() {
        @Override
        public void customize(JList list, NuxeoSDK value, int index,
                boolean selected, boolean hasFocus) {
            if (value == null) {
                setText("No Nuxeo SDK");
            } else {
                setText(value.getName());
            }
        }
    });
}
项目:consulo    文件:CreateNewLibraryDialog.java   
public CreateNewLibraryDialog(@Nonnull JComponent parent, @Nonnull StructureConfigurableContext context, @Nonnull NewLibraryEditor libraryEditor,
                              @Nonnull List<LibraryTable> libraryTables, int selectedTable) {
  super(parent, new LibraryRootsComponent(context.getProject(), libraryEditor));
  myContext = context;
  myLibraryEditor = libraryEditor;
  final DefaultComboBoxModel model = new DefaultComboBoxModel();
  for (LibraryTable table : libraryTables) {
    model.addElement(table);
  }
  myLibraryLevelCombobox = new ComboBox(model);
  myLibraryLevelCombobox.setSelectedIndex(selectedTable);
  myLibraryLevelCombobox.setRenderer(new ListCellRendererWrapper() {
    @Override
    public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (value instanceof LibraryTable) {
        setText(((LibraryTable)value).getPresentation().getDisplayName(false));
      }
    }
  });
  init();
}
项目:consulo    文件:ProfilesConfigurableComboBox.java   
public ProfilesConfigurableComboBox(final ListCellRendererWrapper<Profile> comboBoxItemsRenderer) {
  myCardLayout = new CardLayout();
  setLayout(myCardLayout);

  myProfilesComboBox = new JComboBox();
  add(myProfilesComboBox, COMBO_CARD);

  mySaveListener = new SaveInputComponentValidator.Wrapper();
  mySubmitNameComponent = new ValidatedTextField(mySaveListener);
  add(mySubmitNameComponent, EDIT_CARD);

  myProfilesComboBox.setRenderer(comboBoxItemsRenderer);
  myProfilesComboBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      final InspectionProfileImpl profile = getSelectedProfile();
      if (profile != null) {
        onProfileChosen(profile);
      }
    }
  });

  showComboBoxCard();
}
项目: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);
}
项目: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    文件:FullyQualifiedNamesInJavadocOptionProvider.java   
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 = new Insets(0, 5, 0, 0);

  myPanel.add(title, left);
  myPanel.add(myComboBox, right);
}
项目:intellij-ce-playground    文件:InplaceIntroduceParameterUI.java   
@Override
protected JPanel createReplaceFieldsWithGettersPanel() {
  final LabeledComponent<JComboBox> component = new LabeledComponent<JComboBox>();
  myReplaceFieldsCb = new JComboBox(new Integer[]{IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL,
    IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE,
    IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE});
  myReplaceFieldsCb.setRenderer(new ListCellRendererWrapper<Integer>() {
    @Override
    public void customize(JList list, Integer value, int index, boolean selected, boolean hasFocus) {
      switch (value) {
        case IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE:
          setText(UIUtil.removeMnemonic(RefactoringBundle.message("do.not.replace")));
          break;
        case IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE:
          setText(UIUtil.removeMnemonic(RefactoringBundle.message("replace.fields.inaccessible.in.usage.context")));
          break;
        default:
          setText(UIUtil.removeMnemonic(RefactoringBundle.message("replace.all.fields")));
      }
    }
  });
  myReplaceFieldsCb.setSelectedItem(JavaRefactoringSettings.getInstance().INTRODUCE_PARAMETER_REPLACE_FIELDS_WITH_GETTERS);
  KeyboardComboSwitcher.setupActions(myReplaceFieldsCb, myProject);
  component.setComponent(myReplaceFieldsCb);
  component.setText(RefactoringBundle.message("replace.fields.used.in.expressions.with.their.getters"));
  component.getLabel().setDisplayedMnemonic('u');
  component.setLabelLocation(BorderLayout.NORTH);
  component.setBorder(IdeBorderFactory.createEmptyBorder(3, 3, 2, 2));
  return component;
}
项目:intellij-ce-playground    文件:FrameworkVersionComponent.java   
public FrameworkVersionComponent(final FrameworkSupportModelBase model, final String frameworkOrGroupId,
                                 final List<? extends FrameworkVersion> versions_, String labelText) {
  myModel = model;
  myAllVersions = versions_;
  myMainPanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 3, true, false));
  myFrameworkOrGroupId = frameworkOrGroupId;
  myVersionsBox = new ComboBox();
  myVersionsBox.setRenderer(new ListCellRendererWrapper<FrameworkVersion>() {
    @Override
    public void customize(JList list, FrameworkVersion value, int index, boolean selected, boolean hasFocus) {
      setText(value != null ? value.getPresentableName() : "");
    }
  });
  myVersionsBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      FrameworkVersion selectedVersion = getSelectedVersion();
      if (selectedVersion != null) {
        model.setSelectedVersion(frameworkOrGroupId, selectedVersion);
      }
    }
  });

  myVersionsPanel = FormBuilder.createFormBuilder().setHorizontalGap(5).addLabeledComponent(labelText, myVersionsBox).getPanel();
  myMainPanel.add(myVersionsPanel);
  updateVersionsList();
}
项目: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    文件:NewDirectoryProjectDialog.java   
@NotNull
private static ListCellRendererWrapper<Object> createProjectTypeListCellRenderer() {
  return new ListCellRendererWrapper<Object>() {
    @Override
    public void customize(JList list, Object value, int index, boolean selected, boolean cellHasFocus) {
      if (value == EMPTY_PROJECT_GENERATOR) {
        setText(IdeBundle.message("new.dir.project.default.generator"));
      }
      else if (value != null) {
        setText(((DirectoryProjectGenerator)value).getName());
      }
    }
  };
}
项目:intellij-ce-playground    文件:ImplementationViewComponent.java   
private void updateRenderer(final Project project) {
  myFileChooser.setRenderer(new ListCellRendererWrapper<FileDescriptor>() {
    @Override
    public void customize(JList list, FileDescriptor value, int index, boolean selected, boolean hasFocus) {
      final PsiFile file = value.myFile;
      setIcon(getIconForFile(file));
      final VirtualFile vFile = file.getVirtualFile();
      setForeground(FileStatusManager.getInstance(project).getStatus(vFile).getColor());
      //noinspection ConstantConditions
      setText(value.getPresentableName(vFile));
    }
  });
}
项目:intellij-ce-playground    文件:ArrangementComboBoxUiComponent.java   
@SuppressWarnings("unchecked")
public ArrangementComboBoxUiComponent(@NotNull List<ArrangementSettingsToken> tokens) {
  super(tokens);
  ArrangementSettingsToken[] tokensArray = tokens.toArray(new ArrangementSettingsToken[tokens.size()]);
  Arrays.sort(tokensArray, new Comparator<ArrangementSettingsToken>() {
    @Override
    public int compare(ArrangementSettingsToken t1, ArrangementSettingsToken t2) {
      return t1.getRepresentationValue().compareTo(t2.getRepresentationValue());
    }
  });
  myComboBox = new JComboBox(tokensArray);
  myComboBox.setRenderer(new ListCellRendererWrapper() {
    @Override
    public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      setText(((ArrangementSettingsToken)value).getRepresentationValue());
    }
  });
  myComboBox.addItemListener(new ItemListener() {
    @Override
    public void itemStateChanged(ItemEvent e) {
      if (e.getStateChange() == ItemEvent.SELECTED) {
        fireStateChanged();
      }
    }
  });
  int minWidth = 0;
  ListCellRenderer renderer = myComboBox.getRenderer();
  JBList dummyList = new JBList();
  for (int i = 0, max = myComboBox.getItemCount(); i < max; i++) {
    Component rendererComponent = renderer.getListCellRendererComponent(dummyList, myComboBox.getItemAt(i), i, false, true);
    minWidth = Math.max(minWidth, rendererComponent.getPreferredSize().width);
  }
  myComboBox.setPreferredSize(new Dimension(minWidth * 5 / 3, myComboBox.getPreferredSize().height));
}
项目:intellij-ce-playground    文件:FileTypePatternDialog.java   
public FileTypePatternDialog(@Nullable String initialPatterns, FileType fileType, Language templateDataLanguage) {
  myPatternField.setText(initialPatterns);

  if (fileType instanceof TemplateLanguageFileType) {
    final DefaultComboBoxModel model = (DefaultComboBoxModel) myLanguageCombo.getModel();
    model.addElement(null);
    final List<Language> languages = TemplateDataLanguageMappings.getTemplateableLanguages();
    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);
    }
    myLanguageCombo.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());
          }
        }
      }
    });
    myLanguageCombo.setSelectedItem(templateDataLanguage);
  } else {
    myLanguageCombo.setVisible(false);
    myTemplateDataLanguageButton.setVisible(false);
  }
}
项目:intellij-ce-playground    文件:ProfilesConfigurableComboBox.java   
public ProfilesConfigurableComboBox(final ListCellRendererWrapper<Profile> comboBoxItemsRenderer) {
  myComboBoxPanel = new JPanel();

  myCardLayout = new CardLayout();
  myComboBoxPanel.setLayout(myCardLayout);
  setBorder(IdeBorderFactory.createEmptyBorder(new Insets(4, 0, 6, 0)));

  myProfilesComboBox = new JComboBox();
  myComboBoxPanel.add(myProfilesComboBox, COMBO_CARD);

  mySaveListener = new SaveInputComponentValidator.Wrapper();
  mySubmitNameComponent = new ValidatedTextField(mySaveListener);
  myComboBoxPanel.add(mySubmitNameComponent, EDIT_CARD);

  myProfilesComboBox.setRenderer(comboBoxItemsRenderer);
  myProfilesComboBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      final InspectionProfileImpl profile = getSelectedProfile();
      if (profile != null) {
        onProfileChosen(profile);
      }
    }
  });

  setLayout(new BorderLayout());
  add(mySubmitNameComponent.getHintLabel(), BorderLayout.NORTH);
  add(myComboBoxPanel, BorderLayout.CENTER);

  showComboBoxCard();
}
项目:intellij-ce-playground    文件:ComboBoxVisibilityPanel.java   
protected ListCellRendererWrapper getRenderer() {
  return new ListCellRendererWrapper() {
    @Override
    public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      setText(myNamesMap.get((V)value));
    }
  };
}