TreeViewer节点刷新求救!

TreeViewer节点刷新求救!
 1   /**/ /* 
 2     * 开始为产品树添加信息,存入数据库,然后刷新树
 3     * (non-Javadoc)
 4     * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
 5     */

 6      protected   void  buttonPressed( int  buttonId)  {
 7        if (buttonId == IDialogConstants.OK_ID) {
 8            addProductFolder();
 9        }

10        super.buttonPressed(buttonId);
11    }

12
13     
14     
15     
16      private   void  addProductFolder()  {
17        ProductFolder receivingProductFolder;
18        IStructuredSelection selection = (IStructuredSelection) productFolderTreeViewer.getSelection();
19        if ((selection.getFirstElement() instanceof ProductFolder)) {
20            receivingProductFolder = (ProductFolder) selection.getFirstElement();
21            ProductFolder productFolder = new ProductFolder();
22            productFolder.setProductFolderName(text.getText());
23            productFolder.setMemo(text_2.getText());
24            productFolder.setPatertProductFolder(receivingProductFolder);
25            saveNewProductFolder(productFolder);
26            receivingProductFolder.getLazyProductFolders().add(productFolder);
27            productFolderTreeViewer.refresh(receivingProductFolder);
28        }

29    }

30


代码中使用productFolderTreeViewer.refresh(receivingProductFolder);来让新增节点的上级父节点更新其下内容,但是,问题是当父节点下没有任何子节点的时候,可以增加新节点,但是如果父节点下已经存在了一个或者多个子节点,则无法更新父节点信息,屏幕如下:
TreeViewer节点刷新求救!_第1张图片

请大虾们帮忙!


客户虐我千百遍,我待客户如初恋!

你可能感兴趣的:(TreeViewer节点刷新求救!)