Hi Hussein,

I've come up with a cheat to accomplish my desired ability to set node trees as 
readonly using css. You may be able to tell me whether this is inadvisable or 
na?ve. I think perhaps it is at least a bit na?ve in that it assumes the 
context node is an alement, so it wouldn't work for comments or attibutes. With 
a bit more time I could probably solve that. I created a stylesheet extension 
that looks like this:

package com.pgs.xxe.css;

import com.xmlmind.xmledit.doc.Element;
import com.xmlmind.xmledit.doc.Node;
import com.xmlmind.xmledit.styledview.StyledViewFactory;
import com.xmlmind.xmledit.stylesheet.StyleSpecsBase;
import com.xmlmind.xmledit.stylesheet.StyleValue;

public class StyleSheetExtension extends StyleSpecsBase {
    
    public StyleSheetExtension(String[]args, StyledViewFactory 
styledviewfactory) {

    }
    
    public StyleValue readonly(StyleValue[] args, Node contextNode,
            StyledViewFactory viewFactory) {
        Element element = (Element) contextNode;
        element.setReadOnly(true);
        return null;
    }
}

And I created a css rule that looks like this:

content: invoke("readonly");


Because the readonly method returns a null StyleValue, it has no effect on the 
element content. As far as I can tell it's working, but it seems so simple that 
it couldn't possibly be covering everything, could it?

Regards,
Matt

-----Original Message-----
From: Hussein Shafie [mailto:[email protected]] 
Sent: 29 July 2008 15:23
To: Matt Flaherty
Cc: xmleditor-support at xmlmind.com
Subject: Re: [XXE] Can a tree be set to read-only from css?

Matt Flaherty wrote:
> Is it possible within
> the API to specify a custom display style value handler like the 
> inline-block and tree views? I have been digging around but so far 
> have not found how to extend that if it's even possible. On the other 
> hand, would it be done similar to this?
> http://www.xmlmind.com/xmleditor/_distrib/doc/dev/styleext.html#soluti
> on
> 1

You can do many things. This is how the form controls -- see 
XXE_install_dir/demo/form-sampler.xml --

Slightly edited excerpt of
XXE_install_dir/demo/form-sampler/form-sampler.css:
---
rgb2 {
     content: gadget("com.xmlmind.xmledit.form.ComboBox",
                     labels, "Green\A Blue\A Red",
                     values, "green\A blue\A red"); }
---
(http://www.xmlmind.com/xmleditor/_distrib/doc/csssupport/gadget.html)

and the support of MathML have been implemented.

Slightly edited excerpt of MathML_addon_install_dir/common/mathml.css:
---
mml|msqrt {
   /* Block-like */
   display: view("com.xmlmind.xmleditext.mathml.MathElementViewFactory");
}
---

However the most advanced techniques are not documented. For now, you just have:

---
smiley {
     content: component("Smiley");
     font: normal normal small sans-serif;
     /* Needed to display the red border of the selection */
     display: inline-block;
     padding: 1px;
}
---

That is, you can replace the normal view of a styled element by a custom 
component.

See "XMLmind XML Editor - Developer's Guide", "Active custom views: 
specialized editors embedded in the DocumentView" 
http://www.xmlmind.com/xmleditor/_distrib/doc/dev/styleext.html#d0e5046



This email and any files contained therein is confidential and may contain 
privileged information.  If you are not the named addressee(s) or you have 
otherwise received this in error, you should not distribute or copy this e-mail 
or use any of its content for any purpose. Please notify the sender immediately 
by e-mail if you have received this e-mail in error and delete it from your 
system

Reply via email to