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 126503 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 (4)
docshare4.txt (text/plain), 10.71 KB, created by
Stephan Wahlbrink
on 2009-02-23 17:05:14 EST
(
hide
)
Description:
Patch for DocShare, implementation based on Annotations (4)
Filename:
MIME Type:
Creator:
Stephan Wahlbrink
Created:
2009-02-23 17:05:14 EST
Size:
10.71 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ecf.docshare >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/framework/bundles/org.eclipse.ecf.docshare/plugin.xml,v >retrieving revision 1.5 >diff -u -r1.5 plugin.xml >--- plugin.xml 26 Nov 2008 23:54:03 -0000 1.5 >+++ plugin.xml 23 Feb 2009 21:44:27 -0000 >@@ -29,5 +29,52 @@ > </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/docshare/DocShare.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.ecf/framework/bundles/org.eclipse.ecf.docshare/src/org/eclipse/ecf/docshare/DocShare.java,v >retrieving revision 1.20 >diff -u -r1.20 DocShare.java >--- src/org/eclipse/ecf/docshare/DocShare.java 10 Feb 2009 00:00:52 -0000 1.20 >+++ src/org/eclipse/ecf/docshare/DocShare.java 23 Feb 2009 21:44:28 -0000 >@@ -15,6 +15,8 @@ > package org.eclipse.ecf.docshare; > > import java.io.*; >+import java.util.Collections; >+import java.util.Map; > import org.eclipse.core.filesystem.EFS; > import org.eclipse.core.filesystem.IFileStore; > import org.eclipse.core.runtime.*; >@@ -36,6 +38,8 @@ > import org.eclipse.ecf.sync.doc.IDocumentSynchronizationStrategyFactory; > 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.*; >@@ -50,6 +54,97 @@ > */ > public class DocShare extends AbstractShare { > >+ public 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, >+ * <code>null</code> if no model is provided. >+ */ >+ 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 != null) { >+ if (this.annotationModel instanceof ISynchronizable) { >+ this.annotationModelLock = ((ISynchronizable) this.annotationModel).getLockObject(); >+ } >+ if (this.annotationModelLock == null) { >+ this.annotationModelLock = this; >+ } >+ } >+ } >+ } >+ >+ public void handleMessage(final SelectionMessage remoteMsg) { >+ if (this.annotationModelLock == null) { >+ return; >+ } >+ 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"); >+ synchronized (this.annotationModelLock) { >+ if (this.annotationModel != null) { >+ // 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 = Collections.singletonMap(newAnnotation, newPosition); >+ ((IAnnotationModelExtension) this.annotationModel).replaceAnnotations(oldAnnotations, newAnnotations); >+ } else { >+ this.annotationModel.removeAnnotation(this.currentAnnotation); >+ this.annotationModel.addAnnotation(newAnnotation, newPosition); >+ } >+ } >+ } >+ } >+ >+ public void dispose() { >+ if (this.annotationModelLock == null) { >+ return; >+ } >+ synchronized (this.annotationModelLock) { >+ if (this.annotationModel != null) { >+ if (this.currentAnnotation != null) { >+ this.annotationModel.removeAnnotation(this.currentAnnotation); >+ this.currentAnnotation = null; >+ } >+ this.annotationModel = null; >+ } >+ } >+ } >+ >+ } >+ > /** > * The ID of the initiator > */ >@@ -91,6 +186,11 @@ > IDocumentSynchronizationStrategyFactory factory; > > /** >+ * Handler for SelectionMessage (painting remote selection) >+ */ >+ SelectionReceiver selectionReceiver; >+ >+ /** > * Create a document sharing session instance. > * > * @param adapter >@@ -210,6 +310,37 @@ > } > }; > >+ 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()); >+ >+ try { >+ sendMessage(getOtherID(), msg.serialize()); >+ } catch (final Exception e) { >+ logError(Messages.DocShare_EXCEPTION_SEND_MESSAGE, e); >+ } >+ } >+ >+ }; >+ > /** > * Start sharing an editor's contents between two participants. This will > * send a request to start sharing with the target identified by the >@@ -283,6 +414,11 @@ > > if (message instanceof DocumentChangeMessage) { > handleUpdateMessage((DocumentChangeMessage) message); >+ } else if (message instanceof SelectionMessage) { >+ SelectionReceiver receiver = selectionReceiver; >+ if (receiver != null) { >+ receiver.handleMessage((SelectionMessage) message); >+ } > } else if (message instanceof StartMessage) { > handleStartMessage((StartMessage) message); > } else if (message instanceof StopMessage) { >@@ -590,11 +726,19 @@ > 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); >+ } > } > > } > > void localStopShare() { >+ SelectionReceiver oldSelectionReceiver; > synchronized (stateLock) { > if (rosterManager != null) > rosterManager.removeRosterListener(rosterListener); >@@ -606,12 +750,23 @@ > final IDocument doc = getDocumentFromEditor(); > if (doc != null) > doc.removeDocumentListener(documentListener); >- if (editor != null) { >- editor.getSite().getPage().removePartListener(partListener); >+ if (this.editor != null) { >+ this.editor.getSite().getPage().removePartListener(partListener); >+ >+ 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(); >+ } > } > > void sendStopMessage() {
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
Flags:
slewis
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 237923
:
105592
|
106058
|
106252
|
107805
| 126503