Package java.awt.datatransfer

Examples of java.awt.datatransfer.Transferable


  }

  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


  public void drop(DropTargetDropEvent e) {

    // Drop the TransferAction
    e.acceptDrop(e.getDropAction());
    Transferable tr = e.getTransferable();
    DataFlavor[] flavors = tr.getTransferDataFlavors();
    try {
      String name = (String) tr.getTransferData(flavors[0]);
      int index = ((Integer) tr.getTransferData(flavors[1])).intValue();
      Action separator = DefaultToolBarModel.getInstance().getSeparatorAction();
      Action glue = DefaultToolBarModel.getInstance().getGlueAction();
      Action space = DefaultToolBarModel.getInstance().getSpaceAction();

      JComponent target = (JComponent) ((DropTarget) e.getSource())
View Full Code Here

    clip.setContents(new Data(data), this);
  }
 
  public boolean canPaste() {
    Clipboard clip = editor.getToolkit().getSystemClipboard();
    Transferable xfer = clip.getContents(this);
    return xfer.isDataFlavorSupported(binaryFlavor);
  }
View Full Code Here

    return xfer.isDataFlavorSupported(binaryFlavor);
  }
 
  public void paste() {
    Clipboard clip = editor.getToolkit().getSystemClipboard();
    Transferable xfer = clip.getContents(this);
    int[] data;
    if (xfer.isDataFlavorSupported(binaryFlavor)) {
      try {
        data = (int[]) xfer.getTransferData(binaryFlavor);
      } catch (UnsupportedFlavorException e) {
        return;
      } catch (IOException e) {
        return;
      }
    } else if (xfer.isDataFlavorSupported(DataFlavor.stringFlavor)) {
      String buf;
      try {
        buf = (String) xfer.getTransferData(DataFlavor.stringFlavor);
      } catch (UnsupportedFlavorException e) {
        return;
      } catch (IOException e) {
        return;
      }
View Full Code Here

      try {
        if (drawImage) {
          clearImage();
        }
        int action = dtde.getDropAction();
        Transferable transferable = dtde.getTransferable();
        Point pt = dtde.getLocation();
        if (transferable
            .isDataFlavorSupported(NODE_FLAVOR)
            && controller.canPerformAction(tree, draggedNode, action, pt)) {
          TreePath pathTarget = tree.getPathForLocation(pt.x, pt.y);
          Object node = transferable.getTransferData(NODE_FLAVOR);
          Object newParentNode = pathTarget.getLastPathComponent();
          if (controller.executeDrop(tree, node, newParentNode, action)) {
            dtde.acceptDrop(action);
            dtde.dropComplete(true);
            return;
View Full Code Here

      comp.paste();
    }

    public boolean isEnabled() {
      if (comp.isEditable() && comp.isEnabled()) {
        Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(this);
        return contents.isDataFlavorSupported(DataFlavor.stringFlavor);
      } else {
        return false;
      }
    }
View Full Code Here

    }
  }

  public void drop(DropTargetDropEvent e) {
    e.acceptDrop(e.getDropAction());
    Transferable tr = e.getTransferable();
     
    DataFlavor[] flavors = tr.getTransferDataFlavors();
   
    // If theTransferable is a TransferEntries drop it
    if(flavors != null && flavors.length == 2 &&
        flavors[0].getHumanPresentableName().equals("Indices") &&
        flavors[1].getHumanPresentableName().equals("Source")) {
View Full Code Here

    mPlugin = null;
  }

  public void drop(DropTargetDropEvent e) {
    e.acceptDrop(e.getDropAction());
    final Transferable tr = e.getTransferable();
    final Object src = e.getSource();
    final Point loc = e.getLocation();
    final PluginTree tree = this;
    e.dropComplete(true);
    mDropThread = new Thread("Plugin view drop") {
      public void run() {
        tree.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

        DataFlavor[] flavors = null;
        try {
          flavors = tr.getTransferDataFlavors();
        } catch (Exception e) {
          // there seems to be a bug in Java, causing a NPE internally
          e.printStackTrace();
        }

        if (flavors != null && flavors.length == 1) {
          try {
            TreePath targetPath = ((PluginTree) ((DropTarget) src)
                .getComponent()).getPathForLocation(loc.x, loc.y);
            Node target = (Node) targetPath.getLastPathComponent();

            if(target.getProgramReceiveTarget() == null && targetPath.getPathCount() <= 2) {
              target = (Node) targetPath.getPathComponent(1);
            }

            if (flavors[0].getHumanPresentableName().equals("NodeExport")) {

              TreePath sourcePath = ((PluginTree) ((DropTarget) src)
                  .getComponent()).getSelectionPath();
              Node plugin = (Node) sourcePath.getPathComponent(1);
              Node source = (Node) sourcePath.getLastPathComponent();

              if (target.equals(plugin) || targetPath.isDescendant(sourcePath) || sourcePath.isDescendant(targetPath)) {
                return;
              } else {
                Vector<Program> vec;
                if (source.isLeaf()) {
                  vec = new Vector<Program>();
                  if (source.getUserObject() instanceof ProgramItem) {
                    vec.addElement(((ProgramItem) source.getUserObject())
                        .getProgram());
                  }
                } else {
                  vec = getLeafElements(source, new Vector<Program>());
                }
                Program[] p = vec.toArray(new Program[vec.size()]);

                if(p.length > 0) {
                  if (target.equals(ReminderPlugin.getRootNode()
                      .getMutableTreeNode())) {
                      ReminderPlugin.getInstance().addPrograms(p);
                  } else if(target.getProgramReceiveTarget() == null) {
                    PluginProxy[] pa = PluginProxyManager.getInstance().getActivatedPlugins();

                    for (PluginProxy pluginAccess : pa) {
                      if (pluginAccess.getRootNode() != null) {
                        if (pluginAccess.getRootNode().getMutableTreeNode().equals(target)) {
                          if (pluginAccess.canReceiveProgramsWithTarget()
                              && pluginAccess.getProgramReceiveTargets() != null
                              && pluginAccess.getProgramReceiveTargets().length > 0) {
                            pluginAccess.receivePrograms(p,pluginAccess.getProgramReceiveTargets()[0]);
                          } else {
                            break;
                          }
                        }
                      }
                    }
                  }
                  else {
                    ProgramReceiveTarget receiveTarget = target.getProgramReceiveTarget();
                    receiveTarget.getReceifeIfForIdOfTarget().receivePrograms(p,receiveTarget);
                  }
                }
              }
            } else if (flavors[0].getHumanPresentableName().equals("Program")) {
              PluginProxy[] pa = PluginProxyManager.getInstance().getActivatedPlugins();

              boolean found = false;
              Program program = (Program) tr.getTransferData(flavors[0]);

              for (PluginProxy pluginAccess : pa) {
                if (pluginAccess.getRootNode().getMutableTreeNode().equals(target)) {
                  Action action = getAction(pluginAccess
                      .getContextMenuActions(program));
View Full Code Here

        return Token.isKeyword(s) || s.equals("CREATE") || s.equals("ALTER") || s.equals("SELECT") ||
               s.equals("DROP") || s.equals("TRUNCATE") || s.equals("MODIFY") || s.equals("TABLE") || s.equals("COLUMN");       
    }
   
    public static DcImageIcon getImageFromClipboard() {
        Transferable clipData = clipboard.getContents(clipboard);
        if (clipData != null) {
            if (clipData.isDataFlavorSupported(DataFlavor.imageFlavor)) {
                try {
                    Image image = (Image) clipData.getTransferData(DataFlavor.imageFlavor);
                    return new DcImageIcon(Utilities.getBytes(new DcImageIcon(image)));
                } catch (Exception ignore) {}
            }
        }
        return null;
View Full Code Here

            Debug.message("defaultdndcatcher",
                    "ERROR> DefaultDnDCatcher::getTransferData(): dropEvent is null");
            return null;
        }

        Transferable tr = dtde.getTransferable();
        try {
            return tr.getTransferData(DefaultTransferableObject.OBJECT_FLAVOR);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
View Full Code Here

TOP

Related Classes of java.awt.datatransfer.Transferable

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.