use of com.oxygenxml.git.OxygenGitOptionPagePluginExtension.WhenRepoDetectedInProject in project oxygen-git-client-addon by oxygenxml.
the class PanelRefresh method tryToSwitchToRepo.
/**
* Try to switch to repo, if the user will agree.
*
* @param repoDir Repository directory.
*
* @return <code>true</code> if repo changed.
*/
private boolean tryToSwitchToRepo(File repoDir) {
boolean repoChanged = false;
try {
File currentRepo = null;
if (gitAccess.isRepoInitialized()) {
currentRepo = gitAccess.getRepository().getDirectory().getParentFile();
}
if (currentRepo == null || !same(currentRepo, repoDir)) {
JComboBox<String> wcComboBox = stagingPanel.getWorkingCopySelectionPanel().getWorkingCopyCombo();
if (wcComboBox.isPopupVisible()) {
wcComboBox.setPopupVisible(false);
}
WhenRepoDetectedInProject whatToDo = OptionsManager.getInstance().getWhenRepoDetectedInProject();
String projectDirPath = getCanonicalPath(repoDir);
if (whatToDo == WhenRepoDetectedInProject.ASK_TO_SWITCH_TO_WC) {
repoChanged = switchToProjectRepoIfUserAgrees(projectDirPath);
} else if (whatToDo == WhenRepoDetectedInProject.AUTO_SWITCH_TO_WC) {
GitAccess.getInstance().setRepositoryAsync(projectDirPath);
repoChanged = true;
}
}
} catch (NoRepositorySelected e) {
LOGGER.warn(e.getMessage(), e);
}
return repoChanged;
}
Aggregations