def _add_nodes(self, curTop, dir): """ Recursive implementation to fill the tree with filenames and directories :param curTop: current top directory :param dir: next directory :return: None """ curPath = dir.getPath() if os.path.isdir(curPath): nodePath = os.path.basename(curPath) curDir = DefaultMutableTreeNode(nodePath) if curTop != None: # should only be null at root curTop.add(curDir) ol = Vector() tmp = dir.list() for i in xrange(0, len(tmp)): ol.addElement(tmp[i]) thisObject = None files = Vector() # Make two passes, one for Dirs and one for Files. This is #1. for i in xrange(0, ol.size()): thisObject = ol.elementAt(i) if curPath == self._dir: newPath = thisObject else: newPath = os.path.join(curPath, thisObject) f = File(newPath) if f.isDirectory(): self._add_nodes(curDir, f) else: files.addElement(thisObject) # Pass two: for files. Collections.sort(files) for i in xrange(0, files.size()): f = files.elementAt(i) #if f.split('.')[-1] != 'html': curDir.add(DefaultMutableTreeNode(files.elementAt(i))) return curDir
def elementAt(self, idx): s1 = Vector.elementAt(self, idx) s1 = '[[%s]]' % s1 return s1
def upperElementAt(self, idx): #s1 = self.elementAt(idx) s1 = Vector.elementAt(self, idx) s1 = s1.upper() return s1