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


Java JBList.getSelectedIndex方法代碼示例

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


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

示例1: putInfo

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
@Override
public void putInfo(@NotNull Map<String, String> info) {
  StringBuilder result = new StringBuilder();
  for (int i = 0; i < myList.size(); i++) {
    NavBarItem each = myList.get(i);
    if (each.isSelected()) {
      result.append("[" + each.getText() + "]");
    } else {
      result.append(each.getText());
    }
    if (i < myList.size() - 1) {
      result.append(">");
    }
  }
  info.put("navBar", result.toString());
  
  if (isNodePopupShowing()) {
    StringBuilder popupText = new StringBuilder();
    JBList list = myNodePopup.getList();
    for (int i = 0; i < list.getModel().getSize(); i++) {
      Object eachElement = list.getModel().getElementAt(i);
      String text = new NavBarItem(this, eachElement, myNodePopup).getText();
      int selectedIndex = list.getSelectedIndex();
      if (selectedIndex != -1 && eachElement.equals(list.getSelectedValue())) {
        popupText.append("[" + text + "]");
      } else {
        popupText.append(text);
      }
      if (i < list.getModel().getSize() - 1) {
        popupText.append(">");
      }
    }
    info.put("navBarPopup", popupText.toString());
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:36,代碼來源:NavBarPanel.java

示例2: invoke

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
public void invoke() {
  PsiDocumentManager.getInstance(myProject).commitAllDocuments();

  final PsiElement[][] result = new PsiElement[1][];
  ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
    @Override
    public void run() {
      ApplicationManager.getApplication().runReadAction(new Runnable() {
        @Override
        public void run() {
          final PsiClass psiClass = myMethod.getContainingClass();
          if (!psiClass.isValid()) return;
          if (!psiClass.isEnum()) {
            result[0] = getClassImplementations(psiClass);
          }
          else {
            final List<PsiElement> enumConstants = new ArrayList<PsiElement>();
            for (PsiField field : psiClass.getFields()) {
              if (field instanceof PsiEnumConstant) {
                final PsiEnumConstantInitializer initializingClass = ((PsiEnumConstant)field).getInitializingClass();
                if (initializingClass != null) {
                  PsiMethod method = initializingClass.findMethodBySignature(myMethod, true);
                  if (method == null || !method.getContainingClass().equals(initializingClass)) {
                    enumConstants.add(initializingClass);
                  }
                }
                else {
                  enumConstants.add(field);
                }
              }
            }
            result[0] = PsiUtilCore.toPsiElementArray(enumConstants);
          }
        }
      });
    }
  }, CodeInsightBundle.message("intention.implement.abstract.method.searching.for.descendants.progress"), true, myProject);

  if (result[0] == null) return;

  if (result[0].length == 0) {
    Messages.showMessageDialog(myProject,
                               CodeInsightBundle.message("intention.implement.abstract.method.error.no.classes.message"),
                               CodeInsightBundle.message("intention.implement.abstract.method.error.no.classes.title"),
                               Messages.getInformationIcon());
    return;
  }

  if (result[0].length == 1) {
    implementInClass(new Object[] {result[0][0]});
    return;
  }

  final MyPsiElementListCellRenderer elementListCellRenderer = new MyPsiElementListCellRenderer();
  elementListCellRenderer.sort(result[0]);
  myList = new JBList(result[0]);
  myList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
  final Runnable runnable = new Runnable(){
    @Override
    public void run() {
      int index = myList.getSelectedIndex();
      if (index < 0) return;
      implementInClass(myList.getSelectedValues());
    }
  };
  myList.setCellRenderer(elementListCellRenderer);
  final PopupChooserBuilder builder = new PopupChooserBuilder(myList);
  elementListCellRenderer.installSpeedSearch(builder);

  builder.
    setTitle(CodeInsightBundle.message("intention.implement.abstract.method.class.chooser.title")).
    setItemChoosenCallback(runnable).
    createPopup().
    showInBestPositionFor(myEditor);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:76,代碼來源:ImplementAbstractMethodHandler.java

示例3: run

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
@Override
public void run() {
  if (myClasses.length == 1) {
    //TODO: cdr this place should produce at least warning
    // selected(myClasses[0]);
    selected((T[])ArrayUtil.toObjectArray(myClasses[0].getClass(), myClasses[0]));
  }
  else if (myClasses.length > 0) {
    PsiElementListCellRenderer<T> renderer = createRenderer();

    Arrays.sort(myClasses, renderer.getComparator());

    if (ApplicationManager.getApplication().isUnitTestMode()) {
      selected(myClasses);
      return;
    }
    Vector<Object> model = new Vector<Object>(Arrays.asList(myClasses));
    model.insertElementAt(CodeInsightBundle.message("highlight.thrown.exceptions.chooser.all.entry"), 0);

    myList = new JBList(model);
    myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    myList.setCellRenderer(renderer);

    final PopupChooserBuilder builder = new PopupChooserBuilder(myList);
    renderer.installSpeedSearch(builder);

    final Runnable callback = new Runnable() {
      @Override
      public void run() {
        int idx = myList.getSelectedIndex();
        if (idx < 0) return;
        if (idx > 0) {
          selected((T[])ArrayUtil.toObjectArray(myClasses[idx-1].getClass(), myClasses[idx-1]));
        }
        else {
          selected(myClasses);
        }
      }
    };

    ApplicationManager.getApplication().invokeLater(new Runnable() {
      @Override
      public void run() {
        builder.
          setTitle(myTitle).
          setItemChoosenCallback(callback).
          createPopup().
          showInBestPositionFor(myEditor);
      }
    });
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:53,代碼來源:ChooseOneOrAllRunnable.java


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