use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.
the class StagingView method reload.
/**
* Reload the staging view asynchronously
*
* @param repository
*/
public void reload(final Repository repository) {
if (isDisposed()) {
return;
}
if (repository == null) {
asyncUpdate(() -> clearRepository(null));
return;
}
if (!isValidRepo(repository)) {
asyncUpdate(() -> clearRepository(repository));
return;
}
final boolean repositoryChanged = currentRepository != repository;
realRepository = repository;
currentRepository = repository;
asyncUpdate(() -> {
if (isDisposed()) {
return;
}
final IndexDiffData indexDiff = doReload(repository);
boolean indexDiffAvailable = indexDiffAvailable(indexDiff);
boolean noConflicts = noConflicts(indexDiff);
if (repositoryChanged) {
// Reset paths, they're from the old repository
resetPathsToExpand();
if (refsChangedListener != null)
refsChangedListener.remove();
refsChangedListener = repository.getListenerList().addRefsChangedListener(event -> updateRebaseButtonVisibility(repository.getRepositoryState().isRebasing()));
if (configChangedListener != null) {
configChangedListener.remove();
}
configChangedListener = repository.getListenerList().addConfigChangedListener(event -> resetCommitMessageComponent());
}
final StagingViewUpdate update = new StagingViewUpdate(repository, indexDiff, null);
Object[] unstagedExpanded = unstagedViewer.getVisibleExpandedElements();
Object[] stagedExpanded = stagedViewer.getVisibleExpandedElements();
int unstagedElementsCount = updateAutoExpand(unstagedViewer, getUnstaged(indexDiff));
int stagedElementsCount = updateAutoExpand(stagedViewer, getStaged(indexDiff));
int elementsCount = unstagedElementsCount + stagedElementsCount;
if (elementsCount > getMaxLimitForListMode()) {
listPresentationAction.setEnabled(false);
if (presentation == Presentation.LIST) {
compactTreePresentationAction.setChecked(true);
switchToCompactModeInternal(true);
} else {
setExpandCollapseActionsVisible(false, unstagedElementsCount <= getMaxLimitForListMode(), true);
setExpandCollapseActionsVisible(true, stagedElementsCount <= getMaxLimitForListMode(), true);
}
} else {
listPresentationAction.setEnabled(true);
boolean changed = getPreferenceStore().getBoolean(UIPreferences.STAGING_VIEW_PRESENTATION_CHANGED);
if (changed) {
listPresentationAction.setChecked(true);
switchToListMode();
} else if (presentation != Presentation.LIST) {
setExpandCollapseActionsVisible(false, true, true);
setExpandCollapseActionsVisible(true, true, true);
}
}
setStagingViewerInput(unstagedViewer, update, unstagedExpanded, pathsToExpandInUnstaged);
setStagingViewerInput(stagedViewer, update, stagedExpanded, pathsToExpandInStaged);
resetPathsToExpand();
// Force a selection changed event
unstagedViewer.setSelection(unstagedViewer.getSelection());
refreshAction.setEnabled(true);
updateRebaseButtonVisibility(repository.getRepositoryState().isRebasing());
updateIgnoreErrorsButtonVisibility();
boolean rebaseContinueEnabled = indexDiffAvailable && repository.getRepositoryState().isRebasing() && noConflicts;
rebaseContinueButton.setEnabled(rebaseContinueEnabled);
form.setText(GitLabels.getStyledLabelSafe(repository).toString());
updateCommitMessageComponent(repositoryChanged, indexDiffAvailable);
enableCommitWidgets(indexDiffAvailable && noConflicts);
updateCommitButtons();
updateSectionText();
});
}
use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.
the class PatchOperationUI method isWorkingTreeClean.
private boolean isWorkingTreeClean() {
IndexDiffCache diffCache = org.eclipse.egit.core.Activator.getDefault().getIndexDiffCache();
if (diffCache != null) {
IndexDiffCacheEntry diffCacheEntry = diffCache.getIndexDiffCacheEntry(repository);
if (diffCacheEntry == null) {
return true;
}
IndexDiffData diffData = diffCacheEntry.getIndexDiff();
if (diffData != null) {
Set<String> modified = diffData.getModified();
Set<String> untracked = diffData.getUntracked();
Set<String> missing = diffData.getMissing();
for (IResource resource : resources) {
String repoRelativePath = makeRepoRelative(resource);
if (containsPrefix(modified, repoRelativePath))
return false;
if (containsPrefix(untracked, repoRelativePath))
return false;
if (containsPrefix(missing, repoRelativePath))
return false;
}
}
}
return true;
}
Aggregations