Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Visual Editor (VE) » VE-inspired XML plugin?
VE-inspired XML plugin? [message #79188] Sat, 05 February 2005 22:50 Go to next message
Eclipse UserFriend
Originally posted by: mmt_nin.yahoo.com

I have been searching to try to find a way to either extend the Visual
Editor, or build a new plugin that does near the same. Can someone tell me
how to make a very similar plugin that you drag/drop widgets that
generates XML? Is there already such a plugin that I haven't found? Any
and all help is deeply appreciated.

-Thanks!
Re: VE-inspired XML plugin? [message #79271 is a reply to message #79188] Mon, 07 February 2005 12:36 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
That would be a great thing in my next project something like this would
rock. If I don't exists it would be great to start an project to provide
something like this if even possible at all. Maybe someone could tell us?:-)

Tom

Megan wrote:
> I have been searching to try to find a way to either extend the Visual
> Editor, or build a new plugin that does near the same. Can someone tell
> me how to make a very similar plugin that you drag/drop widgets that
> generates XML? Is there already such a plugin that I haven't found? Any
> and all help is deeply appreciated.
>
> -Thanks!
>
Re: VE-inspired XML plugin? [message #79300 is a reply to message #79188] Mon, 07 February 2005 17:52 Go to previous messageGo to next message
Joe Winchester is currently offline Joe WinchesterFriend
Messages: 496
Registered: July 2009
Senior Member
Hi Megan,

> I have been searching to try to find a way to either extend the Visual
> Editor, or build a new plugin that does near the same. Can someone tell
> me how to make a very similar plugin that you drag/drop widgets that
> generates XML? Is there already such a plugin that I haven't found? Any
> and all help is deeply appreciated.

The VE can be used for this, the only problem is that we don't really
document how. At one time we had an example plugin where you could open
an XML file (actually the EMF model that the visual editor uses
internally). This model is then able to be manipulated visually the
same way the VE can be now, the only difference is that there is no
..java code being updated or listened to for changes.

Could you please open a bugzilla feature request for us to get this
example working again and I think it will be a good starting point for
you to look at.

Best regards,

Joe Winchester
Re: VE-inspired XML plugin? [message #79315 is a reply to message #79300] Mon, 07 February 2005 13:55 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Joe Winchester wrote:
> Hi Megan,
>
>> I have been searching to try to find a way to either extend the Visual
>> Editor, or build a new plugin that does near the same. Can someone
>> tell me how to make a very similar plugin that you drag/drop widgets
>> that generates XML? Is there already such a plugin that I haven't
>> found? Any and all help is deeply appreciated.
>
>
> The VE can be used for this, the only problem is that we don't really
> document how. At one time we had an example plugin where you could open
> an XML file (actually the EMF model that the visual editor uses
> internally). This model is then able to be manipulated visually the
> same way the VE can be now, the only difference is that there is no
> .java code being updated or listened to for changes.
>
> Could you please open a bugzilla feature request for us to get this
> example working again and I think it will be a good starting point for
> you to look at.
>
> Best regards,
>
> Joe Winchester
>

Thanks Joe. I do so. Are there any documents I could read about the
design of VE or do only have the source code (can I get it from cvs?).
Do you suggest any documents I have to read before I can jump in and
start reading the sources.

Tom
Re: VE-inspired XML plugin? [message #79474 is a reply to message #79315] Tue, 08 February 2005 12:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tomAtLinux.gmx.at

Tom Schindl wrote:
> Joe Winchester wrote:
>
>> Hi Megan,
>>
>>> I have been searching to try to find a way to either extend the
>>> Visual Editor, or build a new plugin that does near the same. Can
>>> someone tell me how to make a very similar plugin that you drag/drop
>>> widgets that generates XML? Is there already such a plugin that I
>>> haven't found? Any and all help is deeply appreciated.
>>
>>
>>
>> The VE can be used for this, the only problem is that we don't really
>> document how. At one time we had an example plugin where you could
>> open an XML file (actually the EMF model that the visual editor uses
>> internally). This model is then able to be manipulated visually the
>> same way the VE can be now, the only difference is that there is no
>> .java code being updated or listened to for changes.
>>
>> Could you please open a bugzilla feature request for us to get this
>> example working again and I think it will be a good starting point for
>> you to look at.

Done was not sure what component is the right maybe you have to modify:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=84569
Re: VE-inspired XML plugin? [message #79576 is a reply to message #79188] Wed, 09 February 2005 03:13 Go to previous messageGo to next message
Dave Orme is currently offline Dave OrmeFriend
Messages: 424
Registered: July 2009
Senior Member
Megan wrote:
> I have been searching to try to find a way to either extend the Visual
> Editor, or build a new plugin that does near the same. Can someone tell
> me how to make a very similar plugin that you drag/drop widgets that
> generates XML? Is there already such a plugin that I haven't found? Any
> and all help is deeply appreciated.

There's not a plugin for VE that lets you do this, but the language and
the engine parts have been designed.

See xswt.sourceforge.net for details. The Update Manager URL is:

http://xswt.sourceforge.net/updates

Right now, there is a plug-in that just allows you to preview an XSWT
layout as you type it (whenever you save).

If you install via Update Manager, you will get a File/New wizard for
creating XSWT files. And the preview pane is available through
Window|Show View|Other..., then expand the XSWT node in the tree.

I had a conversation today with Gili about integrating this engine into
VE and this looks like something that the VE team might be interested in
doing.

Would anyone here be interested in helping?


Regards,

Dave Orme
--
Visual Editor Project lead
http://www.db4o.com -- The Open-source Java Object Database
Re: VE-inspired XML plugin? [message #80107 is a reply to message #79576] Mon, 14 February 2005 22:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tomAtLinux.gmx.at

David J. Orme wrote:
> Megan wrote:
>
>> I have been searching to try to find a way to either extend the Visual
>> Editor, or build a new plugin that does near the same. Can someone
>> tell me how to make a very similar plugin that you drag/drop widgets
>> that generates XML? Is there already such a plugin that I haven't
>> found? Any and all help is deeply appreciated.
>
>
> There's not a plugin for VE that lets you do this, but the language and
> the engine parts have been designed.
>
> See xswt.sourceforge.net for details. The Update Manager URL is:
>
> http://xswt.sourceforge.net/updates
>
> Right now, there is a plug-in that just allows you to preview an XSWT
> layout as you type it (whenever you save).
>
> If you install via Update Manager, you will get a File/New wizard for
> creating XSWT files. And the preview pane is available through
> Window|Show View|Other..., then expand the XSWT node in the tree.
>
> I had a conversation today with Gili about integrating this engine into
> VE and this looks like something that the VE team might be interested in
> doing.
>
> Would anyone here be interested in helping?
>

As already said I would but I don't know the internals of the VE and
XSWT. As a first step I checked out the sources of XSWT. Is there any
spec, DTD which tells me what XML-Elements exists? Can I use my own in
XSWT e.g. my own NumberWidget which derives from Text?

>
> Regards,
>
> Dave Orme
Re: VE-inspired XML plugin? [message #80225 is a reply to message #80107] Wed, 16 February 2005 13:56 Go to previous messageGo to next message
Gili Mendel is currently offline Gili MendelFriend
Messages: 338
Registered: July 2009
Senior Member
Tom Schindl wrote:

>
> As already said I would but I don't know the internals of the VE and
> XSWT. As a first step I checked out the sources of XSWT. Is there any
> spec, DTD which tells me what XML-Elements exists? Can I use my own in
> XSWT e.g. my own NumberWidget which derives from Text?
>
>>
>> Regards,
>>
>> Dave Orme

XSWT does not have a DTD per se.. it is based on reflection. There is a
bit of schema based notation... see more on
http://xswt.sourceforge.net/cgi-bin/wiki?XSWTCoreEngineDocum entation
Re: VE-inspired XML plugin? [message #80308 is a reply to message #79315] Wed, 16 February 2005 18:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: michail_matjuchin.at.ibm.com

Tom Schindl wrote:

> Joe Winchester wrote:
>> Hi Megan,
>>
>>> I have been searching to try to find a way to either extend the Visual
>>> Editor, or build a new plugin that does near the same. Can someone
>>> tell me how to make a very similar plugin that you drag/drop widgets
>>> that generates XML? Is there already such a plugin that I haven't
>>> found? Any and all help is deeply appreciated.
>>
>>
>> The VE can be used for this, the only problem is that we don't really
>> document how. At one time we had an example plugin where you could open
>> an XML file (actually the EMF model that the visual editor uses
>> internally). This model is then able to be manipulated visually the
>> same way the VE can be now, the only difference is that there is no
>> .java code being updated or listened to for changes.
>>
>> Could you please open a bugzilla feature request for us to get this
>> example working again and I think it will be a good starting point for
>> you to look at.
>>
>> Best regards,
>>
>> Joe Winchester
>>

> Thanks Joe. I do so. Are there any documents I could read about the
> design of VE or do only have the source code (can I get it from cvs?).
> Do you suggest any documents I have to read before I can jump in and
> start reading the sources.

> Tom

it is easy:

public class SampleAction implements IWorkbenchWindowActionDelegate {
private IWorkbenchWindow window;

private ISelection fSelection = null;

/**
* The constructor.
*/
public SampleAction() {
}

public void selectionChanged(IAction action, ISelection selection) {
fSelection = selection;

}
/**
* The action has been activated. The argument of the method represents
the
* 'real' action sitting in the workbench UI.
*
* @see IWorkbenchWindowActionDelegate#run
*/
public void run(IAction action) {
// *****
if (fSelection instanceof IStructuredSelection
&& ((IStructuredSelection) fSelection).size() == 1) {

Object object = ((IStructuredSelection) fSelection)
.getFirstElement();
if(object instanceof EditPart) {
EditPart editPart=(EditPart)object;
IJavaObjectInstance component = (IJavaObjectInstance)
editPart.getModel();
JavaClass modelType = (JavaClass) component.eClass();
//*****
EditDomain ed = EditDomain.getEditDomain(editPart);
DiagramData dd=ed.getDiagramData();
//*****
ResourceSet resSet = new ResourceSetImpl();
URI fileURI = URI.createFileURI("c:/temp/aaa.xml");
Resource resource =
resSet.createResource(fileURI);

//*****
resource.getContents().add(dd);
//
try {
resource.save(Collections.EMPTY_MAP);
}
catch(Exception ex) {
ex.printStackTrace();
}
}
}

}
Re: VE-inspired XML plugin? [message #80340 is a reply to message #80308] Wed, 16 February 2005 23:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

> DiagramData dd=ed.getDiagramData();
> //*****
> ResourceSet resSet = new ResourceSetImpl();
> URI fileURI = URI.createFileURI("c:/temp/aaa.xml");
> Resource resource =
> resSet.createResource(fileURI);
>
> //*****
> resource.getContents().add(dd);

This will screw up the editor because you just moved the diagram data
from the resource inside the VE to your resource.
--
Thanks,
Rich Kulp
Re: VE-inspired XML plugin? [message #80384 is a reply to message #80340] Thu, 17 February 2005 12:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: michail_matjuchin.at.ibm.com

Rich Kulp wrote:

>> DiagramData dd=ed.getDiagramData();
>> //*****
>> ResourceSet resSet = new ResourceSetImpl();
>> URI fileURI = URI.createFileURI("c:/temp/aaa.xml");
>> Resource resource =
>> resSet.createResource(fileURI);
>>
>> //*****
>> resource.getContents().add(dd);

> This will screw up the editor because you just moved the diagram data
> from the resource inside the VE to your resource.

Will it work ? we really need it...

EditPart editPart = (EditPart) object;
IJavaObjectInstance component = (IJavaObjectInstance) editPart
.getModel();
JavaClass modelType = (JavaClass) component.eClass();
// *****
EditDomain ed = EditDomain.getEditDomain(editPart);
DiagramData dd = ed.getDiagramData();
Resource res = dd.eResource();
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
res.save(os, Collections.EMPTY_MAP);
String xx = os.toString();
System.out.println("xx=" + xx);
BufferedWriter out = new BufferedWriter(new FileWriter(
"c:/temp/aaa.xml"));
out.write(xx);
out.close();

} catch (Exception ex) {
ex.printStackTrace();
}

Many Thanks.
Re: VE-inspired XML plugin? [message #80597 is a reply to message #80384] Fri, 18 February 2005 14:43 Go to previous messageGo to next message
Gili Mendel is currently offline Gili MendelFriend
Messages: 338
Registered: July 2009
Senior Member
Michail Matjuchin wrote:

>
>
> Will it work ? we really need it...
>
> EditPart editPart = (EditPart) object;
> IJavaObjectInstance component = (IJavaObjectInstance)
> editPart
> .getModel();
> JavaClass modelType = (JavaClass) component.eClass();
> // *****
> EditDomain ed = EditDomain.getEditDomain(editPart);
> DiagramData dd = ed.getDiagramData();
> Resource res = dd.eResource();
> ByteArrayOutputStream os = new ByteArrayOutputStream();
> try {
> res.save(os, Collections.EMPTY_MAP);
> String xx = os.toString();
> System.out.println("xx=" + xx);
> BufferedWriter out = new BufferedWriter(new FileWriter(
> "c:/temp/aaa.xml"));
> out.write(xx);
> out.close();
>
> } catch (Exception ex) {
> ex.printStackTrace();
> }
>
> Many Thanks.
>

Note in the VE1.1 stearm (CVS HEAD) VE caches the EMF model, and a
table of content (instance variable name to XPath entry)... see
VEModelCacheUtility for more details on how. This cache is stored as a
IResource meta data
..metadata\.plugins\org.eclipse.core.resources\.projects\<project >\org.eclipse.ve.java.core\.cache\emfmodel

You are on the right track.... you can use the following as well,

XML_TEXT_OPTIONS = new HashMap(3);
XML_TEXT_OPTIONS.put(XMLResource.OPTION_PROCESS_DANGLING_HRE F,
XMLResource.OPTION_PROCESS_DANGLING_HREF_RECORD);
XML_TEXT_OPTIONS.put(XMLResource.OPTION_SAVE_TYPE_INFORMATIO N,
Boolean.TRUE);

XML_TEXT_OPTIONS.put(XMLResource.OPTION_LINE_WIDTH,
new Integer(100));


File f = ...
FileOutputStream os = new FileOutputStream(f);
res.save(os, XML_TEXT_OPTIONS);
os.close();
Re: VE-inspired XML plugin? [message #80722 is a reply to message #80107] Fri, 18 February 2005 19:51 Go to previous message
Dave Orme is currently offline Dave OrmeFriend
Messages: 424
Registered: July 2009
Senior Member
Tom Schindl wrote:
> As already said I would but I don't know the internals of the VE and
> XSWT. As a first step I checked out the sources of XSWT. Is there any
> spec, DTD which tells me what XML-Elements exists? Can I use my own in
> XSWT e.g. my own NumberWidget which derives from Text?

XSWT is designed to use reflection to automatically support any SWT
control on the classpath, including those that haven't been invented yet.


Regards,

Dave Orme

--
Visual Editor Project lead
http://www.db4o.com -- The Open-source Java Object Database
Re: VE-inspired XML plugin? [message #605030 is a reply to message #79188] Mon, 07 February 2005 12:36 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
That would be a great thing in my next project something like this would
rock. If I don't exists it would be great to start an project to provide
something like this if even possible at all. Maybe someone could tell us?:-)

Tom

Megan wrote:
> I have been searching to try to find a way to either extend the Visual
> Editor, or build a new plugin that does near the same. Can someone tell
> me how to make a very similar plugin that you drag/drop widgets that
> generates XML? Is there already such a plugin that I haven't found? Any
> and all help is deeply appreciated.
>
> -Thanks!
>
Re: VE-inspired XML plugin? [message #605036 is a reply to message #79188] Mon, 07 February 2005 17:52 Go to previous message
Joe Winchester is currently offline Joe WinchesterFriend
Messages: 496
Registered: July 2009
Senior Member
Hi Megan,

> I have been searching to try to find a way to either extend the Visual
> Editor, or build a new plugin that does near the same. Can someone tell
> me how to make a very similar plugin that you drag/drop widgets that
> generates XML? Is there already such a plugin that I haven't found? Any
> and all help is deeply appreciated.

The VE can be used for this, the only problem is that we don't really
document how. At one time we had an example plugin where you could open
an XML file (actually the EMF model that the visual editor uses
internally). This model is then able to be manipulated visually the
same way the VE can be now, the only difference is that there is no
..java code being updated or listened to for changes.

Could you please open a bugzilla feature request for us to get this
example working again and I think it will be a good starting point for
you to look at.

Best regards,

Joe Winchester
Re: VE-inspired XML plugin? [message #605040 is a reply to message #79300] Mon, 07 February 2005 13:55 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Joe Winchester wrote:
> Hi Megan,
>
>> I have been searching to try to find a way to either extend the Visual
>> Editor, or build a new plugin that does near the same. Can someone
>> tell me how to make a very similar plugin that you drag/drop widgets
>> that generates XML? Is there already such a plugin that I haven't
>> found? Any and all help is deeply appreciated.
>
>
> The VE can be used for this, the only problem is that we don't really
> document how. At one time we had an example plugin where you could open
> an XML file (actually the EMF model that the visual editor uses
> internally). This model is then able to be manipulated visually the
> same way the VE can be now, the only difference is that there is no
> .java code being updated or listened to for changes.
>
> Could you please open a bugzilla feature request for us to get this
> example working again and I think it will be a good starting point for
> you to look at.
>
> Best regards,
>
> Joe Winchester
>

Thanks Joe. I do so. Are there any documents I could read about the
design of VE or do only have the source code (can I get it from cvs?).
Do you suggest any documents I have to read before I can jump in and
start reading the sources.

Tom
Re: VE-inspired XML plugin? [message #605080 is a reply to message #79315] Tue, 08 February 2005 12:46 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Tom Schindl wrote:
> Joe Winchester wrote:
>
>> Hi Megan,
>>
>>> I have been searching to try to find a way to either extend the
>>> Visual Editor, or build a new plugin that does near the same. Can
>>> someone tell me how to make a very similar plugin that you drag/drop
>>> widgets that generates XML? Is there already such a plugin that I
>>> haven't found? Any and all help is deeply appreciated.
>>
>>
>>
>> The VE can be used for this, the only problem is that we don't really
>> document how. At one time we had an example plugin where you could
>> open an XML file (actually the EMF model that the visual editor uses
>> internally). This model is then able to be manipulated visually the
>> same way the VE can be now, the only difference is that there is no
>> .java code being updated or listened to for changes.
>>
>> Could you please open a bugzilla feature request for us to get this
>> example working again and I think it will be a good starting point for
>> you to look at.

Done was not sure what component is the right maybe you have to modify:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=84569
Re: VE-inspired XML plugin? [message #605116 is a reply to message #79188] Wed, 09 February 2005 03:13 Go to previous message
Dave Orme is currently offline Dave OrmeFriend
Messages: 424
Registered: July 2009
Senior Member
Megan wrote:
> I have been searching to try to find a way to either extend the Visual
> Editor, or build a new plugin that does near the same. Can someone tell
> me how to make a very similar plugin that you drag/drop widgets that
> generates XML? Is there already such a plugin that I haven't found? Any
> and all help is deeply appreciated.

There's not a plugin for VE that lets you do this, but the language and
the engine parts have been designed.

See xswt.sourceforge.net for details. The Update Manager URL is:

http://xswt.sourceforge.net/updates

Right now, there is a plug-in that just allows you to preview an XSWT
layout as you type it (whenever you save).

If you install via Update Manager, you will get a File/New wizard for
creating XSWT files. And the preview pane is available through
Window|Show View|Other..., then expand the XSWT node in the tree.

I had a conversation today with Gili about integrating this engine into
VE and this looks like something that the VE team might be interested in
doing.

Would anyone here be interested in helping?


Regards,

Dave Orme
--
Visual Editor Project lead
http://www.db4o.com -- The Open-source Java Object Database
Re: VE-inspired XML plugin? [message #605242 is a reply to message #79576] Mon, 14 February 2005 22:07 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
David J. Orme wrote:
> Megan wrote:
>
>> I have been searching to try to find a way to either extend the Visual
>> Editor, or build a new plugin that does near the same. Can someone
>> tell me how to make a very similar plugin that you drag/drop widgets
>> that generates XML? Is there already such a plugin that I haven't
>> found? Any and all help is deeply appreciated.
>
>
> There's not a plugin for VE that lets you do this, but the language and
> the engine parts have been designed.
>
> See xswt.sourceforge.net for details. The Update Manager URL is:
>
> http://xswt.sourceforge.net/updates
>
> Right now, there is a plug-in that just allows you to preview an XSWT
> layout as you type it (whenever you save).
>
> If you install via Update Manager, you will get a File/New wizard for
> creating XSWT files. And the preview pane is available through
> Window|Show View|Other..., then expand the XSWT node in the tree.
>
> I had a conversation today with Gili about integrating this engine into
> VE and this looks like something that the VE team might be interested in
> doing.
>
> Would anyone here be interested in helping?
>

As already said I would but I don't know the internals of the VE and
XSWT. As a first step I checked out the sources of XSWT. Is there any
spec, DTD which tells me what XML-Elements exists? Can I use my own in
XSWT e.g. my own NumberWidget which derives from Text?

>
> Regards,
>
> Dave Orme
Re: VE-inspired XML plugin? [message #605272 is a reply to message #80107] Wed, 16 February 2005 13:56 Go to previous message
Gili Mendel is currently offline Gili MendelFriend
Messages: 338
Registered: July 2009
Senior Member
Tom Schindl wrote:

>
> As already said I would but I don't know the internals of the VE and
> XSWT. As a first step I checked out the sources of XSWT. Is there any
> spec, DTD which tells me what XML-Elements exists? Can I use my own in
> XSWT e.g. my own NumberWidget which derives from Text?
>
>>
>> Regards,
>>
>> Dave Orme

XSWT does not have a DTD per se.. it is based on reflection. There is a
bit of schema based notation... see more on
http://xswt.sourceforge.net/cgi-bin/wiki?XSWTCoreEngineDocum entation
Re: VE-inspired XML plugin? [message #605295 is a reply to message #79315] Wed, 16 February 2005 18:16 Go to previous message
Eclipse UserFriend
Originally posted by: michail_matjuchin.at.ibm.com

Tom Schindl wrote:

> Joe Winchester wrote:
>> Hi Megan,
>>
>>> I have been searching to try to find a way to either extend the Visual
>>> Editor, or build a new plugin that does near the same. Can someone
>>> tell me how to make a very similar plugin that you drag/drop widgets
>>> that generates XML? Is there already such a plugin that I haven't
>>> found? Any and all help is deeply appreciated.
>>
>>
>> The VE can be used for this, the only problem is that we don't really
>> document how. At one time we had an example plugin where you could open
>> an XML file (actually the EMF model that the visual editor uses
>> internally). This model is then able to be manipulated visually the
>> same way the VE can be now, the only difference is that there is no
>> .java code being updated or listened to for changes.
>>
>> Could you please open a bugzilla feature request for us to get this
>> example working again and I think it will be a good starting point for
>> you to look at.
>>
>> Best regards,
>>
>> Joe Winchester
>>

> Thanks Joe. I do so. Are there any documents I could read about the
> design of VE or do only have the source code (can I get it from cvs?).
> Do you suggest any documents I have to read before I can jump in and
> start reading the sources.

> Tom

it is easy:

public class SampleAction implements IWorkbenchWindowActionDelegate {
private IWorkbenchWindow window;

private ISelection fSelection = null;

/**
* The constructor.
*/
public SampleAction() {
}

public void selectionChanged(IAction action, ISelection selection) {
fSelection = selection;

}
/**
* The action has been activated. The argument of the method represents
the
* 'real' action sitting in the workbench UI.
*
* @see IWorkbenchWindowActionDelegate#run
*/
public void run(IAction action) {
// *****
if (fSelection instanceof IStructuredSelection
&& ((IStructuredSelection) fSelection).size() == 1) {

Object object = ((IStructuredSelection) fSelection)
.getFirstElement();
if(object instanceof EditPart) {
EditPart editPart=(EditPart)object;
IJavaObjectInstance component = (IJavaObjectInstance)
editPart.getModel();
JavaClass modelType = (JavaClass) component.eClass();
//*****
EditDomain ed = EditDomain.getEditDomain(editPart);
DiagramData dd=ed.getDiagramData();
//*****
ResourceSet resSet = new ResourceSetImpl();
URI fileURI = URI.createFileURI("c:/temp/aaa.xml");
Resource resource =
resSet.createResource(fileURI);

//*****
resource.getContents().add(dd);
//
try {
resource.save(Collections.EMPTY_MAP);
}
catch(Exception ex) {
ex.printStackTrace();
}
}
}

}
Re: VE-inspired XML plugin? [message #605304 is a reply to message #80308] Wed, 16 February 2005 23:14 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

> DiagramData dd=ed.getDiagramData();
> //*****
> ResourceSet resSet = new ResourceSetImpl();
> URI fileURI = URI.createFileURI("c:/temp/aaa.xml");
> Resource resource =
> resSet.createResource(fileURI);
>
> //*****
> resource.getContents().add(dd);

This will screw up the editor because you just moved the diagram data
from the resource inside the VE to your resource.
--
Thanks,
Rich Kulp
Re: VE-inspired XML plugin? [message #605314 is a reply to message #80340] Thu, 17 February 2005 12:59 Go to previous message
Eclipse UserFriend
Originally posted by: michail_matjuchin.at.ibm.com

Rich Kulp wrote:

>> DiagramData dd=ed.getDiagramData();
>> //*****
>> ResourceSet resSet = new ResourceSetImpl();
>> URI fileURI = URI.createFileURI("c:/temp/aaa.xml");
>> Resource resource =
>> resSet.createResource(fileURI);
>>
>> //*****
>> resource.getContents().add(dd);

> This will screw up the editor because you just moved the diagram data
> from the resource inside the VE to your resource.

Will it work ? we really need it...

EditPart editPart = (EditPart) object;
IJavaObjectInstance component = (IJavaObjectInstance) editPart
.getModel();
JavaClass modelType = (JavaClass) component.eClass();
// *****
EditDomain ed = EditDomain.getEditDomain(editPart);
DiagramData dd = ed.getDiagramData();
Resource res = dd.eResource();
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
res.save(os, Collections.EMPTY_MAP);
String xx = os.toString();
System.out.println("xx=" + xx);
BufferedWriter out = new BufferedWriter(new FileWriter(
"c:/temp/aaa.xml"));
out.write(xx);
out.close();

} catch (Exception ex) {
ex.printStackTrace();
}

Many Thanks.
Re: VE-inspired XML plugin? [message #605369 is a reply to message #80384] Fri, 18 February 2005 14:43 Go to previous message
Gili Mendel is currently offline Gili MendelFriend
Messages: 338
Registered: July 2009
Senior Member
Michail Matjuchin wrote:

>
>
> Will it work ? we really need it...
>
> EditPart editPart = (EditPart) object;
> IJavaObjectInstance component = (IJavaObjectInstance)
> editPart
> .getModel();
> JavaClass modelType = (JavaClass) component.eClass();
> // *****
> EditDomain ed = EditDomain.getEditDomain(editPart);
> DiagramData dd = ed.getDiagramData();
> Resource res = dd.eResource();
> ByteArrayOutputStream os = new ByteArrayOutputStream();
> try {
> res.save(os, Collections.EMPTY_MAP);
> String xx = os.toString();
> System.out.println("xx=" + xx);
> BufferedWriter out = new BufferedWriter(new FileWriter(
> "c:/temp/aaa.xml"));
> out.write(xx);
> out.close();
>
> } catch (Exception ex) {
> ex.printStackTrace();
> }
>
> Many Thanks.
>

Note in the VE1.1 stearm (CVS HEAD) VE caches the EMF model, and a
table of content (instance variable name to XPath entry)... see
VEModelCacheUtility for more details on how. This cache is stored as a
IResource meta data
..metadata\.plugins\org.eclipse.core.resources\.projects\<project >\org.eclipse.ve.java.core\.cache\emfmodel

You are on the right track.... you can use the following as well,

XML_TEXT_OPTIONS = new HashMap(3);
XML_TEXT_OPTIONS.put(XMLResource.OPTION_PROCESS_DANGLING_HRE F,
XMLResource.OPTION_PROCESS_DANGLING_HREF_RECORD);
XML_TEXT_OPTIONS.put(XMLResource.OPTION_SAVE_TYPE_INFORMATIO N,
Boolean.TRUE);

XML_TEXT_OPTIONS.put(XMLResource.OPTION_LINE_WIDTH,
new Integer(100));


File f = ...
FileOutputStream os = new FileOutputStream(f);
res.save(os, XML_TEXT_OPTIONS);
os.close();
Re: VE-inspired XML plugin? [message #605412 is a reply to message #80107] Fri, 18 February 2005 19:51 Go to previous message
Dave Orme is currently offline Dave OrmeFriend
Messages: 424
Registered: July 2009
Senior Member
Tom Schindl wrote:
> As already said I would but I don't know the internals of the VE and
> XSWT. As a first step I checked out the sources of XSWT. Is there any
> spec, DTD which tells me what XML-Elements exists? Can I use my own in
> XSWT e.g. my own NumberWidget which derives from Text?

XSWT is designed to use reflection to automatically support any SWT
control on the classpath, including those that haven't been invented yet.


Regards,

Dave Orme

--
Visual Editor Project lead
http://www.db4o.com -- The Open-source Java Object Database
Previous Topic:java.lang.NoClassDefFoundError for VE
Next Topic:GIF on a button
Goto Forum:
  


Current Time: Sat Apr 20 03:22:05 GMT 2024

Powered by FUDForum. Page generated in 0.05208 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top