spring-projects / sts4

The next generation of tooling for Spring Boot, including support for Cloud Foundry manifest files, Concourse CI pipeline definitions, BOSH deployment manifests, and more... - Available for Eclipse, Visual Studio Code, and Theia
https://spring.io/tools
Eclipse Public License 1.0
882 stars 208 forks source link

Jenkov-prizetags issue #85

Closed venky3989 closed 6 years ago

venky3989 commented 6 years ago

import com.jenkov.prizetags.tree.impl.DaoBase; import com.jenkov.prizetags.tree.impl.TreeNode; import com.jenkov.prizetags.tree.impl.TreeSorter; import com.jenkov.prizetags.tree.itf.ITree; import com.jenkov.prizetags.tree.itf.ITreeDao; import com.jenkov.prizetags.tree.itf.ITreeNode;

import java.io.File; import java.util.Set; import java.util.HashSet; import java.util.Iterator;

public class FileDAO extends DaoBase implements ITreeDao {

File rootDirectory = null;
private static final int ASCENDING  = 1;   
private static final int DESCENDING = -1;   

public FileDAO(File rootDirectory) {
    if (!rootDirectory.exists()) {
        throw new IllegalArgumentException("Directory " + rootDirectory.getAbsolutePath() + " doesn't exist");
    }
    this.rootDirectory = rootDirectory;
}
//------------------Here getting the root node--------------------
protected ITreeNode readRoot(ITree tree) {
    tree.setRoot(readNode(this.rootDirectory));
    TreeSorter.sortById(tree.getRoot()); 
    return tree.getRoot();
}

//------------------Here Years will appear----------------------------
protected Set<ITreeNode> readChildren(ITreeNode parentNode) {
    Set<ITreeNode> children = new HashSet<ITreeNode>();

    File parentDir = (File) parentNode.getObject();
    String[] files = parentDir.list();
    System.out.println("list of files........"+files);
    if (files == null)
        return children;
    for (int i = 0; i < files.length; i++) {
        File childFile = new File(parentDir.getAbsolutePath() + File.separator + files[i]);
        ITreeNode child = readNode(childFile);

        child.setParentId(parentNode.getId());
        if (!childFile.exists())
            continue;
        children.add(child);
    }

    // Sort here
    //TreeSorter.sortById(parentNode);

    return children;
}
//-------------------------here months will appear--------------------
    protected Set<ITreeNode> readGrandChildren(ITreeNode parentNode) {
        Set<ITreeNode> grandChildren = new HashSet<ITreeNode>();
        Iterator<ITreeNode> children = parentNode.getChildren().iterator();
        while (children.hasNext()) {
            ITreeNode child = children.next();
            grandChildren.addAll(readChildren(child));
        }
        return grandChildren; 
    }
//------------------- Generating the ADF Reports------------------------
protected ITreeNode readNode(File file) {
    if (!file.exists())
        return null;
    ITreeNode node = null;
    String childType = file.isDirectory() ? "directory" : "file";
    if (childType.equals("file")) {

        node = new TreeNode(file.getAbsolutePath(), "<a href=\"openPdf.jsp?fileName=" + file.getAbsolutePath() + "\" target=_blank>" + file.getName() + "</a>", childType);

    } else {
        node = new TreeNode(file.getAbsolutePath(), file.getName(), childType);
    }
    node.setObject(file);
    return node;
}

}

https://github.com/business-logic/br4j/blob/master/base/SharedComponents/Controls/src/com/jenkov/prizetags/tree/impl/FileDao2.java

In this above code am facing one issue at readGrandChildren() method. like here am getting calendar months ascending order but i want to display calendar order means Jan,Feb,Mar.....Dec.

Thanks&Regards, Venkat.

martinlippert commented 6 years ago

This doesn't sound like an issue with the Spring Tools 4 tooling itself, but more something you should ask on stackoverflow... :-)