Java Code Examples for java.awt.datatransfer.DataFlavor#stringFlavor()

The following examples show how to use java.awt.datatransfer.DataFlavor#stringFlavor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultExternalDropHandlerTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testCanDrop() throws ClassNotFoundException {
    DefaultExternalDropHandler handler = new DefaultExternalDropHandler();

    DataFlavor[] flavors = new DataFlavor[] { DataFlavor.imageFlavor };
    assertFalse( handler.canDrop( flavors ) );

    flavors = new DataFlavor[] { DataFlavor.imageFlavor, DataFlavor.stringFlavor };
    assertFalse( handler.canDrop( flavors ) );

    flavors = new DataFlavor[] { DataFlavor.javaFileListFlavor };
    assertTrue( handler.canDrop( flavors ) );

    flavors = new DataFlavor[] { DataFlavor.javaFileListFlavor, DataFlavor.imageFlavor };
    assertTrue( handler.canDrop( flavors ) );

    DataFlavor uriListFlavor = new DataFlavor("text/uri-list;class=java.lang.String");

    flavors = new DataFlavor[] { uriListFlavor };
    assertTrue( handler.canDrop( flavors ) );

    flavors = new DataFlavor[] { uriListFlavor, DataFlavor.imageFlavor };
    assertTrue( handler.canDrop( flavors ) );

    flavors = new DataFlavor[] { uriListFlavor, DataFlavor.javaFileListFlavor, DataFlavor.imageFlavor };
    assertTrue( handler.canDrop( flavors ) );
}
 
Example 2
Source File: MissingEventsOnModalDialogTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public DataFlavor[] getTransferDataFlavors() {
    return new DataFlavor[]{DataFlavor.stringFlavor};
}
 
Example 3
Source File: TextTransferable.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static DataFlavor[] getFlavours() {
  if (flavors == null) {
    try {
      html = new DataFlavor("text/html;class=java.lang.String");
    }
    catch (ClassNotFoundException e) {
      LOG.error(e);
      html = null;
    }

    flavors = (html == null) ? new DataFlavor[]{DataFlavor.stringFlavor, DataFlavor.plainTextFlavor} :
              new DataFlavor[]{DataFlavor.stringFlavor, DataFlavor.plainTextFlavor, html};
  }
  return flavors;
}
 
Example 4
Source File: TransferableImage.java    From wandora with GNU General Public License v3.0 5 votes vote down vote up
@Override
public DataFlavor[] getTransferDataFlavors() {
    DataFlavor[] flavors = null;
    if(transferableString != null) {
        flavors = new DataFlavor[2];
        flavors[0] = DataFlavor.imageFlavor;
        flavors[1] = DataFlavor.stringFlavor;
    }
    else {
        flavors = new DataFlavor[1];
        flavors[0] = DataFlavor.imageFlavor;
    }
    return flavors;
}
 
Example 5
Source File: ModuleTransferable.java    From opt4j with MIT License 5 votes vote down vote up
@Override
public DataFlavor[] getTransferDataFlavors() {
	DataFlavor[] flavors = new DataFlavor[2];
	flavors[0] = localModuleFlavor;
	flavors[1] = DataFlavor.stringFlavor;
	return flavors;
}
 
Example 6
Source File: EditorPane.java    From SikuliX1 with MIT License 5 votes vote down vote up
@Override
public boolean importData(JComponent comp, Transferable t) {
  Map<String, String> _copiedImgs = SikulixIDE.get().getCopiedImgs();
  DataFlavor htmlFlavor = DataFlavor.stringFlavor;
  if (canImport(comp, t.getTransferDataFlavors())) {
    try {
      String transferString = (String) t.getTransferData(htmlFlavor);
      EditorPane targetTextPane = (EditorPane) comp;
      for (Map.Entry<String, String> entry : _copiedImgs.entrySet()) {
        String imgName = entry.getKey();
        String imgPath = entry.getValue();
        File destFile = targetTextPane.copyFileToBundle(imgPath);
        String newName = destFile.getName();
        if (!newName.equals(imgName)) {
          String ptnImgName = "\"" + imgName + "\"";
          newName = "\"" + newName + "\"";
          transferString = transferString.replaceAll(ptnImgName, newName);
          Debug.info("MyTransferHandler: importData:" + ptnImgName + " exists. Renamed to " + newName);
        }
      }
      targetTextPane.insertString(transferString);
    } catch (Exception e) {
      log(-1, "MyTransferHandler: importData: Problem pasting text\n%s", e.getMessage());
    }
    return true;
  }
  return false;
}
 
Example 7
Source File: TransferableList.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public DataFlavor[] getTransferDataFlavors() {
  return new DataFlavor[]{
          ALL_HTML_DATA_FLAVOR,//DataFlavor.allHtmlFlavor,
          PART_HTML_DATA_FLAVOR,//DataFlavor.fragmentHtmlFlavor,
          DataFlavor.stringFlavor,
          LIST_DATA_FLAVOR};
}
 
Example 8
Source File: TransferableRepositoryEntry.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public DataFlavor[] getTransferDataFlavors() {
	return new DataFlavor[]{contentFlavor, DataFlavor.stringFlavor};
}
 
Example 9
Source File: TextClipboardHandler.java    From openchemlib-js with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public DataFlavor[] getTransferDataFlavors() {
	return new DataFlavor[] { DataFlavor.stringFlavor };
}
 
Example 10
Source File: Column.java    From gcs with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public DataFlavor[] getTransferDataFlavors() {
    return new DataFlavor[]{DATA_FLAVOR, DataFlavor.stringFlavor};
}
 
Example 11
Source File: DBElementNode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Construct new Transferable for this node. */
ElementStringTransferable() { super(DataFlavor.stringFlavor); }
 
Example 12
Source File: MissingEventsOnModalDialogTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public DataFlavor[] getTransferDataFlavors() {
    return new DataFlavor[]{DataFlavor.stringFlavor};
}
 
Example 13
Source File: ProgramDnDTree.java    From ghidra with Apache License 2.0 4 votes vote down vote up
static DataFlavor[] getDataFlavors() {
	return new DataFlavor[] { TreeTransferable.localTreeNodeFlavor,
		GroupTransferable.localGroupFlavor, // a test data flavor
		DataFlavor.stringFlavor, // a test data flavor
		SelectionTransferable.localProgramSelectionFlavor };
}
 
Example 14
Source File: MissingEventsOnModalDialogTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public DataFlavor[] getTransferDataFlavors() {
    return new DataFlavor[]{DataFlavor.stringFlavor};
}
 
Example 15
Source File: Clip.java    From Logisim with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
	return flavor == binaryFlavor || flavor == DataFlavor.stringFlavor;
}
 
Example 16
Source File: MissingEventsOnModalDialogTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public DataFlavor[] getTransferDataFlavors() {
    return new DataFlavor[]{DataFlavor.stringFlavor};
}
 
Example 17
Source File: MissingEventsOnModalDialogTest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public DataFlavor[] getTransferDataFlavors() {
    return new DataFlavor[]{DataFlavor.stringFlavor};
}
 
Example 18
Source File: ChatRoomTransferHandler.java    From Spark with Apache License 2.0 4 votes vote down vote up
@Override
public DataFlavor[] getTransferDataFlavors() {
          return new DataFlavor[]{DataFlavor.stringFlavor};
      }
 
Example 19
Source File: TransferableMediaEntry.java    From jace with GNU General Public License v2.0 4 votes vote down vote up
public DataFlavor[] getTransferDataFlavors() {
    return new DataFlavor[]{DataFlavor.stringFlavor};
}
 
Example 20
Source File: CopyTableMouseAdapter.java    From nextreports-designer with Apache License 2.0 4 votes vote down vote up
public DataFlavor[] getTransferDataFlavors() {
    return new DataFlavor[]{DataFlavor.stringFlavor};
}