Java Code Examples for java.awt.datatransfer.Transferable

The following are top voted examples for showing how to use java.awt.datatransfer.Transferable. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: jdk8u-jdk   File: SunClipboard.java   Source Code and License 6 votes vote down vote up
protected void lostOwnershipNow(final AppContext disposedContext) {
    final SunClipboard sunClipboard = SunClipboard.this;
    ClipboardOwner owner = null;
    Transferable contents = null;

    synchronized (sunClipboard) {
        final AppContext context = sunClipboard.contentsContext;

        if (context == null) {
            return;
        }

        if (disposedContext == null || context == disposedContext) {
            owner = sunClipboard.owner;
            contents = sunClipboard.contents;
            sunClipboard.contentsContext = null;
            sunClipboard.owner = null;
            sunClipboard.contents = null;
            sunClipboard.clearNativeContext();
            context.removePropertyChangeListener
                    (AppContext.DISPOSED_PROPERTY_NAME, sunClipboard);
        } else {
            return;
        }
    }
    if (owner != null) {
        owner.lostOwnership(sunClipboard, contents);
    }
}
 
Example 2
Project: incubator-netbeans   File: ActionPasteType.java   Source Code and License 6 votes vote down vote up
public Transferable paste() throws IOException {
    if (targetFolder != null) {
        for (Iterator iterator = sourceDataObjects.iterator(); iterator.hasNext();) {
            DataObject dataObject = (DataObject) iterator.next();
            boolean isValid = dataObject != null && dataObject.isValid();
            
            if (isValid && pasteOperation == LoaderTransfer.CLIPBOARD_COPY) {
                dataObject.createShadow(targetFolder);
            } 
            
            if (isValid && pasteOperation == LoaderTransfer.CLIPBOARD_CUT) {
                dataObject.move(targetFolder);
            }
                                
        }                
    }
    return null;
}
 
Example 3
Project: incubator-netbeans   File: DataTransferSupport.java   Source Code and License 6 votes vote down vote up
/** Fills in the list of paste types available for given set to transfered
 * DataObjects.
 * @param t clipboard Transferable object, list of transfered DataObjects with their flavors
 * @param s list of paste types supported for transfered objects
 */
public final void createPasteTypes (Transferable t, java.util.List<PasteType> s) {
    /** All supported operations. */
    int [] ops = defineOperations ();

    for (int i = 0; i < ops.length; i++) {
        DataObject objs [] = LoaderTransfer.getDataObjects (t, ops[i]);
        PasteTypeExt pts [];

        if (objs == null || objs.length == 0)
            continue;

        pts = definePasteTypes (ops[i]);

        for (int j = 0; j < pts.length; j++) {
            pts[j].setDataObjects (objs);
            if (pts[j].canPaste ())
                s.add (pts[j]);
        }
    }

    handleCreatePasteTypes (t, s);
}
 
Example 4
Project: CustomWorldGen   File: GuiScreen.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a string stored in the system clipboard.
 */
public static String getClipboardString()
{
    try
    {
        Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents((Object)null);

        if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor))
        {
            return (String)transferable.getTransferData(DataFlavor.stringFlavor);
        }
    }
    catch (Exception var1)
    {
        ;
    }

    return "";
}
 
Example 5
Project: incubator-netbeans   File: OutputOperatorTest.java   Source Code and License 6 votes vote down vote up
/** Wait until clipboard contains string data and returns the text. */
private String getClipboardText() throws Exception {
    Waiter waiter = new Waiter(new Waitable() {

        @Override
        public Object actionProduced(Object obj) {
            Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
            if (contents == null) {
                return null;
            } else {
                return contents.isDataFlavorSupported(DataFlavor.stringFlavor) ? Boolean.TRUE : null;
            }
        }

        @Override
        public String getDescription() {
            return ("Wait clipboard contains string data");
        }
    });
    waiter.waitAction(null);
    return Toolkit.getDefaultToolkit().getSystemClipboard().
            getContents(null).getTransferData(DataFlavor.stringFlavor).toString();
}
 
Example 6
Project: incubator-netbeans   File: WsdlSaasNode.java   Source Code and License 6 votes vote down vote up
@Override
public Transferable clipboardCopy() throws IOException {
    if (getSaas().getState() != Saas.State.READY) {
        getSaas().toStateReady(true);
        return super.clipboardCopy();
    }
    if (! portAdded) {
        final WsdlSaasPort port = getDefaultPort(getSaas());
        if (port != null) {
            transferable.put(new Single(ConsumerFlavorProvider.PORT_FLAVOR) {
                @Override
                protected Object getData() throws IOException, UnsupportedFlavorException {
                    return port;
                }

            });
        }
        portAdded = true;
    }
    return SaasTransferable.addFlavors(transferable);
}
 
Example 7
Project: openjdk-jdk10   File: SunClipboard.java   Source Code and License 6 votes vote down vote up
protected void lostOwnershipNow(final AppContext disposedContext) {
    final SunClipboard sunClipboard = SunClipboard.this;
    ClipboardOwner owner = null;
    Transferable contents = null;

    synchronized (sunClipboard) {
        final AppContext context = sunClipboard.contentsContext;

        if (context == null) {
            return;
        }

        if (disposedContext == null || context == disposedContext) {
            owner = sunClipboard.owner;
            contents = sunClipboard.contents;
            sunClipboard.contentsContext = null;
            sunClipboard.owner = null;
            sunClipboard.contents = null;
            sunClipboard.clearNativeContext();
            context.removePropertyChangeListener
                    (AppContext.DISPOSED_PROPERTY_NAME, sunClipboard);
        } else {
            return;
        }
    }
    if (owner != null) {
        owner.lostOwnership(sunClipboard, contents);
    }
}
 
Example 8
Project: jdk8u-jdk   File: DataTransferer.java   Source Code and License 6 votes vote down vote up
private String getBestCharsetForTextFormat(Long lFormat,
    Transferable localeTransferable) throws IOException
{
    String charset = null;
    if (localeTransferable != null &&
        isLocaleDependentTextFormat(lFormat) &&
        localeTransferable.isDataFlavorSupported(javaTextEncodingFlavor))
    {
        try {
            charset = new String(
                (byte[])localeTransferable.getTransferData(javaTextEncodingFlavor),
                "UTF-8"
            );
        } catch (UnsupportedFlavorException cannotHappen) {
        }
    } else {
        charset = getCharsetForTextFormat(lFormat);
    }
    if (charset == null) {
        // Only happens when we have a custom text type.
        charset = getDefaultTextCharset();
    }
    return charset;
}
 
Example 9
Project: incubator-netbeans   File: PropertiesLocaleNode.java   Source Code and License 6 votes vote down vote up
/** Performs the paste action.
 * @return <code>Transferable</code> which should be inserted into the clipboard after
 * paste action. It can be null, which means that clipboard content
 * should stay the same
 */
public Transferable paste() throws IOException {
    PropertiesStructure ps = ((PropertiesFileEntry)getFileEntry()).getHandler().getStructure();
    String value;
    if (mode == MODE_PASTE_WITH_VALUE) {
        value = item.getValue();
    } else {
        value = "";
    }
    if (ps != null) {
        Element.ItemElem newItem = ps.getItem(item.getKey());
        if (newItem == null) {
            ps.addItem(item.getKey(), value, item.getComment());
        }
        else {
            newItem.setValue(value);
            newItem.setComment(item.getComment());
        }
        if (node != null) {
            node.destroy();
        }
    }

    return null;
}
 
Example 10
Project: freecol   File: TradeRouteInputPanel.java   Source Code and License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void exportDone(JComponent source, Transferable data,
                          int action) {
    try {
        if (source instanceof JList && action == MOVE) {
            JList stopList = (JList)source;
            DefaultListModel listModel
                = (DefaultListModel)stopList.getModel();
            for (Object o : (List) data.getTransferData(STOP_FLAVOR)) {
                listModel.removeElement(o);
            }
        }
    } catch (Exception e) {
        logger.warning(e.toString());
    }
}
 
Example 11
Project: incubator-netbeans   File: FavoritesNode.java   Source Code and License 6 votes vote down vote up
@Override
public Transferable paste() throws IOException {
    Tab.RP.post(new Runnable () {
        @Override
        public void run() {
            Set<FileObject> fos = new HashSet<FileObject>(files.size());
            for (File f : files) {
                FileObject fo = FileUtil.toFileObject(FileUtil.normalizeFile(f));
                if (fo != null) {
                    fos.add(fo);
                }
            }
            if (!fos.isEmpty()) {
                try {
                    Favorites.getDefault().add(fos.toArray(new FileObject[fos.size()]));
                } catch (DataObjectNotFoundException ex) {
                    Logger.getLogger(FavoritesNode.class.getName()).log(Level.INFO, null, ex);
                }
            }
        }
    });
    return null;
}
 
Example 12
Project: UaicNlpToolkit   File: MyDragHandler.java   Source Code and License 6 votes vote down vote up
public boolean importData(JComponent comp, Transferable t) {
    if (GrammarEditor.theEditor.shouldSave) {
        int answer = JOptionPane.showConfirmDialog(GrammarEditor.theEditor.frame, "Save before opening a new grammar?", null, JOptionPane.YES_NO_CANCEL_OPTION);
        if (answer == JOptionPane.YES_OPTION)
            GrammarEditor.theEditor.save.doClick();
        else if (answer == JOptionPane.CANCEL_OPTION)
            return false;
    }

    File f = null;
    try {
        f = ((List<File>) t.getTransferData(DataFlavor.javaFileListFlavor)).get(0);
        GrammarEditor.theEditor.openGrammar(f);
        return true;
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(GrammarEditor.theEditor.frame, ex.getMessage(), "Can't drag file", JOptionPane.ERROR_MESSAGE);
    }

    return false;
}
 
Example 13
Project: Pogamut3   File: ExplorerFactory.java   Source Code and License 6 votes vote down vote up
@Override
public Transferable createNewTransferable() {
    return new ExTransferable.Single(Competence.dataFlavor) {

        @Override
        protected Object getData() throws IOException, UnsupportedFlavorException {
            String competenceName = PGSupport.getIdentifierFromDialog("Name of competence");
            if (competenceName == null) {
                return null;
            }

            String elementName = PGSupport.getIdentifierFromDialog("Name of competence atom");
            if (elementName == null) {
                return null;
            }
            try {
                return LapElementsFactory.createCompetence(competenceName, elementName);
            } catch (DuplicateNameException ex) {
                throw new FubarException("Creating new competence with only one name, what duplicate?", ex);
            }
        }
    };
}
 
Example 14
Project: Neukoelln_SER316   File: HTMLEditor.java   Source Code and License 5 votes vote down vote up
private void doPaste() {
	Clipboard clip =
		java.awt.Toolkit.getDefaultToolkit().getSystemClipboard();
	try {
		Transferable content = clip.getContents(this);
		if (content == null)
			return;
		String txt =
			content
				.getTransferData(new DataFlavor(String.class, "String"))
				.toString();
		document.replace(
			editor.getSelectionStart(),
			editor.getSelectionEnd() - editor.getSelectionStart(),
			txt,
			editorKit.getInputAttributes());
		//editor.replaceSelection(content.getTransferData(new
		// DataFlavor(String.class, "String")).toString());
		//editor.paste();
		//insertHTML(content.getTransferData(new DataFlavor(String.class,
		// "String")).toString(), editor.getCaretPosition());
		/*
		 * Element el =
		 * document.getParagraphElement(editor.getCaretPosition());
		 * insertTextInElement(el, content.getTransferData(new
		 * DataFlavor(String.class, "String")).toString(),
		 */

	} catch (Exception ex) {
		ex.printStackTrace();
	}
}
 
Example 15
Project: jdk8u-jdk   File: WDragSourceContextPeer.java   Source Code and License 5 votes vote down vote up
/**
 * downcall into native code
 */

native long createDragSource(Component component,
                             Transferable transferable,
                             InputEvent nativeTrigger,
                             int actions,
                             long[] formats,
                             Map formatMap);
 
Example 16
Project: incubator-netbeans   File: ItemNode.java   Source Code and License 5 votes vote down vote up
public Transferable drag() throws IOException {
    ExTransferable t = ExTransferable.create( super.drag() );//NodeTransfer.transferable(this, NodeTransfer.DND_MOVE) );
    
    customizeTransferable( t );
    t.put( createTransferable() );
    
    return t;
}
 
Example 17
Project: FreeCol   File: DefaultTransferHandler.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Transferable createTransferable(JComponent comp) {
    return (comp instanceof JLabel && comp instanceof Draggable)
        ? new ImageSelection((JLabel) comp)
        : null;
}
 
Example 18
Project: incubator-netbeans   File: HyperCompoundModel.java   Source Code and License 5 votes vote down vote up
int getAllowedDropActions(Transferable t) {
    int actions = 0;
    for (Models.CompoundModel m : models) {
        actions |= m.getAllowedDropActions(t);
    }
    return actions;
}
 
Example 19
Project: incubator-netbeans   File: TreeRootNode.java   Source Code and License 5 votes vote down vote up
@Override public Transferable clipboardCut() throws IOException {
    DataFolder top = topPackage();
    if (top != null) {
        return top.getNodeDelegate().clipboardCut();
    } else {
        return super.clipboardCut();
    }
}
 
Example 20
Project: jdk8u-jdk   File: XClipboard.java   Source Code and License 5 votes vote down vote up
@Override
public synchronized Transferable getContents(Object requestor) {
    if (contents != null) {
        return contents;
    }
    return new ClipboardTransferable(this);
}
 
Example 21
Project: incubator-netbeans   File: PackageViewChildren.java   Source Code and License 5 votes vote down vote up
@Override
public Transferable clipboardCut () throws IOException {
    try {
        return new PackageTransferable (this, DnDConstants.ACTION_MOVE);
    } catch (ClassNotFoundException e) {
        throw new AssertionError(e);
    }
}
 
Example 22
Project: incubator-netbeans   File: EditorTestCase.java   Source Code and License 5 votes vote down vote up
protected ValueResolver getClipboardResolver(final JEditorPaneOperator txtOper, final Transferable oldClipValue){
    
    ValueResolver clipboardValueResolver = new ValueResolver(){
        public Object getValue(){
            Transferable newClipValue = txtOper.getToolkit().getSystemClipboard().getContents(txtOper);
            log("newClipValue:"+newClipValue);
            return (newClipValue == oldClipValue) ? Boolean.TRUE : Boolean.FALSE;
        }
    };
    
    return clipboardValueResolver;
}
 
Example 23
Project: Tarski   File: mxGraphTransferHandler.java   Source Code and License 5 votes vote down vote up
/**
 * Counts the number of times that the given transferable has been imported.
 */
protected void updateImportCount(Transferable t) {
  if (lastImported != t) {
    importCount = initialImportCount;
  } else {
    importCount++;
  }

  lastImported = t;
}
 
Example 24
Project: Pogamut3   File: ExplorerFactory.java   Source Code and License 5 votes vote down vote up
@Override
public Transferable createTransferable(PrimitiveData data) {
    if (data == null) {
        return null;
    }
    String actionName = data.classFQN;
    return new NodeTransferable<TriggeredAction>(LapElementsFactory.createAction(actionName));
}
 
Example 25
Project: imagingbook-common   File: Clipboard.java   Source Code and License 5 votes vote down vote up
public static String getStringFromClipboard() { 
	String text = null;
	Transferable trf = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); 
	if (trf != null && trf.isDataFlavorSupported(DataFlavor.stringFlavor)) {
		try {
			text = (String) trf.getTransferData(DataFlavor.stringFlavor);
		}  catch (Exception e) {};
	}
	return text; 
}
 
Example 26
Project: openjdk-jdk10   File: LastNodeLowerHalfDrop.java   Source Code and License 5 votes vote down vote up
@Override
protected Transferable createTransferable(JComponent c) {
    JTree tree = (JTree) c;
    TreePath[] paths = tree.getSelectionPaths();
    if (paths != null) {
        // Make up a node array of copies for transfer and
        // another for/of the nodes that will be removed in
        // exportDone after a successful drop.
        List<DefaultMutableTreeNode> copies = new ArrayList<>();
        List<DefaultMutableTreeNode> toRemove = new ArrayList<>();
        DefaultMutableTreeNode node = (DefaultMutableTreeNode)
                paths[0].getLastPathComponent();
        DefaultMutableTreeNode copy = copy(node);
        copies.add(copy);
        toRemove.add(node);
        for (int i = 1; i < paths.length; i++) {
            DefaultMutableTreeNode next = (DefaultMutableTreeNode) paths[i]
                    .getLastPathComponent();
            // Do not allow higher level nodes to be added to list.
            if (next.getLevel() < node.getLevel()) {
                break;
            } else if (next.getLevel() > node.getLevel()) {  // child node
                copy.add(copy(next));
                // node already contains child
            } else {                                        // sibling
                copies.add(copy(next));
                toRemove.add(next);
            }
        }
        DefaultMutableTreeNode[] nodes = copies
                .toArray(new DefaultMutableTreeNode[copies.size()]);
        nodesToRemove = toRemove.toArray(
                new DefaultMutableTreeNode[toRemove.size()]);
        return new NodesTransferable(nodes);
    }
    return null;
}
 
Example 27
Project: Pogamut3   File: Explorer.java   Source Code and License 5 votes vote down vote up
@Override
protected Transferable createTransferable(JComponent c) {
    if (selectedIndex != 0) {
        return createItemTransferable(getSelected());
    }
    // Create transferable for creation of new item
    return newItemTransferable;
}
 
Example 28
Project: openjdk-jdk10   File: ImageTransferTest.java   Source Code and License 5 votes vote down vote up
void checkImage(DropTargetDropEvent dtde) {
    final Transferable t = dtde.getTransferable();
    if (t.isDataFlavorSupported(DataFlavor.imageFlavor)) {
        dtde.acceptDrop(DnDConstants.ACTION_COPY);
        Image im;
        try {
            im = (Image) t.getTransferData(DataFlavor.imageFlavor);
            System.err.println("getTransferData was successful");
        } catch (Exception e) {
            System.err.println("Can't getTransferData: " + e);
            dtde.dropComplete(false);
            notifyTransferSuccess(false);
            return;
        }

        if (im == null) {
            System.err.println("getTransferData returned null");
            dtde.dropComplete(false);
            notifyTransferSuccess(false);
        } else if (areImagesIdentical(image, im)) {
            dtde.dropComplete(true);
            notifyTransferSuccess(true);
        } else {
            System.err.println("transferred image is different from initial image");
            dtde.dropComplete(false);
            notifyTransferSuccess(false);
        }

    } else {
        System.err.println("imageFlavor is not supported by Transferable");
        dtde.rejectDrop();
        notifyTransferSuccess(false);
    }
}
 
Example 29
Project: incubator-netbeans   File: AbstractNode.java   Source Code and License 5 votes vote down vote up
/** Determine which paste operations are allowed when a given transferable is in the clipboard.
* Subclasses should override {@link #createPasteTypes}.
*
* @param t the transferable in the clipboard
* @return array of operations that are allowed
*/
public final PasteType[] getPasteTypes(Transferable t) {
    List<PasteType> s = new LinkedList<PasteType>();
    createPasteTypes(t, s);

    return s.toArray(NO_PASTE_TYPES);
}
 
Example 30
Project: jdk8u-jdk   File: WDataTransferer.java   Source Code and License 5 votes vote down vote up
@Override
public Object translateStream(InputStream str,
                             DataFlavor flavor, long format,
                             Transferable localeTransferable)
    throws IOException
{
    if (format == CF_HTML && flavor.isFlavorTextType()) {
        str = new HTMLCodec(str,
                             EHTMLReadMode.getEHTMLReadMode(flavor));

    }
    return super.translateStream(str, flavor, format,
                                    localeTransferable);

}
 
Example 31
Project: freecol   File: BuildQueuePanel.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void exportDone(JComponent source, Transferable data, 
                          int action) {
    //this.indices = null;
    this.numberOfItems = 0;
    updateAllLists();
}
 
Example 32
Project: incubator-netbeans   File: Models.java   Source Code and License 5 votes vote down vote up
@Override
public PasteType getDropType(Object node, Transferable t, int action,
                             int index) throws UnknownTypeException {
    if (dndfilter != null) {
        return dndfilter.getDropType(model, node, t, action, index);
    } else {
        return model.getDropType(node, t, action, index);
    }
}
 
Example 33
Project: incubator-netbeans   File: WadlMethodNode.java   Source Code and License 5 votes vote down vote up
@Override
public Transferable clipboardCopy() throws IOException {
    if (method.getSaas().getState() != Saas.State.READY) {
        method.getSaas().toStateReady(false);
        return super.clipboardCopy();
    }
    return SaasTransferable.addFlavors(transferable);
}
 
Example 34
Project: JAddOn   File: TreeTransferHandler.java   Source Code and License 5 votes vote down vote up
protected Transferable createTransferable(JComponent c) {
    JTree tree = (JTree)c;
    TreePath[] paths = tree.getSelectionPaths();
    if(paths != null) {
        // Make up a node array of copies for transfer and
        // another for/of the nodes that will be removed in
        // exportDone after a successful drop.
        List<DefaultMutableTreeNode> copies =
            new ArrayList<DefaultMutableTreeNode>();
        List<DefaultMutableTreeNode> toRemove =
            new ArrayList<DefaultMutableTreeNode>();
        DefaultMutableTreeNode node =
            (DefaultMutableTreeNode)paths[0].getLastPathComponent();
        DefaultMutableTreeNode copy = copy(node);
        copies.add(copy);
        toRemove.add(node);
        for(int i = 1; i < paths.length; i++) {
            DefaultMutableTreeNode next =
                (DefaultMutableTreeNode)paths[i].getLastPathComponent();
            // Do not allow higher level nodes to be added to list.
            if(next.getLevel() < node.getLevel()) {
                break;
            } else if(next.getLevel() > node.getLevel()) {  // child node
                copy.add(copy(next));
                // node already contains child
            } else {                                        // sibling
                copies.add(copy(next));
                toRemove.add(next);
            }
        }
        DefaultMutableTreeNode[] nodes =
            copies.toArray(new DefaultMutableTreeNode[copies.size()]);
        nodesToRemove =
            toRemove.toArray(new DefaultMutableTreeNode[toRemove.size()]);
        return new NodesTransferable(nodes);
    }
    return null;
}
 
Example 35
Project: openjdk-jdk10   File: XClipboard.java   Source Code and License 5 votes vote down vote up
@Override
public synchronized Transferable getContents(Object requestor) {
    if (contents != null) {
        return contents;
    }
    return new ClipboardTransferable(this);
}
 
Example 36
Project: ramus   File: RowTreeTable.java   Source Code and License 5 votes vote down vote up
public Transferable createTransferable() {
    exporting = true;
    final int[] is = getSelectedRows();
    final ArrayList<Integer> al = new ArrayList<Integer>();
    Rows rows = new Rows();
    for (final int i : is) {
        al.add(i);
        TreeTableNode node = (TreeTableNode) getPathForRow(i)
                .getLastPathComponent();
        if ((node != null) && (node.getRow() != null))
            rows.add(node.getRow());
    }
    return new ArrayTransferable(al, rows);
}
 
Example 37
Project: OpenJSharp   File: SunClipboard.java   Source Code and License 5 votes vote down vote up
public synchronized void setContents(Transferable contents,
                                     ClipboardOwner owner) {
    // 4378007 : Toolkit.getSystemClipboard().setContents(null, null)
    // should throw NPE
    if (contents == null) {
        throw new NullPointerException("contents");
    }

    initContext();

    final ClipboardOwner oldOwner = this.owner;
    final Transferable oldContents = this.contents;

    try {
        this.owner = owner;
        this.contents = new TransferableProxy(contents, true);

        setContentsNative(contents);
    } finally {
        if (oldOwner != null && oldOwner != owner) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    oldOwner.lostOwnership(SunClipboard.this, oldContents);
                }
            });
        }
    }
}
 
Example 38
Project: incubator-netbeans   File: CategoryTest.java   Source Code and License 5 votes vote down vote up
private Transferable createTransferable( final Item item ) {
    return new ExTransferable.Single( PaletteController.ITEM_DATA_FLAVOR ) {
        protected Object getData() throws IOException, UnsupportedFlavorException {
            return item.getLookup();
        }
    };
}
 
Example 39
Project: jdk8u-jdk   File: XClipboard.java   Source Code and License 5 votes vote down vote up
protected synchronized void setContentsNative(Transferable contents) {
    SortedMap<Long,DataFlavor> formatMap =
        DataTransferer.getInstance().getFormatsForTransferable
            (contents, DataTransferer.adaptFlavorMap(getDefaultFlavorTable()));
    long[] formats = DataTransferer.keysToLongArray(formatMap);

    if (!selection.setOwner(contents, formatMap, formats,
                            XToolkit.getCurrentServerTime())) {
        this.owner = null;
        this.contents = null;
    }
}
 
Example 40
Project: incubator-netbeans   File: ExplorerDnDManager.java   Source Code and License 5 votes vote down vote up
void setDraggedTransferable(Transferable trans, boolean isCut) {
    if (isCut) {
        draggedTransForCut = trans;
    } else {
        draggedTransForCopy = trans;
    }
}