Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ve-dev] Using JEM to draw cartoon images of widgets


Hello Namrata,

I would not use JEM completely for something like this. Your model is static and doesn't require customer code. In that case I would suggest using the proxy part only, but use the IDE proxy registration instead of the remote vm registration. It will be much faster that way since you won't need to start and maintain a remote vm. Also it means that your project DOES NOT have to be a java project. To use remote vm you would need to have your customer's project be a java project.

I suggest using our 1.1M2 driver with the Eclipse 3.1RC1 (RC2 when it comes out), and the appropriate GEF/EMF. That has the latest fixes in it.

I suggest you use:
  1. org.eclipse.ve.internal.jfc.core.ComponentManager - This will handle the refresh and retrieval of the image. It can be your IVisualComponent (though in the M2 drop it is not an IVisualComponent, but in the next drop of VE 1.1 it will be an IVisualComponent all by itself, until then you will need to wrapper it).
  2. org.eclipse.jem.internal.proxy.ide.IDERegistration to start a registry that runs under the Eclipse JVM instead of a remote JVM. IDERegistration.createIDEPRoxyFactoryRegistry will probably be sufficient for your purposes. This would be sufficient if you do not need to access any classes other than a predefined set that you know about. If you need to access customer classes that come from a project at runtime, then you will need to use the remote vm instead.
  3. Use a org.eclipse.ve.internal.cde.core.ImageFigure and  org.eclipse.ve.internal.cde.core.ImageFigureController to work with the ComponentManager to get the image's size and the image itself.
  4. I would use org.eclipse.ve.internal.cde.core.ContentsGraphicalEditpart as the base editpart representing the white freeform surface (this would be put into the GraphicalViewer's setContents() method).
  5. Your Swing visual components (those that produce the images you wish to capture), should be in your plugin's library jar so that the IDERegistration registry can see them (using the createIDEProxyFactoryRegistry(name, pluginname, otherurls. In this case otherURLS can be null, then it will just look in your plugin (the plugin name passed in actually) for the classes that you are trying to create.
  6. Also, I'm pretty sure your Swing visual components need to be hosted within a JWindow to be able to get an image. We usually use a JDialog so that we can actually show it during development to see what is happening on the remote vm, but a JWindow would be more convienent because it wouldn't need an unused JFrame under the covers. You would need to put the JWindow way off-screen or it could show up (we use (10,000, 10,000)).
  7. Take a look at org.eclipse.ve.internal.jfc.core.ComponentGraphicalEditPart as an example. Do not use it directly, copy pieces of it instead. I would also look at how  org.eclipse.ve.internal.jfc.core.ComponentProxyAdapter works with the ComponentManager to tell it the image is invalid and how the ComponentManager then sends the image back.
  8. For the ComponentManager to work you will need to use the org.eclipse.ve.internal.cde.core.ModelChangeController. You will need to create a subclass of it. And you should subclass the GEF commandstack so that it will wrapper the call to execute within a call to the ModelChangeController (see . The change controller is important because one of the things it can do is to allow runnables to be queued up to the end of the transaction (the transaction is the execute of the command stack). We use this with the ComponentManager so that we don't get any new images until after the transaction is complete. If we didn't have the change controller, we wouldn't know when the transaction was complete and we would instead have to get a new image on every change. That can be a lot of extra images that aren't needed. For the stack I would subclass GEF's command stack and just override the execute, undo, redo, to do something like:

           public void execute(final Command aCommand) {
                modelChangeController.doModelChanges(new Runnable() {

                        public void run() {
                                CommandStack.this.super.execute(aCommand);
                        }
                }, false);
        }

This may be enough to get you started. I would start with the IDERegistry to see how to create your Swing visuals, then move up to ComponentManager to see how to get the images, and then finally up to the editparts to put it all together.

I'm sorry we don't have an example of this. We really do want to hightlight such capabilities.

Thanks,
Rich Kulp



"Namrata" <namrata@xxxxxxxxxxxxxx>
Sent by: ve-dev-bounces@xxxxxxxxxxx

06/13/2005 11:37 AM

Please respond to
Discussions people developing code for the Visual Editor project

To
<ve-dev@xxxxxxxxxxx>
cc
Subject
[ve-dev] Using JEM to draw cartoon images of widgets





 
Hi,
 
I'm evaluating the feasibility of developing a form designer. Our model is a static XML based model to represent AWT/Swing forms.
 
I want to develop an editor using EMF/GEF. For drawing the images, I want to reuse the VE internal functionality in the JEM plugin.
 
I looked at the VE source and the JEM test code, but its still confusing due to lack of a document. I will greatly appreciate any pointers on a high level description of how to use JEM to create the widgets in a seperate VM and scrape the cartoon images to display in the form designer.
 
In return I will document the JEM API and the usage in detail.
 
Thanks in advance.
Namrata_______________________________________________
ve-dev mailing list
ve-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ve-dev


Back to the top