Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ve-dev] About the workbench selection

Hi,

I actually find out what was wrong, it was a mistake of my own (few days ago I had modify a jar from VE to make some tests, I extracted it in a directory and erase the jar file so when I added it to the plugin dependencies, it was recognize but not really added ...)
But there is still problem(s) ... :-D

I manage to get the type of the selected object thanks to this :

System.out.println("CLASS:" + (( (ComponentGraphicalEditPart) (ss.getFirstElement())).getBean().eClass().getName()));

But I still don't have an handle on it, i can't find what method to call, I tried with getEAllStructuralFeatures and similars, I even find out how to get all his methods ... but nothing to manipulate it ...
I remind you that I want to have an handle on the selected object in order to interact with him. I don't sure I am pretty clear so I want to give you an example.

Let's take a class X with an attribut picture and getter and setter for it. Now, imagine I've placed on instance of X on a JFrame, if I clicked on it, I want my view to display a text field where I can write the path to my picture and when I click "Ok", it must generate the following code in my JFrame : "myXClass.setPicture("myPathToMyPicture")
I hope I've made myself clear ... :-(


2008/8/11 Nicolas DRUT <nicolas.drut@xxxxxxxxx>
Hi Yves,

Thank for your advises, I have done something but I still have problems.
I casted my ISelection in IStructuredSelection, then I called getFirstElement, getClass and getName as you can see above :

IStructuredSelection ss = (IStructuredSelection) selection;
System.out.println("classs:"+ss.getFirstElement().getClass().getName());



When I run my plugin (I precise that I reuse a plugin providing a view that get the selection), if I clic on a JButton (place on a JFrame) for example I have this printing : classs:org.eclipse.ve.internal.jfc.core.ComponentGraphicalEditPart

So I tried to look at this ComponentGraphicalEditPart class; I found it and better, I see there is a getBean method which is public ! And in fact this method return an IJavaInstance.
I add all needed packages and dependencies (org.eclipse.ve.jfc, org.eclipse.ve.java.core, org.eclipse.jem for IJavaInstance) to my plugin and I managed to write this :
System.out.println("CLASSS:"+((ComponentGraphicalEditPart)(ss.getFirstElement().getClass())).getBean());
But Eclipse doesn't recognize the ComponentGraphicalEditPart ...

I think getBean is THE method I have to call but I can't, how can I do ? Do you have the same problem ?


Thank you for your help

ps : you can fin attached the ComponentGraphicalEditPart if you want to have a look at it



2008/8/8 Yves YANG <yves.yang@xxxxxxxxxxx>

You shloud cast ISelection to IStructualSelection and call getFirstElement(), which should be an IJavaInstance. Afterwards, you can call getEClass().getAllStructuralFeatures().

 

Yves YANG

Soyatec - Eclipse OutSourcing & XAML for java

http://www.soyatec.com

Tel: +33 1 60 13 06 67

Mobile: +33 6 20 74 39 45

Fax: +33 9 58 07 06 67


From: ve-dev-bounces@xxxxxxxxxxx [mailto:ve-dev-bounces@xxxxxxxxxxx] On Behalf Of Nicolas DRUT
Sent: Friday, August 08, 2008 8:50 AM


To: Discussions people developing code for the Visual Editor project
Subject: Re: [ve-dev] About the workbench selection

 

I tried to look at this way Yves, thank you, but I get back an org.eclipse.jface.viewers.StructuredSelection object from the SelectionService and not an IJavaInstance. And the StructuredSelection class doesn't have the getAllStructuralFeatures() method.
Are you sure of your IJavaInstance ? Is it return by the Visual Editor or another part ?

Many thanks.

Nicolas.


2008/8/7 Yves YANG <yves.yang@xxxxxxxxxxx>

The Handle of UI element is a type of IJavaInstance: a subclass of EObject. You can call getAllStructuralFeatures() to get all properties.

 

Yves YANG

Soyatec - Eclipse OutSourcing & XAML for java

http://www.soyatec.com

Tel: +33 1 60 13 06 67

Mobile: +33 6 20 74 39 45

Fax: +33 9 58 07 06 67


From: ve-dev-bounces@xxxxxxxxxxx [mailto:ve-dev-bounces@xxxxxxxxxxx] On Behalf Of Nicolas DRUT
Sent: Thursday, August 07, 2008 3:51 PM
To: richkulp@xxxxxxxxxx
Cc: Discussions people developing code for the Visual Editor project
Subject: Re: [ve-dev] About the workbench selection

 

Hi,

Many thanks for your answer Rich;
So apparently there isn't any method to get back an handle on my JButton ?
But if we look at the properties view, it seems to me that it does a part of it; because when you click on your item, it shows the properties of the item and it can modify the class, call his method, etc ...  Do you think we can find something looking at source of the Properties view ?

Nicolas

2008/8/7 Rich Kulp <richkulp@xxxxxxxxxx>


Hi,

I don't remember the specifics, but you are not really clicking on a JButton. The JButton instance doesn't even exist in Eclipse. In the VE the JButton is modeled by a BeanProxy object that models an actual JButton. I believe what is returned from the selection event handler is actually an IPropertySource which wrappers the JButton VE  model object.

Rich


"Nicolas DRUT" <nicolas.drut@xxxxxxxxx>
Sent by: ve-dev-bounces@xxxxxxxxxxx

08/07/2008 08:30 AM

Please respond to
Discussions people developing code for the Visual Editor project        <ve-dev@xxxxxxxxxxx>

To

"Discussions people developing code for the Visual Editor project" <ve-dev@xxxxxxxxxxx>

cc

 

Subject

[ve-dev] About the workbench selection

 

 

 




Hi,

This is me again with Visual Editor.
I am now trying to develop a new view to use it with VE. My view needs to know witch item is selected on the workbench. For example, if user clic on a JButton called myButton, I would like to be able to get an handle on the myButton class (in order to read his attributes for example).
I have tried to follow this tutorial : http://www.eclipse.org/articles/Article-WorkbenchSelections/article.html

, I managed to get back something but it is an Object type class whereas the item I clicked was a JButton. I tried to cast it in the JButton type but it failed, it seems to me that this is totally an other object ... Could you please help to find out how to get an handle on this JButton ?



I don't really know if it is a VE problem but perhaps some of you have tried to do the same someday, I hope.

Thank you very much for your help and looking forward to hearing from you.

Cheers,

Nicolas._______________________________________________
ve-dev mailing list
ve-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ve-dev


_______________________________________________
ve-dev mailing list
ve-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ve-dev

 


_______________________________________________
ve-dev mailing list
ve-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ve-dev

 


_______________________________________________
ve-dev mailing list
ve-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ve-dev




Back to the top