• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PasteType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openide.util.datatransfer.PasteType的典型用法代码示例。如果您正苦于以下问题:Java PasteType类的具体用法?Java PasteType怎么用?Java PasteType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PasteType类属于org.openide.util.datatransfer包,在下文中一共展示了PasteType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getDropType

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
@Override
public PasteType getDropType(Transferable t, int action, int index) {
    // #139713: drop into empty area creates new link, otherwise disabled
    if (index != -1)
        return null;
    // any kind of drop just creates link in Favorites
    DataObject[] dos = LoaderTransfer.getDataObjects(t, LoaderTransfer.DND_COPY_OR_MOVE | LoaderTransfer.CLIPBOARD_CUT);
    if (dos == null) {
        List<File> files = getDraggedFilesList(t);
        if (!files.isEmpty()) {
            return new FavoritesExternalPasteType(files);
        }
        return null;
    }
    for (DataObject dataObject : dos) {
        if (! Actions.Add.isAllowed(dataObject))
            return null;
    }
    return new FavoritesPasteType(dos);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:FavoritesNode.java


示例2: actionPerformed

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    PasteType[] arr;
    synchronized (this) {
        arr = this.pasteTypes;
    }
    if (arr != null && arr.length > 0) {
        try {
            arr[0].paste();
            return;
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    Utilities.disabledActionBeep();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ExplorerActionsImpl.java


示例3: actionPerformed

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
public void actionPerformed(ActionEvent event) {
    PasteType type = getPasteType();
    if (type != null) {
        try {
            Transferable trans = type.paste();
            if (trans != null) {
                ClipboardOwner owner = trans instanceof ClipboardOwner ?
                    (ClipboardOwner)trans : new StringSelection(""); // NOI18N
                Clipboard clipboard = (Clipboard)Lookup.getDefault().lookup(ExClipboard.class);
                clipboard.setContents(trans, owner);
            }
        } catch (java.io.IOException e) {
            ERR.log( Level.INFO, e.getLocalizedMessage(), e );
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:Utils.java


示例4: getPaste

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
public static PasteType getPaste(Lookup look) {
    ExplorerContext drop = look.lookup(ExplorerContext.class);
    if (drop==null) {
        return null;
    }
    Transferable orig = drop.getTransferable();
    if (orig==null) {
        return null;
    }
    Node n = drop.getTargetNode();
    if (n==null) {
        return null;
    }
    PasteType[] pt = n.getPasteTypes(orig);
    if (pt.length==1) {
        return null;
    }
    return pt[1];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:RefactoringActionsProvider.java


示例5: performActionAt

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
public void performActionAt(int index, ActionEvent ev) {
    Action[] action = new Action[1];

    Object[] arr = getPasteTypesOrActions(action);

    if (arr.length <= index) {
        return;
    }

    if (arr[index] instanceof PasteType) {
        PasteType t = (PasteType) arr[index];

        // posts the action is RP thread
        new ActionPT(t, (ev == null) ? null : ev.getActionCommand());

        return;
    } else {
        // is action
        Action a = (Action) arr[index];
        a.actionPerformed(new ActionEvent(a, ActionEvent.ACTION_PERFORMED, a.NAME));

        return;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:PasteAction.java


示例6: testJavaFileListPasteTypes

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
public void testJavaFileListPasteTypes() throws ClassNotFoundException, IOException {
    FileObject testFO = FileUtil.createData( testFileSystem.getRoot(), "testFile.txt" );
    File testFile = FileUtil.toFile( testFO );
    ArrayList fileList = new ArrayList(1);
    fileList.add( testFile );
    Transferable t = new MockTransferable( new DataFlavor[] {DataFlavor.javaFileListFlavor}, fileList );

    DataFolder.FolderNode node = (DataFolder.FolderNode)folderNode;
    ArrayList list = new ArrayList();
    node.createPasteTypes( t, list );
    assertFalse( list.isEmpty() );
    PasteType paste = (PasteType)list.get( 0 );
    paste.paste();

    FileObject[] children = testFileSystem.getRoot().getFileObject( "testDir" ).getChildren();
    assertEquals( 1, children.length );
    assertEquals( children[0].getNameExt(), "testFile.txt" );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:DataFolderPasteTypesTest.java


示例7: testUriFileListPasteTypes

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
public void testUriFileListPasteTypes() throws ClassNotFoundException, IOException {
    DataFlavor flavor = new DataFlavor( "unsupported/flavor;class=java.lang.Object" );
    FileObject testFO = FileUtil.createData( testFileSystem.getRoot(), "testFile.txt" );
    File testFile = FileUtil.toFile( testFO );
    String uriList = Utilities.toURI(testFile) + "\r\n";
    Transferable t = new MockTransferable( new DataFlavor[] {new DataFlavor("text/uri-list;class=java.lang.String")}, uriList );

    DataFolder.FolderNode node = (DataFolder.FolderNode)folderNode;
    ArrayList list = new ArrayList();
    node.createPasteTypes( t, list );
    assertFalse( list.isEmpty() );
    PasteType paste = (PasteType)list.get( 0 );
    paste.paste();

    FileObject[] children = testFileSystem.getRoot().getFileObject( "testDir" ).getChildren();
    assertEquals( 1, children.length );
    assertEquals( children[0].getNameExt(), "testFile.txt" );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:DataFolderPasteTypesTest.java


示例8: testJavaFileListWithRelativePaths

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
/**
 * Test for bug 233673.
 *
 * @throws java.io.IOException
 */
public void testJavaFileListWithRelativePaths() throws IOException {

    FileObject testFO = FileUtil.createData(testFileSystem.getRoot(),
            "absoluteTestFile.txt");
    File absoluteTestFile = FileUtil.toFile(testFO);
    File relativeTestFile = new File("relativeFile.txt");

    ArrayList fileList = new ArrayList(2);
    fileList.add(relativeTestFile);
    fileList.add(absoluteTestFile);
    Transferable t = new MockTransferable(
            new DataFlavor[]{DataFlavor.javaFileListFlavor}, fileList);

    DataFolder.FolderNode node = (DataFolder.FolderNode) folderNode;
    ArrayList<PasteType> list = new ArrayList<PasteType>();
    node.createPasteTypes(t, list);
    assertEquals("Relative path should be skipped", 1, list.size());
    PasteType paste = (PasteType) list.get(0);
    paste.paste();

    FileObject[] children = testFileSystem.getRoot().getFileObject(
            "testDir").getChildren();
    assertEquals(1, children.length);
    assertEquals(children[0].getNameExt(), "absoluteTestFile.txt");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:DataFolderPasteTypesTest.java


示例9: getPasteType

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
/**
*  
*/ 
   static PasteType getPasteType(final DataFolder targetFolder, final Transferable transfer) {
       final FileObject folder = targetFolder.getPrimaryFile();
       PasteType retVal = null;

       try {
           /*Copy/Cut/Paste is allowed just on SystemFileSystem*/ 
           if (folder.getFileSystem().isDefault()) {
               final int[] pasteOperations = new int[]{LoaderTransfer.CLIPBOARD_COPY, LoaderTransfer.CLIPBOARD_CUT};

               for (int i = 0; i < pasteOperations.length; i++) {
                   final DataObject[] dataObjects = LoaderTransfer.getDataObjects(transfer, pasteOperations[i]);
                   if (dataObjects != null) {                                                
                       if (canBePasted(dataObjects, targetFolder, pasteOperations[i])) {
                           retVal = new PasteTypeImpl(Arrays.asList(dataObjects), targetFolder, pasteOperations[i]);
                           break;
                       }
                   }
               }
           }
       } catch (FileStateInvalidException e) {/*just null is returned if folder.getFileSystem fires ISE*/}

       return retVal;
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ActionPasteType.java


示例10: createPasteTypes

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
@Override
public void createPasteTypes(Transferable transferable,
                             List<PasteType> types) {
    super.createPasteTypes(transferable, types);

    Element.ItemElem item;
    Node node = NodeTransfer.node(transferable, NodeTransfer.MOVE);
    if (node != null && node.canDestroy()) {
        item = node.getCookie(Element.ItemElem.class);
        if (item == null) {
            return;
        }
        Node itemNode = getChildren().findChild(item.getKey());
        if (node.equals(itemNode)) {
            return;
        }
        types.add(new EntryPasteType(item, node));
    } else {
        item = NodeTransfer.cookie(transferable, 
                                   NodeTransfer.COPY,
                                   Element.ItemElem.class);
        if (item != null) {
            types.add(new EntryPasteType(item, null));
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:PropertiesDataNode.java


示例11: doMove

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
@Override
public void doMove(final Lookup lookup) {
    if(canMove(lookup)) {
        Runnable task = new NodeToFileObjectTask(lookup.lookupAll(Node.class)) {

            @Override
            protected RefactoringUI createRefactoringUI(FileObject[] fileObjects) {
                // are other parameters specified e.g. due to drag and drop or copy paste
                PasteType pasteType = getPaste(lookup);
                FileObject targetFolder = getTarget(lookup);
                if (fileObjects.length == 1) {
                    return new MoveMappingFilesRefactoringUI(fileObjects, targetFolder, pasteType);
                } else {
                    return new MoveMappingFilesRefactoringUI(fileObjects, targetFolder, pasteType);
                }
            }
        };
        task.run();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:HibernateMappingRefactoringActionsProvider.java


示例12: getPaste

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
private PasteType getPaste(Lookup look) {
    ExplorerContext drop = look.lookup(ExplorerContext.class);
    if (drop == null) {
        return null;
    }
    Transferable orig = drop.getTransferable();
    if (orig == null) {
        return null;
    }
    Node n = drop.getTargetNode();
    if (n == null) {
        return null;
    }
    PasteType[] pt = n.getPasteTypes(orig);
    if (pt.length == 1) {
        return null;
    }
    return pt[1];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:HibernateMappingRefactoringActionsProvider.java


示例13: getDropType

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
@Override
public PasteType getDropType(Transferable t, int action, int index) {
    PasteType pasteType = super.getDropType(t, action, index);
    //The pasteType can be:
    // 1) PackagePasteType - the t.flavor is package flavor
    // 2) null or DataPasteType - the t.flavor in not package flavor
    if (pasteType instanceof PackageViewChildren.PackagePasteType) {
        ((PackageViewChildren.PackagePasteType)pasteType).setOperation (action);
    }
    return pasteType;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:PackageRootNode.java


示例14: getPasteTypes

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
@Override
public PasteType[] getPasteTypes(ExtendedNodeModel original, Object node, Transferable t) throws UnknownTypeException {
    VariablesFilter vf = getFilter (node, true, null);
    if (!(vf instanceof ExtendedNodeModelFilter))  {
        return original.getPasteTypes(node, t);
    } else {
        return ((ExtendedNodeModelFilter) vf).getPasteTypes(original, node, t);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:VariablesTreeModelFilter.java


示例15: types

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
@Override
public PasteType[] types(Node target) {
    RefactoringPasteType refactoringPaste = new RefactoringPasteType(delegate, target);
    if (refactoringPaste.canHandle())
        return new PasteType[] {refactoringPaste};
    return new PasteType[0];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:ClipboardConvertor.java


示例16: setPasteTypes

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
public void setPasteTypes(PasteType[] arr) {
    synchronized (this) {
        this.pasteTypes = arr;
    }
    LOG.log(Level.FINER, "setPasteTypes for {0}", Arrays.toString(arr));
    toEnabled(arr != null);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:ExplorerActionsImpl.java


示例17: canDrop

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
/** Can node recieve given drop action? */

    // XXX canditate for more general support
    private boolean canDrop(Node n, int dropAction) {
        if (n == null) {
            return false;
        }

        if (ExplorerDnDManager.getDefault().getNodeAllowedActions() == DnDConstants.ACTION_NONE) {
            return false;
        }

        // test if a parent of the dragged nodes isn't the node over
        // only for MOVE action
        if ((DnDConstants.ACTION_MOVE & dropAction) != 0) {
            Node[] nodes = ExplorerDnDManager.getDefault().getDraggedNodes();
            if (nodes != null) {
                for (int i = 0; i < nodes.length; i++) {
                    if (n.equals(nodes[i].getParentNode())) {
                        return false;
                    }
                }
            }
        }

        Transferable trans = ExplorerDnDManager.getDefault().getDraggedTransferable(
                (DnDConstants.ACTION_MOVE & dropAction) != 0
            );

        if (trans == null) {
            return false;
        }

        // get paste types for given transferred transferable
        PasteType pt = null; //TODO DragDropUtilities.getDropType(n, trans, dropAction);

        return (pt != null);
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:TableViewDropSupport.java


示例18: testIllegalStateException

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
public void testIllegalStateException() throws Exception {
    N root = new N();
    final N ch1 = new N();
    final N ch2 = new N();
    final N ch3 = new N();
    PT mockPaste = new PT();
    ch3.pasteTypes = Collections.<PasteType>singletonList(mockPaste);

    root.getChildren().add(new Node[] { ch1, ch2, ch3 });
    final ExplorerManager em = new ExplorerManager();
    em.setRootContext(root);
    em.setSelectedNodes(new Node[] { root });
    Action action = ExplorerUtils.actionPaste(em);
    Action cut = ExplorerUtils.actionCut(em);
    em.waitActionsFinished();
    assertFalse("Not enabled", action.isEnabled());
    
    action.addPropertyChangeListener(this);
    cut.addPropertyChangeListener(this);
    

    em.setSelectedNodes(new Node[] { ch3 });
    em.waitActionsFinished();
    assertFalse("Cut is not enabled", cut.isEnabled());
    assertTrue("Now enabled", action.isEnabled());
    action.actionPerformed(new ActionEvent(this, 0, ""));

    assertEquals("The paste type is going to be called", 1, mockPaste.cnt);
    
    if (err != null) {
        throw err;
    }
    if (cnt == 0) {
        fail("There should be some change in actions: " + cnt);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:ExplorerActionsImplTest.java


示例19: testPasteActionGetDelegatesBlocks

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
@RandomlyFails // NB-Core-Build #9619, #9847, #9998, #10014
public void testPasteActionGetDelegatesBlocks() throws Exception {
    N root = new N();
    final N ch1 = new N();
    final N ch2 = new N();
    final N ch3 = new N();
    PT mockPaste = new PT();
    ch3.pasteTypes = Collections.<PasteType>singletonList(mockPaste);

    root.getChildren().add(new Node[] { ch1, ch2, ch3 });
    final ExplorerManager em = new ExplorerManager();
    em.setRootContext(root);
    em.setSelectedNodes(new Node[] { root });
    Action action = ExplorerUtils.actionPaste(em);
    em.waitActionsFinished();
    assertFalse("Not enabled", action.isEnabled());
    
    action.addPropertyChangeListener(this);
    
    assertNull("No delegates yet", action.getValue("delegates"));

    em.setSelectedNodes(new Node[] { ch3 });
    Object ret = action.getValue("delegates");
    assertNotNull("Delegates are updated", ret);
    Object[] arr = (Object[])ret;
    assertEquals("One item in there", 1, arr.length);
    if (err != null) {
        throw err;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:ExplorerActionsImplTest.java


示例20: ActionPT

import org.openide.util.datatransfer.PasteType; //导入依赖的package包/类
public ActionPT(PasteType t, String command) {
    this.t = t;

    ExplorerManager em = findExplorerManager();

    if (em != null) {
        this.sel = new NodeSelector(em, null);
    }

    if ("waitFinished".equals(command)) { // NOI18N
        run();
    } else {
        RP.post(this);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:PasteAction.java



注:本文中的org.openide.util.datatransfer.PasteType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XML11DTDProcessor类代码示例发布时间:2022-05-23
下一篇:
Java SimpleType类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap