use of com.oxygenxml.git.view.event.GitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method abortRebase.
/**
* Aborts and resets the current rebase
*/
public void abortRebase() {
fireOperationAboutToStart(new GitEventInfo(GitOperation.ABORT_REBASE));
GitOperationScheduler.getInstance().schedule(() -> {
try {
git.rebase().setOperation(Operation.ABORT).call();
fireOperationSuccessfullyEnded(new GitEventInfo(GitOperation.ABORT_REBASE));
} catch (GitAPIException e) {
fireOperationFailed(new GitEventInfo(GitOperation.ABORT_REBASE), e);
LOGGER.error(e.getMessage(), e);
}
});
}
use of com.oxygenxml.git.view.event.GitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method applyStash.
/**
* Apply the given stash.
*
* @param stashRef the stash which will be applied.
*
* @return the status for stash apply operation.
*
* @throws GitAPIException
*/
public StashApplyStatus applyStash(String stashRef) throws GitAPIException {
fireOperationAboutToStart(new GitEventInfo(GitOperation.STASH_APPLY));
StashApplyStatus status = StashApplyStatus.NOT_APPLIED_UNKNOWN_CAUSE;
try {
checkIfStashIsApplicable(stashRef);
git.stashApply().setStashRef(stashRef).call();
status = StashApplyStatus.APPLIED_SUCCESSFULLY;
fireOperationSuccessfullyEnded(new GitEventInfo(GitOperation.STASH_APPLY));
} catch (StashApplyFailureWithStatusException e) {
status = e.getStatus();
displayStashApplyFailedCauseMessage(false, status, e);
} catch (StashApplyFailureException | IOException e) {
displayStashApplyFailedCauseMessage(false, status, e);
}
return status;
}
use of com.oxygenxml.git.view.event.GitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method popStash.
/**
* Pop the given stash.
*
* @param stashRef the stash which will be applied.
*
* @return the status for stash apply operation.
*
* @throws GitAPIException
*/
public StashApplyStatus popStash(String stashRef) throws GitAPIException {
fireOperationAboutToStart(new GitEventInfo(GitOperation.STASH_APPLY));
StashApplyStatus status = StashApplyStatus.NOT_APPLIED_UNKNOWN_CAUSE;
try {
checkIfStashIsApplicable(stashRef);
git.stashApply().setStashRef(stashRef).call();
List<RevCommit> stashes = new ArrayList<>(listStashes());
status = StashApplyStatus.APPLIED_SUCCESSFULLY;
for (int i = 0; i < stashes.size(); i++) {
if (stashRef.equals(stashes.get(i).getName())) {
dropStash(i);
break;
}
}
fireOperationSuccessfullyEnded(new GitEventInfo(GitOperation.STASH_APPLY));
} catch (StashApplyFailureWithStatusException e) {
status = e.getStatus();
displayStashApplyFailedCauseMessage(true, status, e);
} catch (StashApplyFailureException | IOException e) {
displayStashApplyFailedCauseMessage(true, status, e);
}
return status;
}
use of com.oxygenxml.git.view.event.GitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitAccess method createStash.
/**
* Create a new stash command.
*
* @param includeUntrackedFiles <code>True</code> if the stash should include the untracked files.
* @param description The description of stash. May be <code>null</code>.
*
* @return The created stash.
*/
public RevCommit createStash(boolean includeUntrackedFiles, String description) {
fireOperationAboutToStart(new GitEventInfo(GitOperation.STASH_CREATE));
RevCommit stash = null;
try {
StashCreateCommand createStashCmd = git.stashCreate().setIncludeUntracked(includeUntrackedFiles);
if (description != null) {
createStashCmd.setWorkingDirectoryMessage(description);
}
stash = createStashCmd.call();
fireOperationSuccessfullyEnded(new BranchGitEventInfo(GitOperation.STASH_CREATE, getBranchInfo().getBranchName()));
} catch (GitAPIException e) {
if (repositoryHasConflicts()) {
PluginWorkspaceProvider.getPluginWorkspace().showErrorMessage(TRANSLATOR.getTranslation(Tags.RESOLVE_CONFLICTS_FIRST));
} else {
PluginWorkspaceProvider.getPluginWorkspace().showErrorMessage(TRANSLATOR.getTranslation(Tags.STASH_CANNOT_BE_CREATED) + e.getMessage(), e);
LOGGER.error(e.getMessage(), e);
}
fireOperationFailed(new BranchGitEventInfo(GitOperation.STASH_CREATE, getBranchInfo().getBranchName()), e);
}
return stash;
}
use of com.oxygenxml.git.view.event.GitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class OxygenGitPluginExtension method customizeGitStagingView.
/**
* Customize the Git Staging view.
*
* @param viewInfo View information.
*/
private void customizeGitStagingView(final ViewInfo viewInfo, final GitActionsManager gitActionsManager) {
boolean shouldRecreateStagingPanel = stagingPanel == null;
if (shouldRecreateStagingPanel) {
stagingPanel = new StagingPanel(gitRefreshSupport, gitController, OxygenGitPluginExtension.this, gitActionsManager);
gitRefreshSupport.setStagingPanel(stagingPanel);
}
viewInfo.setComponent(stagingPanel);
GitOperationUtil.installMouseBusyCursor(gitController, stagingPanel);
gitController.addGitListener(new GitEventAdapter() {
@Override
public void operationAboutToStart(GitEventInfo info) {
// not needed
}
@Override
public void operationSuccessfullyEnded(GitEventInfo info) {
final GitOperation operation = info.getGitOperation();
if (operation == GitOperation.CHECKOUT || operation == GitOperation.CONTINUE_REBASE || operation == GitOperation.RESET_TO_COMMIT || operation == GitOperation.OPEN_WORKING_COPY || operation == GitOperation.MERGE || operation == GitOperation.COMMIT || operation == GitOperation.REVERT_COMMIT || operation == GitOperation.STASH_CREATE || operation == GitOperation.STASH_DROP || operation == GitOperation.STASH_APPLY || operation == GitOperation.UPDATE_CONFIG_FILE || operation == GitOperation.STASH_POP || operation == GitOperation.CHECKOUT_FILE || operation == GitOperation.CHECKOUT_COMMIT || operation == GitOperation.CREATE_TAG || operation == GitOperation.DELETE_TAG || operation == GitOperation.DISCARD) {
gitRefreshSupport.call();
if (operation == GitOperation.CHECKOUT || operation == GitOperation.MERGE) {
try {
FileUtil.refreshProjectView();
} catch (NoRepositorySelected e) {
LOGGER.debug(e.getMessage(), e);
}
} else if (operation == GitOperation.OPEN_WORKING_COPY && GitAccess.getInstance().getBranchInfo().isDetached()) {
treatDetachedHead((WorkingCopyGitEventInfo) info);
}
}
}
@Override
public void operationFailed(GitEventInfo info, Throwable t) {
final GitOperation operation = info.getGitOperation();
if (operation == GitOperation.CONTINUE_REBASE || operation == GitOperation.RESET_TO_COMMIT) {
gitRefreshSupport.call();
}
}
});
gitRefreshSupport.call();
viewInfo.setIcon(Icons.getIcon(Icons.GIT_ICON));
viewInfo.setTitle(translator.getTranslation(Tags.GIT_STAGING));
}
Aggregations