private boolean testFlavor(DataFlavor inFlavor, Transferable t) { if (inFlavor != null) { if (t.isDataFlavorSupported(inFlavor)) { JConfig.log().logVerboseDebug("Accepting(2): " + inFlavor.getMimeType()); return true; } } return false; }
public StringBuffer getTransferData(Transferable t) { StringBuffer xferData = null; Object dropped; DataFlavor dtf; dtf = testAllFlavors(t); JConfig.log().logVerboseDebug("dtf == " + dtf); try { if (dtf == _htmlFlavor || dtf == _utf8HtmlFlavor || dtf == _thtmlFlavor) { /* * Annoying. */ if (JConfig.queryConfiguration("debug.uber", "false").equals("true") && JConfig.debugging) System.out.println("Ick: " + t.getTransferData(DataFlavor.getTextPlainUnicodeFlavor())); } dropped = t.getTransferData(dtf); } catch (IOException ioe) { try { dropped = t.getTransferData(DataFlavor.stringFlavor); } catch (Exception e) { JConfig.log().logDebug("I/O Exception: " + ioe); return null; } } catch (UnsupportedFlavorException ufe) { try { dropped = t.getTransferData(DataFlavor.stringFlavor); } catch (Exception e) { JConfig.log().logDebug("Unsupported flavor: " + dtf); return null; } } if (dropped != null) { if (dropped instanceof InputStream) { JConfig.log().logVerboseDebug("Dropped an InputStream"); xferData = getInputStreamData(t, dtf, (InputStream) dropped); } else if (dropped instanceof Reader) { JConfig.log().logVerboseDebug("Dropped a Reader"); xferData = getDataFromReader(new BufferedReader((Reader) dropped)); } else if (dropped instanceof java.net.URL) { JConfig.log().logVerboseDebug("Dropped a URL"); JConfig.log().logVerboseDebug("Got: " + dropped.toString()); xferData = new StringBuffer(dropped.toString()); } else if (dropped instanceof String) { JConfig.log().logVerboseDebug("Dropped a String"); xferData = new StringBuffer((String) dropped); } return (xferData); } return null; }
private boolean testFlavor(DataFlavor inFlavor, DropTargetDragEvent t) { if (inFlavor != null) { if (t.isDataFlavorSupported(inFlavor)) { /* * I think this has been debugged enough. This gets annoying. */ JConfig.log().logVerboseDebug("Accepting(1): " + inFlavor.getMimeType()); return true; } } return false; }
private void setupFlavors() { // If it's NOT Windows _windows = System.getProperty("os.name").indexOf("indows") != -1; // Deprecated, generally unused, but deprecation didn't provide // a useful alternative w/o rewriting a lot of code, so I'm keeping it for now. if (_plainFlavor == null) { // _plainFlavor = DataFlavor.plainTextFlavor; _plainFlavor = DataFlavor.getTextPlainUnicodeFlavor(); } _isoFlavor = getDataFlavor(_isoFlavor, "isoFlavor"); _ascFlavor = getDataFlavor(_ascFlavor, "ascFlavor"); _pl2Flavor = getDataFlavor(_pl2Flavor, "pl2Flavor"); _htmlFlavor = getDataFlavor(_htmlFlavor, "htmlFlavor"); _utf8HtmlFlavor = getDataFlavor(_htmlFlavor, "UTF8Html"); _thtmlFlavor = getDataFlavor(_htmlFlavor, "thtmlFlavor"); _urlFlavor = getDataFlavor(_urlFlavor, "urlFlavor"); }