extending VE: accessing SWING/SWT objects [message #123777] |
Mon, 24 April 2006 17:23  |
Eclipse User |
|
|
|
Originally posted by: sgollery.cadrc.calpoly.edu
I'm trying to extend VE so that I can attach fields from my domain model
to specific widgets through a controller.
I see how to add my own action to the popup menu for anything on the
visual editor window, but I can't figure out how to get from the current
selection to anything that connects to a specific widget -- I can get
the widget's class name, but nothing that (as far as I can tell)
represents the widget itself in the code.
For instance: if I have a JButton named jButton1 and there is a
getJButton1 method in the class that extends JFrame, I'd like to be able
to get something representing that method so that I can use it in the
configuration for my controller. But all I can get from the selection
object is the name of the JButton class.
It seems that all the information I need is in the model maintained by
VE/GEF/EMF. If anyone can help me understand how to get to it, it would
be very helpful.
Steven Gollery
|
|
|
|
|
|
Re: extending VE: accessing SWING/SWT objects [message #124117 is a reply to message #123954] |
Fri, 28 April 2006 16:02  |
Eclipse User |
|
|
|
Originally posted by: sgollery.cadrc.calpoly.edu
Thanks, Rich. That does it.
Steve Gollery
Rich Kulp wrote:
> What you want can be gotten but it is in a very internal area and may
> change in the future, then again maybe not. It's been this way for years
> so it may not change soon. :-(
>
> But to get the name of the method that returns the widget (I'm assuming
> you are talking about the getter format that we use for Swing/AWT), then
> (where childComponent is the IJavaObjectInstance for the widget):
>
> JCMMethod cRef = (JCMMethod)
> InverseMaintenanceAdapter.getFirstReferencedBy(childComponen t,
> JCMPackage.eINSTANCE.getJCMMethod_Return());
>
> if (cRef != null)
> String returnMethodName = cRef.getName()
>
>
> To get the name of the class that the editor is editing:
>
> IDiagramModelBuilder mb = (IDiagramModelBuilder)
> editorPart.getEditDomain().getData(IDiagramModelBuilder.MODE L_BUILDER_KEY);
>
> if (mb != null)
> String className = mb.getThisTypeName();
>
|
|
|
|
Re: extending VE: accessing SWING/SWT objects [message #612768 is a reply to message #123790] |
Wed, 26 April 2006 13:19  |
Eclipse User |
|
|
|
Originally posted by: sgollery.cadrc.calpoly.edu
Rich Kulp wrote:
> See this for information on extending VE:
>
> http://eclipse.org/articles/Article-VE-Custom-Widget/customw idget.html
>
Thanks.
Of course I read all the documentation I could find on VE before
starting this, but I've now reread this article carefully and still
don't see how it solves my problem. Maybe if someone could give me a hint.
The situation is this:
I've added an action to the popupmenu of a widget in the visual editor.
In the run method of that action, I'd like to be able to get (a) the
name of the class containing the widget (in this case, a class that
extends JFrame) and (b) the method that gets the widget.
I can get the AbstractEditPart that I selected, and from there the
JavaObjectInstance that is the model for that part. But I don't see that
JavaObjectInstance contains what I need. Or does it? I can also (through
the JavaHelpers) get the name of the class of the widget, but again
that's not what I need.
Is there a solution along these lines, and if so, what is it? Or am I
going about this entirely the wrong way?
Steven Gollery
|
|
|
Re: extending VE: accessing SWING/SWT objects [message #612770 is a reply to message #123942] |
Wed, 26 April 2006 13:55  |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
What you want can be gotten but it is in a very internal area and may
change in the future, then again maybe not. It's been this way for years
so it may not change soon. :-(
But to get the name of the method that returns the widget (I'm assuming
you are talking about the getter format that we use for Swing/AWT), then
(where childComponent is the IJavaObjectInstance for the widget):
JCMMethod cRef = (JCMMethod)
InverseMaintenanceAdapter.getFirstReferencedBy(childComponen t,
JCMPackage.eINSTANCE.getJCMMethod_Return());
if (cRef != null)
String returnMethodName = cRef.getName()
To get the name of the class that the editor is editing:
IDiagramModelBuilder mb = (IDiagramModelBuilder)
editorPart.getEditDomain().getData(IDiagramModelBuilder.MODE L_BUILDER_KEY);
if (mb != null)
String className = mb.getThisTypeName();
--
Thanks,
Rich Kulp
|
|
|
Re: extending VE: accessing SWING/SWT objects [message #612790 is a reply to message #123954] |
Fri, 28 April 2006 16:02  |
Eclipse User |
|
|
|
Originally posted by: sgollery.cadrc.calpoly.edu
Thanks, Rich. That does it.
Steve Gollery
Rich Kulp wrote:
> What you want can be gotten but it is in a very internal area and may
> change in the future, then again maybe not. It's been this way for years
> so it may not change soon. :-(
>
> But to get the name of the method that returns the widget (I'm assuming
> you are talking about the getter format that we use for Swing/AWT), then
> (where childComponent is the IJavaObjectInstance for the widget):
>
> JCMMethod cRef = (JCMMethod)
> InverseMaintenanceAdapter.getFirstReferencedBy(childComponen t,
> JCMPackage.eINSTANCE.getJCMMethod_Return());
>
> if (cRef != null)
> String returnMethodName = cRef.getName()
>
>
> To get the name of the class that the editor is editing:
>
> IDiagramModelBuilder mb = (IDiagramModelBuilder)
> editorPart.getEditDomain().getData(IDiagramModelBuilder.MODE L_BUILDER_KEY);
>
> if (mb != null)
> String className = mb.getThisTypeName();
>
|
|
|
Powered by
FUDForum. Page generated in 0.07200 seconds