Java Code Examples for com.intellij.ui.components.JBList#setModel()

The following examples show how to use com.intellij.ui.components.JBList#setModel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectListManager.java    From tmc-intellij with MIT License 6 votes vote down vote up
public void refreshCourse(String course) {
    logger.info("Refreshing course {}. @ProjectListManager", course);
    List<JBList> list = currentListElements.get(course);
    if (list == null) {
        return;
    }

    for (JBList jbList : list) {
        if (jbList == null || !jbList.getName().equals(course)) {
            continue;
        }
        DefaultListModel model = (DefaultListModel) jbList.getModel();
        model.removeAllElements();
        addExercisesToList(new ObjectFinder(), course, model, new CourseAndExerciseManager());
        jbList.setModel(model);
    }
    refreshAllCourses();
}
 
Example 2
Source File: ChatUserForm.java    From floobits-intellij with Apache License 2.0 6 votes vote down vote up
private void createUIComponents() {
    gravatarContainer = new ClickPanel(new Runnable() {
        @Override
        public void run() {
            FlooHandler flooHandler = context.getFlooHandler();
            if (flooHandler == null) {
                return;
            }
            flooHandler.editorEventHandler.goToLastHighlight(username);
        }
    });
    subContainer = new JPanel();
    clientModel = new DefaultListModel();
    clientList = new JBList();
    clientList.setOpaque(false);
    clientList.setModel(clientModel);
    clientList.setCellRenderer(new ClientCellRenderer());
    menuPopup = new JPopupMenu();
    subContainer.setComponentPopupMenu(menuPopup);
    clientList.setComponentPopupMenu(menuPopup);
    gravatarContainer.setComponentPopupMenu(menuPopup);
}
 
Example 3
Source File: CustomFoldingRegionsPopup.java    From consulo with Apache License 2.0 6 votes vote down vote up
CustomFoldingRegionsPopup(@Nonnull Collection<FoldingDescriptor> descriptors,
                          @Nonnull final Editor editor,
                          @Nonnull 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();
}
 
Example 4
Source File: CourseTabFactory.java    From tmc-intellij with MIT License 5 votes vote down vote up
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);
}
 
Example 5
Source File: ColumnFilteringStrategy.java    From consulo with Apache License 2.0 5 votes vote down vote up
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;
}