Read-only data viewer [message #388545] |
Tue, 12 October 2004 16:13  |
Eclipse User |
|
|
|
Hello,
The EMF tool creates a very nice default editor for the model that it
generates. I've dropped the generated tree view into one of my own
editors. The problem is that I cannot find an easy way to make the view
read-only.
So far, I've managed to get rid of the add child and add sibiling actions
by tweaking the action bar contributor. However, the outline and
properties views still need work to prevent modification.
I wanted to ask if there was an easier way to accomplish a read-only view
than the approach I am taking.
thank you,
Amin
|
|
|
|
Re: Read-only data viewer [message #388570 is a reply to message #388557] |
Wed, 13 October 2004 12:05  |
Eclipse User |
|
|
|
Hello Ed,
thanks for the tip on creation commands, which worked as you indicated.
However, setting my resource to read-only surprisingly didn't have the
desired effect. The code is as below:
// Load the resource through the editing domain.
//
Resource resource =
editingDomain.loadResource
(URI.createPlatformResourceURI(modelFile.getFile().getFullPa th().toString()).toString());
editingDomain.getResourceToReadOnlyMap().put(resource, Boolean.TRUE);
The resource loading line is auto generated. I added the line to make the
resource read-only. Later in my code, when I open the editor, I double
checked that the resource was read-only, and, indeed, the editing domain
indicated that it was. However, the properties view still allowed editing
to go forward, and all the drag and drop operations were still enabled for
the tree.
However, following you second piece of advice worked. Actually for
convenience sake, I extended to AdapterFactoryEditingDomain and
implemented the createCommand method to call super and then decorate the
result with a canExecute method that always returns false. This was easier
than introducing a new base class for my item providers, although it also
prevents the operation of read-only commands like copy.
thanks again for your help,
amin
Ed Merks wrote:
> Amin,
> The child creation stuff can also be disabled by turning off
> "Edit->Creation Commands" in the GenModel's Properties view. The
> editing domain in EMF 2.0.l also supports read-only files, so if
> EditingDomain.isReadOnly returns true for the resource containing the
> objects you don't want edited, that should do the trick. You could
> force this with
> AdapterFactoryEditingDomain.getResourceToReadOnlyMap().put(y ourResource,
> Boolean.TRUE). You could also override createCommand in the editing
> domain to return unexecutable command when appropriate.
> Amin Ahmad wrote:
> >Hello,
> >
> >The EMF tool creates a very nice default editor for the model that it
> >generates. I've dropped the generated tree view into one of my own
> >editors. The problem is that I cannot find an easy way to make the view
> >read-only.
> >
> >So far, I've managed to get rid of the add child and add sibiling actions
> >by tweaking the action bar contributor. However, the outline and
> >properties views still need work to prevent modification.
> >
> >I wanted to ask if there was an easier way to accomplish a read-only view
> >than the approach I am taking.
> >
> >thank you,
> >Amin
> >
> >
> >
|
|
|
Powered by
FUDForum. Page generated in 0.07107 seconds