Search in sources :

Example 1 with CreateBranchFromCommitAction

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

the class HistoryViewContextualMenuPresenter method populateActions4SingleSelection.

/**
 * Contributes the contextual actions for the given file, at the given revision/commit.
 *
 * @param jPopupMenu            Contextual menu in which to put the actions.
 * @param filePath              File path.
 * @param commitCharacteristics Revision/commit data.
 *
 * @throws IOException If it fails.
 * @throws GitAPIException If it fails.
 */
private void populateActions4SingleSelection(JPopupMenu jPopupMenu, String filePath, CommitCharacteristics commitCharacteristics) throws IOException, GitAPIException {
    if (filePath != null) {
        Optional<FileStatus> fileStatusOptional = getFileStatus(filePath, commitCharacteristics);
        fileStatusOptional.ifPresent(fileStatus -> populateContextActionsForFile(jPopupMenu, fileStatus, commitCharacteristics, true));
    }
    if (filePath != null) {
        jPopupMenu.addSeparator();
    }
    String commitId = commitCharacteristics.getCommitId();
    if (!GitAccess.UNCOMMITED_CHANGES.getCommitId().equals(commitId)) {
        jPopupMenu.add(new CreateBranchFromCommitAction(commitId));
        jPopupMenu.add(new CreateTagAction(commitId));
        jPopupMenu.add(new CheckoutCommitAction(commitCharacteristics.getPlotCommit()));
        jPopupMenu.addSeparator();
        jPopupMenu.add(new RevertCommitAction(commitCharacteristics));
        jPopupMenu.add(new ResetBranchToCommitAction(commitCharacteristics));
    }
}
Also used : RevertCommitAction(com.oxygenxml.git.view.history.actions.RevertCommitAction) FileStatus(com.oxygenxml.git.service.entities.FileStatus) CheckoutCommitAction(com.oxygenxml.git.view.history.actions.CheckoutCommitAction) ResetBranchToCommitAction(com.oxygenxml.git.view.history.actions.ResetBranchToCommitAction) CreateTagAction(com.oxygenxml.git.view.history.actions.CreateTagAction) CreateBranchFromCommitAction(com.oxygenxml.git.view.history.actions.CreateBranchFromCommitAction)

Aggregations

FileStatus (com.oxygenxml.git.service.entities.FileStatus)1 CheckoutCommitAction (com.oxygenxml.git.view.history.actions.CheckoutCommitAction)1 CreateBranchFromCommitAction (com.oxygenxml.git.view.history.actions.CreateBranchFromCommitAction)1 CreateTagAction (com.oxygenxml.git.view.history.actions.CreateTagAction)1 ResetBranchToCommitAction (com.oxygenxml.git.view.history.actions.ResetBranchToCommitAction)1 RevertCommitAction (com.oxygenxml.git.view.history.actions.RevertCommitAction)1