You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by Christopher Brind <br...@brindy.org.uk> on 2009/11/15 13:23:05 UTC

problems building an eclipse plugin

Hi,

I don't want to get people too excited, but I'm working on an Eclipse plugin
for Pivot.  At the moment it simply recognises WTKX as an XML format, and
I've extended the XML editor to add a new page called 'Preview'.

My original plan was use the SWT AWT bridge and some very simple code to
render the WTKX.  That is, I don't render the the contents of the WTKX using
Pivot code, I simply call paint(Graphics2D) directly.

However, I've hit a couple of problems:

1) SWT AWT Bridge doesn't work on Mac!

The problem is also described here, ignoring the fact that the original
poster isn't actually using the SWT/AWT bridge - he has come across the same
problem as me, that something in Eclipse basically breaks AWT.  In his case
he can run it on the command line, but when it comes to using the SWT/AWT
bridge, this has fail written all over it.

I'm looking in to this in more detail, but I wonder if it would be worth
abstracting the graphics context so that it isn't AWT specific?  Perhaps a
lot of work, but it would mean I could implement a pure SWT version for
rendering in Eclipse.



2) Instantiation problems when deserialising the WTKX

Here's my rendering code, but in a stand alone way outside of Eclipse (I got
here by trying to debug the SWT/AWT problem) :

public static void main(String[] args) throws Exception {


 // Frame frame = new Frame();

Properties props = System.getProperties();

Iterator iter = props.keySet().iterator();

while (iter.hasNext()) {

String key = (String) iter.next();

System.out.println(key + " : " + props.getProperty(key));

}


 JFrame frame = new JFrame();

frame.setSize(800, 600);

frame.setVisible(true);


 JApplet applet = new JApplet();

applet.setSize(800, 600);

frame.add(applet);

frame.setVisible(true);


 WTKXSerializer wtkx = new WTKXSerializer();

Object o = wtkx.readObject(new FileInputStream("assets/template.wtkx"));


 Window window = null;

if (o instanceof Window) {

window = (Window) o;

} else {

window = new Window();


 Component c = (Component) o;

c.setSize(applet.getWidth(), applet.getHeight());


 window.add(c);

}


 window.setSize(applet.getWidth(), applet.getHeight());

window.validate();


 Graphics2D g2d = (Graphics2D) applet.getGraphics();

window.paint(g2d);


 }

Similar code will be used inside the Eclipse plugin to render the WTKX in
the Eclipse editor - as you can see, it's a render-only process, it doesn't
handle events or anything like that.

Now this actually works OK for the given WTKX:

<BoxPane xmlns="org.apache.pivot.wtk"

    xmlns:wtkx="http://pivot.apache.org/wtkx">

         <Label wtkx:id="label" text="Enter your name: "/>

        <TextInput preferredWidth="200" />



</BoxPane>

But, if I drop in a Button, like this:

<BoxPane xmlns="org.apache.pivot.wtk"

    xmlns:wtkx="http://pivot.apache.org/wtkx">

         <Label wtkx:id="label" text="Enter your name: "/>

        <TextInput preferredWidth="200" />

        <Button label="Submit" />



</BoxPane>

I get some exceptions:

An error occurred while processing  element <BoxPane> starting at line
number 6:
org.apache.pivot.serialization.SerializationException:
java.lang.InstantiationException
at
org.apache.pivot.wtkx.WTKXSerializer.processStartElement(WTKXSerializer.java:585)
at org.apache.pivot.wtkx.WTKXSerializer.readObject(WTKXSerializer.java:426)
at
org.apache.pivot.wtkxeditor.editors.WTKXPreviewer.main(WTKXPreviewer.java:37)
Caused by: java.lang.InstantiationException
at
sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:30)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at
org.apache.pivot.wtkx.WTKXSerializer.processStartElement(WTKXSerializer.java:583)
... 2 more
Exception in thread "main"
org.apache.pivot.serialization.SerializationException:
java.lang.InstantiationException
at
org.apache.pivot.wtkx.WTKXSerializer.processStartElement(WTKXSerializer.java:585)
at org.apache.pivot.wtkx.WTKXSerializer.readObject(WTKXSerializer.java:426)
at
org.apache.pivot.wtkxeditor.editors.WTKXPreviewer.main(WTKXPreviewer.java:37)
Caused by: java.lang.InstantiationException
at
sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:30)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at
org.apache.pivot.wtkx.WTKXSerializer.processStartElement(WTKXSerializer.java:583)
... 2 more


I realise my circumventing the usual Pivot lifecycle might have something to
do with it, so any ideas?

If I can get around problem #2 somehow I think I can still produce an alpha
version Eclipse plugin that will work on Windows/Linux, just not Mac =(  but
like I say - being able to implement a pure SWT graphics context would get
around that problem.

Cheers,
Chris

Re: problems building an eclipse plugin

Posted by Todd Volkert <tv...@gmail.com>.
That sounds great Chris -- I'll give it a whirl tomorrow morning.

-T

On Sun, Nov 15, 2009 at 9:22 AM, Christopher Brind <br...@brindy.org.uk>wrote:

> I had an idea ... I'll just use a Graphics2D from a BufferedImage draw in
> to
> it, then copy the image data over to an SWT image and draw that on
> screen...
> then thought, I better check to see if anyone else had done that already
> and
> they had (probably better than I would have as well) :
>
> http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/SWT2DUnicode.htm
>
>
>
> So after lifting that code and tinkering around, for your consideration,
> here is version 0.0.1 of the Pivot WTKX Editor Eclipse plugin:
>
>
> http://dl.dropbox.com/u/2451973/pivot/plugins/org.apache.pivot.wtkxeditor_0.0.1.jar
>
> It has a new file wizard and associates WTKX files to the WTKX editor.
>
> However, since WTKX's base type is XML (and I needed to use that
> association
> to get the code work) it may open the built in XML Editor.  Simply close
> this, right click on the WTKX file and choose Open With -> Pivot WTKX
> Editor
> and it should open an XML editor with 3 pages, the 3rd being 'preview'.
>
> Note that there's very little error checking going and it's basically
> parsing your WTKX as you type.  Once you hit preview it renderers your WTKX
> *if it is valid* (my next task is to report errors).
>
> You will need to use *Eclipse 3.5* and have the *Web Standard Tools*
> feature
> installed (you can get this from the Eclipse update site : Help -> Install
> Software... ).
>
> For quick installation, just drop it in to your eclipse/dropins folder and
> restart Eclipse.  If that doesn't seem to work, move it in your
> eclipse/plugins folder.
>
> Obviously, there's lots of things still to do and that could be done with
> this - all disclaimers apply! =)
>
> Also, I need to work out where to put the source and how to integrate it
> with the build - if at all.
>
> Feedback, bug reports, suggestions, all welcome. :)
>
> Cheers,
> Chris
>
>
>
>
> 2009/11/15 Christopher Brind <br...@brindy.org.uk>
>
> > Thanks Todd, will give that a whirl later.
> >
> > On 15 Nov 2009 13:09, "Todd Volkert" <tv...@gmail.com> wrote:
> >
> > My guess is that it's because Button is an abstract class - try
> <PushButton
> > buttonData="Sumit" />.   Also, I think you should be calling
> > window.setContent(c) instead of window.add(c).
> >
> > Give those a shot, and hopefully it'll work - exciting stuff!
> >
> > -T
> >
> > On Sun, Nov 15, 2009 at 7:25 AM, Christopher Brind <brindy@brindy.org.uk
> > >wrote:
> >
> > > Typical - I just hit send and then I realise I can create my own
> Graphics
> > > 2D > sub-class and ju...
> >
> >
>

Re: problems building an eclipse plugin

Posted by Sandro Martini <sa...@gmail.com>.
> Technically, I'm not sure that we can split the trunk across two
> repositories. Even if we could, I don't think it is advisable from a
> licensing standpoint.
Right.

> I actually think the current project division makes sense. It might promote
> confusion to try to merge them into a single project (and would only become
> more confusing as new projects were created). Just my 2 cents.
I agree, but in my vision I'd like to have some of the core developers
(like you or Todd) to own one of these sites ... and if i remember
well on Google Code only a limited number of sites can be opened per
person, so the reason to try to merge more in one. But for too
different projects (and complex) like pivot-jfree and pivot-eclipse I
agree that probably a separation of sites  is cleaner.


Merge of subprojects in a single site probably makes sense for
extended components, "strange" demos, etc ... let's see in the future.

Bye

Re: problems building an eclipse plugin

Posted by Greg Brown <gk...@mac.com>.
> So, what do you think on move all that code inside a (new) subproject
> inside the trunk  (but I'd prefer to keep it in the Google Code site)

Technically, I'm not sure that we can split the trunk across two  
repositories. Even if we could, I don't think it is advisable from a  
licensing standpoint.

> But a question:
> instead of fragmenting Pivot extensions in more sites, what do you
> think to refactor the existing pivot-jfree Or create a new
> (pivot-stuff, pivot-extensions, etc) ?

I actually think the current project division makes sense. It might  
promote confusion to try to merge them into a single project (and  
would only become more confusing as new projects were created). Just  
my 2 cents.



Re: problems building an eclipse plugin

Posted by Sandro Martini <sa...@gmail.com>.
Hi,
for example in Pivot all the drawing/graphics code uses AWT and
Graphics2D features, available in Java 6 ... introducing a dependency
on SWT (and a lot of "external" packages, not used by existing
classes) to me seems wrong, at least in the core package.

Oh, Greg just answered like me :-) .

So, what do you think on move all that code inside a (new) subproject
inside the trunk  (but I'd prefer to keep it in the Google Code site)
? In this way maybe we could leave the build as is, and these projects
should only depend on existing jars (where possible, otherwise
regenerate them).


But a question:
instead of fragmenting Pivot extensions in more sites, what do you
think to refactor the existing pivot-jfree Or create a new
(pivot-stuff, pivot-extensions, etc) ?
And then move there the pivot-jfree and the other (pivot-eclipse,
pivot-osgi, etc), as independent subprojects there ?

And last, who better than our Pivot "President" to open and have the
rights in that site (maximum respect :-) ) ?


Comments ?

Bye,
Sandro

Re: problems building an eclipse plugin

Posted by Greg Brown <gk...@mac.com>.
Ah, OK - I just found the relevant thread in the mail archive.

I agree with you that including this in the platform might introduce  
too many dependencies. Putting it on Google Code would allow us to  
avoid that issue as well as sidestep any potential legal issues. You  
could potentially do something similar to what we have done with Pivot/ 
JFree:

http://code.google.com/p/pivot-jfree/

Maybe you could call it pivot-eclipse?


On Nov 17, 2009, at 9:38 AM, Christopher Brind wrote:

> No worries...
>
> Apart from the Pivot codebase it depends on these Eclipse plugins :
>
> org.eclipse.jface.text,
> org.eclipse.core.resources,
> org.eclipse.ui,
> org.eclipse.ui.editors,
> org.eclipse.ui.ide,
> org.eclipse.core.runtime,
> org.eclipse.wst.xml.ui,
> org.eclipse.wst.sse.ui
>
> I have the "Eclipse 3.5 IDE for Java EE Developers" with "Eclipse  
> Platform"
> and "Java EE IDE" features.  These appear to provide all the  
> dependencies.
>
> Cheers,
> Chris
>
>
>
> 2009/11/17 Greg Brown <gk...@mac.com>
>
>> given the complexity of eclipse and its dependency and  
>> requirements, I
>>> fear to add it in the core pivot project.
>>>
>>
>> What kind of dependencies are we talking about here (apologies - I  
>> haven't
>> been following this discussion that closely).
>> G
>>
>>
>>


Re: problems building an eclipse plugin

Posted by Christopher Brind <ch...@googlemail.com>.
No worries...

Apart from the Pivot codebase it depends on these Eclipse plugins :

org.eclipse.jface.text,
 org.eclipse.core.resources,
 org.eclipse.ui,
 org.eclipse.ui.editors,
 org.eclipse.ui.ide,
 org.eclipse.core.runtime,
 org.eclipse.wst.xml.ui,
 org.eclipse.wst.sse.ui

I have the "Eclipse 3.5 IDE for Java EE Developers" with "Eclipse Platform"
and "Java EE IDE" features.  These appear to provide all the dependencies.

Cheers,
Chris



2009/11/17 Greg Brown <gk...@mac.com>

> given the complexity of eclipse and its dependency and requirements, I
>> fear to add it in the core pivot project.
>>
>
> What kind of dependencies are we talking about here (apologies - I haven't
> been following this discussion that closely).
> G
>
>
>

Re: problems building an eclipse plugin

Posted by Greg Brown <gk...@mac.com>.
> given the complexity of eclipse and its dependency and requirements, I
> fear to add it in the core pivot project.

What kind of dependencies are we talking about here (apologies - I  
haven't been following this discussion that closely).
G



Re: problems building an eclipse plugin

Posted by Sandro Martini <sa...@gmail.com>.
Hi to all,
some reflexions on this, just my opinion ... to discuss:

given the complexity of eclipse and its dependency and requirements, I
fear to add it in the core pivot project.
But don't get me wrong, I think this could be a great addition to Pivot.

Only I think it not belongs to the core platform, and the same for Bnd
and other OSGi related tools (at least at the moment). As Todd said,
we could put all this stuff under out project on Google Code, also the
OSGi-fy of Pivot jars.

Some time ago I proposed to change that project to something like
Pivot-stuff (like Wicket ...), a place where to put all Pivot-related
things but that not belongs to the core platform.


Under tools I'd put all our utilities, but without external
dependencies (if possible, or to Apache libraries, to avoid license
problems), and maybe for the 2.0 also a GUI Builder, but all done in
our code.

> How essential is it that the build script we have is the main mechanism for building the release?
It's the standard way of work, as most of us (and others, don't forget
our current and future users).
> Is there scope for any manual process?
Yes, i think for all this stuff, but not for Pivot itself.


Again, don't get me wrong ... my point of view here is only to keep
Pivot as simple as possible, also in its build and dependencies.

Comments ?


Bye,
Sandro

Re: problems building an eclipse plugin

Posted by Christopher Brind <ch...@googlemail.com>.
Thanks Todd,

A few vaguely coherent thoughts in line before I rush for my train home ...

2009/11/16 Todd Volkert <tv...@gmail.com>

> That's sweet, Chris!


> What's also cool is that when we get around to writing a full-fledged
> SWTApplicationContext, that trick with rendering a BufferedImage to the SWT
> graphics context will come in handy.
>
>
I presume it's OK to put the code behind that trick in our code base?  It
has an IBM copyright, but it states that anyone can do anything with it.


> With respect to where to put the code and how to integrate it into the
> build, the obvious place would be in the tools package, but since it will
> introduce a dependency on the Eclipse libraries, what's the associated
> license?  If it's not compatible, we'll either have to (a) host it at
> Google
> Code with the JFreeChart stuff, or (b) just tell the developer who wishes
> to
> build it to get the required jars somehow and put them on the classpath,
> like we do with JUnit.
>

My preference would of course be to put it in the Pivot code base.  My
understanding is that Apache License and Eclipse Public License are broadly
compatible - perhaps Martjin can comment on this?

The main issue in my mind is how to actually build it.

I think the Eclipse community would probably recommended PDE which can be
executed from the command line.  However it requires an appropriate Eclipse
environment handy and is dependency hell if the builder does not have the
exact right setup.  This page is a bit old, but describes how to do it and
as far as I'm aware the process hasn't changed much:
http://www.eclipse.org/articles/Article-PDE-Automation/automation.html

How essential is it that the build script we have is the main mechanism for
building the release?  Is there scope for any manual process?

If we can do it manually using a 'Target Platform' configuration would
ensure that the builder has the right plugin dependencies (though doesn't
help resolve them) and it is possible to sign the plugins as they are being
exported from Eclipse.

Also, I have embedded the Pivot libraries in to the plugin - it would
probably be desirable to OSGify the jars but that will affect our existing
build process as we'll need to generate appropriate MANIFEST.MF files.
 There are tools to do this (e.g. bnd - http://www.aqute.biz/Code/Bnd ) but
I suspect bnd would become an external dependency (like JUnit).

Externalising the Pivot JARS as OSGi bundles then makes us have to group
them all together in to a 'feature' - not a problem but it is another build
artefact we'd need to create and deal with.  And that said, it is
conceivable we'll have more plugins in the future, and maybe even an entire
RCP build.

Actually, if we go down the Bnd route then building the Pivot plugin might
not be that arduous - we would just need to make sure the Eclipse
dependencies are available.  Again this can be an 'external' dependency like
JUnit but I'm starting to feel things becoming a bit too heavy on the
external dependencies.

Cheers,
Chris



>
> -T
>
> On Sun, Nov 15, 2009 at 12:22 PM, Christopher Brind <brindy@brindy.org.uk
> >wrote:
>
> > I had an idea ... I'll just use a Graphics2D from a BufferedImage draw in
> > to
> > it, then copy the image data over to an SWT image and draw that on
> > screen...
> > then thought, I better check to see if anyone else had done that already
> > and
> > they had (probably better than I would have as well) :
> >
> > http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/SWT2DUnicode.htm
> >
> >
> >
> > So after lifting that code and tinkering around, for your consideration,
> > here is version 0.0.1 of the Pivot WTKX Editor Eclipse plugin:
> >
> >
> >
> http://dl.dropbox.com/u/2451973/pivot/plugins/org.apache.pivot.wtkxeditor_0.0.1.jar
> >
> > It has a new file wizard and associates WTKX files to the WTKX editor.
> >
> > However, since WTKX's base type is XML (and I needed to use that
> > association
> > to get the code work) it may open the built in XML Editor.  Simply close
> > this, right click on the WTKX file and choose Open With -> Pivot WTKX
> > Editor
> > and it should open an XML editor with 3 pages, the 3rd being 'preview'.
> >
> > Note that there's very little error checking going and it's basically
> > parsing your WTKX as you type.  Once you hit preview it renderers your
> WTKX
> > *if it is valid* (my next task is to report errors).
> >
> > You will need to use *Eclipse 3.5* and have the *Web Standard Tools*
> > feature
> > installed (you can get this from the Eclipse update site : Help ->
> Install
> > Software... ).
> >
> > For quick installation, just drop it in to your eclipse/dropins folder
> and
> > restart Eclipse.  If that doesn't seem to work, move it in your
> > eclipse/plugins folder.
> >
> > Obviously, there's lots of things still to do and that could be done with
> > this - all disclaimers apply! =)
> >
> > Also, I need to work out where to put the source and how to integrate it
> > with the build - if at all.
> >
> > Feedback, bug reports, suggestions, all welcome. :)
> >
> > Cheers,
> > Chris
> >
> >
> >
> >
> > 2009/11/15 Christopher Brind <br...@brindy.org.uk>
> >
> > > Thanks Todd, will give that a whirl later.
> > >
> > > On 15 Nov 2009 13:09, "Todd Volkert" <tv...@gmail.com> wrote:
> > >
> > > My guess is that it's because Button is an abstract class - try
> > <PushButton
> > > buttonData="Sumit" />.   Also, I think you should be calling
> > > window.setContent(c) instead of window.add(c).
> > >
> > > Give those a shot, and hopefully it'll work - exciting stuff!
> > >
> > > -T
> > >
> > > On Sun, Nov 15, 2009 at 7:25 AM, Christopher Brind <
> brindy@brindy.org.uk
> > > >wrote:
> > >
> > > > Typical - I just hit send and then I realise I can create my own
> > Graphics
> > > > 2D > sub-class and ju...
> > >
> > >
> >
>

Re: problems building an eclipse plugin

Posted by Todd Volkert <tv...@gmail.com>.
That's sweet, Chris!

What's also cool is that when we get around to writing a full-fledged
SWTApplicationContext, that trick with rendering a BufferedImage to the SWT
graphics context will come in handy.

With respect to where to put the code and how to integrate it into the
build, the obvious place would be in the tools package, but since it will
introduce a dependency on the Eclipse libraries, what's the associated
license?  If it's not compatible, we'll either have to (a) host it at Google
Code with the JFreeChart stuff, or (b) just tell the developer who wishes to
build it to get the required jars somehow and put them on the classpath,
like we do with JUnit.

-T

On Sun, Nov 15, 2009 at 12:22 PM, Christopher Brind <br...@brindy.org.uk>wrote:

> I had an idea ... I'll just use a Graphics2D from a BufferedImage draw in
> to
> it, then copy the image data over to an SWT image and draw that on
> screen...
> then thought, I better check to see if anyone else had done that already
> and
> they had (probably better than I would have as well) :
>
> http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/SWT2DUnicode.htm
>
>
>
> So after lifting that code and tinkering around, for your consideration,
> here is version 0.0.1 of the Pivot WTKX Editor Eclipse plugin:
>
>
> http://dl.dropbox.com/u/2451973/pivot/plugins/org.apache.pivot.wtkxeditor_0.0.1.jar
>
> It has a new file wizard and associates WTKX files to the WTKX editor.
>
> However, since WTKX's base type is XML (and I needed to use that
> association
> to get the code work) it may open the built in XML Editor.  Simply close
> this, right click on the WTKX file and choose Open With -> Pivot WTKX
> Editor
> and it should open an XML editor with 3 pages, the 3rd being 'preview'.
>
> Note that there's very little error checking going and it's basically
> parsing your WTKX as you type.  Once you hit preview it renderers your WTKX
> *if it is valid* (my next task is to report errors).
>
> You will need to use *Eclipse 3.5* and have the *Web Standard Tools*
> feature
> installed (you can get this from the Eclipse update site : Help -> Install
> Software... ).
>
> For quick installation, just drop it in to your eclipse/dropins folder and
> restart Eclipse.  If that doesn't seem to work, move it in your
> eclipse/plugins folder.
>
> Obviously, there's lots of things still to do and that could be done with
> this - all disclaimers apply! =)
>
> Also, I need to work out where to put the source and how to integrate it
> with the build - if at all.
>
> Feedback, bug reports, suggestions, all welcome. :)
>
> Cheers,
> Chris
>
>
>
>
> 2009/11/15 Christopher Brind <br...@brindy.org.uk>
>
> > Thanks Todd, will give that a whirl later.
> >
> > On 15 Nov 2009 13:09, "Todd Volkert" <tv...@gmail.com> wrote:
> >
> > My guess is that it's because Button is an abstract class - try
> <PushButton
> > buttonData="Sumit" />.   Also, I think you should be calling
> > window.setContent(c) instead of window.add(c).
> >
> > Give those a shot, and hopefully it'll work - exciting stuff!
> >
> > -T
> >
> > On Sun, Nov 15, 2009 at 7:25 AM, Christopher Brind <brindy@brindy.org.uk
> > >wrote:
> >
> > > Typical - I just hit send and then I realise I can create my own
> Graphics
> > > 2D > sub-class and ju...
> >
> >
>

Re: problems building an eclipse plugin

Posted by Christopher Brind <br...@brindy.org.uk>.
Thanks Sandro, but Todd was right that it was because I was using the
abstract button class.  I use about 3 different ui apis so I get confused
sometimes ;) ... partly why I wanted the Eclipse plugin.  :)

Cheers
Chris

On 16 Nov 2009 08:42, "Sandro Martini" <sa...@gmail.com> wrote:

Hi Chris,
great work ... I'll try as soon as possible.

Only a idea: the error you have, can be related to Pivot GUI
components not Serializable ?

Bye

Re: problems building an eclipse plugin

Posted by Sandro Martini <sa...@gmail.com>.
Hi Chris,
great work ... I'll try as soon as possible.

Only a idea: the error you have, can be related to Pivot GUI
components not Serializable ?

Bye

Re: problems building an eclipse plugin

Posted by Christopher Brind <br...@brindy.org.uk>.
I had an idea ... I'll just use a Graphics2D from a BufferedImage draw in to
it, then copy the image data over to an SWT image and draw that on screen...
then thought, I better check to see if anyone else had done that already and
they had (probably better than I would have as well) :

http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/SWT2DUnicode.htm



So after lifting that code and tinkering around, for your consideration,
here is version 0.0.1 of the Pivot WTKX Editor Eclipse plugin:

http://dl.dropbox.com/u/2451973/pivot/plugins/org.apache.pivot.wtkxeditor_0.0.1.jar

It has a new file wizard and associates WTKX files to the WTKX editor.

However, since WTKX's base type is XML (and I needed to use that association
to get the code work) it may open the built in XML Editor.  Simply close
this, right click on the WTKX file and choose Open With -> Pivot WTKX Editor
and it should open an XML editor with 3 pages, the 3rd being 'preview'.

Note that there's very little error checking going and it's basically
parsing your WTKX as you type.  Once you hit preview it renderers your WTKX
*if it is valid* (my next task is to report errors).

You will need to use *Eclipse 3.5* and have the *Web Standard Tools* feature
installed (you can get this from the Eclipse update site : Help -> Install
Software... ).

For quick installation, just drop it in to your eclipse/dropins folder and
restart Eclipse.  If that doesn't seem to work, move it in your
eclipse/plugins folder.

Obviously, there's lots of things still to do and that could be done with
this - all disclaimers apply! =)

Also, I need to work out where to put the source and how to integrate it
with the build - if at all.

Feedback, bug reports, suggestions, all welcome. :)

Cheers,
Chris




2009/11/15 Christopher Brind <br...@brindy.org.uk>

> Thanks Todd, will give that a whirl later.
>
> On 15 Nov 2009 13:09, "Todd Volkert" <tv...@gmail.com> wrote:
>
> My guess is that it's because Button is an abstract class - try <PushButton
> buttonData="Sumit" />.   Also, I think you should be calling
> window.setContent(c) instead of window.add(c).
>
> Give those a shot, and hopefully it'll work - exciting stuff!
>
> -T
>
> On Sun, Nov 15, 2009 at 7:25 AM, Christopher Brind <brindy@brindy.org.uk
> >wrote:
>
> > Typical - I just hit send and then I realise I can create my own Graphics
> > 2D > sub-class and ju...
>
>

Re: problems building an eclipse plugin

Posted by Christopher Brind <br...@brindy.org.uk>.
Thanks Todd, will give that a whirl later.

On 15 Nov 2009 13:09, "Todd Volkert" <tv...@gmail.com> wrote:

My guess is that it's because Button is an abstract class - try <PushButton
buttonData="Sumit" />.   Also, I think you should be calling
window.setContent(c) instead of window.add(c).

Give those a shot, and hopefully it'll work - exciting stuff!

-T

On Sun, Nov 15, 2009 at 7:25 AM, Christopher Brind <brindy@brindy.org.uk
>wrote:

> Typical - I just hit send and then I realise I can create my own Graphics
> 2D > sub-class and ju...

Re: problems building an eclipse plugin

Posted by Todd Volkert <tv...@gmail.com>.
My guess is that it's because Button is an abstract class - try <PushButton
buttonData="Sumit" />.   Also, I think you should be calling
window.setContent(c) instead of window.add(c).

Give those a shot, and hopefully it'll work - exciting stuff!

-T

On Sun, Nov 15, 2009 at 7:25 AM, Christopher Brind <br...@brindy.org.uk>wrote:

> Typical - I just hit send and then I realise I can create my own Graphics
> 2D
> sub-class and just delegate to a Graphics2D created elsewhere, or to a SWT
> graphics context. I'll have a play with this later, but any ideas about the
> instantiation problem?
>
> Thanks,
> Chris
>
>
>
> 2009/11/15 Christopher Brind <br...@brindy.org.uk>
>
> > Hi,
> >
> > I don't want to get people too excited, but I'm working on an Eclipse
> > plugin for Pivot.  At the moment it simply recognises WTKX as an XML
> format,
> > and I've extended the XML editor to add a new page called 'Preview'.
> >
> > My original plan was use the SWT AWT bridge and some very simple code to
> > render the WTKX.  That is, I don't render the the contents of the WTKX
> using
> > Pivot code, I simply call paint(Graphics2D) directly.
> >
> > However, I've hit a couple of problems:
> >
> > 1) SWT AWT Bridge doesn't work on Mac!
> >
> > The problem is also described here, ignoring the fact that the original
> > poster isn't actually using the SWT/AWT bridge - he has come across the
> same
> > problem as me, that something in Eclipse basically breaks AWT.  In his
> case
> > he can run it on the command line, but when it comes to using the SWT/AWT
> > bridge, this has fail written all over it.
> >
> > I'm looking in to this in more detail, but I wonder if it would be worth
> > abstracting the graphics context so that it isn't AWT specific?  Perhaps
> a
> > lot of work, but it would mean I could implement a pure SWT version for
> > rendering in Eclipse.
> >
> >
> >
> > 2) Instantiation problems when deserialising the WTKX
> >
> > Here's my rendering code, but in a stand alone way outside of Eclipse (I
> > got here by trying to debug the SWT/AWT problem) :
> >
> > public static void main(String[] args) throws Exception {
> >
> >
> >  // Frame frame = new Frame();
> >
> > Properties props = System.getProperties();
> >
> > Iterator iter = props.keySet().iterator();
> >
> > while (iter.hasNext()) {
> >
> > String key = (String) iter.next();
> >
> > System.out.println(key + " : " + props.getProperty(key));
> >
> > }
> >
> >
> >  JFrame frame = new JFrame();
> >
> > frame.setSize(800, 600);
> >
> > frame.setVisible(true);
> >
> >
> >  JApplet applet = new JApplet();
> >
> > applet.setSize(800, 600);
> >
> > frame.add(applet);
> >
> > frame.setVisible(true);
> >
> >
> >  WTKXSerializer wtkx = new WTKXSerializer();
> >
> > Object o = wtkx.readObject(new FileInputStream("assets/template.wtkx"));
> >
> >
> >  Window window = null;
> >
> > if (o instanceof Window) {
> >
> > window = (Window) o;
> >
> > } else {
> >
> > window = new Window();
> >
> >
> >  Component c = (Component) o;
> >
> > c.setSize(applet.getWidth(), applet.getHeight());
> >
> >
> >  window.add(c);
> >
> > }
> >
> >
> >  window.setSize(applet.getWidth(), applet.getHeight());
> >
> > window.validate();
> >
> >
> >  Graphics2D g2d = (Graphics2D) applet.getGraphics();
> >
> > window.paint(g2d);
> >
> >
> >  }
> >
> > Similar code will be used inside the Eclipse plugin to render the WTKX in
> > the Eclipse editor - as you can see, it's a render-only process, it
> doesn't
> > handle events or anything like that.
> >
> > Now this actually works OK for the given WTKX:
> >
> > <BoxPane xmlns="org.apache.pivot.wtk"
> >
> >     xmlns:wtkx="http://pivot.apache.org/wtkx">
> >
> >          <Label wtkx:id="label" text="Enter your name: "/>
> >
> >         <TextInput preferredWidth="200" />
> >
> >
> >
> > </BoxPane>
> >
> > But, if I drop in a Button, like this:
> >
> > <BoxPane xmlns="org.apache.pivot.wtk"
> >
> >     xmlns:wtkx="http://pivot.apache.org/wtkx">
> >
> >          <Label wtkx:id="label" text="Enter your name: "/>
> >
> >         <TextInput preferredWidth="200" />
> >
> >         <Button label="Submit" />
> >
> >
> >
> > </BoxPane>
> >
> > I get some exceptions:
> >
> > An error occurred while processing  element <BoxPane> starting at line
> > number 6:
> > org.apache.pivot.serialization.SerializationException:
> > java.lang.InstantiationException
> > at
> >
> org.apache.pivot.wtkx.WTKXSerializer.processStartElement(WTKXSerializer.java:585)
> >  at
> > org.apache.pivot.wtkx.WTKXSerializer.readObject(WTKXSerializer.java:426)
> > at
> >
> org.apache.pivot.wtkxeditor.editors.WTKXPreviewer.main(WTKXPreviewer.java:37)
> > Caused by: java.lang.InstantiationException
> > at
> >
> sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:30)
> >  at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> > at java.lang.Class.newInstance0(Class.java:355)
> >  at java.lang.Class.newInstance(Class.java:308)
> > at
> >
> org.apache.pivot.wtkx.WTKXSerializer.processStartElement(WTKXSerializer.java:583)
> >  ... 2 more
> > Exception in thread "main"
> > org.apache.pivot.serialization.SerializationException:
> > java.lang.InstantiationException
> >  at
> >
> org.apache.pivot.wtkx.WTKXSerializer.processStartElement(WTKXSerializer.java:585)
> > at
> org.apache.pivot.wtkx.WTKXSerializer.readObject(WTKXSerializer.java:426)
> >  at
> >
> org.apache.pivot.wtkxeditor.editors.WTKXPreviewer.main(WTKXPreviewer.java:37)
> > Caused by: java.lang.InstantiationException
> > at
> >
> sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:30)
> >  at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> > at java.lang.Class.newInstance0(Class.java:355)
> >  at java.lang.Class.newInstance(Class.java:308)
> > at
> >
> org.apache.pivot.wtkx.WTKXSerializer.processStartElement(WTKXSerializer.java:583)
> >  ... 2 more
> >
> >
> > I realise my circumventing the usual Pivot lifecycle might have something
> > to do with it, so any ideas?
> >
> > If I can get around problem #2 somehow I think I can still produce an
> alpha
> > version Eclipse plugin that will work on Windows/Linux, just not Mac =(
>  but
> > like I say - being able to implement a pure SWT graphics context would
> get
> > around that problem.
> >
> > Cheers,
> > Chris
> >
> >
> >
> >
>

Re: problems building an eclipse plugin

Posted by Christopher Brind <br...@brindy.org.uk>.
Typical - I just hit send and then I realise I can create my own Graphics 2D
sub-class and just delegate to a Graphics2D created elsewhere, or to a SWT
graphics context. I'll have a play with this later, but any ideas about the
instantiation problem?

Thanks,
Chris



2009/11/15 Christopher Brind <br...@brindy.org.uk>

> Hi,
>
> I don't want to get people too excited, but I'm working on an Eclipse
> plugin for Pivot.  At the moment it simply recognises WTKX as an XML format,
> and I've extended the XML editor to add a new page called 'Preview'.
>
> My original plan was use the SWT AWT bridge and some very simple code to
> render the WTKX.  That is, I don't render the the contents of the WTKX using
> Pivot code, I simply call paint(Graphics2D) directly.
>
> However, I've hit a couple of problems:
>
> 1) SWT AWT Bridge doesn't work on Mac!
>
> The problem is also described here, ignoring the fact that the original
> poster isn't actually using the SWT/AWT bridge - he has come across the same
> problem as me, that something in Eclipse basically breaks AWT.  In his case
> he can run it on the command line, but when it comes to using the SWT/AWT
> bridge, this has fail written all over it.
>
> I'm looking in to this in more detail, but I wonder if it would be worth
> abstracting the graphics context so that it isn't AWT specific?  Perhaps a
> lot of work, but it would mean I could implement a pure SWT version for
> rendering in Eclipse.
>
>
>
> 2) Instantiation problems when deserialising the WTKX
>
> Here's my rendering code, but in a stand alone way outside of Eclipse (I
> got here by trying to debug the SWT/AWT problem) :
>
> public static void main(String[] args) throws Exception {
>
>
>  // Frame frame = new Frame();
>
> Properties props = System.getProperties();
>
> Iterator iter = props.keySet().iterator();
>
> while (iter.hasNext()) {
>
> String key = (String) iter.next();
>
> System.out.println(key + " : " + props.getProperty(key));
>
> }
>
>
>  JFrame frame = new JFrame();
>
> frame.setSize(800, 600);
>
> frame.setVisible(true);
>
>
>  JApplet applet = new JApplet();
>
> applet.setSize(800, 600);
>
> frame.add(applet);
>
> frame.setVisible(true);
>
>
>  WTKXSerializer wtkx = new WTKXSerializer();
>
> Object o = wtkx.readObject(new FileInputStream("assets/template.wtkx"));
>
>
>  Window window = null;
>
> if (o instanceof Window) {
>
> window = (Window) o;
>
> } else {
>
> window = new Window();
>
>
>  Component c = (Component) o;
>
> c.setSize(applet.getWidth(), applet.getHeight());
>
>
>  window.add(c);
>
> }
>
>
>  window.setSize(applet.getWidth(), applet.getHeight());
>
> window.validate();
>
>
>  Graphics2D g2d = (Graphics2D) applet.getGraphics();
>
> window.paint(g2d);
>
>
>  }
>
> Similar code will be used inside the Eclipse plugin to render the WTKX in
> the Eclipse editor - as you can see, it's a render-only process, it doesn't
> handle events or anything like that.
>
> Now this actually works OK for the given WTKX:
>
> <BoxPane xmlns="org.apache.pivot.wtk"
>
>     xmlns:wtkx="http://pivot.apache.org/wtkx">
>
>          <Label wtkx:id="label" text="Enter your name: "/>
>
>         <TextInput preferredWidth="200" />
>
>
>
> </BoxPane>
>
> But, if I drop in a Button, like this:
>
> <BoxPane xmlns="org.apache.pivot.wtk"
>
>     xmlns:wtkx="http://pivot.apache.org/wtkx">
>
>          <Label wtkx:id="label" text="Enter your name: "/>
>
>         <TextInput preferredWidth="200" />
>
>         <Button label="Submit" />
>
>
>
> </BoxPane>
>
> I get some exceptions:
>
> An error occurred while processing  element <BoxPane> starting at line
> number 6:
> org.apache.pivot.serialization.SerializationException:
> java.lang.InstantiationException
> at
> org.apache.pivot.wtkx.WTKXSerializer.processStartElement(WTKXSerializer.java:585)
>  at
> org.apache.pivot.wtkx.WTKXSerializer.readObject(WTKXSerializer.java:426)
> at
> org.apache.pivot.wtkxeditor.editors.WTKXPreviewer.main(WTKXPreviewer.java:37)
> Caused by: java.lang.InstantiationException
> at
> sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:30)
>  at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> at java.lang.Class.newInstance0(Class.java:355)
>  at java.lang.Class.newInstance(Class.java:308)
> at
> org.apache.pivot.wtkx.WTKXSerializer.processStartElement(WTKXSerializer.java:583)
>  ... 2 more
> Exception in thread "main"
> org.apache.pivot.serialization.SerializationException:
> java.lang.InstantiationException
>  at
> org.apache.pivot.wtkx.WTKXSerializer.processStartElement(WTKXSerializer.java:585)
> at org.apache.pivot.wtkx.WTKXSerializer.readObject(WTKXSerializer.java:426)
>  at
> org.apache.pivot.wtkxeditor.editors.WTKXPreviewer.main(WTKXPreviewer.java:37)
> Caused by: java.lang.InstantiationException
> at
> sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:30)
>  at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> at java.lang.Class.newInstance0(Class.java:355)
>  at java.lang.Class.newInstance(Class.java:308)
> at
> org.apache.pivot.wtkx.WTKXSerializer.processStartElement(WTKXSerializer.java:583)
>  ... 2 more
>
>
> I realise my circumventing the usual Pivot lifecycle might have something
> to do with it, so any ideas?
>
> If I can get around problem #2 somehow I think I can still produce an alpha
> version Eclipse plugin that will work on Windows/Linux, just not Mac =(  but
> like I say - being able to implement a pure SWT graphics context would get
> around that problem.
>
> Cheers,
> Chris
>
>
>
>