package SapforTestingSystem.SapforTasksPackage;
import Common.Current;
import Common.UI.Trees.DataTree;
import Common.UI.UI;
import SapforTestingSystem.Json.SapforVersion_json;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
public class SapforTasksPackageTree extends DataTree {
    Current current;
    public SapforTasksPackageTree(DefaultMutableTreeNode root_in, Current current_in) {
        super(root_in);
        current = current_in;
        //   setRootVisible(false);
        //  CollapseAll();
    }
    @Override
    protected int getStartLine() {
        return 1;
    }
    @Override
    public void LeftMouseAction2() {
    }
    @Override
    public Current getCurrent() {
        return current;
    }
    @Override
    public void SelectionAction(TreePath e) {
        System.out.println("Select " + current);
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getLastPathComponent();
        // Current.set(Current.ProjectNode, node);
        Object o = node.getUserObject();
        if (o instanceof SapforVersion_json) {
            SapforVersion_json version = (SapforVersion_json) o;
            Current.set(current, version);

            /*
            System.out.println(version.version+" files: "+version.files.size());
            for (ProjectFile file: version.files){
                System.out.println(Utils.Brackets(file));
            }
            System.out.println("---");
             */
            if (current.equals(Current.SapforEtalonVersion))
                UI.getMainWindow().getTestingWindow().ShowCurrentSapforPackageVersionEtalon();
            else
                UI.getMainWindow().getTestingWindow().ShowCurrentSapforPackageVersion();
        }
    }
}