Search in sources :

Example 6 with IRosterEntry

use of org.eclipse.ecf.presence.roster.IRosterEntry in project ecf by eclipse.

the class SendMessageRosterEntryContribution method makeActions.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ecf.presence.ui.roster.AbstractPresenceContributionItem#makeActions()
	 */
protected IAction[] makeActions() {
    IAction action = null;
    final IRosterEntry rosterEntry = getSelectedRosterEntry();
    if (rosterEntry != null) {
        if (initializeChannelFor(getContainerForRosterEntry(rosterEntry)) != null) {
            action = new Action() {

                public void run() {
                    sendDataToChannel(rosterEntry);
                }
            };
            action.setText("Send Message and URL");
            action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_DEF_VIEW));
            return new IAction[] { action };
        }
    }
    return null;
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry)

Example 7 with IRosterEntry

use of org.eclipse.ecf.presence.roster.IRosterEntry 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;
}
Also used : RemoteShare(org.eclipse.team.internal.ecf.core.RemoteShare) IUser(org.eclipse.ecf.core.user.IUser) RemoteSubscriberParticipant(org.eclipse.team.internal.ecf.ui.subscriber.RemoteSubscriberParticipant) ID(org.eclipse.ecf.core.identity.ID) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry) IResource(org.eclipse.core.resources.IResource)

Example 8 with IRosterEntry

use of org.eclipse.ecf.presence.roster.IRosterEntry 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 IRosterEntry

use of org.eclipse.ecf.presence.roster.IRosterEntry 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 IRosterEntry

use of org.eclipse.ecf.presence.roster.IRosterEntry in project ecf by eclipse.

the class DocShareRosterMenuHandler method execute.

/**
 * @throws ExecutionException
 */
public Object execute(ExecutionEvent arg0) throws ExecutionException {
    IRosterEntry rosterEntry = getRosterEntry();
    if (rosterEntry != null) {
        IRoster roster = rosterEntry.getRoster();
        final IContainer container = (IContainer) roster.getPresenceContainerAdapter().getAdapter(IContainer.class);
        if (container.getConnectedID() == null)
            showErrorMessage(Messages.DocShareRosterMenuHandler_ERROR_NOT_CONNECTED);
        final DocShare sender = Activator.getDefault().getDocShare(container.getID());
        if (sender == null)
            showErrorMessage(Messages.DocShareRosterMenuHandler_ERROR_NO_SENDER);
        if (sender.isSharing())
            showErrorMessage(Messages.DocShareRosterMenuHandler_ERROR_EDITOR_ALREADY_SHARING);
        final ITextEditor textEditor = getTextEditor();
        if (textEditor == null)
            showErrorMessage(Messages.DocShareRosterMenuHandler_EXCEPTION_EDITOR_NOT_TEXT);
        final String inputName = getInputName(textEditor);
        if (inputName == null)
            showErrorMessage(Messages.DocShareRosterMenuHandler_NO_FILENAME_WITH_CONTENT);
        final IUser user = roster.getUser();
        sender.startShare(user.getID(), user.getName(), rosterEntry.getUser().getID(), inputName, textEditor);
    }
    return null;
}
Also used : IRoster(org.eclipse.ecf.presence.roster.IRoster) DocShare(org.eclipse.ecf.docshare.DocShare) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) IUser(org.eclipse.ecf.core.user.IUser) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry) IContainer(org.eclipse.ecf.core.IContainer)

Aggregations

IRosterEntry (org.eclipse.ecf.presence.roster.IRosterEntry)15 IContainer (org.eclipse.ecf.core.IContainer)9 Action (org.eclipse.jface.action.Action)6 IAction (org.eclipse.jface.action.IAction)6 IUser (org.eclipse.ecf.core.user.IUser)5 IRoster (org.eclipse.ecf.presence.roster.IRoster)5 ID (org.eclipse.ecf.core.identity.ID)4 IChannelContainerAdapter (org.eclipse.ecf.datashare.IChannelContainerAdapter)4 IResource (org.eclipse.core.resources.IResource)3 IRosterGroup (org.eclipse.ecf.presence.roster.IRosterGroup)3 RemoteShare (org.eclipse.team.internal.ecf.core.RemoteShare)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Iterator (java.util.Iterator)2 List (java.util.List)2 IRosterItem (org.eclipse.ecf.presence.roster.IRosterItem)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Job (org.eclipse.core.runtime.jobs.Job)1 IContainerManager (org.eclipse.ecf.core.IContainerManager)1 ISharedObject (org.eclipse.ecf.core.sharedobject.ISharedObject)1