void initChildren()

in eclipse/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java [325:406]


	void initChildren() {
		try {
			if (resourceChildrenAdded) {
				throw new IllegalStateException("Children already loaded");
			}
			Set<String> childrenNames = new HashSet<>();
            for (Iterator<JcrNode> it = children.iterator(); it.hasNext();) {
                JcrNode node = it.next();
				childrenNames.add(node.getName());
			}
			
			if (resource!=null && resource instanceof IFolder) {
				IFolder folder = (IFolder)resource;
				IResource[] members = folder.members();
                List<IResource> membersList = new LinkedList<>(Arrays.asList(members));
				outerLoop: while(membersList.size()>0) {
                    for (Iterator<IResource> it = membersList.iterator(); it.hasNext();) {
                        IResource iResource = it.next();
                        if (isDotVltFile(iResource)) {
                            it.remove();
                            continue;
                        }
                        
                        if (childShouldNotBeShown(iResource)) {
                            it.remove();
                            continue;
                        }
                        
						if (isVaultFile(iResource)) {
							GenericJcrRootFile gjrf;
                            try {
                                gjrf = new GenericJcrRootFile(this, (IFile)iResource);
                                it.remove();
                                // gjrf.getChildren();
                                gjrf.pickResources(membersList);
                            } catch (XMLParseException e) {
                                // don't try to parse it
                                // errors will be reported by the XML validation infrastructure
                                it.remove();
                            }
							
							// as this might have added some new children, go through the children again and
							// add them if they're not already added
                            for (JcrNode node : children) {
								if (!childrenNames.contains(node.getName())) {
									childrenNames.add(node.getName());
								}
							}
							
							continue outerLoop;
						}
					}
					List<JcrNode> newNodes = new LinkedList<>();
                    for (Iterator<IResource> it = membersList.iterator(); it.hasNext();) {
						IResource iResource = it.next();
						JcrNode node;
						if (DirNode.isDirNode(iResource)) {
							node = new DirNode(this, (Element)null, iResource);
						} else {
							node = new JcrNode(this, (Element)null, iResource);
						}
						childrenNames.add(node.getName());
						newNodes.add(node);
						it.remove();
					}
				}
			}
			resourceChildrenAdded = true;
		} catch (CoreException e) {
			e.printStackTrace();
			org.apache.sling.ide.eclipse.ui.internal.Activator.getDefault().getPluginLogger().error("Error initializing children: "+e, e);
		} catch (ParserConfigurationException e) {
			e.printStackTrace();
            org.apache.sling.ide.eclipse.ui.internal.Activator.getDefault().getPluginLogger().error("Error initializing children: "+e, e);
		} catch (SAXException e) {
			e.printStackTrace();
            org.apache.sling.ide.eclipse.ui.internal.Activator.getDefault().getPluginLogger().error("Error initializing children: "+e, e);
		} catch (IOException e) {
			e.printStackTrace();
            org.apache.sling.ide.eclipse.ui.internal.Activator.getDefault().getPluginLogger().error("Error initializing children: "+e, e);
		}
	}