Examples of FileTransfer


Examples of org.directwebremoting.io.FileTransfer

        {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
        }
        id = id.substring(downloadHandlerUrl.length());

        FileTransfer transfer = downloadManager.getFileTransfer(id);
        if (transfer == null)
        {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
        }
        else
        {
            if (transfer.getSize() > 0)
            {
                response.setContentLength((int) transfer.getSize());
            }

            String filename = transfer.getFilename();
            if (filename != null)
            {
                response.setHeader("Content-disposition", "attachment; filename=\"" + filename + "\"");
            }

            response.setContentType(transfer.getMimeType());

            OutputStreamLoader loader = null;
            try
            {
                loader = transfer.getOutputStreamLoader();
                loader.load(response.getOutputStream());
            }
            finally
            {
                LocalUtil.close(loader);
View Full Code Here

Examples of org.directwebremoting.io.FileTransfer

                    public void close() throws IOException
                    {
                        formField.getInputStream().close();
                    }
                };
                return new FileTransfer(formField.getName(), formField.getMimeType(), formField.getFileSize(), inFactory);
            }
            else if (paramType == InputStream.class)
            {
                return formField.getInputStream();
            }
View Full Code Here

Examples of org.directwebremoting.io.FileTransfer

            return new NonNestedOutboundVariable("null");
        }

        try
        {
            FileTransfer transfer;

            if (object instanceof BufferedImage)
            {
                transfer = new FileTransfer((BufferedImage) object, "png");
            }
            else if (object instanceof InputStream)
            {
                final InputStream in = (InputStream) object;
                transfer = new FileTransfer("download.dat", "binary/octet-stream", -1, new InputStreamFactory()
                {
                    public InputStream getInputStream() throws IOException
                    {
                        return in;
                    }

                    public void close() throws IOException
                    {
                        in.close();
                    }
                });
            }
            else if (object instanceof FileTransfer)
            {
                transfer = (FileTransfer) object;
            }
            else if (object.getClass().isArray() && object.getClass().getComponentType() == Byte.TYPE)
            {
                transfer = new FileTransfer("download.dat", "binary/octet-stream", (byte[]) object);
            }
            else
            {
                throw new ConversionException(object.getClass());
            }
View Full Code Here

Examples of org.directwebremoting.io.FileTransfer

        // Parts 0 and 1 are the prefix and id. We know they're right
        String mimeType = parts[2].replace(".", "/");
        String filename = parts[3];
        final InputStream in = new FileInputStream(matched);

        return new FileTransfer(filename, mimeType, matched.length(), new InputStreamFactory()
        {
            public InputStream getInputStream() throws IOException
            {
                return in;
            }
View Full Code Here

Examples of org.directwebremoting.io.FileTransfer

        // Parts 0 and 1 are the prefix and id. We know they're right
        String mimeType = decodeFileNameSegment(parts[2]);
        String filename = decodeFileNameSegment(parts[3]);
        final InputStream in = new FileInputStream(matched);

        return new FileTransfer(filename, mimeType, matched.length(), new InputStreamFactory()
        {
            public InputStream getInputStream() throws IOException
            {
                return in;
            }
View Full Code Here

Examples of org.directwebremoting.io.FileTransfer

        document.addCreator("DWR.war using iText");
        document.open();
        document.add(new Paragraph(contents));
        document.close();

        return new FileTransfer("example.pdf", "application/pdf", buffer.toByteArray());
    }
View Full Code Here

Examples of org.eclipse.swt.dnd.FileTransfer

    dt.setTransfer(new Transfer[] { FileTransfer.getInstance() });
    dt.addDropListener(new DropTargetAdapter() {
      @Override
      public void drop(DropTargetEvent event) {
        String fileList[] = null;
        FileTransfer ft = FileTransfer.getInstance();
        if (ft.isSupportedType(event.currentDataType)) {
          fileList = (String[]) event.data;
        }
        if (fileList != null && fileList.length > 0) {
          String fileString = fileList[0];
          documentSource.setText(fileString);
        }
      }
    });

    documentSink = new Text(this, SWT.SINGLE | SWT.BORDER);
    FormData fdatag = new FormData();
    fdatag.width = 200;
    fdatag.left = new FormAttachment(0, 1000, 5);
    fdatag.top = new FormAttachment(0, 1000, 30);
    fdatag.right = new FormAttachment(1000, 1000, -5);
    documentSink.setLayoutData(fdatag);
    documentSink.setToolTipText("Document gold output folder...");
    documentSink.setMessage("Document gold output folder...");
    DropTarget dtg = new DropTarget(documentSink, DND.DROP_DEFAULT | DND.DROP_MOVE);
    dtg.setTransfer(new Transfer[] { FileTransfer.getInstance() });
    dtg.addDropListener(new DropTargetAdapter() {
      @Override
      public void drop(DropTargetEvent event) {
        String fileList[] = null;
        FileTransfer ft = FileTransfer.getInstance();
        if (ft.isSupportedType(event.currentDataType)) {
          fileList = (String[]) event.data;
        }
        if (fileList != null && fileList.length > 0) {
          String fileString = fileList[0];
          documentSink.setText(fileString);
        }
      }
    });

    typeSystem = new Text(this, SWT.SINGLE | SWT.BORDER);
    FormData fdata2 = new FormData();
    fdata2.width = 200;
    fdata2.left = new FormAttachment(0, 1000, 5);
    fdata2.top = new FormAttachment(0, 1000, 55);
    fdata2.right = new FormAttachment(1000, 1000, -5);
    typeSystem.setLayoutData(fdata2);
    typeSystem.setToolTipText("Type System...");
    typeSystem.setMessage("Type System...");
    DropTarget dt1 = new DropTarget(typeSystem, DND.DROP_DEFAULT | DND.DROP_MOVE);
    dt1.setTransfer(new Transfer[] { FileTransfer.getInstance() });
    dt1.addDropListener(new DropTargetAdapter() {
      @Override
      public void drop(DropTargetEvent event) {
        String fileList[] = null;
        FileTransfer ft = FileTransfer.getInstance();
        if (ft.isSupportedType(event.currentDataType)) {
          fileList = (String[]) event.data;
        }
        if (fileList != null && fileList.length > 0) {
          String fileString = fileList[0];
          typeSystem.setText(fileString);
View Full Code Here

Examples of org.eclipse.swt.dnd.FileTransfer

        int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT;
        Control control = tableViewer.getControl();
        DropTarget target = new DropTarget(control, operations);

        final TextTransfer textTransfer = TextTransfer.getInstance();
        final FileTransfer fileTransfer = FileTransfer.getInstance();
        final URLTransfer urlTransfer = URLTransfer.getInstance();
        final UDigByteAndLocalTransfer omsboxTransfer = UDigByteAndLocalTransfer.getInstance();
        Transfer[] types = new Transfer[]{fileTransfer, textTransfer, urlTransfer, omsboxTransfer};
        target.setTransfer(types);
        target.addDropListener(new DropTargetListener(){
            @SuppressWarnings("nls")
            public void drop( DropTargetEvent event ) {
                if (textTransfer.isSupportedType(event.currentDataType)) {
                    String text = (String) event.data;
                    System.out.println(text);
                }
                if (fileTransfer.isSupportedType(event.currentDataType)) {
                    String[] files = (String[]) event.data;
                    if (files.length > 0) {
                        File file = new File(files[0]);
                        if (file.exists()) {
                            addFileToViewer(file);
View Full Code Here

Examples of org.eclipse.swt.dnd.FileTransfer

                        }catch (Exception e) {
                            toSet.remove(t);
                        }
                    }
                    if (transfer instanceof FileTransfer) {
                        FileTransfer t = (FileTransfer) transfer;
                        try{
                            t.javaToNative(element, t.getSupportedTypes()[0]);
                        }catch (Exception e) {
                            toSet.remove(t);
                        }
                    }
                    if (transfer instanceof RTFTransfer) {
                        RTFTransfer t = (RTFTransfer) transfer;
                        try{
                            t.javaToNative(element, t.getSupportedTypes()[0]);
                        }catch (Exception e) {
                            toSet.remove(t);
                        }
                    }
                    if (transfer instanceof HTMLTransfer) {
                        HTMLTransfer t = (HTMLTransfer) transfer;
                        try{
                            t.javaToNative(element, t.getSupportedTypes()[0]);
                        }catch (Exception e) {
                            toSet.remove(t);
                        }
                    }
                }
View Full Code Here

Examples of org.eclipse.swt.dnd.FileTransfer

    private void addDrop() {
        int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT;
        DropTarget target = new DropTarget(text, operations);

        final TextTransfer textTransfer = TextTransfer.getInstance();
        final FileTransfer fileTransfer = FileTransfer.getInstance();
        final URLTransfer urlTransfer = URLTransfer.getInstance();
        final UDigByteAndLocalTransfer omsboxTransfer = UDigByteAndLocalTransfer.getInstance();
        Transfer[] types = new Transfer[]{fileTransfer, textTransfer, urlTransfer, omsboxTransfer};
        target.setTransfer(types);
        target.addDropListener(new DropTargetListener(){
            public void drop( DropTargetEvent event ) {
                if (textTransfer.isSupportedType(event.currentDataType)) {
                    String text = (String) event.data;
                    System.out.println(text);
                }
                if (fileTransfer.isSupportedType(event.currentDataType)) {
                    String[] files = (String[]) event.data;
                    if (files.length > 0) {
                        File file = new File(files[0]);
                        if (file.exists()) {
                            setTextContent(file);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.