Search in sources :

Example 6 with HistoryViewContextualMenuPresenter

use of com.oxygenxml.git.view.history.HistoryViewContextualMenuPresenter in project oxygen-git-client-addon by oxygenxml.

the class HistoryPanelTestBase method getCompareWithWCAction.

/**
 * Computes the contextual action over the given file.
 * Returns the "Compare_file_with_working_tree_version" action available when you select 2 revisions.
 *
 * @param fileStatus File information for which we want the action.
 * @param cc Revision information.
 *
 * @return The action. If not found, an assert will fail.
 *
 * @throws IOException If it fails.
 * @throws GitAPIException If it fails.
 */
protected Action getCompareWithWCAction(FileStatus fileStatus, CommitCharacteristics cc) throws IOException, GitAPIException {
    HistoryViewContextualMenuPresenter menuPresenter = new HistoryViewContextualMenuPresenter(PowerMockito.mock(GitControllerBase.class));
    JPopupMenu jPopupMenu = new JPopupMenu();
    menuPresenter.populateContextualActionsHistoryContext(jPopupMenu, fileStatus.getFileLocation(), cc);
    MenuElement[] subElements = jPopupMenu.getSubElements();
    List<Action> actions = Arrays.asList(subElements).stream().map(t -> ((JMenuItem) t).getAction()).filter(t -> ((String) t.getValue(Action.NAME)).startsWith("Compare_file_with_working_tree_version")).collect(Collectors.toList());
    assertFalse("Unable to find the 'Compare_with_working_tree_version' action.", actions.isEmpty());
    return actions.get(0);
}
Also used : CommitCharacteristics(com.oxygenxml.git.view.history.CommitCharacteristics) Arrays(java.util.Arrays) HistoryViewContextualMenuPresenter(com.oxygenxml.git.view.history.HistoryViewContextualMenuPresenter) Date(java.util.Date) HistoryPanel(com.oxygenxml.git.view.history.HistoryPanel) GitController(com.oxygenxml.git.view.event.GitController) Action(javax.swing.Action) TableModelListener(javax.swing.event.TableModelListener) GitTestBase(com.oxygenxml.git.service.GitTestBase) FileStatus(com.oxygenxml.git.service.entities.FileStatus) GitAccess(com.oxygenxml.git.service.GitAccess) JMenuItem(javax.swing.JMenuItem) PowerMockito(org.powermock.api.mockito.PowerMockito) TableModelEvent(javax.swing.event.TableModelEvent) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) Semaphore(java.util.concurrent.Semaphore) JPopupMenu(javax.swing.JPopupMenu) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) MenuElement(javax.swing.MenuElement) HistoryCommitTableModel(com.oxygenxml.git.view.history.HistoryCommitTableModel) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Ignore(org.junit.Ignore) JTable(javax.swing.JTable) GitControllerBase(com.oxygenxml.git.service.GitControllerBase) HistoryTableAffectedFilesModel(com.oxygenxml.git.view.history.HistoryTableAffectedFilesModel) GitControllerBase(com.oxygenxml.git.service.GitControllerBase) Action(javax.swing.Action) HistoryViewContextualMenuPresenter(com.oxygenxml.git.view.history.HistoryViewContextualMenuPresenter) MenuElement(javax.swing.MenuElement) JPopupMenu(javax.swing.JPopupMenu)

Example 7 with HistoryViewContextualMenuPresenter

use of com.oxygenxml.git.view.history.HistoryViewContextualMenuPresenter in project oxygen-git-client-addon by oxygenxml.

the class HistoryPanelTestBase method getCompareWithPreviousAction.

/**
 * Computes the contextual action over the given file.
 * Returns the "Compare with each other" action available when you select 2 revisions.
 *
 * @param fileStatus File information for which we want the action.
 * @param cc Revision information.
 *
 * @return The action. If not found, an assert will fail.
 *
 * @throws IOException If it fails.
 * @throws GitAPIException If it fails.
 */
protected Action getCompareWithPreviousAction(FileStatus fileStatus, CommitCharacteristics cc) throws IOException, GitAPIException {
    HistoryViewContextualMenuPresenter menuPresenter = new HistoryViewContextualMenuPresenter(PowerMockito.mock(GitControllerBase.class));
    JPopupMenu jPopupMenu = new JPopupMenu();
    menuPresenter.populateContextualActionsHistoryContext(jPopupMenu, fileStatus.getFileLocation(), cc);
    MenuElement[] subElements = jPopupMenu.getSubElements();
    List<Action> actions = Arrays.asList(subElements).stream().map(t -> ((JMenuItem) t).getAction()).filter(t -> ((String) t.getValue(Action.NAME)).startsWith("Compare_file_with_previous_")).collect(Collectors.toList());
    assertFalse("Unable to find the 'Compare with previous version' action.", actions.isEmpty());
    return actions.get(0);
}
Also used : CommitCharacteristics(com.oxygenxml.git.view.history.CommitCharacteristics) Arrays(java.util.Arrays) HistoryViewContextualMenuPresenter(com.oxygenxml.git.view.history.HistoryViewContextualMenuPresenter) Date(java.util.Date) HistoryPanel(com.oxygenxml.git.view.history.HistoryPanel) GitController(com.oxygenxml.git.view.event.GitController) Action(javax.swing.Action) TableModelListener(javax.swing.event.TableModelListener) GitTestBase(com.oxygenxml.git.service.GitTestBase) FileStatus(com.oxygenxml.git.service.entities.FileStatus) GitAccess(com.oxygenxml.git.service.GitAccess) JMenuItem(javax.swing.JMenuItem) PowerMockito(org.powermock.api.mockito.PowerMockito) TableModelEvent(javax.swing.event.TableModelEvent) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) Semaphore(java.util.concurrent.Semaphore) JPopupMenu(javax.swing.JPopupMenu) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) MenuElement(javax.swing.MenuElement) HistoryCommitTableModel(com.oxygenxml.git.view.history.HistoryCommitTableModel) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Ignore(org.junit.Ignore) JTable(javax.swing.JTable) GitControllerBase(com.oxygenxml.git.service.GitControllerBase) HistoryTableAffectedFilesModel(com.oxygenxml.git.view.history.HistoryTableAffectedFilesModel) GitControllerBase(com.oxygenxml.git.service.GitControllerBase) Action(javax.swing.Action) HistoryViewContextualMenuPresenter(com.oxygenxml.git.view.history.HistoryViewContextualMenuPresenter) MenuElement(javax.swing.MenuElement) JPopupMenu(javax.swing.JPopupMenu)

Example 8 with HistoryViewContextualMenuPresenter

use of com.oxygenxml.git.view.history.HistoryViewContextualMenuPresenter in project oxygen-git-client-addon by oxygenxml.

the class HistoryPanelTestBase method getCompareWithEachOther.

/**
 * Computes the contextual action over the given file.
 * Returns the "Compare with each other" action available when you select 2 revisions.
 *
 * @param fileStatus File informations for which we want the action.
 * @param cc Revision information.
 *
 * @return The action. If not found, an assert will fail.
 *
 * @throws IOException If it fails.
 * @throws GitAPIException If it fails.
 */
protected Action getCompareWithEachOther(FileStatus fileStatus, CommitCharacteristics... cc) throws IOException, GitAPIException {
    HistoryViewContextualMenuPresenter menuPresenter = new HistoryViewContextualMenuPresenter(PowerMockito.mock(GitControllerBase.class));
    JPopupMenu jPopupMenu = new JPopupMenu();
    menuPresenter.populateContextualActionsHistoryContext(jPopupMenu, fileStatus.getFileLocation(), cc);
    MenuElement[] subElements = jPopupMenu.getSubElements();
    List<Action> actions = Arrays.asList(subElements).stream().map(t -> ((JMenuItem) t).getAction()).filter(t -> ((String) t.getValue(Action.NAME)).startsWith("Compare_with_each_other")).collect(Collectors.toList());
    assertFalse("Unable to find the 'Compare_with_each_other' action.", actions.isEmpty());
    return actions.get(0);
}
Also used : CommitCharacteristics(com.oxygenxml.git.view.history.CommitCharacteristics) Arrays(java.util.Arrays) HistoryViewContextualMenuPresenter(com.oxygenxml.git.view.history.HistoryViewContextualMenuPresenter) Date(java.util.Date) HistoryPanel(com.oxygenxml.git.view.history.HistoryPanel) GitController(com.oxygenxml.git.view.event.GitController) Action(javax.swing.Action) TableModelListener(javax.swing.event.TableModelListener) GitTestBase(com.oxygenxml.git.service.GitTestBase) FileStatus(com.oxygenxml.git.service.entities.FileStatus) GitAccess(com.oxygenxml.git.service.GitAccess) JMenuItem(javax.swing.JMenuItem) PowerMockito(org.powermock.api.mockito.PowerMockito) TableModelEvent(javax.swing.event.TableModelEvent) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) Semaphore(java.util.concurrent.Semaphore) JPopupMenu(javax.swing.JPopupMenu) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) MenuElement(javax.swing.MenuElement) HistoryCommitTableModel(com.oxygenxml.git.view.history.HistoryCommitTableModel) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Ignore(org.junit.Ignore) JTable(javax.swing.JTable) GitControllerBase(com.oxygenxml.git.service.GitControllerBase) HistoryTableAffectedFilesModel(com.oxygenxml.git.view.history.HistoryTableAffectedFilesModel) GitControllerBase(com.oxygenxml.git.service.GitControllerBase) Action(javax.swing.Action) HistoryViewContextualMenuPresenter(com.oxygenxml.git.view.history.HistoryViewContextualMenuPresenter) MenuElement(javax.swing.MenuElement) JPopupMenu(javax.swing.JPopupMenu)

Aggregations

FileStatus (com.oxygenxml.git.service.entities.FileStatus)8 CommitCharacteristics (com.oxygenxml.git.view.history.CommitCharacteristics)8 HistoryViewContextualMenuPresenter (com.oxygenxml.git.view.history.HistoryViewContextualMenuPresenter)8 JPopupMenu (javax.swing.JPopupMenu)8 Action (javax.swing.Action)7 GitAccess (com.oxygenxml.git.service.GitAccess)5 GitControllerBase (com.oxygenxml.git.service.GitControllerBase)5 GitTestBase (com.oxygenxml.git.service.GitTestBase)5 GitController (com.oxygenxml.git.view.event.GitController)5 HistoryCommitTableModel (com.oxygenxml.git.view.history.HistoryCommitTableModel)5 HistoryPanel (com.oxygenxml.git.view.history.HistoryPanel)5 HistoryTableAffectedFilesModel (com.oxygenxml.git.view.history.HistoryTableAffectedFilesModel)5 IOException (java.io.IOException)5 Arrays (java.util.Arrays)5 Date (java.util.Date)5 List (java.util.List)5 Semaphore (java.util.concurrent.Semaphore)5 TimeUnit (java.util.concurrent.TimeUnit)5 Collectors (java.util.stream.Collectors)5 JMenuItem (javax.swing.JMenuItem)5