Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Using XML Editor in my plugin - is there some clean way ?
Using XML Editor in my plugin - is there some clean way ? [message #125344] Sun, 24 July 2005 23:49 Go to next message
Pavel Trka is currently offline Pavel TrkaFriend
Messages: 14
Registered: July 2009
Junior Member
hi !

Im trying to find a way to use web tools xml source editor in my
plugin... I searched this forum and docs but I didn't find what I need
or I overlooked it :)

It's quite simple: Im working on my plugin suite that is used for some
special tasks regarding editing of our format of deploy files... Our
plugin implements visual editing and generating source for lazy users
who dont want edit source directly... BUT: under this layer these
deploy files are simply xml files and there is need to have the
possibility to edit them directly in "source mode"...

Till now we used XMLEditor class from solareclipse suite but
solareclipse seems dead and there are bugs when used in eclipse 3.x so
Im trying to replace it by xml editor from webtools - webtools seems
like great and rapidly improving tools package being developed as part
of eclipse project. I dont wanna extend it by adding features, I only
want to use it as one page in our multi-page editor...

I succesfully used XMLMultiPageEditorPart, now Im able to edit our xml
files but I have some questions:

1. is there some clean way ? Now Im using directly mentioned class from
internal package, but my experience tells me that it's not best idea -
some time ago I was migrating our plugins to compile it under Eclipse
3.0 and 3.1 and this was real nightmare - developers who originally
implemented our plugin used classes from internal packages wildly and
you can imagine what refactoring of such code was - internal
implementation is not documented and the code was also completely
undocumented :))

2. is there way to enable syntax highlighting in my code for our files
? These files have not *.xml extension and I cant add these extensions
to XML Content Type in eclipse preferences because I need these
extensions associated with our plugin. I was not diging much in source
code but I found some methods in StructuredTextEditor connected with
StructuredTextViewerConfiguration class - is this the place for some
info ?


Thanks for any answer and sorry for long boring post :)
Re: Using XML Editor in my plugin - is there some clean way ? [message #125360 is a reply to message #125344] Mon, 25 July 2005 00:03 Go to previous messageGo to next message
Pavel Trka is currently offline Pavel TrkaFriend
Messages: 14
Registered: July 2009
Junior Member
one more problem connected with mentioned syntax highlighting error -
design page of xml editor multipage view is empty in case of files with
other than *.xml extension... So the problem probably is that I need tell
the editor that proper structured file type is loaded... or am I wrong ?
Re: Using XML Editor in my plugin - is there some clean way ? [message #125396 is a reply to message #125344] Mon, 25 July 2005 08:53 Go to previous messageGo to next message
Axel Hecht is currently offline Axel HechtFriend
Messages: 16
Registered: July 2009
Junior Member
Pavel Trka wrote:
> hi !
>
> Im trying to find a way to use web tools xml source editor in my
> plugin... I searched this forum and docs but I didn't find what I need
> or I overlooked it :)
>
> It's quite simple: Im working on my plugin suite that is used for some
> special tasks regarding editing of our format of deploy files... Our
> plugin implements visual editing and generating source for lazy users
> who dont want edit source directly... BUT: under this layer these
> deploy files are simply xml files and there is need to have the
> possibility to edit them directly in "source mode"...
>
> Till now we used XMLEditor class from solareclipse suite but
> solareclipse seems dead and there are bugs when used in eclipse 3.x so
> Im trying to replace it by xml editor from webtools - webtools seems
> like great and rapidly improving tools package being developed as part
> of eclipse project. I dont wanna extend it by adding features, I only
> want to use it as one page in our multi-page editor...
>
> I succesfully used XMLMultiPageEditorPart, now Im able to edit our xml
> files but I have some questions:
>
> 1. is there some clean way ? Now Im using directly mentioned class from
> internal package, but my experience tells me that it's not best idea -
> some time ago I was migrating our plugins to compile it under Eclipse
> 3.0 and 3.1 and this was real nightmare - developers who originally
> implemented our plugin used classes from internal packages wildly and
> you can imagine what refactoring of such code was - internal
> implementation is not documented and the code was also completely
> undocumented :))

The not so really clean way I used was to use
org.eclipse.wst.xml.ui.internal.provisional.StructuredTextEd itorXML
in one of my tabs of my editor. If you want the XML outline to work,
then you need to implement getAdapter and feed that into the
StructuredTextEditorXML.

> 2. is there way to enable syntax highlighting in my code for our files
> ? These files have not *.xml extension and I cant add these extensions
> to XML Content Type in eclipse preferences because I need these
> extensions associated with our plugin. I was not diging much in source
> code but I found some methods in StructuredTextEditor connected with
> StructuredTextViewerConfiguration class - is this the place for some
> info ?
>

You want to declare a content type that derives from XML one. That
worked like charm for me. See my snippet below for hooking up the
content type and the schema for my content type and namespace.

Axel

PS: plugin.xml snippet:

<extension
point="org.eclipse.core.runtime.contentTypes">
<content-type
file-extensions="xul"
priority="high"
name="Mozilla XUL Content Type"
id="xul"
base-type="org.eclipse.core.runtime.xml"
default-charset="UTF-8" />
</extension>
<extension
point="org.eclipse.wst.xml.core.catalogContributor">
<catalogContributor catalogId="solid">
<mappingInfo

key=" http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xu l"
uri="src/schemas/SimpleXUL.xsd" />
</catalogContributor>
</extension>
Re: Using XML Editor in my plugin - is there some clean way ? [message #126235 is a reply to message #125396] Wed, 27 July 2005 07:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: news.brkerez.cz

> The not so really clean way I used was to use
> org.eclipse.wst.xml.ui.internal.provisional.StructuredTextEd itorXML
> in one of my tabs of my editor. If you want the XML outline to work,
> then you need to implement getAdapter and feed that into the
> StructuredTextEditorXML.

please can you provide me with some details about getAdapter
implementation in my class ? :)


> You want to declare a content type that derives from XML one. That
> worked like charm for me. See my snippet below for hooking up the
> content type and the schema for my content type and namespace.

Thanks, now it works ;) But with one small problem - syntax highlighting
is not active immediately after opening source page, it's active after I
start to edit the source... But this is maybee problem of our
implementation... When I use XMLMultiPageEditorPart, it's ok but in this
case there is another problem - this class has not getDocumentProvider()
method implemented and it's needed on some places in our plugin...

Can I ask what i the difference or relationship between
XMLMultiPageEditorPart and StructuredTextEditorXML ?
Re: Using XML Editor in my plugin - is there some clean way ? [message #126746 is a reply to message #126235] Thu, 28 July 2005 10:19 Go to previous messageGo to next message
Axel Hecht is currently offline Axel HechtFriend
Messages: 16
Registered: July 2009
Junior Member
Pavel Trka wrote:
>
>> The not so really clean way I used was to use
>> org.eclipse.wst.xml.ui.internal.provisional.StructuredTextEd itorXML
>> in one of my tabs of my editor. If you want the XML outline to work,
>> then you need to implement getAdapter and feed that into the
>> StructuredTextEditorXML.
>
>
> please can you provide me with some details about getAdapter
> implementation in my class ? :)
>

It looks like this in my class:

/**
* Get Adaptable from ourselves, or from the XML source editor page
*/
public Object getAdapter(Class adapter) {
Object retObject = null;
if (editor != null) {
retObject = editor.getAdapter(adapter);
}
if (retObject != null)
return retObject;
return super.getAdapter(adapter);
}

>
>> You want to declare a content type that derives from XML one. That
>> worked like charm for me. See my snippet below for hooking up the
>> content type and the schema for my content type and namespace.
>
>
> Thanks, now it works ;) But with one small problem - syntax highlighting
> is not active immediately after opening source page, it's active after I
> start to edit the source... But this is maybee problem of our
> implementation... When I use XMLMultiPageEditorPart, it's ok but in this
> case there is another problem - this class has not getDocumentProvider()
> method implemented and it's needed on some places in our plugin...
>
> Can I ask what i the difference or relationship between
> XMLMultiPageEditorPart and StructuredTextEditorXML ?
>

You can ask, but I can't answer. I'm just forwarding the little things I
learnt recently, understanding the code is not yet part of my game.

Axel
Re: Using XML Editor in my plugin - is there some clean way ? [message #126879 is a reply to message #126746] Thu, 28 July 2005 13:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: news.brkerez.cz

ok thanks for your answers ! It's obvious I have to learn some more things
about eclipse editor architecture ;)


Axel Hecht wrote:

> You can ask, but I can't answer. I'm just forwarding the little things I
> learnt recently, understanding the code is not yet part of my game.

> Axel
Re: Using XML Editor in my plugin - is there some clean way ? [message #127011 is a reply to message #126746] Thu, 28 July 2005 17:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: amywu.us.DELETETHISPART.ibm.com

When you need to call getDocumentProvider, what you can do is call
getAdapter(ITextEditor.class) and that should return an ITextEditor back to
you. There is a getDocumentProvider() method on that interface.

StructuredTextEditorXML is the XML Source Page editor. It is just 1 single
page editor. The XMLMultiPageEditor contains a design and source page. The
source page it contains is StructuredTextEditorXML.

Hope this helps.

"Axel Hecht" <axel@pike.org> wrote in message
news:dcabfb$eet$1@news.eclipse.org...
> Pavel Trka wrote:
> >
> >> The not so really clean way I used was to use
> >> org.eclipse.wst.xml.ui.internal.provisional.StructuredTextEd itorXML
> >> in one of my tabs of my editor. If you want the XML outline to work,
> >> then you need to implement getAdapter and feed that into the
> >> StructuredTextEditorXML.
> >
> >
> > please can you provide me with some details about getAdapter
> > implementation in my class ? :)
> >
>
> It looks like this in my class:
>
> /**
> * Get Adaptable from ourselves, or from the XML source editor
page
> */
> public Object getAdapter(Class adapter) {
> Object retObject = null;
> if (editor != null) {
> retObject = editor.getAdapter(adapter);
> }
> if (retObject != null)
> return retObject;
> return super.getAdapter(adapter);
> }
>
> >
> >> You want to declare a content type that derives from XML one. That
> >> worked like charm for me. See my snippet below for hooking up the
> >> content type and the schema for my content type and namespace.
> >
> >
> > Thanks, now it works ;) But with one small problem - syntax highlighting
> > is not active immediately after opening source page, it's active after I
> > start to edit the source... But this is maybee problem of our
> > implementation... When I use XMLMultiPageEditorPart, it's ok but in this
> > case there is another problem - this class has not getDocumentProvider()
> > method implemented and it's needed on some places in our plugin...
> >
> > Can I ask what i the difference or relationship between
> > XMLMultiPageEditorPart and StructuredTextEditorXML ?
> >
>
> You can ask, but I can't answer. I'm just forwarding the little things I
> learnt recently, understanding the code is not yet part of my game.
>
> Axel
Re: Using XML Editor in my plugin - is there some clean way ? [message #127407 is a reply to message #127011] Fri, 29 July 2005 14:55 Go to previous message
Eclipse UserFriend
Originally posted by: news.brkerez.cz

hi,

Amy Wu wrote:

> When you need to call getDocumentProvider, what you can do is call
> getAdapter(ITextEditor.class) and that should return an ITextEditor back to
> you. There is a getDocumentProvider() method on that interface.

thanks I'll try it when there will be some free time...


> StructuredTextEditorXML is the XML Source Page editor. It is just 1 single
> page editor. The XMLMultiPageEditor contains a design and source page. The
> source page it contains is StructuredTextEditorXML.

Im dumb :) This was of course the first thing that I was thinking about,
names of classes are pretty self-explanatory... Then I tried it (replacing
XMLMultiPageEditorPart by StructuredTextEditorXML), but (hell knows why) I
was surprised because I had still design page when I opened my deploy file
so I was confused and asking here... Now I tried it again and of course
there is source page only :) I dont know what I was doing before, maybee
I didnt compile or run it right, hell knows :) Thanks anyway

> Hope this helps.

sure, any answers are welcome...
Previous Topic:Validator JSP Error
Next Topic:RC5 Source Format issue
Goto Forum:
  


Current Time: Sun Sep 01 01:02:25 GMT 2024

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

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

Back to the top