public VcsLogGraphTable( @NotNull VcsLogUiImpl UI, @NotNull final VcsLogDataHolder logDataHolder, @NotNull VisiblePack initialDataPack) { super(); myUI = UI; myLogDataHolder = logDataHolder; myGraphCommitCellRenderer = new GraphCommitCellRender(logDataHolder, myGraphCellPainter, this); setDefaultRenderer(VirtualFile.class, new RootCellRenderer(myUI)); setDefaultRenderer(GraphCommitCell.class, myGraphCommitCellRenderer); setDefaultRenderer(String.class, new StringCellRenderer()); setShowHorizontalLines(false); setIntercellSpacing(JBUI.emptySize()); MouseAdapter mouseAdapter = new MyMouseAdapter(); addMouseMotionListener(mouseAdapter); addMouseListener(mouseAdapter); MyHeaderMouseAdapter headerAdapter = new MyHeaderMouseAdapter(); getTableHeader().addMouseListener(headerAdapter); getTableHeader().addMouseMotionListener(headerAdapter); getTableHeader().setReorderingAllowed(false); PopupHandler.installPopupHandler( this, VcsLogActionPlaces.POPUP_ACTION_GROUP, VcsLogActionPlaces.VCS_LOG_TABLE_PLACE); ScrollingUtil.installActions(this, false); GraphTableModel model = new GraphTableModel(initialDataPack, myLogDataHolder, myUI); setModel(model); initColumnSize(); }
@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; }