Search in sources :

Example 6 with IRoster

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;
}
Also used : IRoster(org.eclipse.ecf.presence.roster.IRoster) IChannelContainerAdapter(org.eclipse.ecf.datashare.IChannelContainerAdapter) IContainer(org.eclipse.ecf.core.IContainer)

Example 7 with IRoster

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;
}
Also used : IRoster(org.eclipse.ecf.presence.roster.IRoster) IChannelContainerAdapter(org.eclipse.ecf.datashare.IChannelContainerAdapter) IContainer(org.eclipse.ecf.core.IContainer)

Example 8 with IRoster

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;
}
Also used : ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IRoster(org.eclipse.ecf.presence.roster.IRoster) Shell(org.eclipse.swt.widgets.Shell) ECFException(org.eclipse.ecf.core.util.ECFException) RemoteShare(org.eclipse.team.internal.ecf.core.RemoteShare) IUser(org.eclipse.ecf.core.user.IUser) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry) ID(org.eclipse.ecf.core.identity.ID) IContainer(org.eclipse.ecf.core.IContainer) IResource(org.eclipse.core.resources.IResource)

Example 9 with IRoster

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());
    }
}
Also used : IRosterItem(org.eclipse.ecf.presence.roster.IRosterItem) IRoster(org.eclipse.ecf.presence.roster.IRoster) IRosterGroup(org.eclipse.ecf.presence.roster.IRosterGroup) Iterator(java.util.Iterator) Collection(java.util.Collection) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry)

Example 10 with IRoster

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;
}
Also used : IRoster(org.eclipse.ecf.presence.roster.IRoster) IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) RosterWriterHelper(org.eclipse.ecf.internal.examples.webinar.util.RosterWriterHelper)

Aggregations

IRoster (org.eclipse.ecf.presence.roster.IRoster)11 IContainer (org.eclipse.ecf.core.IContainer)8 IRosterEntry (org.eclipse.ecf.presence.roster.IRosterEntry)5 IUser (org.eclipse.ecf.core.user.IUser)3 IChannelContainerAdapter (org.eclipse.ecf.datashare.IChannelContainerAdapter)3 IResource (org.eclipse.core.resources.IResource)2 ID (org.eclipse.ecf.core.identity.ID)2 DocShare (org.eclipse.ecf.docshare.DocShare)2 RemoteShare (org.eclipse.team.internal.ecf.core.RemoteShare)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 Job (org.eclipse.core.runtime.jobs.Job)1 IContainerManager (org.eclipse.ecf.core.IContainerManager)1 ECFException (org.eclipse.ecf.core.util.ECFException)1 RosterWriterHelper (org.eclipse.ecf.internal.examples.webinar.util.RosterWriterHelper)1 IRosterGroup (org.eclipse.ecf.presence.roster.IRosterGroup)1 IRosterItem (org.eclipse.ecf.presence.roster.IRosterItem)1 MessagesView (org.eclipse.ecf.presence.ui.MessagesView)1