Mozilla
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives Mailing Lists Mozilla

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old June 24th, 2007, 06:40 PM
Daniel Kirsch
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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

Reply With Quote
  #2  
Old June 26th, 2007, 12:20 PM
dunghb
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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

Reply With Quote
  #3  
Old June 26th, 2007, 05:20 PM
Daniel Kirsch
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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

Reply With Quote
  #4  
Old June 26th, 2007, 05:20 PM
Neil Deakin
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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

Reply With Quote
  #5  
Old June 27th, 2007, 06:20 PM
Daniel Kirsch
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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

Reply With Quote
  #6  
Old July 4th, 2007, 06:20 AM
Neil
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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

Reply With Quote
  #7  
Old July 10th, 2007, 08:01 AM
Daniel Kirsch
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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

Reply With Quote
Reply

Viewing: Web Development Archives Mailing Lists Mozilla > Selecting a row with a given URL in a rdf:files tree


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT