Search in sources :

Example 1 with FileStatusOverDiffEntry

use of com.oxygenxml.git.service.entities.FileStatusOverDiffEntry in project oxygen-git-client-addon by oxygenxml.

the class HistoryViewContextualMenuPresenter method createCompareActionsForCommit.

/**
 * Creates the DIFF actions for an actual commit from history.
 *
 * @param actions               List where to put the actions.
 * @param commitCharacteristics Commit data.
 * @param addFileName           <code>true</code> to append the name of the file to the actions' name.
 * @param fileStatus            File to diff.
 */
private void createCompareActionsForCommit(List<Action> actions, CommitCharacteristics commitCharacteristics, boolean addFileName, FileStatus fileStatus) {
    String filePath = fileStatus.getFileLocation();
    if (fileStatus instanceof FileStatusOverDiffEntry && fileStatus.getChangeType() == GitChangeType.RENAME) {
        actions.add(new AbstractAction(getCompareWithPreviousVersionActionName(filePath, addFileName)) {

            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    DiffPresenter.showTwoWayDiff(((FileStatusOverDiffEntry) fileStatus));
                } catch (MalformedURLException e1) {
                    PluginWorkspaceProvider.getPluginWorkspace().showErrorMessage(UNABLE_TO_COMPARE + e1.getMessage());
                    LOGGER.error(e1.getMessage(), e1);
                }
            }
        });
    } else if (fileStatus.getChangeType() != GitChangeType.ADD) {
        addCompareWithParentsAction(actions, commitCharacteristics, addFileName, filePath);
    }
    addCompareWithWorkingTreeAction(actions, commitCharacteristics, addFileName, filePath);
}
Also used : MalformedURLException(java.net.MalformedURLException) ActionEvent(java.awt.event.ActionEvent) AbstractAction(javax.swing.AbstractAction) FileStatusOverDiffEntry(com.oxygenxml.git.service.entities.FileStatusOverDiffEntry)

Aggregations

FileStatusOverDiffEntry (com.oxygenxml.git.service.entities.FileStatusOverDiffEntry)1 ActionEvent (java.awt.event.ActionEvent)1 MalformedURLException (java.net.MalformedURLException)1 AbstractAction (javax.swing.AbstractAction)1