Search in sources :

Example 1 with DocShare

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);
            }
        }
    }
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) DocShare(org.eclipse.ecf.docshare2.DocShare) IPostSelectionProvider(org.eclipse.jface.viewers.IPostSelectionProvider) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ECFException(org.eclipse.ecf.core.util.ECFException) CoreException(org.eclipse.core.runtime.CoreException) Iterator(java.util.Iterator) ResourcesShare(org.eclipse.ecf.internal.sync.resources.core.ResourcesShare)

Example 2 with DocShare

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);
}
Also used : DocShare(org.eclipse.ecf.docshare2.DocShare) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) FileChangeMessage(org.eclipse.ecf.internal.sync.resources.core.FileChangeMessage)

Example 3 with DocShare

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()]));
    }
}
Also used : DocShare(org.eclipse.ecf.docshare2.DocShare) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) FileChangeMessage(org.eclipse.ecf.internal.sync.resources.core.FileChangeMessage)

Example 4 with DocShare

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);
        }
    }
}
Also used : DocShare(org.eclipse.ecf.docshare2.DocShare) Iterator(java.util.Iterator) ResourcesShare(org.eclipse.ecf.internal.sync.resources.core.ResourcesShare)

Aggregations

DocShare (org.eclipse.ecf.docshare2.DocShare)4 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 FileChangeMessage (org.eclipse.ecf.internal.sync.resources.core.FileChangeMessage)2 ResourcesShare (org.eclipse.ecf.internal.sync.resources.core.ResourcesShare)2 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 ECFException (org.eclipse.ecf.core.util.ECFException)1 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)1 IPostSelectionProvider (org.eclipse.jface.viewers.IPostSelectionProvider)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)1