Пример #1
0
  public LookupImpl(Project project, Editor editor, @NotNull LookupArranger arranger) {
    super(new JPanel(new BorderLayout()));
    setForceShowAsPopup(true);
    setCancelOnClickOutside(false);
    setResizable(true);
    AbstractPopup.suppressMacCornerFor(getComponent());

    myProject = project;
    myEditor = editor;
    myArranger = arranger;
    myPresentableArranger = arranger;

    myCellRenderer = new LookupCellRenderer(this);
    myList.setCellRenderer(myCellRenderer);

    myList.setFocusable(false);
    myList.setFixedCellWidth(50);

    myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    myList.setBackground(LookupCellRenderer.BACKGROUND_COLOR);

    myList.getExpandableItemsHandler();

    myAdComponent = new Advertiser();

    myOffsets = new LookupOffsets(editor);

    final CollectionListModel<LookupElement> model = getListModel();
    addEmptyItem(model);
    updateListHeight(model);

    addListeners();
  }
  @NotNull
  private static JPanel createFilesViewPanel(@NotNull List<VirtualFile> files) {
    JPanel panel = new JPanel(new BorderLayout(0, 2));
    panel.add(new JLabel("Files to add:"), BorderLayout.NORTH);

    final JBList fileList = new JBList(ArrayUtil.EMPTY_STRING_ARRAY);
    fileList.setBorder(BorderFactory.createLineBorder(Color.lightGray));
    fileList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent e) {
            fileList.clearSelection();
          }
        });
    fileList.setFocusable(false);
    fileList.setRequestFocusEnabled(false);
    fileList.setBackground(Gray._242);
    fileList.setCellRenderer(
        new ListCellRendererWrapper<VirtualFile>() {
          @Override
          public void customize(
              JList list, VirtualFile value, int index, boolean selected, boolean hasFocus) {
            setText(" " + value.getName());
          }
        });
    fileList.setListData(files.toArray());
    panel.add(fileList, BorderLayout.CENTER);
    return panel;
  }