Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Read-only Property Sheet Page
Read-only Property Sheet Page [message #420481] Tue, 01 July 2008 13:44 Go to next message
Artun Subasi is currently offline Artun SubasiFriend
Messages: 20
Registered: July 2009
Junior Member
Hello,

I am using RCP, EMF and GMF in my application. I have a navigator view
which uses the AdapterFactoryContentProvider as content provider. I
added property sheet support to the view by inspecting how it was done
in the generated EMF editor.

The property sheet page is working properly. However, the cells are
editable and this is bad for the navigator view. Because the navigator
view is not an editor and there is no possibility save the changes.

I want to make the property sheet page read-only, which is displayed
when an element is selected in the navigator view. I can't make the
properties globally read-only using the genmodel, because the property
sheets of GMF editors should not be affected. Any solution or idea is
welcome.

Regards,
Artun
Re: Read-only Property Sheet Page [message #420490 is a reply to message #420481] Tue, 01 July 2008 14:36 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Artun,

Comments below.

Artun Subasi wrote:
> Hello,
>
> I am using RCP, EMF and GMF in my application. I have a navigator view
> which uses the AdapterFactoryContentProvider as content provider. I
> added property sheet support to the view by inspecting how it was done
> in the generated EMF editor.
>
> The property sheet page is working properly. However, the cells are
> editable and this is bad for the navigator view. Because the navigator
> view is not an editor and there is no possibility save the changes.
The editing domain as a whole could mark the resource as read only and
then no commands to change the contents will be executable. You could
use AdapterFactoryEditingDomain.getResourceToReadOnlyMap to make the
resource readonly.
>
> I want to make the property sheet page read-only, which is displayed
> when an element is selected in the navigator view. I can't make the
> properties globally read-only using the genmodel, because the property
> sheets of GMF editors should not be affected. Any solution or idea is
> welcome.
>
> Regards,
> Artun


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Read-only Property Sheet Page [message #420495 is a reply to message #420490] Tue, 01 July 2008 15:00 Go to previous messageGo to next message
Artun Subasi is currently offline Artun SubasiFriend
Messages: 20
Registered: July 2009
Junior Member
I already tried that. Somehow, it didn't work for me.

I added a selection listener to the navigators viewer. When the
selection changes, I get the Resources of the selected EObjects and add
them to the map you mentioned like this:

myAdapterFactoryEditingDomain.getResourceToReadOnlyMap.put(r esource, true);

This didn't change anything.

Ed Merks schrieb:
> Artun,
>
> Comments below.
>
> Artun Subasi wrote:
>> Hello,
>>
>> I am using RCP, EMF and GMF in my application. I have a navigator view
>> which uses the AdapterFactoryContentProvider as content provider. I
>> added property sheet support to the view by inspecting how it was done
>> in the generated EMF editor.
>>
>> The property sheet page is working properly. However, the cells are
>> editable and this is bad for the navigator view. Because the navigator
>> view is not an editor and there is no possibility save the changes.
> The editing domain as a whole could mark the resource as read only and
> then no commands to change the contents will be executable. You could
> use AdapterFactoryEditingDomain.getResourceToReadOnlyMap to make the
> resource readonly.
>>
>> I want to make the property sheet page read-only, which is displayed
>> when an element is selected in the navigator view. I can't make the
>> properties globally read-only using the genmodel, because the property
>> sheets of GMF editors should not be affected. Any solution or idea is
>> welcome.
>>
>> Regards,
>> Artun
Re: Read-only Property Sheet Page [message #420509 is a reply to message #420495] Tue, 01 July 2008 16:29 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020806020408080800050001
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Artun,

The debugger is your best friend. This method in ItemPropertyDescriptor
should be getting called:

public boolean canSetProperty(Object object)
{
if (isSettable)
{
EditingDomain editingDomain = getEditingDomain(object);
if (editingDomain != null)
{
Resource resource = object instanceof EObject ?
((EObject)object).eResource() :
object instanceof Resource ?
(Resource)object :
null;

return resource == null || !editingDomain.isReadOnly(resource);
}
else
{
return true;
}
}
else
{
return false;
}
}

You could investigate what's happening here.


Artun Subasi wrote:
> I already tried that. Somehow, it didn't work for me.
>
> I added a selection listener to the navigators viewer. When the
> selection changes, I get the Resources of the selected EObjects and
> add them to the map you mentioned like this:
>
> myAdapterFactoryEditingDomain.getResourceToReadOnlyMap.put(r esource,
> true);
>
> This didn't change anything.
>
> Ed Merks schrieb:
>> Artun,
>>
>> Comments below.
>>
>> Artun Subasi wrote:
>>> Hello,
>>>
>>> I am using RCP, EMF and GMF in my application. I have a navigator
>>> view which uses the AdapterFactoryContentProvider as content
>>> provider. I added property sheet support to the view by inspecting
>>> how it was done in the generated EMF editor.
>>>
>>> The property sheet page is working properly. However, the cells are
>>> editable and this is bad for the navigator view. Because the
>>> navigator view is not an editor and there is no possibility save the
>>> changes.
>> The editing domain as a whole could mark the resource as read only
>> and then no commands to change the contents will be executable. You
>> could use AdapterFactoryEditingDomain.getResourceToReadOnlyMap to
>> make the resource readonly.
>>>
>>> I want to make the property sheet page read-only, which is displayed
>>> when an element is selected in the navigator view. I can't make the
>>> properties globally read-only using the genmodel, because the
>>> property sheets of GMF editors should not be affected. Any solution
>>> or idea is welcome.
>>>
>>> Regards,
>>> Artun

--------------020806020408080800050001
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Artun,<br>
<br>
The debugger is your best friend.&nbsp; This method in
ItemPropertyDescriptor should be getting called:<br>
<blockquote><small>&nbsp; public boolean canSetProperty(Object object)</small><br>
<small>&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp; if (isSettable)</small><br>
<small>&nbsp;&nbsp;&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EditingDomain editingDomain = getEditingDomain(object);</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (editingDomain != null)</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; Resource resource = object instanceof EObject ?</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ((EObject)object).eResource() :</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object instanceof Resource ?</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (Resource)object :</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; null;</small><br>
<small>&nbsp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; return resource == null ||
!editingDomain.isReadOnly(resource);</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; return true;</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp;&nbsp;&nbsp; else</small><br>
<small>&nbsp;&nbsp;&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;</small><br>
<small>&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp; }</small><br>
</blockquote>
You could investigate what's happening here.<br>
<br>
<br>
Artun Subasi wrote:
<blockquote cite="mid:g4dgqi$4oj$1@build.eclipse.org" type="cite">I
already tried that. Somehow, it didn't work for me.
<br>
<br>
I added a selection listener to the navigators viewer. When the
selection changes, I get the Resources of the selected EObjects and add
them to the map you mentioned like this:
<br>
<br>
myAdapterFactoryEditingDomain.getResourceToReadOnlyMap.put(r esource,
true);
<br>
<br>
This didn't change anything.
<br>
<br>
Ed Merks schrieb:
<br>
<blockquote type="cite">Artun,
<br>
<br>
Comments below.
<br>
<br>
Artun Subasi wrote:
<br>
<blockquote type="cite">Hello,
<br>
<br>
I am using RCP, EMF and GMF in my application. I have a navigator view
which uses the AdapterFactoryContentProvider as content provider. I
added property sheet support to the view by inspecting how it was done
in the generated EMF editor.
<br>
<br>
The property sheet page is working properly. However, the cells are
editable and this is bad for the navigator view. Because the navigator
view is not an editor and there is no possibility save the changes.
<br>
</blockquote>
The editing domain as a whole could mark the resource as read only and
then no commands to change the contents will be executable.&nbsp; You could
use AdapterFactoryEditingDomain.getResourceToReadOnlyMap to make the
resource readonly.
<br>
<blockquote type="cite"><br>
I want to make the property sheet page read-only, which is displayed
when an element is selected in the navigator view. I can't make the
properties globally read-only using the genmodel, because the property
sheets of GMF editors should not be affected. Any solution or idea is
welcome.
<br>
<br>
Regards,
<br>
Artun
<br>
</blockquote>
</blockquote>
</blockquote>
</body>
</html>

--------------020806020408080800050001--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Read-only Property Sheet Page [message #420540 is a reply to message #420509] Wed, 02 July 2008 10:09 Go to previous messageGo to next message
Artun Subasi is currently offline Artun SubasiFriend
Messages: 20
Registered: July 2009
Junior Member
Ed,

I found the cause of the problem.

EditingDomain editingDomain = getEditingDomain(object)

returns an instance of TransactionalEditingDomain instead of an
AdapterFactoryEditingDomain. The navigator view uses this
TransactionalEditingDomain to manage the resources.

I had to create an additional AdapterFactoryEditingDomain in order to
create the property sheet page like this:

public IPropertySheetPage getPropertySheetPage() {
BasicCommandStack commandStack = new BasicCommandStack();
adapterFactoryEditingDomain =
new AdapterFactoryEditingDomain(adapterFactory, commandStack,
new HashMap<Resource, Boolean>());
if (propertySheetPage == null) {
propertySheetPage =
new ExtendedPropertySheetPage(adapterFactoryEditingDomain);
propertySheetPage.setPropertySourceProvider(
new AdapterFactoryContentProvider(adapterFactory));
}

return propertySheetPage;
}

I assume the problem would be solved if I used the same
AdapterFactoryEditingDomain in the navigator view instead of using a
seperate TransactionalEditingDomain. But I can't do this change easily
because the navigator uses AbstractTransactionalCommands which need a
TransactionalEditingDomain.

Ed Merks wrote:
> Artun,
>
> The debugger is your best friend. This method in ItemPropertyDescriptor
> should be getting called:
>
> public boolean canSetProperty(Object object)
> {
> if (isSettable)
> {
> EditingDomain editingDomain = getEditingDomain(object);
> if (editingDomain != null)
> {
> Resource resource = object instanceof EObject ?
> ((EObject)object).eResource() :
> object instanceof Resource ?
> (Resource)object :
> null;
>
> return resource == null || !editingDomain.isReadOnly(resource);
> }
> else
> {
> return true;
> }
> }
> else
> {
> return false;
> }
> }
>
> You could investigate what's happening here.
>
>
> Artun Subasi wrote:
>> I already tried that. Somehow, it didn't work for me.
>>
>> I added a selection listener to the navigators viewer. When the
>> selection changes, I get the Resources of the selected EObjects and
>> add them to the map you mentioned like this:
>>
>> myAdapterFactoryEditingDomain.getResourceToReadOnlyMap.put(r esource,
>> true);
>>
>> This didn't change anything.
>>
>> Ed Merks schrieb:
>>> Artun,
>>>
>>> Comments below.
>>>
>>> Artun Subasi wrote:
>>>> Hello,
>>>>
>>>> I am using RCP, EMF and GMF in my application. I have a navigator
>>>> view which uses the AdapterFactoryContentProvider as content
>>>> provider. I added property sheet support to the view by inspecting
>>>> how it was done in the generated EMF editor.
>>>>
>>>> The property sheet page is working properly. However, the cells are
>>>> editable and this is bad for the navigator view. Because the
>>>> navigator view is not an editor and there is no possibility save the
>>>> changes.
>>> The editing domain as a whole could mark the resource as read only
>>> and then no commands to change the contents will be executable. You
>>> could use AdapterFactoryEditingDomain.getResourceToReadOnlyMap to
>>> make the resource readonly.
>>>>
>>>> I want to make the property sheet page read-only, which is displayed
>>>> when an element is selected in the navigator view. I can't make the
>>>> properties globally read-only using the genmodel, because the
>>>> property sheets of GMF editors should not be affected. Any solution
>>>> or idea is welcome.
>>>>
>>>> Regards,
>>>> Artun
Re: Read-only Property Sheet Page [message #420550 is a reply to message #420540] Wed, 02 July 2008 12:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Artun,

Comments below.

Artun Subasi wrote:
> Ed,
>
> I found the cause of the problem.
>
> EditingDomain editingDomain = getEditingDomain(object)
>
> returns an instance of TransactionalEditingDomain instead of an
> AdapterFactoryEditingDomain. The navigator view uses this
> TransactionalEditingDomain to manage the resources.
That class extends AdapterFactoryEditingDomain though, so why is this
causing a problem?
>
> I had to create an additional AdapterFactoryEditingDomain in order to
> create the property sheet page like this:
>
> public IPropertySheetPage getPropertySheetPage() {
> BasicCommandStack commandStack = new BasicCommandStack();
> adapterFactoryEditingDomain =
> new AdapterFactoryEditingDomain(adapterFactory, commandStack,
> new HashMap<Resource, Boolean>());
> if (propertySheetPage == null) {
> propertySheetPage =
> new ExtendedPropertySheetPage(adapterFactoryEditingDomain);
> propertySheetPage.setPropertySourceProvider(
> new AdapterFactoryContentProvider(adapterFactory));
> }
>
> return propertySheetPage;
> }
>
> I assume the problem would be solved if I used the same
> AdapterFactoryEditingDomain in the navigator view instead of using a
> seperate TransactionalEditingDomain. But I can't do this change easily
> because the navigator uses AbstractTransactionalCommands which need a
> TransactionalEditingDomain.
I don't really get why it's a problem? Could you elaborate on the
problem? Do you want, for example, editing supported in one place and
not the other?
>
> Ed Merks wrote:
>> Artun,
>>
>> The debugger is your best friend. This method in
>> ItemPropertyDescriptor should be getting called:
>>
>> public boolean canSetProperty(Object object)
>> {
>> if (isSettable)
>> {
>> EditingDomain editingDomain = getEditingDomain(object);
>> if (editingDomain != null)
>> {
>> Resource resource = object instanceof EObject ?
>> ((EObject)object).eResource() :
>> object instanceof Resource ?
>> (Resource)object :
>> null;
>> return resource == null ||
>> !editingDomain.isReadOnly(resource);
>> }
>> else
>> {
>> return true;
>> }
>> }
>> else
>> {
>> return false;
>> }
>> }
>>
>> You could investigate what's happening here.
>>
>>
>> Artun Subasi wrote:
>>> I already tried that. Somehow, it didn't work for me.
>>>
>>> I added a selection listener to the navigators viewer. When the
>>> selection changes, I get the Resources of the selected EObjects and
>>> add them to the map you mentioned like this:
>>>
>>> myAdapterFactoryEditingDomain.getResourceToReadOnlyMap.put(r esource,
>>> true);
>>>
>>> This didn't change anything.
>>>
>>> Ed Merks schrieb:
>>>> Artun,
>>>>
>>>> Comments below.
>>>>
>>>> Artun Subasi wrote:
>>>>> Hello,
>>>>>
>>>>> I am using RCP, EMF and GMF in my application. I have a navigator
>>>>> view which uses the AdapterFactoryContentProvider as content
>>>>> provider. I added property sheet support to the view by inspecting
>>>>> how it was done in the generated EMF editor.
>>>>>
>>>>> The property sheet page is working properly. However, the cells
>>>>> are editable and this is bad for the navigator view. Because the
>>>>> navigator view is not an editor and there is no possibility save
>>>>> the changes.
>>>> The editing domain as a whole could mark the resource as read only
>>>> and then no commands to change the contents will be executable.
>>>> You could use AdapterFactoryEditingDomain.getResourceToReadOnlyMap
>>>> to make the resource readonly.
>>>>>
>>>>> I want to make the property sheet page read-only, which is
>>>>> displayed when an element is selected in the navigator view. I
>>>>> can't make the properties globally read-only using the genmodel,
>>>>> because the property sheets of GMF editors should not be affected.
>>>>> Any solution or idea is welcome.
>>>>>
>>>>> Regards,
>>>>> Artun


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Read-only Property Sheet Page [message #420594 is a reply to message #420550] Thu, 03 July 2008 06:51 Go to previous message
Artun Subasi is currently offline Artun SubasiFriend
Messages: 20
Registered: July 2009
Junior Member
Hi Ed,

Comments below.

Ed Merks wrote:
> Artun,
>
> Comments below.
>
> Artun Subasi wrote:
>> Ed,
>>
>> I found the cause of the problem.
>>
>> EditingDomain editingDomain = getEditingDomain(object)
>>
>> returns an instance of TransactionalEditingDomain instead of an
>> AdapterFactoryEditingDomain. The navigator view uses this
>> TransactionalEditingDomain to manage the resources.
> That class extends AdapterFactoryEditingDomain though, so why is this
> causing a problem?

The TransactionalEditingDomain interface extends EditingDomain. But
thanks to your comment, I found out that TransactionalEditingDomainImpl
extends AdapterFactoryEditingDomain. I used to use

GMFEditingDomainFactory.INSTANCE.createEditingDomain()

to create an instance of the TransactionalEditingDomain. This method
returns the TransactionalEditingDomain interface. Because I wasn't sure
whether it always uses TransactionalEditingDomainImpl internally, I
changed the creation of the editing domain. Now I create it with the
constructor of TransactionalEditingDomainImpl.

Because TransactionalEditingDomainImpl extends
AdapterFactoryEditingDomain, my problem is solved. Thanks.

>>
>> I had to create an additional AdapterFactoryEditingDomain in order to
>> create the property sheet page like this:
>>
>> public IPropertySheetPage getPropertySheetPage() {
>> BasicCommandStack commandStack = new BasicCommandStack();
>> adapterFactoryEditingDomain =
>> new AdapterFactoryEditingDomain(adapterFactory, commandStack,
>> new HashMap<Resource, Boolean>());
>> if (propertySheetPage == null) {
>> propertySheetPage =
>> new ExtendedPropertySheetPage(adapterFactoryEditingDomain);
>> propertySheetPage.setPropertySourceProvider(
>> new AdapterFactoryContentProvider(adapterFactory));
>> }
>>
>> return propertySheetPage;
>> }
>>
>> I assume the problem would be solved if I used the same
>> AdapterFactoryEditingDomain in the navigator view instead of using a
>> seperate TransactionalEditingDomain. But I can't do this change easily
>> because the navigator uses AbstractTransactionalCommands which need a
>> TransactionalEditingDomain.
> I don't really get why it's a problem? Could you elaborate on the
> problem? Do you want, for example, editing supported in one place and
> not the other?
>>
>> Ed Merks wrote:
>>> Artun,
>>>
>>> The debugger is your best friend. This method in
>>> ItemPropertyDescriptor should be getting called:
>>>
>>> public boolean canSetProperty(Object object)
>>> {
>>> if (isSettable)
>>> {
>>> EditingDomain editingDomain = getEditingDomain(object);
>>> if (editingDomain != null)
>>> {
>>> Resource resource = object instanceof EObject ?
>>> ((EObject)object).eResource() :
>>> object instanceof Resource ?
>>> (Resource)object :
>>> null;
>>> return resource == null ||
>>> !editingDomain.isReadOnly(resource);
>>> }
>>> else
>>> {
>>> return true;
>>> }
>>> }
>>> else
>>> {
>>> return false;
>>> }
>>> }
>>>
>>> You could investigate what's happening here.
>>>
>>>
>>> Artun Subasi wrote:
>>>> I already tried that. Somehow, it didn't work for me.
>>>>
>>>> I added a selection listener to the navigators viewer. When the
>>>> selection changes, I get the Resources of the selected EObjects and
>>>> add them to the map you mentioned like this:
>>>>
>>>> myAdapterFactoryEditingDomain.getResourceToReadOnlyMap.put(r esource,
>>>> true);
>>>>
>>>> This didn't change anything.
>>>>
>>>> Ed Merks schrieb:
>>>>> Artun,
>>>>>
>>>>> Comments below.
>>>>>
>>>>> Artun Subasi wrote:
>>>>>> Hello,
>>>>>>
>>>>>> I am using RCP, EMF and GMF in my application. I have a navigator
>>>>>> view which uses the AdapterFactoryContentProvider as content
>>>>>> provider. I added property sheet support to the view by inspecting
>>>>>> how it was done in the generated EMF editor.
>>>>>>
>>>>>> The property sheet page is working properly. However, the cells
>>>>>> are editable and this is bad for the navigator view. Because the
>>>>>> navigator view is not an editor and there is no possibility save
>>>>>> the changes.
>>>>> The editing domain as a whole could mark the resource as read only
>>>>> and then no commands to change the contents will be executable.
>>>>> You could use AdapterFactoryEditingDomain.getResourceToReadOnlyMap
>>>>> to make the resource readonly.
>>>>>>
>>>>>> I want to make the property sheet page read-only, which is
>>>>>> displayed when an element is selected in the navigator view. I
>>>>>> can't make the properties globally read-only using the genmodel,
>>>>>> because the property sheets of GMF editors should not be affected.
>>>>>> Any solution or idea is welcome.
>>>>>>
>>>>>> Regards,
>>>>>> Artun
Previous Topic:AdapterFactory advice
Next Topic:Extending JWT's EMF metamodel
Goto Forum:
  


Current Time: Thu Apr 25 02:11:17 GMT 2024

Powered by FUDForum. Page generated in 0.02908 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top