Search in sources :

Example 1 with NotConnectedToManagerException

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

Aggregations

NotConnectedToManagerException (alma.acs.commandcenter.meta.IMaciSupervisor.NotConnectedToManagerException)1 MaciInfo (alma.acs.commandcenter.meta.MaciInfo)1 SortingTreeNode (alma.acs.commandcenter.meta.MaciInfo.SortingTreeNode)1 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)1 TreePath (javax.swing.tree.TreePath)1