Search in sources :

Example 1 with IMaciSupervisor

use of alma.acs.commandcenter.meta.IMaciSupervisor 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 2 with IMaciSupervisor

use of alma.acs.commandcenter.meta.IMaciSupervisor in project ACS by ACS-Community.

the class DeploymentTree method isMyself.

/**
	 * Little helper for the renderer. Just because it seems nice for the user. The
	 * specified node must contain a ClientInfo user object.
	 */
protected boolean isMyself(DefaultMutableTreeNode node) {
    try {
        // find manager node
        DefaultMutableTreeNode n = node;
        do {
            n = (DefaultMutableTreeNode) n.getParent();
        } while (!(n.getUserObject() instanceof IMaciSupervisor));
        // compare handles
        ClientInfo info = (ClientInfo) node.getUserObject();
        return (maciSupervisor(n).myMaciHandle() == info.h);
    } catch (Exception e) {
        // instead of making the above code rock-stable, let's do it cheap
        return false;
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ClientInfo(si.ijs.maci.ClientInfo) CannotRetrieveManagerException(alma.acs.commandcenter.meta.IMaciSupervisor.CannotRetrieveManagerException) CorbaNoPermissionException(alma.acs.commandcenter.meta.IMaciSupervisor.CorbaNoPermissionException) CorbaNotExistException(alma.acs.commandcenter.meta.IMaciSupervisor.CorbaNotExistException) OrbInitException(alma.acs.commandcenter.meta.Firestarter.OrbInitException) CorbaUnknownException(alma.acs.commandcenter.meta.IMaciSupervisor.CorbaUnknownException) NotConnectedToManagerException(alma.acs.commandcenter.meta.IMaciSupervisor.NotConnectedToManagerException) CorbaTransientException(alma.acs.commandcenter.meta.IMaciSupervisor.CorbaTransientException) UnknownErrorException(alma.acs.commandcenter.meta.IMaciSupervisor.UnknownErrorException) IMaciSupervisor(alma.acs.commandcenter.meta.IMaciSupervisor)

Aggregations

IMaciSupervisor (alma.acs.commandcenter.meta.IMaciSupervisor)2 ClientInfo (si.ijs.maci.ClientInfo)2 OrbInitException (alma.acs.commandcenter.meta.Firestarter.OrbInitException)1 GuiMaciSupervisor (alma.acs.commandcenter.meta.GuiMaciSupervisor)1 CannotRetrieveManagerException (alma.acs.commandcenter.meta.IMaciSupervisor.CannotRetrieveManagerException)1 CorbaNoPermissionException (alma.acs.commandcenter.meta.IMaciSupervisor.CorbaNoPermissionException)1 CorbaNotExistException (alma.acs.commandcenter.meta.IMaciSupervisor.CorbaNotExistException)1 CorbaTransientException (alma.acs.commandcenter.meta.IMaciSupervisor.CorbaTransientException)1 CorbaUnknownException (alma.acs.commandcenter.meta.IMaciSupervisor.CorbaUnknownException)1 NotConnectedToManagerException (alma.acs.commandcenter.meta.IMaciSupervisor.NotConnectedToManagerException)1 UnknownErrorException (alma.acs.commandcenter.meta.IMaciSupervisor.UnknownErrorException)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 ActionEvent (java.awt.event.ActionEvent)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AbstractAction (javax.swing.AbstractAction)1 JLabel (javax.swing.JLabel)1