Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » getting semantic object from outiline selection
getting semantic object from outiline selection [message #1066986] Fri, 05 July 2013 10:55 Go to next message
Vincent De Bry is currently offline Vincent De BryFriend
Messages: 55
Registered: May 2013
Member
Hi

I have implemented a Selection Listener which reacts when I am selecting an element of the Outline. But I am getting a EObjectNode whikle I would like to manage the model element.

How could I get the instance of the corresponding model element from an outline selection ?

Thanks
Re: getting semantic object from outiline selection [message #1066999 is a reply to message #1066986] Fri, 05 July 2013 11:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

what do you actually want todo you may have a look at
org.eclipse.xtext.util.concurrent.IReadAccess.readOnly(IUnitOfWork<EObject, EObject>)
(EObjectNode implements IReadAccess)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: getting semantic object from outiline selection [message #1067039 is a reply to message #1066999] Fri, 05 July 2013 14:39 Go to previous messageGo to next message
Vincent De Bry is currently offline Vincent De BryFriend
Messages: 55
Registered: May 2013
Member
Christian,

that sounds good... But I really don't know how to find what to set as attribute.

I tried this:
EObjectNode eon = (EObjectNode)selected;
Object o = eon.readOnly(new IUnitOfWork.Void<EObject>() {
    @Override
    public void process(EObject state) throws Exception {
        // TODO Auto-generated method stub
						
        }
    });			


of course it does not work... what do to in "process" ??
Could you please tell me a bit more ?

thanks
Re: getting semantic object from outiline selection [message #1067040 is a reply to message #1067039] Fri, 05 July 2013 14:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
This is your business logic not mine ?!?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: getting semantic object from outiline selection [message #1067050 is a reply to message #1067040] Fri, 05 July 2013 15:20 Go to previous messageGo to next message
Vincent De Bry is currently offline Vincent De BryFriend
Messages: 55
Registered: May 2013
Member
Christian,

I just ment there was a way to get the modelObject directly in the returned value of readOnly, and I did not figure out how, basically.

I finally did the following, that seem to work
{
    ...
    EObjectNode eon = (EObjectNode)selected;

    eon.readOnly(new IUnitOfWork.Void<EObject>() {
        @Override
         public void process(EObject state) throws Exception {
            setModelObject(state);
        }
    });
                
    return getModelObject();
}
    
EObject modelObject= null;
public void setModelObject(EObject eo)
{
    modelObject= eo;
}
public void getModelObject()
{
    return modelObject;
}


Thank again Smile
Re: getting semantic object from outiline selection [message #1067053 is a reply to message #1067050] Fri, 05 July 2013 15:27 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi I still not get it. You get the eobject as parameter. So simply
downcast. Please note you should not use the eobject outside of the
method.

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Formatting: Custom formatting function
Next Topic:something about outline view
Goto Forum:
  


Current Time: Thu Apr 25 21:35:29 GMT 2024

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

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

Back to the top