private void startSharing(ITextEditor editor, IFile file) {
String projectName = file.getProject().getName();
for (Iterator it = SyncResourcesCore.getResourceShares().iterator(); it
.hasNext();) {
ResourcesShare share = (ResourcesShare) it.next();
if (share.isSharing(projectName) && share(file)) {
DocShare docShare = getDocShare(share.getContainerID());
try {
IAnnotationModel annotationModel = editor
.getDocumentProvider().getAnnotationModel(
editor.getEditorInput());
docShare.startSharing(share.getLocalID(), share
.getReceiverID(), file.getFullPath().toString(),
annotationModel);
ISelectionProvider provider = editor.getSelectionProvider();
if (provider instanceof IPostSelectionProvider) {
ISelectionChangedListener listener = new SelectionChangedListener(
share.getReceiverID(), file.getFullPath()
.toString(), docShare);
((IPostSelectionProvider) provider)
.addPostSelectionChangedListener(listener);
sharedEditors.put(editor, listener);
}
} catch (ECFException e) {
IStatus status = new Status(IStatus.ERROR, PLUGIN_ID,
"Could not send initiation request to " //$NON-NLS-1$
+ share.getReceiverID(), e);
log(status);
StatusManager.getManager().handle(status,
StatusManager.SHOW);
} catch (CoreException e) {
IStatus status = new Status(IStatus.ERROR, PLUGIN_ID,