private void refreshPostponedRoots() { for (VirtualFile root : safeGetAndClear(myRootsToRefresh)) { myDataHolder.refresh(root); // TODO support batch root refresh } for (VirtualFile root : safeGetAndClear(myRootsToRefreshRefs)) { myDataHolder.refreshRefs(root); // TODO support batch root refresh } }
DetailsPanel( @NotNull VcsLogDataHolder logDataHolder, @NotNull VcsLogGraphTable graphTable, @NotNull VcsLogColorManager colorManager, @NotNull VisiblePack initialDataPack) { myLogDataHolder = logDataHolder; myGraphTable = graphTable; myColorManager = colorManager; myDataPack = initialDataPack; myReferencesPanel = new ReferencesPanel(myColorManager); myCommitDetailsPanel = new DataPanel(logDataHolder.getProject(), logDataHolder.isMultiRoot(), logDataHolder); myScrollPane = new JBScrollPane( ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); myMainContentPanel = new JPanel(new MigLayout("flowy, ins 0, hidemode 3, gapy 0")) { @Override public Dimension getPreferredSize() { Dimension size = super.getPreferredSize(); size.width = myScrollPane.getViewport().getWidth() - 5; return size; } }; myMainContentPanel.setOpaque(false); myScrollPane.setOpaque(false); myScrollPane.getViewport().setOpaque(false); myScrollPane.setViewportView(myMainContentPanel); myMainContentPanel.add(myReferencesPanel, ""); myMainContentPanel.add(myCommitDetailsPanel, ""); myLoadingPanel = new JBLoadingPanel( new BorderLayout(), logDataHolder, ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS) { @Override public Color getBackground() { return getDetailsBackground(); } }; myLoadingPanel.add(myScrollPane); myMessagePanel = new MessagePanel(); setLayout(new CardLayout()); add(myLoadingPanel, STANDARD_LAYER); add(myMessagePanel, MESSAGE_LAYER); showMessage("No commits selected"); }
@Override public void valueChanged(@Nullable ListSelectionEvent notUsed) { if (notUsed != null && notUsed.getValueIsAdjusting()) return; VcsFullCommitDetails newCommitDetails = null; int[] rows = myGraphTable.getSelectedRows(); if (rows.length < 1) { showMessage("No commits selected"); } else if (rows.length > 1) { showMessage("Several commits selected"); } else { ((CardLayout) getLayout()).show(this, STANDARD_LAYER); int row = rows[0]; GraphTableModel tableModel = (GraphTableModel) myGraphTable.getModel(); VcsFullCommitDetails commitData = myLogDataHolder.getCommitDetailsGetter().getCommitData(row, tableModel); if (commitData == null) { showMessage("No commits selected"); return; } if (commitData instanceof LoadingDetails) { myLoadingPanel.startLoading(); myCommitDetailsPanel.setData(null); myReferencesPanel.setReferences(Collections.<VcsRef>emptyList()); updateDetailsBorder(null); } else { myLoadingPanel.stopLoading(); myCommitDetailsPanel.setData(commitData); myReferencesPanel.setReferences(sortRefs(commitData.getId(), commitData.getRoot())); updateDetailsBorder(commitData); newCommitDetails = commitData; } List<String> branches = null; if (!(commitData instanceof LoadingDetails)) { branches = myLogDataHolder .getContainingBranchesGetter() .requestContainingBranches(commitData.getRoot(), commitData.getId()); } myCommitDetailsPanel.setBranches(branches); if (!Comparing.equal(myCurrentCommitDetails, newCommitDetails)) { myCurrentCommitDetails = newCommitDetails; myScrollPane.getVerticalScrollBar().setValue(0); } } }
@NotNull private List<VcsRef> sortRefs(@NotNull Hash hash, @NotNull VirtualFile root) { Collection<VcsRef> refs = myDataPack.getRefsModel().refsToCommit(hash, root); return ContainerUtil.sorted( refs, myLogDataHolder.getLogProvider(root).getReferenceManager().getLabelsOrderComparator()); }
private int calculateMaxRootWidth() { int width = 0; for (VirtualFile file : myLogDataHolder.getRoots()) { Font tableFont = UIManager.getFont("Table.font"); width = Math.max(getFontMetrics(tableFont).stringWidth(file.getName() + " "), width); } return width; }
@Nullable private TableColumn getRootColumnOrNull(@NotNull MouseEvent e) { if (!myLogDataHolder.isMultiRoot()) return null; int column = convertColumnIndexToModel(columnAtPoint(e.getPoint())); if (column == GraphTableModel.ROOT_COLUMN) { return getColumnModel().getColumn(column); } return null; }
@Override public void refreshRefs(@NotNull VirtualFile root) { if (isOurContentPaneShowing()) { myDataHolder.refreshRefs(root); } else { synchronized (REFRESH_LOCK) { myRootsToRefreshRefs.add(root); } } }
public VcsLogGraphTable( @NotNull VcsLogUiImpl UI, @NotNull final VcsLogDataHolder logDataHolder, @NotNull DataPack initialDataPack) { super(); myUI = UI; myLogDataHolder = logDataHolder; myDataPack = initialDataPack; myGraphCommitCellRender = new GraphCommitCellRender( myUI.getColorManager(), logDataHolder, myDataPack.getGraphFacade(), this); setDefaultRenderer( VirtualFile.class, new RootCellRenderer(myUI, myLogDataHolder.isMultiRoot())); setDefaultRenderer(GraphCommitCell.class, myGraphCommitCellRender); setDefaultRenderer(String.class, new StringCellRenderer()); setRowHeight(HEIGHT_CELL); setShowHorizontalLines(false); setIntercellSpacing(new Dimension(0, 0)); getSelectionModel() .addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int selectedRow = getSelectedRow(); if (selectedRow >= 0) { myUI.click(selectedRow); } } }); MouseAdapter mouseAdapter = new MyMouseAdapter(); addMouseMotionListener(mouseAdapter); addMouseListener(mouseAdapter); PopupHandler.installPopupHandler( this, VcsLogUiImpl.POPUP_ACTION_GROUP, VcsLogUiImpl.VCS_LOG_TABLE_PLACE); TableScrollingUtil.installActions(this, false); }
@NotNull public JComponent initContent() { final Map<VirtualFile, VcsLogProvider> logProviders = findLogProviders(); final VcsLogContainer mainPanel = new VcsLogContainer(myProject); myLogDataHolder = new VcsLogDataHolder(myProject, this, logProviders, mySettings); myLogDataHolder.initialize( new PairConsumer<VcsLogDataHolder, DataPack>() { @Override public void consume(VcsLogDataHolder vcsLogDataHolder, DataPack dataPack) { VcsLogUiImpl logUI = new VcsLogUiImpl( vcsLogDataHolder, myProject, mySettings, new VcsLogColorManagerImpl(logProviders.keySet()), myUiProperties, dataPack); myLogDataHolder = vcsLogDataHolder; myUi = logUI; mainPanel.init(logUI.getMainFrame().getMainComponent()); final VcsLogGraphTable graphTable = logUI.getTable(); if (graphTable.getRowCount() > 0) { IdeFocusManager.getInstance(myProject) .requestFocus(graphTable, true) .doWhenProcessed( new Runnable() { @Override public void run() { graphTable.setRowSelectionInterval(0, 0); } }); } myLogRefresher = new PostponeableLogRefresher(myProject, vcsLogDataHolder); refreshLogOnVcsEvents(logProviders); } }); return mainPanel; }
public VcsLogClassicFilterUi( @NotNull VcsLogUiImpl ui, @NotNull VcsLogDataHolder logDataHolder, @NotNull VcsLogUiProperties uiProperties, @NotNull DataPack initialDataPack) { myUi = ui; myTextFilter = new SearchTextFieldWithStoredHistory("Vcs.Log.Text.Filter.History") { @Override protected void onFieldCleared() { applyFilters(); } }; myTextFilter .getTextEditor() .addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { applyFilters(); myTextFilter.addCurrentTextToHistory(); } }); myBranchFilterComponent = new BranchFilterPopupComponent(this, initialDataPack, uiProperties); myUserFilterComponent = new UserFilterPopupComponent(this, logDataHolder, uiProperties); myDateFilterComponent = new DateFilterPopupComponent(this); myStructureFilterComponent = new StructureFilterPopupComponent(this, logDataHolder.getRoots()); myActionGroup = new DefaultActionGroup(); myActionGroup.add(new TextFilterComponent(myTextFilter)); myActionGroup.add(new FilterActionComponent(myBranchFilterComponent)); myActionGroup.add(new FilterActionComponent(myUserFilterComponent)); myActionGroup.add(new FilterActionComponent(myDateFilterComponent)); myActionGroup.add(new FilterActionComponent(myStructureFilterComponent)); }
private int getXOffset() { TableColumn rootColumn = getColumnModel().getColumn(AbstractVcsLogTableModel.ROOT_COLUMN); return myLogDataHolder.isMultiRoot() ? rootColumn.getWidth() : 0; }
public VcsLogGraphTable(@NotNull VcsLogUI UI, final VcsLogDataHolder logDataHolder) { super(); myUI = UI; myGraphPainter = new SimpleGraphCellPainter(logDataHolder.isMultiRoot()); setDefaultRenderer(VirtualFile.class, new RootCellRenderer(myUI)); setDefaultRenderer( GraphCommitCell.class, new GraphCommitCellRender(myGraphPainter, logDataHolder, myUI.getColorManager())); setDefaultRenderer( CommitCell.class, new CommitCellRender(myUI.getColorManager(), logDataHolder.getProject())); setDefaultRenderer(String.class, new StringCellRenderer()); setRowHeight(HEIGHT_CELL); setShowHorizontalLines(false); setIntercellSpacing(new Dimension(0, 0)); getSelectionModel() .addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int selectedRow = getSelectedRow(); if (selectedRow >= 0) { myUI.click(selectedRow); } } }); MouseAdapter mouseAdapter = new MyMouseAdapter(); addMouseMotionListener(mouseAdapter); addMouseListener(mouseAdapter); PopupHandler.installPopupHandler( this, VcsLogUI.POPUP_ACTION_GROUP, VcsLogUI.VCS_LOG_TABLE_PLACE); getColumnModel() .addColumnModelListener( new TableColumnModelListener() { @Override public void columnAdded(TableColumnModelEvent e) { if (e.getToIndex() == AbstractVcsLogTableModel.ROOT_COLUMN) { myGraphPainter.setRootColumn( getColumnModel().getColumn(AbstractVcsLogTableModel.ROOT_COLUMN)); } } @Override public void columnRemoved(TableColumnModelEvent e) {} @Override public void columnMoved(TableColumnModelEvent e) {} @Override public void columnMarginChanged(ChangeEvent e) {} @Override public void columnSelectionChanged(ListSelectionEvent e) {} }); }