Search in sources :

Example 1 with SortingTreeNode

use of alma.acs.commandcenter.meta.MaciInfo.SortingTreeNode 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 SortingTreeNode

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

the class DeploymentTree method addManager.

public void addManager(GuiMaciSupervisor mrfotogen) throws NoPermissionEx, CorbaTransientException, CorbaNotExistException, UnknownErrorException {
    // retrieve the tree-structured info that the manager offers as a TreeModel
    MaciInfo maciInfo = null;
    try {
        maciInfo = mrfotogen.getMaciInfo();
    } catch (NotConnectedToManagerException exc) {
        // really shouldn't happen (the passed in supervisor is started)
        throw new AssertionError("This supervisor has obviously not been started: " + mrfotogen);
    }
    // no exception occurred, we have valid info
    // the root of maciInfo is just a node with the boring string "Manager"...
    final SortingTreeNode managerNode = ((SortingTreeNode) maciInfo.getRoot()).clone();
    // ...but the root of guiInfo will be a node holding the MaciSupervisor
    managerNode.setUserObject(mrfotogen);
    DefaultTreeModel guiInfo = new DefaultTreeModel(managerNode);
    ModelConverter mc = new ModelConverter(maciInfo, guiInfo);
    modelConverters.add(mc);
    maciInfo.addTreeModelListener(mc);
    // have events forwarded from the TreeModel to our own all-in-one TreeModel
    treeEventForwarder.addSource(guiInfo);
    // store the additional manager node in our tree
    getTreeModel().insertNodeInto(managerNode, getRoot(), getRoot().getChildCount());
    // populate guitree, will make the tree display
    mc.convertCompleteModel();
    // must expand the new manager node otherwise the subtree won't be visible
    runSwingNow(new Runnable() {

        public void run() {
            expandPath(new TreePath(new Object[] { getRoot(), managerNode }));
            // for user joy also expand the manager's subnodes
            expandPath(new TreePath(new Object[] { getRoot(), managerNode, managerNode.getChildAt(0) }));
            expandPath(new TreePath(new Object[] { getRoot(), managerNode, managerNode.getChildAt(1) }));
            expandPath(new TreePath(new Object[] { getRoot(), managerNode, managerNode.getChildAt(2) }));
        }
    });
}
Also used : TreePath(javax.swing.tree.TreePath) SortingTreeNode(alma.acs.commandcenter.meta.MaciInfo.SortingTreeNode) NotConnectedToManagerException(alma.acs.commandcenter.meta.IMaciSupervisor.NotConnectedToManagerException) MaciInfo(alma.acs.commandcenter.meta.MaciInfo) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 3 with SortingTreeNode

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

the class DeploymentTree method applyFilter.

void applyFilter(SortingTreeNode folder) {
    FolderInfo folderInfo = (FolderInfo) folder.getUserObject();
    for (SortingTreeNode entry : folder.childrens()) {
        String caption = cellRenderer.getCaptions(entry)[0];
        boolean passes = !folderInfo.hasFilter() || caption.contains(folderInfo.filter);
        for (Enumeration<?> subtree = entry.breadthFirstEnumeration(); subtree.hasMoreElements(); ) ((SortingTreeNode) (subtree.nextElement())).filtered = !passes;
    }
}
Also used : SortingTreeNode(alma.acs.commandcenter.meta.MaciInfo.SortingTreeNode) FolderInfo(alma.acs.commandcenter.meta.MaciInfo.FolderInfo)

Aggregations

SortingTreeNode (alma.acs.commandcenter.meta.MaciInfo.SortingTreeNode)3 FolderInfo (alma.acs.commandcenter.meta.MaciInfo.FolderInfo)2 TreePath (javax.swing.tree.TreePath)2 GuiMaciSupervisor (alma.acs.commandcenter.meta.GuiMaciSupervisor)1 IMaciSupervisor (alma.acs.commandcenter.meta.IMaciSupervisor)1 NotConnectedToManagerException (alma.acs.commandcenter.meta.IMaciSupervisor.NotConnectedToManagerException)1 MaciInfo (alma.acs.commandcenter.meta.MaciInfo)1 InfoDetail (alma.acs.commandcenter.meta.MaciInfo.InfoDetail)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 JSeparator (javax.swing.JSeparator)1 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)1 ClientInfo (si.ijs.maci.ClientInfo)1 ComponentInfo (si.ijs.maci.ComponentInfo)1 ContainerInfo (si.ijs.maci.ContainerInfo)1