use of com.oxygenxml.git.view.history.HistoryTableAffectedFilesModel in project oxygen-git-client-addon by oxygenxml.
the class UIUtil method createResourcesTable.
/**
* Creates a git resource table widget and install renderers on it.
*
* @param fileTableModel The model for the table.
* @param contextMenuShowing Can tell if a contextual menu is showing over the table.
*
* @return The table that presents the resources.
*/
public static JTable createResourcesTable(AbstractTableModel fileTableModel, BooleanSupplier contextMenuShowing) {
JTable table = new Table() {
@Override
public JToolTip createToolTip() {
return UIUtil.createMultilineTooltip(this).orElseGet(super::createToolTip);
}
};
table.setModel(fileTableModel);
table.getColumnModel().setColumnMargin(0);
table.setTableHeader(null);
table.setShowGrid(false);
Icon icon = Icons.getIcon(Icons.GIT_ADD_ICON);
int iconWidth = icon.getIconWidth();
int colWidth = iconWidth + RESOURCE_TABLE_ICON_COLUMN_EXTRA_WIDTH;
TableColumn statusCol = table.getColumnModel().getColumn(StagingResourcesTableModel.FILE_STATUS_COLUMN);
statusCol.setMinWidth(colWidth);
statusCol.setPreferredWidth(colWidth);
statusCol.setMaxWidth(colWidth);
boolean isForHistoryTable = fileTableModel instanceof HistoryTableAffectedFilesModel;
table.setDefaultRenderer(Object.class, isForHistoryTable ? new HistoryAffectedFileCellRender(contextMenuShowing) : new StagingResourcesTableCellRenderer(contextMenuShowing));
return table;
}
use of com.oxygenxml.git.view.history.HistoryTableAffectedFilesModel in project oxygen-git-client-addon by oxygenxml.
the class HistoryPanelTestBase method assertAffectedFiles.
/**
* Asserts the presented affected files.
*
* @param historyPanel History table.
* @param expected The expected content.
*/
protected void assertAffectedFiles(HistoryPanel historyPanel, String expected) {
JTable affectedFilesTable = historyPanel.getAffectedFilesTable();
HistoryTableAffectedFilesModel affectedFilesModel = (HistoryTableAffectedFilesModel) affectedFilesTable.getModel();
String dumpFS = dumpFS(affectedFilesModel.getFilesStatuses());
assertEquals(expected, dumpFS);
}
use of com.oxygenxml.git.view.history.HistoryTableAffectedFilesModel in project oxygen-git-client-addon by oxygenxml.
the class HistoryPanel2Test method testAffectedFiles_ShowCopyRenames.
/**
* Tests the affected files presented when a revision is selected inside the history panel.
*
* @throws Exception If it fails.
*/
@Test
public void testAffectedFiles_ShowCopyRenames() throws Exception {
generateRepositoryAndLoad(getClass().getClassLoader().getResource("scripts/history_script_follow_move.txt"), new File("target/gen/HistoryPanelTest/testAffectedFiles_ShowCopyRenames"));
List<CommitCharacteristics> commitsCharacteristics = GitAccess.getInstance().getCommitsCharacteristics(HistoryStrategy.CURRENT_BRANCH, null, null);
String dump = dumpHistory(commitsCharacteristics, true);
String expected = "[ Move , {date} , Alex <alex_jitianu@sync.ro> , 1 , AlexJitianu , [2] ]\n" + "[ Initial , {date} , Alex <alex_jitianu@sync.ro> , 2 , AlexJitianu , null ]\n" + "";
assertEquals(expected, dump);
historyPanel.showRepositoryHistory();
waitForScheduler();
flushAWT();
sleep(500);
JTable historyTable = historyPanel.getHistoryTable();
HistoryCommitTableModel model = (HistoryCommitTableModel) historyTable.getModel();
dump = dumpHistory(model.getAllCommits(), true);
assertEquals(expected, dump);
// -----------
// Select an entry in the revision table.
// -----------
expected = "[ Move , {date} , Alex <alex_jitianu@sync.ro> , 1 , AlexJitianu , [2] ]";
expected = replaceDate(expected);
selectAndAssertRevision(historyTable, historyPanel.getAffectedFilesTable(), 0, expected);
// -----------
// Assert the affected files
// -----------
assertAffectedFiles(historyPanel, "(changeType=RENAME, fileLocation=child/file.txt)\n");
// ---------------
// Invoke the Diff action to see if the built URLs are O.K.
// ---------------
HistoryTableAffectedFilesModel affectedFilesModel = (HistoryTableAffectedFilesModel) historyPanel.getAffectedFilesTable().getModel();
FileStatus fileStatus = affectedFilesModel.getFilesStatuses().get(0);
CommitCharacteristics cc = model.getAllCommits().get(0);
Action action = getCompareWithPreviousAction(fileStatus, cc);
action.actionPerformed(null);
assertEquals("Unexpected number of URLs intercepted in the comparison support:" + urls2compare.toString(), 2, urls2compare.size());
URL left = urls2compare.get(0);
URL right = urls2compare.get(1);
assertEquals("git://" + model.getAllCommits().get(0).getCommitId() + "/child/file.txt", left.toString());
assertEquals("git://" + model.getAllCommits().get(1).getCommitId() + "/file.txt", right.toString());
}
use of com.oxygenxml.git.view.history.HistoryTableAffectedFilesModel in project oxygen-git-client-addon by oxygenxml.
the class HistoryPanel2Test method testAffectedFiles_ShowRenames.
/**
* Tests the affected files presented when a revision is selected inside the history panel.
*
* @throws Exception If it fails.
*/
@Test
public void testAffectedFiles_ShowRenames() throws Exception {
generateRepositoryAndLoad(getClass().getClassLoader().getResource("scripts/history_script_rename.txt"), new File("target/gen/HistoryPanelTest/testAffectedFiles_ShowRenames"));
List<CommitCharacteristics> commitsCharacteristics = GitAccess.getInstance().getCommitsCharacteristics(HistoryStrategy.CURRENT_BRANCH, null, null);
String dump = dumpHistory(commitsCharacteristics, true);
String expected = "[ Rename. , {date} , Alex <alex_jitianu@sync.ro> , 1 , AlexJitianu , [2] ]\n" + "[ First commit. , {date} , Alex <alex_jitianu@sync.ro> , 2 , AlexJitianu , null ]\n" + "";
assertEquals(expected, dump);
historyPanel.showRepositoryHistory();
waitForScheduler();
flushAWT();
sleep(300);
JTable historyTable = historyPanel.getHistoryTable();
HistoryCommitTableModel model = (HistoryCommitTableModel) historyTable.getModel();
dump = dumpHistory(model.getAllCommits(), true);
assertEquals(expected, dump);
// -----------
// Select an entry in the revision table.
// -----------
expected = "[ Rename. , {date} , Alex <alex_jitianu@sync.ro> , 1 , AlexJitianu , [2] ]";
expected = replaceDate(expected);
selectAndAssertRevision(historyTable, historyPanel.getAffectedFilesTable(), 0, expected);
// -----------
// Assert the affected files
// -----------
assertAffectedFiles(historyPanel, "(changeType=RENAME, fileLocation=file_renamed.txt)\n");
// ---------------
// Invoke the Diff action to see if the built URLs are O.K.
// ---------------
HistoryTableAffectedFilesModel affectedFilesModel = (HistoryTableAffectedFilesModel) historyPanel.getAffectedFilesTable().getModel();
FileStatus fileStatus = affectedFilesModel.getFilesStatuses().get(0);
CommitCharacteristics cc = model.getAllCommits().get(0);
Action action = getCompareWithPreviousAction(fileStatus, cc);
action.actionPerformed(null);
assertEquals("Unexpected number of URLs intercepted in the comparison support:" + urls2compare.toString(), 2, urls2compare.size());
URL left = urls2compare.get(0);
URL right = urls2compare.get(1);
assertEquals("git://" + model.getAllCommits().get(0).getCommitId() + "/file_renamed.txt", left.toString());
assertEquals("git://" + model.getAllCommits().get(1).getCommitId() + "/file.txt", right.toString());
}
Aggregations