@@ -0,0 +1,2100 @@
+/*%0A * To change this license header, choose License Headers in Project Properties.%0A * To change this template file, choose Tools %7C Templates%0A * and open the template in the editor.%0A */%0Apackage com.blazzify.jasonium.ui;%0A%0Aimport com.blazzify.jasonium.MainApp;%0Aimport com.blazzify.jasonium.models.Server;%0Aimport com.fasterxml.jackson.databind.ObjectMapper;%0Aimport java.io.IOException;%0Aimport java.util.Map;%0Aimport java.util.logging.Level;%0Aimport java.util.logging.Logger;%0Aimport javafx.scene.control.TreeItem;%0Aimport javafx.scene.control.TreeView;%0Aimport javafx.scene.image.Image;%0Aimport javafx.scene.image.ImageView;%0Aimport javafx.stage.Window;%0A%0A/**%0A *%0A * @author Azzuwan Aziz %3Cazzuwan@gmail.com%3E%0A */%0Apublic class ServerTree extends TreeView%3CServer%3E %7B%0A%0A    ObjectMapper mapper = new ObjectMapper();%0A%0A    public ServerTree() %7B%0A    %7D%0A    %0A    public ServerTree(Window root, Map%3CString, String%3E servers) %7B%0A        Image imgRoot = new Image(getClass().getClassLoader().getResourceAsStream(%22icons/servers.png%22));%0A        Server node = new Server();%0A        node.setName(%22Servers%22);%0A        TreeItem%3CServer%3E rootNode = new TreeItem%3C%3E(node, new ImageView(imgRoot));%0A        servers.forEach((t, u) -%3E %7B%0A            Server s = new Server();%0A            try %7B%0A                s = mapper.readValue(u.toString(), Server.class);%0A            %7D catch (IOException ex) %7B%0A                Logger.getLogger(MainApp.class.getName()).log(Level.SEVERE, null, ex);%0A            %7D%0A            Image imgOffline = new Image(getClass().getClassLoader().getResourceAsStream(%22icons/server-off.png%22));%0A            TreeItem%3CServer%3E child = new TreeItem%3C%3E(s, new ImageView(imgOffline));%0A            rootNode.getChildren().add(child);%0A        %7D);%0A        this.setRoot(rootNode);%0A        this.setOnContextMenuRequested((event) -%3E %7B%0A            ServerTreeContextMenu menu = new ServerTreeContextMenu();%0A            Window w = root.getScene().getWindow();%0A            Double winX = w.getX();%0A            Double winY = w.getY();            %0A            menu.show(w, event.getSceneX() + winX, event.getSceneY() + winY);%0A        %7D);%0A    %7D%0A%0A%7D%0A

Refactor server tree into it's own component