• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java NodeTransfer类的典型用法和代码示例

java 1次浏览

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

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

示例1: testMultiTransferableForCopy

点赞 3

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
public void testMultiTransferableForCopy() throws Exception {
    N node = new N();
    N n2 = new N();
    N[] arr = { node, n2 };
    
    Transferable t = DragDropUtilities.getNodeTransferable(arr, NodeTransfer.DND_COPY);
    
    assertEquals("One call to copy", 1, node.copy);
    assertEquals("One call to copy on n2", 1, n2.copy);
    assertEquals("Also one call to drag which delegates to copy", 1, node.drag);
    assertEquals("Also one call to drag which delegates to copy on n2", 1, n2.drag);
    assertEquals("No call to cut", 0, node.cut);
    assertEquals("No call to cut", 0, n2.cut);
    
    assertNotNull("Call to convertor", last);
    assertTrue("multi flavor supported", last.isDataFlavorSupported(ExTransferable.multiFlavor));
    Object obj = last.getTransferData(ExTransferable.multiFlavor);
    if (!( obj instanceof MultiTransferObject)) {
        fail("It should be MultiTransferObject: " + obj);
    }
    MultiTransferObject m = (MultiTransferObject)obj;
    
    assertEquals("Two in multi", 2, m.getCount());
    assertTrue("Is string", m.getTransferData(0, DataFlavor.stringFlavor) instanceof String);
    assertTrue("Is string2", m.getTransferData(1, DataFlavor.stringFlavor) instanceof String);
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:27,
代码来源:DragDropUtilitiesTest.java

示例2: testMultiTransferableForCut

点赞 3

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
public void testMultiTransferableForCut() throws Exception {
    N node = new N();
    N n2 = new N();
    N[] arr = { node, n2 };
    
    Transferable t = DragDropUtilities.getNodeTransferable(arr, NodeTransfer.DND_MOVE);
    
    assertEquals("One call to cut ", 1, node.cut);
    assertEquals("One call to cut on n2", 1, n2.cut);
    assertEquals("No to drag", 0, node.drag);
    assertEquals("No to drag on n2", 0, n2.drag);
    assertEquals("No call to copy", 0, node.copy);
    assertEquals("No call to copy on n2", 0, n2.copy);
    
    assertNotNull("Call to convertor", last);
    assertTrue("multi flavor supported", last.isDataFlavorSupported(ExTransferable.multiFlavor));
    Object obj = last.getTransferData(ExTransferable.multiFlavor);
    if (!( obj instanceof MultiTransferObject)) {
        fail("It should be MultiTransferObject: " + obj);
    }
    MultiTransferObject m = (MultiTransferObject)obj;
    
    assertEquals("Two in multi", 2, m.getCount());
    assertTrue("Is string", m.getTransferData(0, DataFlavor.stringFlavor) instanceof String);
    assertTrue("Is string2", m.getTransferData(1, DataFlavor.stringFlavor) instanceof String);
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:27,
代码来源:DragDropUtilitiesTest.java

示例3: createPasteTypes

点赞 3

import org.openide.nodes.NodeTransfer; //导入依赖的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

示例4: getDropType

点赞 3

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
@Override
public PasteType getDropType(Transferable t, int action, final int index) {

    final Node node = NodeTransfer.node(t, action);
    return new PasteType() {

        @Override
        public Transferable paste() throws IOException {
            FilterIndexSupport indexSupport = getLookup().lookup(FilterIndexSupport.class);
            int nodeIndex = indexSupport.indexOf(node);
            if (nodeIndex < index) {
                indexSupport.move(index - 1, nodeIndex);
            } else {
                indexSupport.move(index, nodeIndex);
            }

            return null;
        }
    };
}
 

开发者ID:jMonkeyEngine,
项目名称:sdk,
代码行数:21,
代码来源:FilterPostProcessorNode.java

示例5: testGetNodeTransferableForSingleNodeCopy

点赞 2

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
public void testGetNodeTransferableForSingleNodeCopy() throws Exception {
    N node = new N();
    
    Transferable t = DragDropUtilities.getNodeTransferable(node, NodeTransfer.DND_COPY);
    
    assertEquals("One call to copy", 1, node.copy);
    assertEquals("Also one call to drag which delegates to copy", 1, node.drag);
    assertEquals("No call to cut", 0, node.cut);
    assertNotNull("Call to convertor", last);
    assertTrue("StringSelection got to ExClipboard convertor", last instanceof StringSelection);
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:12,
代码来源:DragDropUtilitiesTest.java

示例6: testGetNodeTransferableForSingleNodeCut

点赞 2

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
public void testGetNodeTransferableForSingleNodeCut() throws Exception {
    N node = new N();
    
    Transferable t = DragDropUtilities.getNodeTransferable(node, NodeTransfer.DND_MOVE);
    
    assertEquals("One call to cut", 1, node.cut);
    assertEquals("No call to drag", 0, node.drag);
    assertEquals("No call to copy", 0, node.copy);
    assertNotNull("Call to convertor", last);
    assertTrue("StringSelection got to ExClipboard convertor", last instanceof StringSelection);
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:12,
代码来源:DragDropUtilitiesTest.java

示例7: createPasteTypes

点赞 2

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
/** Creates paste types for this node. Overrides superclass method. */
@Override
protected void createPasteTypes(Transferable t, List<PasteType> s) {
    super.createPasteTypes(t, s);
    Element.ItemElem item;
    Node n = NodeTransfer.node(t, NodeTransfer.MOVE);
    // cut
    if (n != null && n.canDestroy ()) {
        item = n.getCookie(Element.ItemElem.class);
        if (item != null) {
            // are we pasting into the same node
            Node n2 = getChildren().findChild(item.getKey());
            if (n == n2) {
                return;
            }
            s.add(new KeyPasteType(item, n, KeyPasteType.MODE_PASTE_WITH_VALUE));
            s.add(new KeyPasteType(item, n, KeyPasteType.MODE_PASTE_WITHOUT_VALUE));
            return;
        }
    }
    // copy
    else {
        item = NodeTransfer.cookie(t, NodeTransfer.COPY, Element.ItemElem.class);
        if (item != null) {
            s.add(new KeyPasteType(item, null, KeyPasteType.MODE_PASTE_WITH_VALUE));
            s.add(new KeyPasteType(item, null, KeyPasteType.MODE_PASTE_WITHOUT_VALUE));
            return;
        }
    }
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:31,
代码来源:PropertiesLocaleNode.java

示例8: getCopiedBeanClassSource

点赞 2

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
@Override
public ClassSource getCopiedBeanClassSource(Transferable transferable) {
    DataObject dobj = NodeTransfer.cookie(transferable, NodeTransfer.COPY, DataObject.class);
    FileObject fo = (dobj != null && dobj.isValid()) ? dobj.getPrimaryFile() : null;
    if (fo == null) {
        return null;
    }

    String clsName = BeanInstaller.findJavaBeanName(fo);
    if (clsName == null) {
        return null;
    }

    return BeanInstaller.getProjectClassSource(fo, clsName);
}
 

开发者ID:apache,
项目名称:incubator-netbeans,
代码行数:16,
代码来源:NbFormServices.java

示例9: drop

点赞 2

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
@Override
public void drop(DropTargetDropEvent dropEv) {
  setEditCuts();    // clearly we're editing cuts now
  dropEv.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
  Node node = NodeTransfer.node(dropEv.getTransferable(), NodeTransfer.DND_COPY_OR_MOVE);
  dropEv.dropComplete(node != null);
  if (null != node) {
    Point2D.Double pt = scalePixToInch(dropEv.getLocation());
    if (!node.getName().equals("GoToPoint")) {    // don't snap GoToPoints to the curve
      pt = onCutCurve(pt);
    }
    addFromPalette(pt);   // duplicate the paramenters from the last (if applicable)
  }
}
 

开发者ID:billooms,
项目名称:COrnLathe,
代码行数:15,
代码来源:OutlineEditorTopComponent.java

示例10: getDropType

点赞 2

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
@Override
public PasteType getDropType(Transferable t, final int action, final int index) {

    final Node dropNode = NodeTransfer.node(t, DnDConstants.ACTION_COPY_OR_MOVE + NodeTransfer.CLIPBOARD_CUT);
    final int dropAction = DnDUtilities.getTransferAction(t);

    if (null != dropNode && index >= 0) {

        final BaseColumn column = dropNode.getLookup().lookup(BaseColumn.class);

        if (null != column) {

            // check if the column belongs to this table...
            final TableMatrix matrix = new TableMatrix(getJasperDesign(), getTable());

            if (matrix.getColumnIndex(column) < 0) return null;

            return new PasteType() {

                @SuppressWarnings("unchecked")
                public Transferable paste() throws IOException {

                    matrix.moveColumn(column, getTable(), index);
                    return null;
                }
            };
        }
    }
    return null;
}
 

开发者ID:JockiHendry,
项目名称:ireport-fork,
代码行数:31,
代码来源:TableColumnGroupNode.java

示例11: getDropType

点赞 2

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
@Override
public PasteType getDropType(Transferable t, final int action, final int index) {

    final Node dropNode = NodeTransfer.node(t, DnDConstants.ACTION_COPY_OR_MOVE + NodeTransfer.CLIPBOARD_CUT);
    final int dropAction = DnDUtilities.getTransferAction(t);

    if (null != dropNode && index >= 0) {

        final BaseColumn column = dropNode.getLookup().lookup(BaseColumn.class);
        
        if (null != column) {

            // check if the column belongs to this table...
            final TableMatrix matrix = new TableMatrix(getJasperDesign(), getTable());

            if (matrix.getColumnIndex(column) < 0) return null;

            return new PasteType() {

                @SuppressWarnings("unchecked")
                public Transferable paste() throws IOException {

                    matrix.moveColumn(column, getTable(), index);
                    return null;
                }
            };
        }
    }
    return null;
}
 

开发者ID:JockiHendry,
项目名称:ireport-fork,
代码行数:31,
代码来源:TableSectionNode.java

示例12: getDropType

点赞 2

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
@Override
public PasteType getDropType(Transferable t, final int action, int index) {

    Node dropNode = NodeTransfer.node(t, DnDConstants.ACTION_COPY_OR_MOVE + NodeTransfer.CLIPBOARD_CUT);
    Node[] dropNodes = NodeTransfer.nodes(t, DnDConstants.ACTION_COPY_OR_MOVE + NodeTransfer.CLIPBOARD_CUT);
    int dropAction = DnDUtilities.getTransferAction(t);

    if (dropNode == null)
    {
        ElementPasteType.setLastPastedNodes(dropNodes);
    }

    if (null != dropNode) {
        JRDesignElement element = dropNode.getLookup().lookup(JRDesignElement.class);

        if (element instanceof JRDesignComponentElement && ((JRDesignComponentElement)element).getComponent() == getTable()) return null;

        if (null != element ) {

            return new ElementPasteType( element.getElementGroup(),
                                         (JRElementGroup)getCell(),
                                         element,dropAction,this);
        }

        if (dropNode instanceof ElementGroupNode)
        {
            JRDesignElementGroup g = ((ElementGroupNode)dropNode).getElementGroup();
            return new ElementPasteType( g.getElementGroup(),
                                         (JRElementGroup)getCell(),
                                         g,dropAction,this);
        }
        else
        {

        }
    }
    return null;
}
 

开发者ID:JockiHendry,
项目名称:ireport-fork,
代码行数:39,
代码来源:TableCellNode.java

示例13: getDropType

点赞 2

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
@Override
public PasteType getDropType(Transferable t, final int action, int index) {

    Node dropNode = NodeTransfer.node(t, DnDConstants.ACTION_COPY_OR_MOVE + NodeTransfer.CLIPBOARD_CUT);

    if (dropNode == null ||
        dropNode instanceof TableCellNode ||
        dropNode instanceof TableNullCellNode ||
        dropNode instanceof TableColumnGroupNode ||
        dropNode instanceof TableSectionNode) return null;

    return super.getDropType(t, action, index);
}
 

开发者ID:JockiHendry,
项目名称:ireport-fork,
代码行数:14,
代码来源:TableElementNode.java

示例14: getDropType

点赞 2

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
@Override
public PasteType getDropType(Transferable t, final int action, int index) {
    
    Node dropNode = NodeTransfer.node(t, DnDConstants.ACTION_COPY_OR_MOVE + NodeTransfer.CLIPBOARD_CUT);
    Node[] dropNodes = NodeTransfer.nodes(t, DnDConstants.ACTION_COPY_OR_MOVE + NodeTransfer.CLIPBOARD_CUT);
    int dropAction = DnDUtilities.getTransferAction(t);

    if (dropNode == null)
    {
        ElementPasteType.setLastPastedNodes(dropNodes);
    }

    if (null != dropNode && !(dropNode instanceof NotRealElementNode)) {
        JRDesignElement element = dropNode.getLookup().lookup(JRDesignElement.class);

        if (null != element) {

            return new ElementPasteType( element.getElementGroup(),
                                         getElement().getElementGroup(),
                                         element,dropAction,this);
        }

        if (dropNode instanceof ElementGroupNode)
        {
            JRDesignElementGroup g = ((ElementGroupNode)dropNode).getElementGroup();
            return new ElementPasteType( g.getElementGroup(),
                                         getElement().getElementGroup(),
                                         g,dropAction,this);
        }
        else
        {

        }
    }
    return null;
}
 

开发者ID:JockiHendry,
项目名称:ireport-fork,
代码行数:37,
代码来源:ElementNode.java

示例15: getDropType

点赞 2

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
@Override
public PasteType getDropType(Transferable t, final int action, int index) {

    final Node dropNode = NodeTransfer.node(t, DnDConstants.ACTION_COPY_OR_MOVE + NodeTransfer.CLIPBOARD_CUT);
    final int dropAction = DnDUtilities.getTransferAction(t);

    if (null != dropNode && dropNode instanceof DatasetNode) {
        final JRDesignDataset dataset = ((DatasetNode)dropNode).getDataset();
        if (null != dataset) {
            return new PasteType() {

                @SuppressWarnings("unchecked")
                public Transferable paste() throws IOException {
                    try {

                        JRDesignDataset newDataset = (JRDesignDataset) dataset.clone();

                        String name = newDataset.getName();
                        for (int i = 1;; i++) {
                            if (!getJasperDesign().getDatasetMap().containsKey(name + "_" + i)) {
                            newDataset.setName(name + "_" + i);
                            break;
                            }
                        }

                        getJasperDesign().addDataset(newDataset);

                    } catch (JRException ex) {
                        ex.printStackTrace();
                    }
                   return null;
                };
            };
        }
    }
    return null;
}
 

开发者ID:JockiHendry,
项目名称:ireport-fork,
代码行数:38,
代码来源:ReportNode.java

示例16: getDropType

点赞 2

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
@Override
public PasteType getDropType(Transferable t, final int action, int index) {

    Node dropNode = NodeTransfer.node(t, DnDConstants.ACTION_COPY_OR_MOVE + NodeTransfer.CLIPBOARD_CUT);
    Node[] dropNodes = NodeTransfer.nodes(t, DnDConstants.ACTION_COPY_OR_MOVE + NodeTransfer.CLIPBOARD_CUT);
    int dropAction = DnDUtilities.getTransferAction(t);

    if (dropNode == null)
    {
        ElementPasteType.setLastPastedNodes(dropNodes);
    }
           
    if (null != dropNode) {
        JRDesignElement element = dropNode.getLookup().lookup(JRDesignElement.class);
        
        if (null != element) {
            
            return new ElementPasteType( element.getElementGroup(),
                                         getFrame(),
                                         element,dropAction,this);
        }
        
        // Check if we are pasting a group not an element
        if (dropNode instanceof ElementGroupNode)
        {
            JRDesignElementGroup g = ((ElementGroupNode)dropNode).getElementGroup();
            return new ElementPasteType( g.getElementGroup(),
                                         getFrame(),
                                         g,dropAction,this);
        }
    }
    return null;
}
 

开发者ID:JockiHendry,
项目名称:ireport-fork,
代码行数:34,
代码来源:FrameNode.java

示例17: getDropType

点赞 2

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
@Override
public PasteType getDropType(Transferable t, final int action, int index) {

    Node dropNode = NodeTransfer.node(t, DnDConstants.ACTION_COPY_OR_MOVE + NodeTransfer.CLIPBOARD_CUT);
    int dropAction = DnDUtilities.getTransferAction(t);


    if (null != dropNode) {
        JRDesignElement element = dropNode.getLookup().lookup(JRDesignElement.class);


        if (null != element) {

            DesignListContents contents = (DesignListContents) ((StandardListComponent)((JRDesignComponentElement)this.getElement()).getComponent()).getContents();

            return new ElementPasteType( element.getElementGroup(),
                                         contents,
                                         element,dropAction,this);
        }

    }
    return null;
}
 

开发者ID:JockiHendry,
项目名称:ireport-fork,
代码行数:24,
代码来源:ListElementNode.java

示例18: clipboardCut

点赞 2

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
@Override
public Transferable clipboardCut() throws IOException {
    return NodeTransfer.transferable(this, NodeTransfer.CLIPBOARD_CUT);
}
 

开发者ID:JockiHendry,
项目名称:ireport-fork,
代码行数:5,
代码来源:TableColumnGroupNode.java

示例19: clipboardCopy

点赞 2

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
@Override
public Transferable clipboardCopy() throws IOException {
    return NodeTransfer.transferable(this, NodeTransfer.CLIPBOARD_COPY);
}
 

开发者ID:JockiHendry,
项目名称:ireport-fork,
代码行数:5,
代码来源:TableColumnGroupNode.java

示例20: getDropType

点赞 2

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
@Override
public PasteType getDropType(Transferable t, final int action, int index) {

    Node dropNode = NodeTransfer.node(t, DnDConstants.ACTION_COPY_OR_MOVE + NodeTransfer.CLIPBOARD_CUT);
    Node[] dropNodes = NodeTransfer.nodes(t, DnDConstants.ACTION_COPY_OR_MOVE + NodeTransfer.CLIPBOARD_CUT);
    int dropAction = DnDUtilities.getTransferAction(t);

    if (dropNode == null)
    {
        ElementPasteType.setLastPastedNodes(dropNodes);
    }
           
    if (null != dropNode) {
        JRDesignElement element = dropNode.getLookup().lookup(JRDesignElement.class);
        
        if (null != element)
        {
            if (element instanceof JRElementGroup &&
                ModelUtils.isAncestorElemenetGroup((JRElementGroup)element, (JRElementGroup)getElementGroup()) )
            {
                return null;
            }
            
            return new ElementPasteType( element.getElementGroup(),
                                         getElementGroup(),
                                         element,dropAction,this);
        }
        
        if (dropNode instanceof ElementGroupNode)
        {
            JRDesignElementGroup g = ((ElementGroupNode)dropNode).getElementGroup();
            
            if (ModelUtils.isAncestorElemenetGroup(g,getElementGroup()))
            {
                return null;
            }
            
            return new ElementPasteType( g.getElementGroup(),
                                         getElementGroup(),
                                         g,dropAction,this);
        }
    }
    return null;
}
 

开发者ID:JockiHendry,
项目名称:ireport-fork,
代码行数:45,
代码来源:ElementGroupNode.java

示例21: getDropType

点赞 2

import org.openide.nodes.NodeTransfer; //导入依赖的package包/类
/**
 *  We can add element groups and new elements here.
 */
//@Override
//public NewType[] getNewTypes()
//{
//  return NewTypesUtils.getNewType( NewTypesUtils.FIELD, this);
//}

@Override
public PasteType getDropType(Transferable t, final int action, int index) {

    Node dropNode = NodeTransfer.node(t, DnDConstants.ACTION_COPY_OR_MOVE + NodeTransfer.CLIPBOARD_CUT);
    Node[] dropNodes = NodeTransfer.nodes(t, DnDConstants.ACTION_COPY_OR_MOVE + NodeTransfer.CLIPBOARD_CUT);
    int dropAction = DnDUtilities.getTransferAction(t);

    if (dropNode == null)
    {
        ElementPasteType.setLastPastedNodes(dropNodes);
    }
           
    if (null != dropNode) {
        JRDesignElement element = dropNode.getLookup().lookup(JRDesignElement.class);
        
        if (element instanceof JRCrosstab) return null;
        
        if (null != element ) {
            
            return new ElementPasteType( element.getElementGroup(),
                                         (JRElementGroup)getCellContents(),
                                         element,dropAction,this);
        }
        
        if (dropNode instanceof ElementGroupNode)
        {
            JRDesignElementGroup g = ((ElementGroupNode)dropNode).getElementGroup();
            return new ElementPasteType( g.getElementGroup(),
                                         (JRElementGroup)getCellContents(),
                                         g,dropAction,this);
        }
        else
        {
            
        }
    }
    return null;
}
 

开发者ID:JockiHendry,
项目名称:ireport-fork,
代码行数:48,
代码来源:CellNode.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)