Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/compare/SyncInfoDiffNode.java')
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/compare/SyncInfoDiffNode.java77
1 files changed, 77 insertions, 0 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/compare/SyncInfoDiffNode.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/compare/SyncInfoDiffNode.java
new file mode 100644
index 000000000..a7f83d7f7
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/compare/SyncInfoDiffNode.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui.synchronize.compare;
+
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.structuremergeviewer.DiffNode;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.subscribers.SyncInfo;
+import org.eclipse.team.core.sync.IRemoteResource;
+import org.eclipse.team.internal.ui.Policy;
+
+public class SyncInfoDiffNode extends DiffNode {
+
+ /**
+ * Create an ITypedElement for the given local resource. The returned ITypedElement
+ * will prevent edited of outgoing deletions.
+ */
+ public static ITypedElement createTypeElement(IResource resource, final int kind) {
+ if(resource != null && resource.exists()) {
+ return new LocalResourceTypedElement(resource) {
+ public boolean isEditable() {
+ if(SyncInfo.getDirection(kind) == SyncInfo.OUTGOING && SyncInfo.getChange(kind) == SyncInfo.DELETION) {
+ return false;
+ }
+ return super.isEditable();
+ }
+ };
+ }
+ return null;
+ }
+
+ /**
+ * Create an ITypedElement for the given remote resource. The contents for the remote resource
+ * will be retrieved from the given IStorage which is a local cache used to buffer the remote contents
+ */
+ public static ITypedElement createTypeElement(IRemoteResource remoteResource) {
+ return new RemoteResourceTypedElement(remoteResource);
+ }
+
+ /**
+ * Creates a new diff node.
+ */
+ public SyncInfoDiffNode(ITypedElement base, ITypedElement local, ITypedElement remote, int syncKind) {
+ super(syncKind, base, local, remote);
+ }
+
+ /**
+ * Cache the contents for the base and remote.
+ * @param monitor
+ */
+ public void cacheContents(IProgressMonitor monitor) throws TeamException {
+ ITypedElement base = getAncestor();
+ ITypedElement remote = getRight();
+ int work = Math.min((remote== null ? 0 : 50) + (base == null ? 0 : 50), 10);
+ monitor.beginTask(null, work);
+ try {
+ if (base != null && base instanceof RemoteResourceTypedElement) {
+ ((RemoteResourceTypedElement)base).cacheContents(Policy.subMonitorFor(monitor, 50));
+ }
+ if (remote != null && remote instanceof RemoteResourceTypedElement) {
+ ((RemoteResourceTypedElement)remote).cacheContents(Policy.subMonitorFor(monitor, 50));
+ }
+ } finally {
+ monitor.done();
+ }
+ }
+}

Back to the top