|
Re: Update of JFace TreeViewer fails [message #329969 is a reply to message #329963] |
Fri, 11 July 2008 14:18 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Hi,
The code looks correct. Do you see any exception? If there's an uncaught
exception thrown it should be part of the .metadata/.log or if you
started with -consoleLog in the Eclipse console.
Tom
Mathias schrieb:
> Hi,
>
> I have a problem using a JFace TreeViewer in my application. (I am using
> Eclipse 3.4 and Instantiation's SWTBuilder). The application shall show
> device groups and devices in a tree - just like a file system.
>
> root (empty element. not shown)
> |
> container
> |
> -- group1
> |
> -- group2
> |
> -- devive1
> |
> -- device2
>
> When adding new elements to my tree (or removing) the domain object gets
> manipulated correctly but the tree shown in the UI remains the same.
> Here you can see the code for adding an element and changing their content:
>
> /* removing is similar. both fail!!! */
>
> final Button _btnAddGroup = new Button(_grpDevEditor, SWT.NONE);
> _btnAddGroup.addSelectionListener(new SelectionAdapter() {
> public void widgetSelected(final SelectionEvent e) {
> IStructuredSelection sel =
> (IStructuredSelection)_trvDevices.getSelection();
> if (sel != null) {
> ResourceModel model = (ResourceModel)sel.getFirstElement();
> if (model instanceof DeviceGroupModel) {
> DeviceGroupModel parent =
> (DeviceGroupModel)sel.getFirstElement();
> if (parent.getParent() == root) {
> new DeviceGroupModel(container, _txtName.getText(),
> _txtImage.getText());
> }
> else {
> new DeviceGroupModel(parent, _txtName.getText(),
> _txtImage.getText());
> }
> _trvDevices.refresh();
> }
> }
> }
> });
>
> /* changing contents works fine!!! */
>
> final Button _btnSave = new Button(_grpDevEditor, SWT.NONE);
> _btnSave.addSelectionListener(new SelectionAdapter() {
> public void widgetSelected(final SelectionEvent e) {
> IStructuredSelection sel =
> (IStructuredSelection)_trvDevices.getSelection();
> if (sel != null) {
> ResourceModel model = (ResourceModel)sel.getFirstElement();
> if (model instanceof DeviceModel) {
> DeviceModel mod = (DeviceModel)sel.getFirstElement();
> mod.setName(_txtName.getText());
> mod.setTypeDescription(_txtDescription.getText());
> mod.setTypeReference(_txtReference.getText());
> mod.setTypeImage(_txtImage.getText());
> _trvDevices.refresh();
> }
> else {
> if (model instanceof DeviceGroupModel) {
> DeviceGroupModel mod = (DeviceGroupModel)sel.getFirstElement();
> mod.setName(_txtName.getText());
> mod.setTypeImage(_txtImage.getText());
> _trvDevices.refresh();
> }
> }
> }
> }
> });
>
> Has anybody an idea what I am doing wrong? Is there an event or listener
> missing?
>
> Since I am a beginner I did most of the data bindings with the tool. It
> also generated the content and label provider classes. As you can
> imagine I am a bit lost now.
>
> Thanks for helping! Best regards,
> Mathias
>
--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03083 seconds