Updating the Semantic model element during start of an Application [message #38202] |
Mon, 04 September 2006 08:02  |
Eclipse User |
|
|
|
Originally posted by: ganesh.mohan.hp.com
Hello,
I am designing an graphical editor for Voice XML Applications using GMF.
Suppose during application startup, i want to have an wizard using which i
can create certain default elements, i am successfully able to create the
notational ascept of the element. That element appears on the editor as
soon as i start my new project.
But i want to update simultaneously the semantic ascept of the element too.
For example:
Suppose i want to have a structure like the following in my sematic file
during startup:
<Vxml..>
<Menu...>
</Vxml>
where menu represents the a dialog tag in VXML Applications. I am able to
display the menu diagrmatically on the editor but not able to update the
xml file as shown above.
Investigation: From my knowledge, when we create a new diagramfile, there
are two resources( a diagram resource and a model resource) The model
resource has the "Vxml" to be set as its document root using the
"resource.getContents.add("Object") method. Now suppose i want to add a
"MenuType" under this VXML Type how should i go about doing this.
The two resources use the " resource.save(Map options) " method to save
the initial contents into the file. Can anyone please help me, on how can
i create this default elment during startup and update my xml file.
Thanx,
Ganesh
|
|
|
Re: Updating the Semantic model element during start of an Application [message #38400 is a reply to message #38202] |
Mon, 04 September 2006 09:05   |
Eclipse User |
|
|
|
Originally posted by: khai.n.situvista.com
I'm assuming you're overriding:
....diagram.part.XXXDiagramEditorUtil.createNewDiagramFile()
Here's an example from the MindmapDiagramEditorUtil; it
creates a new topic element at creation time.
=== Original code ====================================
if (diagram != null) {
diagramResource.getContents().add(diagram);
diagram.setName(diagramFile.getName());
diagram.setElement(model);
}
try {
java.util.Map options = new HashMap();
options.put(XMIResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$
modelResource.save(options);
diagramResource.save(Collections.EMPTY_MAP);
} catch (IOException e) {
MindmapDiagramEditorPlugin.getInstance().logError("Unable to store
model and diagram resources", e); //$NON-NLS-1$
}
=======================================================
=== Modified code to create a root topic on creation ==
if (diagram != null) {
diagramResource.getContents().add(diagram);
diagram.setName(diagramFile.getName());
diagram.setElement(model);
}
//==== Add Topic (semantic model)==
Topic newTopic = MindmapFactory.eINSTANCE.createTopic();
newTopic.setName("SomeNewTopic");
model.getRootTopics().add(newTopic);
//=== Add Topic (notation view)
ViewService.createNode(diagram, newTopic, kindParam,
MindmapDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
try {
java.util.Map options = new HashMap();
options.put(XMIResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$
modelResource.save(options);
diagramResource.save(Collections.EMPTY_MAP);
} catch (IOException e) {
MindmapDiagramEditorPlugin.getInstance().logError("Unable to store
model and diagram resources", e); //$NON-NLS-1$
}
=======================================================
That's it!
(I hope I understood your question correctly :-))
-- Khai --
Ganesh wrote:
> Hello,
>
> I am designing an graphical editor for Voice XML Applications using GMF.
> Suppose during application startup, i want to have an wizard using which
> i can create certain default elements, i am successfully able to create
> the notational ascept of the element. That element appears on the editor
> as soon as i start my new project.
>
> But i want to update simultaneously the semantic ascept of the element too.
>
> For example:
>
> Suppose i want to have a structure like the following in my sematic file
> during startup:
>
> <Vxml..>
>
> <Menu...>
>
> </Vxml>
>
> where menu represents the a dialog tag in VXML Applications. I am able
> to display the menu diagrmatically on the editor but not able to update
> the xml file as shown above.
>
> Investigation: From my knowledge, when we create a new diagramfile,
> there are two resources( a diagram resource and a model resource) The
> model resource has the "Vxml" to be set as its document root using the
> "resource.getContents.add("Object") method. Now suppose i want to add a
> "MenuType" under this VXML Type how should i go about doing this.
>
> The two resources use the " resource.save(Map options) " method to save
> the initial contents into the file. Can anyone please help me, on how
> can i create this default elment during startup and update my xml file.
>
> Thanx,
> Ganesh
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.05691 seconds