Framework Customization: Hide Elements (Tags) in AuthorView using Stylesfilter.

Having trouble installing Oxygen? Got a bug to report? Post it all here.
Stevee
Posts: 16
Joined: Wed Jan 12, 2022 6:17 pm

Framework Customization: Hide Elements (Tags) in AuthorView using Stylesfilter.

Post by Stevee »

Hi,
i want to hide several XML-Tags ( and their children) , from the AuthorView.

I used the following approach:
In a Stylesfilter, i check for the AuthorNode which i want to hide. I then use the according Styles object which i receive in the filter Method and do

Code: Select all

styles.setProperty(Styles.KEY_DISPLAY, "none");
I aussme this sets the CSS-Property display to value none, which i would expect that this hides the Element.
But it seems that setting this property has no effect at all.

If i use

Code: Select all

styles.setProperty(Styles.KEY_VISIBILITY, "hidden");
the Tags get invisibile, but of course the Element still takes its space in the Layout.

Does someone know how i can hide Elements completly from AuthorView, including that they dont need any space in the Layout?

Greetings
Stevee
Stevee
Posts: 16
Joined: Wed Jan 12, 2022 6:17 pm

Re: Framework Customization: Hide Elements (Tags) in AuthorView using Stylesfilter.

Post by Stevee »

Sorry, i forgot to add some additional Information about my used Oxygen Version:
I am using:
<oXyygen/> XML Author 23.1 , build: 2021030206
Eclipse Plugin.
Radu
Posts: 9434
Joined: Fri Jul 09, 2004 5:18 pm

Re: Framework Customization: Hide Elements (Tags) in AuthorView using Stylesfilter.

Post by Radu »

Hi Steeve,

I tried this on my side:

1) An XML document looking like this:

Code: Select all

<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="topic_vfq_mbq_x5b">
    <title>T</title>
    <prolog>
        <author>hidden</author>
        <resourceid/>
    </prolog>
    <body>
        <p>para</p>
    </body>
</topic>
2) With the StylesFilter implementation I attempt to hide its entire "prolog":

Code: Select all

new StylesFilter() {
      
      @Override
      public String getDescription() {
        return "abc";
      }
      
      @Override
      public Styles filter(Styles styles, AuthorNode authorNode) {
        if("prolog".equals(authorNode.getName())) {
          styles.setProperty(Styles.KEY_DISPLAY, ro.sync.ecss.css.CSS.NONE);
        }
        return styles;
      }
    }
and this seems to work for me. That "ro.sync.ecss.css.CSS.NONE" is equivalent to the literal "none" that you are using.
Can you try something similar on your side? Does your StylesFilter's "filter" method actually get called?
How did you set up the StylesFilter on your side?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Stevee
Posts: 16
Joined: Wed Jan 12, 2022 6:17 pm

Re: Framework Customization: Hide Elements (Tags) in AuthorView using Stylesfilter.

Post by Stevee »

Hi Radu,

thanks for your reply.

My code gets called. If i set another CSS-Property like the visibility - hidden, that works, and the style is applied to the authorNode that i expect that it has to.

My Stylesfilter Method looks like this:

Code: Select all

    @Override
    public Styles filter(Styles styles, AuthorNode authorNode) {

        if (authorNode.getType() == AuthorNode.NODE_TYPE_ELEMENT) {
            if (shouldHideElement(authorNode)) {   //Determines if a element should be visibile 

                styles.setProperty(Styles.KEY_DISPLAY, "none");
                // styles.setProperty(Styles.KEY_VISIBILITY, "hidden");  //This would take effect if it is not a comment. 
            }

        }
        return styles;
    }
I also checked for other Styling Information. There is a CSS-Associated with the Document that is currently in editing (and for which the Stylesfilter is applyed for), but even if i remove the CSS-Files from the Document that does not work.

If i use the CSS-Property (display:none) directly in an associated CSS-File, it works.
Radu
Posts: 9434
Joined: Fri Jul 09, 2004 5:18 pm

Re: Framework Customization: Hide Elements (Tags) in AuthorView using Stylesfilter.

Post by Radu »

Hi,

Can you also answer the questions I asked in my previous post:

Does your StylesFilter's "filter" method actually get called?
- Maybe here you can add some logging in the "if" clause like "System.err.println(authorNode);" to see if the node is actually matched by your "shouldHideElement" method.

How did you set up the StylesFilter on your side?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply