File Tree Bug

185 views
Skip to first unread message

austi...@gmail.com

unread,
Mar 15, 2012, 10:46:21 AM3/15/12
to codenameone...@googlegroups.com
Hi,

I just noticed a small bug with the filetree UI element. It works fine untill at depth 2 the file path separator '/' is not appended to the file path. This makes it impossible to browse the folders.

Please can you fix it for us. Thanks.
filetree bug.JPG

Eric Coolman

unread,
Mar 15, 2012, 11:58:19 AM3/15/12
to codenameone...@googlegroups.com
Bugs should really be filed in the issue tracker rather than the discussion forum, better chance at it getting prioritized and fixed:

http://code.google.com/p/codenameone/issues/list

Shai Almog

unread,
Mar 15, 2012, 2:26:23 PM3/15/12
to codenameone...@googlegroups.com
Its a highly buggy component, the paths should be a single element and not the full path for every node within the tree.
As Eric said you can file an issue on that and we will try to address it soon.

Thanks.

Akintayo Olusegun

unread,
Apr 8, 2012, 3:08:59 PM4/8/12
to codenameone...@googlegroups.com
I needed this feature so bad I wrote a fix for it. See here http://code.google.com/p/codenameone/issues/detail?id=97

The trick is to copy the FileTreeModel.java into your source tree then do this

                    FileTree fileTree = new FileTree();
                    fileTree.setModel(new FileTreeModel(true));


Make sure you edit the package name on the file accordingly. And make sure you import the FileTreeModel in your source tree, not the one in the lib.

Until an official release that fixes this bug is issued, this one works.
--
You received this message because you are subscribed to the Google
Groups "CodenameOne Discussions" group.
 
For more information about Codename One please visit http://www.codenameone.com/
 
To post to this group, send email to
codenameone...@googlegroups.com
To unsubscribe from this group, send email to
codenameone-discu...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/codenameone-discussions?hl=en?hl=en


-- 
pǝʇɐʇs ǝsıʍɹǝɥʇo ssǝʃun ˙unƃǝsnʃO ˙∀ oʎɐʇuıʞ∀

aardvocate akintayo olusegun don.

Shai Almog

unread,
Apr 8, 2012, 3:16:34 PM4/8/12
to codenameone...@googlegroups.com
Sorry about missing it. I'm not quite in full throttle focus.
What's the actual fix?

austi...@gmail.com

unread,
Apr 10, 2012, 8:05:45 AM4/10/12
to codenameone...@googlegroups.com
Thanks anyway but my folder browser UI element helps me a lot too.


On Sunday, April 8, 2012 8:08:59 PM UTC+1, Akintayo Olusegun wrote:
I needed this feature so bad I wrote a fix for it. See here http://code.google.com/p/codenameone/issues/detail?id=97

The trick is to copy the FileTreeModel.java into your source tree then do this

                    FileTree fileTree = new FileTree();
                    fileTree.setModel(new FileTreeModel(true));


Make sure you edit the package name on the file accordingly. And make sure you import the FileTreeModel in your source tree, not the one in the lib.

Until an official release that fixes this bug is issued, this one works.

On 3/15/12 3:46 PM, austi...@gmail.com wrote:
Hi,

I just noticed a small bug with the filetree UI element. It works fine untill at depth 2 the file path separator '/' is not appended to the file path. This makes it impossible to browse the folders.

Please can you fix it for us. Thanks.
--
You received this message because you are subscribed to the Google
Groups "CodenameOne Discussions" group.
 
For more information about Codename One please visit http://www.codenameone.com/
 
To post to this group, send email to

To unsubscribe from this group, send email to

Akintayo Olusegun

unread,
Apr 10, 2012, 8:12:59 AM4/10/12
to codenameone...@googlegroups.com
What I actually needed was a folder browser.

You just solved 50% of my problems.

Muchas Gracias

To unsubscribe from this group, send email to

Akintayo Olusegun

unread,
Apr 8, 2012, 3:41:57 PM4/8/12
to codenameone...@googlegroups.com
Also I can't seem to select a directory, only a file.

                    fileTree.addLeafListener(new ActionListener() {

                        public void actionPerformed(ActionEvent evt) {
                            System.out.println(fileTree.getSelectedItem());
                        }
                    });

In the above, only the files are printed, the directories are not. Even when I initialise the tree thus
                    final FileTree fileTree = new FileTree();
                    final FileTreeModel model = new FileTreeModel(false);


I need a way to selected the directory.

Thanks


On 4/8/12 8:16 PM, Shai Almog wrote:
Sorry about missing it. I'm not quite in full throttle focus.
What's the actual fix?
--
You received this message because you are subscribed to the Google
Groups "CodenameOne Discussions" group.
 
For more information about Codename One please visit http://www.codenameone.com/
 
To post to this group, send email to
codenameone...@googlegroups.com
To unsubscribe from this group, send email to
codenameone-discu...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/codenameone-discussions?hl=en?hl=en

Akintayo Olusegun

unread,
Apr 8, 2012, 3:30:55 PM4/8/12
to codenameone...@googlegroups.com
You can compare with the original file.

The modified code is in green
            if (parent == null) {
                String[] roots = FileSystemStorage.getInstance().getRoots();
                for (int iter = 0; iter < roots.length; iter++) {
                    response.addElement(roots[iter]);
                }
            } else {
                String name = (String) parent;
                String[] res = FileSystemStorage.getInstance().listFiles(name);
                /**If separator is the last character in name, we are ok, else make separator the last character                
                 * For some reasons I don't like to modify the name variable, so I created a new variable
                 * newFileStart, from here onwards all occurrences of name becomes newFileStart
                 */
                String newFileStart = name.indexOf(separator) == (name.length() - 1) ? name : name + separator;
                if (showFiles) {                   
                    for (int iter = 0; iter < res.length; iter++) {
                        response.addElement(newFileStart + res[iter]);
                    }
                } else {
                    for (int iter = 0; iter < res.length; iter++) {
                        if (FileSystemStorage.getInstance().isDirectory(newFileStart + res[iter])) {
                            response.addElement(newFileStart + res[iter]);
                        }
                    }
                }

            }

On 4/8/12 8:16 PM, Shai Almog wrote:
Sorry about missing it. I'm not quite in full throttle focus.
What's the actual fix?
--
You received this message because you are subscribed to the Google
Groups "CodenameOne Discussions" group.
 
For more information about Codename One please visit http://www.codenameone.com/
 
To post to this group, send email to
codenameone...@googlegroups.com
To unsubscribe from this group, send email to
codenameone-discu...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/codenameone-discussions?hl=en?hl=en
Reply all
Reply to author
Forward
0 new messages