Example usage for java.awt.dnd DropTargetDropEvent getTransferable

List of usage examples for java.awt.dnd DropTargetDropEvent getTransferable

Introduction

In this page you can find the example usage for java.awt.dnd DropTargetDropEvent getTransferable.

Prototype


public Transferable getTransferable() 

Source Link

Document

This method returns the Transferable object associated with the drop.

Usage

From source file:se.trixon.pacoma.ui.MainFrame.java

private void initListeners() {
    mActionManager.addAppListener(new ActionManager.AppListener() {
        @Override/*ww w  .j a v  a 2  s  .  c  o  m*/
        public void onCancel(ActionEvent actionEvent) {
        }

        @Override
        public void onMenu(ActionEvent actionEvent) {
            if (actionEvent.getSource() != menuButton) {
                menuButtonMousePressed(null);
            }
        }

        @Override
        public void onOptions(ActionEvent actionEvent) {
            showOptions();
        }

        @Override
        public void onQuit(ActionEvent actionEvent) {
            quit();
        }

        @Override
        public void onRedo(ActionEvent actionEvent) {
            mCollage.nextHistory();
            updateToolButtons();
        }

        @Override
        public void onStart(ActionEvent actionEvent) {
        }

        @Override
        public void onUndo(ActionEvent actionEvent) {
            mCollage.prevHistory();
            updateToolButtons();
        }
    });

    mActionManager.addProfileListener(new ActionManager.ProfileListener() {
        @Override
        public void onAdd(ActionEvent actionEvent) {
            addImages();
        }

        @Override
        public void onClear(ActionEvent actionEvent) {
            mCollage.clearFiles();
        }

        @Override
        public void onClose(ActionEvent actionEvent) {
            setTitle("pacoma");
            mActionManager.setEnabledDocumentActions(false);
            canvasPanel.close();
        }

        @Override
        public void onEdit(ActionEvent actionEvent) {
            editCollage(mCollage);
        }

        @Override
        public void onRegenerate(ActionEvent actionEvent) {
            //TODO
        }

        @Override
        public void onNew(ActionEvent actionEvent) {
            editCollage(null);
            if (mCollage != null && mCollage.getName() != null) {
                setTitle(mCollage);
                canvasPanel.open(mCollage);
                mActionManager.getAction(ActionManager.CLEAR).setEnabled(false);
                mActionManager.getAction(ActionManager.REGENERATE).setEnabled(false);
            }
        }

        @Override
        public void onOpen(ActionEvent actionEvent) {
            initFileDialog(mCollageFileNameExtensionFilter);

            if (SimpleDialog.openFile()) {
                try {
                    open(SimpleDialog.getPath());
                } catch (IOException ex) {
                    Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }

        @Override
        public void onSave(ActionEvent actionEvent) {
            save();
        }

        @Override
        public void onSaveAs(ActionEvent actionEvent) {
            saveAs();
        }
    });

    mCollagePropertyChangeListener = () -> {
        if (mCollage != null) {
            setTitle(mCollage);
            mActionManager.getAction(ActionManager.SAVE).setEnabled(true);
            mActionManager.getAction(ActionManager.CLEAR).setEnabled(mCollage.hasImages());
            mActionManager.getAction(ActionManager.REGENERATE).setEnabled(mCollage.hasImages());
        }
    };

    mDropTarget = new DropTarget() {
        @Override
        public synchronized void drop(DropTargetDropEvent evt) {
            try {
                evt.acceptDrop(DnDConstants.ACTION_COPY);
                LinkedList<File> droppedFiles = new LinkedList<>(
                        (List<File>) evt.getTransferable().getTransferData(DataFlavor.javaFileListFlavor));
                List<File> invalidFiles = new LinkedList<>();

                droppedFiles.forEach((droppedFile) -> {
                    if (droppedFile.isFile() && FilenameUtils.isExtension(
                            droppedFile.getName().toLowerCase(Locale.getDefault()), Collage.FILE_EXT)) {
                        //all ok
                    } else {
                        invalidFiles.add(droppedFile);
                    }
                });

                invalidFiles.forEach((invalidFile) -> {
                    droppedFiles.remove(invalidFile);
                });

                switch (droppedFiles.size()) {
                case 0:
                    Message.error(MainFrame.this, Dict.Dialog.TITLE_IO_ERROR.toString(),
                            "Not a valid collage file.");
                    break;
                case 1:
                    open(droppedFiles.getFirst());
                    break;
                default:
                    Message.error(MainFrame.this, Dict.Dialog.TITLE_IO_ERROR.toString(),
                            "Too many files dropped.");
                    break;
                }
            } catch (UnsupportedFlavorException | IOException ex) {
                System.err.println(ex.getMessage());
            }
        }
    };

    canvasPanel.setDropTarget(mDropTarget);
}

From source file:se.trixon.pacoma.ui.PagePanel.java

private void init() {
    mDropTarget = new DropTarget() {
        @Override/*from   w  w  w . j  a  v a 2 s. c  o  m*/
        public synchronized void drop(DropTargetDropEvent evt) {
            try {
                evt.acceptDrop(DnDConstants.ACTION_COPY);
                LinkedList<File> droppedFiles = new LinkedList<>(
                        (List<File>) evt.getTransferable().getTransferData(DataFlavor.javaFileListFlavor));
                List<File> invalidFiles = new LinkedList<>();

                droppedFiles.forEach((droppedFile) -> {
                    if (droppedFile.isFile()
                            && FilenameUtils.isExtension(droppedFile.getName().toLowerCase(Locale.getDefault()),
                                    new String[] { "jpg", "jpeg", "png" })) {
                        //all ok
                    } else {
                        invalidFiles.add(droppedFile);
                    }
                });

                invalidFiles.forEach((invalidFile) -> {
                    droppedFiles.remove(invalidFile);
                    System.out.println("remomve invalid file: " + invalidFile.getAbsolutePath());
                });

                droppedFiles.forEach((droppedFile) -> {
                    System.out.println("accept: " + droppedFile.getAbsolutePath());
                });

                mCollage.addFiles(droppedFiles);
            } catch (UnsupportedFlavorException | IOException ex) {
                System.err.println(ex.getMessage());
            }
        }
    };

    setDropTarget(mDropTarget);
}

From source file:se.trixon.solos.core.panel.NavigatorPanel.java

private void init() {
    DropTarget dropTarget = new DropTarget() {
        @Override//ww  w . j  av  a 2 s.  c o m
        public synchronized void drop(DropTargetDropEvent evt) {
            try {
                evt.acceptDrop(DnDConstants.ACTION_COPY);
                List<File> droppedFiles = (List<File>) evt.getTransferable()
                        .getTransferData(DataFlavor.javaFileListFlavor);
                File file = droppedFiles.get(0);

                if (droppedFiles.size() == 1) {
                    if (file.isDirectory()) {
                        setPath(file);
                    } else if (file.isFile()) {
                        setPath(file.getParentFile());
                    }
                } else {
                    setPath(file.getParentFile());
                }

                directoryChanged();
            } catch (UnsupportedFlavorException | IOException ex) {
            }
        }
    };

    textField.setDropTarget(dropTarget);
}

From source file:se.trixon.toolbox.geotagger.GeotaggerTopComponent.java

private void init() {
    openButton.setIcon(Pict.Actions.DOCUMENT_OPEN.get(TOOLBAR_ICON_SIZE));
    editToggleButton.setIcon(Pict.Actions.DOCUMENT_EDIT.get(TOOLBAR_ICON_SIZE));

    closeButton.setIcon(Pict.Actions.WINDOW_CLOSE.get(TOOLBAR_ICON_SIZE));
    closeButton.setEnabled(false);/*w  w  w  . j  av  a 2 s .c  o m*/

    startButton.setIcon(Pict.Actions.ARROW_RIGHT.get(ICON_SIZE));
    startButton.setToolTipText(Dict.START.getString());
    startButton.setEnabled(false);

    saveLogButton.setIcon(Pict.Actions.DOCUMENT_SAVE.get(ICON_SIZE));
    saveLogButton.setEnabled(false);

    helpButton.setIcon(Pict.Actions.HELP_CONTENTS.get(ICON_SIZE));
    helpButton.setToolTipText(Dict.HELP.getString());

    DropTarget dropTarget = new DropTarget() {
        @Override
        public synchronized void drop(DropTargetDropEvent evt) {
            try {
                evt.acceptDrop(DnDConstants.ACTION_COPY);
                List<File> droppedFiles = (List<File>) evt.getTransferable()
                        .getTransferData(DataFlavor.javaFileListFlavor);
                if (droppedFiles.get(0).isFile()) {
                    openFile(droppedFiles.get(0));
                }
            } catch (UnsupportedFlavorException | IOException ex) {
            }
        }
    };

    scrollPane.setDropTarget(dropTarget);

    mTableModel = new GeotagTableModel();
    table.setModel(mTableModel);
    mTableRowSorter = new TableRowSorter<>(mTableModel);
    table.setRowSorter(mTableRowSorter);

    TableColumnModel columnModel = table.getColumnModel();

    NumericTableCellRenderer cooNumericTableCellRenderer = new NumericTableCellRenderer(Double.class, 6);
    NumericTableCellRenderer altNumericTableCellRenderer = new NumericTableCellRenderer(Double.class, 4);

    columnModel.getColumn(GeotagTableModel.COLUMN_LATITUDE).setCellRenderer(cooNumericTableCellRenderer);
    columnModel.getColumn(GeotagTableModel.COLUMN_LONGITUDE).setCellRenderer(cooNumericTableCellRenderer);
    columnModel.getColumn(GeotagTableModel.COLUMN_ALTITUDE).setCellRenderer(altNumericTableCellRenderer);

    columnModel.getColumn(GeotagTableModel.COLUMN_NAME).setPreferredWidth(200);
    columnModel.getColumn(GeotagTableModel.COLUMN_LATITUDE).setPreferredWidth(100);
    columnModel.getColumn(GeotagTableModel.COLUMN_LONGITUDE).setPreferredWidth(100);
    columnModel.getColumn(GeotagTableModel.COLUMN_ALTITUDE).setPreferredWidth(50);
}

From source file:tk.tomby.tedit.core.Workspace.java

/**
 * Creates a new WorkSpace object./*from w  w w . j  a  v a2 s .c om*/
 */
public Workspace() {
    super();

    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    MessageManager.addMessageListener(MessageManager.BUFFER_GROUP_NAME, new IMessageListener<BufferMessage>() {
        public void receiveMessage(BufferMessage message) {
            Workspace.this.receiveMessage(message);
        }
    });

    MessageManager.addMessageListener(MessageManager.PREFERENCE_GROUP_NAME,
            new IMessageListener<PreferenceMessage>() {
                public void receiveMessage(PreferenceMessage message) {
                    Workspace.this.receiveMessage(message);
                }
            });

    bufferPane = new JTabbedPane();
    bufferPane.setMinimumSize(new Dimension(600, 400));
    bufferPane.setPreferredSize(new Dimension(800, 600));
    bufferPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);

    bottomPort = createDockingPort(0, 80);
    rightPort = createDockingPort(80, 0);
    leftPort = createDockingPort(80, 0);

    splitPaneRight = createSplitPane(JSplitPane.HORIZONTAL_SPLIT, bufferPane, rightPort);
    splitPaneLeft = createSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPort, splitPaneRight);
    splitPaneBottom = createSplitPane(JSplitPane.VERTICAL_SPLIT, splitPaneLeft, bottomPort);

    bufferPane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent evt) {
            MessageManager
                    .sendMessage(new WorkspaceMessage(evt.getSource(), bufferPane.getSelectedComponent()));
        }
    });

    bufferPane.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent evt) {
            if (evt.getClickCount() == 2) {
                splitPaneLeft.setDividerLocation(0.0d);
                splitPaneBottom.setDividerLocation(1.0d);
                splitPaneRight.setDividerLocation(1.0d);
            }
        }
    });

    DropTarget dropTarget = new DropTarget(bufferPane, new DropTargetAdapter() {
        public void drop(DropTargetDropEvent dtde) {
            if (log.isDebugEnabled()) {
                log.debug("drop start");
            }

            try {
                if (log.isDebugEnabled()) {
                    log.debug(dtde.getSource());
                }

                Transferable tr = dtde.getTransferable();
                DataFlavor[] flavors = tr.getTransferDataFlavors();

                for (int i = 0; i < flavors.length; i++) {
                    DataFlavor flavor = flavors[i];

                    if (log.isDebugEnabled()) {
                        log.debug("mime-type:" + flavor.getMimeType());
                    }

                    if (flavor.isMimeTypeEqual("text/plain")) {
                        final Object obj = tr.getTransferData(flavor);

                        if (log.isDebugEnabled()) {
                            log.debug(obj);
                        }

                        if (obj instanceof String) {
                            TaskManager.execute(new Runnable() {
                                public void run() {
                                    BufferFactory factory = new BufferFactory();
                                    IBuffer buffer = factory.createBuffer();
                                    buffer.open((String) obj);

                                    addBuffer(buffer);
                                }
                            });
                        }

                        dtde.dropComplete(true);

                        return;
                    }
                }
            } catch (UnsupportedFlavorException e) {
                log.warn(e.getMessage(), e);
            } catch (IOException e) {
                log.warn(e.getMessage(), e);
            }

            dtde.rejectDrop();

            if (log.isDebugEnabled()) {
                log.debug("drop end");
            }
        }
    });

    bufferPane.setDropTarget(dropTarget);

    this.add(BorderLayout.CENTER, splitPaneBottom);
}

From source file:tvbrowser.ui.mainframe.MainFrame.java

@Override
public void drop(DropTargetDropEvent dtde) {
    dtde.acceptDrop(dtde.getDropAction());
    File[] files = getDragDropPlugins(dtde.getCurrentDataFlavors(), dtde.getTransferable());

    try {//from   ww w .ja v  a  2 s  .  c  o m
        File tmpFile = File.createTempFile("plugins", ".txt");
        StringBuilder alreadyInstalled = new StringBuilder();
        StringBuilder notCompatiblePlugins = new StringBuilder();

        for (File jarFile : files) {
            ClassLoader classLoader = null;

            try {
                URL[] urls = new URL[] { jarFile.toURI().toURL() };
                classLoader = URLClassLoader.newInstance(urls, ClassLoader.getSystemClassLoader());
            } catch (MalformedURLException exc) {

            }

            if (classLoader != null) {
                // Get the plugin name
                String pluginName = jarFile.getName();
                pluginName = pluginName.substring(0, pluginName.length() - 4);

                try {
                    String pluginId = "java." + pluginName.toLowerCase() + "." + pluginName;

                    PluginProxy installedPlugin = PluginProxyManager.getInstance().getPluginForId(pluginId);
                    TvDataServiceProxy service = TvDataServiceProxyManager.getInstance()
                            .findDataServiceById(pluginName.toLowerCase() + '.' + pluginName);

                    Class<?> pluginClass = classLoader.loadClass(pluginName.toLowerCase() + '.' + pluginName);

                    Method getVersion = pluginClass.getMethod("getVersion", new Class[0]);

                    Version version1 = null;
                    try {
                        version1 = (Version) getVersion.invoke(pluginClass, new Object[0]);
                    } catch (Throwable t1) {
                        t1.printStackTrace();
                    }

                    if (installedPlugin != null
                            && (installedPlugin.getInfo().getVersion().compareTo(version1) > 0
                                    || (installedPlugin.getInfo().getVersion().compareTo(version1) == 0
                                            && version1.isStable()))) {
                        alreadyInstalled.append(installedPlugin.getInfo().getName()).append('\n');
                    } else if (service != null && (service.getInfo().getVersion().compareTo(version1) > 0
                            || (service.getInfo().getVersion().compareTo(version1) == 0
                                    && version1.isStable()))) {
                        alreadyInstalled.append(service.getInfo().getName()).append('\n');
                    } else {
                        RandomAccessFile write = new RandomAccessFile(tmpFile, "rw");

                        String versionString = Integer.toString(version1.getMajor()) + '.'
                                + (version1.getMinor() / 10) + (version1.getMinor() % 10) + '.'
                                + version1.getSubMinor();

                        write.seek(write.length());

                        write.writeBytes("[plugin:" + pluginName + "]\n");
                        write.writeBytes("name_en=" + pluginName + "\n");
                        write.writeBytes("filename=" + jarFile.getName() + "\n");
                        write.writeBytes("version=" + versionString + "\n");
                        write.writeBytes("stable=" + version1.isStable() + "\n");
                        write.writeBytes("download=" + jarFile.toURI().toURL() + "\n");
                        write.writeBytes("category=unknown\n");

                        write.close();

                    }
                } catch (Exception e) {
                    notCompatiblePlugins.append(jarFile.getName()).append("\n");
                }
            }
        }

        if (alreadyInstalled.length() > 0) {
            showInfoTextMessage(
                    mLocalizer.msg("update.alreadyInstalled",
                            "The following Plugin in current version are already installed:"),
                    alreadyInstalled.toString(), 400);
        }

        if (notCompatiblePlugins.length() > 0) {
            showInfoTextMessage(
                    mLocalizer.msg("update.noTVBPlugin", "This following files are not TV-Browser Plugins:"),
                    notCompatiblePlugins.toString(), 400);
        }

        if (tmpFile.length() > 0) {
            java.net.URL url = tmpFile.toURI().toURL();
            SoftwareUpdater softwareUpdater = new SoftwareUpdater(url, false, true);
            mSoftwareUpdateItems = softwareUpdater.getAvailableSoftwareUpdateItems();
            dtde.dropComplete(true);

            SoftwareUpdateDlg updateDlg = new SoftwareUpdateDlg(this, false, mSoftwareUpdateItems);
            updateDlg.setVisible(true);
        } else {
            dtde.rejectDrop();
            dtde.dropComplete(false);
        }

        if (!tmpFile.delete()) {
            tmpFile.deleteOnExit();
        }
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:unikn.dbis.univis.visualization.pivottable.VPivotTable.java

/**
 * Called when the drag operation has terminated with a drop on
 * the operable part of the drop site for the <code>DropTarget</code>
 * registered with this listener.//from  w  ww .jav a2 s.  com
 * <p/>
 * This method is responsible for undertaking
 * the transfer of the data associated with the
 * gesture. The <code>DropTargetDropEvent</code>
 * provides a means to obtain a <code>Transferable</code>
 * object that represents the data object(s) to
 * be transfered.<P>
 * From this method, the <code>DropTargetListener</code>
 * shall accept or reject the drop via the
 * acceptDrop(int dropAction) or rejectDrop() methods of the
 * <code>DropTargetDropEvent</code> parameter.
 * <p/>
 * Subsequent to acceptDrop(), but not before,
 * <code>DropTargetDropEvent</code>'s getTransferable()
 * method may be invoked, and data transfer may be
 * performed via the returned <code>Transferable</code>'s
 * getTransferData() method.
 * <p/>
 * At the completion of a drop, an implementation
 * of this method is required to signal the success/failure
 * of the drop by passing an appropriate
 * <code>boolean</code> to the <code>DropTargetDropEvent</code>'s
 * dropComplete(boolean success) method.
 * <p/>
 * Note: The data transfer should be completed before the call  to the
 * <code>DropTargetDropEvent</code>'s dropComplete(boolean success) method.
 * After that, a call to the getTransferData() method of the
 * <code>Transferable</code> returned by
 * <code>DropTargetDropEvent.getTransferable()</code> is guaranteed to
 * succeed only if the data transfer is local; that is, only if
 * <code>DropTargetDropEvent.isLocalTransfer()</code> returns
 * <code>true</code>. Otherwise, the behavior of the call is
 * implementation-dependent.
 * <p/>
 *
 * @param dtde the <code>DropTargetDropEvent</code>
 */

public void drop(DropTargetDropEvent dtde) {
    Object o = null;
    try {
        if (dtde.getTransferable().isDataFlavorSupported(VDataReferenceFlavor.COMBINATION_FLAVOR)) {
            o = dtde.getTransferable().getTransferData(VDataReferenceFlavor.COMBINATION_FLAVOR);
        }

        if (o == null) {
            dtde.rejectDrop();
            dtde.dropComplete(false);
        }
    } catch (UnsupportedFlavorException ufe) {
        dtde.rejectDrop();
        dtde.dropComplete(false);
        /*if (LOG.isErrorEnabled()) {
           LOG.error(ufe.getMessage(), ufe);
        } */
    } catch (IOException ioe) {
        dtde.rejectDrop();
        dtde.dropComplete(false);
        /*if (LOG.isErrorEnabled()) {
           LOG.error(ioe.getMessage(), ioe);
        } */
    }

    if (o instanceof VCombination) {
        VCombination combination = (VCombination) o;

        VDimension dimension = combination.getDimension();

        if (cube == null) {
            Set<VCube> supportedCubes = dimension.getSupportedCubes();
            if (supportedCubes.size() > 1) {
                cube = CubeChooser.showCubeChooser(VPivotTable.this, supportedCubes);
            } else {
                cube = supportedCubes.iterator().next();
            }

            // Check whether a cube exists or a cube has been selected on the
            // cube chooser. The chooser maybe interrupted with window close
            // and then return null.
            if (cube == null) {
                return;
            }
        }

        if (measure == null) {
            measure = combination.getMeasure();
        }

        if (function == null) {
            function = combination.getFunction();
        }

        addDimension(dimension, dtde);
        setAncestorsDropped(dimension, true);
        dtde.dropComplete(true);
    }
}

From source file:view.MainWindow.java

private void setupDropListener() {
    this.setDropTarget(new DropTarget() {
        @Override//ww  w.j  a  va 2s. co  m
        public synchronized void drop(DropTargetDropEvent evt) {
            try {
                evt.acceptDrop(DnDConstants.ACTION_COPY);
                List<File> droppedFiles = (List<File>) evt.getTransferable()
                        .getTransferData(DataFlavor.javaFileListFlavor);
                if (!droppedFiles.isEmpty()) {
                    for (File file : droppedFiles) {
                        if (file.exists() && file.isFile() && file.getAbsolutePath().endsWith(".pdf")) {
                            if (loadPdf(file, false)) {
                                ctrl.openDocument(file.getAbsolutePath());
                                workspacePanel.setDocument(ctrl.getDocument());
                            } else {
                                errorList.add(file.getAbsolutePath());
                            }
                        } else if (file.exists() && file.isDirectory()) {
                            loadFolder(file, true);
                        }
                    }
                    showErrors();
                }
            } catch (UnsupportedFlavorException | IOException ex) {
                controller.Logger.getLogger().addEntry(ex);
            }
        }
    });
}

From source file:xtrememp.PlaylistManager.java

@Override
@SuppressWarnings("unchecked")
public void drop(DropTargetDropEvent ev) {
    DropTargetContext targetContext = ev.getDropTargetContext();
    Transferable t = ev.getTransferable();
    try {//from  ww w.j av  a2s.c o  m
        // Windows
        if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
            ev.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
            addFiles((List<File>) t.getTransferData(DataFlavor.javaFileListFlavor), false);
            targetContext.dropComplete(true);
            // Linux
        } else if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
            ev.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
            String urls = (String) t.getTransferData(DataFlavor.stringFlavor);
            List<File> fileList = new ArrayList<>();
            StringTokenizer st = new StringTokenizer(urls);
            while (st.hasMoreTokens()) {
                URI uri = new URI(st.nextToken());
                fileList.add(new File(uri));
            }
            addFiles(fileList, false);
            targetContext.dropComplete(true);
        }
    } catch (UnsupportedFlavorException | InvalidDnDOperationException | IOException | URISyntaxException ex) {
        logger.error(ex.getMessage(), ex);
    }
}

From source file:zsk.JFCMainClient.java

/**
 * processing event of dropping a HTTP URL, YT-Video Image or plain text (URL) onto the frame
 * /*from w ww .j a v a2  s . c  o m*/
 * seems not to work with M$-IE (8,9) - what a pity!
 */
public void drop(DropTargetDropEvent dtde) {
    Transferable tr = dtde.getTransferable();
    DataFlavor[] flavors = tr.getTransferDataFlavors();
    DataFlavor fl = null;
    String str = "";

    debugoutput("DataFlavors found: ".concat(Integer.toString(flavors.length)));
    for (int i = 0; i < flavors.length; i++) {
        fl = flavors[i];
        if (fl.isFlavorTextType() /* || fl.isMimeTypeEqual("text/html") || fl.isMimeTypeEqual("application/x-java-url") || fl.isMimeTypeEqual("text/uri-list")*/) {
            try {
                dtde.acceptDrop(dtde.getDropAction());
            } catch (Throwable t) {
            }
            try {
                if (tr.getTransferData(fl) instanceof InputStreamReader) {
                    debugoutput("Text-InputStream");
                    BufferedReader textreader = new BufferedReader((Reader) tr.getTransferData(fl));
                    String sline = "";
                    try {
                        while (sline != null) {
                            sline = textreader.readLine();
                            if (sline != null)
                                str += sline;
                        }
                    } catch (Exception e) {
                    } finally {
                        textreader.close();
                    }
                    str = str.replaceAll("<[^>]*>", ""); // remove HTML tags, especially a hrefs - ignore HTML characters like &szlig; (which are no tags)
                } else if (tr.getTransferData(fl) instanceof InputStream) {
                    debugoutput("Byte-InputStream");
                    InputStream input = new BufferedInputStream((InputStream) tr.getTransferData(fl));
                    int idata = input.read();
                    String sresult = "";
                    while (idata != -1) {
                        if (idata != 0)
                            sresult += new Character((char) idata).toString();
                        idata = input.read();
                    } // while
                    debugoutput("sresult: ".concat(sresult));
                } else {
                    str = tr.getTransferData(fl).toString();
                }
            } catch (IOException ioe) {
            } catch (UnsupportedFlavorException ufe) {
            }

            debugoutput("drop event text: ".concat(str).concat(" (").concat(fl.getMimeType()).concat(") "));
            // insert text into textfield - almost the same as user drops text/url into this field
            // except special characaters -> from http://de.wikipedia.org/wiki/GNU-Projekt (GNU is not Unix)(&bdquo;GNU is not Unix&ldquo;)
            // two drops from same source .. one time in textfield and elsewhere - maybe we change that later?!
            if (str.matches(szYTREGEX.concat("(.*)"))) {
                synchronized (JFCMainClient.frame.textinputfield) {
                    JFCMainClient.frame.textinputfield
                            .setText(str.concat(JFCMainClient.frame.textinputfield.getText()));
                }
                debugoutput("breaking for-loop with str: ".concat(str));
                break;
            }
        } else {
            String sv = "drop event unknown type: ".concat(fl.getHumanPresentableName());
            //output(sv);
            debugoutput(sv);
        }
    } // for

    dtde.dropComplete(true);
}