Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 106058 Details for
Bug 237923
[rtcollab] Provide an indication of where other users are editing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch for DocShare, implementation based on Annotations
docshare-remoteselection.txt (text/plain), 10.76 KB, created by
Stephan Wahlbrink
on 2008-06-28 06:28:22 EDT
(
hide
)
Description:
Patch for DocShare, implementation based on Annotations
Filename:
MIME Type:
Creator:
Stephan Wahlbrink
Created:
2008-06-28 06:28:22 EDT
Size:
10.76 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ecf.docshare >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.docshare/plugin.xml,v >retrieving revision 1.4 >diff -u -r1.4 plugin.xml >--- plugin.xml 16 Jun 2008 04:58:27 -0000 1.4 >+++ plugin.xml 28 Jun 2008 10:23:39 -0000 >@@ -29,5 +29,53 @@ > </menuContribution> > </extension> > >+ <extension >+ point="org.eclipse.ui.editors.annotationTypes"> >+ <type >+ name="org.eclipse.ecf.docshare.annotations.RemoteSelection"> >+ </type> >+ <type >+ name="org.eclipse.ecf.docshare.annotations.RemoteCursor" >+ super="org.eclipse.ecf.docshare.annotations.RemoteSelection"> >+ </type> >+ </extension> >+ <extension >+ point="org.eclipse.ui.editors.markerAnnotationSpecification"> >+ <specification >+ annotationType="org.eclipse.ecf.docshare.annotations.RemoteSelection" >+ colorPreferenceKey="remoteSelectionColor" >+ colorPreferenceValue="231,223,143" >+ contributesToHeader="false" >+ highlightPreferenceKey="remoteSelectionHighlighting" >+ highlightPreferenceValue="true" >+ includeOnPreferencePage="true" >+ label="Remote Selection" >+ overviewRulerPreferenceKey="remoteSelectionIndicationInOverviewRuler" >+ overviewRulerPreferenceValue="true" >+ presentationLayer="5" >+ textPreferenceKey="remoteSelectionTextIndication" >+ textPreferenceValue="false" >+ textStylePreferenceKey="remoteSelectionTextIndicationStyle" >+ textStylePreferenceValue="NONE"> >+ </specification> >+ <specification >+ annotationType="org.eclipse.ecf.docshare.annotations.RemoteCursor" >+ colorPreferenceKey="remoteCursorColor" >+ colorPreferenceValue="166,138,60" >+ contributesToHeader="false" >+ highlightPreferenceKey="remoteCursorHighlighting" >+ highlightPreferenceValue="false" >+ includeOnPreferencePage="true" >+ label="Remote Cursor" >+ overviewRulerPreferenceKey="remoteCursorIndicationInOverviewRuler" >+ overviewRulerPreferenceValue="true" >+ presentationLayer="5" >+ textPreferenceKey="remoteCursorTextIndication" >+ textPreferenceValue="true" >+ textStylePreferenceKey="remoteCursorTextIndicationStyle" >+ textStylePreferenceValue="IBEAM"> >+ </specification> >+ </extension> >+ > > </plugin> >Index: src/org/eclipse/ecf/internal/provisional/docshare/DocShare.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.ecf/plugins/org.eclipse.ecf.docshare/src/org/eclipse/ecf/internal/provisional/docshare/DocShare.java,v >retrieving revision 1.4 >diff -u -r1.4 DocShare.java >--- src/org/eclipse/ecf/internal/provisional/docshare/DocShare.java 16 Jun 2008 16:33:45 -0000 1.4 >+++ src/org/eclipse/ecf/internal/provisional/docshare/DocShare.java 28 Jun 2008 10:23:39 -0000 >@@ -13,8 +13,7 @@ > package org.eclipse.ecf.internal.provisional.docshare; > > import java.io.*; >-import java.util.Iterator; >-import java.util.List; >+import java.util.*; > import org.eclipse.core.filesystem.EFS; > import org.eclipse.core.filesystem.IFileStore; > import org.eclipse.core.runtime.*; >@@ -31,6 +30,8 @@ > import org.eclipse.ecf.internal.provisional.docshare.messages.*; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.text.*; >+import org.eclipse.jface.text.source.*; >+import org.eclipse.jface.viewers.*; > import org.eclipse.osgi.util.NLS; > import org.eclipse.swt.custom.StyledText; > import org.eclipse.swt.widgets.Control; >@@ -48,6 +49,89 @@ > */ > public class DocShare extends AbstractShare { > >+ private static class SelectionReceiver { >+ >+ private static final String SELECTION_ANNOTATION_ID = "org.eclipse.ecf.docshare.annotations.RemoteSelection"; //$NON-NLS-1$ >+ private static final String CURSOR_ANNOTATION_ID = "org.eclipse.ecf.docshare.annotations.RemoteCursor"; //$NON-NLS-1$ >+ >+ /** >+ * Annotation model of current document >+ */ >+ private IAnnotationModel annotationModel; >+ >+ /** >+ * Object to use as lock for changing in annotation model >+ */ >+ private Object annotationModelLock; >+ >+ /** >+ * Annotation for remote selection in annotationModel >+ */ >+ private Annotation currentAnnotation; >+ >+ public SelectionReceiver(ITextEditor editor) { >+ if (editor == null) { >+ return; >+ } >+ IDocumentProvider documentProvider = editor.getDocumentProvider(); >+ if (documentProvider != null) { >+ this.annotationModel = documentProvider.getAnnotationModel(editor.getEditorInput()); >+ } >+ if (this.annotationModel instanceof ISynchronizable) { >+ this.annotationModelLock = ((ISynchronizable) this.annotationModel).getLockObject(); >+ } >+ if (this.annotationModelLock == null) { >+ this.annotationModelLock = this; >+ } >+ >+ } >+ >+ void handleMessage(final SelectionMessage remoteMsg) { >+ final Position newPosition = new Position(remoteMsg.getOffset(), remoteMsg.getLength()); >+ final Annotation newAnnotation = new Annotation(newPosition.getLength() > 0 ? SELECTION_ANNOTATION_ID : CURSOR_ANNOTATION_ID, false, "Remote Selection"); >+ if (this.annotationModel != null) { >+ synchronized (this.annotationModelLock) { >+ // initial selection, create new >+ if (this.currentAnnotation == null) { >+ this.currentAnnotation = newAnnotation; >+ this.annotationModel.addAnnotation(newAnnotation, newPosition); >+ return; >+ } >+ // selection not changed, skip >+ if (this.currentAnnotation.getType() == newAnnotation.getType()) { >+ Position oldPosition = this.annotationModel.getPosition(this.currentAnnotation); >+ if (oldPosition == null || newPosition.equals(oldPosition)) { >+ return; >+ } >+ } >+ // selection changed, replace annotation >+ if (this.annotationModel instanceof IAnnotationModelExtension) { >+ Annotation[] oldAnnotations = new Annotation[] {this.currentAnnotation}; >+ this.currentAnnotation = newAnnotation; >+ Map newAnnotations = new TreeMap(); >+ newAnnotations.put(newAnnotation, newPosition); >+ ((IAnnotationModelExtension) this.annotationModel).replaceAnnotations(oldAnnotations, newAnnotations); >+ } else { >+ this.annotationModel.removeAnnotation(this.currentAnnotation); >+ this.annotationModel.addAnnotation(newAnnotation, newPosition); >+ } >+ } >+ } >+ } >+ >+ void dispose() { >+ if (this.annotationModel != null) { >+ synchronized (this.annotationModelLock) { >+ if (this.currentAnnotation != null) { >+ this.annotationModel.removeAnnotation(this.currentAnnotation); >+ this.currentAnnotation = null; >+ } >+ } >+ } >+ } >+ >+ } >+ > /** > * The ID of the initiator > */ >@@ -83,6 +167,8 @@ > // TODO provide for a user-interactive selection mechanism > SynchronizationStrategy sync; > >+ SelectionReceiver selectionReceiver; >+ > /** > * The document listener is the listener for changes to the *local* copy of > * the IDocument. This listener is responsible for sending document update >@@ -131,6 +217,33 @@ > } > }; > >+ ISelectionChangedListener selectionListener = new ISelectionChangedListener() { >+ >+ public void selectionChanged(final SelectionChangedEvent event) { >+ // If the channel is gone, then no reason to handle this. >+ if (getChannel() == null || !Activator.getDefault().isListenerActive()) { >+ return; >+ } >+ // If the listener is not active, ignore input >+ if (!Activator.getDefault().isListenerActive()) { >+ // The local editor is being updated by a remote peer, so we do >+ // not >+ // wish to echo this change. >+ return; >+ } >+ Trace.trace(Activator.PLUGIN_ID, NLS.bind("{0}.selectionChanged[{1}]", DocShare.this, event)); //$NON-NLS-1$ >+ >+ if (!(event.getSelection() instanceof ITextSelection)) { >+ return; >+ } >+ final ITextSelection textSelection = (ITextSelection) event.getSelection(); >+ final SelectionMessage msg = new SelectionMessage(textSelection.getOffset(), textSelection.getLength()); >+ >+ sendSelectionMsg(msg); >+ } >+ >+ }; >+ > /** > * Create a document sharing session instance. > * >@@ -255,6 +368,11 @@ > handleStartMessage((StartMessage) message); > } else if (message instanceof UpdateMessage) { > handleUpdateMessage((UpdateMessage) message); >+ } else if (message instanceof SelectionMessage) { >+ SelectionReceiver receiver = selectionReceiver; >+ if (receiver != null) { >+ receiver.handleMessage((SelectionMessage) message); >+ } > } else if (message instanceof StopMessage) { > handleStopMessage((StopMessage) message); > } else { >@@ -499,6 +617,13 @@ > final IDocument doc = getDocumentFromEditor(); > if (doc != null) > doc.addDocumentListener(documentListener); >+ if (this.editor != null) { >+ ISelectionProvider selectionProvider = this.editor.getSelectionProvider(); >+ if (selectionProvider instanceof IPostSelectionProvider) { >+ ((IPostSelectionProvider) selectionProvider).addPostSelectionChangedListener(selectionListener); >+ } >+ selectionReceiver = new SelectionReceiver(this.editor); >+ } > } > // used to have the ColaSynchronizer.getInstanceFor(...) call here ... > // TODO needs to be moved to a more appropriate spot, where ColaSynch'er >@@ -508,6 +633,7 @@ > } > > void localStopShare() { >+ SelectionReceiver oldSelectionReceiver; > synchronized (stateLock) { > this.ourID = null; > this.initiatorID = null; >@@ -516,8 +642,20 @@ > final IDocument doc = getDocumentFromEditor(); > if (doc != null) > doc.removeDocumentListener(documentListener); >+ if (this.editor != null) { >+ ISelectionProvider selectionProvider = this.editor.getSelectionProvider(); >+ if (selectionProvider instanceof IPostSelectionProvider) { >+ ((IPostSelectionProvider) selectionProvider).removePostSelectionChangedListener(selectionListener); >+ } >+ } >+ oldSelectionReceiver = this.selectionReceiver; >+ this.selectionReceiver = null; > this.editor = null; > } >+ >+ if (oldSelectionReceiver != null) { >+ oldSelectionReceiver.dispose(); >+ } > // clean up if necessary > // TODO abstract this to work for SynchronizationStrategy > ColaSynchronizer.cleanUpFor(this); >@@ -534,6 +672,16 @@ > } > } > >+ void sendSelectionMsg(SelectionMessage msg) { >+ if (isSharing()) { >+ try { >+ send(getOtherID(), msg); >+ } catch (final Exception e) { >+ logError(Messages.DocShare_EXCEPTION_SEND_MESSAGE, e); >+ } >+ } >+ } >+ > void sendStopMessage() { > sendStopMessage(getOtherID()); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 237923
:
105592
|
106058
|
106252
|
107805
|
126503