Search in sources :

Example 1 with IChannelContainerAdapter

use of org.eclipse.ecf.datashare.IChannelContainerAdapter in project ecf by eclipse.

the class ScreenCaptureShareRosterContributionItem 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 ScreenCaptureShare for this container (if it exists)
            final ScreenCaptureShare screenCaptureShare = ScreenCaptureShare.getScreenCaptureShare(c.getID());
            // If it does exist already, then create action to remove
            if (screenCaptureShare != null)
                return createActionRemove(c.getID(), screenCaptureShare);
            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 2 with IChannelContainerAdapter

use of org.eclipse.ecf.datashare.IChannelContainerAdapter in project ecf by eclipse.

the class ScreenCaptureShareRosterEntryContributionItem method makeActions.

protected IAction[] makeActions() {
    // Else check for Roster entry
    final IRosterEntry entry = getSelectedRosterEntry();
    final IContainer c = getContainerForRosterEntry(entry);
    // If roster entry is selected and it has a container
    if (entry != null && c != null) {
        final IChannelContainerAdapter channelAdapter = (IChannelContainerAdapter) c.getAdapter(IChannelContainerAdapter.class);
        // If the container has channel container adapter and is online/available
        if (channelAdapter != null && isAvailable(entry)) {
            final ScreenCaptureShare tmp = ScreenCaptureShare.getScreenCaptureShare(c.getID());
            // If there is an URL share associated with this container
            if (tmp != null) {
                final ScreenCaptureShare screencaptureshare = tmp;
                final IAction action = new Action() {

                    public void run() {
                        MessageDialog dialog = new MessageDialog(null, Messages.ScreenCaptureShareRosterEntryContributionItem_SCREEN_CAPTURE_MESSAGEBOX_TITLE, Window.getDefaultImage(), Messages.ScreenCaptureShareRosterEntryContributionItem_SCREEN_CAPTURE_MESSAGEBOX_MESSAGE, MessageDialog.QUESTION, new String[] { NLS.bind(Messages.ScreenCaptureShareRosterEntryContributionItem_VERIFY_SEND_BUTTON_TEXT, entry.getName()), Messages.ScreenCaptureShareRosterEntryContributionItem_VERIFY_CANCEL_BUTTON_TEXT }, 0);
                        if (dialog.open() == Window.OK) {
                            ScreenCaptureJob screenCaptureJob = new ScreenCaptureJob(Display.getCurrent(), entry.getUser().getID(), entry.getUser().getName(), new IImageSender() {

                                public void sendImage(ID targetID, ImageData imageData) {
                                    screencaptureshare.sendImage(entry.getRoster().getUser().getID(), entry.getRoster().getUser().getName(), targetID, imageData);
                                }
                            });
                            screenCaptureJob.schedule(SCREEN_CAPTURE_DELAY);
                        }
                    }
                };
                action.setText(Messages.ScreenCaptureShareRosterEntryContributionItem_SCREEN_CAPTURE_MENU);
                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) IImageSender(org.eclipse.ecf.ui.screencapture.IImageSender) IAction(org.eclipse.jface.action.IAction) ImageData(org.eclipse.swt.graphics.ImageData) IChannelContainerAdapter(org.eclipse.ecf.datashare.IChannelContainerAdapter) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) ID(org.eclipse.ecf.core.identity.ID) IContainer(org.eclipse.ecf.core.IContainer) ScreenCaptureJob(org.eclipse.ecf.ui.screencapture.ScreenCaptureJob)

Example 3 with IChannelContainerAdapter

use of org.eclipse.ecf.datashare.IChannelContainerAdapter 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 4 with IChannelContainerAdapter

use of org.eclipse.ecf.datashare.IChannelContainerAdapter 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 5 with IChannelContainerAdapter

use of org.eclipse.ecf.datashare.IChannelContainerAdapter in project ecf by eclipse.

the class DsClient2 method createChannel.

protected IChannel createChannel(IContainer container) throws ECFException {
    // Get IChannelContainerAdapter adapter
    IChannelContainerAdapter channelContainer = (IChannelContainerAdapter) container.getAdapter(IChannelContainerAdapter.class);
    // Check it's valid, throw if not
    if (channelContainer == null)
        throw new NullPointerException("cannot get channel container adapter");
    // Create channel ID with fixed name 'channel2'
    final ID channelID = IDFactory.getDefault().createID(channelContainer.getChannelNamespace(), "channel2");
    // Setup listener so then when channelmessageevents are received that
    // they present in UI
    final IChannelListener channelListener = new IChannelListener() {

        public void handleChannelEvent(final IChannelEvent event) {
            if (event instanceof IChannelMessageEvent) {
                IChannelMessageEvent msg = (IChannelMessageEvent) event;
                showMessageInUI(new String(msg.getData()));
            } else
                System.out.println("got channel event " + event);
        }
    };
    // Create channel config information
    IChannelConfig config = new BaseChannelConfig(channelID, channelListener, new HashMap());
    // Create and return new channel
    return channelContainer.createChannel(config);
}
Also used : IChannelConfig(org.eclipse.ecf.datashare.IChannelConfig) IChannelListener(org.eclipse.ecf.datashare.IChannelListener) IChannelEvent(org.eclipse.ecf.datashare.events.IChannelEvent) BaseChannelConfig(org.eclipse.ecf.datashare.BaseChannelConfig) HashMap(java.util.HashMap) IChannelContainerAdapter(org.eclipse.ecf.datashare.IChannelContainerAdapter) ID(org.eclipse.ecf.core.identity.ID) IChannelMessageEvent(org.eclipse.ecf.datashare.events.IChannelMessageEvent)

Aggregations

IChannelContainerAdapter (org.eclipse.ecf.datashare.IChannelContainerAdapter)19 IContainer (org.eclipse.ecf.core.IContainer)7 ID (org.eclipse.ecf.core.identity.ID)6 IChannel (org.eclipse.ecf.datashare.IChannel)5 IRosterEntry (org.eclipse.ecf.presence.roster.IRosterEntry)4 Action (org.eclipse.jface.action.Action)4 IAction (org.eclipse.jface.action.IAction)4 HashMap (java.util.HashMap)3 IChannelListener (org.eclipse.ecf.datashare.IChannelListener)3 IChannelEvent (org.eclipse.ecf.datashare.events.IChannelEvent)3 IRoster (org.eclipse.ecf.presence.roster.IRoster)3 IChannelMessageEvent (org.eclipse.ecf.datashare.events.IChannelMessageEvent)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 Job (org.eclipse.core.runtime.jobs.Job)1 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1 BaseChannelConfig (org.eclipse.ecf.datashare.BaseChannelConfig)1 IChannelConfig (org.eclipse.ecf.datashare.IChannelConfig)1 AbstractRosterMenuHandler (org.eclipse.ecf.presence.ui.menu.AbstractRosterMenuHandler)1