[Geoserver-devel] Best way to hook into the UI of the styling tabs

Hi,

I am currently investigating the possibility to introduce the geostyler
community extension into the different styling tabs.

At the moment, the extension hooks into the styling UI by creating a new
separate tab through the usage of the class
`org.geoserver.wms.web.data.StyleEditTabPanelInfo`.

This solution is not ideal, as the extension (and maybe other extensions
as well) is not really integrated / directly next to the sld editor.

Please have a look at this screenshot to get an idea what i intend to
do:
https://github.com/geostyler/geostyler/discussions/1324#discussioncomment-357127

I am still trying to figure out what other options there are, but it
seems at least for the styling there is no way of having a custom class
injected into the AbstractStylePage, which seems to be the right entry
point as it is the parent of all styling tabs.

My current solution makes minor changes to that class
(src/web/wms/src/main/java/org/geoserver/wms/web/data/AbstractStylePage.java):

WebMarkupContainer styleComponents = new
WebMarkupContainer("styleComponents");
styleComponents.setOutputMarkupId(true);
List<StyleComponentInfo> compInfo =
getGeoServerApplication().getBeansOfType(StyleComponentInfo.class);
for (StyleComponentInfo comp: compInfo) {
try {
Component c = (Component)
comp.getComponentClass().getConstructor(String.class,
AbstractStylePage.class)
.newInstance(comp.getId(), this);
styleComponents.add(c);
} catch (Exception e) {
throw new WicketRuntimeException(e);
}
}
styleForm.add(styleComponents);

That way i am able to inject my own extension class in the right spot.
But as this changes code in the core, i fear this may not be the way to go.

Are there any other ways to reach my goal and if not, do you see chances
that this change may get into the core when the usual requirements for
such a PR are met?

Thanks in advance!

Johannes Weskamm

Hi Johannes,
I agree that a new extension point is needed to achieve what you want. However I cannot evaluate your proposal,
in terms of “where it would happen” in the AbstractStylePage code.

The component you’re trying to add is basically an additional style editor, so it would have to go on the lower part of the page,
right on top of the CodeMirror editor, and be available as people switch between tabs, e.g., I’m guessing it should still be visible
when the map preview is on. And behave correctly when the “full screen” editor mode is enabled.

If that’s what you’re looking for, then we agree :smiley:

Cheers
Andrea

···

Regards, Andrea Aime

== GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.

Hi Andrea,

Yes, i forgot to mention the place where i wanted that code to be added and its like you describe, right above the code mirror editor:

https://github.com/geoserver/geoserver/blob/master/src/web/wms/src/main/java/org/geoserver/wms/web/data/AbstractStylePage.java#L396

And yes, the idea is to have the geostyler available even when the user switches tabs, as it is useful in any place where the current code mirror editor is.

You can see the current state of my idea in my fork here:

https://github.com/geoserver/geoserver/compare/master…weskamm:geostylerintegration

The main issue i am struggling with is the wicket part (which i am still learning), as it seems that i cannot render children through the template of the abstract style page without explicitly naming / creating HTML elements for them in the parent template. This is of course unwanted as we want to add children dynamically.

Maybe someone got a hint for that…

Anyways, is this something i should proceed with or are there other options to go for?

Greetings,

Johannes

···

Am 11.02.21 um 12:27 schrieb Andrea Aime:

Hi Johannes,
I agree that a new extension point is needed to achieve what you want. However I cannot evaluate your proposal,
in terms of “where it would happen” in the AbstractStylePage code.

The component you’re trying to add is basically an additional style editor, so it would have to go on the lower part of the page,
right on top of the CodeMirror editor, and be available as people switch between tabs, e.g., I’m guessing it should still be visible
when the map preview is on. And behave correctly when the “full screen” editor mode is enabled.

If that’s what you’re looking for, then we agree :smiley:

Cheers
Andrea

On Wed, Feb 10, 2021 at 5:24 PM Johannes Weskamm <weskamm@anonymised.com> wrote:

Hi,

I am currently investigating the possibility to introduce the geostyler
community extension into the different styling tabs.

At the moment, the extension hooks into the styling UI by creating a new
separate tab through the usage of the class
org.geoserver.wms.web.data.StyleEditTabPanelInfo.

This solution is not ideal, as the extension (and maybe other extensions
as well) is not really integrated / directly next to the sld editor.

Please have a look at this screenshot to get an idea what i intend to
do:
https://github.com/geostyler/geostyler/discussions/1324#discussioncomment-357127

I am still trying to figure out what other options there are, but it
seems at least for the styling there is no way of having a custom class
injected into the AbstractStylePage, which seems to be the right entry
point as it is the parent of all styling tabs.

My current solution makes minor changes to that class
(src/web/wms/src/main/java/org/geoserver/wms/web/data/AbstractStylePage.java):

WebMarkupContainer styleComponents = new
WebMarkupContainer(“styleComponents”);
styleComponents.setOutputMarkupId(true);
List compInfo =
getGeoServerApplication().getBeansOfType(StyleComponentInfo.class);
for (StyleComponentInfo comp: compInfo) {
try {
Component c = (Component)
comp.getComponentClass().getConstructor(String.class,
AbstractStylePage.class)
.newInstance(comp.getId(), this);
styleComponents.add(c);
} catch (Exception e) {
throw new WicketRuntimeException(e);
}
}
styleForm.add(styleComponents);

That way i am able to inject my own extension class in the right spot.
But as this changes code in the core, i fear this may not be the way to go.

Are there any other ways to reach my goal and if not, do you see chances
that this change may get into the core when the usual requirements for
such a PR are met?

Thanks in advance!

Johannes Weskamm


Geoserver-devel mailing list
Geoserver-devel@anonymised.coms.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Regards, Andrea Aime

== GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.

he main issue i am struggling with is the wicket part (which i am still learning), as it seems that i cannot render children through the template of the abstract style page without explicitly naming / creating HTML elements for them in the parent template. This is of course unwanted as we want to add children dynamically.

Maybe someone got a hint for that…

Create a fixed container element for it, that has a name, and make it invisible in case there is no plugin to be hosted inside.
Use a repeating container (e.g. ListView) if you want to allow adding more elements, otherwise a div with fixed id will do the
trick, and you can call setVisible(false) if you don’t have anything to fill it with (still needs to be declared, can be made into
a generic WebMarkupContainer)

Anyways, is this something i should proceed with or are there other options to go for?

Seems to me you’re on the right track, but cannot predict if others would like to add feedback, or not :smiley:

Cheers
Andrea

···

== GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.

Hi,

Yay, the ListView was the missing bit. I have updated my fork with the
current solution, thanks for the hint.

So now i will continue working in this direction and may come up with a
PR soon.

If anyone has ideas or wishes for the geostyler addon integration, feel
free to join the discussion at
https://github.com/geostyler/geostyler/discussions/1324

Greets,

Johannes