use of org.eclipse.team.internal.ecf.core.RemoteShare in project ecf by eclipse.
the class CompareWithHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IRosterEntry selectedEntry = getRosterEntry();
IRoster roster = selectedEntry.getRoster();
final IUser remoteUser = roster.getUser();
ID localId = remoteUser.getID();
ID remoteId = selectedEntry.getUser().getID();
IContainer container = (IContainer) roster.getPresenceContainerAdapter().getAdapter(IContainer.class);
final IResource resource = getResource(event);
if (resource == null) {
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), null, Messages.CompareWithHandler_FileNotSelectedError);
return null;
}
RemoteShare share = TeamSynchronization.getShare(container.getID());
final RemoteResourceVariantTreeSubscriber subscriber = new RemoteResourceVariantTreeSubscriber(share, localId, remoteId);
Job job = new Job(Messages.CompareWithHandler_ResourceComparisonJobTitle) {
protected IStatus run(IProgressMonitor monitor) {
try {
openCompareEditor(subscriber.getSyncInfo(resource, monitor), remoteUser);
return Status.OK_STATUS;
} catch (TeamException e) {
return e.getStatus();
}
}
};
job.setUser(true);
job.schedule();
return null;
}
use of org.eclipse.team.internal.ecf.core.RemoteShare in project ecf by eclipse.
the class RemotePeerSynchronizeWizard method performFinish.
public boolean performFinish() {
ID containerId = page.getContainerId();
RemoteShare share = TeamSynchronization.getShare(containerId);
IRosterEntry entry = page.getRosterEntry();
IUser remoteUser = entry.getUser();
ID ownId = entry.getRoster().getUser().getID();
IResource[] resources = page.getSelectedResources();
RemoteSubscriberParticipant participant = getSubscriberParticipant(share, ownId, remoteUser.getID());
participant.setResources(resources);
TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] { participant });
if (resources.length == 1) {
participant.refresh(resources, NLS.bind(Messages.SynchronizeWithHandler_RemoteSynchronizationTaskName, remoteUser.getNickname()), NLS.bind(Messages.SynchronizeWithHandler_RemoteSynchronizationResourceDescription, resources[0].getName(), remoteUser.getNickname()), null);
} else {
participant.refresh(resources, NLS.bind(Messages.SynchronizeWithHandler_RemoteSynchronizationTaskName, remoteUser.getNickname()), NLS.bind(Messages.SynchronizeWithHandler_RemoteSynchronizationResourcesDescription, remoteUser.getNickname()), null);
}
return true;
}
use of org.eclipse.team.internal.ecf.core.RemoteShare in project ecf by eclipse.
the class SynchronizeWithHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IRosterEntry selectedEntry = getRosterEntry();
IRoster roster = selectedEntry.getRoster();
final IUser remoteUser = roster.getUser();
final ID localId = remoteUser.getID();
final ID remoteId = selectedEntry.getUser().getID();
IContainer container = (IContainer) roster.getPresenceContainerAdapter().getAdapter(IContainer.class);
final IResource[] resources = getResources(event);
final RemoteShare share = TeamSynchronization.getShare(container.getID());
IWorkbenchPart part = HandlerUtil.getActivePart(event);
final IWorkbenchPartSite site = part == null ? null : part.getSite();
final Shell shell = HandlerUtil.getActiveShellChecked(event);
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
final boolean[] response = { true };
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
if (resources.length == 1) {
monitor.beginTask(NLS.bind(Messages.SynchronizeWithHandler_SynchronizeResourceTaskName, resources[0].getName()), IProgressMonitor.UNKNOWN);
} else {
monitor.beginTask(Messages.SynchronizeWithHandler_SynchronizeResourcesTaskName, IProgressMonitor.UNKNOWN);
}
try {
if (share.sendShareRequest(localId, remoteId, resources, monitor)) {
scheduleRefreshJob(share, localId, remoteId, resources, remoteUser, site);
} else {
response[0] = false;
}
} catch (ECFException e) {
throw new InvocationTargetException(e);
} catch (OperationCanceledException e) {
// operation, but check for this just in case
if (!monitor.isCanceled()) {
throw e;
}
}
}
};
try {
dialog.run(true, true, runnable);
if (!response[0]) {
MessageDialog.openInformation(shell, null, Messages.SynchronizeWithHandler_SynchronizeRequestDenial);
}
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause instanceof ECFException) {
MessageDialog.openError(shell, null, Messages.SynchronizeWithHandler_SynchronizeRequestError);
}
// $NON-NLS-1$
TeamSynchronization.log("Failed to contact remote peer", cause);
} catch (InterruptedException e) {
Thread.interrupted();
MessageDialog.openError(shell, null, Messages.SynchronizeWithHandler_SynchronizeRequestInterrupted);
// $NON-NLS-1$
TeamSynchronization.log("Synchronization request operation was interrupted", e);
}
return null;
}
Aggregations