Search in sources :

Example 6 with ContainerInfo

use of si.ijs.maci.ContainerInfo in project ACS by ACS-Community.

the class TreeMouseListener method showLoggingConfigTab.

/**
	 * Show the dialog to read and configure the log level
	 * 
	 * @param path The path of the selected node
	 *
	 */
private void showLoggingConfigTab(TreePath path) {
    if (path == null) {
        throw new IllegalArgumentException("Invalid null path");
    }
    DefaultMutableTreeNode selNode = (DefaultMutableTreeNode) path.getLastPathComponent();
    DefaultMutableTreeNode targetNode = selNode;
    boolean implementsLogging = implementsLoggingConfigurable(selNode);
    if (!implementsLogging) {
        // yatagai: ad hoc implementation
        targetNode = (DefaultMutableTreeNode) selNode.getParent();
        if (targetNode == null || !implementsLoggingConfigurable(targetNode))
            return;
    }
    // Get a reference to the LoggingConfigurable for the 
    // selected item
    LoggingConfigurableOperations logConf = null;
    if (model.isManagerNode(targetNode)) {
        try {
            logConf = getLogConfFromManager();
        } catch (Throwable t) {
            JOptionPane.showInternalMessageDialog(tree, "Error getting the LoggingConfigurable:\n" + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
    } else if (model.isServiceNode(targetNode)) {
        try {
            logConf = getLogConfFromService(targetNode.getUserObject().toString());
        } catch (Throwable t) {
            JOptionPane.showInternalMessageDialog(tree, "Error getting the LoggingConfigurable:\n" + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
    } else {
        ContainerInfo cInfo;
        try {
            cInfo = ((TreeContainerInfo) targetNode.getUserObject()).getClientInfo();
        } catch (Throwable t) {
            JOptionPane.showInternalMessageDialog(tree, "Error retrieving ContainerInfo from the node", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        try {
            logConf = getLogConfFromContainer(cInfo);
        } catch (Throwable t) {
            JOptionPane.showInternalMessageDialog(tree, "Error getting the LoggingConfigurable:\n" + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
    }
    if (logConf == null) {
        JOptionPane.showMessageDialog(tree, "LoggingConfigurable is null", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    try {
        tree.getTabPanel().showTab(targetNode.getUserObject().toString());
    } catch (LogPaneNotFoundException e) {
        // The tab with this name does not exist: create and add a new one
        LogLevelSelectorPanel pnl;
        try {
            pnl = new LogLevelSelectorPanel(logConf, targetNode.getUserObject().toString(), logger);
        //} catch (LogLvlSelNotSupportedException ex) {
        } catch (Exception t) {
            JOptionPane.showMessageDialog(tree, //"<HTML>"+targetNode.getUserObject().toString()+" does not support selection of log levels:<BR>"+ex.getMessage(),
            "<HTML>" + targetNode.getUserObject().toString() + " Error selecting log level panel:<BR>" + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        try {
            tree.getTabPanel().addLogSelectorTab(pnl);
        } catch (Throwable t) {
            JOptionPane.showMessageDialog(tree, "<HTML>Error creating the panel for " + targetNode.getUserObject().toString() + ":<BR>" + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
    }
    // yatagai : Although the mousePressed action for a LoggingConfigurable 
    // folder node, expanding or collapsing, which is set by the JTree UI is not desirable,
    // I could not find a good way to disable it. 
    //
    // Reaching here, a LoggingConfigTab is displayed.
    // If this is a folder node, the following code cancels expanding or collapsing
    // action.
    TreeNode node = (TreeNode) path.getLastPathComponent();
    if (node.isLeaf())
        return;
    else {
        if (tree.isExpanded(path))
            tree.collapsePath(path);
        else
            tree.expandPath(path);
    }
}
Also used : LoggingConfigurableOperations(alma.Logging.LoggingConfigurableOperations) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) LogPaneNotFoundException(alma.acs.gui.loglevel.LogPaneNotFoundException) TreeNode(javax.swing.tree.TreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeContainerInfo(alma.acs.gui.loglevel.tree.node.TreeContainerInfo) ContainerInfo(si.ijs.maci.ContainerInfo) TreeContainerInfo(alma.acs.gui.loglevel.tree.node.TreeContainerInfo) LogLevelSelectorPanel(alma.acs.gui.loglevel.leveldlg.LogLevelSelectorPanel) LogPaneNotFoundException(alma.acs.gui.loglevel.LogPaneNotFoundException)

Example 7 with ContainerInfo

use of si.ijs.maci.ContainerInfo in project ACS by ACS-Community.

the class DeploymentTree method showContextMenu.

/**
	 * @param evt
	 */
protected void showContextMenu(MouseEvent evt) {
    TreePath targetPath = this.getClosestPathForLocation(evt.getX(), evt.getY());
    if (targetPath == null) {
        // clicked into a totally empty tree (no manager shown): ignore click.
        return;
    }
    setSelectionPath(targetPath);
    if (targetPath.getPathCount() == 1) {
        // that has no function besides looking good
        return;
    }
    // the supervisor (which is in the rootnode) for this subtree
    selectedSupervisor = maciSupervisor(((SortingTreeNode) targetPath.getPathComponent(1)));
    // the node the mouse was clicked on
    target = (SortingTreeNode) targetPath.getLastPathComponent();
    Object userObject = target.getUserObject();
    ContextMenu menu;
    if (userObject instanceof IMaciSupervisor) {
        menu = managerContextMenu;
    } else if (userObject instanceof ContainerInfo) {
        menu = containerContextMenu;
    } else if (userObject instanceof ClientInfo) {
        menu = clientContextMenu;
    } else if (userObject instanceof ComponentInfo) {
        menu = componentContextMenu;
    } else if (userObject instanceof FolderInfo) {
        menu = folderContextMenu;
    } else if (userObject instanceof InfoDetail) {
        // msc 2012-06: help user navigate in large datasets (cf. COMP-3684)
        // this menu is built dynamically from rather expensive information.
        menu = new ContextMenu(false);
        int[] selectedHandles = ((SortingTreeNode) target).representedHandles;
        if (selectedHandles.length > 0) {
            menu.add(new JLabel(" Scroll to ..."));
            menu.add(new JSeparator(JSeparator.HORIZONTAL));
            SortingTreeNode mgrNode = (SortingTreeNode) target.getPath()[1];
            List<Object> list = new ArrayList<Object>();
            list.add(mgrNode);
            for (SortingTreeNode top : mgrNode.childrens()) list.addAll(Collections.list(top.children()));
            for (Object obj : list) {
                final SortingTreeNode elem = (SortingTreeNode) obj;
                for (int i = 0; i < selectedHandles.length; i++) {
                    if (elem.represents(selectedHandles[i])) {
                        Object elemUserObject = elem.getUserObject();
                        String elemName = null;
                        if (elemUserObject instanceof ComponentInfo)
                            elemName = ((ComponentInfo) elemUserObject).name;
                        else if (elemUserObject instanceof ContainerInfo)
                            elemName = ((ContainerInfo) elemUserObject).name;
                        else if (elemUserObject instanceof ClientInfo)
                            elemName = ((ClientInfo) elemUserObject).name;
                        else if (elemUserObject instanceof MaciSupervisor)
                            elemName = "Manager";
                        if (elemName != null) {
                            menu.add(new AbstractAction(selectedHandles[i] + " = " + elemName) {

                                @Override
                                public void actionPerformed(ActionEvent evt) {
                                    DeploymentTree.this.scrollPathToVisible(new TreePath(elem.getPath()));
                                }
                            });
                        }
                    }
                }
            }
        }
    } else {
        return;
    }
    menu.show(this, evt.getX(), evt.getY());
}
Also used : GuiMaciSupervisor(alma.acs.commandcenter.meta.GuiMaciSupervisor) MaciSupervisor(alma.acs.commandcenter.meta.MaciSupervisor) IMaciSupervisor(alma.acs.commandcenter.meta.IMaciSupervisor) SortingTreeNode(alma.acs.commandcenter.meta.MaciInfo.SortingTreeNode) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) InfoDetail(alma.acs.commandcenter.meta.MaciInfo.InfoDetail) FolderInfo(alma.acs.commandcenter.meta.MaciInfo.FolderInfo) JSeparator(javax.swing.JSeparator) TreePath(javax.swing.tree.TreePath) ContainerInfo(si.ijs.maci.ContainerInfo) List(java.util.List) ArrayList(java.util.ArrayList) ClientInfo(si.ijs.maci.ClientInfo) ComponentInfo(si.ijs.maci.ComponentInfo) AbstractAction(javax.swing.AbstractAction) IMaciSupervisor(alma.acs.commandcenter.meta.IMaciSupervisor)

Example 8 with ContainerInfo

use of si.ijs.maci.ContainerInfo in project ACS by ACS-Community.

the class MaciInfo method addInfoNodes.

protected void addInfoNodes(SortingTreeNode node, Map<Object, String> auxiliary) {
    Object info = node.getUserObject();
    int infokey = System.identityHashCode(info);
    if (info instanceof ContainerInfo) {
        //ContainerInfo casted = (ContainerInfo)info;
        node.add(createNode(new InfoDetail("location", auxiliary.get(infokey + ".location"))));
    } else if (info instanceof ClientInfo) {
        ClientInfo casted = (ClientInfo) info;
        node.add(createNode(new InfoDetail("location", auxiliary.get(infokey + ".location"))));
        node.add(createNode(new InfoDetail("components", casted.components, true)));
        node.add(createNode(new InfoDetail("access", casted.access, false)));
        node.add(createNode(new InfoDetail("reference", casted.reference)));
    } else if (info instanceof ComponentInfo) {
        ComponentInfo casted = (ComponentInfo) info;
        node.add(createNode(new InfoDetail("clients", casted.clients, true)));
        node.add(createNode(new InfoDetail("container", casted.container, true)));
        node.add(createNode(new InfoDetail("container_name", casted.container_name)));
        node.add(createNode(new InfoDetail("access", casted.access, false)));
        node.add(createNode(new InfoDetail("reference", casted.reference)));
        node.add(createNode(new InfoDetail("interfaces", casted.interfaces)));
        node.add(createNode(new InfoDetail("type", casted.type)));
        node.add(createNode(new InfoDetail("code", casted.code)));
    }
}
Also used : ContainerInfo(si.ijs.maci.ContainerInfo) ClientInfo(si.ijs.maci.ClientInfo) ComponentInfo(si.ijs.maci.ComponentInfo)

Example 9 with ContainerInfo

use of si.ijs.maci.ContainerInfo in project ACS by ACS-Community.

the class MaciInfo method setContents.

/**
    * Sets the components, containers, and clients.
    * The given lists must not be changed anymore (otherwise 
    * this method would have to make a copy of them).
    */
protected void setContents(List<ComponentInfo> newComponents, List<ContainerInfo> newContainers, List<ClientInfo> newClientApps, Map<Object, String> auxiliary) {
    // bend references, each assignment is atomic and triggers a flush.
    // note we shall not modify the lists anymore after this point! 
    this.components = newComponents;
    this.containers = newContainers;
    this.clientApps = newClientApps;
    // re-populate the toplevel nodes
    // ---------------------------------------------
    componentNode.removeAllChildren();
    for (ComponentInfo comp : newComponents) {
        SortingTreeNode n = createNode(comp);
        addInfoNodes(n, auxiliary);
        componentNode.add(n);
    }
    containerNode.removeAllChildren();
    for (ContainerInfo cont : newContainers) {
        SortingTreeNode n = createNode(cont);
        addInfoNodes(n, auxiliary);
        // attach components that are active in this container
        for (ComponentInfo comp : newComponents) {
            if (comp.container == cont.h && comp.h != 0)
                n.add(createNode(comp));
        }
        containerNode.add(n);
    }
    clientNode.removeAllChildren();
    for (ClientInfo client : newClientApps) {
        SortingTreeNode n = createNode(client);
        addInfoNodes(n, auxiliary);
        clientNode.add(n);
    }
    // we sort - for some great user experience
    componentNode.sortChildrenByName();
    containerNode.sortChildrenByName();
    clientNode.sortChildrenByName();
    // send out change event
    nodeStructureChanged(managerNode);
}
Also used : ContainerInfo(si.ijs.maci.ContainerInfo) ComponentInfo(si.ijs.maci.ComponentInfo) ClientInfo(si.ijs.maci.ClientInfo)

Example 10 with ContainerInfo

use of si.ijs.maci.ContainerInfo in project ACS by ACS-Community.

the class DumpManagerState method test.

/**
	 * Main test routine.
	 */
public void test() {
    initializeCORBA();
    Manager manager = resolveManager();
    if (manager != null) {
        ClientInfo clientInfo = login(manager);
        if (clientInfo != null) {
            System.out.println("All initialization done.");
            try {
                ComponentInfo[] componentInfo = manager.get_component_info(clientInfo.h, new int[0], "*", "*", true);
                if (componentInfo == null)
                    throw new Exception("null client info returned.");
                System.out.println(componentInfo.length + " component(s) returned:");
                for (int i = 0; i < componentInfo.length; i++) {
                    System.out.println("\tName            : " + componentInfo[i].name);
                    System.out.println("\tHandle          : " + componentInfo[i].h + ", " + HandleHelper.toString(componentInfo[i].h));
                    System.out.println("\tType            : " + componentInfo[i].type);
                    System.out.println("\tCode            : " + componentInfo[i].code);
                    System.out.println("\tContainer name  : " + componentInfo[i].container_name);
                    System.out.println("\tContainer handle: " + HandleHelper.toString(componentInfo[i].container));
                    System.out.println("\tClients         : count = " + componentInfo[i].clients.length);
                    for (int j = 0; j < componentInfo[i].clients.length; j++) System.out.println("\t             \t" + componentInfo[i].clients[j]);
                    System.out.println("\t-------------------------------");
                }
            } catch (Throwable th) {
                th.printStackTrace();
            }
            System.out.println();
            System.out.println();
            System.out.println();
            try {
                ContainerInfo[] containersInfo = manager.get_container_info(clientInfo.h, new int[0], "*");
                if (containersInfo == null)
                    throw new Exception("null container info returned.");
                System.out.println(containersInfo.length + " container(s) returned:");
                for (int i = 0; i < containersInfo.length; i++) {
                    System.out.println("\tName            : " + containersInfo[i].name);
                    System.out.println("\tHandle          : " + containersInfo[i].h + ", " + HandleHelper.toString(containersInfo[i].h));
                    System.out.println("\tComponents      : count = " + containersInfo[i].components.length);
                    for (int j = 0; j < containersInfo[i].components.length; j++) System.out.println("\t             \t" + containersInfo[i].components[j]);
                    System.out.println("\t-------------------------------");
                }
            } catch (Throwable th) {
                th.printStackTrace();
            }
            System.out.println();
            System.out.println();
            System.out.println();
            try {
                ClientInfo[] clientsInfo = manager.get_client_info(clientInfo.h, new int[0], "*");
                if (clientsInfo == null)
                    throw new Exception("null component info returned.");
                System.out.println(clientsInfo.length + " clients(s) returned:");
                for (int i = 0; i < clientsInfo.length; i++) {
                    System.out.println("\tName            : " + clientsInfo[i].name);
                    System.out.println("\tHandle          : " + clientsInfo[i].h + ", " + HandleHelper.toString(clientsInfo[i].h));
                    System.out.println("\tComponents      : count = " + clientsInfo[i].components.length);
                    for (int j = 0; j < clientsInfo[i].components.length; j++) System.out.println("\t             \t" + clientsInfo[i].components[j]);
                    System.out.println("\t-------------------------------");
                }
            } catch (Throwable th) {
                th.printStackTrace();
            }
            logout(manager, clientInfo);
        }
    }
    finalizeCORBA();
}
Also used : ContainerInfo(si.ijs.maci.ContainerInfo) ClientInfo(si.ijs.maci.ClientInfo) ComponentInfo(si.ijs.maci.ComponentInfo) POAManager(org.omg.PortableServer.POAManager) Manager(si.ijs.maci.Manager)

Aggregations

ContainerInfo (si.ijs.maci.ContainerInfo)11 ClientInfo (si.ijs.maci.ClientInfo)8 ComponentInfo (si.ijs.maci.ComponentInfo)8 Manager (si.ijs.maci.Manager)3 LoggingConfigurableOperations (alma.Logging.LoggingConfigurableOperations)1 GuiMaciSupervisor (alma.acs.commandcenter.meta.GuiMaciSupervisor)1 IMaciSupervisor (alma.acs.commandcenter.meta.IMaciSupervisor)1 FolderInfo (alma.acs.commandcenter.meta.MaciInfo.FolderInfo)1 InfoDetail (alma.acs.commandcenter.meta.MaciInfo.InfoDetail)1 SortingTreeNode (alma.acs.commandcenter.meta.MaciInfo.SortingTreeNode)1 MaciSupervisor (alma.acs.commandcenter.meta.MaciSupervisor)1 LogPaneNotFoundException (alma.acs.gui.loglevel.LogPaneNotFoundException)1 LogLevelSelectorPanel (alma.acs.gui.loglevel.leveldlg.LogLevelSelectorPanel)1 TreeContainerInfo (alma.acs.gui.loglevel.tree.node.TreeContainerInfo)1 ClientLogManager (alma.acs.logging.ClientLogManager)1 NoPermissionEx (alma.maciErrType.NoPermissionEx)1 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)1 BadParametersException (com.cosylab.acs.maci.BadParametersException)1 CoreException (com.cosylab.acs.maci.CoreException)1 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)1