Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2002-05-17 17:16:45 -0400
committerJean Michel-Lemieux2002-05-17 17:16:45 -0400
commitd8b03558a1060ae3d1073223ca26643ef77c3342 (patch)
tree6d1645e6bffb7adaa51073d927496668f565edc5
parent8d0387af050b642da242dcfb4d524dfd73850898 (diff)
downloadeclipse.platform.team-d8b03558a1060ae3d1073223ca26643ef77c3342.tar.gz
eclipse.platform.team-d8b03558a1060ae3d1073223ca26643ef77c3342.tar.xz
eclipse.platform.team-d8b03558a1060ae3d1073223ca26643ef77c3342.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java12
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ResourceState.java5
-rw-r--r--bundles/org.eclipse.team.ui/plugin.xml10
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/LocalTargetSyncElement.java64
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteTargetSyncElement.java165
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SyncAction.java55
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetCatchupReleaseViewer.java12
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncAction.java196
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncCompareInput.java57
9 files changed, 571 insertions, 5 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java
index 44ddb349b..7f4aa453b 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java
@@ -101,5 +101,17 @@ public abstract class TargetProvider {
return true;
}
+ /**
+ * Answers true if the base identifier of the given resource is different to the
+ * current released state of the resource.
+ */
+ public abstract boolean isOutOfDate(IResource resource);
+
+ /**
+ * Answer if the local resource currently has a different timestamp to the
+ * base timestamp for this resource.
+ */
+ public abstract boolean isDirty(IResource resource);
+
public abstract void deregister(IProject project);
}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ResourceState.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ResourceState.java
index f9fe93b8d..773d62e29 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ResourceState.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ResourceState.java
@@ -241,11 +241,10 @@ public abstract class ResourceState {
*/
public boolean isDirty(IResource resource) {
if (!hasLocal())
- return true; // by API definition.
- File localFile = resource.getLocation().toFile();
+ return false; // by API definition.
if (localBaseTimestamp == EMPTY_LOCALBASETS)
return false; // by API definition.
- return localBaseTimestamp != localFile.lastModified();
+ return localBaseTimestamp != resource.getModificationStamp();
}
/**
diff --git a/bundles/org.eclipse.team.ui/plugin.xml b/bundles/org.eclipse.team.ui/plugin.xml
index 755710adb..feaa66936 100644
--- a/bundles/org.eclipse.team.ui/plugin.xml
+++ b/bundles/org.eclipse.team.ui/plugin.xml
@@ -108,6 +108,12 @@
id="org.eclipse.team.target.putAction"
label="Put">
</action>
+ <action
+ menubarPath="team.target/group1"
+ class="org.eclipse.team.internal.ui.target.SyncAction"
+ id="org.eclipse.team.target.SyncAction"
+ label="Synchronize with Target...">
+ </action>
</objectContribution>
<objectContribution
@@ -138,7 +144,7 @@
category="org.eclipse.team.ui"
class="org.eclipse.team.internal.ui.sync.SyncView">
</view>
- <!--
+
<category
id="org.eclipse.team.ui.target"
name="Deployment">
@@ -151,7 +157,7 @@
class="org.eclipse.team.internal.ui.target.SiteExplorerView"
id="org.eclipse.team.ui.target.SiteExplorerView">
</view>
- -->
+
</extension>
<!-- ****************** Import Wizards ********************* -->
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/LocalTargetSyncElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/LocalTargetSyncElement.java
new file mode 100644
index 000000000..be6875b72
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/LocalTargetSyncElement.java
@@ -0,0 +1,64 @@
+package org.eclipse.team.internal.ui.target;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.team.core.sync.ILocalSyncElement;
+import org.eclipse.team.core.sync.IRemoteResource;
+import org.eclipse.team.core.sync.LocalSyncElement;
+
+public class LocalTargetSyncElement extends LocalSyncElement {
+
+ private IResource local;
+
+ public LocalTargetSyncElement(IResource local) {
+ this.local = local;
+ }
+
+ /**
+ * @see LocalSyncElement#create(IResource, IRemoteResource, Object)
+ */
+ public ILocalSyncElement create(IResource local, IRemoteResource base, Object data) {
+ return new LocalTargetSyncElement(local);
+ }
+
+ /**
+ * @see LocalSyncElement#getData()
+ */
+ protected Object getData() {
+ return null;
+ }
+
+ /**
+ * @see LocalSyncElement#isIgnored(IResource)
+ */
+ protected boolean isIgnored(IResource resource) {
+ return false;
+ }
+
+ /**
+ * @see ILocalSyncElement#getLocal()
+ */
+ public IResource getLocal() {
+ return local;
+ }
+
+ /**
+ * @see ILocalSyncElement#getBase()
+ */
+ public IRemoteResource getBase() {
+ return null;
+ }
+
+ /**
+ * @see ILocalSyncElement#isCheckedOut()
+ */
+ public boolean isCheckedOut() {
+ return false;
+ }
+
+ /**
+ * @see ILocalSyncElement#hasRemote()
+ */
+ public boolean hasRemote() {
+ return false;
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteTargetSyncElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteTargetSyncElement.java
new file mode 100644
index 000000000..b2dd55a80
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteTargetSyncElement.java
@@ -0,0 +1,165 @@
+package org.eclipse.team.internal.ui.target;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.sync.ILocalSyncElement;
+import org.eclipse.team.core.sync.IRemoteResource;
+import org.eclipse.team.core.sync.IRemoteSyncElement;
+import org.eclipse.team.core.sync.RemoteSyncElement;
+import org.eclipse.team.core.target.IRemoteTargetResource;
+import org.eclipse.team.core.target.TargetManager;
+import org.eclipse.team.core.target.TargetProvider;
+
+public class RemoteTargetSyncElement extends RemoteSyncElement {
+
+ private IRemoteTargetResource remote;
+ private LocalTargetSyncElement localSyncElement;
+ private TargetProvider provider;
+
+ public RemoteTargetSyncElement(IResource local, IRemoteTargetResource remote) {
+ this.localSyncElement = new LocalTargetSyncElement(local);
+ this.remote = remote;
+ try {
+ this.provider = TargetManager.getProvider(local.getProject());
+ } catch (TeamException e) {
+ }
+ }
+
+ /**
+ * @see RemoteSyncElement#create(boolean, IResource, IRemoteResource, IRemoteResource, Object)
+ */
+ public IRemoteSyncElement create(boolean isThreeWay, IResource local, IRemoteResource base, IRemoteResource remote, Object data) {
+ return new RemoteTargetSyncElement(local, (IRemoteTargetResource)remote);
+ }
+
+ /**
+ * @see RemoteSyncElement#timestampEquals(IResource, IRemoteResource)
+ */
+ protected boolean timestampEquals(IResource e1, IRemoteResource e2) {
+ return false;
+ }
+
+ /**
+ * @see RemoteSyncElement#timestampEquals(IRemoteResource, IRemoteResource)
+ */
+ protected boolean timestampEquals(IRemoteResource e1, IRemoteResource e2) {
+ return false;
+ }
+
+ /**
+ * @see LocalSyncElement#create(IResource, IRemoteResource, Object)
+ */
+ public ILocalSyncElement create(IResource local, IRemoteResource base, Object data) {
+ return localSyncElement.create(local, base, data);
+ }
+
+ /**
+ * @see LocalSyncElement#getData()
+ */
+ protected Object getData() {
+ return null;
+ }
+
+ /**
+ * @see LocalSyncElement#isIgnored(IResource)
+ */
+ protected boolean isIgnored(IResource resource) {
+ return false;
+ }
+
+ /**
+ * @see IRemoteSyncElement#getRemote()
+ */
+ public IRemoteResource getRemote() {
+ return remote;
+ }
+
+ /**
+ * @see IRemoteSyncElement#isThreeWay()
+ */
+ public boolean isThreeWay() {
+ return true;
+ }
+
+ /**
+ * @see ILocalSyncElement#getLocal()
+ */
+ public IResource getLocal() {
+ return localSyncElement.getLocal();
+ }
+
+ /**
+ * @see ILocalSyncElement#getBase()
+ */
+ public IRemoteResource getBase() {
+ return null;
+ }
+
+ /**
+ * @see ILocalSyncElement#isCheckedOut()
+ */
+ public boolean isCheckedOut() {
+ return false;
+ }
+
+ /**
+ * @see ILocalSyncElement#hasRemote()
+ */
+ public boolean hasRemote() {
+ return false;
+ }
+
+ /**
+ * @see ILocalSyncElement#getSyncKind(int, IProgressMonitor)
+ */
+ public int getSyncKind(int granularity, IProgressMonitor progress) {
+ int description = IN_SYNC;
+ IResource local = getLocal();
+ boolean isDirty = provider.isDirty(local);
+ boolean isOutOfDate = provider.isOutOfDate(local);
+ boolean localExists = local.exists();
+
+ if (remote == null) {
+ if (!localExists) {
+ // this should never happen
+ // Assert.isTrue(false);
+ } else {
+ // no remote but a local
+ if (!isDirty && isOutOfDate) {
+ description = INCOMING | DELETION;
+ } else if (isDirty && isOutOfDate) {
+ description = CONFLICTING | CHANGE;
+ } else if (!isDirty && !isOutOfDate) {
+ description = OUTGOING | ADDITION;
+ }
+ }
+ } else {
+ if (!localExists) {
+ // a remote but no local
+ if (!isDirty && !isOutOfDate) {
+ description = INCOMING | ADDITION;
+ } else if (isDirty && !isOutOfDate) {
+ description = OUTGOING | DELETION;
+ } else if (isDirty && isOutOfDate) {
+ description = CONFLICTING | CHANGE;
+ }
+ } else {
+ // have a local and a remote
+ if (!isDirty && !isOutOfDate) {
+ // ignore, there is no change;
+ } else if (!isDirty && isOutOfDate) {
+ description = INCOMING | CHANGE;
+ } else if (isDirty && !isOutOfDate) {
+ description = OUTGOING | CHANGE;
+ } else {
+ description = CONFLICTING | CHANGE;
+ }
+ // if contents are the same, then mark as pseudo change
+ if (description != IN_SYNC && compare(granularity, false, local, remote, progress))
+ description |= PSEUDO_CONFLICT;
+ }
+ }
+ return description;
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SyncAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SyncAction.java
new file mode 100644
index 000000000..75248aa8b
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SyncAction.java
@@ -0,0 +1,55 @@
+package org.eclipse.team.internal.ui.target;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2002.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.sync.IRemoteSyncElement;
+import org.eclipse.team.core.target.TargetManager;
+import org.eclipse.team.core.target.TargetProvider;
+import org.eclipse.team.internal.ui.TeamUIPlugin;
+import org.eclipse.team.internal.ui.actions.TeamAction;
+import org.eclipse.team.internal.ui.sync.SyncCompareInput;
+import org.eclipse.team.internal.ui.sync.SyncView;
+import org.eclipse.ui.PartInitException;
+
+/**
+ * Action for catchup/release in popup menus.
+ */
+public class SyncAction extends TeamAction {
+
+ public void run(IAction action) {
+ IResource[] resources = getSelectedResources();
+ SyncView view = (SyncView)TeamUIPlugin.getActivePage().findView(SyncView.VIEW_ID);
+ if (view == null) {
+ view = SyncView.findInActivePerspective();
+ }
+ if (view != null) {
+ try {
+ TeamUIPlugin.getActivePage().showView(SyncView.VIEW_ID);
+ } catch (PartInitException e) {
+ TeamUIPlugin.log(e.getStatus());
+ }
+ view.showSync(getCompareInput(resources));
+ }
+ }
+
+ protected boolean isEnabled() throws TeamException {
+ IResource[] resources = getSelectedResources();
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ if (!resource.isAccessible()) return false;
+ TargetProvider provider = TargetManager.getProvider(resource.getProject());
+ if(provider == null) return false;
+ }
+ return true;
+ }
+
+ protected SyncCompareInput getCompareInput(IResource[] resources) {
+ return new TargetSyncCompareInput(resources, IRemoteSyncElement.GRANULARITY_TIMESTAMP);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetCatchupReleaseViewer.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetCatchupReleaseViewer.java
new file mode 100644
index 000000000..4218df7c2
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetCatchupReleaseViewer.java
@@ -0,0 +1,12 @@
+package org.eclipse.team.internal.ui.target;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.team.internal.ui.sync.CatchupReleaseViewer;
+import org.eclipse.team.internal.ui.sync.SyncCompareInput;
+
+public class TargetCatchupReleaseViewer extends CatchupReleaseViewer {
+
+ public TargetCatchupReleaseViewer(Composite parent, SyncCompareInput input) {
+ super(parent, input);
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncAction.java
new file mode 100644
index 000000000..0857440d8
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncAction.java
@@ -0,0 +1,196 @@
+package org.eclipse.team.internal.ui.target;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.compare.structuremergeviewer.Differencer;
+import org.eclipse.compare.structuremergeviewer.IDiffContainer;
+import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.sync.IRemoteSyncElement;
+import org.eclipse.team.internal.ui.Policy;
+import org.eclipse.team.internal.ui.TeamUIPlugin;
+import org.eclipse.team.internal.ui.sync.ChangedTeamContainer;
+import org.eclipse.team.internal.ui.sync.ITeamNode;
+import org.eclipse.team.internal.ui.sync.SyncSet;
+import org.eclipse.team.internal.ui.sync.UnchangedTeamContainer;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+public abstract class TargetSyncAction extends Action {
+ private TargetSyncCompareInput diffModel;
+ private ISelectionProvider selectionProvider;
+
+ protected int syncMode;
+ private Shell shell;
+
+ /**
+ * Creates a MergeAction which works on selection and doesn't commit changes.
+ */
+ public TargetSyncAction(TargetSyncCompareInput model, ISelectionProvider sp, String label, Shell shell) {
+ super(label);
+ this.diffModel = model;
+ this.selectionProvider = sp;
+ this.shell = shell;
+ }
+
+ protected Shell getShell() {
+ return shell;
+ }
+
+ protected TargetSyncCompareInput getDiffModel() {
+ return diffModel;
+ }
+
+ /**
+ * Returns true if at least one node can perform the specified action.
+ */
+ private boolean isEnabled(Object[] nodes) {
+ for (int i = 0; i < nodes.length; i++) {
+ if (nodes[i] instanceof ITeamNode) {
+ ITeamNode node = (ITeamNode)nodes[i];
+ if (isEnabled(node)) {
+ return true;
+ }
+ } else {
+ if (nodes[i] instanceof IDiffContainer)
+ if (isEnabled(((IDiffContainer)nodes[i]).getChildren()))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected abstract boolean isEnabled(ITeamNode node);
+
+ /**
+ * Perform the sychronization operation.
+ */
+ public void run() {
+ ISelection s = selectionProvider.getSelection();
+ if (!(s instanceof IStructuredSelection) || s.isEmpty()) {
+ return;
+ }
+ final SyncSet set = new SyncSet((IStructuredSelection)s);
+ removeNonApplicableNodes(set, syncMode);
+ final SyncSet[] result = new SyncSet[1];
+ WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+ public void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ result[0] = TargetSyncAction.this.run(set, monitor);
+ }
+ };
+ try {
+ run(op, Policy.bind("MergeAction.problemsDuringSync")); //$NON-NLS-1$
+ } catch (InterruptedException e) {
+ }
+ if (result[0] != null) {
+ // all returned nodes that have a changed sync kind are assumed
+ // to have been operated on and will be removed from the diff tree.
+ removeNodes(result[0].getChangedNodes());
+
+ // any node that claims that it's IN_SYNC will be automatically
+ // filtered from the diff tree - see DiffElement.setKind().
+ diffModel.updateView();
+ }
+ }
+
+ protected abstract void removeNonApplicableNodes(SyncSet set, int syncMode);
+
+ /**
+ * The given nodes have been synchronized. Remove them from
+ * the sync set.
+ *
+ * For folders that are outgoing deletions, we may need to leave the
+ * folder as is or adjust the sync kind depending on the sync kind of
+ * the folder's children.
+ *
+ * @see CVSSyncCompareInput#collectResourceChanges(IDiffContainer, IRemoteSyncElement, IProgressMonitor)
+ */
+ private void removeNodes(final ITeamNode[] nodes) {
+ // Update the model
+ Set outgoingFolderDeletions = new HashSet();
+ for (int i = 0; i < nodes.length; i++) {
+ if (nodes[i].getClass() == UnchangedTeamContainer.class) {
+ // Unchanged containers get removed automatically when all
+ // children are removed
+ continue;
+ }
+ if (nodes[i].getClass() == ChangedTeamContainer.class) {
+ // If this node still has children, convert to an
+ // unchanged container, then it will disappear when
+ // all children have been removed.
+ ChangedTeamContainer container = (ChangedTeamContainer)nodes[i];
+ IDiffElement[] children = container.getChildren();
+ if (children.length > 0) {
+ IDiffContainer parent = container.getParent();
+ UnchangedTeamContainer unchanged = new UnchangedTeamContainer(parent, container.getResource());
+ for (int j = 0; j < children.length; j++) {
+ unchanged.add(children[j]);
+ }
+ parent.removeToRoot(container);
+ // No children, it will get removed below.
+ }
+ nodes[i].getParent().removeToRoot(nodes[i]);
+ }
+ }
+ }
+
+ /**
+ * Updates the action with the latest selection, setting enablement
+ * as necessary.
+ */
+ public void update(int syncMode) {
+ this.syncMode = syncMode;
+ IStructuredSelection selection = (IStructuredSelection)selectionProvider.getSelection();
+ setEnabled(isEnabled(selection.toArray()));
+ }
+
+ /**
+ * Subclasses must implement this method, which performs action-specific code.
+ *
+ * It may return the sync set which was passed in, or null.
+ */
+ protected abstract SyncSet run(SyncSet syncSet, IProgressMonitor monitor);
+
+ /**
+ * Helper method to run a runnable in a progress monitor dialog, and display any errors.
+ */
+ protected void run(IRunnableWithProgress op, String problemMessage) throws InterruptedException {
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
+ try {
+ dialog.run(true, true, op);
+ } catch (InvocationTargetException e) {
+ Throwable throwable = e.getTargetException();
+ IStatus error = null;
+ if (throwable instanceof CoreException) {
+ error = ((CoreException)throwable).getStatus();
+ } else {
+ error = new Status(IStatus.ERROR, TeamUIPlugin.ID, 1, Policy.bind("simpleInternal") , throwable); //$NON-NLS-1$
+ }
+ ErrorDialog.openError(shell, problemMessage, error.getMessage(), error);
+ TeamUIPlugin.log(error);
+ }
+ }
+
+ /**
+ * Helper method. Check if a save is necessary. If it is, prompt the user to save.
+ * Return true if all necessary saves have been performed, false otherwise.
+ */
+ protected boolean saveIfNecessary() {
+ return getDiffModel().saveIfNecessary();
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncCompareInput.java
new file mode 100644
index 000000000..38044b48f
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncCompareInput.java
@@ -0,0 +1,57 @@
+package org.eclipse.team.internal.ui.target;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.sync.IRemoteSyncElement;
+import org.eclipse.team.core.target.TargetManager;
+import org.eclipse.team.core.target.TargetProvider;
+import org.eclipse.team.internal.ui.Policy;
+import org.eclipse.team.internal.ui.sync.CatchupReleaseViewer;
+import org.eclipse.team.internal.ui.sync.SyncCompareInput;
+
+public class TargetSyncCompareInput extends SyncCompareInput {
+
+ private IResource[] resources;
+
+ protected TargetSyncCompareInput(IResource[] resources, int granularity) {
+ super(granularity);
+ this.resources = resources;
+ }
+
+ /**
+ * @see SyncCompareInput#createSyncElements(IProgressMonitor)
+ */
+ protected IRemoteSyncElement[] createSyncElements(IProgressMonitor monitor) throws TeamException {
+ RemoteTargetSyncElement[] elements = new RemoteTargetSyncElement[resources.length];
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ TargetProvider provider = TargetManager.getProvider(resource.getProject());
+ elements[i] = new RemoteTargetSyncElement(resources[i], provider.getRemoteResourceFor(resource));
+ }
+ return elements;
+ }
+
+ /**
+ * @see CompareEditorInput#createDiffViewer(Composite)
+ */
+ public Viewer createDiffViewer(Composite parent) {
+ CatchupReleaseViewer viewer = new TargetCatchupReleaseViewer(parent, this);
+ setViewer(viewer);
+ return viewer;
+ }
+
+ protected void updateView() {
+ // Update the view
+ if (getDiffRoot().hasChildren()) {
+ getViewer().refresh();
+ } else {
+ getViewer().setInput(null);
+ }
+
+ // Update the status line
+ updateStatusLine();
+ }
+}

Back to the top