Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDariusz Luksza2011-05-12 22:10:09 +0000
committerChris Aniszczyk2011-05-23 19:42:30 +0000
commite039d918ce4a57136ddd17b8917336af72fb7ae5 (patch)
treea69f4fee4338cd90282e6a8bcc8ea12bb7e5a96c /org.eclipse.egit.ui/src/org
parenta8e1af9c9dcf76a1cb6caa5c759a23ef253f5ab0 (diff)
downloadegit-e039d918ce4a57136ddd17b8917336af72fb7ae5.tar.gz
egit-e039d918ce4a57136ddd17b8917336af72fb7ae5.tar.xz
egit-e039d918ce4a57136ddd17b8917336af72fb7ae5.zip
[sync] Add preference option to disable automatic fetch
Adds preference option to disable automatic fetch before synchronization launch. Also user is informed that he can disable automatic fetch in preferences when fetch failed. Change-Id: I8ca2578e366894081aae120e2ba422d2e90240f5 Signed-off-by: Dariusz Luksza <dariusz@luksza.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Diffstat (limited to 'org.eclipse.egit.ui/src/org')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/PluginPreferenceInitializer.java1
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java9
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitPreferenceRoot.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitModelSynchronize.java24
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/SynchronizeFetchJob.java18
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties3
7 files changed, 52 insertions, 8 deletions
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 17a5546b8c..c6b6e66945 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
@@ -82,6 +82,7 @@ public class PluginPreferenceInitializer extends AbstractPreferenceInitializer {
GitChangeSetLabelProvider.DEFAULT_CHANGESET_FORMAT);
store.setDefault(UIPreferences.SYNC_VIEW_ALWAYS_SHOW_CHANGESET_MODEL,
false);
+ store.setDefault(UIPreferences.SYNC_VIEW_FETCH_BEFORE_LAUNCH, true);
store.setDefault(UIPreferences.DATE_FORMAT,
GitChangeSetLabelProvider.DEFAULT_DATE_FORMAT);
store.setDefault(UIPreferences.HISTORY_MAX_NUM_COMMITS, 10000);
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 92cc1568e4..252596c832 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
@@ -112,6 +112,8 @@ public class UIPreferences {
/** */
public final static String SYNC_VIEW_ALWAYS_SHOW_CHANGESET_MODEL = "sync_view_show_changeset_model"; //$NON-NLS-1$
/** */
+ public static final String SYNC_VIEW_FETCH_BEFORE_LAUNCH = "sync_view_fetch_before_launch"; //$NON-NLS-1$
+ /** */
public final static String DATE_FORMAT = "date_format"; //$NON-NLS-1$
/** */
public static final String REFESH_ON_INDEX_CHANGE = "refesh_on_index_change"; //$NON-NLS-1$
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
index 810150d898..98f0d0beb9 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
@@ -424,6 +424,9 @@ public class UIText extends NLS {
public static String GitPreferenceRoot_automaticallyEnableChangesetModel;
/** */
+ public static String GitPreferenceRoot_fetchBeforeSynchronization;
+
+ /** */
public static String GitPreferenceRoot_CloningRepoGroupHeader;
/** */
@@ -3673,6 +3676,12 @@ public class UIText extends NLS {
/** */
public static String SynchronizeFetchJob_SubTaskName;
+ /** */
+ public static String SynchronizeFetchJob_FetchFailedTitle;
+
+ /** */
+ public static String SynchronizeFetchJob_FetchFailedMessage;
+
static {
initializeMessages(BUNDLE_NAME, UIText.class);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitPreferenceRoot.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitPreferenceRoot.java
index 35b132a4c6..e917510a0f 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitPreferenceRoot.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitPreferenceRoot.java
@@ -156,6 +156,9 @@ public class GitPreferenceRoot extends FieldEditorPreferencePage implements
GridDataFactory.fillDefaults().grab(true, false).span(GROUP_SPAN, 1)
.applyTo(synchronizeGroup);
synchronizeGroup.setText(UIText.GitPreferenceRoot_SynchronizeView);
+ addField(new BooleanFieldEditor(UIPreferences.SYNC_VIEW_FETCH_BEFORE_LAUNCH,
+ UIText.GitPreferenceRoot_fetchBeforeSynchronization,
+ synchronizeGroup));
addField(new BooleanFieldEditor(UIPreferences.SYNC_VIEW_ALWAYS_SHOW_CHANGESET_MODEL,
UIText.GitPreferenceRoot_automaticallyEnableChangesetModel,
synchronizeGroup));
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitModelSynchronize.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitModelSynchronize.java
index bbc49c30ac..7c2fccb778 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitModelSynchronize.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitModelSynchronize.java
@@ -23,6 +23,7 @@ import org.eclipse.egit.core.synchronize.GitSubscriberResourceMappingContext;
import org.eclipse.egit.core.synchronize.dto.GitSynchronizeData;
import org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet;
import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.subscribers.SubscriberScopeManager;
import org.eclipse.team.ui.TeamUI;
@@ -57,9 +58,14 @@ public class GitModelSynchronize {
*/
public static final void launch(final GitSynchronizeDataSet gsdSet,
IResource[] resources) {
- Job fetchJob = new SynchronizeFetchJob(gsdSet);
- fetchJob.setUser(true);
- fetchJob.schedule();
+ boolean launchFetch = Activator.getDefault().getPreferenceStore()
+ .getBoolean(UIPreferences.SYNC_VIEW_FETCH_BEFORE_LAUNCH);
+ Job fetchJob = null;
+ if (launchFetch) {
+ fetchJob = new SynchronizeFetchJob(gsdSet);
+ fetchJob.setUser(true);
+ fetchJob.schedule();
+ }
ResourceMapping[] mappings = getSelectedResourceMappings(resources);
@@ -82,11 +88,13 @@ public class GitModelSynchronize {
if (window != null)
activePart = window.getActivePage().getActivePart();
- try {
- fetchJob.join();
- } catch (InterruptedException e) {
- Activator.logError("Fetch operation interupted", e); //$NON-NLS-1$
- }
+ if (launchFetch && fetchJob != null)
+ try {
+ fetchJob.join();
+ } catch (InterruptedException e) {
+ Activator.logError("Fetch operation interupted", e); //$NON-NLS-1$
+ }
+
participant.run(activePart);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/SynchronizeFetchJob.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/SynchronizeFetchJob.java
index 8608773384..b062488e04 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/SynchronizeFetchJob.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/SynchronizeFetchJob.java
@@ -23,10 +23,13 @@ import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.UIText;
import org.eclipse.egit.ui.credentials.EGitCredentialsProvider;
import org.eclipse.egit.ui.internal.fetch.FetchOperationUI;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
class SynchronizeFetchJob extends Job {
@@ -71,6 +74,7 @@ class SynchronizeFetchJob extends Job {
try {
fetchOperationUI.execute(subMonitor);
} catch (CoreException e) {
+ showInformationDialog(remoteName);
Activator.logError(e.getMessage(), e);
}
@@ -79,4 +83,18 @@ class SynchronizeFetchJob extends Job {
return Status.OK_STATUS;
}
+
+ private void showInformationDialog(final String remoteName) {
+ final Display display = PlatformUI.getWorkbench().getDisplay();
+ display.syncExec(new Runnable() {
+ public void run() {
+ MessageDialog.openInformation(display.getActiveShell(), NLS
+ .bind(UIText.SynchronizeFetchJob_FetchFailedTitle,
+ remoteName), NLS.bind(
+ UIText.SynchronizeFetchJob_FetchFailedMessage,
+ UIText.GitPreferenceRoot_fetchBeforeSynchronization));
+ }
+ });
+ }
+
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
index 6486ef9ef0..2306436520 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
@@ -145,6 +145,7 @@ GitHistoryPage_IncompleteListTooltip=Not all commits are shown, the limit may be
GitHistoryPage_ListIncompleteWarningMessage=The list is incomplete
GitHistoryPage_ShowSubMenuLabel=&Show
GitPreferenceRoot_automaticallyEnableChangesetModel=Automatically enable chan&ge set grouping in Git synchronizations
+GitPreferenceRoot_fetchBeforeSynchronization=Always launch fetch before synchronization
GitPreferenceRoot_CloningRepoGroupHeader=Cloning Repositories
GitPreferenceRoot_DefaultRepoFolderLabel=Default Repository &folder:
GitPreferenceRoot_DefaultRepoFolderTooltip=This folder will be suggested as parent folder when cloning a Remote Repository
@@ -1278,3 +1279,5 @@ SynchronizeWithMenu_custom=&Custom...
SynchronizeFetchJob_JobName=Fetching changes before synchronization launch
SynchronizeFetchJob_TaskName=Fetching changes for synchronization
SynchronizeFetchJob_SubTaskName=Fetching changes from {0}
+SynchronizeFetchJob_FetchFailedTitle=Fetch from {0} failed
+SynchronizeFetchJob_FetchFailedMessage=Fetch operation failed.\n\nSychronization will be continued based on data that are currently in repository.\n\nYou can disable fetching changes before synchronization in preferences:\nTeam > Git > {0}

Back to the top