@Override public void valueChanged(TreeSelectionEvent event) { TreePath path = event.getPath(); AbstractDefineComponent selectedComponent = (AbstractDefineComponent) path.getLastPathComponent(); if (selectedComponent.getModuleId() != DefinitionController.getInstance().getSelectedModuleId()) { this.updateSelectedModule(selectedComponent.getModuleId()); } this.checkLayerComponentIsSelected(); }
private long getSelectedModuleId() { long moduleId = -1; TreePath path = this.moduleTree.getSelectionPath(); if (path != null) { // returns null if nothing is selected AbstractDefineComponent selectedComponent = (AbstractDefineComponent) path.getLastPathComponent(); moduleId = selectedComponent.getModuleId(); } return moduleId; }