use of org.eclipse.ecf.docshare2.DocShare in project ecf by eclipse.
the class SyncResourcesUI method startSharing.
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, // $NON-NLS-1$
"Could not send initiation request to " + share.getReceiverID(), e);
log(status);
StatusManager.getManager().handle(status, StatusManager.SHOW);
} catch (CoreException e) {
IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, // $NON-NLS-1$
"Could not connect to the file buffer of " + file.getFullPath(), e);
log(status);
StatusManager.getManager().handle(status, StatusManager.SHOW);
}
}
}
}
use of org.eclipse.ecf.docshare2.DocShare in project ecf by eclipse.
the class WorkbenchAwareResourcesShare method lock.
protected void lock(IModelChange[] remoteChanges) {
DocShare docShare = SyncResourcesUI.getDocShare(getContainerID());
if (docShare != null) {
List paths = new ArrayList(remoteChanges.length);
for (int i = 0; i < remoteChanges.length; i++) {
if (remoteChanges[i] instanceof FileChangeMessage) {
String path = ((FileChangeMessage) remoteChanges[i]).getPath();
paths.add(path);
}
}
docShare.lock((String[]) paths.toArray(new String[paths.size()]));
}
super.lock(remoteChanges);
}
use of org.eclipse.ecf.docshare2.DocShare in project ecf by eclipse.
the class WorkbenchAwareResourcesShare method unlock.
protected void unlock(IModelChange[] remoteChanges) {
super.unlock(remoteChanges);
DocShare docShare = SyncResourcesUI.getDocShare(getContainerID());
if (docShare != null) {
List paths = new ArrayList(remoteChanges.length);
for (int i = 0; i < remoteChanges.length; i++) {
if (remoteChanges[i] instanceof FileChangeMessage) {
String path = ((FileChangeMessage) remoteChanges[i]).getPath();
paths.add(path);
}
}
docShare.unlock((String[]) paths.toArray(new String[paths.size()]));
}
}
use of org.eclipse.ecf.docshare2.DocShare in project ecf by eclipse.
the class SyncResourcesUI method stopSharing.
private void stopSharing(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) && unshare(file)) {
DocShare docShare = getDocShare(share.getContainerID());
stopSharing(docShare, share.getReceiverID(), editor, file);
}
}
}
Aggregations