Home » Archived » Visual Editor (VE) » New Palette
New Palette [message #105261] |
Mon, 05 September 2005 14:27  |
Eclipse User |
|
|
|
Originally posted by: billy.webwhysguy.com
Greetings,
I'm a newbee to eclipse development, so please forgive me if this question
has an obvious answer. I want to create a new palette for another type of
content, i.e., not java files, but a special set/type of files with custom
code generation for the items on the palette. Any ideas where to start?
I have started with the Palette example on eclipse.org (written on 06/05),
but it really focuses on extending the Java Palette, whereas I want to
create an entirely new palette. Any assistace on where/how to begin would
be appreciated.
Thanks
- Billy
|
|
| | |
Re: New Palette [message #106491 is a reply to message #106196] |
Tue, 13 September 2005 10:28   |
Eclipse User |
|
|
|
John Cage wrote:
> Hi, I'll provide small example, but if you wawnt please simlify it if
> you need it for purpose of explanation.
>
> Target code XSWT:
>
> <composite>
> <layout x:class="fillLayout"/>
> <x:children>
> <label text="Push this button:"/>
> <button text="Punch me!"/>
> </x:children>
> </composite>
>
>
> Target component (SWT' Label or Button, or subclasses of them[if it is
> necessary for VE])
>
> -------------------------
> If you can provide example how too generate code, it would be nice.
> Also if you can show how to decode such source code it will be
> definitely the BEST.
>
> Thanks,
> John Cage
>
>
Generating/Reverse Parsing XML syntax/particulars and mechanics is something I have not looked at. With all the XML
information/code out there it should be something you should be able to figure out yourself. I think that the
inhibiting problems for you is where to start, and how does the VE model looks like to begin with. The following should
help you get started:
If you drop the composite above on a SWT shell, the following would the the VE EMF model (you can snap this from the VE
cache in
<workspace>\.metadata\.plugins\org.eclipse.core.resources\.projects\ <project>\org.eclipse.ve.java.core\.cache\emfmodel
BeanSubclassComposition is the root, and the components features denotes (using XPath) that members[0] is on the Free
form. members[0] is the Shell.
=======================================
<?xml version="1.0" encoding="UTF-8"?>
<org.eclipse.ve.internal.jcm:BeanSubclassComposition ... components="//@members.0">
<members xsi:type="org.eclipse.swt.widgets:Shell" size="//@methods.0/@properties.0" controls="//@members.1">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:ParseTreeAllocation ">
<expression xsi:type=" org.eclipse.jem.internal.instantiation:PTClassInstanceCreati on "
type="org.eclipse.swt.widgets.Shell"/>
</allocation>
</members>
<members xsi:type="org.eclipse.swt.widgets:Composite" bounds="//@methods.1/@properties.0"
layout="//@methods.1/@properties.1"
controls="//@members.2 //@members.3">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:ParseTreeAllocation ">
<expression xsi:type=" org.eclipse.jem.internal.instantiation:PTClassInstanceCreati on "
type="org.eclipse.swt.widgets.Composite">
<arguments xsi:type="org.eclipse.jem.internal.instantiation:PTInstanceReference " object="//@members.0"/>
<arguments xsi:type="org.eclipse.jem.internal.instantiation:PTFieldAccess " field="NONE">
<receiver xsi:type="org.eclipse.jem.internal.instantiation:PTName" name="org.eclipse.swt.SWT"/>
</arguments>
</expression>
</allocation>
</members>
<members xsi:type="org.eclipse.swt.widgets:Label" text="//@methods.1/@properties.2">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:ParseTreeAllocation ">
<expression xsi:type=" org.eclipse.jem.internal.instantiation:PTClassInstanceCreati on "
type="org.eclipse.swt.widgets.Label">
<arguments xsi:type="org.eclipse.jem.internal.instantiation:PTInstanceReference " object="//@members.1"/>
<arguments xsi:type="org.eclipse.jem.internal.instantiation:PTFieldAccess " field="NONE">
<receiver xsi:type="org.eclipse.jem.internal.instantiation:PTName" name="org.eclipse.swt.SWT"/>
</arguments>
</expression>
</allocation>
</members>
<members xsi:type="org.eclipse.swt.widgets:Button" text="//@methods.1/@properties.3">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:ParseTreeAllocation ">
<expression xsi:type=" org.eclipse.jem.internal.instantiation:PTClassInstanceCreati on "
type="org.eclipse.swt.widgets.Button">
<arguments xsi:type="org.eclipse.jem.internal.instantiation:PTInstanceReference " object="//@members.1"/>
<arguments xsi:type="org.eclipse.jem.internal.instantiation:PTFieldAccess " field="NONE">
<receiver xsi:type="org.eclipse.jem.internal.instantiation:PTName" name="org.eclipse.swt.SWT"/>
</arguments>
</expression>
</allocation>
</members>
<methods name="createSShell" initializes="//@members.0">
<properties xsi:type="org.eclipse.swt.graphics:Point">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:InitStringAllocation " initString="new
org.eclipse.swt.graphics.Point(246,107)"/>
</properties>
</methods>
<methods name="createComposite" initializes="//@members.1 //@members.2 //@members.3">
<properties xsi:type="org.eclipse.swt.graphics:Rectangle">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:InitStringAllocation " initString="new
org.eclipse.swt.graphics.Rectangle(25,14,133,55)"/>
</properties>
<properties xsi:type="org.eclipse.swt.layout:FillLayout"/>
<properties xsi:type="java.lang:String">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:InitStringAllocation " initString=""Push This
Buttonl""/>
</properties>
<properties xsi:type="java.lang:String">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:InitStringAllocation " initString=""Punch
me!""/>
</properties>
</methods>
</org.eclipse.ve.internal.jcm:BeanSubclassComposition>
============================================================ ===
The <allocation> feature is similar to an AST representation of the constructor... since (for the sake of this example
where SWT bitmanps are *not* needed), if you filter the allocation feature (and also remove the createSShell method
def.) the model looks like this:
============================================================ ===
<?xml version="1.0" encoding="UTF-8"?>
<org.eclipse.ve.internal.jcm:BeanSubclassComposition ... components="//@members.0">
<members xsi:type="org.eclipse.swt.widgets:Shell" size="//@methods.0/@properties.0" controls="//@members.1"/>
<members xsi:type="org.eclipse.swt.widgets:Composite" bounds="//@methods.1/@properties.0"
layout="//@methods.1/@properties.1"
controls="//@members.2 //@members.3">
</members>
<members xsi:type="org.eclipse.swt.widgets:Label" text="//@methods.1/@properties.2"/>
<members xsi:type="org.eclipse.swt.widgets:Button" text="//@methods.1/@properties.3"/>
<methods name="createSShell" initializes="//@members.0">
<properties xsi:type="org.eclipse.swt.graphics:Point">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:InitStringAllocation " initString="new
org.eclipse.swt.graphics.Point(246,107)"/>
</properties>
</methods>
<methods name="createComposite" initializes="//@members.1 //@members.2 //@members.3">
<properties xsi:type="org.eclipse.swt.graphics:Rectangle">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:InitStringAllocation " initString="new
org.eclipse.swt.graphics.Rectangle(25,14,133,55)"/>
</properties>
<properties xsi:type="org.eclipse.swt.layout:FillLayout"/>
<properties xsi:type="java.lang:String">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:InitStringAllocation " initString=""Push This
Buttonl""/>
</properties>
<properties xsi:type="java.lang:String">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:InitStringAllocation " initString=""Punch
me!""/>
</properties>
</methods>
</org.eclipse.ve.internal.jcm:BeanSubclassComposition>
=======================================================
<org.eclipse.ve.internal.jcm:BeanSubclassComposition ... components="//@members.0">
this is the model root. components designates which member is a top level on the FreeForm
<members xsi:type="org.eclipse.swt.widgets:Shell" size="//@methods.0/@properties.0" controls="//@members.1"/>
members[0] is a Shell, its size property is set with an instance that is defined in methods[0].properties[0].
It has a single (child) control, defined as members[1] (the composite)
<methods name="createComposite" initializes="//@members.1 //@members.2 //@members.3">
A method tag represent source method (scoping). This implies the createComposite initializes the composite, label, and
button.
A method may have members (localy scoped/ref variables), and properties (elements that are not referenced beyond a given
setting.
You can get the BeanSubclassComposition from the editor's EditDomain.getDiagramData()
|
|
| |
Re: New Palette [message #107604 is a reply to message #106505] |
Tue, 20 September 2005 10:55  |
Eclipse User |
|
|
|
John Cage wrote:
> Hi Gili,
>
> I tried to generate XML source code so that I have my own EditParts, where I
> add my code generation behaviour
> there, via attaching my adapter to the bean (at EditPart), which works as a
> LISTENER and that do the code generation).
> Attaching via:
> getBean().eAdapters().add(adapter);
> And in the notifyChanged method of that adapter I determined the property
> and via BeanProxies I find the actual value of the Property which changed.
>
> But it can catch only the modification of properties, but not
> creation/deleting of beans.
> The XML file source model I put into modelRoot (BeanSubclassComposition - so
> from every bean it is accessible).
> The changes I write into the XML file via DOM Model representation of the
> output source code.
> Component nodes I have identified via component name.
>
> Questions:
> ----------
> 1) How do I handle creation/deleting of the beans?
> 1.1) May I do it via attaching my Adapter(Listener) at
> BeanSubclassComposition?
>
When a Bean is created it will be inserted to the members feature (if it is an instance/local variable), or properties
feature if it is not referenced by anything. Your adapter can listen to this change.
If the Bean is marked as GLOBAL_xx (in the class annotation), VE will create an "Instance Variable" and will insert the
bean into the members of the BeanSubclassComposition. If it is a LOCAL, it will insert the bean into the members
feature of the (model) method (scope) the bean it is declared in.
|
|
|
Re: New Palette [message #610728 is a reply to message #105261] |
Fri, 09 September 2005 16:03  |
Eclipse User |
|
|
|
WebWhysGuy wrote:
> Greetings,
>
> I'm a newbee to eclipse development, so please forgive me if this
> question has an obvious answer. I want to create a new palette for
> another type of content, i.e., not java files, but a special set/type of
> files with custom code generation for the items on the palette. Any
> ideas where to start? I have started with the Palette example on
> eclipse.org (written on 06/05), but it really focuses on extending the
> Java Palette, whereas I want to create an entirely new palette. Any
> assistace on where/how to begin would be appreciated.
>
> Thanks
>
> - Billy
>
>
.... be great if you could provide a simple sample of an object that you want to drop, and the code that you want to
generate.
|
|
|
Re: New Palette [message #610736 is a reply to message #106087] |
Mon, 12 September 2005 10:52  |
Eclipse User |
|
|
|
Hi, I'll provide small example, but if you wawnt please simlify it if you
need it for purpose of explanation.
Target code XSWT:
<composite>
<layout x:class="fillLayout"/>
<x:children>
<label text="Push this button:"/>
<button text="Punch me!"/>
</x:children>
</composite>
Target component (SWT' Label or Button, or subclasses of them[if it is
necessary for VE])
-------------------------
If you can provide example how too generate code, it would be nice.
Also if you can show how to decode such source code it will be definitely
the BEST.
Thanks,
John Cage
|
|
|
Re: New Palette [message #610757 is a reply to message #106196] |
Tue, 13 September 2005 10:28  |
Eclipse User |
|
|
|
John Cage wrote:
> Hi, I'll provide small example, but if you wawnt please simlify it if
> you need it for purpose of explanation.
>
> Target code XSWT:
>
> <composite>
> <layout x:class="fillLayout"/>
> <x:children>
> <label text="Push this button:"/>
> <button text="Punch me!"/>
> </x:children>
> </composite>
>
>
> Target component (SWT' Label or Button, or subclasses of them[if it is
> necessary for VE])
>
> -------------------------
> If you can provide example how too generate code, it would be nice.
> Also if you can show how to decode such source code it will be
> definitely the BEST.
>
> Thanks,
> John Cage
>
>
Generating/Reverse Parsing XML syntax/particulars and mechanics is something I have not looked at. With all the XML
information/code out there it should be something you should be able to figure out yourself. I think that the
inhibiting problems for you is where to start, and how does the VE model looks like to begin with. The following should
help you get started:
If you drop the composite above on a SWT shell, the following would the the VE EMF model (you can snap this from the VE
cache in
<workspace>\.metadata\.plugins\org.eclipse.core.resources\.projects\ <project>\org.eclipse.ve.java.core\.cache\emfmodel
BeanSubclassComposition is the root, and the components features denotes (using XPath) that members[0] is on the Free
form. members[0] is the Shell.
=======================================
<?xml version="1.0" encoding="UTF-8"?>
<org.eclipse.ve.internal.jcm:BeanSubclassComposition ... components="//@members.0">
<members xsi:type="org.eclipse.swt.widgets:Shell" size="//@methods.0/@properties.0" controls="//@members.1">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:ParseTreeAllocation ">
<expression xsi:type=" org.eclipse.jem.internal.instantiation:PTClassInstanceCreati on "
type="org.eclipse.swt.widgets.Shell"/>
</allocation>
</members>
<members xsi:type="org.eclipse.swt.widgets:Composite" bounds="//@methods.1/@properties.0"
layout="//@methods.1/@properties.1"
controls="//@members.2 //@members.3">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:ParseTreeAllocation ">
<expression xsi:type=" org.eclipse.jem.internal.instantiation:PTClassInstanceCreati on "
type="org.eclipse.swt.widgets.Composite">
<arguments xsi:type="org.eclipse.jem.internal.instantiation:PTInstanceReference " object="//@members.0"/>
<arguments xsi:type="org.eclipse.jem.internal.instantiation:PTFieldAccess " field="NONE">
<receiver xsi:type="org.eclipse.jem.internal.instantiation:PTName" name="org.eclipse.swt.SWT"/>
</arguments>
</expression>
</allocation>
</members>
<members xsi:type="org.eclipse.swt.widgets:Label" text="//@methods.1/@properties.2">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:ParseTreeAllocation ">
<expression xsi:type=" org.eclipse.jem.internal.instantiation:PTClassInstanceCreati on "
type="org.eclipse.swt.widgets.Label">
<arguments xsi:type="org.eclipse.jem.internal.instantiation:PTInstanceReference " object="//@members.1"/>
<arguments xsi:type="org.eclipse.jem.internal.instantiation:PTFieldAccess " field="NONE">
<receiver xsi:type="org.eclipse.jem.internal.instantiation:PTName" name="org.eclipse.swt.SWT"/>
</arguments>
</expression>
</allocation>
</members>
<members xsi:type="org.eclipse.swt.widgets:Button" text="//@methods.1/@properties.3">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:ParseTreeAllocation ">
<expression xsi:type=" org.eclipse.jem.internal.instantiation:PTClassInstanceCreati on "
type="org.eclipse.swt.widgets.Button">
<arguments xsi:type="org.eclipse.jem.internal.instantiation:PTInstanceReference " object="//@members.1"/>
<arguments xsi:type="org.eclipse.jem.internal.instantiation:PTFieldAccess " field="NONE">
<receiver xsi:type="org.eclipse.jem.internal.instantiation:PTName" name="org.eclipse.swt.SWT"/>
</arguments>
</expression>
</allocation>
</members>
<methods name="createSShell" initializes="//@members.0">
<properties xsi:type="org.eclipse.swt.graphics:Point">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:InitStringAllocation " initString="new
org.eclipse.swt.graphics.Point(246,107)"/>
</properties>
</methods>
<methods name="createComposite" initializes="//@members.1 //@members.2 //@members.3">
<properties xsi:type="org.eclipse.swt.graphics:Rectangle">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:InitStringAllocation " initString="new
org.eclipse.swt.graphics.Rectangle(25,14,133,55)"/>
</properties>
<properties xsi:type="org.eclipse.swt.layout:FillLayout"/>
<properties xsi:type="java.lang:String">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:InitStringAllocation " initString=""Push This
Buttonl""/>
</properties>
<properties xsi:type="java.lang:String">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:InitStringAllocation " initString=""Punch
me!""/>
</properties>
</methods>
</org.eclipse.ve.internal.jcm:BeanSubclassComposition>
============================================================ ===
The <allocation> feature is similar to an AST representation of the constructor... since (for the sake of this example
where SWT bitmanps are *not* needed), if you filter the allocation feature (and also remove the createSShell method
def.) the model looks like this:
============================================================ ===
<?xml version="1.0" encoding="UTF-8"?>
<org.eclipse.ve.internal.jcm:BeanSubclassComposition ... components="//@members.0">
<members xsi:type="org.eclipse.swt.widgets:Shell" size="//@methods.0/@properties.0" controls="//@members.1"/>
<members xsi:type="org.eclipse.swt.widgets:Composite" bounds="//@methods.1/@properties.0"
layout="//@methods.1/@properties.1"
controls="//@members.2 //@members.3">
</members>
<members xsi:type="org.eclipse.swt.widgets:Label" text="//@methods.1/@properties.2"/>
<members xsi:type="org.eclipse.swt.widgets:Button" text="//@methods.1/@properties.3"/>
<methods name="createSShell" initializes="//@members.0">
<properties xsi:type="org.eclipse.swt.graphics:Point">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:InitStringAllocation " initString="new
org.eclipse.swt.graphics.Point(246,107)"/>
</properties>
</methods>
<methods name="createComposite" initializes="//@members.1 //@members.2 //@members.3">
<properties xsi:type="org.eclipse.swt.graphics:Rectangle">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:InitStringAllocation " initString="new
org.eclipse.swt.graphics.Rectangle(25,14,133,55)"/>
</properties>
<properties xsi:type="org.eclipse.swt.layout:FillLayout"/>
<properties xsi:type="java.lang:String">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:InitStringAllocation " initString=""Push This
Buttonl""/>
</properties>
<properties xsi:type="java.lang:String">
<allocation xsi:type="org.eclipse.jem.internal.instantiation:InitStringAllocation " initString=""Punch
me!""/>
</properties>
</methods>
</org.eclipse.ve.internal.jcm:BeanSubclassComposition>
=======================================================
<org.eclipse.ve.internal.jcm:BeanSubclassComposition ... components="//@members.0">
this is the model root. components designates which member is a top level on the FreeForm
<members xsi:type="org.eclipse.swt.widgets:Shell" size="//@methods.0/@properties.0" controls="//@members.1"/>
members[0] is a Shell, its size property is set with an instance that is defined in methods[0].properties[0].
It has a single (child) control, defined as members[1] (the composite)
<methods name="createComposite" initializes="//@members.1 //@members.2 //@members.3">
A method tag represent source method (scoping). This implies the createComposite initializes the composite, label, and
button.
A method may have members (localy scoped/ref variables), and properties (elements that are not referenced beyond a given
setting.
You can get the BeanSubclassComposition from the editor's EditDomain.getDiagramData()
|
|
|
Re: New Palette [message #610758 is a reply to message #106491] |
Tue, 13 September 2005 11:28  |
Eclipse User |
|
|
|
Hi Gili,
I tried to generate XML source code so that I have my own EditParts, where I
add my code generation behaviour
there, via attaching my adapter to the bean (at EditPart), which works as a
LISTENER and that do the code generation).
Attaching via:
getBean().eAdapters().add(adapter);
And in the notifyChanged method of that adapter I determined the property
and via BeanProxies I find the actual value of the Property which changed.
But it can catch only the modification of properties, but not
creation/deleting of beans.
The XML file source model I put into modelRoot (BeanSubclassComposition - so
from every bean it is accessible).
The changes I write into the XML file via DOM Model representation of the
output source code.
Component nodes I have identified via component name.
Questions:
----------
1) How do I handle creation/deleting of the beans?
1.1) May I do it via attaching my Adapter(Listener) at
BeanSubclassComposition?
2) What else I need for basic code generation?
3) If I will have the code generation completed, how do I make decoding of
the XML code?
3.1) What I need to create BASIC PARSING FUNCTIONALITY, and where to
hook it? It is the thing where I really NEED HELP.
May you please provide some small example?
3.1.1) What creates beans from source code?
3.1.2) What maps source code expressions to VE beans?
Thanks,
John Cage
|
|
|
Re: New Palette [message #610830 is a reply to message #106505] |
Tue, 20 September 2005 10:55  |
Eclipse User |
|
|
|
John Cage wrote:
> Hi Gili,
>
> I tried to generate XML source code so that I have my own EditParts, where I
> add my code generation behaviour
> there, via attaching my adapter to the bean (at EditPart), which works as a
> LISTENER and that do the code generation).
> Attaching via:
> getBean().eAdapters().add(adapter);
> And in the notifyChanged method of that adapter I determined the property
> and via BeanProxies I find the actual value of the Property which changed.
>
> But it can catch only the modification of properties, but not
> creation/deleting of beans.
> The XML file source model I put into modelRoot (BeanSubclassComposition - so
> from every bean it is accessible).
> The changes I write into the XML file via DOM Model representation of the
> output source code.
> Component nodes I have identified via component name.
>
> Questions:
> ----------
> 1) How do I handle creation/deleting of the beans?
> 1.1) May I do it via attaching my Adapter(Listener) at
> BeanSubclassComposition?
>
When a Bean is created it will be inserted to the members feature (if it is an instance/local variable), or properties
feature if it is not referenced by anything. Your adapter can listen to this change.
If the Bean is marked as GLOBAL_xx (in the class annotation), VE will create an "Instance Variable" and will insert the
bean into the members of the BeanSubclassComposition. If it is a LOCAL, it will insert the bean into the members
feature of the (model) method (scope) the bean it is declared in.
|
|
|
Goto Forum:
Current Time: Tue Jun 03 05:07:29 EDT 2025
Powered by FUDForum. Page generated in 0.03890 seconds
|