Hussein, thanks a lot, it worked.

My 2nd question now (was having this problem before with the
implementation of documentChecked() too):

The extension has this CSS:

@charset "UTF-8";
@import url(xxe-config:docbook5/css/docbook5.css);
@namespace prop "http://www.xmlmind.com/xmleditor/namespace/property";;

/*
 * Read-Only parts
 */
*:property(prop|readOnly, "true") {
  background-color: #E0F0F0;
  color: #999;
}

*:property(prop|readOnly, "false") {
  background-color: normal;
  color: normal;
}

However, the element in question (a whole section in this case, just
started testing with this extension mechanism) is not rendered with
the above style.

I've noticed using the nodepath at the top of the document view that
the section is properly marked read-only, its part of the path is
shown in violet, instead of black, and I cannot effectively modify
anything on that section, but I don't have visual feedback (expecting
gray text and the light blue background) that the section is marked
read-only.

If I add a toolbar button running the readOnly command, the CSS is
taken into account and I do see the rendering OK.

Once I've traversed and processed the document in the ValidateHook at
Reason.OPEN time, what may I be missing to have the CSS styles apply?

I hope to have been clear, the Java code marking things read-only is this:

        @Override
        public void checkingDocument(Document doc, Reason reason, URL 
saveAsURL) {
                if (Reason.OPEN.equals(reason)) {
                        final ArrayList<Element> readOnlyParts = new 
ArrayList<Element>();
                        Traversal.traverse(doc.getRootElement(), new 
Traversal.HandlerBase() {
                                @Override
                                public Object enterElement(Element element) {
                                        if (SECTION.equals(element.getName())) {
                                                if 
(readOnlyItems.contains(element.getAttribute(Name.XML_ID))) {
                                                        
readOnlyParts.add(element);
                                                }
                                        }
                                        return null;
                                }
                        });
                        for (Element roPart : readOnlyParts) {
                                System.err.println("Found R/O item " + roPart + 
" with xml:id=" +
roPart.getAttribute(Name.XML_ID));
                                doc.setNotifyDisabled(true);
                                doc.beginEdit();
                                
roPart.putProperty(Name.get("http://www.xmlmind.com/xmleditor/namespace/property";,
"readOnly"), Boolean.TRUE); // Mark it R/O
                                doc.endEdit();
                                doc.setNotifyDisabled(false);
                        }
                System.err.println("documentChecked '" + doc.getSourceURL() + 
"'");
                } // else ignore other reasons, only perform at document open 
time
        }

2011/7/23 Hussein Shafie <[email protected]>:
> On 07/23/2011 12:02 AM, Fabián Mandelbaum wrote:
>>
>> I was wondering if there's currently something similar to the previous
>> DocumentHook. I'd need to perform certain tasks (mark certain parts of
>> the document as read-only) at document open time. I'm currently doing
>> it with a ValidationHook, but this hook is also executed at document
>> save time, and when the user chooses the Tools>  Validate menu. I'd
>> like to avoid this extra work every time the document is saved or the
>> user runs a validation of it. Is this possible with XXE 4.9.1?
>
> Yes, you must implement ValidateHook.checkingDocument.
>
> checkingDocument is passed a Reason argument. If the Reason argument is
> different from Reason.OPEN, then simply do nothing at all.
>
> References:
>
> http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xmleditapp/validatehook/ValidateHook.html
>
> http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xmleditapp/validatehook/Reason.html
>



-- 
Fabián Mandelbaum
IS Engineer
 
--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to