当前位置: 首页>>代码示例>>Java>>正文


Java DataFolder.getChildren方法代码示例

本文整理汇总了Java中org.openide.loaders.DataFolder.getChildren方法的典型用法代码示例。如果您正苦于以下问题:Java DataFolder.getChildren方法的具体用法?Java DataFolder.getChildren怎么用?Java DataFolder.getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openide.loaders.DataFolder的用法示例。

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

示例1: isValidCategory

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
boolean isValidCategory(Node node) {
    if (classPath == null)
        return true;

    // check if there is some valid item in this category
    // [ideally we should listen on the category for adding/removing items,
    //  practically we just need to hide Swing categories on some mobile platforms]
    DataFolder folder = node.getCookie(DataFolder.class);
    if (folder == null)
        return false;

    DataObject[] dobjs = folder.getChildren();
    for (int i=0; i < dobjs.length; i++) {
        PaletteItem item = dobjs[i].getCookie(PaletteItem.class);
        if (item == null || isValidItem(item))
            return true;
    }
    return dobjs.length == 0;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:PaletteUtils.java


示例2: preparePackageDelete

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
private Problem preparePackageDelete(NonRecursiveFolder folder, RefactoringElementsBag refactoringElements) {
    DataFolder dataFolder = DataFolder.findFolder(folder.getFolder());
    // First; delete all files except packages
    DataObject children[] = dataFolder.getChildren();
    boolean empty = true;
    for( int i = 0; children != null && i < children.length; i++ ) {
        FileObject fileObject = children[i].getPrimaryFile();
        if ( !fileObject.isFolder() ) {
            refactoringElements.addFileChange(refactoring, new DeleteFile(fileObject, refactoringElements));
        }
        else {
            empty = false;
        }
    }

    // If empty delete itself
    if ( empty ) {
        refactoringElements.addFileChange(refactoring, new PackageDeleteElem(folder));
    }
        
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:PackageDeleteRefactoringPlugin.java


示例3: containsAcceptedDataObject

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
/** 
 * Indicates if folder or its subfolders contains data object
 * that is supported by any internationalization factory. 
 */
public static boolean containsAcceptedDataObject(DataFolder folder) {
    DataObject[] children = folder.getChildren();
    DataObject[] folders = new DataObject[children.length];
    int i, foldersCount = 0;

    for (DataObject child : children) {
        if (child instanceof DataFolder) {  
            folders[foldersCount++] = child;
        } else if (FactoryRegistry.hasFactory(child.getClass())) {
            return true;
        }
    }
    for (i = 0; i < foldersCount; i++) {
        if (containsAcceptedDataObject((DataFolder) children[i])) {
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:I18nUtil.java


示例4: loadActions

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
private void loadActions(List<Action> actions, DataFolder df) throws IOException, ClassNotFoundException {
    DataObject[] dob = df.getChildren();
    int i;
    int k = dob.length;

    for (i = 0; i < k; i++) {
        InstanceCookie ic = dob[i].getCookie(InstanceCookie.class);
        if (ic == null) {
            LOG.log(Level.WARNING, "Not an action instance, or broken action: {0}", dob[i].getPrimaryFile());
            continue;
        }
        Class clazz = ic.instanceClass();

        if (JSeparator.class.isAssignableFrom(clazz)) {
            actions.add(null);
        } else {
            actions.add((Action)ic.instanceCreate());
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:GsfDataNode.java


示例5: addSource

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
/** Adds source to source map (I18N wizard settings). If there is already no change is done.
 * If it's added anew then it is tried to find correspondin reousrce, i.e.
 * first resource from the same folder.
 * @param sourceMap settings where to add teh sources
 * @param source source to add */
public static void addSource(Map<DataObject,SourceData> sourceMap,
                             DataObject source) {
    if (sourceMap.containsKey(source)) {
        return;
    }
    
    DataFolder folder = source.getFolder();
    
    if (folder == null) {
        sourceMap.put(source, null);
        return;
    }

    // try to associate Bundle file

    for (DataObject child : folder.getChildren()) {
        if (child instanceof PropertiesDataObject) { // PENDING 
            sourceMap.put(source, new SourceData(child));
            return;
        }
    }
    
    // No resource found in the same folder.
    sourceMap.put(source, null);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:Util.java


示例6: fillWebBrowsersCombo

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
private void fillWebBrowsersCombo(List<String> list, String select) {
    // PENDING need to get rid of this filtering
    FileObject fo = FileUtil.getConfigFile (BROWSERS_FOLDER);
    if (fo != null) {
        DataFolder folder = DataFolder.findFolder (fo);
        DataObject [] dobjs = folder.getChildren ();
        for (int i = 0; i<dobjs.length; i++) {
            // Must not be hidden and have to provide instances (we assume instance is HtmlBrowser.Factory)
            if (Boolean.TRUE.equals(dobjs[i].getPrimaryFile().getAttribute(EA_HIDDEN)) ||
                    dobjs[i].getLookup().lookup(InstanceCookie.class) == null) {
                FileObject fo2 = dobjs[i].getPrimaryFile();
                String n = fo2.getName();
                try {
                    n = fo2.getFileSystem().getDecorator().annotateName(n, dobjs[i].files());
                } catch (FileStateInvalidException e) {
                    // Never mind.
                }
                list.remove(n);
            }
        }
    }
    comboBoxWebBrowser.removeAllItems ();
    if (!list.isEmpty()) {
        for (String tag : list) {
            comboBoxWebBrowser.addItem(tag);
        }
        if(select != null) {
            comboBoxWebBrowser.setSelectedItem(select);
        }
        labelWebBrowser.setEnabled(true);
        comboBoxWebBrowser.setEnabled(true);
        jSeparator2.setEnabled(true);
    } else {
        labelWebBrowser.setEnabled(false);
        comboBoxWebBrowser.setEnabled(false);
        jSeparator2.setEnabled(false);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:JFXRunPanel.java


示例7: buildContent

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
private void buildContent() {
    String rootName = "WelcomePage/TutorialsLinks";  // NOI18N
    FileObject root = FileUtil.getConfigFile( rootName );
    if( null == root ) {
        Logger.getLogger(Tutorials.class.getName()).log(Level.INFO,
                "Start page content not found: " + "FileObject: " + rootName ); //NOI18N
        return;
    }
    DataFolder folder = DataFolder.findFolder( root );
    if( null == folder ) {
        Logger.getLogger(Tutorials.class.getName()).log(Level.INFO,
                "Start page content not found: " + "DataFolder: " + rootName ); //NOI18N
        return;
    }
    DataObject[] children = folder.getChildren();
    if( null == children ) {
        Logger.getLogger(Tutorials.class.getName()).log(Level.INFO,
                "Start page content not found: " + "DataObject: " + rootName ); //NOI18N
        return;
    }

    for( int i=0; i<children.length; i++ ) {
        row = addLink( row, children[i] );
    }

    WebLink link = new WebLink(BundleSupport.getLabel("AllOnlineDocs"), BundleSupport.getURL("AllOnlineDocs"), Utils.getLinkColor(), false); //NOI18N
    link.setFont( link.getFont().deriveFont( Font.BOLD ) );
    add( link, new GridBagConstraints(0, row++, 1, 1, 0.0, 0.0,
            GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(20,0,0,0), 0, 0 ) );

    add( new JLabel(), new GridBagConstraints(0, row++, 1, 1, 0.0, 1.0,
            GridBagConstraints.NORTHWEST, GridBagConstraints.VERTICAL, new Insets(0,0,0,0), 0, 0 ) );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:Tutorials.java


示例8: getFolders

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
private static void getFolders(DataFolder folder, List<DataFolder> folders) {
    for (DataObject d : folder.getChildren()) {
        if (d instanceof DataFolder) {
            DataFolder f = (DataFolder) d;
            folders.add(f);
            getFolders(f, folders);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:GUIRegistrationPanel.java


示例9: visit

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
private static void visit(List<DataFolder> folders, DataFolder f) {
    folders.add(f);
    DataObject[] kids = f.getChildren();
    for (int i = 0; i < kids.length; i++) {
        if (kids[i] instanceof DataFolder) {
            visit(folders, (DataFolder)kids[i]);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:SelectFolderPanel.java


示例10: warmUp

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
void warmUp (FileObject templatesFolder) {
    if (templatesFolder != null) {
        DataFolder df = DataFolder.findFolder (templatesFolder);
        if (df != null) {
            df.getChildren();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:TemplatesPanelGUI.java


示例11: clearBrokenShadows

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
/**
 * Removes references to nonexistent files.
 * Package-private for tests.
 */
void clearBrokenShadows() throws IOException {
    DataFolder f = FavoritesNode.getFolder();
    DataObject [] arr = f.getChildren();
    for (DataObject obj : arr) {
        if (! (obj instanceof DataShadow)) {
            obj.delete();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:Favorites.java


示例12: getTags

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
public java.lang.String[] getTags () {
    ArrayList<String> list = new ArrayList<String> (6);
    Lookup.Result<org.openide.awt.HtmlBrowser.Factory> r = Lookup.getDefault().lookupResult(org.openide.awt.HtmlBrowser.Factory.class);
    for (Lookup.Item<org.openide.awt.HtmlBrowser.Factory> i: r.allItems()) {
        list.add(i.getDisplayName());
    }
    
    // PENDING need to get rid of this filtering
    FileObject fo = FileUtil.getConfigFile (BROWSER_FOLDER);
    if (fo != null) {
        DataFolder folder = DataFolder.findFolder (fo);
        DataObject [] dobjs = folder.getChildren ();
        for (int i = 0; i<dobjs.length; i++) {
            // Must not be hidden and have to provide instances (we assume instance is HtmlBrowser.Factory)
            if (Boolean.TRUE.equals(dobjs[i].getPrimaryFile().getAttribute(EA_HIDDEN)) ||
                    dobjs[i].getCookie(InstanceCookie.class) == null) {
                FileObject fo2 = dobjs[i].getPrimaryFile();
                String n = fo2.getName();
                try {
                    n = fo2.getFileSystem().getDecorator().annotateName(n, dobjs[i].files());
                } catch (FileStateInvalidException e) {
                    // Never mind.
                }
                list.remove(n);
            }
        }
    }
    String[] retValue = new String[list.size ()];
    
    list.toArray (retValue);
    return retValue;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:HtmlBrowser.java


示例13: addButton

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
/**
 * Add a new toolbar button represented by the given DataObject.
 */
private boolean addButton( DataObject dobj, int dropIndex, boolean dropBefore ) throws IOException {
    if( null == dobj )
        return false;
    //check if the dropped button (action) already exists in this toolbar
    String objName = dobj.getName();
    DataFolder backingFolder = getBackingFolder(currentToolbar);
    DataObject[] children = backingFolder.getChildren();
    for( int i=0; i<children.length; i++ ) {
        //TODO is comparing DataObject names ok?
        if( objName.equals( children[i].getName() ) ) {
            //user dropped to toolbat a new button that already exists in this toolbar
            //just move the existing button to a new position
            return moveButton( children[i], dropIndex, dropBefore );
        }
    }

    DataObject objUnderCursor = getDataObjectUnderDropCursor( dropIndex-1, dropBefore );

    DataShadow shadow = DataShadow.create( backingFolder, dobj );
    // use some fake position, so getChildren don't complain
    shadow.getPrimaryFile().setAttribute("position", 100001); // NOI18N

    //find the added object
    DataObject newObj = null;
    children = backingFolder.getChildren();
    for( int i=0; i<children.length; i++ ) {
        if( objName.equals( children[i].getName() ) ) {
            newObj = children[i];
            break;
        }
    }

    if( null != newObj )
        reorderButtons( newObj, objUnderCursor ); //put the button to its proper position

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


示例14: removeNotify

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
@Override
public void removeNotify() {
    super.removeNotify();

    ToolbarPool pool = ToolbarPool.getDefault();
    final ToolbarConfiguration tc = ToolbarConfiguration.findConfiguration( pool.getConfiguration() );
    if( null != tc ) {
        tc.setToolbarButtonDragAndDropAllowed( false );
    }
    //remove empty toolbars
    DataFolder folder = pool.getFolder();
    DataObject[] children = folder.getChildren();
    for( int i=0; i<children.length; i++ ) {
        final DataFolder subFolder = children[i].getCookie( DataFolder.class );
        if( null != subFolder && subFolder.getChildren().length == 0 ) {
            SwingUtilities.invokeLater( new Runnable() {

                @Override
                public void run() {
                    try {
                        subFolder.delete();
                        ToolbarPool.getDefault().waitFinished();
                        if( null != tc ) {
                            tc.removeEmptyRows();
                            tc.save();
                        }
                    }
                    catch (IOException e) {
                        LOG.log(Level.WARNING, null, e);
                    }
                }
            });
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:ConfigureToolbarPanel.java


示例15: getFavoriteRoots

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
/**
 * Returns list of current root file objects in Favorites.
 * @return
 */
public synchronized List<FileObject> getFavoriteRoots() {
    DataFolder f = FavoritesNode.getFolder();
    DataObject [] arr = f.getChildren();
    List<FileObject> ret = new ArrayList<FileObject>(arr.length);

    for (DataObject obj : arr) {
        if (obj instanceof DataShadow) {
            ret.add(((DataShadow) obj).getOriginal().getPrimaryFile());
        }
    }
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:Favorites.java


示例16: createPasteSuffix

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
/** Creates new name for this instance when moving/copying to new folder destination. 
 * @param folder new folder destination. */
private String createPasteSuffix(DataFolder folder) {
    String basicName = getPrimaryFile().getName();

    DataObject[] children = folder.getChildren();


    // Repeat until there is not such file name.
    for(int i = 0; ; i++) {
        String newName;

        if (i == 0) {
            newName = basicName;
        } else {
            newName = basicName + i;
        }
        boolean exist = false;

        for(int j = 0; j < children.length; j++) {
            if(children[j] instanceof PropertiesDataObject && newName.equals(children[j].getName())) {
                exist = true;
                break;
            }
        }

        if(!exist) {
            if (i == 0) {
                return ""; // NOI18N
            } else {
                return "" + i; // NOI18N
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:PropertiesDataObject.java


示例17: remove

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
/**
 * Removes the file describing the specified JDBC driver.
 */
public static void remove(JDBCDriver drv) throws IOException {
    String name = drv.getName();
    FileObject fo = FileUtil.getConfigFile(DRIVERS_PATH); //NOI18N
    // If DRIVERS_PATH can't be found (getConfigFile returns null)
    // its useless to try to delete any driver
    if(fo == null) {
        return;
    }
    DataFolder folder = DataFolder.findFolder(fo);
    DataObject[] objects = folder.getChildren();
    
    for (int i = 0; i < objects.length; i++) {
        InstanceCookie ic = (InstanceCookie)objects[i].getCookie(InstanceCookie.class);
        if (ic != null) {
            try {
                Object obj = ic.instanceCreate();
                if (obj instanceof JDBCDriver) {
                    JDBCDriver driver = (JDBCDriver) obj;
                    if (driver.getName().equals(name)) {
                        objects[i].delete();
                        break;
                    }
                }
            } catch (ClassNotFoundException e) {
                continue;
            }

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


示例18: findShadow

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
private static DataShadow findShadow (DataFolder f, DataObject dobj) {
    FileObject fo = dobj.getPrimaryFile();
    if (fo != null) {
        DataObject [] arr = f.getChildren();
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] instanceof DataShadow) {
                DataShadow obj = (DataShadow) arr[i];
                if (fo.equals(obj.getOriginal().getPrimaryFile())) {
                    return obj;
                }
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:Actions.java


示例19: reorder

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
private void reorder( String fileName, FileObject categoryFolder, int dropIndex ) throws IOException {
    if( dropIndex < 0 )
        return;
    FileObject itemFile = categoryFolder.getFileObject(fileName, "xml" ); //NOI18N
    if( null == itemFile )
        return;
    DataFolder catDob = DataFolder.findFolder(categoryFolder);
    DataObject[] children = catDob.getChildren();
    
    DataObject dob = DataObject.find(itemFile);
    if( null == dob )
        return;
    
    int curIndex = -1;
    for( int i=0; i<children.length; i++ ) {
        if( children[i].equals(dob) ) {
            curIndex = i;
            break;
        } 
    }
    if( curIndex < 0 )
        return;
    
    DataObject[] sortedChildren = new DataObject[children.length];
    if( dropIndex >= sortedChildren.length )
        dropIndex = sortedChildren.length-1;
    sortedChildren[dropIndex] = dob;
    int index = 0;
    for( int i=0; i<sortedChildren.length; i++ ) {
        if( sortedChildren[i] != null ) {
            continue;
        }
        DataObject tmp = children[index++];
        if( dob.equals(tmp) ) {
            i--;
            continue;
        }
        sortedChildren[i] = tmp;
    }
    
    catDob.setOrder(sortedChildren);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:43,代码来源:TextImporter.java


示例20: handleRename

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
@Override
public void handleRename(Node node, String newName) {
    DataFolder dob = (DataFolder) node.getCookie(DataObject.class);
    FileObject fo = dob.getPrimaryFile();
    if (node.isLeaf()) {
        //rename empty package and don't try to do any refactoring
        try {
            if (!RefactoringUtils.isValidPackageName(newName)) {
                String msg = new MessageFormat(NbBundle.getMessage(RenameRefactoringPlugin.class,"ERR_InvalidPackage")).format(
                        new Object[] {newName}
                );
                
                DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                    msg, NotifyDescriptor.INFORMATION_MESSAGE));
                return;
            }
            ClassPath sourcepath = ClassPath.getClassPath(fo, ClassPath.SOURCE);
            if (sourcepath == null) {
                throw new IOException("no sourcepath for " + fo);
            }
            FileObject root = sourcepath.findOwnerRoot(fo);
            if (root == null) {
                throw new IOException(fo + " not in its own sourcepath " + sourcepath);
            }
            FileObject newFolder = FileUtil.createFolder(root, newName.replace('.','/'));
            while (dob.getChildren().length == 0 && dob.isDeleteAllowed() && !dob.getPrimaryFile().equals(newFolder)) {
                DataFolder parent = dob.getFolder();
                dob.delete();
                dob = parent;
            }
        } catch (IOException ioe) {
            ErrorManager.getDefault().notify(ioe);
        }
        return;
    }

    InstanceContent ic = new InstanceContent();
    ic.add(node);
    ExplorerContext d = new ExplorerContext();
    d.setNewName(newName);
    ic.add(d);
    final Lookup l = new AbstractLookup(ic);
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            Action a = RefactoringActionsFactory.renameAction().createContextAwareInstance(l);
            if (Boolean.TRUE.equals(a.getValue("applicable"))) { //NOI18N
                a.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:53,代码来源:PackageRenameHandlerImpl.java



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