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


Java JBList.setSelectedIndex方法代碼示例

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


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

示例1: addRightMouseButtonFunctionality

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
private void addRightMouseButtonFunctionality(MouseEvent mouseEvent,
                                              final JBList list,
                                              JBScrollPane panel) {

    logger.info("Adding functionality for right mouse button. @CourseTabFactory");
    if (!SwingUtilities.isRightMouseButton(mouseEvent)) {
        return;
    }

    int index = list.locationToIndex(mouseEvent.getPoint());
    list.setSelectedIndex(index);
    PopUpMenu menu = new PopUpMenu();
    JBMenuItem openInExplorer = new JBMenuItem("Open path");
    final Object selectedItem = list.getSelectedValue();
    JBMenuItem deleteFolder = new JBMenuItem("Delete folder");

    openInExplorer.addActionListener(createOpenInExploreListener(list, selectedItem));

    deleteFolder.addActionListener(createDeleteButtonActionListener(list, selectedItem));

    menu.add(openInExplorer);
    menu.add(deleteFolder);
    menu.show(panel, mouseEvent.getX(), mouseEvent.getY());
    menu.setLocation(mouseEvent.getXOnScreen(), mouseEvent.getYOnScreen());

}
 
開發者ID:testmycode,項目名稱:tmc-intellij,代碼行數:27,代碼來源:CourseTabFactory.java

示例2: CustomFoldingRegionsPopup

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
CustomFoldingRegionsPopup(@NotNull Collection<FoldingDescriptor> descriptors,
                          @NotNull final Editor editor,
                          @NotNull final Project project) {
  myEditor = editor;
  myRegionsList = new JBList();
  //noinspection unchecked
  myRegionsList.setModel(new MyListModel(orderByPosition(descriptors)));
  myRegionsList.setSelectedIndex(0);

  final PopupChooserBuilder popupBuilder = JBPopupFactory.getInstance().createListPopupBuilder(myRegionsList);
    myPopup = popupBuilder
      .setTitle(IdeBundle.message("goto.custom.region.command"))
      .setResizable(false)
      .setMovable(false)
      .setItemChoosenCallback(new Runnable() {
        @Override
        public void run() {
          PsiElement navigationElement = getNavigationElement();
          if (navigationElement != null) {
            navigateTo(editor, navigationElement);
            IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
          }
        }
      }).createPopup();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:CustomFoldingRegionsPopup.java

示例3: 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

示例4: 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

示例5: 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

示例6: assertMerge

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
private void assertMerge(String[] initialItems,
                         int initialSelectionIdx,
                         int selectionIndexAfterMerge,
                         String... itemsToMerge) {

  final StringFinderRecursivePanel panel = createStringPanel(initialItems);
  disposeOnTearDown(panel);

  JBList list = panel.getList();
  CollectionListModel<String> model = panel.getListModel();

  list.setSelectedIndex(initialSelectionIdx);

  ListSelectionListener selectionListener = new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent e) {
      if (panel.isMergeListItemsRunning()) return;
      assertTrue("selection changed", false);
    }
  };
  list.addListSelectionListener(selectionListener);

  panel.merge(model, list, Arrays.asList(itemsToMerge));
  assertEquals(itemsToMerge.length, model.getSize());
  for (int i = 0; i < itemsToMerge.length; i++) {
    assertEquals("idx:" + i + " " + toString(model.getItems(), ","), itemsToMerge[i], model.getElementAt(i));
  }
  assertEquals(toString(model.getItems(), ","), selectionIndexAfterMerge, list.getSelectedIndex());

  list.removeListSelectionListener(selectionListener);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:32,代碼來源:FinderRecursivePanelListModelMergeTest.java

示例7: prepareProjectSettings

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void prepareProjectSettings(@NotNull SystemSettings s) {
  myProjectsModel = new DefaultListModel();
  myProjectsList = new JBList(myProjectsModel);
  myProjectsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

  addTitle(ExternalSystemBundle.message("settings.title.linked.projects", myExternalSystemId.getReadableName()));
  myComponent.add(new JBScrollPane(myProjectsList), ExternalSystemUiUtil.getFillLineConstraints(1));

  addTitle(ExternalSystemBundle.message("settings.title.project.settings"));
  List<ProjectSettings> settings = ContainerUtilRt.newArrayList(s.getLinkedProjectsSettings());
  myProjectsList.setVisibleRowCount(Math.max(3, Math.min(5, settings.size())));
  ContainerUtil.sort(settings, new Comparator<ProjectSettings>() {
    @Override
    public int compare(ProjectSettings s1, ProjectSettings s2) {
      return getProjectName(s1.getExternalProjectPath()).compareTo(getProjectName(s2.getExternalProjectPath()));
    }
  });

  myProjectSettingsControls.clear();
  for (ProjectSettings setting : settings) {
    ExternalSystemSettingsControl<ProjectSettings> control = createProjectSettingsControl(setting);
    control.fillUi(myComponent, 1);
    myProjectsModel.addElement(getProjectName(setting.getExternalProjectPath()));
    myProjectSettingsControls.add(control);
    if (control instanceof AbstractExternalProjectSettingsControl<?>) {
      ((AbstractExternalProjectSettingsControl)control).setCurrentProject(myProject);
    }
    control.showUi(false);
  }

  myProjectsList.addListSelectionListener(new ListSelectionListener() {
    @SuppressWarnings("unchecked")
    @Override
    public void valueChanged(ListSelectionEvent e) {
      if (e.getValueIsAdjusting()) {
        return;
      }
      int i = myProjectsList.getSelectedIndex();
      if (i < 0) {
        return;
      }
      if (myActiveProjectSettingsControl != null) {
        myActiveProjectSettingsControl.showUi(false);
      }
      myActiveProjectSettingsControl = myProjectSettingsControls.get(i);
      myActiveProjectSettingsControl.showUi(true);
    }
  });

  
  if (!myProjectsModel.isEmpty()) {
    myProjectsList.setSelectedIndex(0);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:56,代碼來源:AbstractExternalSystemConfigurable.java


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