|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Selecting a row with a given URL in a rdf:files tree
I create a treeview using the rdf:files datasource. I now want to select
the row referencing the file for a given URL. If the file is currently not visible because it's container is closed, it should be made visible by opening the containers. I know how to open the containers and select an entry, but I couldn't find a way to find the correct row or the row(s) to open. Any ideas? Thanks Daniel dev-tech-xul mailing list dev-tech-xul (AT) lists (DOT) mozilla.org |
|
#2
|
|||
|
|||
|
Selecting a row with a given URL in a rdf:files tree
Jun 25, 6:19 am, Daniel Kirsch <Iwillnotread_dan (AT) gmx (DOT) dewrote:
I create a treeview using the rdf:files datasource. I now want to select the row referencing the file for a given URL. If the file is currently not visible because it's container is closed, it should be made visible by opening the containers. > I know how to open the containers and select an entry, but I couldn't find a way to find the correct row or the row(s) to open. > Any ideas? > Thanks Daniel I guess you must first get a resource which points to that URL. res = rdfService.getResource(uri); After that you can use getIResource() of the treebuilder of that tree to get the index of the resource. Now you use the index to select the right row. e.g tree.view.selection.select(index); HTH Max dev-tech-xul mailing list dev-tech-xul (AT) lists (DOT) mozilla.org |
|
#3
|
|||
|
|||
|
Selecting a row with a given URL in a rdf:files tree
dunghb schrieb:
I guess you must first get a resource which points to that URL. res = rdfService.getResource(uri); After that you can use getIResource() of the treebuilder of that tree to get the index of the resource. Now you use the index to select the right row. e.g tree.view.selection.select(index); Will that work with hidden elements too? eg because their parent folder is closed? They don't have an index. Daniel dev-tech-xul mailing list dev-tech-xul (AT) lists (DOT) mozilla.org |
|
#4
|
|||
|
|||
|
Selecting a row with a given URL in a rdf:files tree
Daniel Kirsch wrote:
I create a treeview using the rdf:files datasource. I now want to select the row referencing the file for a given URL. If the file is currently not visible because it's container is closed, it should be made visible by opening the containers. I know how to open the containers and select an entry, but I couldn't find a way to find the correct row or the row(s) to open. Any ideas? There isn't a means to do this with a template as the child rows aren't processed and created until the parent row is opened. You would need to use the RDF API to scan up from a file to its parent directories, until you come to one where the file resource matches one that exists in the tree. From there, open each directory until you get to the file. Neil dev-tech-xul mailing list dev-tech-xul (AT) lists (DOT) mozilla.org |
|
#5
|
|||
|
|||
|
Selecting a row with a given URL in a rdf:files tree
Neil Deakin schrieb:
You would need to use the RDF API to scan up from a file to its parent directories, until you come to one where the file resource matches one that exists in the tree. From there, open each directory until you get to the file. Yes, I've allready done something similar: <method name="showUrl"> <parameter name="url" /> <body><![CDATA[ var cols = this.tree.columns; var view = this.view; // remove the file stuff in front. We don't need that // and split the result so each directory name is defined in one entry var urlArray = url.replace("file:///","").split("/"); var aryPos = 0; var pos = 0; var col = cols[0]; var t = view.getCellText(pos,col); while (t) { // if the current cells text is the same as the one in our Array, we've found the next pos if (t == urlArray[aryPos]) { // check, if this is the last entry. If so, just select that and return. aryPos++; if (urlArray.length == aryPos) { view.selection.select(pos); this.scrollToRow(Math.max(pos-2,0)); return pos; } // If we are not at the end of our search, the element must be a container. try { // open it, if i's not open allready if (!view.isC(pos)) { State(pos); } } catch(e) { // something went wrong. Nothing we can actually do, so just return return -1; } } pos++; try { t = view.getCellText(pos,col); } catch(e) { return -1; } } return -1; ]]></body> </method> Ah, well, the scrollToRow method is quite simple: <method name="scrollToRow"> <parameter name="index" /> <body><![CDATA[ var boxobject = ; boxobject.QueryInterface(Components.interfaces.nsI TreeB); boxobject.scrollToRow(index); ]]></body> </method> "this.tree" is referencing the xul:tree element. Maybe this is of some help. Suggestions, how to improve that are welcome. Daniel dev-tech-xul mailing list dev-tech-xul (AT) lists (DOT) mozilla.org |
|
#6
|
|||
|
|||
|
Selecting a row with a given URL in a rdf:files tree
Daniel Kirsch wrote:
Ah, well, the scrollToRow method is quite simple: > <method name="scrollToRow"> <parameter name="index" /> <body><![CDATA[ var boxobject = ; boxobject.QueryInterface(Components.interfaces.nsI TreeB); boxobject.scrollToRow(index); ]]></body> </method> What's wrong with this.tree.treeBToRow(index); ? Suggestions, how to improve that are welcome. There's a similar method in msgMail3PaneWindow.js called EnsureFolderIndex. Basically it looks up the RDF resource in the tree and if it doesn't find it then it obtains the parent resource (fortunately for a message folder there's a .parent property but in your case you would have to trim your URL and retrieve the new resource) and calls itself recursively to open the parent item. -- Warning: May contain traces of nuts. dev-tech-xul mailing list dev-tech-xul (AT) lists (DOT) mozilla.org |
|
#7
|
|||
|
|||
|
Selecting a row with a given URL in a rdf:files tree
Neil wrote:
What's wrong with this.tree.treeBToRow(index); ? Nothing. I just didn't recognized that it allready exists :-) There's a similar method in msgMail3PaneWindow.js called EnsureFolderIndex. This looks nice. I like recursions. I'm going to check that out and try to get it working. Thanks Daniel dev-tech-xul mailing list dev-tech-xul (AT) lists (DOT) mozilla.org |
![]() |
| Viewing: Web Development Archives > Mailing Lists > Mozilla > Selecting a row with a given URL in a rdf:files tree |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|