Search in sources :

Example 1 with ResourcesShare

use of org.eclipse.ecf.internal.sync.resources.core.ResourcesShare in project ecf by eclipse.

the class SyncResourcesUI method addResourceShare.

public static ResourcesShare addResourceShare(ID containerID, IChannelContainerAdapter channelAdapter) throws ECFException {
    ResourcesShare resourcesShare = SyncResourcesCore.getResourcesShare(containerID);
    if (resourcesShare == null) {
        resourcesShare = new WorkbenchAwareResourcesShare(containerID, channelAdapter);
        SyncResourcesCore.addResourcesShare(containerID, resourcesShare);
    }
    return resourcesShare;
}
Also used : ResourcesShare(org.eclipse.ecf.internal.sync.resources.core.ResourcesShare)

Example 2 with ResourcesShare

use of org.eclipse.ecf.internal.sync.resources.core.ResourcesShare 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 3 with ResourcesShare

use of org.eclipse.ecf.internal.sync.resources.core.ResourcesShare in project ecf by eclipse.

the class ResourcesShareHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
    if (!(selection instanceof IStructuredSelection)) {
        return null;
    }
    IStructuredSelection iss = (IStructuredSelection) selection;
    Object o = iss.getFirstElement();
    IResource resource = null;
    if (o instanceof IAdaptable) {
        resource = (IResource) ((IAdaptable) o).getAdapter(IResource.class);
    } else {
        return null;
    }
    IPresenceContainerAdapter ipca = getRosterEntry().getRoster().getPresenceContainerAdapter();
    IContainer container = (IContainer) ipca.getAdapter(IContainer.class);
    ResourcesShare sender = SyncResourcesCore.getResourcesShare(container.getID());
    IProject project = resource.getProject();
    String projectName = project.getName();
    if (!SyncResourcesCore.isSharing(projectName)) {
        run(HandlerUtil.getActiveShellChecked(event), sender, projectName);
    } else {
        sender.stopSharing(projectName);
    }
    return null;
}
Also used : IPresenceContainerAdapter(org.eclipse.ecf.presence.IPresenceContainerAdapter) IAdaptable(org.eclipse.core.runtime.IAdaptable) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IContainer(org.eclipse.ecf.core.IContainer) ResourcesShare(org.eclipse.ecf.internal.sync.resources.core.ResourcesShare) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject)

Example 4 with ResourcesShare

use of org.eclipse.ecf.internal.sync.resources.core.ResourcesShare 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

ResourcesShare (org.eclipse.ecf.internal.sync.resources.core.ResourcesShare)4 Iterator (java.util.Iterator)2 DocShare (org.eclipse.ecf.docshare2.DocShare)2 IProject (org.eclipse.core.resources.IProject)1 IResource (org.eclipse.core.resources.IResource)1 CoreException (org.eclipse.core.runtime.CoreException)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 IContainer (org.eclipse.ecf.core.IContainer)1 ECFException (org.eclipse.ecf.core.util.ECFException)1 IPresenceContainerAdapter (org.eclipse.ecf.presence.IPresenceContainerAdapter)1 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)1 IPostSelectionProvider (org.eclipse.jface.viewers.IPostSelectionProvider)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1