package SapforTestingSystem.SapforTasksPackage.UI;
import Common.Current;
import Common.UI.Trees.DataTree;
import Common.UI.Trees.TreeRenderers;
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;
    }
    @Override
    protected int getStartLine() {
        return 1;
    }
    @Override
    public void LeftMouseAction2() {
    }

    @Override
    public TreeRenderers getRenderer() {
        return TreeRenderers.RendererSapforVersion;
    }
    @Override
    public Current getCurrent() {
        return current;
    }
    @Override
    public void SelectionAction(TreePath e) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getLastPathComponent();
        Object o = node.getUserObject();
        if (o instanceof SapforVersion_json) {
            SapforVersion_json version = (SapforVersion_json) o;
            Current.set(current, version);
            if (current.equals(Current.SapforEtalonVersion))
                UI.getMainWindow().getTestingWindow().ShowCurrentSapforPackageVersionEtalon();
            else
                UI.getMainWindow().getTestingWindow().ShowCurrentSapforPackageVersion();
        }
    }
}