当选择未更改但用户再次单击它时,Java SWT TreeViewer获取选择事件

时间:2016-03-29 09:17:11

标签: java onclick swt selection treeviewer

我有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。如果用户再次选择相同的节点,我现在如何检测?

0 个答案:

没有答案