Module () { final Object selectedObject = getSelectedObject(); if (selectedObject instanceof Module) { return (Module)selectedObject; } if (selectedObject instanceof Library) { if (((Library)selectedObject).getTable() == null) { final MyNode node = (MyNode)myTree.getSelectionPath().getLastPathComponent(); return (Module)((MyNode)node.getParent()).getConfigurable().getEditableObject(); } } return null; }