Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2003-07-16 19:54:49 +0000
committerJean Michel-Lemieux2003-07-16 19:54:49 +0000
commite23ecb08d7b55434829202dbfd06168b101b5bd3 (patch)
tree366ab8bfaf337eec686e065dec2484256742808a
parent8b15a805dd48af6fd192ba77d9448fe9ed2a5904 (diff)
downloadeclipse.platform.team-e23ecb08d7b55434829202dbfd06168b101b5bd3.tar.gz
eclipse.platform.team-e23ecb08d7b55434829202dbfd06168b101b5bd3.tar.xz
eclipse.platform.team-e23ecb08d7b55434829202dbfd06168b101b5bd3.zip
Bug 40027: Null pointer exception in Live Synchronize view
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/OpenInCompareAction.java32
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SubscriberInput.java16
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetInputFromSubscriber.java36
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetInputFromSubscriberWorkingSet.java5
4 files changed, 48 insertions, 41 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/OpenInCompareAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/OpenInCompareAction.java
index 274b501d1..9198e299a 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/OpenInCompareAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/actions/OpenInCompareAction.java
@@ -128,25 +128,25 @@ public class OpenInCompareAction extends Action {
return editor;
}
- public static void closeCompareEditorFor(SyncViewer viewer, IResource resource) {
- final IWorkbenchPage page = viewer.getSite().getPage();
- IEditorReference[] editorRefs = page.getEditorReferences();
-
- for (int i = 0; i < editorRefs.length; i++) {
- final IEditorPart part = editorRefs[i].getEditor(true);
- if(part != null) {
- IEditorInput input = part.getEditorInput();
- if(part != null && input instanceof SyncInfoCompareInput) {
- SyncInfo inputInfo = ((SyncInfoCompareInput)input).getSyncInfo();
- if(inputInfo.getLocal().equals(resource)) {
- viewer.getSite().getShell().getDisplay().asyncExec(new Runnable() {
- public void run() {
- page.closeEditor(part, true /*save changes if required */);
+ public static void closeCompareEditorFor(final SyncViewer viewer, final IResource resource) {
+ viewer.getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ IWorkbenchPage page = viewer.getSite().getPage();
+ IEditorReference[] editorRefs = page.getEditorReferences();
+
+ for (int i = 0; i < editorRefs.length; i++) {
+ final IEditorPart part = editorRefs[i].getEditor(false /* don't restore editor */);
+ if(part != null) {
+ IEditorInput input = part.getEditorInput();
+ if(part != null && input instanceof SyncInfoCompareInput) {
+ SyncInfo inputInfo = ((SyncInfoCompareInput)input).getSyncInfo();
+ if(inputInfo.getLocal().equals(resource)) {
+ page.closeEditor(part, true /*save changes if required */);
}
- });
+ }
}
}
}
- }
+ });
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SubscriberInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SubscriberInput.java
index ee8ce2017..c779456f4 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SubscriberInput.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SubscriberInput.java
@@ -17,6 +17,7 @@ import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.TeamSubscriber;
+import org.eclipse.team.internal.core.Assert;
import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.ui.TeamUI;
@@ -42,15 +43,10 @@ public class SubscriberInput implements IPropertyChangeListener {
*/
private SyncSetInputFromSyncSet filteredInput;
- /*
- * The subscriber
- */
- private TeamSubscriber subscriber;
-
SubscriberInput(TeamSubscriber subscriber) {
- this.subscriber = subscriber;
- subscriberInput = new SyncSetInputFromSubscriberWorkingSet();
- filteredInput = new SyncSetInputFromSyncSet();
+ Assert.isNotNull(subscriber);
+ subscriberInput = new SyncSetInputFromSubscriberWorkingSet(subscriber);
+ filteredInput = new SyncSetInputFromSyncSet();
TeamUI.addPropertyChangeListener(this);
}
@@ -61,7 +57,7 @@ public class SubscriberInput implements IPropertyChangeListener {
public void prepareInput(IProgressMonitor monitor) throws TeamException {
monitor.beginTask(null, 100);
try {
- subscriberInput.setSubscriber(getSubscriber(), Policy.subMonitorFor(monitor, 70));
+ subscriberInput.initialize(Policy.subMonitorFor(monitor, 70));
filteredInput.setInputSyncSet(subscriberInput.getSyncSet(), Policy.subMonitorFor(monitor, 30));
} finally {
monitor.done();
@@ -69,7 +65,7 @@ public class SubscriberInput implements IPropertyChangeListener {
}
public TeamSubscriber getSubscriber() {
- return subscriber;
+ return subscriberInput.getSubscriber();
}
public SyncSet getFilteredSyncSet() {
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetInputFromSubscriber.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetInputFromSubscriber.java
index abedb344b..bfbbcd3e5 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetInputFromSubscriber.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetInputFromSubscriber.java
@@ -34,28 +34,35 @@ import org.eclipse.team.internal.ui.TeamUIPlugin;
public class SyncSetInputFromSubscriber extends SyncSetInput implements IResourceChangeListener, ITeamResourceChangeListener {
private TeamSubscriber subscriber;
+ private boolean connected = false;
- private void connect(TeamSubscriber s) {
- if (this.subscriber != null) return;
- this.subscriber = s;
- ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
- s.addListener(this);
+ private void connect() {
+ if(! connected) {
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
+ subscriber.addListener(this);
+ connected = true;
+ }
}
public void disconnect() {
- if (subscriber == null) return;
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
- subscriber.removeListener(this);
- subscriber = null;
+ if(connected) {
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+ subscriber.removeListener(this);
+ connected = false;
+ }
}
- /**
- * @return
- */
public TeamSubscriber getSubscriber() {
return subscriber;
}
+ public void setSubscriber(TeamSubscriber subscriber) {
+ if(this.subscriber != null) {
+ disconnect();
+ }
+ this.subscriber = subscriber;
+ }
+
/**
* This method changes the subscriber the input is obtained from.
* This method may be long running as the sync state of several resources
@@ -63,9 +70,8 @@ public class SyncSetInputFromSubscriber extends SyncSetInput implements IResour
*
* @param subscriber
*/
- public void setSubscriber(TeamSubscriber subscriber, IProgressMonitor monitor) throws TeamException {
- if (subscriber != null) disconnect();
- connect(subscriber);
+ public void initialize(IProgressMonitor monitor) throws TeamException {
+ connect();
reset(monitor);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetInputFromSubscriberWorkingSet.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetInputFromSubscriberWorkingSet.java
index 84f4c5050..ffa8e793b 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetInputFromSubscriberWorkingSet.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/sync/views/SyncSetInputFromSubscriberWorkingSet.java
@@ -20,6 +20,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.subscribers.TeamSubscriber;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.ui.IWorkingSet;
@@ -30,6 +31,10 @@ public class SyncSetInputFromSubscriberWorkingSet extends SyncSetInputFromSubscr
private IWorkingSet workingSet;
+ public SyncSetInputFromSubscriberWorkingSet(TeamSubscriber subscriber) {
+ setSubscriber(subscriber);
+ }
+
/* (non-Javadoc)
* @see org.eclipse.team.internal.ui.sync.views.SyncSetInputFromSubscriber#collect(org.eclipse.core.resources.IResource, org.eclipse.core.runtime.IProgressMonitor)
*/

Back to the top