Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2006-01-26 02:49:47 +0000
committerMichael Valenta2006-01-26 02:49:47 +0000
commit38e69104597b020f62550b28cd0a9d6f8d7d2a94 (patch)
treef7d640ba3bb6be28b7375d3002352c674da926c0
parentc8d3be2990aa58195a82056dee60e3d22d40f460 (diff)
downloadeclipse.platform.team-38e69104597b020f62550b28cd0a9d6f8d7d2a94.tar.gz
eclipse.platform.team-38e69104597b020f62550b28cd0a9d6f8d7d2a94.tar.xz
eclipse.platform.team-38e69104597b020f62550b28cd0a9d6f8d7d2a94.zip
Added refresh to the model sync
-rw-r--r--bundles/org.eclipse.team.cvs.ui/plugin.xml2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java11
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CommonViewerAdvisor.java1
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelSynchronizePage.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/RefreshResourceMappingParticipantJob.java71
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceMappingCheckinOperation.java95
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceMappingLoadOperation.java63
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureSynchronizeScheduleComposite.java6
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshEvent.java16
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshable.java25
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshChangeListener.java18
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshEvent.java24
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshModelParticipantJob.java81
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob.java61
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshSubscriberParticipantJob.java21
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java50
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberRefreshSchedule.java44
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefreshActionContribution.java97
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ResourceMappingSynchronizeParticipant.java151
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeParticipant.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipant.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SubscriberParticipant.java36
22 files changed, 512 insertions, 373 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.xml b/bundles/org.eclipse.team.cvs.ui/plugin.xml
index 775fa8dd3..750e40c80 100644
--- a/bundles/org.eclipse.team.cvs.ui/plugin.xml
+++ b/bundles/org.eclipse.team.cvs.ui/plugin.xml
@@ -79,7 +79,7 @@
allowsPlatformContributions="false"
id="org.eclipse.team.cvs.ui.workspaceSynchronizationMenu">
<insertionPoint name="file"/>
- <insertionPoint name="edit"/>
+ <insertionPoint name="edit" separator="true"/>
<insertionPoint name="synchronize"/>
<insertionPoint
name="navigate"
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java
index 22ae2a7af..239aa6019 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java
@@ -759,4 +759,15 @@ public class Utils {
}
return null;
}
+
+ public static ResourceMapping[] getResourceMappings(Object[] objects) {
+ List result = new ArrayList();
+ for (int i = 0; i < objects.length; i++) {
+ Object object = objects[i];
+ ResourceMapping mapping = getResourceMapping(object);
+ if (mapping != null)
+ result.add(mapping);
+ }
+ return (ResourceMapping[]) result.toArray(new ResourceMapping[result.size()]);
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CommonViewerAdvisor.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CommonViewerAdvisor.java
index 3ea874191..bb64011af 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CommonViewerAdvisor.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/CommonViewerAdvisor.java
@@ -103,6 +103,7 @@ public class CommonViewerAdvisor extends AbstractTreeViewerAdvisor implements IN
dlp.setDecorationContext(decorationContext);
}
viewer.setInput(getInitialInput());
+ viewer.expandToLevel(2);
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelSynchronizePage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelSynchronizePage.java
index f4ba3cf83..8cba6452f 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelSynchronizePage.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ModelSynchronizePage.java
@@ -13,6 +13,7 @@ package org.eclipse.team.internal.ui.mapping;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.team.core.mapping.ISynchronizationContext;
import org.eclipse.team.internal.ui.synchronize.*;
+import org.eclipse.team.internal.ui.synchronize.actions.RefreshActionContribution;
import org.eclipse.team.ui.operations.ResourceMappingSynchronizeParticipant;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
@@ -41,9 +42,7 @@ public class ModelSynchronizePage extends AbstractSynchronizePage {
configuration.setComparisonType(isThreeWay()
? ISynchronizePageConfiguration.THREE_WAY
: ISynchronizePageConfiguration.TWO_WAY);
- // TODO: This is a hack to get something working
- //configuration.setProperty(ISynchronizePageConfiguration.P_SYNC_INFO_SET, new SyncInfoTree());
- //configuration.setProperty(SynchronizePageConfiguration.P_WORKING_SET_SYNC_INFO_SET, new SyncInfoTree());
+ configuration.addActionContribution(new RefreshActionContribution());
}
private boolean isThreeWay() {
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/RefreshResourceMappingParticipantJob.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/RefreshResourceMappingParticipantJob.java
deleted file mode 100644
index 456818e8a..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/RefreshResourceMappingParticipantJob.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ui.mapping;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.mapping.ResourceTraversal;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.core.diff.*;
-import org.eclipse.team.core.mapping.ISynchronizationContext;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.team.internal.ui.synchronize.*;
-import org.eclipse.team.ui.operations.ResourceMappingSynchronizeParticipant;
-
-public class RefreshResourceMappingParticipantJob extends RefreshParticipantJob {
-
- public RefreshResourceMappingParticipantJob(ResourceMappingSynchronizeParticipant participant, String jobName, String taskName, IResource[] resources, IRefreshSubscriberListener listener) {
- super(participant, jobName, taskName, resources, listener);
- }
-
- protected void doRefresh(RefreshChangeListener changeListener, IProgressMonitor monitor) throws CoreException {
- // TODO Auto-generated method stub
- ISynchronizationContext context = ((ResourceMappingSynchronizeParticipant)getParticipant()).getContext();
- IDiffChangeListener listener = null;
- try {
- context.getDiffTree().addDiffChangeListener(listener);
- context.refresh(getTraversals(), IResource.NONE, monitor);
- } finally {
- context.getDiffTree().removeDiffChangeListener(listener);
- }
- }
-
- private ResourceTraversal[] getTraversals() {
- // TODO Auto-generated method stub
- return null;
- }
-
- protected int getChangeCount() {
- ISynchronizationContext context = ((ResourceMappingSynchronizeParticipant)getParticipant()).getContext();
- try {
- context.getDiffTree().accept(new IDiffVisitor() {
- public boolean visit(IDiffNode delta) throws CoreException {
- // TODO Auto-generated method stub
- return false;
- }
- }, getTraversals());
- } catch (CoreException e) {
- TeamUIPlugin.log(e);
- }
- return 0;
- }
-
- protected void handleProgressGroupSet(IProgressMonitor group) {
- // TODO Auto-generated method stub
-
- }
-
- protected RefreshChangeListener getChangeListener() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceMappingCheckinOperation.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceMappingCheckinOperation.java
deleted file mode 100644
index c5a60d7a7..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceMappingCheckinOperation.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ui.mapping;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.mapping.ResourceMapping;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.ui.operations.ResourceMappingOperation;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * The check-in operation needs to delegate the check-in to the
- * repository tooling somehow. The things we can do up front is to
- * adjust the input using the participants. TO do this, we need the
- * resource mapping context of the check-in.
- * <p>
- * Another thing we could potentially do is display a model diff
- * tree that shows the outgoing changes. This would need to be
- * integrated with the repository tooling check-in UI artifacts
- * (e.g. commit comment).
- *
- * The steps of a check-in operation are:
- * <ol>
- * <li>Obtain the selection to be operated on.
- * <li>Determine the projection of the selection onto resources
- * using resource mappings and traversals.
- * <ul>
- * <li>this will require traversals from ancestor
- * <li>may require traversals from remote for conflict notification
- * </ul>
- * <li>Ensure that all affected mappings are known
- * <ul>
- * <li>additional mappings may be included due to resource project
- * (i.e. many-to-one case).
- * <li>notify users of additional mappings that will be affected.
- * <li>this list must include locally modified model elements including
- * deletions.
- * <li>the list could also indicate remote changes that will cause the commit
- * to fail
- * </ul>
- * <li>Prompt the user for additional information required by check-in
- * (e.g. comment)
- * <ul>
- * <li>This may show model elements being included in the commit
- * <li>Could also show sync state and support merging
- * <li>Could if support exclusion of model elements? This would be complicated.
- * </ul>
- * <li>Perform the check-in on the resources
- * </ol>
- * <p>
- * Special case involving sub-file elements.
- * <ul>
- * <li>Level 1: prompt to indicate that the check-in will include
- * additional elements (Need a way to detect this is the case).
- * <li>Level 2: prompt to display the additional elements. A participant
- * can provide the elements but they need to be able to include deletions.
- * Display could be a flat list that makes use of Generic Navigator type API.
- * <li>Level 3: Display diff tree and highlight the additional elements.
- * Need to be able to identify and highlight the additional elements.
- * </ul>
- * One way to handle this would be to delegate the prompt to the model provider.
- * That is, collect the resource mappings involved and ask the model provider
- * to indicate to the user what additional resource mappings will be operated
- * on and return an adjusted list.
- *
- * <p>
- * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
- * part of a work in progress. There is a guarantee neither that this API will
- * work nor that it will remain the same. Please do not use this API without
- * consulting with the Platform/Team team.
- * </p>
- *
- * @since 3.2
- */
-public abstract class ResourceMappingCheckinOperation extends ResourceMappingOperation {
-
- protected ResourceMappingCheckinOperation(IWorkbenchPart part, ResourceMapping[] selectedMappings) {
- super(part, selectedMappings);
- }
-
- protected void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceMappingLoadOperation.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceMappingLoadOperation.java
deleted file mode 100644
index 3dfbf5488..000000000
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/mapping/ResourceMappingLoadOperation.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ui.mapping;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.mapping.ResourceMapping;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.team.ui.operations.ResourceMappingOperation;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * The steps of an load (replace with version or branch) operation are:
- * <ol>
- * <li>Obtain the selection to be operated on.
- * <li>Determine the projection of the selection onto resources
- * using resource mappings and traversals.
- * <ul>
- * <li>this will require traversal of remote only
- * </ul>
- * <li>Ensure that all affected mappings are known
- * <ul>
- * <li>additional mappings may be included due to resource project
- * (i.e. many-to-one case).
- * <li>notify users of additional mappings that will be affected
- * <li>this list must include locally changed model elements whose
- * changes will be lost including any that were deleted.
- * <li>this list could include changed remote elements that
- * will be received including additions
- * </ul>
- * <li>Perform the replace at the resource level
- * </ol>
- *
- * <p>
- * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
- * part of a work in progress. There is a guarantee neither that this API will
- * work nor that it will remain the same. Please do not use this API without
- * consulting with the Platform/Team team.
- * </p>
- *
- * @since 32
- */
-public class ResourceMappingLoadOperation extends ResourceMappingOperation {
-
- protected ResourceMappingLoadOperation(IWorkbenchPart part, ResourceMapping[] selectedMappings) {
- super(part, selectedMappings);
- }
-
- protected void execute(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureSynchronizeScheduleComposite.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureSynchronizeScheduleComposite.java
index 9a5fce7bf..040fe8fb4 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureSynchronizeScheduleComposite.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/ConfigureSynchronizeScheduleComposite.java
@@ -19,7 +19,7 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.Utils;
-import org.eclipse.team.ui.synchronize.SubscriberParticipant;
+import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
/**
* A composite that allows editing a subscriber refresh schedule. A validator can be used to allow
@@ -160,13 +160,13 @@ public class ConfigureSynchronizeScheduleComposite extends Composite {
}
// update schedule
- SubscriberParticipant participant = schedule.getParticipant();
+ ISynchronizeParticipant participant = schedule.getParticipant();
if (!participant.isPinned() && schedule.isEnabled()) {
participant.setPinned(MessageDialog.openQuestion(getShell(),
NLS.bind(TeamUIMessages.ConfigureSynchronizeScheduleComposite_0, new String[] { Utils.getTypeName(participant) }),
NLS.bind(TeamUIMessages.ConfigureSynchronizeScheduleComposite_1, new String[] { Utils.getTypeName(participant) })));
}
- participant.setRefreshSchedule(schedule);
+ schedule.getRefreshable().setRefreshSchedule(schedule);
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshEvent.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshEvent.java
index 279f96603..dcdbd892a 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshEvent.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshEvent.java
@@ -11,9 +11,10 @@
package org.eclipse.team.internal.ui.synchronize;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.team.core.subscribers.Subscriber;
-import org.eclipse.team.core.synchronize.SyncInfo;
+import org.eclipse.team.internal.ui.synchronize.RefreshParticipantJob.IChangeDescription;
import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
/**
@@ -68,11 +69,11 @@ public interface IRefreshEvent {
public ISynchronizeParticipant getParticipant();
/**
- * The changes found during the refresh or an empty list if no changes were found.
+ * Return a description of the changes found.
*
- * @return the changes found during the refresh or an empty list if no changes were found.
+ * @return a description of the changes found
*/
- public SyncInfo[] getChanges();
+ public IChangeDescription getChangeDescription();
/**
* The time, in milliseconds, at which the refresh was started.
@@ -95,11 +96,4 @@ public interface IRefreshEvent {
* @return the status of the refresh operation.
*/
public IStatus getStatus();
-
- /**
- * Returns the list of resources that were refreshed.
- *
- * @return the list of resources that were refreshed.
- */
- public IResource[] getResources();
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshable.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshable.java
new file mode 100644
index 000000000..e777946e0
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/IRefreshable.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize;
+
+import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
+
+public interface IRefreshable {
+
+ public SubscriberRefreshSchedule getRefreshSchedule();
+
+ public void setRefreshSchedule(SubscriberRefreshSchedule schedule);
+
+ public ISynchronizeParticipant getParticipant();
+
+ public RefreshParticipantJob createJob(String refreshInterval);
+
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshChangeListener.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshChangeListener.java
index dcde9ff21..5f53fb75c 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshChangeListener.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshChangeListener.java
@@ -12,18 +12,21 @@ package org.eclipse.team.internal.ui.synchronize;
import java.util.*;
-import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.resources.IResource;
import org.eclipse.team.core.subscribers.ISubscriberChangeEvent;
import org.eclipse.team.core.subscribers.ISubscriberChangeListener;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.synchronize.SyncInfoSet;
import org.eclipse.team.internal.core.subscribers.SubscriberSyncInfoCollector;
+import org.eclipse.team.internal.ui.synchronize.RefreshParticipantJob.IChangeDescription;
-public class RefreshChangeListener implements ISubscriberChangeListener {
+public class RefreshChangeListener implements ISubscriberChangeListener, IChangeDescription {
private List changes = new ArrayList();
private SubscriberSyncInfoCollector collector;
+ private IResource[] resources;
- public RefreshChangeListener(SubscriberSyncInfoCollector collector) {
+ public RefreshChangeListener(IResource[] resources, SubscriberSyncInfoCollector collector) {
+ this.resources = resources;
this.collector = collector;
}
public void subscriberResourceChanged(ISubscriberChangeEvent[] deltas) {
@@ -34,8 +37,7 @@ public class RefreshChangeListener implements ISubscriberChangeListener {
}
}
}
- public SyncInfo[] getChanges(IProgressMonitor monitor) {
- collector.waitForCollector(monitor);
+ public SyncInfo[] getChanges() {
List changedSyncInfos = new ArrayList();
SyncInfoSet set = collector.getSyncInfoSet();
for (Iterator it = changes.iterator(); it.hasNext();) {
@@ -61,4 +63,10 @@ public class RefreshChangeListener implements ISubscriberChangeListener {
private boolean isThreeWay() {
return collector.getSubscriber().getResourceComparator().isThreeWay();
}
+ public int getChangeCount() {
+ return getChanges().length;
+ }
+ public IResource[] getResources() {
+ return resources;
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshEvent.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshEvent.java
index 7d57533fa..68184689c 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshEvent.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshEvent.java
@@ -10,9 +10,9 @@
*******************************************************************************/
package org.eclipse.team.internal.ui.synchronize;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.team.core.synchronize.SyncInfo;
+import org.eclipse.team.internal.ui.synchronize.RefreshParticipantJob.IChangeDescription;
import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
/**
@@ -24,26 +24,18 @@ public class RefreshEvent implements IRefreshEvent {
long startTime = 0;
long stopTime = 0;
IStatus status;
- IResource[] resources;
private final ISynchronizeParticipant participant;
+ private final IChangeDescription description;
- public RefreshEvent(int type, IResource[] resources, ISynchronizeParticipant participant) {
+ public RefreshEvent(int type, ISynchronizeParticipant participant, IChangeDescription description) {
this.type = type;
- this.resources = resources;
this.participant = participant;
+ this.description = description;
}
public int getRefreshType() {
return type;
}
-
- public SyncInfo[] getChanges() {
- return changes != null ? changes : new SyncInfo[0];
- }
-
- public void setChanges(SyncInfo[] changes) {
- this.changes = changes;
- }
public long getStartTime() {
return startTime;
@@ -69,11 +61,11 @@ public class RefreshEvent implements IRefreshEvent {
this.status = status;
}
- public IResource[] getResources() {
- return resources;
- }
-
public ISynchronizeParticipant getParticipant() {
return participant;
}
+
+ public IChangeDescription getChangeDescription() {
+ return description;
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshModelParticipantJob.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshModelParticipantJob.java
new file mode 100644
index 000000000..8af058b14
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshModelParticipantJob.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.*;
+import org.eclipse.team.core.diff.*;
+import org.eclipse.team.core.mapping.ISynchronizationContext;
+import org.eclipse.team.ui.operations.ResourceMappingSynchronizeParticipant;
+import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
+
+public class RefreshModelParticipantJob extends RefreshParticipantJob {
+
+ public class ChangeDescription implements IChangeDescription, IDiffChangeListener {
+
+ Map changes = new HashMap();
+
+ public int getChangeCount() {
+ return changes.size();
+ }
+
+ public void diffChanged(IDiffChangeEvent event, IProgressMonitor monitor) {
+ IDiffNode[] additions = event.getAdditions();
+ for (int i = 0; i < additions.length; i++) {
+ IDiffNode node = additions[i];
+ changes.put(node.getPath(), node);
+ }
+ IDiffNode[] changed = event.getChanges();
+ for (int i = 0; i < changed.length; i++) {
+ IDiffNode node = changed[i];
+ changes.put(node.getPath(), node);
+ }
+ }
+ }
+
+ public RefreshModelParticipantJob(ISynchronizeParticipant participant, String jobName, String taskName, IRefreshSubscriberListener listener) {
+ super(participant, jobName, taskName, listener);
+ }
+
+ protected void doRefresh(IChangeDescription changeListener,
+ IProgressMonitor monitor) throws CoreException {
+ ISynchronizationContext context = ((ResourceMappingSynchronizeParticipant)getParticipant()).getContext();
+ try {
+ context.getDiffTree().addDiffChangeListener((ChangeDescription)changeListener);
+ // TODO: finer grained refresh
+ context.refresh(context.getScope().getMappings(), monitor);
+ // Wait for any asynchronous updating to complete
+ try {
+ Platform.getJobManager().join(context, monitor);
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+ } finally {
+ context.getDiffTree().removeDiffChangeListener((ChangeDescription)changeListener);
+ }
+ }
+
+ protected int getChangeCount() {
+ return ((ResourceMappingSynchronizeParticipant)getParticipant()).getContext().getDiffTree().size();
+ }
+
+ protected void handleProgressGroupSet(IProgressMonitor group) {
+ // TODO Auto-generated method stub
+
+ }
+
+ protected IChangeDescription createChangeDescription() {
+ return new ChangeDescription();
+ }
+
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob.java
index 382699421..5c19fc592 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob.java
@@ -13,7 +13,6 @@ package org.eclipse.team.internal.ui.synchronize;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.*;
@@ -23,7 +22,6 @@ import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.subscribers.Subscriber;
-import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.internal.ui.*;
import org.eclipse.team.ui.synchronize.*;
import org.eclipse.ui.actions.ActionFactory;
@@ -45,7 +43,6 @@ import org.eclipse.ui.progress.UIJob;
*/
public abstract class RefreshParticipantJob extends Job {
- private final static boolean TEST_PROGRESS_VIEW = false;
/**
* Uniquely identifies this type of job. This is used for cancellation.
*/
@@ -65,11 +62,6 @@ public abstract class RefreshParticipantJob extends Job {
* The schedule delay used when rescheduling a completed job
*/
private static long scheduleDelay;
-
- /**
- * The subscribers and resources to refresh.
- */
- private IResource[] resources;
/**
* The participant that is being refreshed.
@@ -217,6 +209,10 @@ public abstract class RefreshParticipantJob extends Job {
}
}
+ public static interface IChangeDescription {
+ int getChangeCount();
+ }
+
/**
* Create a job to refresh the specified resources with the subscriber.
*
@@ -225,12 +221,9 @@ public abstract class RefreshParticipantJob extends Job {
* @param resources
* @param subscriber
*/
- public RefreshParticipantJob(ISynchronizeParticipant participant, String jobName, String taskName, IResource[] resources, IRefreshSubscriberListener listener) {
+ public RefreshParticipantJob(ISynchronizeParticipant participant, String jobName, String taskName, IRefreshSubscriberListener listener) {
super(taskName);
- Assert.isNotNull(resources);
Assert.isNotNull(participant);
- Assert.isNotNull(resources);
- this.resources = resources;
this.participant = participant;
this.taskName = jobName;
setPriority(Job.DECORATE);
@@ -297,16 +290,11 @@ public abstract class RefreshParticipantJob extends Job {
}
Policy.checkCanceled(monitor);
}
- IResource[] roots = getResources();
- // if there are no resources to refresh, just return
- if(roots == null) {
- return Status.OK_STATUS;
- }
- RefreshEvent event = new RefreshEvent(reschedule ? IRefreshEvent.SCHEDULED_REFRESH : IRefreshEvent.USER_REFRESH, roots, participant);
+ IChangeDescription changeDescription = createChangeDescription();
+ RefreshEvent event = new RefreshEvent(reschedule ? IRefreshEvent.SCHEDULED_REFRESH : IRefreshEvent.USER_REFRESH, participant, changeDescription);
IStatus status = null;
NonblockingProgressMonitor wrappedMonitor = null;
- RefreshChangeListener changeListener = getChangeListener();
try {
event.setStartTime(System.currentTimeMillis());
if(monitor.isCanceled()) {
@@ -317,7 +305,7 @@ public abstract class RefreshParticipantJob extends Job {
// Perform the refresh
monitor.setTaskName(getName());
wrappedMonitor = new NonblockingProgressMonitor(monitor, this);
- doRefresh(changeListener, wrappedMonitor);
+ doRefresh(changeDescription, wrappedMonitor);
// Prepare the results
setProperty(IProgressConstants.KEEPONE_PROPERTY, Boolean.valueOf(! isJobModal()));
} catch(OperationCanceledException e2) {
@@ -336,15 +324,13 @@ public abstract class RefreshParticipantJob extends Job {
// Determine the status to be returned and the GOTO action
status = e.getStatus();
if (!isUser()) {
- if (!TEST_PROGRESS_VIEW) {
- // Use the GOTO action to show the error and return OK
- Object prop = getProperty(IProgressConstants.ACTION_PROPERTY);
- if (prop instanceof GotoActionWrapper) {
- GotoActionWrapper wrapper = (GotoActionWrapper)prop;
- wrapper.setStatus(e.getStatus());
- status = new Status(IStatus.OK, TeamUIPlugin.ID, IStatus.OK, e.getStatus().getMessage(), e);
- }
- }
+ // Use the GOTO action to show the error and return OK
+ Object prop = getProperty(IProgressConstants.ACTION_PROPERTY);
+ if (prop instanceof GotoActionWrapper) {
+ GotoActionWrapper wrapper = (GotoActionWrapper)prop;
+ wrapper.setStatus(e.getStatus());
+ status = new Status(IStatus.OK, TeamUIPlugin.ID, IStatus.OK, e.getStatus().getMessage(), e);
+ }
}
if (!isUser() && status.getSeverity() == IStatus.ERROR) {
// Never prompt for errors on non-user jobs
@@ -355,7 +341,6 @@ public abstract class RefreshParticipantJob extends Job {
}
// Post-Notify
- event.setChanges(changeListener.getChanges(monitor));
if (status == null) {
status = calculateStatus(event);
}
@@ -368,7 +353,7 @@ public abstract class RefreshParticipantJob extends Job {
}
}
- protected abstract void doRefresh(RefreshChangeListener changeListener, IProgressMonitor monitor) throws CoreException;
+ protected abstract void doRefresh(IChangeDescription changeListener, IProgressMonitor monitor) throws CoreException;
/**
* Return the total number of changes covered by the resources
@@ -394,14 +379,14 @@ public abstract class RefreshParticipantJob extends Job {
private IStatus calculateStatus(IRefreshEvent event) {
StringBuffer text = new StringBuffer();
int code = IStatus.OK;
- SyncInfo[] changes = event.getChanges();
+ int changeCount = event.getChangeDescription().getChangeCount();
int numChanges = getChangeCount();
if (numChanges > 0) {
code = IRefreshEvent.STATUS_CHANGES;
- if (changes.length > 0) {
+ if (changeCount > 0) {
// New changes found
- String numNewChanges = Integer.toString(event.getChanges().length);
- if (event.getChanges().length == 1) {
+ String numNewChanges = Integer.toString(changeCount);
+ if (changeCount == 1) {
text.append(NLS.bind(TeamUIMessages.RefreshCompleteDialog_newChangesSingular, (new Object[]{getName(), numNewChanges})));
} else {
text.append(NLS.bind(TeamUIMessages.RefreshCompleteDialog_newChangesPlural, (new Object[]{getName(), numNewChanges})));
@@ -475,11 +460,7 @@ public abstract class RefreshParticipantJob extends Job {
protected abstract void handleProgressGroupSet(IProgressMonitor group);
- protected abstract RefreshChangeListener getChangeListener();
-
- protected IResource[] getResources() {
- return resources;
- }
+ protected abstract IChangeDescription createChangeDescription();
public long getScheduleDelay() {
return scheduleDelay;
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshSubscriberParticipantJob.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshSubscriberParticipantJob.java
index 22fb2bda3..11cfc01fa 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshSubscriberParticipantJob.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshSubscriberParticipantJob.java
@@ -21,8 +21,11 @@ import org.eclipse.team.ui.synchronize.SubscriberParticipant;
public class RefreshSubscriberParticipantJob extends RefreshParticipantJob {
+ private final IResource[] resources;
+
public RefreshSubscriberParticipantJob(SubscriberParticipant participant, String jobName, String taskName, IResource[] resources, IRefreshSubscriberListener listener) {
- super(participant, jobName, taskName, resources, listener);
+ super(participant, jobName, taskName, listener);
+ this.resources = resources;
}
/* (non-Javadoc)
@@ -39,7 +42,6 @@ public class RefreshSubscriberParticipantJob extends RefreshParticipantJob {
protected int getChangeCount() {
int numChanges = 0;
SubscriberSyncInfoCollector collector = getCollector();
- IResource[] resources = getResources();
if (collector != null) {
SyncInfoTree set = collector.getSyncInfoSet();
for (int i = 0; i < resources.length; i++) {
@@ -53,8 +55,8 @@ public class RefreshSubscriberParticipantJob extends RefreshParticipantJob {
return numChanges;
}
- protected RefreshChangeListener getChangeListener() {
- return new RefreshChangeListener(getCollector());
+ protected RefreshParticipantJob.IChangeDescription createChangeDescription() {
+ return new RefreshChangeListener(resources, getCollector());
}
protected void handleProgressGroupSet(IProgressMonitor group) {
@@ -67,7 +69,7 @@ public class RefreshSubscriberParticipantJob extends RefreshParticipantJob {
*/
public boolean shouldRun() {
// Ensure that any progress shown as a result of this refresh occurs hidden in a progress group.
- return getSubscriber() != null;
+ return getSubscriber() != null && getCollector().getSyncInfoSet() != null;
}
public boolean belongsTo(Object family) {
@@ -77,14 +79,15 @@ public class RefreshSubscriberParticipantJob extends RefreshParticipantJob {
return super.belongsTo(family);
}
- protected void doRefresh(RefreshChangeListener changeListener, IProgressMonitor monitor) throws TeamException {
+ protected void doRefresh(IChangeDescription changeListener, IProgressMonitor monitor) throws TeamException {
Subscriber subscriber = getSubscriber();
if (subscriber != null) {
try {
- subscriber.addListener(changeListener);
- subscriber.refresh(getResources(), IResource.DEPTH_INFINITE, monitor);
+ subscriber.addListener((RefreshChangeListener)changeListener);
+ subscriber.refresh(resources, IResource.DEPTH_INFINITE, monitor);
+ getCollector().waitForCollector(monitor);
} finally {
- subscriber.removeListener(changeListener);
+ subscriber.removeListener((RefreshChangeListener)changeListener);
}
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java
index 7fa0ee9c4..de420211a 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/RefreshUserNotificationPolicy.java
@@ -19,8 +19,7 @@ import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.internal.ui.*;
import org.eclipse.team.internal.ui.synchronize.actions.OpenInCompareAction;
import org.eclipse.team.ui.TeamUI;
-import org.eclipse.team.ui.synchronize.ISynchronizeView;
-import org.eclipse.team.ui.synchronize.SubscriberParticipant;
+import org.eclipse.team.ui.synchronize.*;
import org.eclipse.ui.actions.ActionFactory;
/**
@@ -28,9 +27,9 @@ import org.eclipse.ui.actions.ActionFactory;
*/
public class RefreshUserNotificationPolicy implements IRefreshSubscriberListener {
- private SubscriberParticipant participant;
+ private ISynchronizeParticipant participant;
- public RefreshUserNotificationPolicy(SubscriberParticipant participant) {
+ public RefreshUserNotificationPolicy(ISynchronizeParticipant participant) {
this.participant = participant;
}
@@ -66,23 +65,7 @@ public class RefreshUserNotificationPolicy implements IRefreshSubscriberListener
public void run() {
boolean prompt = (event.getStatus().getCode() == IRefreshEvent.STATUS_NO_CHANGES);
- SyncInfo[] infos = event.getChanges();
- List selectedResources = new ArrayList();
- selectedResources.addAll(Arrays.asList(event.getResources()));
- for (int i = 0; i < infos.length; i++) {
- selectedResources.add(infos[i].getLocal());
- }
- IResource[] resources = (IResource[]) selectedResources.toArray(new IResource[selectedResources.size()]);
-
- // If it's a file, simply show the compare editor
- if (resources.length == 1 && resources[0].getType() == IResource.FILE) {
- IResource file = resources[0];
- SyncInfo info = participant.getSubscriberSyncInfoCollector().getSyncInfoSet().getSyncInfo(file);
- if(info != null) {
- OpenInCompareAction.openCompareEditor(participant, info, false /* do not keep focus */, null);
- prompt = false;
- }
- }
+ prompt = handleRefreshDone(event, prompt);
// Prompt user if preferences are set for this type of refresh.
if (prompt) {
@@ -113,4 +96,29 @@ public class RefreshUserNotificationPolicy implements IRefreshSubscriberListener
}
});
}
+
+ protected boolean handleRefreshDone(final IRefreshEvent event, boolean prompt) {
+ if (participant instanceof SubscriberParticipant) {
+ SubscriberParticipant sp = (SubscriberParticipant) participant;
+ SyncInfo[] infos = ((RefreshChangeListener)event.getChangeDescription()).getChanges();
+ List selectedResources = new ArrayList();
+ selectedResources.addAll(Arrays.asList(((RefreshChangeListener)event.getChangeDescription()).getResources()));
+ for (int i = 0; i < infos.length; i++) {
+ selectedResources.add(infos[i].getLocal());
+ }
+ IResource[] resources = (IResource[]) selectedResources.toArray(new IResource[selectedResources.size()]);
+
+ // If it's a file, simply show the compare editor
+ if (resources.length == 1 && resources[0].getType() == IResource.FILE) {
+ IResource file = resources[0];
+ SyncInfo info = sp.getSubscriberSyncInfoCollector().getSyncInfoSet().getSyncInfo(file);
+ if(info != null) {
+ OpenInCompareAction.openCompareEditor(participant, info, false /* do not keep focus */, null);
+ prompt = false;
+ }
+ }
+ }
+ // TODO: Implement one change case for model participant
+ return prompt;
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberRefreshSchedule.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberRefreshSchedule.java
index 802aee726..2dbe7bc98 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberRefreshSchedule.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SubscriberRefreshSchedule.java
@@ -12,13 +12,12 @@ package org.eclipse.team.internal.ui.synchronize;
import java.text.DateFormat;
import java.util.Date;
+
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.core.synchronize.SyncInfoSet;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.team.ui.synchronize.SubscriberParticipant;
+import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.actions.ActionFactory;
@@ -35,7 +34,7 @@ public class SubscriberRefreshSchedule {
private RefreshParticipantJob job;
- private SubscriberParticipant participant;
+ private IRefreshable refreshable;
private IRefreshEvent lastRefreshEvent;
@@ -53,10 +52,10 @@ public class SubscriberRefreshSchedule {
public void refreshStarted(IRefreshEvent event) {
}
public ActionFactory.IWorkbenchAction refreshDone(final IRefreshEvent event) {
- if (event.getParticipant() == participant) {
+ if (event.getParticipant() == refreshable) {
lastRefreshEvent = event;
if(enabled && event.getRefreshType() == IRefreshEvent.SCHEDULED_REFRESH) {
- RefreshUserNotificationPolicy policy = new RefreshUserNotificationPolicy(participant);
+ RefreshUserNotificationPolicy policy = new RefreshUserNotificationPolicy(refreshable.getParticipant());
policy.refreshDone(event);
}
}
@@ -65,8 +64,8 @@ public class SubscriberRefreshSchedule {
};
- public SubscriberRefreshSchedule(SubscriberParticipant participant) {
- this.participant = participant;
+ public SubscriberRefreshSchedule(IRefreshable refreshable) {
+ this.refreshable = refreshable;
RefreshParticipantJob.addRefreshListener(refreshSubscriberListener);
}
@@ -99,8 +98,8 @@ public class SubscriberRefreshSchedule {
return refreshInterval;
}
- public SubscriberParticipant getParticipant() {
- return participant;
+ public ISynchronizeParticipant getParticipant() {
+ return refreshable.getParticipant();
}
/**
@@ -117,13 +116,8 @@ public class SubscriberRefreshSchedule {
}
public void startJob() {
- SyncInfoSet set = participant.getSubscriberSyncInfoCollector().getSyncInfoSet();
- if(set == null) {
- return;
- }
if(job == null) {
- SubscriberParticipant participant = getParticipant();
- job = new RefreshSubscriberParticipantJob(participant, TeamUIMessages.RefreshSchedule_14, NLS.bind(TeamUIMessages.RefreshSchedule_15, new String[] { participant.getName(), getRefreshIntervalAsString() }), participant.getResources(), new RefreshUserNotificationPolicy(getParticipant()));
+ job = refreshable.createJob(getRefreshIntervalAsString());
job.setUser(false);
} else if(job.getState() != Job.NONE){
stopJob();
@@ -154,8 +148,8 @@ public class SubscriberRefreshSchedule {
memento.putInteger(CTX_REFRESHSCHEDULE_INTERVAL, (int)refreshInterval);
}
- public static SubscriberRefreshSchedule init(IMemento memento, SubscriberParticipant participant) {
- SubscriberRefreshSchedule schedule = new SubscriberRefreshSchedule(participant);
+ public static SubscriberRefreshSchedule init(IMemento memento, IRefreshable refreshable) {
+ SubscriberRefreshSchedule schedule = new SubscriberRefreshSchedule(refreshable);
if(memento != null) {
String enabled = memento.getString(CTX_REFRESHSCHEDULE_ENABLED);
int interval = memento.getInteger(CTX_REFRESHSCHEDULE_INTERVAL).intValue();
@@ -178,13 +172,13 @@ public class SubscriberRefreshSchedule {
Date lastTimeRun = new Date(stopMills);
text.append(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(lastTimeRun));
}
- SyncInfo[] changes = event.getChanges();
- if (changes.length == 0) {
+ int changeCount = event.getChangeDescription().getChangeCount();
+ if (changeCount == 0) {
text.append(TeamUIMessages.RefreshSchedule_7);
- } else if (changes.length == 1) {
- text.append(NLS.bind(TeamUIMessages.RefreshSchedule_changesSingular, new String[] { Integer.toString(changes.length) }));
+ } else if (changeCount == 1) {
+ text.append(NLS.bind(TeamUIMessages.RefreshSchedule_changesSingular, new String[] { Integer.toString(changeCount) }));
} else {
- text.append(NLS.bind(TeamUIMessages.RefreshSchedule_changesPlural, new String[] { Integer.toString(changes.length) }));
+ text.append(NLS.bind(TeamUIMessages.RefreshSchedule_changesPlural, new String[] { Integer.toString(changeCount) }));
}
return text.toString();
}
@@ -212,4 +206,8 @@ public class SubscriberRefreshSchedule {
}
return NLS.bind(TeamUIMessages.RefreshSchedule_13, new String[] { Long.toString(minutes), unit });
}
+
+ public IRefreshable getRefreshable() {
+ return refreshable;
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefreshActionContribution.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefreshActionContribution.java
new file mode 100644
index 000000000..182a7c2d0
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/actions/RefreshActionContribution.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.actions;
+
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.team.internal.ui.Utils;
+import org.eclipse.team.internal.ui.synchronize.ConfigureRefreshScheduleDialog;
+import org.eclipse.team.internal.ui.synchronize.IRefreshable;
+import org.eclipse.team.ui.operations.ResourceMappingSynchronizeParticipant;
+import org.eclipse.team.ui.synchronize.*;
+import org.eclipse.ui.IActionBars;
+
+public class RefreshActionContribution extends SynchronizePageActionGroup {
+ // the changes viewer are contributed via the viewer and not the page.
+ private Action configureSchedule;
+ private Action refreshSelectionAction;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.IActionContribution#initialize(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration)
+ */
+ public void initialize(final ISynchronizePageConfiguration configuration) {
+ super.initialize(configuration);
+ final ISynchronizePageSite site = configuration.getSite();
+ final ResourceMappingSynchronizeParticipant participant = (ResourceMappingSynchronizeParticipant)configuration.getParticipant();
+ // toolbar
+ if (participant.doesSupportSynchronize()) {
+ refreshSelectionAction = new Action() {
+ public void run() {
+ IStructuredSelection selection = (IStructuredSelection)site.getSelectionProvider().getSelection();
+ ResourceMapping[] mappings = Utils.getResourceMappings(selection.toArray());
+ if (mappings.length == 0) {
+ // Refresh all participant resources
+ mappings = null;
+ }
+ participant.refresh(null, null, null, null, site.getWorkbenchSite());
+ }
+ };
+ Utils.initAction(refreshSelectionAction, "action.refreshWithRemote."); //$NON-NLS-1$
+ refreshSelectionAction.setActionDefinitionId("org.eclipse.team.ui.synchronizeLast"); //$NON-NLS-1$
+ refreshSelectionAction.setId("org.eclipse.team.ui.synchronizeLast"); //$NON-NLS-1$
+
+ Object o = participant.getAdapter(IRefreshable.class);
+ if (o instanceof IRefreshable) {
+ final IRefreshable refreshable = (IRefreshable) o;
+ configureSchedule = new Action() {
+ public void run() {
+ ConfigureRefreshScheduleDialog d = new ConfigureRefreshScheduleDialog(
+ site.getShell(), refreshable.getRefreshSchedule());
+ d.setBlockOnOpen(false);
+ d.open();
+ }
+ };
+ Utils.initAction(configureSchedule, "action.configureSchedulel."); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.IActionContribution#fillContextMenu(org.eclipse.jface.action.IMenuManager)
+ */
+ public void fillContextMenu(IMenuManager manager) {
+ if (findGroup(manager, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP) != null
+ && findGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP) != null) {
+ // Place synchronize with navigate to save space
+ appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, refreshSelectionAction);
+ } else {
+ appendToGroup(manager, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP, refreshSelectionAction);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.IActionContribution#setActionBars(org.eclipse.ui.IActionBars)
+ */
+ public void fillActionBars(IActionBars actionBars) {
+ if(actionBars != null) {
+ // view menu
+ IMenuManager menu = actionBars.getMenuManager();
+ if (findGroup(menu, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP) != null
+ && findGroup(menu, ISynchronizePageConfiguration.PREFERENCES_GROUP) != null) {
+ appendToGroup(menu, ISynchronizePageConfiguration.PREFERENCES_GROUP, configureSchedule);
+ } else {
+ appendToGroup(menu, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP, configureSchedule);
+ }
+ }
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ResourceMappingSynchronizeParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ResourceMappingSynchronizeParticipant.java
index 79c7f1764..fb22dbeff 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ResourceMappingSynchronizeParticipant.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/operations/ResourceMappingSynchronizeParticipant.java
@@ -11,18 +11,22 @@
package org.eclipse.team.ui.operations;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.mapping.IMergeContext;
import org.eclipse.team.core.mapping.ISynchronizationContext;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.team.internal.ui.Utils;
+import org.eclipse.team.internal.ui.*;
import org.eclipse.team.internal.ui.mapping.ModelSynchronizePage;
+import org.eclipse.team.internal.ui.synchronize.*;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.mapping.ICompareAdapter;
import org.eclipse.team.ui.mapping.ISynchronizationConstants;
-import org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant;
-import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
+import org.eclipse.team.ui.synchronize.*;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.part.IPageBookViewPage;
/**
@@ -46,6 +50,8 @@ public class ResourceMappingSynchronizeParticipant extends
private boolean mergingEnabled = true;
+ protected SubscriberRefreshSchedule refreshSchedule;
+
/**
* Create a participant for the given context
* @param context the synchronization context
@@ -61,9 +67,34 @@ public class ResourceMappingSynchronizeParticipant extends
setSecondaryId(Long.toString(System.currentTimeMillis()));
setName(name);
mergingEnabled = context instanceof IMergeContext;
+ refreshSchedule = new SubscriberRefreshSchedule(createRefreshable());
}
/* (non-Javadoc)
+ * @see org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant#getName()
+ */
+ public String getName() {
+ String name = super.getName();
+ return NLS.bind(TeamUIMessages.SubscriberParticipant_namePattern, new String[] { name, getScopeDescription() });
+ }
+
+ private String getScopeDescription() {
+ // TODO Auto-generated method stub
+ return "Model";
+ }
+
+ /**
+ * Return the name of the participant as specified in the plugin manifest file.
+ * This method is provided to give access to this name since it is masked by
+ * the <code>getName()</code> method defined in this class.
+ * @return the name of the participant as specified in the plugin manifest file
+ * @since 3.1
+ */
+ protected final String getShortName() {
+ return super.getName();
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant#initializeConfiguration(org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration)
*/
protected void initializeConfiguration(
@@ -102,10 +133,30 @@ public class ResourceMappingSynchronizeParticipant extends
* @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#run(org.eclipse.ui.IWorkbenchPart)
*/
public void run(IWorkbenchPart part) {
- // TODO
- // getContext().refresh(getContext().getScope().getMappings(), monitor);
+ refresh(getContext().getScope().getMappings(), null, null, null, part != null ? part.getSite() : null);
}
+ /**
+ * Refresh a participant in the background the result of the refresh are shown in the progress view. Refreshing
+ * can also be considered synchronizing, or refreshing the synchronization state. Basically this is a long
+ * running operation that will update the participants sync info sets with new changes detected on the
+ * server. Either or both of the <code>shortTaskName</code> and <code>longTaskName</code> can be <code>null</code>
+ * in which case, the default values for these are returned by the methods <code>getShortTaskName()</code> and
+ * <code>getLongTaskName(IResource[])</code> will be used.
+ *
+ * @param resources the resources to be refreshed.
+ * @param shortTaskName the taskName of the background job that will run the synchronize or <code>null</code>
+ * if the default job name is desired.
+ * @param longTaskName the taskName of the progress monitor running the synchronize or <code>null</code>
+ * if the default job name is desired.
+ * @param site the workbench site the synchronize is running from. This can be used to notify the site
+ * that a job is running.
+ */
+ public final void refresh(ResourceMapping[] mappings, ResourceTraversal[] traversals, String shortTaskName, String longTaskName, IWorkbenchSite site) {
+ IRefreshSubscriberListener listener = new RefreshUserNotificationPolicy(this);
+ internalRefresh(mappings, traversals, shortTaskName, longTaskName, site, listener);
+ }
+
/* (non-Javadoc)
* @see org.eclipse.team.ui.synchronize.ISynchronizeParticipant#dispose()
*/
@@ -179,4 +230,92 @@ public class ResourceMappingSynchronizeParticipant extends
public void setMergingEnabled(boolean mergingEnabled) {
this.mergingEnabled = mergingEnabled;
}
+
+ private void internalRefresh(ResourceMapping[] mappings, ResourceTraversal[] traversals, String jobName, String taskName, IWorkbenchSite site, IRefreshSubscriberListener listener) {
+ if (jobName == null)
+ jobName = getShortTaskName();
+ if (taskName == null)
+ taskName = getLongTaskName(mappings);
+ Platform.getJobManager().cancel(this);
+ RefreshParticipantJob job = new RefreshModelParticipantJob(this, jobName, taskName, listener);
+ job.setUser(true);
+ Utils.schedule(job, site);
+
+ // Remember the last participant synchronized
+ TeamUIPlugin.getPlugin().getPreferenceStore().setValue(IPreferenceIds.SYNCHRONIZING_DEFAULT_PARTICIPANT, getId());
+ TeamUIPlugin.getPlugin().getPreferenceStore().setValue(IPreferenceIds.SYNCHRONIZING_DEFAULT_PARTICIPANT_SEC_ID, getSecondaryId());
+ }
+
+ /**
+ * Returns the short task name (e.g. no more than 25 characters) to describe
+ * the behavior of the refresh operation to the user. This is typically
+ * shown in the status line when this participant is refreshed in the
+ * background. When refreshed in the foreground, only the long task name is
+ * shown.
+ *
+ * @return the short task name to show in the status line.
+ */
+ protected String getShortTaskName() {
+ return TeamUIMessages.Participant_synchronizing;
+ }
+
+ /**
+ * Returns the long task name to describe the behavior of the refresh
+ * operation to the user. This is typically shown in the status line when
+ * this subscriber is refreshed in the background.
+ *
+ * @param mappings the mappings being refreshed
+ * @return the long task name
+ * @since 3.1
+ */
+ protected String getLongTaskName(ResourceMapping[] mappings) {
+ if (mappings == null || (mappings.length == getContext().getScope().getMappings().length)) {
+ // Assume we are refrshing everything
+ return NLS.bind(TeamUIMessages.Participant_synchronizingDetails, new String[] { getName() });
+ }
+ int mappingCount = mappings.length;
+ if (mappingCount == 1) {
+ return NLS.bind(TeamUIMessages.Participant_synchronizingMoreDetails, new String[] { getShortName(), getLabel(mappings[0]) });
+ }
+ return NLS.bind(TeamUIMessages.Participant_synchronizingResources, new String[] { getShortName(), Integer.toString(mappingCount) });
+ }
+
+ private String getLabel(ResourceMapping mapping) {
+ // TODO Auto-generated method stub
+ return "";
+ }
+
+ private IRefreshable createRefreshable() {
+ return new IRefreshable() {
+
+ public RefreshParticipantJob createJob(String interval) {
+ return new RefreshModelParticipantJob(ResourceMappingSynchronizeParticipant.this,
+ TeamUIMessages.RefreshSchedule_14,
+ NLS.bind(TeamUIMessages.RefreshSchedule_15, new String[] { ResourceMappingSynchronizeParticipant.this.getName(), interval }),
+ new RefreshUserNotificationPolicy(ResourceMappingSynchronizeParticipant.this));
+ }
+ public ISynchronizeParticipant getParticipant() {
+ return ResourceMappingSynchronizeParticipant.this;
+ }
+ public void setRefreshSchedule(SubscriberRefreshSchedule schedule) {
+ refreshSchedule = schedule;
+ }
+ public SubscriberRefreshSchedule getRefreshSchedule() {
+ return refreshSchedule;
+ }
+
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class adapter) {
+ if (adapter == IRefreshable.class && refreshSchedule != null) {
+ return refreshSchedule.getRefreshable();
+
+ }
+ return super.getAdapter(adapter);
+ }
+
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeParticipant.java
index 7816b99cc..59f63c90e 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeParticipant.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeParticipant.java
@@ -37,7 +37,7 @@ import org.eclipse.ui.PartInitException;
* @see ISynchronizeParticipant
* @since 3.0
*/
-public abstract class AbstractSynchronizeParticipant implements ISynchronizeParticipant {
+public abstract class AbstractSynchronizeParticipant extends PlatformObject implements ISynchronizeParticipant {
/**
* Property key used in the property change event fired when the pinned
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipant.java
index 0471ab8d4..8fbfc0173 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipant.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ISynchronizeParticipant.java
@@ -11,8 +11,7 @@
package org.eclipse.team.ui.synchronize;
import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.core.runtime.IExecutableExtension;
-import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.*;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
@@ -65,7 +64,7 @@ import org.eclipse.ui.part.IPageBookViewPage;
* @see AbstractSynchronizeParticipant
* @since 3.0
*/
-public interface ISynchronizeParticipant extends IExecutableExtension {
+public interface ISynchronizeParticipant extends IExecutableExtension, IAdaptable {
/**
* Returns the unique id that identified the <i>type</i> of this
* synchronize participant. The synchronize manager supports registering
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SubscriberParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SubscriberParticipant.java
index 843fd6c0e..f5be09218 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SubscriberParticipant.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SubscriberParticipant.java
@@ -79,7 +79,28 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa
* Constructor initializes the schedule. Subclasses must call this method.
*/
public SubscriberParticipant() {
- refreshSchedule = new SubscriberRefreshSchedule(this);
+ refreshSchedule = new SubscriberRefreshSchedule(createRefreshable());
+ }
+
+ private IRefreshable createRefreshable() {
+ return new IRefreshable() {
+ public RefreshParticipantJob createJob(String interval) {
+ return new RefreshSubscriberParticipantJob(SubscriberParticipant.this,
+ TeamUIMessages.RefreshSchedule_14,
+ NLS.bind(TeamUIMessages.RefreshSchedule_15, new String[] { SubscriberParticipant.this.getName(), interval }), getResources(),
+ new RefreshUserNotificationPolicy(SubscriberParticipant.this));
+ }
+ public ISynchronizeParticipant getParticipant() {
+ return SubscriberParticipant.this;
+ }
+ public void setRefreshSchedule(SubscriberRefreshSchedule schedule) {
+ SubscriberParticipant.this.setRefreshSchedule(schedule);
+ }
+ public SubscriberRefreshSchedule getRefreshSchedule() {
+ return SubscriberParticipant.this.getRefreshSchedule();
+ }
+
+ };
}
/**
@@ -273,7 +294,7 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa
if(memento != null) {
IMemento settings = memento.getChild(CTX_SUBSCRIBER_PARTICIPANT_SETTINGS);
if(settings != null) {
- SubscriberRefreshSchedule schedule = SubscriberRefreshSchedule.init(settings.getChild(CTX_SUBSCRIBER_SCHEDULE_SETTINGS), this);
+ SubscriberRefreshSchedule schedule = SubscriberRefreshSchedule.init(settings.getChild(CTX_SUBSCRIBER_SCHEDULE_SETTINGS), createRefreshable());
setRefreshSchedule(schedule);
this.scope = AbstractSynchronizeScope.createScope(settings);
scope.addPropertyChangeListener(this);
@@ -479,4 +500,15 @@ public abstract class SubscriberParticipant extends AbstractSynchronizeParticipa
public ISynchronizeScope getScope() {
return scope;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class adapter) {
+ if (adapter == IRefreshable.class && refreshSchedule != null) {
+ return refreshSchedule.getRefreshable();
+
+ }
+ return super.getAdapter(adapter);
+ }
}

Back to the top