package _VisualDVM.ProjectData.Files.UI;
import Common.Visual.Trees.DataTree;
import Common.Visual.Trees.TreeRenderers;
import _VisualDVM.Current;
import _VisualDVM.Global;
import _VisualDVM.ProjectData.SapforData.FileObject;
import _VisualDVM.ProjectData.SapforData.FileObjectWithMessages;

import javax.swing.tree.DefaultMutableTreeNode;
public class FileGraphTree extends DataTree {
    public FileGraphTree(DefaultMutableTreeNode root) {
        super(root);
        //  ExpandAll();
    }
    @Override
    public TreeRenderers getRenderer() {
        return TreeRenderers.RendererGraph;
    }
    @Override
    public Current getCurrent() {
        return Current.FileGraphElement;
    }
    @Override
    public void ShowCurrentObject() throws Exception {
        Global.mainModule.getFile().form.EventsOff();
        Object o = Global.mainModule.get(getCurrent());
        Global.mainModule.getFile().form.getEditor().gotoLine((o instanceof FileObjectWithMessages) ? (((FileObjectWithMessages) o).line) : 1);
        Global.mainModule.getFile().form.ShowMessages();
        Global.mainModule.getFile().form.EventsOn();
    }
    @Override
    protected boolean findNode(Object userObject, Object criteria) {
        return (userObject instanceof FileObject) && (
                ((FileObject) (userObject)).line == (Integer) criteria);
    }
    @Override
    protected int getStartLine() {
        return 1;
    }
}