當前位置: 首頁>>代碼示例>>Java>>正文


Java DataObject.Container方法代碼示例

本文整理匯總了Java中org.openide.loaders.DataObject.Container方法的典型用法代碼示例。如果您正苦於以下問題:Java DataObject.Container方法的具體用法?Java DataObject.Container怎麽用?Java DataObject.Container使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openide.loaders.DataObject的用法示例。


在下文中一共展示了DataObject.Container方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAcceptedDataObjects

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
/** 
 * Recursivelly get all accepted data objects starting from given folder. 
 */
public static List<DataObject> getAcceptedDataObjects(DataObject.Container folder) {
    List<DataObject> accepted = new ArrayList<DataObject>();
    
    final VisibilityQuery visQuery = VisibilityQuery.getDefault();

    DataObject[] children = folder.getChildren();

    for (DataObject child : children) {
        if (!visQuery.isVisible(child.getPrimaryFile())) {
            continue;
        }
        if(child instanceof DataObject.Container) {
            accepted.addAll(getAcceptedDataObjects((DataObject.Container)child));
        } else {
            if(FactoryRegistry.hasFactory(child.getClass()))
                accepted.add(child);
        }
    }

    return accepted;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:I18nUtil.java

示例2: createWizardSourceMap

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
/** 
 * Create settings based on selected nodes. Finds all accepted data objects. 
 * Used by actions to populate wizard.
 * @param activatedNodes selected nodes 
 * @return map with accepted data objects as keys or empty map if no such
 * data object were found.
 */
public static Map<DataObject,SourceData> createWizardSourceMap(Node[] activatedNodes) {
    Map<DataObject,SourceData> sourceMap = createWizardSourceMap();
    
    if (activatedNodes != null && activatedNodes.length > 0) {
        final VisibilityQuery visQuery = VisibilityQuery.getDefault();
        for (Node node : activatedNodes) {
            DataObject dobj = node.getCookie(DataObject.class);
            if (dobj != null && !visQuery.isVisible(dobj.getPrimaryFile())) {
                continue;
            }

            DataObject.Container container = node.getCookie(DataObject.Container.class);
            if (container != null) {
                for (DataObject dataObj : I18nUtil.getAcceptedDataObjects(container)) {
                    addSource(sourceMap, dataObj);
                }
            }

            if (dobj == null) {
                continue;
            }

            if (FactoryRegistry.hasFactory(dobj.getClass())) {
                addSource(sourceMap, dobj);
            }
        }
    }
    
    return sourceMap;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:38,代碼來源:Util.java

示例3: assertNodes

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
private static void assertNodes( Children children, String[] nodeNames, int[] childCount, boolean optimalResult ) throws InterruptedException, InvocationTargetException {
    waitForAWT();
    Node[] nodes = children.getNodes (optimalResult);
    String[] actualNodeNames = new String[nodes.length];
    for (int i = 0; i < nodes.length; i++) {
        actualNodeNames[i] = nodes[i].getDisplayName();
    }
    assertEquals("Wrong # or names of nodes", Arrays.asList(nodeNames), Arrays.asList(actualNodeNames));
    
    for( int i = 0; i < nodeNames.length; i++ ) {
        if ( childCount != null ) {
            if ( childCount[i] == 0 ) {
                assertEquals( "Node should be leaf", true, nodes[i].isLeaf() );
            }
            else {
                assertEquals( "Node should not be leaf", false, nodes[i].isLeaf() );
            }
            
            assertEquals( "Wrong number of children. Node: " + nodeNames[i] +".", childCount[i], nodes[i].getChildren().getNodes( true ).length );
            
            
            DataObject.Container cont = nodes[i].getLookup().lookup (DataObject.Container.class);
            if (cont != null) {
                Node[] arr = nodes[i].getChildren ().getNodes ( true );
                DataObject[] child = cont.getChildren ();
                for (int k = 0, l = 0; k < arr.length; k++) {
                    if ( !VisibilityQuery.getDefault().isVisible( child[k].getPrimaryFile() ) ) {
                        continue;
                    }
                    DataObject myObj = arr[l].getLookup().lookup(DataObject.class);
                    assertNotNull ("Data object should be found for " + arr[k], myObj);
                    if (child.length <= k) {
                        fail ("But there is no object for node: " + arr[k]);
                    } else {
                        assertEquals ("child objects are the same", child[k], myObj);
                    }
                    l++;
                }
            }
            
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:44,代碼來源:PackageViewTest.java


注:本文中的org.openide.loaders.DataObject.Container方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。