Package java.awt.datatransfer

Examples of java.awt.datatransfer.DataFlavor


  public void drop(DropTargetDropEvent e) {
    e.acceptDrop(e.getDropAction());
    this.paintImmediately(mCueLine.getBounds());
    Transferable transfer = e.getTransferable();

    if(transfer.isDataFlavorSupported(new DataFlavor(TreePath.class, "FavoriteNodeExport"))) {
      try {
        FavoriteNode node = mTransferNode;
        FavoriteNode parent = (FavoriteNode)node.getParent();

        int row = getClosestRowForLocation(e.getLocation().x, e.getLocation().y);
View Full Code Here


   * Set up the transferEntries.
   * @param program The selected program.
   */
  public TransferProgram(Program program) {
    mProgram = program;
    mPF = new DataFlavor(Program.class,"Program");
  }
View Full Code Here

   * @param source The source list name.
   * @param type The type of the list entries.
   */
  public TransferEntries(int[] indices, String source, String type) {
    mIndices = indices;
    mIF = new DataFlavor(Integer.class,type);
    mSource = source;
    mSF = new DataFlavor(JList.class,"Source");
  }
View Full Code Here

     * @param index
     *          The index of the drag source.
     */
    public TransferAction(String name, int index) {
      mName = name;
      mNF = new DataFlavor(Action.class, "Action");
      mIndex = index;
      mIF = new DataFlavor(Integer.class, "Integer");
    }
View Full Code Here

  private static class TransferNode implements Transferable {
    private DataFlavor mDF;

    public TransferNode() {
      mDF = new DataFlavor(TreePath.class, "NodeExport");
    }
View Full Code Here

      DragSource dragSource = DragSource.getDefaultDragSource();
      dragSource.createDefaultDragGestureRecognizer(getRealWidget(), DnDConstants.ACTION_COPY_OR_MOVE, handler);
    } else if (event.startsWith("drop[") && event.endsWith("]")) {
      try {
        StringTokenizer tokenizer = new StringTokenizer(event.substring(5, event.length() - 1), ", ");
        DataFlavor flavors[] = new DataFlavor[tokenizer.countTokens()];

        int counter = 0;
        while (tokenizer.hasMoreTokens()) {
          flavors[counter++] = new DataFlavor(tokenizer.nextToken());
        }

        DropHandler handler = new DropHandler(this, listener, name, flavors);
        new DropTarget(getRealWidget(), handler);
      } catch (Exception e) {
View Full Code Here

  /**
   * Add data of a given mime type
   */
  public void addData(String mimeType, Object transferableData) throws GUIException {
    try {
      data.put(new DataFlavor(mimeType), transferableData);
    } catch (Exception e) {
      throw new GUIException("Error while creating data flavor", e);
    }
  }
View Full Code Here

  /**
   * Retrieve data of a given mime type
   */ 
  public Object getData(String mimeType) throws GUIException {
    try {
      return data.get(new DataFlavor(mimeType));
    } catch (Exception e) {
      throw new GUIException("Error while creating data flavor", e);
    }
  }
View Full Code Here

  public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
    return data.get(flavor);
  }

  public DataFlavor[] getTransferDataFlavors() {
    DataFlavor flavors[] = new DataFlavor[data.size()];
    int counter = 0;

    for (Iterator i = data.keySet().iterator(); i.hasNext(); ) {
      flavors[counter++] = (DataFlavor) i.next();
    }
View Full Code Here

    public DataFlavor[] getTransferDataFlavors() {
      Object node = getSelectionPath().getLastPathComponent();
      if (node==null) return new DataFlavor[0];
            //If there is a selected data, the available data flavors will be the data itself, and a string.
      DataFlavor[] ret = new DataFlavor[2];
      if (node instanceof DataSourceNode) ret[0] = new DataFlavor(DataSource.class, node.toString());
      else if (node instanceof CollectionNode) ret[0] = new DataFlavor(DataSourceCollection.class, node.toString());
      else ret[0] = DataFlavor.stringFlavor; // error, unknown object => as string
            //Add the String dataFlavor, to also export data path.
            ret[1] = DataFlavor.stringFlavor;
      return ret;
    }
View Full Code Here

TOP

Related Classes of java.awt.datatransfer.DataFlavor

Copyright © 2018 www.massapicom. 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.