Adding myself some of the answers after a hard days work...

(I assume this mail list is moderated? which I would understand 
BTW, just a bit of an adaption, didn't read any message about this)

Marc Portier wrote:
> Hi there,
> 

<snip content="context" />

> 
> These are the 3 small commands that should tackle my problem:
> 1. tox.readAttribute att_name
> 
> returns the value of the @att_name on the selected node
> (strange that this is not available already?)
> 

finished, really simple code too:

        public boolean prepareCommand(
                Gadget gadget,
                String parameter,
                int x,
                int y) {
                Element selElm = getSelectedElement(gadget);
                return ((selElm != 
null)&&(selElm.getAttribute(Name.get("src"))!=null)) ;
        }

        protected Element getSelectedElement(Gadget gadget) {
                DocumentView docView = (DocumentView) gadget;
                MarkManager marks = docView.getMarkManager();
                NodeMark sel = marks.getSelected();
                Node selNode = sel.getNode();
                Element selElm = null;
                if(selNode.getNodeType() == Node.ELEMENT) {
                    selElm = (Element) selNode;
                }
                return selElm;
        }

        public Object executeCommand(
                Gadget gadget,
                String parameter,
                int x,
                int y) {
         return 
getSelectedElement(gadget).getAttribute(Name.get("src"));
        }
> 
> 2. tox.resolveSrc fileRelative path
>    tox.resolveSrc sysPropRelative path sysPropName
> 
> returns the resolved version of the path variable into an 
> absoluteFileName by either using the current file location (1st version) 
> or using a base-path found in a Java system property (2nd version of the 
> command)
> 
> Question: for the first version: is there a way to grab the current file 
> location? Which method/object I should ask?
> 

found this one after some search:
Document has getEntityURL();

        public boolean prepareCommand(
                Gadget gadget,
                String parameter,
                int x,
                int y) {
                return (parameter != null && !"".equals(parameter)) ;
        }

        public Object executeCommand(
                Gadget gadget,
                String parameter,
                int x,
                int y) {
         DocumentView docView = (DocumentView) gadget;
         Document doc = docView.getDocument();
         URL u = doc.getEntityURL();
         String url = u.toString();
         url = url.substring(0, url.lastIndexOf("/") + 1);
         return url + parameter;
        }

> 3. tox.openFile path
> 
> instructs xxe to open the file in a new document window.
> 

Which is leading me nowhere yet...
I did find something like
- new OpenedDocument(App)
- openedDoc.open(java.net.URL)

and maybe I will also need to create my own
- new Editor(App, OpenedDocument, StylesheetInfo)

I guess the StyleSheetInfo could be obtained from the 
App.getActiveEditor().getStyleSheetInfo();

assuming my reasoning is correct the issue remains to get a hold 
of the App instance, which I fail to find.

help is welcomed.

> Question: is there a way to do this? what is the method/object this 
> should go to?
> 
> thx for any pointers,
> -marc=

regards,

-marc=
-- 
Marc Portier                            http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at              http://radio.weblogs.com/0116284/
mpo at outerthought.org                              mpo at apache.org


Reply via email to