Search in sources :

Example 1 with IOutgoingFileTransferSendDoneEvent

use of org.eclipse.ecf.filetransfer.events.IOutgoingFileTransferSendDoneEvent in project ecf by eclipse.

the class AbstractFileSendAction method createDefaultFileTransferListener.

/**
 * @return IFileTransferListener to use as the default listener. Must not be
 *         <code>null</code>.
 */
protected IFileTransferListener createDefaultFileTransferListener() {
    return new IFileTransferListener() {

        public void handleTransferEvent(final IFileTransferEvent event) {
            // then a custom IFileTransferListener should be provided.
            if (event instanceof IOutgoingFileTransferSendDoneEvent) {
                final IOutgoingFileTransferSendDoneEvent oftsde = (IOutgoingFileTransferSendDoneEvent) event;
                final Exception errorException = oftsde.getSource().getException();
                Display.getDefault().asyncExec(new Runnable() {

                    public void run() {
                        if (errorException == null) {
                            // $NON-NLS-1$
                            MessageDialog.openInformation(// $NON-NLS-1$
                            null, // $NON-NLS-1$
                            Messages.getString("AbstractFileSendAction.TITLE_FILE_TRANSFER_SUCESSFUL"), // $NON-NLS-1$
                            NLS.bind(// $NON-NLS-1$
                            Messages.getString("AbstractFileSendAction.MESSAGE_FILE_TRANSFER_SUCCESSFUL"), getFileTransferInfo().getFile().getName()));
                        } else {
                            // $NON-NLS-1$
                            MessageDialog.openError(// $NON-NLS-1$
                            null, // $NON-NLS-1$
                            Messages.getString("AbstractFileSendAction.TITLE_FILE_TRANSFER_FAILED"), // $NON-NLS-1$
                            NLS.bind(// $NON-NLS-1$
                            Messages.getString("AbstractFileSendAction.MESSAGE_FILE_TRANSFER_FAILED"), errorException.getLocalizedMessage()));
                        }
                    }
                });
            }
        }
    };
}
Also used : IFileTransferEvent(org.eclipse.ecf.filetransfer.events.IFileTransferEvent) IOutgoingFileTransferSendDoneEvent(org.eclipse.ecf.filetransfer.events.IOutgoingFileTransferSendDoneEvent)

Aggregations

IFileTransferEvent (org.eclipse.ecf.filetransfer.events.IFileTransferEvent)1 IOutgoingFileTransferSendDoneEvent (org.eclipse.ecf.filetransfer.events.IOutgoingFileTransferSendDoneEvent)1