Keeping in sync : StructuredTextEditor and GrapicalEditor in MultipageEditorPart [message #212898] |
Thu, 24 April 2008 14:20 |
Eclipse User |
|
|
|
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 22:10 |
Eclipse User |
|
|
|
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 19:07 |
Eclipse User |
|
|
|
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 #654308 is a reply to message #654263] |
Tue, 15 February 2011 03:40 |
|
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.
_
Nitin Dahyabhai
Eclipse Web Tools Platform
|
|
|
|
Powered by
FUDForum. Page generated in 0.03042 seconds