Search in sources :

Example 1 with DocShare

use of org.eclipse.ecf.docshare.DocShare in project ecf by eclipse.

the class DocShareRosterMenuContributionItem method createContributionItemsForPresenceContainer.

/* (non-Javadoc)
	 * @see org.eclipse.ecf.presence.ui.menu.AbstractRosterMenuContributionItem#createContributionItemsForPresenceContainer(org.eclipse.ecf.presence.IPresenceContainerAdapter)
	 */
protected IContributionItem[] createContributionItemsForPresenceContainer(IPresenceContainerAdapter presenceContainerAdapter) {
    final IContainer container = (IContainer) presenceContainerAdapter.getAdapter(IContainer.class);
    if (container == null)
        return NO_CONTRIBUTIONS;
    final DocShare docShare = Activator.getDefault().getDocShare(container.getID());
    if (docShare == null)
        return NO_CONTRIBUTIONS;
    final IRoster roster = presenceContainerAdapter.getRosterManager().getRoster();
    final IContributionItem[] contributions = createContributionItemsForRoster(roster);
    if (contributions == null || contributions.length == 0)
        return NO_CONTRIBUTIONS;
    final MenuManager menuManager = createMenuManagerForRoster(roster);
    for (int i = 0; i < contributions.length; i++) {
        menuManager.add(contributions[i]);
    }
    return new IContributionItem[] { menuManager };
}
Also used : DocShare(org.eclipse.ecf.docshare.DocShare) IRoster(org.eclipse.ecf.presence.roster.IRoster) IContainer(org.eclipse.ecf.core.IContainer)

Example 2 with DocShare

use of org.eclipse.ecf.docshare.DocShare in project ecf by eclipse.

the class DocShareRosterMenuContributionItem method getContributionItems.

/* (non-Javadoc)
	 * @see org.eclipse.ecf.presence.ui.menu.AbstractRosterMenuContributionItem#getContributionItems()
	 */
protected IContributionItem[] getContributionItems() {
    // Make sure this is a text editor
    IEditorPart editorPart = getEditorPart();
    if (editorPart == null)
        return NO_CONTRIBUTIONS;
    // A frequent pattern for multi-page editors with one source page
    if (!(editorPart instanceof ITextEditor)) {
        editorPart = (IEditorPart) editorPart.getAdapter(ITextEditor.class);
        if (editorPart == null)
            return NO_CONTRIBUTIONS;
    }
    // If we are already engaged in a doc share (either as initiator or as receiver)
    // Then present menu item to stop
    final List presenceContainerAdapters = getPresenceContainerAdapters();
    for (final Iterator i = presenceContainerAdapters.iterator(); i.hasNext(); ) {
        final IPresenceContainerAdapter pca = (IPresenceContainerAdapter) i.next();
        final DocShare docShare = getDocShareForPresenceContainerAdapter(pca);
        if (docShare != null && docShare.isSharing() && docShare.getTextEditor().equals(editorPart)) {
            return getMenuContributionForStopShare(pca.getRosterManager().getRoster(), docShare, docShare.getOtherID());
        }
    }
    return super.getContributionItems();
}
Also used : IPresenceContainerAdapter(org.eclipse.ecf.presence.IPresenceContainerAdapter) DocShare(org.eclipse.ecf.docshare.DocShare) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) Iterator(java.util.Iterator) List(java.util.List)

Example 3 with DocShare

use of org.eclipse.ecf.docshare.DocShare 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

DocShare (org.eclipse.ecf.docshare.DocShare)3 IContainer (org.eclipse.ecf.core.IContainer)2 IRoster (org.eclipse.ecf.presence.roster.IRoster)2 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)2 Iterator (java.util.Iterator)1 List (java.util.List)1 IUser (org.eclipse.ecf.core.user.IUser)1 IPresenceContainerAdapter (org.eclipse.ecf.presence.IPresenceContainerAdapter)1 IRosterEntry (org.eclipse.ecf.presence.roster.IRosterEntry)1