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;
}
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);
}
}
}
}
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;
}
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);
}
}
}
Aggregations