Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r1471 - trunk/subclipse/ui/src/org/tigris/subversion/subclipse/ui

subclipse
Discussion topic

Back to topic list

svn commit: r1471 - trunk/subclipse/ui/src/org/tigris/subversion/subclipse/ui

Author brockj
Full name Brock Janiczak
Date 2005-07-22 17:27:02 PDT
Message Author: brockj
Date: Fri Jul 22 17:27:02 2005
New Revision: 1471

Modified:
   trunk/subclipse/ui/s​rc/org/tigris/subver​sion/subclipse/ui/SV​NPristineCopyQuickDi​ffProvider.java
Log:
*SVNPristineCopyQuic​kDiffProvider.java
Updated provider to use SyncInfo. It will also listen for Sync changes and refresh as needed.

Modified: trunk/subclipse/ui/s​rc/org/tigris/subver​sion/subclipse/ui/SV​NPristineCopyQuickDi​ffProvider.java
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/trunk/su​bclipse/ui/src/org/t​igris/subversion/sub​clipse/ui/SVNPristin​eCopyQuickDiffProvid​er.java?view=diff​&rev=1471&p1=tr​unk/subclipse/ui/src​/org/tigris/subversi​on/subclipse/ui/SVNP​ristineCopyQuickDiff​Provider.java&r1​=1470&p2=trunk/s​ubclipse/ui/src/org/​tigris/subversion/su​bclipse/ui/SVNPristi​neCopyQuickDiffProvi​der.java&r2=1471​
====================​====================​====================​==================
--- trunk/subclipse/ui/s​rc/org/tigris/subver​sion/subclipse/ui/SV​NPristineCopyQuickDi​ffProvider.java (original)
+++ trunk/subclipse/ui/s​rc/org/tigris/subver​sion/subclipse/ui/SV​NPristineCopyQuickDi​ffProvider.java Fri Jul 22 17:27:02 2005
@@ -18,6 +18,7 @@
 import java.io.Reader;
 
 import org.eclipse.core.res​ources.IFile;
+import org.eclipse.core.res​ources.IResource;
 import org.eclipse.core.run​time.CoreException;
 import org.eclipse.core.run​time.IProgressMonito​r;
 import org.eclipse.core.run​time.IStatus;
@@ -25,6 +26,9 @@
 import org.eclipse.core.run​time.jobs.Job;
 import org.eclipse.jface.te​xt.Document;
 import org.eclipse.jface.te​xt.IDocument;
+import org.eclipse.team.cor​e.TeamException;
+import org.eclipse.team.cor​e.subscribers.ISubsc​riberChangeEvent;
+import org.eclipse.team.cor​e.subscribers.ISubsc​riberChangeListener;​
 import org.eclipse.team.cor​e.synchronize.SyncIn​fo;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IFile​EditorInput;
@@ -33,10 +37,12 @@
 import org.eclipse.ui.texte​ditor.IElementStateL​istener;
 import org.eclipse.ui.texte​ditor.ITextEditor;
 import org.eclipse.ui.texte​ditor.quickdiff.IQui​ckDiffReferenceProvi​der;
+import org.tigris.subversio​n.subclipse.core.ISV​NFile;
 import org.tigris.subversio​n.subclipse.core.ISV​NLocalFile;
-import org.tigris.subversio​n.subclipse.core.ISV​NRemoteResource;
+import org.tigris.subversio​n.subclipse.core.ISV​NRemoteFile;
 import org.tigris.subversio​n.subclipse.core.SVN​Exception;
 import org.tigris.subversio​n.subclipse.core.res​ources.SVNWorkspaceR​oot;
+import org.tigris.subversio​n.subclipse.core.syn​c.SVNWorkspaceSubscr​iber;
 
 /**
 
@@ -83,32 +89,32 @@
     private String id;
     
     // A handle to the remote SVN file for this provider.
-// private SyncInfo fLastSyncState;
+ private SyncInfo fLastSyncState;
 
     // Job that re-creates the reference document.
     private Job fUpdateJob;
     
     private boolean DEBUG = false;
     
-// /**
-// * Updates the document if a sync changes occurs to the associated SVN file.
-// */
-// private ISubscriberChangeListener teamChangeListener = new ISubscriberChangeListener() {
-// public void subscriberResourceCh​anged(ISubscriberCha​ngeEvent[] deltas) {
-// if(fReferenceInitialized) {
-// for (int i = 0; i < deltas.length; i++) {
-// ISubscriberChangeEvent delta = deltas[i];
-// IResource resource = delta.getResource();
-// if(resource.getType() == IResource.FILE &&
-// fLastSyncState != null && resource.equals(fLas​tSyncState.getLocal(​))) {
-// if(delta.getFlags() == ISubscriberChangeEve​nt.SYNC_CHANGED) {
-// fetchContentsInJob();
-// }
-// }
-// }
-// }
-// }
-// };
+ /**
+ * Updates the document if a sync changes occurs to the associated SVN file.
+ */
+ private ISubscriberChangeListener teamChangeListener = new ISubscriberChangeListener() {
+ public void subscriberResourceCh​anged(ISubscriberCha​ngeEvent[] deltas) {
+ if(isReferenceInitialized) {
+ for (int i = 0; i < deltas.length; i++) {
+ ISubscriberChangeEvent delta = deltas[i];
+ IResource resource = delta.getResource();
+ if(resource.getType() == IResource.FILE &&
+ fLastSyncState != null && resource.equals(fLas​tSyncState.getLocal(​))) {
+ if(delta.getFlags() == ISubscriberChangeEve​nt.SYNC_CHANGED) {
+ fetchContentsInJob();
+ }
+ }
+ }
+ }
+ }
+ };
 
     /**
      * Updates the document if the document is changed (e.g. replace with)
@@ -134,7 +140,7 @@
     };
 
     /*
- * @see org.eclipse.test.qui​ckdiff.DocumentLineD​iffer.IQuickDiffRefe​renceProvider#getRef​erence()
+ * @see org.eclipse.test.qui​ckdiff.DocumentLineD​iffer.IQuickDifrefer​enceDocumentProvider​#getReference()
      */
     public IDocument getReference(IProgressMonitor monitor) throws CoreException {
         if(! isReferenceInitialized) return null;
@@ -153,7 +159,7 @@
         documentProvider= editor.getDocumentProvider();
         
         if(documentProvider != null) {
-// SVNProviderPlugin.ge​tPlugin().getSVNWork​spaceSubscriber().ad​dListener(teamChange​Listener);
+ SVNWorkspaceSubscrib​er.getInstance().add​Listener(teamChangeL​istener);
             ((IDocumentProvider)​documentProvider).ad​dElementStateListene​r(documentListener);​
         }
         isReferenceInitialized= true;
@@ -173,7 +179,7 @@
     }
 
     /*
- * @see org.eclipse.jface.te​xt.source.diff.Docum​entLineDiffer.IQuick​DiffReferenceProvide​r#dispose()
+ * @see org.eclipse.jface.te​xt.source.diff.Docum​entLineDiffer.IQuick​DifreferenceDocument​Provider#dispose()
      */
     public void dispose() {
         isReferenceInitialized = false;
@@ -197,38 +203,38 @@
     }
 
     /*
- * @see org.eclipse.jface.te​xt.source.diff.Docum​entLineDiffer.IQuick​DiffReferenceProvide​r#getId()
+ * @see org.eclipse.jface.te​xt.source.diff.Docum​entLineDiffer.IQuick​DifreferenceDocument​Provider#getId()
      */
     public String getId() {
         return id;
     }
     
-// /**
-// * Determine if the file represented by this quickdiff provider has changed with
-// * respect to it's remote state. Return true if the remote contents should be
-// * refreshed, and false if not.
-// */
-// private boolean computeChange(IProgressMonitor monitor) throws TeamException {
-// boolean needToUpdateReferenceDocument = false;
-// if(fReferenceInitialized) {
-// SyncInfo info = getSyncState(getFile​FromEditor());
-// if(info == null && fLastSyncState != null) {
-// return true;
-// } else if(info == null) {
-// return false;
-// }
-//
-// int kind = info.getKind();
-// if(fLastSyncState == null) {
-// needToUpdateReferenceDocument = true;
-// } else if(! fLastSyncState.equals(info)) {
-// needToUpdateReferenceDocument = true;
-// }
-// if(DEBUG) debug(fLastSyncState, info);
-// fLastSyncState = info;
-// }
-// return needToUpdateReferenceDocument;
-// }
+ /**
+ * Determine if the file represented by this quickdiff provider has changed with
+ * respect to it's remote state. Return true if the remote contents should be
+ * refreshed, and false if not.
+ */
+ private boolean computeChange(IProgressMonitor monitor) throws TeamException {
+ boolean needToUpdateReferenceDocument = false;
+ if(isReferenceInitialized) {
+ SyncInfo info = getSyncState(getFile​FromEditor());
+ if(info == null && fLastSyncState != null) {
+ return true;
+ } else if(info == null) {
+ return false;
+ }
+
+ int kind = info.getKind();
+ if(fLastSyncState == null) {
+ needToUpdateReferenceDocument = true;
+ } else if(! fLastSyncState.equals(info)) {
+ needToUpdateReferenceDocument = true;
+ }
+ if(DEBUG) debug(fLastSyncState, info);
+ fLastSyncState = info;
+ }
+ return needToUpdateReferenceDocument;
+ }
     
     private void debug(SyncInfo lastSyncState, SyncInfo info) {
         String last = "[none]"; //$NON-NLS-1$
@@ -238,45 +244,12 @@
         System.out.println("+ SVNQuickDiff: was " + last + " is " + info.toString()); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-// private SyncInfo getSyncState(IResource resource) throws TeamException {
-// if (resource == null) return null;
-// ISVNFile SVNFile = getManagedSVNFile();
-// return SVNProviderPlugin.ge​tPlugin().getSVNWork​spaceSubscriber().ge​tSyncInfo(resource);​
-// }
+ private SyncInfo getSyncState(IResource resource) throws TeamException {
+ if (resource == null) return null;
+ ISVNFile SVNFile = getManagedSVNFile();
+ return SVNWorkspaceSubscrib​er.getInstance().get​SyncInfo(resource);
+ }
     
-// /**
-// * Creates a document and initializes it with the contents of a SVN remote
-// * resource.
-// * @param monitor the progress monitor
-// * @throws CoreException
-// */
-// private void readDocument(IProgressMonitor monitor) throws CoreException {
-// if(! fReferenceInitialized) return;
-// if(fReference == null)
-// fReference = new Document();
-// if(computeChange(monitor)) {
-// ISVNRemoteFile remoteFile = (ISVNRemoteFile)fLas​tSyncState.getRemote​();
-// if (fLastSyncState.getRemote() != null && fDocumentProvider instanceof IStorageDocumentProvider) {
-// IStorageDocumentProvider provider= (IStorageDocumentProvider) fDocumentProvider;
-// String encoding= provider.getEncoding​(fEditor.getEditorIn​put());
-// if (encoding == null) {
-// encoding= provider.getDefaultEncoding();
-// }
-// if(monitor.isCanceled()) return;
-// InputStream stream= remoteFile.getConten​ts(monitor);
-// if (stream == null || monitor.isCanceled() || ! fReferenceInitialized) {
-// return;
-// }
-// setDocumentContent(fReference, stream, encoding);
-// } else {
-// // the remote is null, so ensure that the document is null
-// if(monitor.isCanceled()) return;
-// fReference.set(""); //$NON-NLS-1$
-// }
-// if(DEBUG) System.out.println("+ SVNQuickDiff: updating document " + (fReference!=null ? "remote found" : "remote empty")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-// }
-// }
-
     /**
      * Creates a document and initializes it with the contents of a SVN remote
      * resource.
@@ -287,30 +260,63 @@
         if(! isReferenceInitialized) return;
         if(referenceDocument == null)
             referenceDocument = new Document();
-
- ISVNLocalFile localFile = getManagedSVNFile();
-
- // TODO shouldn't have to defend against base revisions not existing for added files
- if (!localFile.getStatu​s().isAdded() && documentProvider instanceof IStorageDocumentProvider) {
- IStorageDocumentProvider provider= (IStorageDocumentProvider) documentProvider;
- String encoding= provider.getEncoding​(editor.getEditorInp​ut());
- if (encoding == null) {
- encoding= provider.getDefaultEncoding();
- }
- if(monitor.isCanceled()) return;
-
- ISVNRemoteResource remoteFile = localFile.getBaseResource();
- if (remoteFile == null || monitor.isCanceled() || ! isReferenceInitialized) {
- return;
+ if(computeChange(monitor)) {
+ ISVNRemoteFile remoteFile = (ISVNRemoteFile)fLas​tSyncState.getBase()​;
+ if (remoteFile != null && documentProvider instanceof IStorageDocumentProvider) {
+ IStorageDocumentProvider provider= (IStorageDocumentProvider) documentProvider;
+ String encoding= provider.getEncoding​(editor.getEditorInp​ut());
+ if (encoding == null) {
+ encoding= provider.getDefaultEncoding();
+ }
+ if(monitor.isCanceled()) return;
+ InputStream stream= remoteFile.getStorag​e(monitor).getConten​ts();
+ if (stream == null || monitor.isCanceled() || ! isReferenceInitialized) {
+ return;
+ }
+ setDocumentContent(r​eferenceDocument, stream, encoding);
+ } else {
+ // the remote is null, so ensure that the document is null
+ if(monitor.isCanceled()) return;
+ referenceDocument.set(""); //$NON-NLS-1$
             }
- setDocumentContent(r​eferenceDocument, remoteFile.getStorag​e(monitor).getConten​ts(), encoding);
- } else {
- if(monitor.isCanceled()) return;
- referenceDocument.set(""); //$NON-NLS-1$
+ if(DEBUG) System.out.println("+ SVNQuickDiff: updating document " + (referenceDocument!=null ? "remote found" : "remote empty")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         }
- if(DEBUG) System.out.println("+ SVNQuickDiff: updating document " + (referenceDocument!=null ? "remote found" : "remote empty")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
 
+// /**
+// * Creates a document and initializes it with the contents of a SVN remote
+// * resource.
+// * @param monitor the progress monitor
+// * @throws CoreException
+// */
+// private void readDocument(IProgressMonitor monitor) throws CoreException {
+// if(! isReferenceInitialized) return;
+// if(referenceDocument == null)
+// referenceDocument = new Document();
+//
+// ISVNLocalFile localFile = getManagedSVNFile();
+//
+// // TODO shouldn't have to defend against base revisions not existing for added files
+// if (!localFile.getStatu​s().isAdded() && documentProvider instanceof IStorageDocumentProvider) {
+// IStorageDocumentProvider provider= (IStorageDocumentProvider) documentProvider;
+// String encoding= provider.getEncoding​(editor.getEditorInp​ut());
+// if (encoding == null) {
+// encoding= provider.getDefaultEncoding();
+// }
+// if(monitor.isCanceled()) return;
+//
+// ISVNRemoteResource remoteFile = localFile.getBaseResource();
+// if (remoteFile == null || monitor.isCanceled() || ! isReferenceInitialized) {
+// return;
+// }
+// setDocumentContent(r​eferenceDocument, remoteFile.getStorag​e(monitor).getConten​ts(), encoding);
+// } else {
+// if(monitor.isCanceled()) return;
+// referenceDocument.set(""); //$NON-NLS-1$
+// }
+// if(DEBUG) System.out.println("+ SVNQuickDiff: updating document " + (referenceDocument!=null ? "remote found" : "remote empty")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+// }
+
     /**
      * Intitializes the given document with the given stream using the given encoding.
      *

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r1471 - trunk/subclipse/ui/src/org/tigris/subversion/subclipse/ui brockj Brock Janiczak 2005-07-22 17:27:02 PDT
Messages per page: