當前位置: 首頁>>代碼示例>>Java>>正文


Java JBList.setCellRenderer方法代碼示例

本文整理匯總了Java中com.intellij.ui.components.JBList.setCellRenderer方法的典型用法代碼示例。如果您正苦於以下問題:Java JBList.setCellRenderer方法的具體用法?Java JBList.setCellRenderer怎麽用?Java JBList.setCellRenderer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.ui.components.JBList的用法示例。


在下文中一共展示了JBList.setCellRenderer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createCenterPanel

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
@Override
protected JComponent createCenterPanel() {
  final JPanel panel = new JPanel(new BorderLayout(UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP));
  myList = new JBList(myNamedElements);
  myList.setCellRenderer(new FQNameCellRenderer());
  panel.add(ScrollPaneFactory.createScrollPane(myList), BorderLayout.CENTER);

  panel.add(new JBLabel(myContainsClassesOnly ?
                        CodeInsightBundle.message("dialog.paste.on.import.text") :
                        CodeInsightBundle.message("dialog.paste.on.import.text2"), SMALL, BRIGHTER), BorderLayout.NORTH);

  final JPanel buttonPanel = new JPanel(new VerticalFlowLayout());
  final JButton okButton = new JButton(CommonBundle.getOkButtonText());
  getRootPane().setDefaultButton(okButton);
  buttonPanel.add(okButton);
  final JButton cancelButton = new JButton(CommonBundle.getCancelButtonText());
  buttonPanel.add(cancelButton);

  panel.setPreferredSize(JBUI.size(500, 400));

  return panel;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:RestoreReferencesDialog.java

示例2: createList

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
protected JBList createList() {
  final JBList list = new JBList(myListModel);
  list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  list.setEmptyText(getListEmptyText());
  list.setCellRenderer(createListCellRenderer());

  installListActions(list);
  list.addListSelectionListener(new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent event) {
      if (event.getValueIsAdjusting()) return;
      if (isMergeListItemsRunning()) return;
      if (myUpdateSelectedPathModeActive.get()) return;
      updateRightComponent(true);
    }
  });
  ScrollingUtil.installActions(list);

  //    installSpeedSearch(list); // TODO

  installEditOnDoubleClick(list);
  return list;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:FinderRecursivePanel.java

示例3: initUI

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
private void initUI() {
  myComponent = new JPanel(new BorderLayout());
  mySplitter = new JBSplitter("AssociationsEditor.dividerProportion", 0.3f);
  myComponent.add(mySplitter, BorderLayout.CENTER);

  JPanel leftPanel = new JPanel(new BorderLayout());
  leftPanel.setBorder(IdeBorderFactory.createTitledBorder("Project XSLT Files", false, new Insets(0, 0, 0, 0)));
  myTree = new Tree();
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(false);
  leftPanel.add(new JBScrollPane(myTree), BorderLayout.CENTER);
  mySplitter.setFirstComponent(leftPanel);

  myList = new JBList();
  myList.setCellRenderer(new MyCellRenderer());
  myList.setMinimumSize(new Dimension(120, 200));
  myList.getEmptyText().setText("No associated files");
  JPanel rightPanel = ToolbarDecorator.createDecorator(myList)
    .addExtraAction(AnActionButton.fromAction(new AddAssociationActionWrapper()))
    .addExtraAction(AnActionButton.fromAction(new RemoveAssociationAction()))
    .disableUpDownActions().disableAddAction().disableRemoveAction().createPanel();
  UIUtil.addBorder(rightPanel, IdeBorderFactory.createTitledBorder("Associated Files", false, new Insets(0, 0, 0, 0)));
  mySplitter.setSecondComponent(rightPanel);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:AssociationsEditor.java

示例4: invoke

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
@Override
public void invoke(@NotNull final Project project, @Nullable final Editor editor, PsiFile file) {
  if (myModules.size() == 1) {
    addDependencyOnModule(project, editor, ContainerUtil.getFirstItem(myModules));
  }
  else {
    final JBList list = new JBList(myModules);
    list.setCellRenderer(new ModuleListCellRenderer());
    final JBPopup popup = JBPopupFactory.getInstance().createListPopupBuilder(list)
      .setTitle("Choose Module to Add Dependency on")
      .setMovable(false)
      .setResizable(false)
      .setRequestFocus(true)
      .setItemChoosenCallback(new Runnable() {
        @Override
        public void run() {
          final Object value = list.getSelectedValue();
          if (value instanceof Module) {
            addDependencyOnModule(project, editor, (Module)value);
          }
        }
      }).createPopup();
    if (editor != null) {
      popup.showInBestPositionFor(editor);
    } else {
      popup.showCenteredInCurrentWindow(project);
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:30,代碼來源:AddModuleDependencyFix.java

示例5: invoke

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
@Override
public void invoke(final @NotNull Project project, final Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
  final PsiClass srcClass = PsiTreeUtil.getParentOfType(element, PsiClass.class);

  if (srcClass == null) return;

  final Collection<PsiElement> testClasses = TestFinderHelper.findTestsForClass(srcClass);
  
  if (testClasses.isEmpty()) {
    HintManager.getInstance().showErrorHint(editor, "No tests found.");
    return;
  }
  
  if (testClasses.size() == 1) {
    generateMissedTests((PsiClass)ContainerUtil.getFirstItem(testClasses), srcClass, editor);
    return;
  }

  final JBList list = new JBList(testClasses);
  list.setCellRenderer(new PsiClassListCellRenderer());
  JBPopupFactory.getInstance().createListPopupBuilder(list)
    .setItemChoosenCallback(new Runnable() {
    @Override
    public void run() {
      generateMissedTests((PsiClass)list.getSelectedValue(), srcClass, editor);
    }
  })
    .setTitle("Choose Test")
    .createPopup().showInBestPositionFor(editor);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:31,代碼來源:GenerateMissedTestsAction.java

示例6: createCenterPanel

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
protected JComponent createCenterPanel() {
  JPanel panel = new JPanel();
  panel.setLayout(new BorderLayout(UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP));

  final JLabel classListLabel = new JLabel();
  panel.add(classListLabel, BorderLayout.NORTH);

  mySuperClassesList = new JBList(mySuperClasses.toArray());
  mySuperClassesList.setCellRenderer(new ClassCellRenderer(mySuperClassesList.getCellRenderer()));
  mySuperClassesList.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  classListLabel.setText(RefactoringBundle.message("turnRefsToSuper.change.usages.to", mySubClass.getQualifiedName()));

  PsiClass nearestBase = RefactoringHierarchyUtil.getNearestBaseClass(mySubClass, true);
  int indexToSelect = 0;
  if(nearestBase != null) {
    indexToSelect = mySuperClasses.indexOf(nearestBase);
  }
  mySuperClassesList.setSelectedIndex(indexToSelect);
  panel.add(ScrollPaneFactory.createScrollPane(mySuperClassesList), BorderLayout.CENTER);

  myCbReplaceInstanceOf.setText(RefactoringBundle.message("turnRefsToSuper.use.superclass.in.instanceof"));
  myCbReplaceInstanceOf.setSelected(false);
  myCbReplaceInstanceOf.setFocusable(false);
  panel.add(myCbReplaceInstanceOf, BorderLayout.SOUTH);

  return panel;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:28,代碼來源:TurnRefsToSuperDialog.java

示例7: createNorthPanel

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
protected JComponent createNorthPanel() {
  JPanel panel = new JPanel();

  panel.setLayout(new GridBagLayout());
  GridBagConstraints gbConstraints = new GridBagConstraints();

  gbConstraints.insets = new Insets(4, 8, 4, 8);
  gbConstraints.weighty = 0;
  gbConstraints.weightx = 1;
  gbConstraints.gridy = 0;
  gbConstraints.gridwidth = GridBagConstraints.REMAINDER;
  gbConstraints.gridheight = 1;
  gbConstraints.fill = GridBagConstraints.BOTH;
  gbConstraints.anchor = GridBagConstraints.WEST;
  panel.add(new JLabel(RefactoringBundle.message("introduce.parameter.to.method")), gbConstraints);

  gbConstraints.weighty = 1;
  myEnclosingMethodsList = new JBList(myEnclosingMethods.toArray());
  myEnclosingMethodsList.setCellRenderer(new MethodCellRenderer());
  myEnclosingMethodsList.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

  int indexToSelect = 0;
  myEnclosingMethodsList.setSelectedIndex(indexToSelect);
  gbConstraints.gridy++;
  panel.add(ScrollPaneFactory.createScrollPane(myEnclosingMethodsList), gbConstraints);

  return panel;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:29,代碼來源:EnclosingMethodSelectionDialog.java

示例8: createList

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
private JBList createList(RefGroup group) {
  JBList list = new JBList(createListModel(group));
  list.setCellRenderer(myCellRenderer);
  ListUtil.installAutoSelectOnMouseMove(list);
  list.setSelectedIndex(0);
  list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

  jumpOnMouseClick(list);
  jumpOnEnter(list);

  return list;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:BranchesPanel.java

示例9: showRecentFilesPopup

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
private void showRecentFilesPopup() {
  final JBList files = new JBList(getRecentFiles()) {
    @Override
    public Dimension getPreferredSize() {
      return new Dimension(myPathTextField.getField().getWidth(), super.getPreferredSize().height);
    }
  };
  files.setCellRenderer(new ColoredListCellRenderer() {
    @Override
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      final String path = value.toString();
      append(path);
      final VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(new File(path));
      if (file != null) {
        setIcon(IconUtil.getIcon(file, Iconable.ICON_FLAG_READ_STATUS, null));
      }
    }
  });
  JBPopupFactory.getInstance()
    .createListPopupBuilder(files)
    .setItemChoosenCallback(new Runnable() {
      @Override
      public void run() {
        myPathTextField.getField().setText(files.getSelectedValue().toString());
      }
    }).createPopup().showUnderneathOf(myPathTextField.getField());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:28,代碼來源:FileChooserDialogImpl.java

示例10: SSBasedInspectionOptions

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
public SSBasedInspectionOptions(final List<Configuration> configurations) {
  myConfigurations = configurations;
  myTemplatesList  = new JBList(new MyListModel());
  myTemplatesList.setCellRenderer(new DefaultListCellRenderer() {
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      JLabel component = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
      Configuration configuration = myConfigurations.get(index);
      component.setText(configuration.getName());
      return component;
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:SSBasedInspectionOptions.java

示例11: ColumnFilteringStrategy

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:30,代碼來源:ColumnFilteringStrategy.java

示例12: IgnoredSettingsPanel

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
public IgnoredSettingsPanel(Project project) {
  myList = new JBList();
  myList.setCellRenderer(new MyCellRenderer());
  myList.getEmptyText().setText(VcsBundle.message("no.ignored.files"));

  myProject = project;
  myChangeListManager = ChangeListManagerImpl.getInstanceImpl(myProject);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:9,代碼來源:IgnoredSettingsPanel.java

示例13: CompoundRunConfigurationSettingsEditor

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
public CompoundRunConfigurationSettingsEditor(@NotNull Project project) {
  myRunManager = RunManagerImpl.getInstanceImpl(project);
  myModel = new SortedListModel<RunConfiguration>(CompoundRunConfiguration.COMPARATOR);
  myList = new JBList(myModel);
  myList.setCellRenderer(new ColoredListCellRenderer() {
    @Override
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      RunConfiguration configuration = myModel.get(index);
      setIcon(configuration.getType().getIcon());
      append(configuration.getType().getDisplayName() + " '" + configuration.getName() + "'");
    }
  });
  myList.setVisibleRowCount(15);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:15,代碼來源:CompoundRunConfigurationSettingsEditor.java

示例14: NamedObjectPanel

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
public NamedObjectPanel(@NotNull Project project, @NotNull String moduleName, @NotNull BuildFileKey buildFileKey,
                        @NotNull String newItemName, @NotNull PanelGroup panelGroup) {
  super(project, moduleName);
  myBuildFileKey = buildFileKey;
  myNewItemName = newItemName;
  myPanelGroup = panelGroup;
  myListModel = new SortedListModel();
  myObjectName.getDocument().addDocumentListener(this);

  myList = new JBList();
  myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myList.addListSelectionListener(this);
  myList.setModel(myListModel);
  myList.setCellRenderer(new DefaultListCellRenderer() {
    @Override
    public Component getListCellRendererComponent(JList jList, Object o, int i, boolean b, boolean b2) {
      return super.getListCellRendererComponent(jList, ((NamedObject)o).getName(), i, b, b2);
    }
  });
  ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myList);
  decorator.setAddAction(new AnActionButtonRunnable() {
    @Override
    public void run(AnActionButton button) {
      updateCurrentObjectFromUi();
      addObject();
    }
  });
  decorator.setRemoveAction(new AnActionButtonRunnable() {
    @Override
    public void run(AnActionButton anActionButton) {
      removeObject();
    }
  });
  decorator.setRemoveActionUpdater(new AnActionButtonUpdater() {
    @Override
    public boolean isEnabled(AnActionEvent e) {
      NamedObject selectedObject = getSelectedObject();
      return selectedObject != null && !(selectedObject instanceof UndeletableNamedObject);
    }
  });
  decorator.disableUpDownActions();
  mySplitPane.setLeftComponent(decorator.createPanel());
  mySplitPane.setDividerLocation(200);
  myRightPane.setBorder(IdeBorderFactory.createBorder());

  myNameWarning.setForeground(JBColor.RED);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:48,代碼來源:NamedObjectPanel.java

示例15: MyOptions

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
public MyOptions() {
  myAdditionalLocalesList = new JBList(new MyListModel());
  myAdditionalLocalesList.setCellRenderer(new DefaultListCellRenderer());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:5,代碼來源:SuspiciousLocalesLanguagesInspection.java


注:本文中的com.intellij.ui.components.JBList.setCellRenderer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。