Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2015-09-13 19:13:29 -0400
committerGerrit Code Review @ Eclipse.org2015-09-13 19:13:30 -0400
commit0884b2142bfc7beccc00ae9f5c5daa9efe393d9d (patch)
tree5c2c654d12963e7653395f24063be837eddba6d6
parent0831deae6fd973df0696b450f274e1a2b6cf73ef (diff)
parentdd2adb23465d983616ffe9ab121f4d78d32f984a (diff)
downloadegit-0884b2142bfc7beccc00ae9f5c5daa9efe393d9d.tar.gz
egit-0884b2142bfc7beccc00ae9f5c5daa9efe393d9d.tar.xz
egit-0884b2142bfc7beccc00ae9f5c5daa9efe393d9d.zip
Merge changes Ief5d8000,I18808837
* changes: Introduce new preference page for Staging view [scalability] Staging view should handle huge amount of entries
-rw-r--r--org.eclipse.egit.ui/plugin.properties1
-rw-r--r--org.eclipse.egit.ui/plugin.xml9
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/StagingViewPreferencePage.java52
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java166
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties3
8 files changed, 220 insertions, 28 deletions
diff --git a/org.eclipse.egit.ui/plugin.properties b/org.eclipse.egit.ui/plugin.properties
index 2cb645d70..0483621cb 100644
--- a/org.eclipse.egit.ui/plugin.properties
+++ b/org.eclipse.egit.ui/plugin.properties
@@ -115,6 +115,7 @@ GitPreferences_name=Git
GitPreferences_WindowCachePreferencePage_name=Window Cache
GitPreferences_DecoratorPreferencePage_name=Label Decorations
GitPreferences_CommittingPreferencePage_name=Committing
+GitPreferences_StagingViewPreferencePage_name=Staging View
GitPreferences_ProjectPreferencePage_name=Projects
ShareProjectCommand_name=Share with Git
diff --git a/org.eclipse.egit.ui/plugin.xml b/org.eclipse.egit.ui/plugin.xml
index 2c7a9bd00..41e72d425 100644
--- a/org.eclipse.egit.ui/plugin.xml
+++ b/org.eclipse.egit.ui/plugin.xml
@@ -462,6 +462,15 @@
</page>
<page
category="org.eclipse.egit.ui.GitPreferences"
+ class="org.eclipse.egit.ui.internal.preferences.StagingViewPreferencePage"
+ id="org.eclipse.egit.ui.internal.preferences.StagingViewPreferencePage"
+ name="%GitPreferences_StagingViewPreferencePage_name">
+ <keywordReference
+ id="org.eclipse.egit.ui.keyword.git">
+ </keywordReference>
+ </page>
+ <page
+ category="org.eclipse.egit.ui.GitPreferences"
class="org.eclipse.egit.ui.internal.preferences.DialogsPreferencePage"
id="org.eclipse.egit.ui.internal.preferences.DialogsPreferencePage"
name="%DialogsPreferencePage.name">
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java
index 2de70e0ff..4f4abdcd1 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java
@@ -122,6 +122,9 @@ public class PluginPreferenceInitializer extends AbstractPreferenceInitializer {
StagingView.Presentation.LIST.name());
store.setDefault(UIPreferences.STAGING_VIEW_FILENAME_MODE, true);
store.setDefault(UIPreferences.STAGING_VIEW_COMPARE_MODE, true);
+ store.setDefault(UIPreferences.STAGING_VIEW_MAX_LIMIT_LIST_MODE, 10000);
+ store.setDefault(UIPreferences.STAGING_VIEW_PRESENTATION_CHANGED,
+ false);
store.setDefault(UIPreferences.CLONE_WIZARD_STORE_SECURESTORE, false);
store.setDefault(UIPreferences.COMMIT_DIALOG_HISTORY_SIZE, 10);
store.setDefault(UIPreferences.CHECKOUT_PROJECT_RESTORE, true);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java
index 2f86e82b3..5877f4366 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java
@@ -207,6 +207,14 @@ public class UIPreferences {
public static final String STAGING_VIEW_FILENAME_MODE = "StagingView_FileNameMode"; //$NON-NLS-1$
/** */
public static final String STAGING_VIEW_PRESENTATION = "StagingView_Presentation"; //$NON-NLS-1$
+
+ /** max number of files in the view to allow for the list mode */
+ public static final String STAGING_VIEW_MAX_LIMIT_LIST_MODE = "StagingView_MaxLimitListMode"; //$NON-NLS-1$
+
+ /**
+ * List presentation mode was automatically switched to faster mode
+ */
+ public static final String STAGING_VIEW_PRESENTATION_CHANGED = "StagingView_Presentation_Changed"; //$NON-NLS-1$
/** */
public static final String PAGE_COMMIT_PREFERENCES = "org.eclipse.egit.ui.internal.preferences.CommitDialogPreferencePage"; //$NON-NLS-1$
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
index 168d2829f..3297a2952 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
@@ -5411,6 +5411,12 @@ public class UIText extends NLS {
/** */
public static String DiffStyleRangeFormatter_diffTruncated;
+ /** */
+ public static String StagingViewPreferencePage_title;
+
+ /** */
+ public static String StagingViewPreferencePage_maxLimitListMode;
+
static {
initializeMessages(BUNDLE_NAME, UIText.class);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/StagingViewPreferencePage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/StagingViewPreferencePage.java
new file mode 100644
index 000000000..9a207a0d4
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/StagingViewPreferencePage.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (C) 2015 Andrey Loskutov <loskutov@gmx.de>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.preferences;
+
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.UIPreferences;
+import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/** Preferences for committing with commit dialog/staging view. */
+public class StagingViewPreferencePage extends FieldEditorPreferencePage
+ implements IWorkbenchPreferencePage {
+
+ /** */
+ public StagingViewPreferencePage() {
+ super(GRID);
+ setTitle(UIText.StagingViewPreferencePage_title);
+ }
+
+ @Override
+ public void init(IWorkbench workbench) {
+ // Nothing to do
+ }
+
+ @Override
+ protected IPreferenceStore doGetPreferenceStore() {
+ return Activator.getDefault().getPreferenceStore();
+ }
+
+ @Override
+ protected void createFieldEditors() {
+ Composite main = getFieldEditorParent();
+
+ IntegerFieldEditor historySize = new IntegerFieldEditor(
+ UIPreferences.STAGING_VIEW_MAX_LIMIT_LIST_MODE,
+ UIText.StagingViewPreferencePage_maxLimitListMode, main);
+ addField(historySize);
+ }
+
+
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
index 43e954bea..aefa6ce8f 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
@@ -1634,12 +1634,11 @@ public class StagingView extends ViewPart implements IShowInSource {
IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
- if (!isChecked())
+ if (!isChecked()) {
return;
+ }
presentation = Presentation.LIST;
- getPreferenceStore().setValue(
- UIPreferences.STAGING_VIEW_PRESENTATION,
- Presentation.LIST.name());
+ setPresentation(presentation, false);
treePresentationAction.setChecked(false);
compactTreePresentationAction.setChecked(false);
setExpandCollapseActionsVisible(false);
@@ -1653,15 +1652,14 @@ public class StagingView extends ViewPart implements IShowInSource {
IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
- if (!isChecked())
+ if (!isChecked()) {
return;
+ }
presentation = Presentation.TREE;
- getPreferenceStore().setValue(
- UIPreferences.STAGING_VIEW_PRESENTATION,
- Presentation.TREE.name());
+ setPresentation(presentation, false);
listPresentationAction.setChecked(false);
compactTreePresentationAction.setChecked(false);
- setExpandCollapseActionsVisible(true);
+ setExpandCollapseActionsVisible(isExpandAllowed());
refreshViewers();
}
};
@@ -1672,30 +1670,19 @@ public class StagingView extends ViewPart implements IShowInSource {
IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
- if (!isChecked())
+ if (!isChecked()) {
return;
- presentation = Presentation.COMPACT_TREE;
- getPreferenceStore().setValue(
- UIPreferences.STAGING_VIEW_PRESENTATION,
- Presentation.COMPACT_TREE.name());
- listPresentationAction.setChecked(false);
- treePresentationAction.setChecked(false);
- setExpandCollapseActionsVisible(true);
+ }
+ switchToCompactModeInternal(false);
refreshViewers();
}
+
};
compactTreePresentationAction.setImageDescriptor(UIIcons.COMPACT);
presentationMenu.add(compactTreePresentationAction);
- String presentationString = getPreferenceStore().getString(
- UIPreferences.STAGING_VIEW_PRESENTATION);
- if (presentationString.length() > 0) {
- try {
- presentation = Presentation.valueOf(presentationString);
- } catch (IllegalArgumentException e) {
- // Use already set value of presentation
- }
- }
+ presentation = readPresentation(UIPreferences.STAGING_VIEW_PRESENTATION,
+ Presentation.LIST);
switch (presentation) {
case LIST:
listPresentationAction.setChecked(true);
@@ -1728,6 +1715,32 @@ public class StagingView extends ViewPart implements IShowInSource {
actionBars.updateActionBars();
}
+ private Presentation readPresentation(String key, Presentation def) {
+ String presentationString = getPreferenceStore().getString(key);
+ if (presentationString.length() > 0) {
+ try {
+ return Presentation.valueOf(presentationString);
+ } catch (IllegalArgumentException e) {
+ // Use given default
+ }
+ }
+ return def;
+ }
+
+ private void setPresentation(Presentation newOne, boolean auto) {
+ Presentation old = presentation;
+ presentation = newOne;
+ IPreferenceStore store = getPreferenceStore();
+ store.setValue(UIPreferences.STAGING_VIEW_PRESENTATION, newOne.name());
+ if (auto && old != newOne) {
+ // remember user choice if we switch mode automatically
+ store.setValue(UIPreferences.STAGING_VIEW_PRESENTATION_CHANGED,
+ true);
+ } else {
+ store.setToDefault(UIPreferences.STAGING_VIEW_PRESENTATION_CHANGED);
+ }
+ }
+
private void setExpandCollapseActionsVisible(boolean visible) {
for (IContributionItem item : unstagedToolBarManager.getItems())
item.setVisible(visible);
@@ -1741,6 +1754,19 @@ public class StagingView extends ViewPart implements IShowInSource {
stagedToolBarManager.update(true);
}
+ private boolean isExpandAllowed() {
+ StagingViewContentProvider contentProvider = getContentProvider(
+ stagedViewer);
+ if (contentProvider.getCount() > getMaxLimitForListMode()) {
+ return false;
+ }
+ contentProvider = getContentProvider(unstagedViewer);
+ if (contentProvider.getCount() > getMaxLimitForListMode()) {
+ return false;
+ }
+ return true;
+ }
+
private TreeViewer createTree(Composite composite) {
Tree tree = toolkit.createTree(composite, SWT.FULL_SELECTION
| SWT.MULTI);
@@ -2686,6 +2712,32 @@ public class StagingView extends ViewPart implements IShowInSource {
.getExpandedElements();
Object[] stagedExpanded = stagedViewer
.getExpandedElements();
+
+ int elementsCount = updateAutoExpand(unstagedViewer,
+ getUnstaged(indexDiff));
+ elementsCount += updateAutoExpand(stagedViewer,
+ getStaged(indexDiff));
+
+ if (elementsCount > getMaxLimitForListMode()) {
+ listPresentationAction.setEnabled(false);
+ if (presentation == Presentation.LIST) {
+ compactTreePresentationAction.setChecked(true);
+ switchToCompactModeInternal(true);
+ } else {
+ setExpandCollapseActionsVisible(false);
+ }
+ } else {
+ listPresentationAction.setEnabled(true);
+ boolean changed = getPreferenceStore().getBoolean(
+ UIPreferences.STAGING_VIEW_PRESENTATION_CHANGED);
+ if (changed) {
+ listPresentationAction.setChecked(true);
+ listPresentationAction.run();
+ } else if (presentation != Presentation.LIST) {
+ setExpandCollapseActionsVisible(true);
+ }
+ }
+
unstagedViewer.setInput(update);
stagedViewer.setInput(update);
expandPreviousExpandedAndPaths(unstagedExpanded, unstagedViewer,
@@ -2715,6 +2767,57 @@ public class StagingView extends ViewPart implements IShowInSource {
});
}
+ /**
+ * The max number of changed files we can handle in the "list" presentation
+ * without freezing Eclipse UI for a too long time.
+ *
+ * @return default is 10000
+ */
+ private int getMaxLimitForListMode() {
+ return Activator.getDefault().getPreferenceStore()
+ .getInt(UIPreferences.STAGING_VIEW_MAX_LIMIT_LIST_MODE);
+ }
+
+ private static int getUnstaged(@Nullable IndexDiffData indexDiff) {
+ if (indexDiff == null) {
+ return 0;
+ }
+ int size = indexDiff.getUntracked().size();
+ size += indexDiff.getMissing().size();
+ size += indexDiff.getModified().size();
+ size += indexDiff.getConflicting().size();
+ return size;
+ }
+
+ private static int getStaged(@Nullable IndexDiffData indexDiff) {
+ if (indexDiff == null) {
+ return 0;
+ }
+ int size = indexDiff.getAdded().size();
+ size += indexDiff.getChanged().size();
+ size += indexDiff.getRemoved().size();
+ return size;
+ }
+
+ private int updateAutoExpand(TreeViewer viewer, int newSize) {
+ if (newSize > getMaxLimitForListMode()) {
+ // auto expand with too many nodes freezes eclipse
+ disableAutoExpand(viewer);
+ }
+ return newSize;
+ }
+
+ private void switchToCompactModeInternal(boolean auto) {
+ setPresentation(Presentation.COMPACT_TREE, auto);
+ listPresentationAction.setChecked(false);
+ treePresentationAction.setChecked(false);
+ if (auto) {
+ setExpandCollapseActionsVisible(false);
+ } else {
+ setExpandCollapseActionsVisible(isExpandAllowed());
+ }
+ }
+
private static boolean noConflicts(IndexDiffData indexDiff) {
return indexDiff == null ? true : indexDiff.getConflicting().isEmpty();
}
@@ -2758,9 +2861,16 @@ public class StagingView extends ViewPart implements IShowInSource {
private void expandPreviousExpandedAndPaths(Object[] previous,
TreeViewer viewer, Set<IPath> additionalPaths) {
+
+ StagingViewContentProvider stagedContentProvider = getContentProvider(
+ viewer);
+ int count = stagedContentProvider.getCount();
+ updateAutoExpand(viewer, count);
+
// Auto-expand is on, so don't change expanded items
- if (viewer.getAutoExpandLevel() == AbstractTreeViewer.ALL_LEVELS)
+ if (viewer.getAutoExpandLevel() == AbstractTreeViewer.ALL_LEVELS) {
return;
+ }
// No need to expand anything
if (getPresentation() == Presentation.LIST)
@@ -2774,7 +2884,7 @@ public class StagingView extends ViewPart implements IShowInSource {
if (element instanceof StagingFolderEntry)
addPathAndParentPaths(((StagingFolderEntry) element).getPath(), paths);
List<StagingFolderEntry> expand = new ArrayList<StagingFolderEntry>();
- StagingViewContentProvider stagedContentProvider = getContentProvider(viewer);
+
calculateNodesToExpand(paths, stagedContentProvider.getElements(null),
expand);
viewer.setExpandedElements(expand.toArray());
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
index 58f413731..3f9f3c45f 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
@@ -1900,3 +1900,6 @@ PushMenu_PushHEAD=Push &HEAD...
PushMenu_PushBranch=Push &Branch ''{0}''...
DiffStyleRangeFormatter_diffTruncated=[...] diff truncated after {0} lines.
+
+StagingViewPreferencePage_title=Staging View
+StagingViewPreferencePage_maxLimitListMode=Switch to compact mode if files number exceeds:

Back to the top