private void addFileToDir(TreeNode<File> dir, File file) { final TreeNode<File> fileNode = new TreeNode<File>(file.getName()); fileNode.setContent(file); dir.addChild(fileNode); }
private void addFileToDir(TreeNode<File> dir, File file) { final TreeNode<File> fileNode = new TreeNode<File>(file.getName()); fileNode.setContent(file); dir.addChild(fileNode); }
private TreeNode<T> getChildForId(String id, boolean create) { if (id.equals("") || id.equals(".")) { return this; } if (id.equals("..")) { return getParent(); } if (children != null) { for (TreeNode<T> child : children) { if (child.getId().equals(id)) { return child; } } } if (create) { TreeNode<T> proxyChild = new TreeNode<T>(id); addChild(proxyChild); return proxyChild; } return null; } }
@Override public TreeNode<File> getProductComponents() { try { final File headerFile = EnviProductReaderPlugIn.getInputFile(getInput()); File parentDir = headerFile.getParentFile(); final TreeNode<File> root = new TreeNode<>(parentDir.getCanonicalPath()); root.setContent(parentDir); final TreeNode<File> header = new TreeNode<>(headerFile.getName()); header.setContent(headerFile); root.addChild(header); if (productZip == null) { final File imageFile = getEnviImageFile(headerFile); final TreeNode<File> image = new TreeNode<>(imageFile.getName()); image.setContent(imageFile); root.addChild(image); } return root; } catch (IOException ignored) { return null; } }
TreeNode<File> getProductComponents() { try { File parentDir = baseDir.getParentFile(); if (parentDir == null) { throw new IllegalStateException("Could not retrieve the parent directory of '" + baseDir.getAbsolutePath() + "'."); } final TreeNode<File> root = new TreeNode<File>(parentDir.getCanonicalPath()); root.setContent(parentDir); final TreeNode<File> dir = new TreeNode<File>(baseDir.getName()); dir.setContent(baseDir); root.addChild(dir); File volumeFile = CeosHelper.getVolumeFile(baseDir); addFileToDir(dir, volumeFile); addFileToDir(dir, new File(volumeDirectoryFile.getLeaderFileName())); addFileToDir(dir, new File(volumeDirectoryFile.getTrailerFileName())); String supplemental = volumeDirectoryFile.getSupplementalFileName(); if (StringUtils.isNotNullAndNotEmpty(supplemental)) { addFileToDir(dir, new File(supplemental)); } final String[] imageFileNames = volumeDirectoryFile.getImageFileNames(); for (String imageFileName : imageFileNames) { addFileToDir(dir, new File(imageFileName)); } return root; } catch (IOException e) { return null; } }
throw new IllegalStateException("Could not retrieve the parent directory of '" + baseDir.getAbsolutePath() + "'."); final TreeNode<File> root = new TreeNode<File>(parentDir.getCanonicalPath()); root.setContent(parentDir); final TreeNode<File> dir = new TreeNode<File>(baseDir.getName()); dir.setContent(baseDir); root.addChild(dir);
public void testProxy() { TreeNode<String> n = new TreeNode<String>("x"); Assert.assertEquals("x", n.getId()); Assert.assertEquals(null, n.getParent()); Assert.assertEquals(null, n.getContent()); assertNotNull(n.getChildren()); Assert.assertEquals(0, n.getChildren().length); }
public void testRoot() { TreeNode<String> root = new TreeNode<String>(""); TreeNode<String> grunt = root.createChild("foo/bar/grunt"); assertSame(root, grunt.getRoot()); }
TreeNode<HelpSet> childNode = parentNode.getChild(helpSetId); if (childNode == null) { childNode = new TreeNode<>(helpSetId, helpSet); parentNode.addChild(childNode); } else if (childNode.getContent() == null) {
private void registerHelpSets(ModuleContext moduleContext) { this.helpSetRegistry = new TreeNode<>(""); ExtensionPoint hsExtensionPoint = moduleContext.getModule().getExtensionPoint("helpSets"); Extension[] hsExtensions = hsExtensionPoint.getExtensions(); for (Extension extension : hsExtensions) { ConfigurationElement confElem = extension.getConfigurationElement(); ConfigurationElement[] helpSetElements = confElem.getChildren("helpSet"); for (ConfigurationElement helpSetElement : helpSetElements) { final Module declaringModule = extension.getDeclaringModule(); if (declaringModule.getState().is(ModuleState.RESOLVED)) { registerHelpSet(helpSetElement, declaringModule); } } } addNodeToHelpSys(helpSetRegistry); }
public void testGetChildren() { TreeNode<String> root = new TreeNode<String>(""); TreeNode<String>[] children = root.getChildren(); assertNotNull(children); assertEquals(0, children.length); root.createChild("foo/bar"); root.createChild("foo/baz"); root.createChild("foo/boo"); children = root.getChildren(); assertNotNull(children); assertEquals(1, children.length); children = root.getChild("foo").getChildren(); assertNotNull(children); assertEquals(3, children.length); }
public void testAbsolutePaths() { TreeNode<String> root = new TreeNode<String>(""); TreeNode<String> foo = root.createChild("foo"); TreeNode<String> bar = foo.createChild("bar"); TreeNode<String> grunt = bar.createChild("grunt"); assertSame(grunt, grunt.getChild("/foo/bar/grunt")); assertSame(grunt, foo.getChild("/foo/bar/grunt")); assertSame(grunt, bar.getChild("/foo/bar/grunt")); assertSame(grunt, grunt.getChild("/foo/bar/grunt")); TreeNode<String> baz = grunt.createChild("/foo/bar/baz"); assertSame(baz, grunt.getChild("/foo/bar/baz")); assertSame(baz, foo.getChild("/foo/bar/baz")); assertSame(baz, bar.getChild("/foo/bar/baz")); assertSame(baz, grunt.getChild("/foo/bar/baz")); assertSame(baz, baz.getChild("/foo/bar/baz")); } }
public void testGetAndCreateChild() { TreeNode<String> root = new TreeNode<String>(""); TreeNode<String> subChild = root.createChild("foo/bar/grunt");