use of org.eclipse.ecf.filetransfer.events.IOutgoingFileTransferResponseEvent in project ecf by eclipse.
the class XMPPCompoundContributionItem method sendFileToTarget.
private void sendFileToTarget(ISendFileTransferContainerAdapter 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
// $NON-NLS-1$
fd.setFilterPath(System.getProperty("user.home"));
fd.setText(NLS.bind(Messages.XMPPCompoundContributionItem_CHOOSE_FILE, targetID.getName()));
final String res = fd.open();
if (res != null) {
final File aFile = new File(res);
try {
final IFileID targetFileID = FileIDFactory.getDefault().createFileID(fileTransfer.getOutgoingNamespace(), new Object[] { targetID, res });
fileTransfer.sendOutgoingRequest(targetFileID, aFile, new IFileTransferListener() {
public void handleTransferEvent(final IFileTransferEvent event) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
// 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 (final Exception e) {
MessageDialog.openError(shell, Messages.XMPPCompoundContributionItem_SEND_ERROR_TITLE, NLS.bind(Messages.XMPPCompoundContributionItem_SEND_ERROR_MESSAGE, res, e.getLocalizedMessage()));
}
}
}
Aggregations