Index: /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/thread/ThreadPhotoSending.java
===================================================================
--- /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/thread/ThreadPhotoSending.java	(revision 8834)
+++ /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/thread/ThreadPhotoSending.java	(revision 8834)
@@ -0,0 +1,73 @@
+package fr.mael.jiwigo.ui.mainframe.thread;
+
+import java.io.File;
+
+import javax.swing.JOptionPane;
+
+import fr.mael.jiwigo.service.ImageService;
+import fr.mael.jiwigo.transverse.util.Messages;
+import fr.mael.jiwigo.ui.mainframe.MainFrame;
+import fr.mael.jiwigo.ui.mainframe.ThumbnailCategoryPanel;
+
+/**
+   Copyright (c) 2010, Mael
+   All rights reserved.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+    * Neither the name of jiwigo nor the
+      names of its contributors may be used to endorse or promote products
+      derived from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+   DISCLAIMED. IN NO EVENT SHALL Mael BE LIABLE FOR ANY
+   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * @author mael
+ * Thread that send the photos
+ */
+public class ThreadPhotoSending implements Runnable {
+    private File[] files;
+    private ThumbnailCategoryPanel thumbPanel;
+
+    public ThreadPhotoSending(File[] files, ThumbnailCategoryPanel thumbPanel) {
+	this.files = files;
+	this.thumbPanel = thumbPanel;
+    }
+
+    @Override
+    public void run() {
+
+	for (int i = 0; i < files.length; i++) {
+	    int nbProgressBar = ((i + 1) * 100) / files.length;
+	    try {
+		MainFrame.getInstance().setAdditionalMessage(
+			Messages.getMessage("file") + " " + (i + 1) + "/" + files.length + " : ");
+		ImageService.getInstance().creer(files[i].getCanonicalPath(), thumbPanel.getCategoryId());
+		MainFrame.getInstance().setMessage(files[i].getName() + " " + Messages.getMessage("sendingSuccess"));
+	    } catch (Exception e) {
+		//displays a dialog if there is an error
+		JOptionPane.showMessageDialog(null, Messages.getMessage("sendingError") + files[i].getName(), Messages
+			.getMessage("error"), JOptionPane.ERROR_MESSAGE);
+		MainFrame.getInstance().setMessage(Messages.getMessage("sendingError") + " " + files[i].getName());
+	    } finally {
+		MainFrame.getInstance().getProgressBar().setValue(nbProgressBar);
+	    }
+	}
+	MainFrame.getInstance().setAdditionalMessage("");
+	//refresh
+	thumbPanel.rafraichir(thumbPanel.getCategoryId(), true);
+	MainFrame.getInstance().getProgressBar().setValue(0);
+    }
+}
Index: /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/File.java
===================================================================
--- /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/File.java	(revision 8834)
+++ /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/File.java	(revision 8834)
@@ -0,0 +1,69 @@
+package fr.mael.jiwigo.ui.search;
+
+/**
+Copyright (c) 2010, Mael
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+ * Neither the name of jiwigo nor the
+   names of its contributors may be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Mael BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+* @author mael
+* Class that extends a file. Allows to display the files in the tree with only their names (instead
+* of their path)
+*/
+public class File extends java.io.File {
+
+    /**
+     * Constructor
+     * @param pathname
+     */
+    public File(String pathname) {
+	super(pathname);
+    }
+
+    @Override
+    public String toString() {
+	// TODO Auto-generated method stub
+	return this.getName();
+    }
+
+    /**
+     * This method is overriden to allow listing fr.mael.jiwigo.ui.search.File
+     * instead of java.io.Files
+     * @see java.io.File#listFiles()
+     */
+    @Override
+    public File[] listFiles() {
+	// TODO Auto-generated method stub
+	java.io.File files[] = super.listFiles();
+	if (files == null) {
+	    return new File[0];
+	} else {
+	    File myFiles[] = new File[files.length];
+	    for (int i = 0; i < files.length; i++) {
+		myFiles[i] = new File(files[i].getAbsolutePath());
+	    }
+	    return myFiles;
+	}
+    }
+
+}
Index: /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/ImageSearchDisplay.java
===================================================================
--- /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/ImageSearchDisplay.java	(revision 8834)
+++ /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/ImageSearchDisplay.java	(revision 8834)
@@ -0,0 +1,79 @@
+package fr.mael.jiwigo.ui.search;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.AffineTransform;
+import java.awt.image.BufferedImage;
+
+import javax.swing.JPanel;
+
+/**
+    Copyright (c) 2010, Mael
+   All rights reserved.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+    * Neither the name of jiwigo nor the
+      names of its contributors may be used to endorse or promote products
+      derived from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+   DISCLAIMED. IN NO EVENT SHALL Mael BE LIABLE FOR ANY
+   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * @author mael
+ * Panel which displays an image in the @see fr.mael.jiwigo.ui.search.ImageSearchPanel
+ */
+public class ImageSearchDisplay extends JPanel {
+    private BufferedImage image;
+
+    public ImageSearchDisplay() {
+    }
+
+    public ImageSearchDisplay(BufferedImage image) {
+	this.image = image;
+    }
+
+    public void changeImage(BufferedImage image) {
+	this.image = image;
+	revalidate();
+	repaint();
+    }
+
+    protected void paintComponent(Graphics g) {
+	super.paintComponent(g);
+	Graphics2D g2 = (Graphics2D) g;
+	g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+	if (image != null) {
+	    double x = (getWidth() - image.getWidth()) / 2;
+	    double y = (getHeight() - image.getHeight()) / 2;
+	    AffineTransform at = AffineTransform.getTranslateInstance(x, y);
+	    g2.drawRenderedImage(image, at);
+	}
+	//	g2.drawImage(image, 0, 0, null);
+
+    }
+
+    public Dimension getPreferredSize() {
+	if (image != null) {
+	    int w = (int) (image.getWidth());
+	    int h = (int) (image.getHeight());
+	    return new Dimension(w, h);
+	} else {
+	    return new Dimension(100, 100);
+	}
+    }
+}
Index: /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/ImageSearchPanel.java
===================================================================
--- /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/ImageSearchPanel.java	(revision 8834)
+++ /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/ImageSearchPanel.java	(revision 8834)
@@ -0,0 +1,78 @@
+package fr.mael.jiwigo.ui.search;
+
+import java.awt.BorderLayout;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultMutableTreeNode;
+
+import fr.mael.jiwigo.ui.search.tree.FileTree;
+
+/**
+    Copyright (c) 2010, Mael
+   All rights reserved.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+    * Neither the name of jiwigo nor the
+      names of its contributors may be used to endorse or promote products
+      derived from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+   DISCLAIMED. IN NO EVENT SHALL Mael BE LIABLE FOR ANY
+   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * @author mael
+ *
+ */
+public class ImageSearchPanel extends JPanel implements TreeSelectionListener {
+    private ImageSearchDisplay imageSearchDisplay;
+
+    private FileTree fileTree;
+
+    public ImageSearchPanel() {
+	this.setLayout(new BorderLayout());
+	fileTree = new FileTree(System.getProperty("user.home"));
+	fileTree.getTree().addTreeSelectionListener(this);
+	this.add(fileTree, BorderLayout.WEST);
+	imageSearchDisplay = new ImageSearchDisplay();
+
+	JScrollPane scrollPane = new JScrollPane(imageSearchDisplay);
+	//	scrollPane.setPreferredSize(new Dimension(100, 100));
+	this.add(scrollPane, BorderLayout.CENTER);
+    }
+
+    @Override
+    public void valueChanged(TreeSelectionEvent arg0) {
+	DefaultMutableTreeNode node = (DefaultMutableTreeNode) fileTree.getTree().getLastSelectedPathComponent();
+	if (node == null)
+	    return;
+	File selectedFile = (File) node.getUserObject();
+	if (!selectedFile.isFile()) {
+	    return;
+	}
+	try {
+	    BufferedImage image = ImageIO.read(new File(selectedFile.getAbsolutePath()));
+	    imageSearchDisplay.changeImage(image);
+	} catch (IOException e) {
+	    e.printStackTrace();
+	}
+    }
+
+}
Index: /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/tree/FileTree.java
===================================================================
--- /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/tree/FileTree.java	(revision 8834)
+++ /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/tree/FileTree.java	(revision 8834)
@@ -0,0 +1,198 @@
+package fr.mael.jiwigo.ui.search.tree;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.ArrayList;
+
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import javax.swing.JTree;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeSelectionModel;
+
+import fr.mael.jiwigo.ui.search.File;
+
+/**
+    Copyright (c) 2010, Mael
+    All rights reserved.
+    
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+     * Redistributions of source code must retain the above copyright
+       notice, this list of conditions and the following disclaimer.
+     * Redistributions in binary form must reproduce the above copyright
+       notice, this list of conditions and the following disclaimer in the
+       documentation and/or other materials provided with the distribution.
+     * Neither the name of jiwigo nor the
+       names of its contributors may be used to endorse or promote products
+       derived from this software without specific prior written permission.
+    
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL Mael BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+    
+    * @author mael
+    * File tree
+*/
+public class FileTree extends JPanel implements TreeSelectionListener, MouseListener {
+    private String path;
+
+    private JTextField fieldPath;
+
+    private DefaultMutableTreeNode root = new DefaultMutableTreeNode("");
+
+    private JTree tree;
+
+    public static void main(String[] args) {
+	JFrame frame = new JFrame();
+	frame.add(new FileTree("/home/mael/Documents"));
+
+	frame.pack();
+	frame.setVisible(true);
+	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+    }
+
+    /**
+     * Constructor
+     * @param path : the path of the directory where to search for files
+     */
+    public FileTree(String path) {
+	super(new BorderLayout());
+	this.path = path;
+	fieldPath = new JTextField(path);
+	fieldPath.addMouseListener(this);
+	tree = new JTree(root);
+	tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+	tree.addTreeSelectionListener(this);
+	tree.setCellRenderer(new MyTreeCellRenderer());
+	tree.setRootVisible(false);
+	JScrollPane treeView = new JScrollPane(tree);
+	Dimension minimumSize = new Dimension(100, 50);
+	treeView.setMinimumSize(minimumSize);
+	this.add(treeView, BorderLayout.CENTER);
+	this.add(fieldPath, BorderLayout.NORTH);
+	reload();
+    }
+
+    public void reload() {
+	root.removeAllChildren();
+	createNodes(root);
+	((DefaultTreeModel) tree.getModel()).reload();
+    }
+
+    private void createNodes(DefaultMutableTreeNode root) {
+	DefaultMutableTreeNode fileNode = null;
+	File f = new File(path);
+	try {
+	    File fls[] = f.listFiles();
+	    ArrayList<File> filter = new ArrayList<File>();
+	    for (File file : fls) {
+		if ((file.isDirectory() && !(file.getName().charAt(0) == '.'))
+			|| (file.isFile() && ((file.getName().toLowerCase().endsWith(".jpg")
+				|| file.getName().toLowerCase().endsWith(".jpeg") || file.getName().toLowerCase()
+				.endsWith(".png"))))) {
+		    filter.add(file);
+		}
+	    }
+	    for (File file : filter) {
+		fileNode = new DefaultMutableTreeNode(file);
+		root.add(fileNode);
+		recursiveNodeCreation(fileNode, file);
+
+	    }
+	} catch (Exception e) {
+	    e.printStackTrace();
+	}
+
+    }
+
+    /**
+     * recursive method for the creation of the nodes
+     * @param categoryNode
+     * @param category
+     */
+    private void recursiveNodeCreation(DefaultMutableTreeNode categoryNode, File file) {
+	if (file.isDirectory() && !(file.getName().charAt(0) == '.')) {
+	    File fls[] = file.listFiles();
+	    ArrayList<File> filter = new ArrayList<File>();
+	    for (File fich : fls) {
+		if (!(fich.getName().charAt(0) == '.')
+			&& fich.isDirectory()
+			|| (fich.isFile() && ((fich.getName().toLowerCase().endsWith(".jpg")
+				|| fich.getName().toLowerCase().endsWith(".jpeg") || fich.getName().toLowerCase()
+				.endsWith(".png"))))) {
+		    filter.add(fich);
+		}
+	    }
+	    for (File fich : filter) {
+		DefaultMutableTreeNode node = new DefaultMutableTreeNode(fich);
+		categoryNode.add(node);
+		recursiveNodeCreation(node, fich);
+	    }
+	}
+    }
+
+    @Override
+    public void valueChanged(TreeSelectionEvent arg0) {
+
+    }
+
+    @Override
+    public void mouseClicked(MouseEvent arg0) {
+	if (arg0.getSource().equals(fieldPath)) {
+	    JFileChooser chooser = new JFileChooser();
+	    chooser.setCurrentDirectory(new java.io.File(path));
+	    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+	    chooser.setAcceptAllFileFilterUsed(false);
+	    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
+		path = chooser.getSelectedFile().getAbsolutePath();
+		fieldPath.setText(path);
+		reload();
+	    }
+	}
+    }
+
+    @Override
+    public void mouseEntered(MouseEvent arg0) {
+	// TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void mouseExited(MouseEvent arg0) {
+	// TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void mousePressed(MouseEvent arg0) {
+	// TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void mouseReleased(MouseEvent arg0) {
+	// TODO Auto-generated method stub
+
+    }
+
+    public JTree getTree() {
+	return tree;
+    }
+
+}
Index: /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/tree/MyTreeCellRenderer.java
===================================================================
--- /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/tree/MyTreeCellRenderer.java	(revision 8834)
+++ /extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/tree/MyTreeCellRenderer.java	(revision 8834)
@@ -0,0 +1,70 @@
+package fr.mael.jiwigo.ui.search.tree;
+
+import java.awt.Component;
+
+import javax.swing.ImageIcon;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+import fr.mael.jiwigo.transverse.util.Outil;
+import fr.mael.jiwigo.ui.search.File;
+
+/**
+Copyright (c) 2010, Mael
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+ * Neither the name of jiwigo nor the
+   names of its contributors may be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Mael BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+* @author mael
+* Cell renderer. Allows to display a specific image for a png or a jpg image
+* And allows to display "leaf" folders with a folder gui
+*/
+public class MyTreeCellRenderer extends DefaultTreeCellRenderer {
+
+    public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
+	    boolean leaf, int row, boolean hasFocus) {
+
+	super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
+
+	DefaultMutableTreeNode theNode = (DefaultMutableTreeNode) value;
+	//only if it's a file : the value can be a string and it's not interesting
+	if (theNode.getUserObject() instanceof File) {
+	    File file = (File) theNode.getUserObject();
+	    //if it's a directory and a leaf, the default icon is overriden with the
+	    //"openIcon", which shows to the users that it's a folder. Otherwise it can be confusing
+	    //and if it's a png or jpg files (which means everything excepts the folders), specific icons
+	    //are setted
+	    if (file.isDirectory() && leaf) {
+		setIcon(openIcon);
+	    } else if (file.isFile() && file.getName().toLowerCase().endsWith(".png")) {
+		setIcon(new ImageIcon(Outil.getURL("fr/mael/jiwigo/img/png.png")));
+	    } else if (file.isFile()
+		    && (file.getName().toLowerCase().endsWith(".jpg") || file.getName().toLowerCase().endsWith(".jpeg"))) {
+		setIcon(new ImageIcon(Outil.getURL("fr/mael/jiwigo/img/jpg.png")));
+	    }
+	}
+	return this;
+    }
+
+}
