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


Java JBList.setSelectionMode方法代碼示例

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


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

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

示例2: GroupList

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
public GroupList(PsiClass[] classes)
{
    super(new BorderLayout());
    SortedListModel<String> model = new SortedListModel<String>(new Comparator<String>()
    {
        public int compare(String s1, String s2) {
            return s1.compareTo(s2);
        }
    });
    list = new JBList(model);
    Set<String> groups = TestNGUtil.getAnnotationValues("groups", classes);
  String[] array = ArrayUtil.toStringArray(groups);
    Arrays.sort(array);
    model.addAll(array);
    add(ScrollPaneFactory.createScrollPane(list));
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    ScrollingUtil.ensureSelectionExists(list);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:GroupList.java

示例3: createCourseSpecificTab

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
public void createCourseSpecificTab(
        ObjectFinder finder,
        ProjectOpener opener,
        String course,
        JTabbedPane tabbedPaneBase,
        CourseAndExerciseManager courseAndExerciseManager) {
    logger.info("Creating course specific tab. @CourseTabFactory");
    final JBScrollPane panel = new JBScrollPane();
    final JBList list = new JBList();
    list.setCellRenderer(new ProjectListRenderer());

    DefaultListModel defaultListModel = new DefaultListModel();
    panel.setBorder(BorderFactory.createTitledBorder(""));

    ProjectListManagerHolder.get()
            .addExercisesToList(finder, course, defaultListModel, courseAndExerciseManager);

    if (defaultListModel.getSize() <= 0) {
        return;
    }

    list.setName(course);
    list.setModel(defaultListModel);

    MouseListener mouseListener = createMouseListenerForWindow(opener, panel, list);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.addMouseListener(mouseListener);

    panel.setName(course);
    panel.setViewportView(list);

    ProjectListManagerHolder.get().addList(list);
    tabbedPaneBase.addTab(course, panel);
    tabbedPaneBase.addMouseListener(tabMouseListener(tabbedPaneBase));
    setScrollBarToBottom(course, tabbedPaneBase, panel);
}
 
開發者ID:testmycode,項目名稱:tmc-intellij,代碼行數:37,代碼來源:CourseTabFactory.java

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

示例5: ActionMacroConfigurationPanel

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
public ActionMacroConfigurationPanel() {
  myMacrosList = new JBList();
  myMacroActionsList = new JBList();
  myMacrosList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myMacroActionsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

  myMacrosList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      final int selIndex = myMacrosList.getSelectedIndex();
      if (selIndex == -1) {
        ((DefaultListModel)myMacroActionsList.getModel()).removeAllElements();
      }
      else {
        initActionList((ActionMacro)myMacrosModel.getElementAt(selIndex));
      }
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:ActionMacroConfigurationPanel.java

示例6: createCenterPanel

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

示例7: createCenterPanel

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
@Nullable
@Override
protected JComponent createCenterPanel() {
  final JBList list = new JBList();
  list.setModel(getListModel(myFiles));
  list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  list.addListSelectionListener(new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent e) {
      myChosenFile = (FileListItem)list.getSelectedValue();
    }
  });
  return ListWithFilter.wrap(list);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:15,代碼來源:ChooseFromFileListDialog.java

示例8: applyFix

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
  final PsiDirectory[] dirs = getDirectories();
  final List<VirtualFile> virtualFiles = getPotentialRoots(myModule, dirs);
  final VirtualFile[] roots = prepare(VfsUtilCore.toVirtualFileArray(virtualFiles));
  if (roots.length == 1) {
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      public void run() {
        createDescription(roots[0]);
      }
    });
  }
  else {
    List<String> options = new ArrayList<String>();
    for (VirtualFile file : roots) {
      String path = getPath(file);
      options.add(path);
    }
    final JBList files = new JBList(ArrayUtil.toStringArray(options));
    files.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    final JBPopup popup = JBPopupFactory.getInstance()
      .createListPopupBuilder(files)
      .setTitle(DevKitBundle.message("select.target.location.of.description", myFilename))
      .setItemChoosenCallback(new Runnable() {
        public void run() {
          final int index = files.getSelectedIndex();
          if (0 <= index && index < roots.length) {
            ApplicationManager.getApplication().runWriteAction(new Runnable() {
              public void run() {
                createDescription(roots[index]);
              }
            });
          }
        }
      }).createPopup();
    final Editor editor = FileEditorManager.getInstance(myModule.getProject()).getSelectedTextEditor();
    if (editor == null) return;
    popup.showInBestPositionFor(editor);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:40,代碼來源:CreateHtmlDescriptionFix.java

示例9: chooseSubclass

import com.intellij.ui.components.JBList; //導入方法依賴的package包/類
static void chooseSubclass(
    ConfigurationContext context,
    PsiClass testClass,
    Consumer<PsiClass> callbackOnClassSelection) {
  List<PsiClass> classes = findTestSubclasses(testClass);
  if (!testClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
    classes.add(testClass);
  }
  if (classes.isEmpty()) {
    return;
  }
  if (classes.size() == 1) {
    callbackOnClassSelection.accept(classes.get(0));
    return;
  }
  PsiClassListCellRenderer renderer = new PsiClassListCellRenderer();
  classes.sort(renderer.getComparator());
  // #api171 add generics to JBList.
  JBList list = new JBList(classes);
  list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  list.setCellRenderer(renderer);
  JBPopupFactory.getInstance()
      .createListPopupBuilder(list)
      .setTitle("Choose test class to run")
      .setMovable(false)
      .setResizable(false)
      .setRequestFocus(true)
      .setCancelOnWindowDeactivation(false)
      .setItemChoosenCallback(
          () -> callbackOnClassSelection.accept((PsiClass) list.getSelectedValue()))
      .createPopup()
      .showInBestPositionFor(context.getDataContext());
}
 
開發者ID:bazelbuild,項目名稱:intellij,代碼行數:34,代碼來源:SubclassTestChooser.java

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

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

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

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


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