diff options
author | Michael Valenta | 2004-06-22 18:37:21 +0000 |
---|---|---|
committer | Michael Valenta | 2004-06-22 18:37:21 +0000 |
commit | 1a6e8a8e7786e6e6481011ad253ea4619949ab72 (patch) | |
tree | e89688b15613d57bad91ebff05c81696c7573251 /examples | |
parent | 1c60470b1dfd0d5f3f36d718eecd11aa926e6e5f (diff) | |
download | eclipse.platform.team-1a6e8a8e7786e6e6481011ad253ea4619949ab72.tar.gz eclipse.platform.team-1a6e8a8e7786e6e6481011ad253ea4619949ab72.tar.xz eclipse.platform.team-1a6e8a8e7786e6e6481011ad253ea4619949ab72.zip |
Updated Sync example
Diffstat (limited to 'examples')
3 files changed, 53 insertions, 33 deletions
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryPartipant.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryPartipant.java index fde5878c2..08c9cd411 100644 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryPartipant.java +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistoryPartipant.java @@ -29,7 +29,6 @@ public class LocalHistoryPartipant extends SubscriberParticipant { private class LocalHistoryActionContribution extends SynchronizePageActionGroup { public void initialize(ISynchronizePageConfiguration configuration) { super.initialize(configuration); - appendToGroup( ISynchronizePageConfiguration.P_CONTEXT_MENU, CONTEXT_MENU_CONTRIBUTION_GROUP, new SynchronizeModelAction("Revert to latest in local history", configuration) { //$NON-NLS-1$ diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySubscriber.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySubscriber.java index 12e5be628..b5e2c8723 100644 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySubscriber.java +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySubscriber.java @@ -11,26 +11,21 @@ package org.eclipse.team.examples.localhistory; import java.util.*; + import org.eclipse.core.resources.*; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.team.core.TeamException; import org.eclipse.team.core.subscribers.Subscriber; import org.eclipse.team.core.synchronize.SyncInfo; +import org.eclipse.team.core.variants.IResourceVariant; import org.eclipse.team.core.variants.IResourceVariantComparator; -import org.eclipse.team.examples.filesystem.FileSystemPlugin; public class LocalHistorySubscriber extends Subscriber { - private long timestamp; - private static final long LAST_FILESTATE = 0L; private LocalHistoryVariantComparator comparator; public LocalHistorySubscriber() { - this(LAST_FILESTATE); - } - - public LocalHistorySubscriber(long timestamp) { - this.timestamp = timestamp; this.comparator = new LocalHistoryVariantComparator(); } @@ -45,16 +40,14 @@ public class LocalHistorySubscriber extends Subscriber { public IResource[] members(IResource resource) throws TeamException { try { - if(resource.getType() == IResource.FILE) { + if(resource.getType() == IResource.FILE) return new IResource[0]; - } IContainer container = (IContainer)resource; List existingChildren = new ArrayList(Arrays.asList(container.members())); - existingChildren.addAll(Arrays.asList(container.findDeletedMembersWithHistory(IResource.DEPTH_INFINITE, new NullProgressMonitor()))); + existingChildren.addAll(Arrays.asList(container.findDeletedMembersWithHistory(IResource.DEPTH_INFINITE, null))); return (IResource[]) existingChildren.toArray(new IResource[existingChildren.size()]); } catch (CoreException e) { - FileSystemPlugin.getPlugin().getLog().log(e.getStatus()); - return new IResource[0]; + throw TeamException.asTeamException(e); } } @@ -63,25 +56,22 @@ public class LocalHistorySubscriber extends Subscriber { } public SyncInfo getSyncInfo(IResource resource) throws TeamException { - try { - if(resource.getType() == IResource.FILE) { - IFile file = (IFile)resource; - IFileState[] states = file.getHistory(new NullProgressMonitor()); - if(states.length > 0) { - // last state only - SyncInfo info = new SyncInfo(file,null, new LocalHistoryVariant(states[0]), comparator); - info.init(); - return info; - } - } - } catch (CoreException e) { - FileSystemPlugin.getPlugin().getLog().log(e.getStatus()); + try { + IResourceVariant variant = null; + if(resource.getType() == IResource.FILE) { + IFile file = (IFile)resource; + IFileState[] states = file.getHistory(null); + if(states.length > 0) { + // last state only + variant = new LocalHistoryVariant(states[0]); + } } - return new SyncInfo(resource, null, null, comparator) { - protected int calculateKind() throws TeamException { - return IN_SYNC; - } - }; + SyncInfo info = new LocalHistorySyncInfo(resource, variant, comparator); + info.init(); + return info; + } catch (CoreException e) { + throw TeamException.asTeamException(e); + } } public IResourceVariantComparator getResourceComparator() { diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySyncInfo.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySyncInfo.java new file mode 100644 index 000000000..fd0c38fdc --- /dev/null +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySyncInfo.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 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.examples.localhistory; + +import org.eclipse.core.resources.IResource; +import org.eclipse.team.core.TeamException; +import org.eclipse.team.core.synchronize.SyncInfo; +import org.eclipse.team.core.variants.IResourceVariant; +import org.eclipse.team.core.variants.IResourceVariantComparator; + +public class LocalHistorySyncInfo extends SyncInfo { + + public LocalHistorySyncInfo(IResource local, IResourceVariant remote, IResourceVariantComparator comparator) { + super(local, null, remote, comparator); + } + + protected int calculateKind() throws TeamException { + if (getRemote() == null) + return IN_SYNC; + else + return super.calculateKind(); + } +}
\ No newline at end of file |