MCTLogger.getLogger(NewObjectAction.class).warn(
"new object not selected in directory as only MCTDirectoryArea instances are supported " + directoryAreaView.getClass().getName());
}
if (newComponentId != null && directoryAreaView instanceof MCTDirectoryArea) {
MCTDirectoryArea directoryArea = MCTDirectoryArea.class.cast(directoryAreaView);
JTree activeTree = directoryArea.getActiveTree();
// Identify the currently selected node in the directory area.
MCTMutableTreeNode initiallySelectedNode = directoryArea.getSelectedNode();
if (initiallySelectedNode == null) {
// set the root of the tree as the initially selected node.
initiallySelectedNode = (MCTMutableTreeNode) activeTree.getModel().getRoot();
}
assert initiallySelectedNode!=null : "Selected node must not be null by this point";
// Check to see if children have been loaded. If not fire are tree expansion event to force them to be loaded.
if (initiallySelectedNode.isProxy()) {
// Force children to be loaded.
DefaultTreeModel treeModel = (DefaultTreeModel) activeTree.getModel();
TreePath path = new TreePath(treeModel.getPathToRoot(initiallySelectedNode));
if (path!=null) {
View initiallySelectedManifestation = directoryArea.getSelectedManifestations().iterator().next();
initiallySelectedManifestation.getViewListener().actionPerformed(new TreeExpansionEvent(activeTree, path));
}
}
// Find the child that corresponds to our new component.
for(int i=0; i< initiallySelectedNode.getChildCount(); i++) {
MCTMutableTreeNode childNode = (MCTMutableTreeNode) initiallySelectedNode.getChildAt(i);
if(childNode.getUserObject() instanceof View) {
View man = (View) childNode.getUserObject();
if (man.getManifestedComponent().getId().equalsIgnoreCase(newComponentId)) {
// Found the child that corresponds to our new component. Set it as selected.
directoryArea.setSelectedNode(childNode);
PropertyChangeEvent pce = new PropertyChangeEvent(man.getManifestedComponent());
pce.setProperty(PropertyChangeEvent.DISPLAY_NAME, PropertyChangeEvent.DISPLAY_NAME);
man.updateMonitoredGUI(pce);
break;
}