我有TreeViewer
我自己的Objects
,我添加了ISelectionChangedListener
,但现在我想知道用户是否再次在树中选择了相同的Object
。
这是我的ISelectionChangedListener
:
viewer.addSelectionChangedListener(new ISelectionChangedListener()
{
@Override
public void selectionChanged(SelectionChangedEvent event)
{
if(event.getSelection() instanceof IStructuredSelection)
{
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
UATreeNode treeNode = (UATreeNode) selection.getFirstElement();
NodeId currentUANodeId = treeNode.getNodeId();
if(!(treeNode.getAlreadyBrowsed() == true && treeNode.getNodeClass().equals(NodeClass.Object)))
{
treeNode.setAlreadyBrowsed(true);
treeNode.removeAll();
CompletableFuture.runAsync(() -> {
browseNodes(currentUANodeId, treeNode);
});
}
else if(treeNode.getNodeClass().equals(NodeClass.Variable))
{
CompletableFuture.runAsync(() -> {
getAndDisplayAttributesAndPropertiesFromNodeId(currentUANodeId, treeNode, true);
});
}
}
}
UaTreeNode
是我的Object
工作的ViewContentProvider
。如果用户再次选择相同的节点,我现在如何检测?