private void rebuildListContent() {
   ArrayList<Item> items = new ArrayList<Item>();
   int i = 0;
   List<Data> contents = new ArrayList<Data>(getContents());
   for (Data content : contents) {
     String fullString = getStringRepresentationFor(content);
     if (fullString != null) {
       String shortString;
       fullString = StringUtil.convertLineSeparators(fullString);
       int newLineIdx = fullString.indexOf('\n');
       if (newLineIdx == -1) {
         shortString = fullString.trim();
       } else {
         int lastLooked = 0;
         do {
           int nextLineIdx = fullString.indexOf("\n", lastLooked);
           if (nextLineIdx > lastLooked) {
             shortString = fullString.substring(lastLooked, nextLineIdx).trim() + " ...";
             break;
           } else if (nextLineIdx == -1) {
             shortString = " ...";
             break;
           }
           lastLooked = nextLineIdx + 1;
         } while (true);
       }
       items.add(new Item(i++, shortString, fullString));
     }
   }
   myAllContents = contents;
   FilteringListModel listModel = (FilteringListModel) myList.getModel();
   ((CollectionListModel) listModel.getOriginalModel()).removeAll();
   listModel.addAll(items);
   ListWithFilter listWithFilter = UIUtil.getParentOfType(ListWithFilter.class, myList);
   if (listWithFilter != null) {
     listWithFilter.getSpeedSearch().update();
     if (listModel.getSize() == 0) listWithFilter.resetFilter();
   }
 }
  public RecentProjectPanel() {
    super(new BorderLayout());

    final AnAction[] recentProjectActions =
        RecentProjectsManagerBase.getInstance().getRecentProjectsActions(false);
    myList = new MyList(recentProjectActions);
    myList.setCellRenderer(new RecentProjectItemRenderer());

    new ClickListener() {
      @Override
      public boolean onClick(MouseEvent event, int clickCount) {
        int selectedIndex = myList.getSelectedIndex();
        if (selectedIndex >= 0) {
          if (myList.getCellBounds(selectedIndex, selectedIndex).contains(event.getPoint())) {
            Object selection = myList.getSelectedValue();

            if (selection != null) {
              ((AnAction) selection)
                  .actionPerformed(
                      AnActionEvent.createFromInputEvent(
                          (AnAction) selection, event, ActionPlaces.WELCOME_SCREEN));
            }
          }
        }

        return true;
      }
    }.installOn(myList);

    myList.registerKeyboardAction(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Object selection = myList.getSelectedValue();

            if (selection != null) {
              ((AnAction) selection)
                  .actionPerformed(
                      AnActionEvent.createFromInputEvent(
                          (AnAction) selection, null, ActionPlaces.WELCOME_SCREEN));
            }
          }
        },
        KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
        WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    ActionListener deleteAction =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            ReopenProjectAction selection = (ReopenProjectAction) myList.getSelectedValue();

            final int rc =
                Messages.showOkCancelDialog(
                    RecentProjectPanel.this,
                    "Remove '"
                        + selection.getTemplatePresentation().getText()
                        + "' from recent projects list?",
                    "Remove Recent Project",
                    Messages.getQuestionIcon());
            if (rc == 0) {
              final RecentProjectsManagerBase manager = RecentProjectsManagerBase.getInstance();

              manager.removePath(selection.getProjectPath());
              ListUtil.removeSelectedItems(myList);
            }
          }
        };

    myList.registerKeyboardAction(
        deleteAction,
        KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
        WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    myList.registerKeyboardAction(
        deleteAction,
        KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0),
        WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    myList.addMouseMotionListener(
        new MouseMotionAdapter() {
          boolean myIsEngaged = false;

          public void mouseMoved(MouseEvent e) {
            if (myIsEngaged && !UIUtil.isSelectionButtonDown(e)) {
              Point point = e.getPoint();
              int index = myList.locationToIndex(point);
              myList.setSelectedIndex(index);

              final Rectangle bounds = myList.getCellBounds(index, index);
              if (bounds != null && bounds.contains(point)) {
                myList.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
              } else {
                myList.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
              }
            } else {
              myIsEngaged = true;
            }
          }
        });

    myList.setSelectedIndex(0);

    JBScrollPane scroll = new JBScrollPane(myList);
    scroll.setBorder(null);

    JComponent list =
        recentProjectActions.length == 0
            ? myList
            : ListWithFilter.wrap(
                myList,
                scroll,
                new Function<Object, String>() {
                  @Override
                  public String fun(Object o) {
                    ReopenProjectAction item = (ReopenProjectAction) o;
                    String home = SystemProperties.getUserHome();
                    String path = item.getProjectPath();
                    if (FileUtil.startsWith(path, home)) {
                      path = path.substring(home.length());
                    }
                    return item.getProjectName() + " " + path;
                  }
                });
    add(list, BorderLayout.CENTER);

    JPanel title =
        new JPanel() {
          @Override
          public Dimension getPreferredSize() {
            return new Dimension(super.getPreferredSize().width, 28);
          }
        };
    title.setBorder(new BottomLineBorder());

    JLabel titleLabel = new JLabel("Recent Projects");
    title.add(titleLabel);
    titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
    titleLabel.setForeground(WelcomeScreenColors.CAPTION_FOREGROUND);
    title.setBackground(WelcomeScreenColors.CAPTION_BACKGROUND);

    add(title, BorderLayout.NORTH);

    setBorder(new LineBorder(WelcomeScreenColors.BORDER_COLOR));
  }
  @Override
  protected JComponent createCenterPanel() {
    final int selectionMode =
        myAllowMultipleSelections
            ? ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
            : ListSelectionModel.SINGLE_SELECTION;
    myList.setSelectionMode(selectionMode);
    if (myUseIdeaEditor) {
      EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
      myList.setFont(scheme.getFont(EditorFontType.PLAIN));
      Color fg =
          ObjectUtils.chooseNotNull(scheme.getDefaultForeground(), UIUtil.getListForeground());
      Color bg =
          ObjectUtils.chooseNotNull(scheme.getDefaultBackground(), UIUtil.getListBackground());
      myList.setForeground(fg);
      myList.setBackground(bg);
    }

    new DoubleClickListener() {
      @Override
      protected boolean onDoubleClick(MouseEvent e) {
        close(OK_EXIT_CODE);
        return true;
      }
    }.installOn(myList);

    myList.setCellRenderer(new MyListCellRenderer());
    myList.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
              int newSelectionIndex = -1;
              for (Object o : myList.getSelectedValues()) {
                int i = ((Item) o).index;
                removeContentAt(myAllContents.get(i));
                if (newSelectionIndex < 0) {
                  newSelectionIndex = i;
                }
              }

              rebuildListContent();
              if (myAllContents.isEmpty()) {
                close(CANCEL_EXIT_CODE);
                return;
              }
              newSelectionIndex = Math.min(newSelectionIndex, myAllContents.size() - 1);
              myList.setSelectedIndex(newSelectionIndex);
            } else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
              doOKAction();
            } else {
              final char aChar = e.getKeyChar();
              if (aChar >= '0' && aChar <= '9') {
                int idx = aChar == '0' ? 9 : aChar - '1';
                if (idx < myAllContents.size()) {
                  myList.setSelectedIndex(idx);
                  e.consume();
                  doOKAction();
                }
              }
            }
          }
        });

    mySplitter.setFirstComponent(
        ListWithFilter.wrap(
            myList,
            ScrollPaneFactory.createScrollPane(myList),
            new Function<Object, String>() {
              @Override
              public String fun(Object o) {
                return ((Item) o).longText;
              }
            }));
    mySplitter.setSecondComponent(new JPanel());
    rebuildListContent();

    ScrollingUtil.installActions(myList);
    ScrollingUtil.ensureSelectionExists(myList);
    updateViewerForSelection();
    myList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent e) {
            myUpdateAlarm.cancelAllRequests();
            myUpdateAlarm.addRequest(
                new Runnable() {
                  @Override
                  public void run() {
                    updateViewerForSelection();
                  }
                },
                100);
          }
        });

    mySplitter.setPreferredSize(JBUI.size(500, 500));

    SplitterProportionsData d = new SplitterProportionsDataImpl();
    d.externalizeToDimensionService(getClass().getName());
    d.restoreSplitterProportions(mySplitter);

    return mySplitter;
  }