Skip to main content



      Home
Home » Language IDEs » ServerTools (WTP) » Keeping in sync : StructuredTextEditor and GrapicalEditor in MultipageEditorPart
Keeping in sync : StructuredTextEditor and GrapicalEditor in MultipageEditorPart [message #212898] Thu, 24 April 2008 10:20 Go to next message
Eclipse UserFriend
Originally posted by: vidyasagar_anand.yahoo.com

I started with writing a Graphical editor embedded alongside with a
StructuredTextEditor and I need help understanding the basics of the
StructuredTextEditor. I followed this article to get started
http://www.eclipse.org/webtools/wst/components/sse/tutorials /multipage-editor-tutorial.html.

In the MultipageEditor part I have created the pages to instantiate the
Graphical and StructuredTextEditor. (I intend to use the Source Editor for
editing XML documents but because of the restriction on the
XMLMultipageEditorPart am staying away)

I want the users to be able to keep both my pages in sync.
1. How do I get access to the "model" held by the StructuredTextEditor at
the time of switching from the Source to Graphical View?
2. What kind of Listeners would I need to attach (api on the
StructuredTextEditor). An example would help a lot!!

Regards.
Re: Keeping in sync : StructuredTextEditor and GrapicalEditor in MultipageEditorPart [message #212926 is a reply to message #212898] Thu, 24 April 2008 18:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: valentinbaciu.hotmail.com

The XSD and WSDL multipage source/graphical editors are based on the same
design. Feel free to look at their source code for ideas. They are hosted in
the org.eclipse.wst.xsd.ui and org.eclipse.wst.wsdl.ui.
Regards, Valentin

"Anand Vidyasagar" <vidyasagar_anand@yahoo.com> wrote in message
news:42fb5409df8c3e040c476c623afcd46c$1@www.eclipse.org...
>I started with writing a Graphical editor embedded alongside with a
>StructuredTextEditor and I need help understanding the basics of the
>StructuredTextEditor. I followed this article to get started
> http://www.eclipse.org/webtools/wst/components/sse/tutorials /multipage-editor-tutorial.html.
>
> In the MultipageEditor part I have created the pages to instantiate the
> Graphical and StructuredTextEditor. (I intend to use the Source Editor for
> editing XML documents but because of the restriction on the
> XMLMultipageEditorPart am staying away)
>
> I want the users to be able to keep both my pages in sync. 1. How do I get
> access to the "model" held by the StructuredTextEditor at the time of
> switching from the Source to Graphical View?
> 2. What kind of Listeners would I need to attach (api on the
> StructuredTextEditor). An example would help a lot!!
>
> Regards.
>
>
>
Re: Keeping in sync : StructuredTextEditor and GrapicalEditor in MultipageEditorPart [message #212954 is a reply to message #212926] Fri, 25 April 2008 15:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vidyasagar_anand.yahoo.com

Thanks,
This gave me the much needed lead...
For the benefit of the other users of the news group.. I will write the
code to access the model here .. Hope it helps someone!!

(This code is not 100% efficient...From the source code I can see that I
need to write better code than this so that I dont keep the model open
forever for editing.)

<code>
void createSourcePage() {
try {
sourcePage = new StructuredTextEditor();
int index = addPage(sourcePage, getEditorInput());
setPageText(index, "source");
IDocument doc = sourcePage.getDocumentProvider().getDocument(
getEditorInput());
if (doc instanceof IStructuredDocument) {
IStructuredModel model = StructuredModelManager.getModelManager()
.getExistingModelForEdit(doc);
if (model == null) {
model = StructuredModelManager.getModelManager()
.getModelForEdit((IStructuredDocument) doc);
}
model.addModelStateListener(new IModelStateListener(){

public void modelAboutToBeChanged(IStructuredModel model) {
// TODO Auto-generated method stub

}

public void modelAboutToBeReinitialized(
IStructuredModel structuredModel) {
// TODO Auto-generated method stub

}

public void modelChanged(IStructuredModel model) {
// TODO Auto-generated method stub

}

public void modelDirtyStateChanged(IStructuredModel model,
boolean isDirty) {
// TODO Auto-generated method stub

}

public void modelReinitialized(
IStructuredModel structuredModel) {
// TODO Auto-generated method stub

}

public void modelResourceDeleted(IStructuredModel model) {
// TODO Auto-generated method stub

}

public void modelResourceMoved(IStructuredModel oldModel,
IStructuredModel newModel) {
// TODO Auto-generated method stub

}

});
}
} catch (PartInitException e) {
ErrorDialog.openError(getSite().getShell(),
"Error creating nested text editor", null, e.getStatus());
}
}
</code>

Implement the methods in the interface and keep track of changes to the
model and update the GEF model accordingly. Now when you switch over to
the Graphical part your Figures would render themselves correctly!!
Re: Keeping in sync : StructuredTextEditor and GrapicalEditor in MultipageEditorPart [message #654263 is a reply to message #212954] Mon, 14 February 2011 14:45 Go to previous messageGo to next message
Eclipse UserFriend
Hi

I would like to know witch event is send by the editor to notify the multiparteditor that the editing content has hanged.

Regards
Re: Keeping in sync : StructuredTextEditor and GrapicalEditor in MultipageEditorPart [message #654308 is a reply to message #654263] Mon, 14 February 2011 22:40 Go to previous messageGo to next message
Eclipse UserFriend
Arise, thread, arise!

I'm assuming you mean "changed" and not "hanged". It really depends on the kind of information you're looking for. In terms of basic text changes, the change notification available through IDocument might be enough. Casting it to our own IStructuredDocument interface will let you register listeners for more descriptive text change notifications, but if you're looking for how our own Design page updates itself, take a close look at org.eclipse.wst.xml.ui.internal.tabletree.XMLTableTreeConten tProvider#inputChanged(Viewer, Object, Object) and how the viewer is called by the model's IJFaceNodeAdapterFactory once it's added to its list of listeners.
Re: Keeping in sync : StructuredTextEditor and GrapicalEditor in MultipageEditorPart [message #1065759 is a reply to message #654308] Thu, 27 June 2013 08:13 Go to previous message
Eclipse UserFriend
I`m actually planning to generate a custom xml, using StructuredTextEditor is that possible ?

<Shell xmlns="http://www.eclipse.org/xwt/presentation" xmlns:x="http://www.eclipse.org/xwt"
	x:Class="com.demo.client.DemoXWT" text="XWT Application">
	<Label text="Name:" bounds="126, 69, 49, 13" />
</Shell>



to

<div type="Label" name="Name:" />



something like this or to any custom xml..
Previous Topic:Validate WSDL Ant Task
Next Topic:Porting XML Editor Challenge [SOLVED]
Goto Forum:
  


Current Time: Fri Jul 04 04:32:56 EDT 2025

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

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

Back to the top