diff options
author | slewis | 2007-09-06 04:42:20 +0000 |
---|---|---|
committer | slewis | 2007-09-06 04:42:20 +0000 |
commit | 114d4b30e15ee296af77269950db475ec41ab663 (patch) | |
tree | 0b66eb707b26184a334e7b991ed692b420e56d06 | |
parent | 8042df74780a03d511ab4fadecbd434cf48d4826 (diff) | |
download | org.eclipse.ecf-114d4b30e15ee296af77269950db475ec41ab663.tar.gz org.eclipse.ecf-114d4b30e15ee296af77269950db475ec41ab663.tar.xz org.eclipse.ecf-114d4b30e15ee296af77269950db475ec41ab663.zip |
Updated versions for ECF 1.1
-rw-r--r-- | providers/bundles/org.eclipse.ecf.provider.xmpp.ui/src/org/eclipse/ecf/internal/provider/xmpp/ui/XMPPCompoundContributionItem.java | 89 |
1 files changed, 31 insertions, 58 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/src/org/eclipse/ecf/internal/provider/xmpp/ui/XMPPCompoundContributionItem.java b/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/src/org/eclipse/ecf/internal/provider/xmpp/ui/XMPPCompoundContributionItem.java index 59b4d6e54..ce1d37c15 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/src/org/eclipse/ecf/internal/provider/xmpp/ui/XMPPCompoundContributionItem.java +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp.ui/src/org/eclipse/ecf/internal/provider/xmpp/ui/XMPPCompoundContributionItem.java @@ -35,35 +35,31 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; -public class XMPPCompoundContributionItem extends - AbstractRosterEntryContributionItem { +public class XMPPCompoundContributionItem extends AbstractRosterEntryContributionItem { protected IAction[] makeActions() { return null; } protected IContributionItem[] getContributionItems() { - Object selection = getSelection(); + final Object selection = getSelection(); if (!(selection instanceof IRosterEntry)) { return EMPTY_ARRAY; } final IRosterEntry entry = (IRosterEntry) selection; - IContainer container = getContainerForRosterEntry(entry); + final IContainer container = getContainerForRosterEntry(entry); if (container instanceof XMPPContainer) { - IContributionItem[] contributions = new IContributionItem[1]; - final IOutgoingFileTransferContainerAdapter ioftca = (IOutgoingFileTransferContainerAdapter) container - .getAdapter(IOutgoingFileTransferContainerAdapter.class); - if (!(ioftca != null && isAvailable(entry))) return EMPTY_ARRAY; - IAction fileSendAction = new Action() { + final IContributionItem[] contributions = new IContributionItem[1]; + final IOutgoingFileTransferContainerAdapter ioftca = (IOutgoingFileTransferContainerAdapter) container.getAdapter(IOutgoingFileTransferContainerAdapter.class); + if (!(ioftca != null && isAvailable(entry))) + return EMPTY_ARRAY; + final IAction fileSendAction = new Action() { public void run() { sendFileToTarget(ioftca, entry.getUser().getID()); } }; - fileSendAction - .setText(Messages.XMPPCompoundContributionItem_SEND_FILE); - fileSendAction.setImageDescriptor(PlatformUI.getWorkbench() - .getSharedImages().getImageDescriptor( - ISharedImages.IMG_OBJ_FILE)); + fileSendAction.setText(Messages.XMPPCompoundContributionItem_SEND_FILE); + fileSendAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FILE)); contributions[0] = new ActionContributionItem(fileSendAction); return contributions; } else { @@ -71,56 +67,33 @@ public class XMPPCompoundContributionItem extends } } - private void sendFileToTarget( - IOutgoingFileTransferContainerAdapter fileTransfer, - final ID targetID) { - final Shell shell = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell(); - FileDialog fd = new FileDialog(shell, SWT.OPEN); + private void sendFileToTarget(IOutgoingFileTransferContainerAdapter fileTransfer, final ID targetID) { + final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + final FileDialog fd = new FileDialog(shell, SWT.OPEN); // XXX this should be some default path set by preferences fd.setFilterPath(System.getProperty("user.home")); //$NON-NLS-1$ - fd.setText(NLS.bind(Messages.XMPPCompoundContributionItem_CHOOSE_FILE, - targetID.getName())); + fd.setText(NLS.bind(Messages.XMPPCompoundContributionItem_CHOOSE_FILE, targetID.getName())); final String res = fd.open(); if (res != null) { - File aFile = new File(res); + final File aFile = new File(res); try { - fileTransfer.sendOutgoingRequest(targetID, aFile, - new IFileTransferListener() { - public void handleTransferEvent( - final IFileTransferEvent event) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - // XXX This should be handled more - // gracefully/with better UI (progress - // bar?) - if (event instanceof IOutgoingFileTransferResponseEvent) { - if (!((IOutgoingFileTransferResponseEvent) event) - .requestAccepted()) - MessageDialog - .openInformation( - shell, - Messages.XMPPCompoundContributionItem_FILE_SEND_REFUSED_TITLE, - NLS - .bind( - Messages.XMPPCompoundContributionItem_FILE_SEND_REFUSED_MESSAGE, - res, - targetID - .getName())); - } - } - }); + fileTransfer.sendOutgoingRequest(targetID, aFile, new IFileTransferListener() { + public void handleTransferEvent(final IFileTransferEvent event) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + // XXX This should be handled more + // gracefully/with better UI (progress + // bar?) + if (event instanceof IOutgoingFileTransferResponseEvent) { + if (!((IOutgoingFileTransferResponseEvent) event).requestAccepted()) + MessageDialog.openInformation(shell, Messages.XMPPCompoundContributionItem_FILE_SEND_REFUSED_TITLE, NLS.bind(Messages.XMPPCompoundContributionItem_FILE_SEND_REFUSED_MESSAGE, res, targetID.getName())); + } } - }, null); - } catch (OutgoingFileTransferException e) { - MessageDialog - .openError( - shell, - Messages.XMPPCompoundContributionItem_SEND_ERROR_TITLE, - NLS - .bind( - Messages.XMPPCompoundContributionItem_SEND_ERROR_MESSAGE, - res, e.getLocalizedMessage())); + }); + } + }, null); + } catch (final OutgoingFileTransferException e) { + MessageDialog.openError(shell, Messages.XMPPCompoundContributionItem_SEND_ERROR_TITLE, NLS.bind(Messages.XMPPCompoundContributionItem_SEND_ERROR_MESSAGE, res, e.getLocalizedMessage())); } } } |