use of com.oxygenxml.git.service.NoRepositorySelected in project oxygen-git-client-addon by oxygenxml.
the class RevertCommitAction method actionPerformed.
/**
* Action performed.
*/
@Override
public void actionPerformed(ActionEvent e) {
Translator translator = Translator.getInstance();
int result = FileStatusDialog.showQuestionMessage(translator.getTranslation(Tags.REVERT_COMMIT), translator.getTranslation(Tags.REVERT_COMMIT_CONFIRMATION), translator.getTranslation(Tags.YES), translator.getTranslation(Tags.NO));
if (result == OKCancelDialog.RESULT_OK) {
GitOperationScheduler.getInstance().schedule(() -> {
try {
GitAccess.getInstance().revertCommit(commitCharacteristics.getCommitId());
} catch (IOException | NoRepositorySelected | GitAPIException ex) {
LOGGER.debug(ex.getMessage(), ex);
PluginWorkspaceProvider.getPluginWorkspace().showErrorMessage(ex.getMessage(), ex);
}
});
}
}
use of com.oxygenxml.git.service.NoRepositorySelected 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));
}
use of com.oxygenxml.git.service.NoRepositorySelected in project oxygen-git-client-addon by oxygenxml.
the class OxygenGitPluginExtension method treatDetachedHead.
/**
* Treat detached HEAD.
*
* @param wcEventInfo event info.
*/
private void treatDetachedHead(WorkingCopyGitEventInfo wcEventInfo) {
if (wcEventInfo.isWorkingCopySubmodule()) {
return;
}
Repository repo = null;
try {
repo = GitAccess.getInstance().getRepository();
} catch (NoRepositorySelected e) {
LOGGER.error(e.getMessage(), e);
}
if (repo != null && repo.getRepositoryState() != RepositoryState.REBASING_MERGE) {
String commitFullID = GitAccess.getInstance().getBranchInfo().getBranchName();
try (RevWalk revWalk = new RevWalk(repo)) {
RevCommit commit = revWalk.parseCommit(repo.resolve(commitFullID));
DetachedHeadDialog dlg = new DetachedHeadDialog(commit);
dlg.setVisible(true);
} catch (RevisionSyntaxException | IOException e) {
LOGGER.debug(e.getMessage(), e);
}
}
}
use of com.oxygenxml.git.service.NoRepositorySelected in project oxygen-git-client-addon by oxygenxml.
the class BranchSelectionCombo method refresh.
/**
* Refresh.
*/
public void refresh() {
int pullsBehind = GIT_ACCESS.getPullsBehind();
int pushesAhead = -1;
try {
pushesAhead = GIT_ACCESS.getPushesAhead();
} catch (RepoNotInitializedException e) {
LOGGER.debug(e.getMessage(), e);
}
// update pop up
updateBranchesPopup();
Repository repo = null;
try {
repo = GIT_ACCESS.getRepository();
} catch (NoRepositorySelected e) {
LOGGER.debug(e.getMessage(), e);
}
this.setEnabled(repo != null);
final BranchInfo branchInfo = GIT_ACCESS.getBranchInfo();
final String currentBranchName = branchInfo.getBranchName();
if (branchInfo.isDetached()) {
detachedHeadId = currentBranchName;
String tooltipText = TRANSLATOR.getTranslation(Tags.TOOLBAR_PANEL_INFORMATION_STATUS_DETACHED_HEAD) + " " + currentBranchName;
if (repo != null && repo.getRepositoryState() == RepositoryState.REBASING_MERGE) {
tooltipText += "<br>" + TRANSLATOR.getTranslation(Tags.REBASE_IN_PROGRESS) + ".";
}
tooltipText = TextFormatUtil.toHTML(tooltipText);
String finalText = tooltipText;
SwingUtilities.invokeLater(() -> this.setToolTipText(finalText));
} else {
detachedHeadId = null;
String branchTooltip = null;
if (currentBranchName != null && !currentBranchName.isEmpty()) {
branchTooltip = getBranchTooltip(pullsBehind, pushesAhead, currentBranchName);
}
String branchTooltipFinal = branchTooltip;
this.setToolTipText(branchTooltipFinal);
}
}
use of com.oxygenxml.git.service.NoRepositorySelected in project oxygen-git-client-addon by oxygenxml.
the class BranchSelectionCombo method tryCheckingOutBranch.
/**
* The action performed for this Abstract Action
*
* @param oldBranchInfo Old branch info.
* @param newBranchName New branch name.
*/
private void tryCheckingOutBranch(final BranchInfo oldBranchInfo, final String newBranchName) {
final RepositoryState repoState = RepoUtil.getRepoState().orElse(null);
if (oldBranchInfo.isDetached() && !RepoUtil.isRepoRebasing(repoState)) {
detachedHeadId = null;
this.removeItem(oldBranchInfo.getBranchName());
}
GitOperationScheduler.getInstance().schedule(() -> {
try {
GIT_ACCESS.setBranch(newBranchName);
BranchesUtil.fixupFetchInConfig(GIT_ACCESS.getRepository().getConfig());
} catch (CheckoutConflictException ex) {
restoreCurrentBranchSelectionInMenu();
BranchesUtil.showBranchSwitchErrorMessage();
} catch (GitAPIException | JGitInternalException | IOException | NoRepositorySelected ex) {
restoreCurrentBranchSelectionInMenu();
PluginWorkspaceProvider.getPluginWorkspace().showErrorMessage(ex.getMessage(), ex);
}
});
}
Aggregations