This is part 2 of my tu­to­rial se­ries on oxy­gen plugin de­ve­lop­ment. If you mis­sed part 1, read it here or check out the code on GitHub.


Part 2 of this tu­to­rial is about the EditorChangeListener and how we can use it to enable or disa­ble our custom but­ton on dif­fe­rent file ty­pes. The code can be found in step2 branch in the GitHub repo.

Let’s say, our custom but­ton should only be active/enabled/clickable when there is an XML file opened in the cur­rent oXy­gen edi­tor tab.

First, we add an EditorChangeListener with a new func­tion in all it’s change me­thods:

check­Cur­ren­tE­di­to­rAnd­Ch­an­ge­But­ton­Sta­tus() is a new me­thod to check the cur­rent edi­tor on any change in the oXy­gen edi­tor pa­nes. Everytime we change the cur­rent tab in oXy­gen, close a file or open a new one, the check­Cur­ren­tE­di­to­rAnd­Ch­an­ge­But­ton­Sta­tus() is cal­led to check the cur­rent file URL:

First, we re­treive the cur­rent edi­tor with the me­thod pluginWorkspaceAccess.getCurrentEditorAccess(PluginWorkspace.MAIN_EDITING_AREA) and check whe­ther we have an edi­tor opened or not.

Second, we re­treive the file URL of the cur­rent edi­tor with currentEditor.getEditorLocation() and then check the file ex­ten­sion for .xml en­ding.

Based on these checks we eit­her enable or disa­ble the plugin demo but­ton.

There’s also some other foo we have to change in or­der to get these chan­ges to work. Check out the whole file CustomButtonPluginExtension.java in the GitHub repo in branch step2.


In part 3 we will learn how to check whe­ther the file is opened in author- or text-mode. Stay tu­ned…

In the next couple of weeks I’d like to write some blog­posts and tu­to­ri­als about plugin de­ve­lop­ment for the awe­some oXy­gen XML Editor. I’d like to share my ex­pe­ri­en­ces in plugin de­ve­lop­ment since tu­to­ri­als and re­sour­ces for this to­pic are rare…

I’ll start off by sho­w­ing how to add a custom tool­bar with a simple but­ton to the oXy­gen main win­dow.

First of all, we need to down­load the oXy­gen plug­ins SDK from the oXy­gen Website. Create a new Java Project in your fa­vo­rite IDE (I’m using Eclipse), place the oxygen.jar li­brary from the SDK down­load in your lib/ fol­der and add it to the build path. Also add the Javadoc, that’s quite hel­pful. You can also ac­cess the the do­cu­men­ta­tion on­line.

To start off with plugin de­ve­lop­ment, read the oXy­gen ma­nuel chap­ter about plugin de­ve­lop­ment. Their blog also of­fers some help.

For ex­ten­ding the oXy­gen main win­dow we need to create a „Workspace Access Plugin“. A plugin al­ways con­sists of the fol­lo­wing sour­ces:

YourDemoPlugin.java
YourDemoPluginExtension.java
plugin.xml

plugin.xml is the plugin de­scrip­tor and you can set it up as fol­lows:

The <tool­bar> ele­ment de­fi­nes our custom tool­bar with its id at­tri­bute.

Next, we need YourDemoPlugin.java which is for con­ve­ni­ence and can re­turn an in­stance of our plugin. Haven’t found out what else you can use it for…

And fi­nally, YourDemoPluginExtension.java is the Extension its­elf. Your PluginExtension class al­ways needs to im­ple­ment the plugin type in­ter­face, like in our case, the WorkspaceAccessPluginExtension with it’s me­thods ap­p­li­ca­ti­on­S­tar­ted() and ap­p­li­ca­tionClo­sing(). We will use ap­p­li­ca­ti­on­S­tar­ted() to add our tool­bar and but­ton to the oXy­gen main win­dow at star­tup time. Take a look at the fol­lo­wing:

We add a ToolbarComponentsCustomizer and add a custom JButton if the cur­rently pro­ces­sed tool­bar equals our tool­bar ID in plugin.xml.

For demo re­a­sons I ad­ded a mes­sa­ge­Dia­log with the name of our tool­bar. Feel free to do wha­te­ver you want with the JButton…

However, don’t for­get to add your freshly crea­ted GUI com­po­n­ents to the tool­bar with toolbarInfo.setComponents() and name your tool­bar with toolbarInfo.setTitle().

To load the plugin in oXy­gen ex­port your Java Project as a JAR li­brary and go to the oXy­gen in­stal­la­tion di­rec­tory. Open the fol­der plugins/ and create your own plugin fol­der DemoButton/. Place the plugin.xml file in­side, create a fol­der lib/ in­side and place the jar file in it. Restart oXy­gen.

That’s it… 🙂

paginaEPUBChecker_markupforumAuf dem letz­ten Markupforum in Stuttgart (Nov. 2013) habe ich ei­nen Kurzvortrag über den pa­gina EPUB-Checker ge­hal­ten, den ich seit ca. 2-3 Jahren als Freeware ent­wickle (der EPUB-Checker ist eine gra­phi­sche Benutzeroberfläche um EPUB-E-Books zu va­li­die­ren).

Von mei­nem ehe­ma­li­gen HdM-Professor Marko Hedler wurde ich (und je­der an­dere Referent) nach dem Vortrag kurz in­ter­viewt. Sehr spon­tan, muss ich er­wäh­nen, um mein Stottern zu recht­fer­ti­gen 😉

Oder wie ein Kollege so nett meinte: „Du bist im Internet und kommst da nie wie­der raus.“ 😉

Die dies­jäh­rige European Outdoor Film Tour war mal wie­der ham­mer­mä­ßige Outdoor-Action! Absolut se­hens­wert und in­spi­rie­rend!

Auf ei­nige Filme mir be­son­ders gut ge­fal­len ha­ben möchte ich hier kurz hin­wei­sen.

Das wäre zum ei­nen die Doku „The Road From Karakol“ von Kyle Dempster der im Sommer 2011 mit dem Fahrrad al­leine quer durch Kirgistan ge­ra­delt ist. Den ge­sam­ten 25-Minuten-Film kann man sich üb­ri­gens auch auf Youtube an­schauen:

Soundtrack: Exitmusic – The Modern Age und Lemolomusic – Open Air

Und des­wei­te­ren der Canyoning-Film „The Beginning“ wel­cher mich als Canyoning-Begeisterten be­son­ders ge­flasht hat. Zumal ich in ei­ner der Tessiner-Schluchten („Boggera“) im Sommer selbst erst war. Den Trailer gibts hier, den ge­sam­ten Film kann man ab 4 € als VOD über die Website kau­fen.

Warren Verboom und sein Team ha­ben den wohl ers­ten Canyoning-Film über­haupt ge­dreht und ich kann euch die Vollversion nur wärms­tens emp­feh­len. Absolut kras­ser Shiet 😉