Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Disable edit possibility in non-containment reference
Disable edit possibility in non-containment reference [message #912853] Fri, 14 September 2012 09:36 Go to next message
John M. is currently offline John M.
Messages: 198
Registered: July 2010
Senior Member
The attached picture show my editor content. It is a part of the generated emf editor and you can move all around like you want.
index.php/fa/11453/0/

To show the children of a reference entry I overwrote the method getChildren in ReferenceContentItemProvider:
@Override
public Collection<?> getChildren(Object object) {
	if (object instanceof ReferenceContentImpl && ((ReferenceContentImpl) object).getReference() != null) {
		return ((ReferenceContentImpl) object).getReference().getCommands();
	}

	return super.getChildren(object);
}


But I don't want that is possibility to edit the content of a included sequence. It is a own class.
index.php/fa/11454/0/

Ed Merks point to the wrapping functionality. I overwrote the method isWrappingNeeded in the ReferenceContentItemProvider and return always true.
But it seems that it has no effect. I think I am missing something out.

Thanks for any hints.
Re: Disable edit possibility in non-containment reference [message #912883 is a reply to message #912853] Fri, 14 September 2012 10:33 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26137
Registered: July 2009
Senior Member
That's just the start.

You should see it gets to this method:

protected Object createWrapper(EObject object, EStructuralFeature
feature, Object value, int index)
{
if (!isWrappingNeeded(object)) return value;

if (FeatureMapUtil.isFeatureMap(feature))
{
value = new
FeatureMapEntryWrapperItemProvider((FeatureMap.Entry)value, object,
(EAttribute)feature, index, adapterFactory, getResourceLocator());
}
else if (feature instanceof EAttribute)
{
value = new AttributeValueWrapperItemProvider(value, object,
(EAttribute)feature, index, adapterFactory, getResourceLocator());
}
else if (!((EReference)feature).isContainment())
{
value = new DelegatingWrapperItemProvider(value, object, feature,
index, adapterFactory);
}

return value;
}

So it should get into "new DelegatingWrapperItemProvider". Does it?
You'll need to specialize that wrapper implementation.


On 14/09/2012 11:36 AM, Missing name Mising name wrote:
> The attached picture show my editor content. It is a part of the
> generated emf editor and you can move all around like you want.
>
>
> To show the children of a reference entry I overwrote the method
> getChildren in ReferenceContentItemProvider:
> @Override
> public Collection<?> getChildren(Object object) {
> if (object instanceof ReferenceContentImpl &&
> ((ReferenceContentImpl) object).getReference() != null) {
> return ((ReferenceContentImpl)
> object).getReference().getCommands();
> }
>
> return super.getChildren(object);
> }
>
> But I don't want that is possibility to edit the content of a included
> sequence. It is a own class.
>
>
> Ed Merks point to the wrapping functionality. I overwrote the method
> isWrappingNeeded in the ReferenceContentItemProvider and return always
> true.
> But it seems that it has no effect. I think I am missing something out.
>
> Thanks for any hints.
Re: Disable edit possibility in non-containment reference [message #912917 is a reply to message #912883] Fri, 14 September 2012 11:51 Go to previous messageGo to next message
John M. is currently offline John M.
Messages: 198
Registered: July 2010
Senior Member
No it doesn't reach the expected condition.
The point is that the method createWrapper is always called in class SequenceItemProvider and the corresponding object is SequenceImpl.
Re: Disable edit possibility in non-containment reference [message #912933 is a reply to message #912917] Fri, 14 September 2012 12:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26137
Registered: July 2009
Senior Member
But I told you to do this in ReferenceContentItemProvider, i.e., the
item provider for the object that holds the non-containment reference.

On 14/09/2012 1:51 PM, Missing name Mising name wrote:
> No it doesn't reach the expected condition.
> The point is that the method createWrapper is always called in class
> SequenceItemProvider and the corresponding object is SequenceImpl.
Re: Disable edit possibility in non-containment reference [message #912941 is a reply to message #912933] Fri, 14 September 2012 12:51 Go to previous messageGo to next message
John M. is currently offline John M.
Messages: 198
Registered: July 2010
Senior Member
Yeah I had done that. I overwrote the method isWrappingNeeded in the ReferenceContentItemProvider, it always return null.
After that I set a breakpoint on createWrapper in ItemProvider and in the isWrappningNeeded to see if it is called.
createWrapper is called only be the SequenceItemProvider, I explained the results above.
The method isWrappingNeeded in the RCIP is only called by wrapCommand, when I select the Reference.
Re: Disable edit possibility in non-containment reference [message #912970 is a reply to message #912941] Fri, 14 September 2012 13:54 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26137
Registered: July 2009
Senior Member
Comments below.

On 14/09/2012 2:51 PM, Missing name Mising name wrote:
> Yeah I had done that. I overwrote the method isWrappingNeeded in the
> ReferenceContentItemProvider, it always return null.
It returns a boolean, it can't be null.
> After that I set a breakpoint on createWrapper in ItemProvider and in
> the isWrappningNeeded to see if it is called.
> createWrapper is called only be the SequenceItemProvider, I explained
> the results above.
But wrap is called for all children it it always calls createWrapper.
> The method isWrappingNeeded in the RCIP is only called by wrapCommand,
> when I select the Reference.
So that one should return true and you want to create a wrapper for the
"reference" feature.

There seems to be some confusion here and I'm making assumptions based
on the snippets of information you provide. Is a Sequence displayed as
a child of a ReferenceContent in your tree view?
Re: Disable edit possibility in non-containment reference [message #912985 is a reply to message #912970] Fri, 14 September 2012 14:43 Go to previous messageGo to next message
John M. is currently offline John M.
Messages: 198
Registered: July 2010
Senior Member
>> Yeah I had done that. I overwrote the method isWrappingNeeded in the
>> ReferenceContentItemProvider, it always return null.
> It returns a boolean, it can't be null.
Sorry I meant true.

>> After that I set a breakpoint on createWrapper in ItemProvider and in
>> the isWrappningNeeded to see if it is called.
>> createWrapper is called only be the SequenceItemProvider, I explained
>> the results above.
> But wrap is called for all children it it always calls createWrapper.
That is correct, but only in class SequenceItemProvider.

>> The method isWrappingNeeded in the RCIP is only called by wrapCommand,
>> when I select the Reference.
> So that one should return true and you want to create a wrapper for the
> "reference" feature.
In that class I had overwritten the method.

> There seems to be some confusion here and I'm making assumptions based
> on the snippets of information you provide. Is a Sequence displayed as
> a child of a ReferenceContent in your tree view?
No it is another ReferenceContent, I only called them sequence to prevent missunderstanding.

The editor gets as input a "real" Sequence object. The Sequence object contains SequenceContent objects, which can be ReferenceContent or AbstractCommandData.
The ReferenceContent refers to a Sequence object and loads its commands, which are returned as children.
Re: Disable edit possibility in non-containment reference [message #912997 is a reply to message #912985] Fri, 14 September 2012 15:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26137
Registered: July 2009
Senior Member
Sorry but I can't answer questions based on this tangle of details.
You've more than exhausted your quota of questions for the week.


On 14/09/2012 4:43 PM, Missing name Mising name wrote:
>>> Yeah I had done that. I overwrote the method isWrappingNeeded in the
>>> ReferenceContentItemProvider, it always return null.
>> It returns a boolean, it can't be null.
> Sorry I meant true.
>
>>> After that I set a breakpoint on createWrapper in ItemProvider and in
>>> the isWrappningNeeded to see if it is called.
>>> createWrapper is called only be the SequenceItemProvider, I explained
>>> the results above.
>> But wrap is called for all children it it always calls createWrapper.
> That is correct, but only in class SequenceItemProvider.
>
>>> The method isWrappingNeeded in the RCIP is only called by wrapCommand,
>>> when I select the Reference.
>> So that one should return true and you want to create a wrapper for the
>> "reference" feature.
> In that class I had overwritten the method.
>
>> There seems to be some confusion here and I'm making assumptions based
>> on the snippets of information you provide. Is a Sequence displayed as
>> a child of a ReferenceContent in your tree view?
> No it is another ReferenceContent, I only called them sequence to
> prevent missunderstanding.
>
> The editor gets as input a "real" Sequence object. The Sequence object
> contains SequenceContent objects, which can be ReferenceContent or
> AbstractCommandData.
> The ReferenceContent refers to a Sequence object and loads its
> commands, which are returned as children.
Re: Disable edit possibility in non-containment reference [message #913021 is a reply to message #912997] Fri, 14 September 2012 16:00 Go to previous messageGo to next message
John M. is currently offline John M.
Messages: 198
Registered: July 2010
Senior Member
So I think I got it working now.
The summary is I have to overwrite the method isWrappingNeeded in ReferenceContentItemProvider and specialize the method createWrapper in SequenceItemProvider.
There was for me the confusion. I have always understood that I shall specialize the createWrapper in ReferenceContentItemProvider. Why should I do that, when it is never called?
Finally I tried it in the SequenceItemProvider and it works.

If it is possibile, please add some information about the wrapper in your EMF book, I couldn't find anything. Smile
Furthermore please tell me, where I can send information about feedback to your book.

But I think I found an abnormal behaviour for DND. The system returns always an executable command for inserting in the delegating wrapper above itself.
There is no other insert position in the delegation, where it works, only above the object itself.
You must have at least 2 elements.
I had tried to debug the DND, but you (Ed Merks) said, it is nearly impossible and I don't have the source code for doing real debugging/testing.

I will try to create a mini example, which shows the behavior and if I can proof it, I will add an entry in the tracker.
Re: Disable edit possibility in non-containment reference [message #915457 is a reply to message #912853] Mon, 17 September 2012 10:13 Go to previous message
John M. is currently offline John M.
Messages: 198
Registered: July 2010
Senior Member
So I have proofed the behavior. I added all necessary stuff to show the issue.
I am using EMF 2.7.2.

The DelegatingWrapperItemProvider allows to move the same element in front of itself:
index.php/fa/11514/0/

But not to another position:
index.php/fa/11516/0/

My post (http://www.eclipse.org/forums/index.php/mv/msg/376193/913021/#msg_913021) shows up, what I have done.
Previous Topic:Teneo | CDO| Could not find PAnnotatedEPackage "http://www.eclipse.org/emf/2002/Ecore"
Next Topic:Problems with targetNamespace
Goto Forum:
  


Current Time: Thu Oct 23 22:10:48 GMT 2014

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

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