file browser tree

Hello Everyone,

I have made a tree that traverses the server’s files very well using vaadin example of File browser(
File Browser Example vaadin
). But it shows the entire path for each leaf. How can I get it to only show a folder or file name,folder Icon without showing the full path?

it show as below example Eg:
:rolleyes:
foldername
|
|_fileone
|
filetwo etc…

Thanks in advance

please give response with respective above example( vaddin program ) :rolleyes:

Mukthyar

I think following properties can be used.

tree.setItemIconPropertyId("Icon");
    tree.setItemCaptionPropertyId("Name");
    tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);

Thanks for quick response…1).file browser giving out put as >____
|>
|
> with out any name for the file paths(But i need file (or) folder name),i used the below code [quote]
filesystem.setItemCaptionPropertyId(“Name”);
[/quote]

                                                2) filesystem.setItemIconPropertyId("Icon");  Icon is giving run time error..please provide the solution with respective vaadin example code [url=http://dev.vaadin.com/browser/svn/versions/6.0/src/com/vaadin/tests/TreeFilesystem.java]

Example code
[/url]

Thanks in advance
Mukthyar:rolleyes:

Thanks Shakir,please provide the proper solution for this issue…

Thanks
Azam

Specific to your problem
At line # 86 of your sample code

final String path = files[x]
.getName();

since file.getCanonicalPath() return complete path

I was proposing a generic solution in my last post.
remove setIcon , since you are using File object directly. which does not have any ICON associated with it.

Thanks for response, please provide solution for my above problem to show (folder or file )name instead of displaying whole file or folder path.

Thanks
Mukthyar

Hi,

Have you tried the proposed above method File#getName() instead of File#getCanonicalPath()?

cheers,
sasha

Hi,
Alexander V Pchelintsev ,I tried above code String path = files
.getName().toString(); its giving Null pointer Exception at line populateNode(event.getItemId().toString(), event.getItemId()); because we have to pass file path as parameter for populateNode not a fileName please tell some solution for this :grin:

    private void populateNode(String file, Object parent) {
        final File subdir = new File(file);
           final File[] files = subdir.listFiles();
             for (int x = 0; x < files.length; x++) {
                  try {  }
                  catch(Exception e)

{

}
}

for Example you can see this
file Browser Vaadin

Thanks :blink:
Mukthyar

ok,

There’s an outline of a way that I would follow in such a case.

  1. Create an HierarchicalContainer fsContainer;
  2. Add a property to that container (for the display).
fsContainer.addContainerProperty("name", String.class, "");
  1. Populate the nodes the same way (but instead referring to the Tree - operate with the fsContainer). Also, for every added Item (that has a path as an id) you have to specify the name property.
Item item = fsContainer.addItem(path);
item.getItemProperty("name").setValue(files[x]
.getName());
  1. Assign the container to the Tree and set the display property:
tree.setContainerDataSource(fsContainer);
tree.setItemCaptionPropertyId("name");

cheers,
sasha

Hi,
I achieved this by using code file
.getName().toString,by concatenating parent path to its children files…so on at the end i got result from
By using Eg code
,

but i got this idea by your advice ( to use file.getName())

Thanks for help
Azam