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

项目:intellij-ce-playground    文件:ExpressionInputComponent.java   
private void showHistory() {
  List<XExpression> expressions = myExpressionEditor.getRecentExpressions();
  if (!expressions.isEmpty()) {
    ListPopupImpl popup = new ListPopupImpl(new BaseListPopupStep<XExpression>(null, expressions) {
      @Override
      public PopupStep onChosen(XExpression selectedValue, boolean finalChoice) {
        myExpressionEditor.setExpression(selectedValue);
        myExpressionEditor.requestFocusInEditor();
        return FINAL_CHOICE;
      }
    }) {
      @Override
      protected ListCellRenderer getListElementRenderer() {
        return new ColoredListCellRenderer<XExpression>() {
          @Override
          protected void customizeCellRenderer(JList list, XExpression value, int index, boolean selected, boolean hasFocus) {
            append(value.getExpression());
          }
        };
      }
    };
    popup.getList().setFont(EditorUtil.getEditorFont());
    popup.showUnderneathOf(myExpressionEditor.getEditorComponent());
  }
}
项目:intellij-ce-playground    文件:ConfigurationSettingsEditor.java   
public RunnersEditorComponent() {
  myRunnerPanel.setLayout(myLayout);
  myRunnerPanel.add(myNoRunner, NO_RUNNER_COMPONENT);
  myRunnersList.setModel(myListModel);
  myRunnersList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent e) {
      updateRunnerComponent();
    }
  });
  updateRunnerComponent();
  myRunnersList.setCellRenderer(new ColoredListCellRenderer() {
    @Override
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      Executor executor = (Executor)value;
      setIcon(executor.getIcon());
      append(executor.getId(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    }
  });
}
项目:intellij-ce-playground    文件:ValidExcludeListItem.java   
@Override
public void renderItem(ColoredListCellRenderer renderer) {
  if (myFrameworkType != null) {
    renderer.setIcon(myFrameworkType.getIcon());
    renderer.append(myFrameworkType.getPresentableName());
    if (myFile != null) {
      renderer.append(" in " + myFile.getName());
      renderer.append(" (" + myFile.getPresentableUrl() + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
    }
  }
  else {
    renderer.setIcon(VirtualFilePresentation.getIcon(myFile));
    renderer.append(myFile.getName());
    renderer.append(" (" + myFile.getPresentableUrl() + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
  }
}
项目:GitToolBox    文件:GtRepoChooser.java   
GtRepoChooser(@NotNull Project project, @Nullable Component parentComponent) {
  super(project, parentComponent, false, IdeModalityType.PROJECT);
  this.project = project;
  centerPanel = new JPanel(new BorderLayout());
  repoList = new JBList<>();
  repoList.setCellRenderer(new ColoredListCellRenderer<GitRepository>() {
    @Override
    protected void customizeCellRenderer(@NotNull JList<? extends GitRepository> list, GitRepository value, int index,
                                         boolean selected, boolean hasFocus) {
      append(GtUtil.name(value));
      StringBand url = new StringBand(" (");
      url.append(value.getRoot().getPresentableUrl());
      url.append(")");
      append(url.toString(), SimpleTextAttributes.GRAYED_ATTRIBUTES);
    }
  });
  JBScrollPane scrollPane = new JBScrollPane(repoList);
  centerPanel.add(scrollPane, BorderLayout.CENTER);
  setTitle(ResBundle.getString("configurable.prj.autoFetch.exclusions.add.title"));
  init();
}
项目:tools-idea    文件:ConfigurationSettingsEditor.java   
public RunnersEditorComponent() {
  myRunnerPanel.setLayout(myLayout);
  myRunnerPanel.add(myNoRunner, NO_RUNNER_COMPONENT);
  myRunnersList.setModel(myListModel);
  myRunnersList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent e) {
      updateRunnerComponent();
    }
  });
  updateRunnerComponent();
  myRunnersList.setCellRenderer(new ColoredListCellRenderer() {
    @Override
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      Executor executor = (Executor)value;
      setIcon(executor.getIcon());
      append(executor.getId(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    }
  });
}
项目:tools-idea    文件:ValidExcludeListItem.java   
@Override
public void renderItem(ColoredListCellRenderer renderer) {
  if (myFrameworkType != null) {
    renderer.setIcon(myFrameworkType.getIcon());
    renderer.append(myFrameworkType.getPresentableName());
    if (myFile != null) {
      renderer.append(" in " + myFile.getName());
      renderer.append(" (" + myFile.getPresentableUrl() + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
    }
  }
  else {
    renderer.setIcon(VirtualFilePresentation.getIcon(myFile));
    renderer.append(myFile.getName());
    renderer.append(" (" + myFile.getPresentableUrl() + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
  }
}
项目:consulo    文件:ExpressionInputComponent.java   
private void showHistory() {
  List<XExpression> expressions = myExpressionEditor.getRecentExpressions();
  if (!expressions.isEmpty()) {
    ListPopupImpl popup = new ListPopupImpl(new BaseListPopupStep<XExpression>(null, expressions) {
      @Override
      public PopupStep onChosen(XExpression selectedValue, boolean finalChoice) {
        myExpressionEditor.setExpression(selectedValue);
        myExpressionEditor.requestFocusInEditor();
        return FINAL_CHOICE;
      }
    }) {
      @Override
      protected ListCellRenderer getListElementRenderer() {
        return new ColoredListCellRenderer<XExpression>() {
          @Override
          protected void customizeCellRenderer(@Nonnull JList list, XExpression value, int index, boolean selected, boolean hasFocus) {
            append(value.getExpression());
          }
        };
      }
    };
    popup.getList().setFont(EditorUtil.getEditorFont());
    popup.showUnderneathOf(myExpressionEditor.getEditorComponent());
  }
}
项目:consulo    文件:ConfigurationSettingsEditor.java   
public RunnersEditorComponent() {
  myRunnerPanel.setLayout(myLayout);
  myRunnerPanel.add(myNoRunner, NO_RUNNER_COMPONENT);
  myRunnersList.setModel(myListModel);
  myRunnersList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent e) {
      updateRunnerComponent();
    }
  });
  updateRunnerComponent();
  myRunnersList.setCellRenderer(new ColoredListCellRenderer() {
    @Override
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      Executor executor = (Executor)value;
      setIcon(executor.getIcon());
      append(executor.getId(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    }
  });
}
项目:intellij-ce-playground    文件:SelectFromListDialog.java   
public SelectFromListDialog(Project project,
                            Object[] objects,
                            ToStringAspect toStringAspect,
                            String title,
                            @JdkConstants.ListSelectionMode int selectionMode) {
  super(project, true);
  myToStringAspect = toStringAspect;
  myList.setSelectionMode(selectionMode);
  setTitle(title);

  for (Object object : objects) {
    myModel.addElement(object);
  }

  myList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      setOKActionEnabled(myList.getSelectedValues().length > 0);
    }
  });

  myList.setSelectedIndex(0);

  myList.setCellRenderer(new ColoredListCellRenderer(){
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      append(myToStringAspect.getToStirng(value),
             new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, list.getForeground()));
    }
  });


  init();
}
项目:intellij-ce-playground    文件:ColumnFilteringStrategy.java   
public ColumnFilteringStrategy(final ChangeListColumn column,
                               final Class<? extends CommittedChangesProvider> providerClass) {
  myModel = new MyListModel();
  myValueList = new JBList();
  myScrollPane = ScrollPaneFactory.createScrollPane(myValueList);
  myValueList.setModel(myModel);
  myValueList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(final ListSelectionEvent e) {
      for (ChangeListener listener : myListeners) {
        listener.stateChanged(new ChangeEvent(this));
      }
    }
  });
  myValueList.setCellRenderer(new ColoredListCellRenderer() {
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (index == 0) {
        append(value.toString(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
      }
      else if (value.toString().length() == 0) {
        append(VcsBundle.message("committed.changes.filter.none"), SimpleTextAttributes.GRAYED_ATTRIBUTES);
      }
      else {
        append(value.toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
      }
    }
  });
  myColumn = column;
  myProviderClass = providerClass;
}
项目:intellij-ce-playground    文件:RunConfigurationBeforeRunProvider.java   
@Override
protected JComponent createCenterPanel() {
  myJBList = new JBList(mySettings);
  myJBList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myJBList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent e) {
      Object selectedValue = myJBList.getSelectedValue();
      if (selectedValue instanceof RunnerAndConfigurationSettings) {
        mySelectedSettings = (RunnerAndConfigurationSettings)selectedValue;
      }
      else {
        mySelectedSettings = null;
      }
      setOKActionEnabled(mySelectedSettings != null);
    }
  });
  myJBList.setCellRenderer(new ColoredListCellRenderer() {
    @Override
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (value instanceof RunnerAndConfigurationSettings) {
        RunnerAndConfigurationSettings settings = (RunnerAndConfigurationSettings)value;
        RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject);
        setIcon(runManager.getConfigurationIcon(settings));
        RunConfiguration configuration = settings.getConfiguration();
        append(configuration.getName(), settings.isTemporary()
                                        ? SimpleTextAttributes.GRAY_ATTRIBUTES
                                        : SimpleTextAttributes.REGULAR_ATTRIBUTES);
      }
    }
  });
  return new JBScrollPane(myJBList);
}
项目:intellij-ce-playground    文件:SearchEverywherePsiRenderer.java   
@Override
protected boolean customizeNonPsiElementLeftRenderer(ColoredListCellRenderer renderer,
                                                     JList list,
                                                     Object value,
                                                     int index,
                                                     boolean selected,
                                                     boolean hasFocus) {
  if (!(value instanceof NavigationItem)) return false;

  NavigationItem item = (NavigationItem)value;

  TextAttributes attributes = getNavigationItemAttributes(item);

  SimpleTextAttributes nameAttributes = attributes != null ? SimpleTextAttributes.fromTextAttributes(attributes) : null;

  Color color = list.getForeground();
  if (nameAttributes == null) nameAttributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, color);

  renderer.append(item + " ", nameAttributes);
  ItemPresentation itemPresentation = item.getPresentation();
  assert itemPresentation != null;
  renderer.setIcon(itemPresentation.getIcon(true));

  String locationString = itemPresentation.getLocationString();
  if (!StringUtil.isEmpty(locationString)) {
    renderer.append(locationString, new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, JBColor.GRAY));
  }
  return true;
}
项目:intellij-ce-playground    文件:GotoFileCellRenderer.java   
@Override
protected boolean customizeNonPsiElementLeftRenderer(ColoredListCellRenderer renderer,
                                                     JList list,
                                                     Object value,
                                                     int index,
                                                     boolean selected,
                                                     boolean hasFocus) {
  if (!(value instanceof NavigationItem)) return false;

  NavigationItem item = (NavigationItem)value;

  TextAttributes attributes = getNavigationItemAttributes(item);

  SimpleTextAttributes nameAttributes = attributes != null ? SimpleTextAttributes.fromTextAttributes(attributes) : null;

  Color color = list.getForeground();
  if (nameAttributes == null) nameAttributes = new SimpleTextAttributes(Font.PLAIN, color);

  renderer.append(item + " ", nameAttributes);
  ItemPresentation itemPresentation = item.getPresentation();
  assert itemPresentation != null;
  renderer.setIcon(itemPresentation.getIcon(true));

  String locationString = itemPresentation.getLocationString();
  if (!StringUtil.isEmpty(locationString)) {
    renderer.append(locationString, new SimpleTextAttributes(Font.PLAIN, JBColor.GRAY));
  }
  return true;
}
项目:intellij-ce-playground    文件:InvalidExcludeListItem.java   
@Override
public void renderItem(ColoredListCellRenderer renderer) {
  if (myFrameworkTypeId != null) {
    renderer.append(myFrameworkTypeId, SimpleTextAttributes.ERROR_ATTRIBUTES);
    if (myFileUrl != null) {
      renderer.append(" in " + myFileUrl, SimpleTextAttributes.ERROR_ATTRIBUTES);
    }
  }
  else {
    renderer.append(myFileUrl, SimpleTextAttributes.ERROR_ATTRIBUTES);
  }
  renderer.setIcon(EmptyIcon.ICON_16);
}
项目:intellij-ce-playground    文件:FlagManager.java   
/** Returns a {@link ListCellRenderer} suitable for displaying languages when the list model contains String language codes */
@NotNull
public ListCellRenderer getLanguageCodeCellRenderer() {
  final Function<Object, String> nameMapper = getLanguageNameMapper();
  return new ColoredListCellRenderer() {
    @Override
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      append(nameMapper.fun(value));
      setIcon(getFlag((String)value, null));
    }
  };
}
项目:intellij-ce-playground    文件:FlagManager.java   
/** Returns a {@link ListCellRenderer} suitable for displaying regions when the list model contains String region codes */
@NotNull
public ListCellRenderer getRegionCodeCellRenderer() {
  final Function<Object, String> nameMapper = getRegionNameMapper();
  return new ColoredListCellRenderer() {
    @Override
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      append(nameMapper.fun(value));
      setIcon(getFlag(null, (String)value));
    }
  };
}
项目:intellij-ce-playground    文件:TraceViewPanel.java   
public void setTrace(@NotNull VmTraceData trace) {
  myTraceData = trace;

  List<ThreadInfo> threads = trace.getThreads(true);
  if (threads.isEmpty()) {
    return;
  }

  ThreadInfo defaultThread = Iterables.find(threads, new Predicate<ThreadInfo>() {
    @Override
    public boolean apply(ThreadInfo input) {
      return MAIN_THREAD_NAME.equals(input.getName());
    }
  }, threads.get(0));

  myTraceViewCanvas.setTrace(trace, defaultThread, getCurrentRenderClock());
  myThreadCombo.setModel(new DefaultComboBoxModel(threads.toArray()));
  myThreadCombo.setSelectedItem(defaultThread);
  myThreadCombo.setRenderer(new ColoredListCellRenderer() {
    @Override
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      String name = value instanceof ThreadInfo ? ((ThreadInfo)value).getName() : value.toString();
      append(name);
    }
  });

  myThreadCombo.setEnabled(true);
  myRenderClockSelectorCombo.setEnabled(true);

  myVmStatsTreeTableModel.setTraceData(trace, defaultThread);
  myVmStatsTreeTableModel.setClockType(getCurrentRenderClock());
  myTreeTable.setModel(myVmStatsTreeTableModel);

  VmStatsTreeUtils.adjustTableColumnWidths(myTreeTable);
  VmStatsTreeUtils.setCellRenderers(myTreeTable);
  VmStatsTreeUtils.setSpeedSearch(myTreeTable);
  VmStatsTreeUtils.enableSorting(myTreeTable, myVmStatsTreeTableModel);
}
项目:intellij-ce-playground    文件:ComponentItem.java   
public void customizeCellRenderer(ColoredListCellRenderer cellRenderer, boolean selected, boolean hasFocus) {
  cellRenderer.setIcon(getSmallIcon());
  if (myAnyComponent) {
    cellRenderer.append(UIDesignerBundle.message("palette.non.palette.component"), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    cellRenderer.setToolTipText(UIDesignerBundle.message("palette.non.palette.component.tooltip"));
  }
  else {
    cellRenderer.append(getClassShortName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    cellRenderer.setToolTipText(getToolTipText());
  }
}
项目: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    文件:SelectFromListDialog.java   
public SelectFromListDialog(Project project,
                            Object[] objects,
                            ToStringAspect toStringAspect,
                            String title,
                            @JdkConstants.ListSelectionMode int selectionMode) {
  super(project, true);
  myToStringAspect = toStringAspect;
  myList.setSelectionMode(selectionMode);
  setTitle(title);

  for (Object object : objects) {
    myModel.addElement(object);
  }

  myList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      setOKActionEnabled(myList.getSelectedValues().length > 0);
    }
  });

  myList.setSelectedIndex(0);

  myList.setCellRenderer(new ColoredListCellRenderer(){
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      append(myToStringAspect.getToStirng(value),
             new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, list.getForeground()));
    }
  });


  init();
}
项目:tools-idea    文件:ColumnFilteringStrategy.java   
public ColumnFilteringStrategy(final ChangeListColumn column,
                               final Class<? extends CommittedChangesProvider> providerClass) {
  myModel = new MyListModel();
  myValueList = new JBList();
  myScrollPane = ScrollPaneFactory.createScrollPane(myValueList);
  myValueList.setModel(myModel);
  myValueList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(final ListSelectionEvent e) {
      for (ChangeListener listener : myListeners) {
        listener.stateChanged(new ChangeEvent(this));
      }
    }
  });
  myValueList.setCellRenderer(new ColoredListCellRenderer() {
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (index == 0) {
        append(value.toString(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
      }
      else if (value.toString().length() == 0) {
        append(VcsBundle.message("committed.changes.filter.none"), SimpleTextAttributes.GRAYED_ATTRIBUTES);
      }
      else {
        append(value.toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
      }
    }
  });
  myColumn = column;
  myProviderClass = providerClass;
}
项目:tools-idea    文件:RunConfigurationBeforeRunProvider.java   
@Override
protected JComponent createCenterPanel() {
  myJBList = new JBList(mySettings);
  myJBList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myJBList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent e) {
      Object selectedValue = myJBList.getSelectedValue();
      if (selectedValue instanceof RunnerAndConfigurationSettings) {
        mySelectedSettings = (RunnerAndConfigurationSettings)selectedValue;
      }
      else {
        mySelectedSettings = null;
      }
      setOKActionEnabled(mySelectedSettings != null);
    }
  });
  myJBList.setCellRenderer(new ColoredListCellRenderer() {
    @Override
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (value instanceof RunnerAndConfigurationSettings) {
        RunnerAndConfigurationSettings settings = (RunnerAndConfigurationSettings)value;
        RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject);
        setIcon(runManager.getConfigurationIcon(settings));
        RunConfiguration configuration = settings.getConfiguration();
        append(configuration.getName(), runManager.isTemporary(configuration)
                                        ? SimpleTextAttributes.GRAY_ATTRIBUTES
                                        : SimpleTextAttributes.REGULAR_ATTRIBUTES);
      }
    }
  });
  return new JBScrollPane(myJBList);
}
项目:tools-idea    文件:GotoFileCellRenderer.java   
@Override
protected boolean customizeNonPsiElementLeftRenderer(ColoredListCellRenderer renderer,
                                                     JList list,
                                                     Object value,
                                                     int index,
                                                     boolean selected,
                                                     boolean hasFocus) {
  if (!(value instanceof NavigationItem)) return false;

  NavigationItem item = (NavigationItem)value;

  TextAttributes attributes = getNavigationItemAttributes(item);

  SimpleTextAttributes nameAttributes = attributes != null ? SimpleTextAttributes.fromTextAttributes(attributes) : null;

  Color color = list.getForeground();
  if (nameAttributes == null) nameAttributes = new SimpleTextAttributes(Font.PLAIN, color);

  renderer.append(item + " ", nameAttributes);
  ItemPresentation itemPresentation = item.getPresentation();
  assert itemPresentation != null;
  renderer.setIcon(itemPresentation.getIcon(true));

  String locationString = itemPresentation.getLocationString();
  if (!StringUtil.isEmpty(locationString)) {
    renderer.append(locationString, new SimpleTextAttributes(Font.PLAIN, JBColor.GRAY));
  }
  return true;
}
项目:tools-idea    文件:InvalidExcludeListItem.java   
@Override
public void renderItem(ColoredListCellRenderer renderer) {
  if (myFrameworkTypeId != null) {
    renderer.append(myFrameworkTypeId, SimpleTextAttributes.ERROR_ATTRIBUTES);
    if (myFileUrl != null) {
      renderer.append(" in " + myFileUrl, SimpleTextAttributes.ERROR_ATTRIBUTES);
    }
  }
  else {
    renderer.append(myFileUrl, SimpleTextAttributes.ERROR_ATTRIBUTES);
  }
}
项目:tools-idea    文件:ComponentItem.java   
public void customizeCellRenderer(ColoredListCellRenderer cellRenderer, boolean selected, boolean hasFocus) {
  cellRenderer.setIcon(getSmallIcon());
  if (myAnyComponent) {
    cellRenderer.append(UIDesignerBundle.message("palette.non.palette.component"), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    cellRenderer.setToolTipText(UIDesignerBundle.message("palette.non.palette.component.tooltip"));
  }
  else {
    cellRenderer.append(getClassShortName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    cellRenderer.setToolTipText(getToolTipText());
  }
}
项目:tools-idea    文件:ChooseCheckoutMode.java   
public ChooseCheckoutMode(CheckoutWizard wizard) {
  super("###", wizard);
  myCheckoutModeList.setCellRenderer(new ColoredListCellRenderer() {
    @Override
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      final CheckoutStrategy checkoutStrategy = (CheckoutStrategy)value;
      append(checkoutStrategy.getResult().getAbsolutePath(), new SimpleTextAttributes(Font.PLAIN, list.getForeground()));
      setIcon(PlatformIcons.DIRECTORY_CLOSED_ICON);
    }
  });
  myCheckoutModeList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent e) {
      getWizard().updateButtons();
    }
  });

  myCheckoutModeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  final CvsApplicationLevelConfiguration config = CvsApplicationLevelConfiguration.getInstance();
  myMakeNewFilesReadOnly.setSelected(config.MAKE_CHECKED_OUT_FILES_READONLY);
  myPruneEmptyDirectories.setSelected(config.CHECKOUT_PRUNE_EMPTY_DIRECTORIES);
  myChangeKeywordSubstitutionPanel =
    new ChangeKeywordSubstitutionPanel(KeywordSubstitution.getValue(config.CHECKOUT_KEYWORD_SUBSTITUTION));

  myCenterPanel.add(LIST, ScrollPaneFactory.createScrollPane(myCheckoutModeList));
  final JPanel messagePanel = new JPanel(new BorderLayout(2,4));
  messagePanel.add(myMessage, BorderLayout.NORTH);
  messagePanel.setBackground(UIUtil.getTableBackground());
  myMessage.setBackground(UIUtil.getTableBackground());
  myCenterPanel.add(MESSAGE, ScrollPaneFactory.createScrollPane(messagePanel));

  init();
}
项目:nosql4idea    文件:AbstractAddDialog.java   
void initCombo(final ComboBox combobox, final JPanel parentPanel) {
    combobox.setModel(new DefaultComboBoxModel(JsonDataType.values()));
    combobox.setRenderer(new ColoredListCellRenderer() {

        @Override
        protected void customizeCellRenderer(JList jList, Object o, int i, boolean b, boolean b2) {
            append(((JsonDataType) o).type);
        }
    });

    combobox.setSelectedItem(null);
    combobox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent itemEvent) {
            JsonDataType selectedType = (JsonDataType) combobox.getSelectedItem();
            currentEditor = UI_COMPONENT_BY_JSON_DATATYPE.get(selectedType);
            currentEditor.reset();

            parentPanel.invalidate();
            parentPanel.removeAll();
            parentPanel.add(currentEditor.getComponent(), BorderLayout.CENTER);
            parentPanel.validate();
        }
    });

    combobox.setSelectedItem(JsonDataType.STRING);
}
项目:nosql4idea    文件:SelectDatabaseVendorDialog.java   
private void initCombobox() {

        databaseVendorCombobox.setModel(new DefaultComboBoxModel(DatabaseVendor.values()));
        databaseVendorCombobox.setRenderer(new ColoredListCellRenderer() {
            @Override
            protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
                DatabaseVendor databaseVendor = (DatabaseVendor) value;
                setIcon(databaseVendor.icon);
                append(databaseVendor.name);
            }
        });

        databaseVendorCombobox.setSelectedItem(DatabaseVendor.MONGO);
    }
项目:consulo-csharp    文件:CSharpSdkPanel.java   
public CSharpSdkPanel()
{
    super(new VerticalFlowLayout());

    myTargetComboBox = new ComboBox<>(DotNetTarget.values());
    myTargetComboBox.setRenderer(new ColoredListCellRenderer<DotNetTarget>()
    {
        @Override
        protected void customizeCellRenderer(@NotNull JList<? extends DotNetTarget> jList, DotNetTarget target, int i, boolean b, boolean b1)
        {
            append(target.getDescription());
        }
    });
    add(myTargetComponent = LabeledComponent.left(myTargetComboBox, "Target"));

    List<String> validSdkTypes = new SmartList<>();
    for(Map.Entry<String, String[]> entry : CSharpNewModuleBuilder.ourExtensionMapping.entrySet())
    {
        // need check C# extension
        ModuleExtensionProviderEP providerEP = ModuleExtensionProviders.findProvider(entry.getValue()[1]);
        if(providerEP == null)
        {
            continue;
        }
        validSdkTypes.add(entry.getKey());
    }

    ProjectSdksModel model = new ProjectSdksModel();
    model.reset();

    myComboBox = new SdkComboBox(model, sdkTypeId -> validSdkTypes.contains(sdkTypeId.getName()), false);

    add(LabeledComponent.left(myComboBox, ".NET SDK"));
}
项目:consulo-ui-designer    文件:ComponentItem.java   
public void customizeCellRenderer(ColoredListCellRenderer cellRenderer, boolean selected, boolean hasFocus) {
  cellRenderer.setIcon(getSmallIcon());
  if (myAnyComponent) {
    cellRenderer.append(UIDesignerBundle.message("palette.non.palette.component"), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    cellRenderer.setToolTipText(UIDesignerBundle.message("palette.non.palette.component.tooltip"));
  }
  else {
    cellRenderer.append(getClassShortName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    cellRenderer.setToolTipText(getToolTipText());
  }
}
项目:consulo    文件:SelectFromListDialog.java   
public SelectFromListDialog(Project project,
                            Object[] objects,
                            ToStringAspect toStringAspect,
                            String title,
                            @JdkConstants.ListSelectionMode int selectionMode) {
  super(project, true);
  myToStringAspect = toStringAspect;
  myList.setSelectionMode(selectionMode);
  setTitle(title);

  for (Object object : objects) {
    myModel.addElement(object);
  }

  myList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      setOKActionEnabled(myList.getSelectedValues().length > 0);
    }
  });

  myList.setSelectedIndex(0);

  myList.setCellRenderer(new ColoredListCellRenderer(){
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      append(myToStringAspect.getToStirng(value),
             new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, list.getForeground()));
    }
  });


  init();
}
项目:consulo    文件:ColumnFilteringStrategy.java   
public ColumnFilteringStrategy(final ChangeListColumn column,
                               final Class<? extends CommittedChangesProvider> providerClass) {
  myModel = new MyListModel();
  myValueList = new JBList();
  myScrollPane = ScrollPaneFactory.createScrollPane(myValueList);
  myValueList.setModel(myModel);
  myValueList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(final ListSelectionEvent e) {
      for (ChangeListener listener : myListeners) {
        listener.stateChanged(new ChangeEvent(this));
      }
    }
  });
  myValueList.setCellRenderer(new ColoredListCellRenderer() {
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (index == 0) {
        append(value.toString(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
      }
      else if (value.toString().length() == 0) {
        append(VcsBundle.message("committed.changes.filter.none"), SimpleTextAttributes.GRAYED_ATTRIBUTES);
      }
      else {
        append(value.toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
      }
    }
  });
  myColumn = column;
  myProviderClass = providerClass;
}
项目:consulo    文件:RunConfigurationBeforeRunProvider.java   
@Override
protected JComponent createCenterPanel() {
  myJBList = new JBList(mySettings);
  myJBList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myJBList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent e) {
      Object selectedValue = myJBList.getSelectedValue();
      if (selectedValue instanceof RunnerAndConfigurationSettings) {
        mySelectedSettings = (RunnerAndConfigurationSettings)selectedValue;
      }
      else {
        mySelectedSettings = null;
      }
      setOKActionEnabled(mySelectedSettings != null);
    }
  });
  myJBList.setCellRenderer(new ColoredListCellRenderer() {
    @Override
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (value instanceof RunnerAndConfigurationSettings) {
        RunnerAndConfigurationSettings settings = (RunnerAndConfigurationSettings)value;
        RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject);
        setIcon(runManager.getConfigurationIcon(settings));
        RunConfiguration configuration = settings.getConfiguration();
        append(configuration.getName(), settings.isTemporary()
                                        ? SimpleTextAttributes.GRAY_ATTRIBUTES
                                        : SimpleTextAttributes.REGULAR_ATTRIBUTES);
      }
    }
  });
  return new JBScrollPane(myJBList);
}
项目:consulo    文件:SearchEverywherePsiRenderer.java   
@Override
protected boolean customizeNonPsiElementLeftRenderer(ColoredListCellRenderer renderer,
                                                     JList list,
                                                     Object value,
                                                     int index,
                                                     boolean selected,
                                                     boolean hasFocus) {
  if (!(value instanceof NavigationItem)) return false;

  NavigationItem item = (NavigationItem)value;

  TextAttributes attributes = getNavigationItemAttributes(item);

  SimpleTextAttributes nameAttributes = attributes != null ? SimpleTextAttributes.fromTextAttributes(attributes) : null;

  Color color = list.getForeground();
  if (nameAttributes == null) nameAttributes = new SimpleTextAttributes(Font.PLAIN, color);

  renderer.append(item + " ", nameAttributes);
  ItemPresentation itemPresentation = item.getPresentation();
  assert itemPresentation != null;
  renderer.setIcon(itemPresentation.getIcon(true));

  String locationString = itemPresentation.getLocationString();
  if (!StringUtil.isEmpty(locationString)) {
    renderer.append(locationString, new SimpleTextAttributes(Font.PLAIN, JBColor.GRAY));
  }
  return true;
}
项目:consulo    文件:PsiElementListCellRenderer.java   
protected boolean customizeNonPsiElementLeftRenderer(ColoredListCellRenderer renderer,
                                                     JList list,
                                                     Object value,
                                                     int index,
                                                     boolean selected,
                                                     boolean hasFocus) {
  return false;
}
项目:consulo    文件:GotoFileCellRenderer.java   
@Override
protected boolean customizeNonPsiElementLeftRenderer(ColoredListCellRenderer renderer,
                                                     JList list,
                                                     Object value,
                                                     int index,
                                                     boolean selected,
                                                     boolean hasFocus) {
  if (!(value instanceof NavigationItem)) return false;

  NavigationItem item = (NavigationItem)value;

  TextAttributes attributes = getNavigationItemAttributes(item);

  SimpleTextAttributes nameAttributes = attributes != null ? SimpleTextAttributes.fromTextAttributes(attributes) : null;

  Color color = list.getForeground();
  if (nameAttributes == null) nameAttributes = new SimpleTextAttributes(Font.PLAIN, color);

  renderer.append(item + " ", nameAttributes);
  ItemPresentation itemPresentation = item.getPresentation();
  assert itemPresentation != null;
  renderer.setIcon(itemPresentation.getIcon(true));

  String locationString = itemPresentation.getLocationString();
  if (!StringUtil.isEmpty(locationString)) {
    renderer.append(locationString, new SimpleTextAttributes(Font.PLAIN, JBColor.GRAY));
  }
  return true;
}
项目:consulo    文件:DesktopComboBoxImpl.java   
public DesktopComboBoxImpl(ListModel<E> model) {
  myModel = new DesktopComboBoxModelWrapper<E>(model);

  setModel(myModel);
  setRenderer(new ColoredListCellRenderer<E>() {
    @Override
    protected void customizeCellRenderer(@Nonnull JList<? extends E> list, E value, int index, boolean selected, boolean hasFocus) {
      DesktopItemPresentationImpl<E> render = new DesktopItemPresentationImpl<E>(this);
      myRender.render(render, index, value);
    }
  });
}
项目:consulo    文件:DesktopListBoxImpl.java   
public DesktopListBoxImpl(ListModel<E> model) {
  myModel = new DesktopComboBoxModelWrapper<>(model);

  myList = new JBList<>(myModel);
  myList.setCellRenderer(new ColoredListCellRenderer<E>() {
    @Override
    protected void customizeCellRenderer(@Nonnull JList<? extends E> list, E value, int index, boolean selected, boolean hasFocus) {
      DesktopItemPresentationImpl<E> render = new DesktopItemPresentationImpl<>(this);
      myRender.render(render, index, value);
    }
  });
  myRootPanel = ScrollPaneFactory.createScrollPane(myList);
}
项目: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"));
}
项目:consulo-java    文件:ShortenCommandLineModeCombo.java   
public ShortenCommandLineModeCombo(Project project, JrePathEditor pathEditor, ModuleDescriptionsComboBox component)
{
    myProject = project;
    initModel(null, pathEditor, component.getSelectedModule());
    setRenderer(new ColoredListCellRenderer<ShortenCommandLine>()
    {
        @Override
        protected void customizeCellRenderer(@NotNull JList<? extends ShortenCommandLine> list, ShortenCommandLine value, int index, boolean selected, boolean hasFocus)
        {
            if(value == null)
            {
                ShortenCommandLine defaultMode = ShortenCommandLine.getDefaultMethod(myProject, getJdkRoot(pathEditor, component.getSelectedModule()));
                append("user-local default: " + defaultMode.getPresentableName()).append(" - " + defaultMode.getDescription(), SimpleTextAttributes.GRAYED_ATTRIBUTES);
            }
            else
            {
                append(value.getPresentableName()).append(" - " + value.getDescription(), SimpleTextAttributes.GRAYED_ATTRIBUTES);
            }
        }
    });
    ActionListener updateModelListener = e ->
    {
        Object item = getSelectedItem();
        initModel((ShortenCommandLine) item, pathEditor, component.getSelectedModule());
    };
    pathEditor.addActionListener(updateModelListener);
    component.addActionListener(updateModelListener);
}