public TreeSelection getSelection() { TreeSelection selection = new TreeSelection(); TreePath path = myTree.getSelectionPath(); if (path == null) return selection; Object[] paths = path.getPath(); for (Object o : paths) { if (o instanceof MessageNode) { MessageNode messageNode = (MessageNode) o; AntBuildMessageView.MessageType type = messageNode.getType(); if (type == AntBuildMessageView.MessageType.TARGET) { selection.mySelectedTarget = messageNode.getText()[0]; } else if (type == AntBuildMessageView.MessageType.TASK) { selection.mySelectedTask = messageNode.getText()[0]; } } } return selection; }