Examples of Transferable


Examples of java.awt.datatransfer.Transferable

      // get the system clipboard
      Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
     
      // get the contents on the clipboard in a
      // transferable object
      Transferable clipboardContents = systemClipboard.getContents(null);
     
      // check if clipboard is empty
      if (clipboardContents == null) {
       
        //Clipboard is empty!!!
        return ("");
     
        // see if DataFlavor of
        // DataFlavor.stringFlavor is supported
      } else if (clipboardContents.isDataFlavorSupported(DataFlavor.stringFlavor)) {
     
        // return text content
        String returnText = (String) clipboardContents.getTransferData(DataFlavor.stringFlavor);
       
        return returnText;
      }
   
      return "";
View Full Code Here

Examples of java.awt.datatransfer.Transferable

    {
      Clipboard clippy = Toolkit.getDefaultToolkit().getSystemClipboard();
      //Transferable clippysContent = clippy.getContents( null );
      try{

     Transferable transferableText = new StringSelection(charValue);
         clippy.setContents( transferableText, null  );
       
         //logger.debug("os.name :: "+System.getProperty("os.name"));
      
         if (System.getProperty("os.name").toUpperCase().indexOf("WINDOWS") >= 0) {
View Full Code Here

Examples of java.awt.datatransfer.Transferable

      // get the system clipboard
      Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
     
      // get the contents on the clipboard in a
      // transferable object
      Transferable clipboardContents = systemClipboard.getContents(null);
     
      // check if clipboard is empty
      if (clipboardContents == null) {
       
        //Clipboard is empty!!!
        return ("");
     
        // see if DataFlavor of
        // DataFlavor.stringFlavor is supported
      } else if (clipboardContents.isDataFlavorSupported(DataFlavor.stringFlavor)) {
     
        // return text content
        String returnText = (String) clipboardContents.getTransferData(DataFlavor.stringFlavor);
       
        return returnText;
      }
   
      return "";
View Full Code Here

Examples of java.awt.datatransfer.Transferable

    {
      Clipboard clippy = Toolkit.getDefaultToolkit().getSystemClipboard();
      //Transferable clippysContent = clippy.getContents( null );
      try{

     Transferable transferableText = new StringSelection(charValue);
         clippy.setContents( transferableText, null  );
       
         //logger.debug("os.name :: "+System.getProperty("os.name"));
      
         if (System.getProperty("os.name").toUpperCase().indexOf("WINDOWS") >= 0) {
View Full Code Here

Examples of java.awt.datatransfer.Transferable

  @SuppressWarnings("unchecked")
  public void drop(DropTargetDropEvent e)  {
    try {
            DropTargetContext context = e.getDropTargetContext();
            e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
            Transferable t = e.getTransferable();
            List<File> data = null;          
           
            if(t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)){
              data = (List<File>)t.getTransferData(DataFlavor.javaFileListFlavor);
             
            }else if(t.isDataFlavorSupported(DnDSupportUtility.URI_LIST_FLAVOR)){
              data = DnDSupportUtility.textURIListToFileList((String)t.getTransferData(DnDSupportUtility.URI_LIST_FLAVOR));
            }
            if(data!=null){
              executeDrop(data);
            }
            context.dropComplete(true);
View Full Code Here

Examples of java.awt.datatransfer.Transferable

  public boolean importData(TransferHandler.TransferSupport info) {
    boolean retVal = false;
    if(info.isDrop()){
            try {       

              Transferable t = info.getTransferable();
              if(t.isDataFlavorSupported(DataFlavor.javaFileListFlavor) || t.isDataFlavorSupported(DnDSupportUtility.URI_LIST_FLAVOR)){
                retVal = super.importData(info);
              }else if (t.isDataFlavorSupported(DnDSupportUtility.VISUAL_LIST_FLAVOR)) {
                     retVal = importVisualListItems(info);                     
                }
            }catch(Exception e){
              log.error(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),"Error during drag and drop."), e);
            }
View Full Code Here

Examples of java.awt.datatransfer.Transferable

     * @param t
     * @return
     */
    private boolean importVisualListItems(TransferHandler.TransferSupport info){
      boolean retVal = false;
      Transferable transferable = info.getTransferable();
      //source and destination are equals or the handler accepts different components
        try{
          JList.DropLocation dropLocation = (JList.DropLocation)info.getDropLocation();
              int index = dropLocation.getIndex();
              VisualListModel destModel =  ((VisualListModel)((JVisualSelectionList)info.getComponent()).getModel());
              TransferableData transferredData = (TransferableData)transferable.getTransferData(DnDSupportUtility.VISUAL_LIST_FLAVOR);
              if(transferredData!=null){
                VisualPageListItem[] dataList = transferredData.getDataList();
            if(dataList!=null && dataList.length>0){
              //drop at the end
              if(index==-1){
View Full Code Here

Examples of java.awt.datatransfer.Transferable

        // Copy
        itemCopy.setEnabled(getSelectedText() != null);

        // Paste
        try {
            Transferable clipboardContent = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(this);
            itemPaste.setEnabled(isEditable() && (clipboardContent != null) && clipboardContent.isDataFlavorSupported(DataFlavor.stringFlavor));
        } catch (Exception e) {
            itemPaste.setEnabled(false);
        }

        // Delete
View Full Code Here

Examples of java.awt.datatransfer.Transferable

        }
    }

    private void drop(final DropTargetDropEvent event) {
        logger.debug("Event:" + event);
        Transferable transferable = event.getTransferable();
        try {
            // Cannot cast transferable.
            final ComponentReference componentReference = (ComponentReference) transferable
                    .getTransferData(ComponentSourceTransferable.FLAVOR);
            final Point location = event.getLocation();

            // The component might not have loaded if the network is slow.
            new Thread() {
View Full Code Here

Examples of java.awt.datatransfer.Transferable

    {
        public void dragGestureRecognized(DragGestureEvent event) {
            if (selection.getSelected().isEmpty()) {
                return;
            }
            Transferable trans = createTransferable(null);
            if (DragSource.isDragImageSupported()) {
                Image image = createDragImage();
                Point origin = event.getDragOrigin();
                Point offset = new Point(- origin.x, - origin.y);
                event.startDrag(null, image, offset, trans, this);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.