use of org.eclipse.ecf.presence.roster.IRoster in project ecf by eclipse.
the class URLShareRosterContributionItem method makeActions.
protected IAction[] makeActions() {
final IRoster roster = getSelectedRoster();
if (roster != null) {
// Roster is selected
final IContainer c = getContainerForRoster(roster);
if (c != null) {
// Get existing urlshare for this container (if it exists)
final URLShare urlshare = URLShare.getURLShare(c.getID());
// If it does exist already, then create action to remove
if (urlshare != null)
return createActionRemove(c.getID(), urlshare);
final IChannelContainerAdapter channelAdapter = (IChannelContainerAdapter) c.getAdapter(IChannelContainerAdapter.class);
return (channelAdapter == null) ? null : createActionAdd(c.getID(), channelAdapter);
}
}
return null;
}
use of org.eclipse.ecf.presence.roster.IRoster in project ecf by eclipse.
the class ViewShareRosterContributionItem method makeActions.
protected IAction[] makeActions() {
final IRoster roster = getSelectedRoster();
if (roster != null) {
// Roster is selected
final IContainer c = getContainerForRoster(roster);
if (c != null) {
// Get existing ViewShare for this container (if it exists)
final ViewShare viewShare = ViewShare.getViewShare(c.getID());
// If it does exist already, then create action to remove
if (viewShare != null)
return createActionRemove(c.getID(), viewShare);
final IChannelContainerAdapter channelAdapter = (IChannelContainerAdapter) c.getAdapter(IChannelContainerAdapter.class);
return (channelAdapter == null) ? null : createActionAdd(c.getID(), channelAdapter);
}
}
return null;
}
use of org.eclipse.ecf.presence.roster.IRoster 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;
}
use of org.eclipse.ecf.presence.roster.IRoster in project ecf by eclipse.
the class RosterWriterHelper method showRosterItems.
private void showRosterItems(IRosterItem rosterItem) {
if (rosterItem == null)
return;
Collection children = null;
if (rosterItem instanceof IRoster) {
System.out.println("Roster: " + rosterItem.getName());
children = ((IRoster) rosterItem).getItems();
} else if (rosterItem instanceof IRosterGroup) {
System.out.println(" Group: " + rosterItem.getName());
children = ((IRosterGroup) rosterItem).getEntries();
} else if (rosterItem instanceof IRosterEntry) {
System.out.println(" Entry: " + rosterItem.getName());
System.out.println(" Type: " + ((IRosterEntry) rosterItem).getPresence().getType());
children = null;
}
if (children != null) {
for (Iterator i = children.iterator(); i.hasNext(); ) showRosterItems((IRosterItem) i.next());
}
}
use of org.eclipse.ecf.presence.roster.IRoster in project ecf by eclipse.
the class ShowSelectedRosterContribution method makeActions.
/* (non-Javadoc)
* @see org.eclipse.ecf.presence.ui.roster.AbstractPresenceContributionItem#makeActions()
*/
protected IAction[] makeActions() {
final IRoster roster = getSelectedRoster();
if (roster != null) {
IAction action = new Action() {
public void run() {
// Write selected roster to console
new RosterWriterHelper().writeRosterToConsole(roster);
}
};
action.setText("Show this roster on console");
action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_DEF_VIEW));
return new IAction[] { action };
} else
return null;
}
Aggregations