Index: extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/Main.java
===================================================================
--- extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/Main.java	(revision 7219)
+++ extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/Main.java	(revision 7221)
@@ -3,9 +3,6 @@
 import java.io.File;
 import java.io.IOException;
-
 import javax.swing.UIManager;
-
 import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel;
-
 import fr.mael.jiwigo.transverse.session.SessionManager;
 import fr.mael.jiwigo.transverse.util.Outil;
@@ -13,4 +10,5 @@
 import fr.mael.jiwigo.ui.ConnexionDialog;
 import fr.mael.jiwigo.ui.mainframe.MainFrame;
+
 
 /**
@@ -45,47 +43,50 @@
  */
 public class Main {
-    /**
-     * Logger
-     */
-    public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(Main.class);
-    /**
-     * The login and session manager that allows to connect to
-     * the webservice and to query it
-     */
-    public static SessionManager sessionManager;
 
-    /**
-     *  the main window
-     */
-    private static MainFrame mainFrame;
+	/**
+	 * Logger
+	 */
+	public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(Main.class);
+	/**
+	 * The login and session manager that allows to connect to
+	 * the webservice and to query it
+	 */
+	public static SessionManager sessionManager;
 
-    public static void main(String[] args) {
-	try {
-	    UIManager.setLookAndFeel(new NimbusLookAndFeel());
-	} catch (Exception e) {
-	}
-	File dossierConfig = new File(System.getProperty("user.home") + "/.jiwigo");
-	if (!dossierConfig.exists()) {
-	    dossierConfig.mkdir();
-	}
-	try {
-	    PreferencesManagement.creerFichierParDefaut();
-	    //dialog de connexion
-	    ConnexionDialog dialog = new ConnexionDialog();
-	    dialog.showDialog();
-	} catch (IOException e) {
-	    LOG.error(Outil.getStackTrace(e));
+	/**
+	 *  the main window
+	 */
+	private static MainFrame mainFrame;
+
+
+	public static void main(String[] args) {
+		try {
+			UIManager.setLookAndFeel(new NimbusLookAndFeel());
+		} catch (Exception e) {
+		}
+		File dossierConfig = new File(System.getProperty("user.home") + "/.jiwigo");
+		if (!dossierConfig.exists()) {
+			dossierConfig.mkdir();
+		}
+		try {
+			PreferencesManagement.creerFichierParDefaut();
+			//dialog de connexion
+			ConnexionDialog dialog = new ConnexionDialog();
+			dialog.showDialog();
+		} catch (IOException e) {
+			LOG.error(Outil.getStackTrace(e));
+		}
+
 	}
 
-    }
 
-    public static void showFrame() {
+	public static void showFrame() {
 
-	if (mainFrame == null) {
-	    mainFrame = MainFrame.getInstance();
+		if (mainFrame == null) {
+			mainFrame = MainFrame.getInstance();
+		}
+		if (!mainFrame.isVisible()) {
+			mainFrame.showUi();
+		}
 	}
-	if (!mainFrame.isVisible()) {
-	    mainFrame.showUi();
-	}
-    }
 }
Index: extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/dao/ImageDao.java
===================================================================
--- extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/dao/ImageDao.java	(revision 7219)
+++ extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/dao/ImageDao.java	(revision 7221)
@@ -6,8 +6,6 @@
 import java.util.HashMap;
 import java.util.List;
-
 import org.jdom.Document;
 import org.jdom.Element;
-
 import sun.misc.BASE64Encoder;
 import fr.mael.jiwigo.Main;
@@ -18,4 +16,5 @@
 import fr.mael.jiwigo.transverse.util.Outil;
 import fr.mael.jiwigo.transverse.util.preferences.PreferencesManagement;
+
 
 /**
@@ -50,209 +49,218 @@
  */
 public class ImageDao {
-    /**
-     * Logger
-     */
-    public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
-	    .getLog(ImageDao.class);
-
-    /**
-     * Singleton
-     */
-    private static ImageDao instance;
-
-    /**
-     * cache to avoid downloading image for each access
-     */
-    private HashMap<Integer, List<Image>> cache;
-
-    /**
-     * 
-     */
-    private Integer firstCatInCache;
-
-    /**
-     * Private singleton, to use a singleton
-     */
-    private ImageDao() {
-	cache = new HashMap<Integer, List<Image>>();
-    }
-
-    /**
-     * @return le singleton
-     */
-    public static ImageDao getInstance() {
-	if (instance == null) {
-	    instance = new ImageDao();
-	}
-	return instance;
-    }
-
-    /**
-     * Lists all images
-     * @return the list of images
-     * @throws IOException 
-     */
-    public List<Image> lister(boolean rafraichir) throws IOException {
-	return listerParCategory(null, rafraichir);
-    }
-
-    /**
-     * Listing of the images for a category
-     * @param categoryId the id of the category
-     * @return the list of images
-     * @throws IOException 
-     */
-    public List<Image> listerParCategory(Integer categoryId, boolean rafraichir) throws IOException {
-	if (rafraichir || cache.get(categoryId) == null) {
-	    Document doc = null;
-	    if (categoryId != null) {
-		doc = Main.sessionManager.executerReturnDocument(MethodsEnum.LISTER_IMAGES.getLabel(), "cat_id", String
-			.valueOf(categoryId));
-	    } else {
-		doc = Main.sessionManager.executerReturnDocument(MethodsEnum.LISTER_IMAGES.getLabel());
-	    }
-	    Element element = doc.getRootElement().getChild("images");
-	    List<Image> images = getImagesFromElement(element);
-	    cache.remove(categoryId);
-	    cache.put(categoryId, images);
-	    if (firstCatInCache == null) {
-		firstCatInCache = categoryId;
-	    }
-	    return images;
-	} else {
-	    return cache.get(categoryId);
-	}
-    }
-
-    /**
-     * Creation of an image<br/>
-     * Sequence : <br/>
-     * <li>
-     * <ul>sending of the thumbnail in base64, thanks to the method addchunk.</ul>
-     * <ul>sending of the image in base64, thanks to the method addchunk</ul>
-     * <ul>using of the add method to add the image to the database<ul>
-     * </li>
-     * Finally, the response of the webservice is checked
-     * 
-     * @param the image to create
-     * @return true if the creation of the image was the successful
-     * @throws Exception
-     */
-    //TODO ne pas continuer si une des réponses précédentes est négative
-    public boolean creer(Image image) throws Exception {
-	//thumbnail converted to base64
-	BASE64Encoder base64 = new BASE64Encoder();
-
-	String thumbnailBase64 = base64.encode(Outil.getBytesFromFile(image.getThumbnail()));
-	//sends the thumbnail and gets the result 
-	Document reponseThumb = (Main.sessionManager.executerReturnDocument("pwg.images.addChunk", "data",
-		thumbnailBase64, "type", "thumb", "position", "1", "original_sum", Outil.getMD5Checksum(image
-			.getOriginale().getAbsolutePath())));
-
-	//begin feature:0001827
-	Double doubleChunk = Double.parseDouble(PreferencesManagement.getValue(PreferencesEnum.CHUNK_SIZE.getLabel())) * 1000 * 1024;
-	int chunk = doubleChunk.intValue();
-	ArrayList<File> fichiersAEnvoyer = Outil.splitFile(image.getOriginale(), chunk);
-	boolean echec = false;
-	for (int i = 0; i < fichiersAEnvoyer.size(); i++) {
-	    File fichierAEnvoyer = fichiersAEnvoyer.get(i);
-	    String originaleBase64 = base64.encode(Outil.getBytesFromFile(fichierAEnvoyer));
-	    Document reponseOriginale = (Main.sessionManager.executerReturnDocument("pwg.images.addChunk", "data",
-		    originaleBase64, "type", "file", "position", String.valueOf(i), "original_sum", Outil
-			    .getMD5Checksum(image.getOriginale().getAbsolutePath())));
-	    if (!Outil.checkOk(reponseOriginale)) {
-		echec = true;
-		break;
-	    }
-	}
-	//end
-
-	//add the image in the database and get the result of the webservice
-	Document reponseAjout = (Main.sessionManager.executerReturnDocument("pwg.images.add", "file_sum", Outil
-		.getMD5Checksum(image.getOriginale().getAbsolutePath()), "thumbnail_sum", Outil.getMD5Checksum(image
-		.getThumbnail().getCanonicalPath()), "position", "1", "original_sum", Outil.getMD5Checksum(image
-		.getOriginale().getAbsolutePath()), "categories", String.valueOf(image.getIdCategory()), "name", image
-		.getName(), "author", Main.sessionManager.getLogin(), "level", String
-		.valueOf(ImagesManagement.privacyLevel)));
-	LOG.debug("Response add : " + Outil.documentToString(reponseAjout));
-	//	System.out.println(Main.sessionManager.executerReturnString("pwg.images.add", "file_sum", Outil
-	//		.getMD5Checksum(image.getOriginale().getAbsolutePath()), "thumbnail_sum", Outil.getMD5Checksum(image
-	//		.getThumbnail().getCanonicalPath()), "position", "1", "original_sum", Outil.getMD5Checksum(image
-	//		.getOriginale().getAbsolutePath()), "categories", String.valueOf(image.getIdCategory()), "name", image
-	//		.getName(), "author", Main.sessionManager.getLogin()));
-	//	Document reponsePrivacy = null;
-	//	if (Outil.checkOk(reponseAjout)) {
-	//	    reponsePrivacy = Main.sessionManager.executerReturnDocument(MethodsEnum.SET_PRIVACY_LEVEL.getLabel());
-	//	}
-	boolean reussite = true;
-	if (!Outil.checkOk(reponseThumb) || echec || !Outil.checkOk(reponseAjout)) {
-	    reussite = false;
-	}
-	suppressionFichierTemporaires();
-	return reussite;
-
-    }
-
-    /**
-     * Add tags to an image
-     * @param imageId id of the image
-     * @param tagId ids of the tags
-     * @throws IOException
-     */
-    public boolean addTags(Integer imageId, String tagId) throws IOException {
-	Document doc = Main.sessionManager.executerReturnDocument(MethodsEnum.SET_INFO.getLabel(), "image_id", String
-		.valueOf(imageId), "tag_ids", tagId);
-	return Outil.checkOk(doc);
-
-    }
-
-    /**
-     * parse an element to find images
-     * @param element the element to parse
-     * @return the list of images
-     */
-    private List<Image> getImagesFromElement(Element element) {
-	List<Element> listElement = (List<Element>) element.getChildren("image");
-	ArrayList<Image> images = new ArrayList<Image>();
-	for (Element im : listElement) {
-	    Image myImage = new Image();
-	    myImage.setMiniature(im.getAttributeValue("tn_url"));
-	    myImage.setUrl(im.getAttributeValue("element_url"));
-	    myImage.setWidth(Integer.valueOf(im.getAttributeValue("width")));
-	    myImage.setHeight(Integer.valueOf(im.getAttributeValue("height")));
-	    myImage.setFile(im.getAttributeValue("file"));
-	    myImage.setVue(Integer.valueOf(im.getAttributeValue("hit")));
-	    myImage.setIdentifiant(Integer.valueOf(im.getAttributeValue("id")));
-	    myImage.setName(im.getChildText("name"));
-	    if (myImage.getName() == null) {
-		myImage.setName(myImage.getFile());
-	    }
-	    images.add(myImage);
-
-	}
-	return images;
-    }
-
-    /**
-     * Search images
-     * @param searchString the string to search
-     * @return the list of images matching the string
-     * @throws IOException 
-     */
-    public List<Image> search(String searchString) throws IOException {
-	Document doc = Main.sessionManager.executerReturnDocument(MethodsEnum.SEARCH.getLabel(), "query", searchString);
-	LOG.debug(doc);
-	Element element = doc.getRootElement().getChild("images");
-	return getImagesFromElement(element);
-
-    }
-
-    private void suppressionFichierTemporaires() {
-	File file = new File(System.getProperty("java.io.tmpdir") + "/originale.jpg");
-	file.delete();
-	file = new File(System.getProperty("java.io.tmpdir") + "/thumb.jpg");
-	file.delete();
-
-    }
+
+	/**
+	 * Logger
+	 */
+	public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(ImageDao.class);
+
+	/**
+	 * Singleton
+	 */
+	private static ImageDao instance;
+
+	/**
+	 * cache to avoid downloading image for each access
+	 */
+	private HashMap<Integer, List<Image>> cache;
+
+	/**
+	 * 
+	 */
+	private Integer firstCatInCache;
+
+
+	/**
+	 * Private singleton, to use a singleton
+	 */
+	private ImageDao() {
+		cache = new HashMap<Integer, List<Image>>();
+	}
+
+
+	/**
+	 * @return le singleton
+	 */
+	public static ImageDao getInstance() {
+		if (instance == null) {
+			instance = new ImageDao();
+		}
+		return instance;
+	}
+
+
+	/**
+	 * Lists all images
+	 * @return the list of images
+	 * @throws IOException 
+	 */
+	public List<Image> lister(boolean rafraichir) throws IOException {
+		return listerParCategory(null, rafraichir);
+	}
+
+
+	/**
+	 * Listing of the images for a category
+	 * @param categoryId the id of the category
+	 * @return the list of images
+	 * @throws IOException 
+	 */
+	public List<Image> listerParCategory(Integer categoryId, boolean rafraichir) throws IOException {
+		if (rafraichir || cache.get(categoryId) == null) {
+			Document doc = null;
+
+			if (categoryId != null) {
+				doc = Main.sessionManager.executerReturnDocument(MethodsEnum.LISTER_IMAGES.getLabel(), "cat_id",
+						String.valueOf(categoryId));
+			} else {
+				doc = Main.sessionManager.executerReturnDocument(MethodsEnum.LISTER_IMAGES.getLabel());
+			}
+			Element element = doc.getRootElement().getChild("images");
+			List<Image> images = getImagesFromElement(element);
+			cache.remove(categoryId);
+			cache.put(categoryId, images);
+			if (firstCatInCache == null) {
+				firstCatInCache = categoryId;
+			}
+			return images;
+		} else {
+			return cache.get(categoryId);
+		}
+	}
+
+
+	/**
+	 * Creation of an image<br/>
+	 * Sequence : <br/>
+	 * <li>
+	 * <ul>sending of the thumbnail in base64, thanks to the method addchunk.</ul>
+	 * <ul>sending of the image in base64, thanks to the method addchunk</ul>
+	 * <ul>using of the add method to add the image to the database<ul>
+	 * </li>
+	 * Finally, the response of the webservice is checked
+	 * 
+	 * @param the image to create
+	 * @return true if the creation of the image was the successful
+	 * @throws Exception
+	 */
+	//TODO ne pas continuer si une des réponses précédentes est négative
+	public boolean creer(Image image) throws Exception {
+		//thumbnail converted to base64
+		BASE64Encoder base64 = new BASE64Encoder();
+
+		String thumbnailBase64 = base64.encode(Outil.getBytesFromFile(image.getThumbnail()));
+		//sends the thumbnail and gets the result 
+		Document reponseThumb = (Main.sessionManager.executerReturnDocument("pwg.images.addChunk", "data", thumbnailBase64,
+				"type", "thumb", "position", "1", "original_sum", Outil.getMD5Checksum(image.getOriginale().getAbsolutePath())));
+
+		//begin feature:0001827
+		Double doubleChunk = Double.parseDouble(PreferencesManagement.getValue(PreferencesEnum.CHUNK_SIZE.getLabel())) * 1000 * 1024;
+		int chunk = doubleChunk.intValue();
+		ArrayList<File> fichiersAEnvoyer = Outil.splitFile(image.getOriginale(), chunk);
+		boolean echec = false;
+		for (int i = 0; i < fichiersAEnvoyer.size(); i++) {
+			File fichierAEnvoyer = fichiersAEnvoyer.get(i);
+			String originaleBase64 = base64.encode(Outil.getBytesFromFile(fichierAEnvoyer));
+			Document reponseOriginale = (Main.sessionManager.executerReturnDocument("pwg.images.addChunk", "data",
+					originaleBase64, "type", "file", "position", String.valueOf(i), "original_sum",
+					Outil.getMD5Checksum(image.getOriginale().getAbsolutePath())));
+			if (!Outil.checkOk(reponseOriginale)) {
+				echec = true;
+				break;
+			}
+		}
+		//end
+
+		//add the image in the database and get the result of the webservice
+		Document reponseAjout = (Main.sessionManager.executerReturnDocument("pwg.images.add", "file_sum",
+				Outil.getMD5Checksum(image.getOriginale().getAbsolutePath()), "thumbnail_sum",
+				Outil.getMD5Checksum(image.getThumbnail().getCanonicalPath()), "position", "1", "original_sum",
+				Outil.getMD5Checksum(image.getOriginale().getAbsolutePath()), "categories",
+				String.valueOf(image.getIdCategory()), "name", image.getName(), "author", Main.sessionManager.getLogin(),
+				"level", String.valueOf(ImagesManagement.privacyLevel)));
+		LOG.debug("Response add : " + Outil.documentToString(reponseAjout));
+		//	System.out.println(Main.sessionManager.executerReturnString("pwg.images.add", "file_sum", Outil
+		//		.getMD5Checksum(image.getOriginale().getAbsolutePath()), "thumbnail_sum", Outil.getMD5Checksum(image
+		//		.getThumbnail().getCanonicalPath()), "position", "1", "original_sum", Outil.getMD5Checksum(image
+		//		.getOriginale().getAbsolutePath()), "categories", String.valueOf(image.getIdCategory()), "name", image
+		//		.getName(), "author", Main.sessionManager.getLogin()));
+		//	Document reponsePrivacy = null;
+		//	if (Outil.checkOk(reponseAjout)) {
+		//	    reponsePrivacy = Main.sessionManager.executerReturnDocument(MethodsEnum.SET_PRIVACY_LEVEL.getLabel());
+		//	}
+		boolean reussite = true;
+		if (!Outil.checkOk(reponseThumb) || echec || !Outil.checkOk(reponseAjout)) {
+			reussite = false;
+		}
+		suppressionFichierTemporaires();
+		return reussite;
+
+	}
+
+
+	/**
+	 * Add tags to an image
+	 * @param imageId id of the image
+	 * @param tagId ids of the tags
+	 * @throws IOException
+	 */
+	public boolean addTags(Integer imageId, String tagId) throws IOException {
+		Document doc = Main.sessionManager.executerReturnDocument(MethodsEnum.SET_INFO.getLabel(), "image_id",
+				String.valueOf(imageId), "tag_ids", tagId);
+		return Outil.checkOk(doc);
+
+	}
+
+
+	/**
+	 * parse an element to find images
+	 * @param element the element to parse
+	 * @return the list of images
+	 */
+	private List<Image> getImagesFromElement(Element element) {
+		List<Element> listElement = (List<Element>) element.getChildren("image");
+		ArrayList<Image> images = new ArrayList<Image>();
+		for (Element im : listElement) {
+			Image myImage = new Image();
+			myImage.setMiniature(im.getAttributeValue("tn_url"));
+			myImage.setUrl(im.getAttributeValue("element_url"));
+			myImage.setWidth(Integer.valueOf(im.getAttributeValue("width")));
+			myImage.setHeight(Integer.valueOf(im.getAttributeValue("height")));
+			myImage.setFile(im.getAttributeValue("file"));
+			myImage.setVue(Integer.valueOf(im.getAttributeValue("hit")));
+			myImage.setIdentifiant(Integer.valueOf(im.getAttributeValue("id")));
+			myImage.setName(im.getChildText("name"));
+			if (myImage.getName() == null) {
+				myImage.setName(myImage.getFile());
+			}
+			images.add(myImage);
+
+		}
+		return images;
+	}
+
+
+	/**
+	 * Search images
+	 * @param searchString the string to search
+	 * @return the list of images matching the string
+	 * @throws IOException 
+	 */
+	public List<Image> search(String searchString) throws IOException {
+		Document doc = Main.sessionManager.executerReturnDocument(MethodsEnum.SEARCH.getLabel(), "query", searchString);
+		LOG.debug(doc);
+		Element element = doc.getRootElement().getChild("images");
+		return getImagesFromElement(element);
+
+	}
+
+
+	private void suppressionFichierTemporaires() {
+		File file = new File(System.getProperty("java.io.tmpdir") + "/originale.jpg");
+		file.delete();
+		file = new File(System.getProperty("java.io.tmpdir") + "/thumb.jpg");
+		file.delete();
+
+	}
 
 }
Index: extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/service/ImageService.java
===================================================================
--- extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/service/ImageService.java	(revision 7219)
+++ extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/service/ImageService.java	(revision 7221)
@@ -4,5 +4,4 @@
 import java.io.IOException;
 import java.util.List;
-
 import fr.mael.jiwigo.dao.ImageDao;
 import fr.mael.jiwigo.om.Image;
@@ -13,4 +12,5 @@
 import fr.mael.jiwigo.transverse.util.preferences.PreferencesManagement;
 import fr.mael.jiwigo.ui.mainframe.MainFrame;
+
 
 /**
@@ -45,126 +45,130 @@
  */
 public class ImageService {
-    /**
-     * Logger
-     */
-    public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
-	    .getLog(ImageService.class);
 
-    /**
-     * Singleton
-     */
-    private static ImageService instance;
+	/**
+	 * Logger
+	 */
+	public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(ImageService.class);
 
-    /**
-     * @return the singleton
-     */
-    public static ImageService getInstance() {
-	if (instance == null) {
-	    instance = new ImageService();
+	/**
+	 * Singleton
+	 */
+	private static ImageService instance;
+
+
+	/**
+	 * @return the singleton
+	 */
+	public static ImageService getInstance() {
+		if (instance == null) {
+			instance = new ImageService();
+		}
+		return instance;
 	}
-	return instance;
-    }
 
-    /**
-     * private constructor to use a singleton
-     */
-    private ImageService() {
 
-    }
-
-    /**
-     * Lists all images for a category
-     * @param categoryId the id of the category
-     * @param rafraichir true : refresh the list of images
-     * @return the list of images
-     * @throws IOException
-     */
-    public List<Image> listerParCategory(Integer categoryId, boolean rafraichir) throws IOException {
-	return ImageDao.getInstance().listerParCategory(categoryId, rafraichir);
-    }
-
-    /**
-     * Method called to send an image to the server.
-     * @param filePath
-     * @param idCategory
-     * @return
-     * @throws Exception
-     */
-    public boolean creer(String filePath, Integer idCategory) throws Exception {
-	MainFrame.getInstance().setMessage(Messages.getMessage("mainFrame_resizing") + " " + filePath);
-	//get the byte array of the original file, to keep metadata
-	byte[] bytesFichierOriginal = Outil.getBytesFromFile(new File(filePath));
-
-	//size taken from the user's preferences
-	int widthOriginale = Integer
-		.valueOf(PreferencesManagement.getValue(PreferencesEnum.WIDTH_ORIGINALE.getLabel()));
-	int heightOriginale = Integer.valueOf(PreferencesManagement
-		.getValue(PreferencesEnum.HEIGHT_ORIGINAL.getLabel()));
-	//resize the picture (or not)
-	boolean originaleRedimensionnee = ImagesUtil.scale(filePath, "originale.jpg", widthOriginale, heightOriginale);
-	//create the thumbnail
-	ImagesUtil.scale(filePath, "thumb.jpg", 120, 90);
-	//get the thumbnail
-	File thumbnail = new File(System.getProperty("java.io.tmpdir") + "/thumb.jpg");
-	File originale = null;
-	if (originaleRedimensionnee) {
-	    originale = new File(System.getProperty("java.io.tmpdir") + "/originale.jpg");
-	    //if the original file has been resized, we put the metadata in the resized file
-	    //I use here a try catch because if the original file isn't a jpeg
-	    //the methode Outil.enrich will fail, but the procedure has to continue
-	    MainFrame.getInstance().setMessage(Messages.getMessage("mainFrame_addMetadata") + " " + filePath);
-	    try {
-		byte[] fichierEnrichi = Outil.enrich(bytesFichierOriginal, Outil.getBytesFromFile(new File(System
-			.getProperty("java.io.tmpdir")
-			+ "/originale.jpg")));
-		Outil.byteToFile(System.getProperty("java.io.tmpdir") + "/originale.jpg", fichierEnrichi);
-	    } catch (Exception e) {
-	    }
-	} else {
-	    originale = new File(filePath);
+	/**
+	 * private constructor to use a singleton
+	 */
+	private ImageService() {
 
 	}
-	Image image = new Image();
-	image.setName(getImageName(filePath));
-	image.setThumbnail(thumbnail);
-	image.setOriginale(originale);
-	image.setIdCategory(idCategory);
-	MainFrame.getInstance().setMessage(Messages.getMessage("mainFrame_sendingFiles") + " " + filePath);
-	//now we call the dao to send the image to the webservice
-	return ImageDao.getInstance().creer(image);
-    }
 
-    /**
-     * Add tags to an existing image
-     * @param image the image
-     * @param tagId the ids of the tags
-     * @return true if successful
-     * @throws IOException
-     */
-    public boolean addTags(Image image, String tagId) throws IOException {
-	return ImageDao.getInstance().addTags(image.getIdentifiant(), tagId);
-    }
 
-    /**
-     * Search images from a string
-     * @param queryString the string
-     * @return images matching the string
-     * @throws IOException
-     */
-    public List<Image> search(String queryString) throws IOException {
-	return ImageDao.getInstance().search(queryString);
-    }
+	/**
+	 * Lists all images for a category
+	 * @param categoryId the id of the category
+	 * @param rafraichir true : refresh the list of images
+	 * @return the list of images
+	 * @throws IOException
+	 */
+	public List<Image> listerParCategory(Integer categoryId, boolean rafraichir) throws IOException {
+		return ImageDao.getInstance().listerParCategory(categoryId, rafraichir);
+	}
 
-    /**
-     * Deletes the file extension
-     * @param path
-     * @return
-     */
-    private String getImageName(String path) {
-	File fichier = new File(path);
-	StringBuffer name = new StringBuffer(fichier.getName());
-	return (name.delete(name.lastIndexOf("."), name.length())).toString();
 
-    }
+	/**
+	 * Method called to send an image to the server.
+	 * @param filePath
+	 * @param idCategory
+	 * @return
+	 * @throws Exception
+	 */
+	public boolean creer(String filePath, Integer idCategory) throws Exception {
+		MainFrame.getInstance().setMessage(Messages.getMessage("mainFrame_resizing") + " " + filePath);
+		//get the byte array of the original file, to keep metadata
+		byte[] bytesFichierOriginal = Outil.getBytesFromFile(new File(filePath));
+
+		//size taken from the user's preferences
+		int widthOriginale = Integer.valueOf(PreferencesManagement.getValue(PreferencesEnum.WIDTH_ORIGINALE.getLabel()));
+		int heightOriginale = Integer.valueOf(PreferencesManagement.getValue(PreferencesEnum.HEIGHT_ORIGINAL.getLabel()));
+		//resize the picture (or not)
+		boolean originaleRedimensionnee = ImagesUtil.scale(filePath, "originale.jpg", widthOriginale, heightOriginale);
+		//create the thumbnail
+		ImagesUtil.scale(filePath, "thumb.jpg", 120, 90);
+		//get the thumbnail
+		File thumbnail = new File(System.getProperty("java.io.tmpdir") + "/thumb.jpg");
+		File originale = null;
+		if (originaleRedimensionnee) {
+			originale = new File(System.getProperty("java.io.tmpdir") + "/originale.jpg");
+			//if the original file has been resized, we put the metadata in the resized file
+			//I use here a try catch because if the original file isn't a jpeg
+			//the methode Outil.enrich will fail, but the procedure has to continue
+			MainFrame.getInstance().setMessage(Messages.getMessage("mainFrame_addMetadata") + " " + filePath);
+			try {
+				byte[] fichierEnrichi = Outil.enrich(bytesFichierOriginal,
+						Outil.getBytesFromFile(new File(System.getProperty("java.io.tmpdir") + "/originale.jpg")));
+				Outil.byteToFile(System.getProperty("java.io.tmpdir") + "/originale.jpg", fichierEnrichi);
+			} catch (Exception e) {
+			}
+		} else {
+			originale = new File(filePath);
+
+		}
+		Image image = new Image();
+		image.setName(getImageName(filePath));
+		image.setThumbnail(thumbnail);
+		image.setOriginale(originale);
+		image.setIdCategory(idCategory);
+		MainFrame.getInstance().setMessage(Messages.getMessage("mainFrame_sendingFiles") + " " + filePath);
+		//now we call the dao to send the image to the webservice
+		return ImageDao.getInstance().creer(image);
+	}
+
+
+	/**
+	 * Add tags to an existing image
+	 * @param image the image
+	 * @param tagId the ids of the tags
+	 * @return true if successful
+	 * @throws IOException
+	 */
+	public boolean addTags(Image image, String tagId) throws IOException {
+		return ImageDao.getInstance().addTags(image.getIdentifiant(), tagId);
+	}
+
+
+	/**
+	 * Search images from a string
+	 * @param queryString the string
+	 * @return images matching the string
+	 * @throws IOException
+	 */
+	public List<Image> search(String queryString) throws IOException {
+		return ImageDao.getInstance().search(queryString);
+	}
+
+
+	/**
+	 * Deletes the file extension
+	 * @param path
+	 * @return
+	 */
+	private String getImageName(String path) {
+		File fichier = new File(path);
+		StringBuffer name = new StringBuffer(fichier.getName());
+		return (name.delete(name.lastIndexOf("."), name.length())).toString();
+
+	}
 
 }
Index: extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/transverse/ImagesManagement.java
===================================================================
--- extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/transverse/ImagesManagement.java	(revision 7219)
+++ extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/transverse/ImagesManagement.java	(revision 7221)
@@ -5,9 +5,8 @@
 import java.util.HashMap;
 import java.util.List;
-
 import javax.imageio.ImageIO;
-
 import fr.mael.jiwigo.om.Image;
 import fr.mael.jiwigo.transverse.util.Outil;
+
 
 /**
@@ -41,123 +40,130 @@
  */
 public class ImagesManagement {
-    /**
-     * Logger
-     */
-    public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
-	    .getLog(ImagesManagement.class);
-    /**
-     * the index of the current image
-     */
-    public static int CURRENT_IMAGE_INDEX;
-    /**
-     * the current image
-     */
-    public static Image CURRENT_IMAGE;
-    /**
-     * images list
-     */
-    public static List<Image> LIST_IMAGE;
 
-    /**
-     * cache allows to keep the images in the ram
-     */
-    private static HashMap<Integer, BufferedImage> IMAGES_CACHE = new HashMap<Integer, BufferedImage>();
+	/**
+	 * Logger
+	 */
+	public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(ImagesManagement.class);
+	/**
+	 * the index of the current image
+	 */
+	public static int CURRENT_IMAGE_INDEX;
+	/**
+	 * the current image
+	 */
+	public static Image CURRENT_IMAGE;
+	/**
+	 * images list
+	 */
+	public static List<Image> LIST_IMAGE;
 
-    /**
-     * cache allows to keep the thumbnails in the ram
-     */
-    private static HashMap<Integer, BufferedImage> MINIATURE_CACHE = new HashMap<Integer, BufferedImage>();
+	/**
+	 * cache allows to keep the images in the ram
+	 */
+	private static HashMap<Integer, BufferedImage> IMAGES_CACHE = new HashMap<Integer, BufferedImage>();
 
-    /**
-     * If true : the application won't ask the privacy level
-     * to the user each time he adds pictures
-     */
-    public static boolean rememberPrivacyLevel = false;
+	/**
+	 * cache allows to keep the thumbnails in the ram
+	 */
+	private static HashMap<Integer, BufferedImage> MINIATURE_CACHE = new HashMap<Integer, BufferedImage>();
 
-    /**
-     * the privacy level to apply to the pictures
-     */
-    public static int privacyLevel = 1;
+	/**
+	 * If true : the application won't ask the privacy level
+	 * to the user each time he adds pictures
+	 */
+	public static boolean rememberPrivacyLevel = false;
 
-    /**
-     * gets the current image
-     * @return the image
-     */
-    public static Image getCurrentImage() {
-	//return LIST_IMAGE.get(CURRENT_IMAGE_INDEX);
-	return CURRENT_IMAGE;
-    }
+	/**
+	 * the privacy level to apply to the pictures
+	 */
+	public static int privacyLevel = 1;
 
-    /**
-     * next image
-     */
-    public static void next() {
-	if (CURRENT_IMAGE_INDEX != LIST_IMAGE.size() - 1) {
-	    CURRENT_IMAGE_INDEX++;
-	} else {
-	    CURRENT_IMAGE_INDEX = 0;
+
+	/**
+	 * gets the current image
+	 * @return the image
+	 */
+	public static Image getCurrentImage() {
+		//return LIST_IMAGE.get(CURRENT_IMAGE_INDEX);
+		return CURRENT_IMAGE;
 	}
-	CURRENT_IMAGE = LIST_IMAGE.get(CURRENT_IMAGE_INDEX);
-    }
 
-    /**
-     * previous image
-     */
-    public static void previous() {
-	if (CURRENT_IMAGE_INDEX != 0) {
-	    CURRENT_IMAGE_INDEX--;
-	} else {
-	    CURRENT_IMAGE_INDEX = LIST_IMAGE.size() - 1;
+
+	/**
+	 * next image
+	 */
+	public static void next() {
+		if (CURRENT_IMAGE_INDEX != LIST_IMAGE.size() - 1) {
+			CURRENT_IMAGE_INDEX++;
+		} else {
+			CURRENT_IMAGE_INDEX = 0;
+		}
+		CURRENT_IMAGE = LIST_IMAGE.get(CURRENT_IMAGE_INDEX);
 	}
-	CURRENT_IMAGE = LIST_IMAGE.get(CURRENT_IMAGE_INDEX);
-    }
 
-    /**
-     * 
-     * @param image the current image
-     */
-    public static void setCurrentImage(Image image) {
-	CURRENT_IMAGE = image;
-	int compteur = 0;
-	for (Image im : LIST_IMAGE) {
-	    if (im.equals(image)) {
-		CURRENT_IMAGE_INDEX = compteur;
-	    }
-	    compteur++;
+
+	/**
+	 * previous image
+	 */
+	public static void previous() {
+		if (CURRENT_IMAGE_INDEX != 0) {
+			CURRENT_IMAGE_INDEX--;
+		} else {
+			CURRENT_IMAGE_INDEX = LIST_IMAGE.size() - 1;
+		}
+		CURRENT_IMAGE = LIST_IMAGE.get(CURRENT_IMAGE_INDEX);
 	}
-    }
 
-    /**
-     * Function that allows to load images once
-     * to decrease response delays
-     * @return the image
-     */
-    public static BufferedImage getCurrentBufferedImage() {
-	if (IMAGES_CACHE.get(CURRENT_IMAGE.getIdentifiant()) == null) {
-	    try {
-		BufferedImage img = ImageIO.read(new URL(CURRENT_IMAGE.getUrl()));
-		IMAGES_CACHE.put(CURRENT_IMAGE.getIdentifiant(), img);
-	    } catch (Exception e) {
-		LOG.error(Outil.getStackTrace(e));
-	    }
+
+	/**
+	 * 
+	 * @param image the current image
+	 */
+	public static void setCurrentImage(Image image) {
+		CURRENT_IMAGE = image;
+		int compteur = 0;
+		for (Image im : LIST_IMAGE) {
+			if (im.equals(image)) {
+				CURRENT_IMAGE_INDEX = compteur;
+			}
+			compteur++;
+		}
 	}
-	return IMAGES_CACHE.get(CURRENT_IMAGE.getIdentifiant());
-    }
 
-    /**
-     * Function that allows to load thimbnails once
-     * to decrease response delays
-     * @return the image
-     */
-    public static BufferedImage getMiniatureBufferedImage(Image image) {
-	if (MINIATURE_CACHE.get(image.getIdentifiant()) == null) {
-	    try {
-		BufferedImage img = ImageIO.read(new URL(image.getMiniature()));
-		MINIATURE_CACHE.put(image.getIdentifiant(), img);
-	    } catch (Exception e) {
-		LOG.error(Outil.getStackTrace(e));
-	    }
+
+	/**
+	 * Function that allows to load images once
+	 * to decrease response delays
+	 * @return the image
+	 */
+	public static BufferedImage getCurrentBufferedImage() {
+		if (IMAGES_CACHE.get(CURRENT_IMAGE.getIdentifiant()) == null) {
+			try {
+				BufferedImage img = ImageIO.read(new URL(CURRENT_IMAGE.getUrl()));
+				IMAGES_CACHE.put(CURRENT_IMAGE.getIdentifiant(), img);
+			} catch (Exception e) {
+				LOG.error(Outil.getStackTrace(e));
+			}
+		}
+		return IMAGES_CACHE.get(CURRENT_IMAGE.getIdentifiant());
 	}
-	return MINIATURE_CACHE.get(image.getIdentifiant());
-    }
+
+
+	/**
+	 * Function that allows to load thimbnails once
+	 * to decrease response delays
+	 * @return the image
+	 */
+	public static BufferedImage getMiniatureBufferedImage(Image image) {
+		if (MINIATURE_CACHE.get(image.getIdentifiant()) == null) {
+			try {
+				BufferedImage img = ImageIO.read(new URL(image.getMiniature()));
+				MINIATURE_CACHE.put(image.getIdentifiant(), img);
+			} catch (Exception e) {
+				LOG.error(Outil.getStackTrace(e));
+			}
+		}
+
+		return MINIATURE_CACHE.get(image.getIdentifiant());
+	}
 }
Index: extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/ConnexionDialog.java
===================================================================
--- extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/ConnexionDialog.java	(revision 7219)
+++ extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/ConnexionDialog.java	(revision 7221)
@@ -16,5 +16,4 @@
 import java.util.Arrays;
 import java.util.Locale;
-
 import javax.swing.AbstractListModel;
 import javax.swing.ComboBoxModel;
@@ -27,5 +26,4 @@
 import javax.swing.JPasswordField;
 import javax.swing.JTextField;
-
 import fr.mael.jiwigo.Main;
 import fr.mael.jiwigo.transverse.enumeration.PreferencesEnum;
@@ -33,4 +31,5 @@
 import fr.mael.jiwigo.transverse.util.Messages;
 import fr.mael.jiwigo.transverse.util.preferences.PreferencesManagement;
+
 
 /**
@@ -64,261 +63,280 @@
  */
 public class ConnexionDialog extends JDialog implements ActionListener, ItemListener, KeyListener, WindowListener {
-    /**
-     * Logger
-     */
-    public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
-	    .getLog(ConnexionDialog.class);
-    /**
-     * field that contains the url
-     */
-    private JTextField fieldUrl;
-    /**
-     * field that contains the login
-     */
-    private JTextField loginField;
-    /**
-     * field that contains de password
-     */
-    private JPasswordField passwordField;
-    /**
-     * label of the url field
-     */
-    private JLabel labelUrl;
-    /**
-     * label of the login field
-     */
-    private JLabel labelLogin;
-    /**
-     *  label of the password field
-     */
-    private JLabel labelPass;
-    /**
-     * ok button for the connection
-     */
-    private JButton boutonOk;
-
-    /**
-     * Box that allows to save informations
-     */
-    private JCheckBox checkBoxRetenir;
-
-    /**
-     * Combo containing all locales
-     */
-    private JComboBox comboLocales;
-
-    /**
-     * Constructor 
-     */
-    public ConnexionDialog() {
-	Locale defautLocale = Messages.usedLocale;
-	labelUrl = new JLabel(Messages.getMessage("connexionDialog_urlSite"));
-	labelLogin = new JLabel(Messages.getMessage("connexionDialog_login"));
-	labelPass = new JLabel(Messages.getMessage("connexionDialog_pass"));
-	comboLocales = new JComboBox();
-	boutonOk = new JButton("Ok");
-	String url = PreferencesManagement.getValue(PreferencesEnum.URL_SITE.getLabel());
-	String login = PreferencesManagement.getValue(PreferencesEnum.LOGIN.getLabel());
-	String pass = PreferencesManagement.getValue(PreferencesEnum.PASSWORD.getLabel());
-	fieldUrl = new JTextField(url);
-	loginField = new JTextField(login);
-	passwordField = new JPasswordField(pass);
-	checkBoxRetenir = new JCheckBox(Messages.getMessage("connexionDialog_sauvegarder"));
-	if (!url.equals("") && !login.equals("") && !pass.equals("")) {
-	    checkBoxRetenir.setSelected(true);
-	}
-	Dimension fieldDimensions = new Dimension(300, 30);
-	fieldUrl.setPreferredSize(fieldDimensions);
-	fieldUrl.addActionListener(this);
-	loginField.setPreferredSize(fieldDimensions);
-	loginField.addActionListener(this);
-	passwordField.setPreferredSize(fieldDimensions);
-	passwordField.addActionListener(this);
-	this.getContentPane().setLayout(new GridBagLayout());
-	GridBagConstraints constraints = new GridBagConstraints();
-	constraints.gridx = 0;
-	constraints.gridy = 0;
-	constraints.insets = new Insets(3, 3, 3, 3);
-	this.getContentPane().add(labelUrl, constraints);
-	constraints.gridx++;
-	this.getContentPane().add(fieldUrl, constraints);
-	constraints.gridx = 0;
-	constraints.gridy++;
-	this.getContentPane().add(labelLogin, constraints);
-	constraints.gridx++;
-	this.getContentPane().add(loginField, constraints);
-	constraints.gridx = 0;
-	constraints.gridy++;
-	this.getContentPane().add(labelPass, constraints);
-	constraints.gridx++;
-	this.getContentPane().add(passwordField, constraints);
-	constraints.gridx = 0;
-	constraints.gridy++;
-	this.getContentPane().add(comboLocales, constraints);
-	constraints.gridx++;
-	this.getContentPane().add(checkBoxRetenir, constraints);
-	constraints.gridx = 0;
-	constraints.gridy++;//  
-	//	for (Locale locale : SimpleDateFormat.getAvailableLocales()) {
-	//	    comboLocales.addItem(locale.getDisplayName(Locale.ENGLISH));
-	//	}
-	comboLocales.setPreferredSize(new Dimension(130, 25));
-	comboLocales.addItemListener(this);
-	localeModel model = new localeModel();
-	comboLocales.setModel(model);
-	model.setSelectedItem(defautLocale.getDisplayLanguage(Locale.ENGLISH));
-	this.getContentPane().add(boutonOk, constraints);
-	boutonOk.setPreferredSize(new Dimension(80, 30));
-	boutonOk.addActionListener(this);
-	this.addWindowListener(this);
-    }
-
-    public void showDialog() {
-	this.pack();
-	this.setLocationRelativeTo(null);
-	this.setVisible(true);
-    }
-
-    @Override
-    public void actionPerformed(ActionEvent paramActionEvent) {
-	//if one field is empty, an error is displayed
-	if (fieldUrl.getText().equals("") || loginField.getText().equals("") || passwordField.getText().equals("")) {
-	    JOptionPane.showMessageDialog(null, Messages.getMessage("connexionDialog_emptyField"), Messages
-		    .getMessage("error"), JOptionPane.ERROR_MESSAGE);
-	} else {
-	    if (!fieldUrl.getText().startsWith("http://")) {
-		fieldUrl.setText("http://" + fieldUrl.getText());
-	    }
-	    //instanciation of the session manager
-	    Main.sessionManager = new SessionManager(loginField.getText(), passwordField.getText(), fieldUrl.getText());
-	    if (checkBoxRetenir.isSelected()) {
-		PreferencesManagement.setValue(PreferencesEnum.LOGIN.getLabel(), loginField.getText());
-		PreferencesManagement.setValue(PreferencesEnum.PASSWORD.getLabel(), passwordField.getText());
-		PreferencesManagement.setValue(PreferencesEnum.URL_SITE.getLabel(), fieldUrl.getText());
-	    } else {
-		PreferencesManagement.setValue(PreferencesEnum.LOGIN.getLabel(), "");
-		PreferencesManagement.setValue(PreferencesEnum.PASSWORD.getLabel(), "");
-		PreferencesManagement.setValue(PreferencesEnum.URL_SITE.getLabel(), "");
-	    }
-	    if (!Main.sessionManager.processLogin()) {
-		//if the login fails, an error is displayed
-		JOptionPane.showMessageDialog(null, Messages.getMessage("connexionDialog_connexionError"), Messages
-			.getMessage("error"), JOptionPane.ERROR_MESSAGE);
-	    } else {
-		//		Locale.setDefault((Locale) comboLocales.getSelectedItem());
-		Main.showFrame();
-		//hides the dialog
-		this.dispose();
-	    }
-	}
-    }
-
-    /**
-     * @author mael
-     * Internal class that represents the model of the combobox that allows
-     * to choose a locale
-     */
-    class localeModel extends AbstractListModel implements ComboBoxModel {
-	Locale[] locales = SimpleDateFormat.getAvailableLocales();
-	//List<Locale> locales = Messages.getAvailableBundles();
-	String[] localesNames;
-
-	String selection = null;
-
-	public localeModel() {
-	    localesNames = new String[locales.length];
-	    int compteur = 0;
-	    for (Locale locale : locales) {
-		localesNames[compteur] = locale.getDisplayName(Locale.ENGLISH);
-		compteur++;
-	    }
-	    Arrays.sort(localesNames);
-	}
-
-	public Object getElementAt(int index) {
-	    return localesNames[index];
-	}
-
-	public int getSize() {
-	    return locales.length;
-	}
-
-	public void setSelectedItem(Object anItem) {
-	    selection = (String) anItem;
-	}
-
-	public Object getSelectedItem() {
-	    if (selection != null)
-		return selection;
-	    else
-		return null;
-	}
-    }
-
-    @Override
-    public void itemStateChanged(ItemEvent paramItemEvent) {
-	for (Locale locale : SimpleDateFormat.getAvailableLocales()) {
-	    if (locale.getDisplayName(Locale.ENGLISH).equals(paramItemEvent.getItem())) {
-		Messages.usedLocale = locale;
-		dispose();
-		ConnexionDialog dial = new ConnexionDialog();
-		dial.showDialog();
-
-	    }
-
-	}
-    }
-
-    @Override
-    public void keyPressed(KeyEvent arg0) {
-    }
-
-    @Override
-    public void keyReleased(KeyEvent arg0) {
-
-    }
-
-    @Override
-    public void keyTyped(KeyEvent arg0) {
-    }
-
-    @Override
-    public void windowActivated(WindowEvent e) {
-	// TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void windowClosed(WindowEvent e) {
-	System.out.println("closed");
-    }
-
-    @Override
-    public void windowClosing(WindowEvent e) {
-	System.exit(0);
-    }
-
-    @Override
-    public void windowDeactivated(WindowEvent e) {
-	// TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void windowDeiconified(WindowEvent e) {
-	// TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void windowIconified(WindowEvent e) {
-	// TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void windowOpened(WindowEvent e) {
-	// TODO Auto-generated method stub
-
-    }
+
+	/**
+	 * Logger
+	 */
+	public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(ConnexionDialog.class);
+	/**
+	 * field that contains the url
+	 */
+	private JTextField fieldUrl;
+	/**
+	 * field that contains the login
+	 */
+	private JTextField loginField;
+	/**
+	 * field that contains de password
+	 */
+	private JPasswordField passwordField;
+	/**
+	 * label of the url field
+	 */
+	private JLabel labelUrl;
+	/**
+	 * label of the login field
+	 */
+	private JLabel labelLogin;
+	/**
+	 *  label of the password field
+	 */
+	private JLabel labelPass;
+	/**
+	 * ok button for the connection
+	 */
+	private JButton boutonOk;
+
+	/**
+	 * Box that allows to save informations
+	 */
+	private JCheckBox checkBoxRetenir;
+
+	/**
+	 * Combo containing all locales
+	 */
+	private JComboBox comboLocales;
+
+
+	/**
+	 * Constructor 
+	 */
+	public ConnexionDialog() {
+		Locale defautLocale = Messages.usedLocale;
+		labelUrl = new JLabel(Messages.getMessage("connexionDialog_urlSite"));
+		labelLogin = new JLabel(Messages.getMessage("connexionDialog_login"));
+		labelPass = new JLabel(Messages.getMessage("connexionDialog_pass"));
+		comboLocales = new JComboBox();
+		boutonOk = new JButton("Ok");
+		String url = PreferencesManagement.getValue(PreferencesEnum.URL_SITE.getLabel());
+		String login = PreferencesManagement.getValue(PreferencesEnum.LOGIN.getLabel());
+		String pass = PreferencesManagement.getValue(PreferencesEnum.PASSWORD.getLabel());
+		fieldUrl = new JTextField(url);
+		loginField = new JTextField(login);
+		passwordField = new JPasswordField(pass);
+		checkBoxRetenir = new JCheckBox(Messages.getMessage("connexionDialog_sauvegarder"));
+		if (!url.equals("") && !login.equals("") && !pass.equals("")) {
+			checkBoxRetenir.setSelected(true);
+		}
+		Dimension fieldDimensions = new Dimension(300, 30);
+		fieldUrl.setPreferredSize(fieldDimensions);
+		fieldUrl.addActionListener(this);
+		loginField.setPreferredSize(fieldDimensions);
+		loginField.addActionListener(this);
+		passwordField.setPreferredSize(fieldDimensions);
+		passwordField.addActionListener(this);
+		this.getContentPane().setLayout(new GridBagLayout());
+		GridBagConstraints constraints = new GridBagConstraints();
+		constraints.gridx = 0;
+		constraints.gridy = 0;
+		constraints.insets = new Insets(3, 3, 3, 3);
+		this.getContentPane().add(labelUrl, constraints);
+		constraints.gridx++;
+		this.getContentPane().add(fieldUrl, constraints);
+		constraints.gridx = 0;
+		constraints.gridy++;
+		this.getContentPane().add(labelLogin, constraints);
+		constraints.gridx++;
+		this.getContentPane().add(loginField, constraints);
+		constraints.gridx = 0;
+		constraints.gridy++;
+		this.getContentPane().add(labelPass, constraints);
+		constraints.gridx++;
+		this.getContentPane().add(passwordField, constraints);
+		constraints.gridx = 0;
+		constraints.gridy++;
+		this.getContentPane().add(comboLocales, constraints);
+		constraints.gridx++;
+		this.getContentPane().add(checkBoxRetenir, constraints);
+		constraints.gridx = 0;
+		constraints.gridy++;//  
+		//	for (Locale locale : SimpleDateFormat.getAvailableLocales()) {
+		//	    comboLocales.addItem(locale.getDisplayName(Locale.ENGLISH));
+		//	}
+		comboLocales.setPreferredSize(new Dimension(130, 25));
+		comboLocales.addItemListener(this);
+		localeModel model = new localeModel();
+		comboLocales.setModel(model);
+		model.setSelectedItem(defautLocale.getDisplayLanguage(Locale.ENGLISH));
+		this.getContentPane().add(boutonOk, constraints);
+		boutonOk.setPreferredSize(new Dimension(80, 30));
+		boutonOk.addActionListener(this);
+		this.addWindowListener(this);
+	}
+
+
+	public void showDialog() {
+		this.pack();
+		this.setLocationRelativeTo(null);
+		this.setVisible(true);
+	}
+
+
+	@Override
+	public void actionPerformed(ActionEvent paramActionEvent) {
+		//if one field is empty, an error is displayed
+		if (fieldUrl.getText().equals("") || loginField.getText().equals("") || passwordField.getText().equals("")) {
+			JOptionPane.showMessageDialog(null, Messages.getMessage("connexionDialog_emptyField"),
+					Messages.getMessage("error"), JOptionPane.ERROR_MESSAGE);
+		} else {
+			if (!fieldUrl.getText().startsWith("http://")) {
+				fieldUrl.setText("http://" + fieldUrl.getText());
+			}
+			//instanciation of the session manager
+			Main.sessionManager = new SessionManager(loginField.getText(), passwordField.getText(), fieldUrl.getText());
+			if (checkBoxRetenir.isSelected()) {
+				PreferencesManagement.setValue(PreferencesEnum.LOGIN.getLabel(), loginField.getText());
+				PreferencesManagement.setValue(PreferencesEnum.PASSWORD.getLabel(), passwordField.getText());
+				PreferencesManagement.setValue(PreferencesEnum.URL_SITE.getLabel(), fieldUrl.getText());
+			} else {
+				PreferencesManagement.setValue(PreferencesEnum.LOGIN.getLabel(), "");
+				PreferencesManagement.setValue(PreferencesEnum.PASSWORD.getLabel(), "");
+				PreferencesManagement.setValue(PreferencesEnum.URL_SITE.getLabel(), "");
+			}
+			if (!Main.sessionManager.processLogin()) {
+				//if the login fails, an error is displayed
+				JOptionPane.showMessageDialog(null, Messages.getMessage("connexionDialog_connexionError"),
+						Messages.getMessage("error"), JOptionPane.ERROR_MESSAGE);
+			} else {
+				//		Locale.setDefault((Locale) comboLocales.getSelectedItem());
+				Main.showFrame();
+				//hides the dialog
+				this.dispose();
+			}
+		}
+	}
+
+	/**
+	 * @author mael
+	 * Internal class that represents the model of the combobox that allows
+	 * to choose a locale
+	 */
+	class localeModel extends AbstractListModel implements ComboBoxModel {
+
+		Locale[] locales = SimpleDateFormat.getAvailableLocales();
+		//List<Locale> locales = Messages.getAvailableBundles();
+		String[] localesNames;
+
+		String selection = null;
+
+
+		public localeModel() {
+			localesNames = new String[locales.length];
+			int compteur = 0;
+			for (Locale locale : locales) {
+				localesNames[compteur] = locale.getDisplayName(Locale.ENGLISH);
+				compteur++;
+			}
+			Arrays.sort(localesNames);
+		}
+
+
+		public Object getElementAt(int index) {
+			return localesNames[index];
+		}
+
+
+		public int getSize() {
+			return locales.length;
+		}
+
+
+		public void setSelectedItem(Object anItem) {
+			selection = (String) anItem;
+		}
+
+
+		public Object getSelectedItem() {
+			if (selection != null)
+				return selection;
+			else
+				return null;
+		}
+	}
+
+
+	@Override
+	public void itemStateChanged(ItemEvent paramItemEvent) {
+		for (Locale locale : SimpleDateFormat.getAvailableLocales()) {
+			if (locale.getDisplayName(Locale.ENGLISH).equals(paramItemEvent.getItem())) {
+				Messages.usedLocale = locale;
+				dispose();
+				ConnexionDialog dial = new ConnexionDialog();
+				dial.showDialog();
+
+			}
+
+		}
+	}
+
+
+	@Override
+	public void keyPressed(KeyEvent arg0) {
+	}
+
+
+	@Override
+	public void keyReleased(KeyEvent arg0) {
+
+	}
+
+
+	@Override
+	public void keyTyped(KeyEvent arg0) {
+	}
+
+
+	@Override
+	public void windowActivated(WindowEvent e) {
+		// TODO Auto-generated method stub
+
+	}
+
+
+	@Override
+	public void windowClosed(WindowEvent e) {
+	}
+
+
+	@Override
+	public void windowClosing(WindowEvent e) {
+		System.exit(0);
+	}
+
+
+	@Override
+	public void windowDeactivated(WindowEvent e) {
+		// TODO Auto-generated method stub
+
+	}
+
+
+	@Override
+	public void windowDeiconified(WindowEvent e) {
+		// TODO Auto-generated method stub
+
+	}
+
+
+	@Override
+	public void windowIconified(WindowEvent e) {
+		// TODO Auto-generated method stub
+
+	}
+
+
+	@Override
+	public void windowOpened(WindowEvent e) {
+		// TODO Auto-generated method stub
+
+	}
 }
Index: extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/CategoriesTree.java
===================================================================
--- extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/CategoriesTree.java	(revision 7219)
+++ extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/CategoriesTree.java	(revision 7221)
@@ -8,5 +8,4 @@
 import java.awt.event.MouseListener;
 import java.util.List;
-
 import javax.swing.JMenuItem;
 import javax.swing.JOptionPane;
@@ -21,9 +20,9 @@
 import javax.swing.tree.TreePath;
 import javax.swing.tree.TreeSelectionModel;
-
 import fr.mael.jiwigo.om.Category;
 import fr.mael.jiwigo.service.CategoryService;
 import fr.mael.jiwigo.transverse.util.Messages;
 import fr.mael.jiwigo.transverse.util.Outil;
+
 
 /**
@@ -58,191 +57,201 @@
 public class CategoriesTree extends JPanel implements TreeSelectionListener, MouseListener, ActionListener {
 
-    /**
-     * Logger
-     */
-    public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
-	    .getLog(CategoriesTree.class);
-    /**
-     *  the tree
-     */
-    private JTree tree;
-    /**
-     * the menu to add a category
-     */
-    private JMenuItem menuAjouter;
-    /**
-     * the menu to refresh the categories
-     */
-    private JMenuItem menuActualiser;
-    /**
-     * the root of the tree which is not displayed
-     */
-    private DefaultMutableTreeNode root = new DefaultMutableTreeNode("");
-    /**
-     * the selected category
-     */
-    private Category selectedCategory;
-
-    /**
-     * Constructor
-     */
-    public CategoriesTree() {
-	super(new BorderLayout());
-	//creation of the tree
-	createNodes(root);
-	tree = new JTree(root);
-	tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
-	tree.addTreeSelectionListener(this);
-	tree.setRootVisible(false);
-	tree.addMouseListener(this);
-	JScrollPane treeView = new JScrollPane(tree);
-	Dimension minimumSize = new Dimension(100, 50);
-	treeView.setMinimumSize(minimumSize);
-	add(treeView, BorderLayout.CENTER);
-    }
-
-    /**
-     * Method that allows to update the tree
-     */
-    public void setUpUi() {
-	//begin bug:0001830
-	root.removeAllChildren();
-	createNodes(root);
-	((DefaultTreeModel) tree.getModel()).reload();
-	//end
-
-    }
-
-    /* (non-Javadoc)
-     * @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent)
-     */
-    public void valueChanged(TreeSelectionEvent e) {
-	DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
-	//
-	if (node == null)
-	    return;
-	Object catSelectionnee = node.getUserObject();
-	Category category = (Category) catSelectionnee;
-	//MainFrame.imagesPanel.rafraichir(category.getIdentifiant(), false);
-	MainFrame.getInstance().addTabb(new ThumbnailCategoryPanel(category));
-    }
-
-    /**
-     * creation of the nodes
-     * @param root the root 
-     */
-    private void createNodes(DefaultMutableTreeNode root) {
-	DefaultMutableTreeNode category = null;
-	try {
-	    List<Category> list = CategoryService.getInstance().construireArbre();
-	    for (Category cat : list) {
-		if (cat.getCategoriesMeres().size() == 0) {
-		    category = new DefaultMutableTreeNode(cat);
-		    root.add(category);
-		    recursiveNodeCreation(category, cat);
-		}
-
-	    }
-	} catch (Exception e) {
-	    LOG.error(Outil.getStackTrace(e));
-	    JOptionPane.showMessageDialog(null, Messages.getMessage("treeCreationError"), Messages.getMessage("error"),
-		    JOptionPane.ERROR_MESSAGE);
-	}
-
-    }
-
-    /**
-     * recursive method for the creation of the nodes
-     * @param categoryNode
-     * @param category
-     */
-    private void recursiveNodeCreation(DefaultMutableTreeNode categoryNode, Category category) {
-	for (Category cat : category.getCategoriesFilles()) {
-	    DefaultMutableTreeNode node = new DefaultMutableTreeNode(cat);
-	    categoryNode.add(node);
-	    recursiveNodeCreation(node, cat);
-	}
-    }
-
-    @Override
-    public void mouseClicked(MouseEvent arg0) {
-
-    }
-
-    @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 e) {
-	int selRow = tree.getRowForLocation(e.getX(), e.getY());
-	TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
-	//begin bug:0001832
-	tree.setSelectionRow(selRow);
-	//end
-
-	if (e.getButton() == 3) {
-	    JPopupMenu popup = new JPopupMenu();
-	    menuAjouter = new JMenuItem(Messages.getMessage("categories_add"));
-	    menuAjouter.addActionListener(this);
-	    popup.add(menuAjouter);
-	    menuActualiser = new JMenuItem(Messages.getMessage("categories_update"));
-	    menuActualiser.addActionListener(this);
-	    popup.add(menuActualiser);
-	    popup.show(tree, e.getX(), e.getY());
-	    if (selRow != -1) {
-		DefaultMutableTreeNode node = (DefaultMutableTreeNode) (selPath.getLastPathComponent());
-		this.selectedCategory = (Category) node.getUserObject();
-	    } else {
-		this.selectedCategory = null;
-	    }
-	}
-
-    }
-
-    @Override
-    public void mouseReleased(MouseEvent arg0) {
-	// TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void actionPerformed(ActionEvent arg0) {
-	if (arg0.getSource().equals(menuAjouter)) {
-	    String nomcategorie = JOptionPane.showInputDialog(null, Messages.getMessage("categories_enterName"),
-		    Messages.getMessage("categories_add"), JOptionPane.INFORMATION_MESSAGE);
-	    //if the name of the category is not empty
-	    if (!(nomcategorie == null) && !nomcategorie.equals("")) {
-		//if there is a parent category
-		if (selectedCategory != null) {
-		    //try to create a category
-		    if (CategoryService.getInstance().creer(nomcategorie, selectedCategory.getIdentifiant())) {
+	/**
+	 * Logger
+	 */
+	public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(CategoriesTree.class);
+	/**
+	 *  the tree
+	 */
+	private JTree tree;
+	/**
+	 * the menu to add a category
+	 */
+	private JMenuItem menuAjouter;
+	/**
+	 * the menu to refresh the categories
+	 */
+	private JMenuItem menuActualiser;
+	/**
+	 * the root of the tree which is not displayed
+	 */
+	private DefaultMutableTreeNode root = new DefaultMutableTreeNode("");
+	/**
+	 * the selected category
+	 */
+	private Category selectedCategory;
+
+
+	/**
+	 * Constructor
+	 */
+	public CategoriesTree() {
+		super(new BorderLayout());
+		//creation of the tree
+		createNodes(root);
+		tree = new JTree(root);
+		tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+		tree.addTreeSelectionListener(this);
+		tree.setRootVisible(false);
+		tree.addMouseListener(this);
+		JScrollPane treeView = new JScrollPane(tree);
+		Dimension minimumSize = new Dimension(100, 50);
+		treeView.setMinimumSize(minimumSize);
+		add(treeView, BorderLayout.CENTER);
+	}
+
+
+	/**
+	 * Method that allows to update the tree
+	 */
+	public void setUpUi() {
+		//begin bug:0001830
+		root.removeAllChildren();
+		createNodes(root);
+		((DefaultTreeModel) tree.getModel()).reload();
+		//end
+
+	}
+
+
+	/* (non-Javadoc)
+	 * @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent)
+	 */
+	public void valueChanged(TreeSelectionEvent e) {
+		DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
+		//
+		if (node == null)
+			return;
+		Object catSelectionnee = node.getUserObject();
+		Category category = (Category) catSelectionnee;
+		//MainFrame.imagesPanel.rafraichir(category.getIdentifiant(), false);
+		MainFrame.getInstance().addTabb(new ThumbnailCategoryPanel(category));
+	}
+
+
+	/**
+	 * creation of the nodes
+	 * @param root the root 
+	 */
+	private void createNodes(DefaultMutableTreeNode root) {
+		DefaultMutableTreeNode category = null;
+		try {
+			List<Category> list = CategoryService.getInstance().construireArbre();
+			for (Category cat : list) {
+				if (cat.getCategoriesMeres().size() == 0) {
+					category = new DefaultMutableTreeNode(cat);
+					root.add(category);
+					recursiveNodeCreation(category, cat);
+				}
+
+			}
+		} catch (Exception e) {
+			LOG.error(Outil.getStackTrace(e));
+			JOptionPane.showMessageDialog(null, Messages.getMessage("treeCreationError"), Messages.getMessage("error"),
+					JOptionPane.ERROR_MESSAGE);
+		}
+
+	}
+
+
+	/**
+	 * recursive method for the creation of the nodes
+	 * @param categoryNode
+	 * @param category
+	 */
+	private void recursiveNodeCreation(DefaultMutableTreeNode categoryNode, Category category) {
+		for (Category cat : category.getCategoriesFilles()) {
+			DefaultMutableTreeNode node = new DefaultMutableTreeNode(cat);
+			categoryNode.add(node);
+			recursiveNodeCreation(node, cat);
+		}
+	}
+
+
+	@Override
+	public void mouseClicked(MouseEvent arg0) {
+
+	}
+
+
+	@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 e) {
+		int selRow = tree.getRowForLocation(e.getX(), e.getY());
+		TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
+		//begin bug:0001832
+		tree.setSelectionRow(selRow);
+		//end
+
+		if (e.getButton() == 3) {
+			JPopupMenu popup = new JPopupMenu();
+			menuAjouter = new JMenuItem(Messages.getMessage("categories_add"));
+			menuAjouter.addActionListener(this);
+			popup.add(menuAjouter);
+			menuActualiser = new JMenuItem(Messages.getMessage("categories_update"));
+			menuActualiser.addActionListener(this);
+			popup.add(menuActualiser);
+			popup.show(tree, e.getX(), e.getY());
+			if (selRow != -1) {
+				DefaultMutableTreeNode node = (DefaultMutableTreeNode) (selPath.getLastPathComponent());
+				this.selectedCategory = (Category) node.getUserObject();
+			} else {
+				this.selectedCategory = null;
+			}
+		}
+
+	}
+
+
+	@Override
+	public void mouseReleased(MouseEvent arg0) {
+		// TODO Auto-generated method stub
+
+	}
+
+
+	@Override
+	public void actionPerformed(ActionEvent arg0) {
+		if (arg0.getSource().equals(menuAjouter)) {
+			String nomcategorie = JOptionPane.showInputDialog(null, Messages.getMessage("categories_enterName"),
+					Messages.getMessage("categories_add"), JOptionPane.INFORMATION_MESSAGE);
+			//if the name of the category is not empty
+			if (!(nomcategorie == null) && !nomcategorie.equals("")) {
+				//if there is a parent category
+				if (selectedCategory != null) {
+					//try to create a category
+					if (CategoryService.getInstance().creer(nomcategorie, selectedCategory.getIdentifiant())) {
+						setUpUi();
+					} else {
+						JOptionPane.showMessageDialog(null, Messages.getMessage("categoryCreationError"),
+								Messages.getMessage("error"), JOptionPane.ERROR_MESSAGE);
+
+					}
+				} else {
+					if (CategoryService.getInstance().creer(nomcategorie)) {
+						setUpUi();
+					} else {
+						JOptionPane.showMessageDialog(null, Messages.getMessage("categoryCreationError"),
+								Messages.getMessage("error"), JOptionPane.ERROR_MESSAGE);
+
+					}
+				}
+			}
+		} else if (arg0.getSource().equals(menuActualiser)) {
 			setUpUi();
-		    } else {
-			JOptionPane.showMessageDialog(null, Messages.getMessage("categoryCreationError"), Messages
-				.getMessage("error"), JOptionPane.ERROR_MESSAGE);
-
-		    }
-		} else {
-		    if (CategoryService.getInstance().creer(nomcategorie)) {
-			setUpUi();
-		    } else {
-			JOptionPane.showMessageDialog(null, Messages.getMessage("categoryCreationError"), Messages
-				.getMessage("error"), JOptionPane.ERROR_MESSAGE);
-
-		    }
-		}
-	    }
-	} else if (arg0.getSource().equals(menuActualiser)) {
-	    setUpUi();
-	}
-    }
+		}
+	}
 }
Index: extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/MainFrame.java
===================================================================
--- extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/MainFrame.java	(revision 7219)
+++ extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/MainFrame.java	(revision 7221)
@@ -9,5 +9,4 @@
 import java.awt.event.KeyListener;
 import java.util.HashMap;
-
 import javax.swing.ImageIcon;
 import javax.swing.JComponent;
@@ -21,9 +20,9 @@
 import javax.swing.JScrollPane;
 import javax.swing.JSplitPane;
-
 import fr.mael.jiwigo.transverse.util.Messages;
 import fr.mael.jiwigo.transverse.util.Outil;
 import fr.mael.jiwigo.ui.field.HintTextField;
 import fr.mael.jiwigo.ui.mainframe.tab.JTabbedPaneWithCloseIcons;
+
 
 /**
@@ -57,205 +56,217 @@
  */
 public class MainFrame extends JFrame implements ActionListener, KeyListener {
-    /**
-     * Logger
-     */
-    public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
-	    .getLog(MainFrame.class);
-    /**
-     * the categories tree
-     */
-    private CategoriesTree categoriesTree;
-    /**
-     * Splitpane. On the left : the categories tree and on the right the thumbnails
-     * for the current category
-     */
-    private JSplitPane splitPane;
-    /**
-     * Panel that contains the thumbnail of the current category
-     */
-    public static ThumbnailCategoryPanel imagesPanel;
-    /**
-     *  Scrollpane that contains the panel above
-     */
-    private JScrollPane scrollPaneImagesPanel;
-    /**
-     * label that displays messages
-     */
-    private JLabel labelMessage;
-
-    /**
-     * menu bar
-     */
-    private JMenuBar jMenuBar;
-
-    /**
-     * edition menu
-     */
-    private JMenu jMenuEdition;
-
-    /**
-     * preferences menu
-     */
-    private JMenuItem jMenuItemPreferences;
-
-    /**
-     * singleton
-     */
-    private static MainFrame instance;
-
-    private JProgressBar progressBar;
-
-    private JTabbedPaneWithCloseIcons tabbedPane;
-
-    private HashMap<Integer, Integer> mapsIdPos = new HashMap<Integer, Integer>();
-
-    private HintTextField fieldSearch;
-
-    /**
-     * @return the singleton
-     */
-    public static MainFrame getInstance() {
-	if (instance == null) {
-	    instance = new MainFrame();
-	}
-	return instance;
-    }
-
-    /**
-     * private constructor to use a singleton
-     */
-    private MainFrame() {
-	this.setTitle("Jiwigo v" + Messages.getMessage("version"));
-	this.setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage(Outil.getURL("fr/mael/jiwigo/img/icon.png")));
-	this.setLayout(new BorderLayout());
-	jMenuBar = new JMenuBar();
-	labelMessage = new JLabel(Messages.getMessage("welcomeMessage"));
-	splitPane = new JSplitPane();
-	categoriesTree = new CategoriesTree();
-	splitPane.setLeftComponent(categoriesTree);
-
-	tabbedPane = new JTabbedPaneWithCloseIcons();
-	splitPane.setRightComponent(tabbedPane);
-
-	this.add(splitPane, BorderLayout.CENTER);
-	JPanel panelBas = new JPanel(new BorderLayout());
-	JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
-	progressBar = new JProgressBar(0, 100);
-	panel.add(progressBar);
-	panel.add(labelMessage);
-	panelBas.add(panel, BorderLayout.WEST);
-
-	fieldSearch = new HintTextField(Messages.getMessage("mainFrame_recherche"));
-	fieldSearch.setPreferredSize(new Dimension(150, 25));
-	fieldSearch.addKeyListener(this);
-	panelBas.add(fieldSearch, BorderLayout.EAST);
-
-	jMenuEdition = new JMenu(Messages.getMessage("mainFrame_editionMenu"));
-	jMenuBar.add(jMenuEdition);
-	jMenuItemPreferences = new JMenuItem(Messages.getMessage("mainFrame_preferencesMenu"));
-	jMenuItemPreferences.addActionListener(this);
-	jMenuEdition.add(jMenuItemPreferences);
-
-	this.setJMenuBar(jMenuBar);
-	this.add(panelBas, BorderLayout.SOUTH);
-	this.setSize(900, 600);
-	this.setLocationRelativeTo(null);
-	this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-	this.setResizable(true);
-    }
-
-    public void addTabb(IThumbnailPanel panel) {
-	JScrollPane scrollPaneImagesPanel = new JScrollPane((JPanel) panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
-		JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
-	scrollPaneImagesPanel.setPreferredSize(new Dimension(900, 600));
-	boolean found = false;
-	boolean isSearch = false;
-	if (panel instanceof ThumbnailSearchPanel) {
-	    isSearch = true;
-	}
-	for (int i = 0; i < tabbedPane.getTabCount(); i++) {
-	    JScrollPane scroll = (JScrollPane) tabbedPane.getComponentAt(i);
-	    IThumbnailPanel thumbPan = (IThumbnailPanel) scroll.getViewport().getComponents()[0];
-	    if (thumbPan.getCategory().getIdentifiant().equals(panel.getCategory().getIdentifiant())) {
-		//only if it's not for a re
-		if (!(panel instanceof ThumbnailSearchPanel)) {
-		    tabbedPane.setSelectedIndex(i);
-		    found = true;
-		    break;
-		}
-	    }
-	}
-	//if it's not for a research, the title of the tab
-	//is the name of the category
-	if (!found && !isSearch) {
-	    tabbedPane.addTab(panel.getCategory().getNom(), scrollPaneImagesPanel, new ImageIcon(Outil
-		    .getURL("fr/mael/jiwigo/img/closetab.png")));
-	    //if it's for a research, the title of the tab
-	    //if the query string
-	} else if (!found && isSearch) {
-	    String queryString = ((ThumbnailSearchPanel) panel).getQueryString();
-	    tabbedPane.addTab(Messages.getMessage("mainFrame_search") + queryString, scrollPaneImagesPanel,
-		    new ImageIcon(Outil.getURL("fr/mael/jiwigo/img/closetab.png")));
-	}
-
-    }
-
-    /**
-     * displays the frame
-     */
-    public void showUi() {
-	this.setVisible(true);
-    }
-
-    /**
-     * Affichage d'un message de réussite
-     * @param message
-     */
-    public void setMessage(String message) {
-	this.labelMessage.setText(message);
-    }
-
-    @Override
-    public void actionPerformed(ActionEvent arg0) {
-	if (arg0.getSource().equals(jMenuItemPreferences)) {
-	    new PreferencesDialog(this);
-	}
-
-    }
-
-    public static void reduceSizeOfComponent(JComponent comp) {
-	comp.setMaximumSize(comp.getPreferredSize());
-    }
-
-    /**
-     * @return the progressBar
-     */
-    public JProgressBar getProgressBar() {
-	return progressBar;
-    }
-
-    /**
-     * @return the mapsIdPos
-     */
-    public HashMap<Integer, Integer> getMapsIdPos() {
-	return mapsIdPos;
-    }
-
-    @Override
-    public void keyPressed(KeyEvent paramKeyEvent) {
-	if (paramKeyEvent.getKeyCode() == KeyEvent.VK_ENTER) {
-	    String queryString = fieldSearch.getText();
-	    ThumbnailSearchPanel searchPanel = new ThumbnailSearchPanel(queryString);
-	    addTabb(searchPanel);
-	}
-    }
-
-    @Override
-    public void keyReleased(KeyEvent paramKeyEvent) {
-    }
-
-    @Override
-    public void keyTyped(KeyEvent paramKeyEvent) {
-    }
+
+	/**
+	 * Logger
+	 */
+	public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(MainFrame.class);
+	/**
+	 * the categories tree
+	 */
+	private CategoriesTree categoriesTree;
+	/**
+	 * Splitpane. On the left : the categories tree and on the right the thumbnails
+	 * for the current category
+	 */
+	private JSplitPane splitPane;
+	/**
+	 * Panel that contains the thumbnail of the current category
+	 */
+	public static ThumbnailCategoryPanel imagesPanel;
+	/**
+	 *  Scrollpane that contains the panel above
+	 */
+	private JScrollPane scrollPaneImagesPanel;
+	/**
+	 * label that displays messages
+	 */
+	private JLabel labelMessage;
+
+	/**
+	 * menu bar
+	 */
+	private JMenuBar jMenuBar;
+
+	/**
+	 * edition menu
+	 */
+	private JMenu jMenuEdition;
+
+	/**
+	 * preferences menu
+	 */
+	private JMenuItem jMenuItemPreferences;
+
+	/**
+	 * singleton
+	 */
+	private static MainFrame instance;
+
+	private JProgressBar progressBar;
+
+	private JTabbedPaneWithCloseIcons tabbedPane;
+
+	private HashMap<Integer, Integer> mapsIdPos = new HashMap<Integer, Integer>();
+
+	private HintTextField fieldSearch;
+
+
+	/**
+	 * @return the singleton
+	 */
+	public static MainFrame getInstance() {
+		if (instance == null) {
+			instance = new MainFrame();
+		}
+		return instance;
+	}
+
+
+	/**
+	 * private constructor to use a singleton
+	 */
+	private MainFrame() {
+		this.setTitle("Jiwigo v" + Messages.getMessage("version"));
+		this.setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage(Outil.getURL("fr/mael/jiwigo/img/icon.png")));
+		this.setLayout(new BorderLayout());
+		jMenuBar = new JMenuBar();
+		labelMessage = new JLabel(Messages.getMessage("welcomeMessage"));
+		splitPane = new JSplitPane();
+		categoriesTree = new CategoriesTree();
+		splitPane.setLeftComponent(categoriesTree);
+
+		tabbedPane = new JTabbedPaneWithCloseIcons();
+		splitPane.setRightComponent(tabbedPane);
+
+		this.add(splitPane, BorderLayout.CENTER);
+		JPanel panelBas = new JPanel(new BorderLayout());
+		JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
+		progressBar = new JProgressBar(0, 100);
+		panel.add(progressBar);
+		panel.add(labelMessage);
+		panelBas.add(panel, BorderLayout.WEST);
+
+		fieldSearch = new HintTextField(Messages.getMessage("mainFrame_recherche"));
+		fieldSearch.setPreferredSize(new Dimension(150, 25));
+		fieldSearch.addKeyListener(this);
+		panelBas.add(fieldSearch, BorderLayout.EAST);
+
+		jMenuEdition = new JMenu(Messages.getMessage("mainFrame_editionMenu"));
+		jMenuBar.add(jMenuEdition);
+		jMenuItemPreferences = new JMenuItem(Messages.getMessage("mainFrame_preferencesMenu"));
+		jMenuItemPreferences.addActionListener(this);
+		jMenuEdition.add(jMenuItemPreferences);
+
+		this.setJMenuBar(jMenuBar);
+		this.add(panelBas, BorderLayout.SOUTH);
+		this.setSize(900, 600);
+		this.setLocationRelativeTo(null);
+		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+		this.setResizable(true);
+	}
+
+
+	public void addTabb(IThumbnailPanel panel) {
+		JScrollPane scrollPaneImagesPanel = new JScrollPane((JPanel) panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+		scrollPaneImagesPanel.setPreferredSize(new Dimension(900, 600));
+		boolean found = false;
+		boolean isSearch = false;
+		if (panel instanceof ThumbnailSearchPanel) {
+			isSearch = true;
+		}
+
+		for (int i = 0; i < tabbedPane.getTabCount(); i++) {
+			JScrollPane scroll = (JScrollPane) tabbedPane.getComponentAt(i);
+			IThumbnailPanel thumbPan = (IThumbnailPanel) scroll.getViewport().getComponents()[0];
+			if (thumbPan.getCategory().getIdentifiant().equals(panel.getCategory().getIdentifiant())) {
+				//only if it's not for a re
+				if (!(panel instanceof ThumbnailSearchPanel)) {
+					tabbedPane.setSelectedIndex(i);
+					found = true;
+					break;
+				}
+			}
+		}
+		//if it's not for a research, the title of the tab
+		//is the name of the category
+		if (!found && !isSearch) {
+			tabbedPane.addTab(panel.getCategory().getNom(), scrollPaneImagesPanel,
+					new ImageIcon(Outil.getURL("fr/mael/jiwigo/img/closetab.png")));
+			//if it's for a research, the title of the tab
+			//if the query string
+		} else if (!found && isSearch) {
+			String queryString = ((ThumbnailSearchPanel) panel).getQueryString();
+			tabbedPane.addTab(Messages.getMessage("mainFrame_search") + queryString, scrollPaneImagesPanel,
+					new ImageIcon(Outil.getURL("fr/mael/jiwigo/img/closetab.png")));
+		}
+
+	}
+
+
+	/**
+	 * displays the frame
+	 */
+	public void showUi() {
+		this.setVisible(true);
+	}
+
+
+	/**
+	 * Affichage d'un message de réussite
+	 * @param message
+	 */
+	public void setMessage(String message) {
+		this.labelMessage.setText(message);
+	}
+
+
+	@Override
+	public void actionPerformed(ActionEvent arg0) {
+		if (arg0.getSource().equals(jMenuItemPreferences)) {
+			new PreferencesDialog(this);
+		}
+
+	}
+
+
+	public static void reduceSizeOfComponent(JComponent comp) {
+		comp.setMaximumSize(comp.getPreferredSize());
+	}
+
+
+	/**
+	 * @return the progressBar
+	 */
+	public JProgressBar getProgressBar() {
+		return progressBar;
+	}
+
+
+	/**
+	 * @return the mapsIdPos
+	 */
+	public HashMap<Integer, Integer> getMapsIdPos() {
+		return mapsIdPos;
+	}
+
+
+	@Override
+	public void keyPressed(KeyEvent paramKeyEvent) {
+		if (paramKeyEvent.getKeyCode() == KeyEvent.VK_ENTER) {
+			String queryString = fieldSearch.getText();
+			ThumbnailSearchPanel searchPanel = new ThumbnailSearchPanel(queryString);
+			addTabb(searchPanel);
+		}
+	}
+
+
+	@Override
+	public void keyReleased(KeyEvent paramKeyEvent) {
+	}
+
+
+	@Override
+	public void keyTyped(KeyEvent paramKeyEvent) {
+	}
 
 }
Index: extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/ThumbnailCategoryPanel.java
===================================================================
--- extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/ThumbnailCategoryPanel.java	(revision 7219)
+++ extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/ThumbnailCategoryPanel.java	(revision 7221)
@@ -1,10 +1,10 @@
 package fr.mael.jiwigo.ui.mainframe;
 
+import java.awt.Dimension;
 import java.awt.FlowLayout;
+import java.awt.Graphics;
 import java.io.File;
-
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
-
 import fr.mael.jiwigo.om.Category;
 import fr.mael.jiwigo.om.Image;
@@ -15,4 +15,5 @@
 import fr.mael.jiwigo.transverse.util.filedrop.FileDrop;
 import fr.mael.jiwigo.ui.layout.VerticalLayout;
+
 
 /**
@@ -46,173 +47,193 @@
  */
 public class ThumbnailCategoryPanel extends JPanel implements IThumbnailPanel {
-    /**
-     * Logger
-     */
-    public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
-	    .getLog(ThumbnailCategoryPanel.class);
-    /**
-     * id of the category
-     */
-    private Integer categoryId;
-
-    private Category category;
-
-    public ThumbnailCategoryPanel(Category category) {
-	this(category.getIdentifiant());
-	this.category = category;
-    }
-
-    /**
-     * Constructor
-     * @param categoryId id of the category
-     */
-    public ThumbnailCategoryPanel(Integer categoryId) {
-	this.categoryId = categoryId;
-	this.setLayout(new VerticalLayout());
-	if (categoryId != null) {
-	    rafraichir(categoryId, false);
-	}
-	//gestion du drag'n drop
-	new FileDrop(System.out, this, new FileDrop.Listener() {
-	    public void filesDropped(final java.io.File[] files) {
-		if (!ImagesManagement.rememberPrivacyLevel) {
-		    new DialogPrivacyLevel();
-		}
-		new Thread(new ThreadEnvoiPhoto(files)).start();
-
-	    }
-	});
-
-    }
-
-    /**
-     * refreshes the panel
-     * @param categoryId the id of the category
-     */
-    public void rafraichir(Integer categoryId, boolean rafraichir) {
-	this.categoryId = categoryId;
-	new Thread(new ThreadLoadThumb(this, rafraichir)).start();
-    }
-
-    /**
-     * @return the categoryId
-     */
-    public Integer getCategoryId() {
-	return categoryId;
-    }
-
-    /**
-     * @param categoryId the categoryId to set
-     */
-    public void setCategoryId(Integer categoryId) {
-	this.categoryId = categoryId;
-    }
-
-    /**
-     * @return the category
-     */
-    public Category getCategory() {
-	return category;
-    }
-
-    /**
-     * @param category the category to set
-     */
-    public void setCategory(Category category) {
-	this.category = category;
-    }
-
-    /**
-     * @author mael
-     * Thread that send the photos
-     */
-    public class ThreadEnvoiPhoto implements Runnable {
-	private File[] files;
-
-	public ThreadEnvoiPhoto(File[] files) {
-	    this.files = files;
-	}
+
+	/**
+	 * Logger
+	 */
+	public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(ThumbnailCategoryPanel.class);
+	/**
+	 * id of the category
+	 */
+	private Integer categoryId;
+
+	private Category category;
+
+	/**
+	 * thumbnails per line
+	 */
+	private int thumbnailPerLine = 7;
+
+	/**
+	 * Saved dimension of the panel, used to define the number
+	 * of thumbnails on a line
+	 */
+	private Dimension savedDimension = new Dimension();
+
+
+	public ThumbnailCategoryPanel(Category category) {
+		this(category.getIdentifiant());
+		this.category = category;
+	}
+
+
+	/**
+	 * Constructor
+	 * @param categoryId id of the category
+	 */
+	public ThumbnailCategoryPanel(Integer categoryId) {
+		this.categoryId = categoryId;
+		this.setLayout(new VerticalLayout());
+		if (categoryId != null) {
+			rafraichir(categoryId, false);
+		}
+		//gestion du drag'n drop
+		new FileDrop(System.out, this, new FileDrop.Listener() {
+
+			public void filesDropped(final java.io.File[] files) {
+				if (!ImagesManagement.rememberPrivacyLevel) {
+					new DialogPrivacyLevel();
+				}
+				new Thread(new ThreadEnvoiPhoto(files)).start();
+
+			}
+		});
+
+	}
+
 
 	@Override
-	public void run() {
-
-	    for (int i = 0; i < files.length; i++) {
-		int nbProgressBar = ((i + 1) * 100) / files.length;
+	public void paint(Graphics g) {
+		super.paint(g);
+		if (!MainFrame.getInstance().getSize().equals(savedDimension)) {
+			//			LOG.debug("paint " + getSize());
+			savedDimension = MainFrame.getInstance().getSize();
+			int width = savedDimension.width;
+			thumbnailPerLine = width / 150;
+			addThumbnails();
+		}
+	}
+
+
+	/**
+	 * refreshes the panel
+	 * @param categoryId the id of the category
+	 */
+	public void rafraichir(Integer categoryId, boolean rafraichir) {
+		this.categoryId = categoryId;
 		try {
-
-		    ImageService.getInstance().creer(files[i].getCanonicalPath(), categoryId);
-		    MainFrame.getInstance()
-			    .setMessage(files[i].getName() + " " + Messages.getMessage("sendingSuccess"));
+			MainFrame.getInstance().setMessage(Messages.getMessage("thumbviewer_loading"));
+			ImagesManagement.LIST_IMAGE = ImageService.getInstance().listerParCategory(categoryId, rafraichir);
+			addThumbnails();
+			this.repaint();
+			this.revalidate();
+			MainFrame.getInstance().setMessage(Messages.getMessage("loadingOk"));
 		} catch (Exception e) {
-		    LOG.error(Outil.getStackTrace(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);
-		}
-	    }
-	    //refresh
-	    rafraichir(categoryId, true);
-	    MainFrame.getInstance().getProgressBar().setValue(0);
-	}
-    }
-
-    /**
-     * 
-     * @author mael
-     * Thread that loads the thumbs and fills the thumb panel
-     */
-    public class ThreadLoadThumb implements Runnable {
-	ThumbnailCategoryPanel panel;
-	boolean rafraichir;
-
-	public ThreadLoadThumb(ThumbnailCategoryPanel panel, boolean rafraichir) {
-	    this.panel = panel;
-	    this.rafraichir = rafraichir;
-	}
-
-	@Override
-	public void run() {
-
-	    panel.removeAll();
-	    int nb = 1;
-	    JPanel panelh = new JPanel(new FlowLayout());
-	    try {
-		MainFrame.getInstance().setMessage(Messages.getMessage("thumbviewer_loading"));
-		ImagesManagement.LIST_IMAGE = ImageService.getInstance().listerParCategory(categoryId, rafraichir);
+			LOG.error(Outil.getStackTrace(e));
+			JOptionPane.showMessageDialog(null, Messages.getMessage("imagesListingError"), Messages.getMessage("error"),
+					JOptionPane.ERROR_MESSAGE);
+			MainFrame.getInstance().setMessage(Messages.getMessage("imagesListingError"));
+		}
+	}
+
+
+	/**
+	 * Adds the thumbnails to the panel
+	 */
+	private void addThumbnails() {
+		this.removeAll();
+		int nb = 1;
+		JPanel panelh = new JPanel(new FlowLayout());
 		for (Image image : ImagesManagement.LIST_IMAGE) {
-		    try {
-
-			if (nb == 7) {
-			    panel.add(panelh);
-			    panelh = new JPanel(new FlowLayout());
-			    nb = 0;
-			} else {
-			    ThumbnailPanel panel = new ThumbnailPanel(image);
-			    panelh.add(panel);
+			try {
+
+				if (nb == thumbnailPerLine) {
+					this.add(panelh);
+					panelh = new JPanel(new FlowLayout());
+					nb = 0;
+				} else {
+					ThumbnailPanel panel = new ThumbnailPanel(image);
+					panelh.add(panel);
+				}
+				nb++;
+
+			} catch (Exception e) {
+
 			}
-			nb++;
-
-		    } catch (Exception e) {
-
-		    }
-		}
-		if (nb != 8) {
-		    panel.add(panelh);
-		}
-		panel.repaint();
-		panel.revalidate();
-		MainFrame.getInstance().setMessage(Messages.getMessage("loadingOk"));
-	    } catch (Exception e) {
-		LOG.error(Outil.getStackTrace(e));
-		JOptionPane.showMessageDialog(null, Messages.getMessage("imagesListingError"), Messages
-			.getMessage("error"), JOptionPane.ERROR_MESSAGE);
-		MainFrame.getInstance().setMessage(Messages.getMessage("imagesListingError"));
-	    }
-
-	}
-    }
+		}
+		if (nb != thumbnailPerLine + 1) {
+			this.add(panelh);
+		}
+	}
+
+
+	/**
+	 * @return the categoryId
+	 */
+	public Integer getCategoryId() {
+		return categoryId;
+	}
+
+
+	/**
+	 * @param categoryId the categoryId to set
+	 */
+	public void setCategoryId(Integer categoryId) {
+		this.categoryId = categoryId;
+	}
+
+
+	/**
+	 * @return the category
+	 */
+	public Category getCategory() {
+		return category;
+	}
+
+
+	/**
+	 * @param category the category to set
+	 */
+	public void setCategory(Category category) {
+		this.category = category;
+	}
+
+	/**
+	 * @author mael
+	 * Thread that send the photos
+	 */
+	public class ThreadEnvoiPhoto implements Runnable {
+
+		private File[] files;
+
+
+		public ThreadEnvoiPhoto(File[] files) {
+			this.files = files;
+		}
+
+
+		@Override
+		public void run() {
+
+			for (int i = 0; i < files.length; i++) {
+				int nbProgressBar = ((i + 1) * 100) / files.length;
+				try {
+
+					ImageService.getInstance().creer(files[i].getCanonicalPath(), categoryId);
+					MainFrame.getInstance().setMessage(files[i].getName() + " " + Messages.getMessage("sendingSuccess"));
+				} catch (Exception e) {
+					LOG.error(Outil.getStackTrace(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);
+				}
+			}
+			//refresh
+			rafraichir(categoryId, true);
+			MainFrame.getInstance().getProgressBar().setValue(0);
+		}
+	}
 
 }
Index: extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/ThumbnailPanel.java
===================================================================
--- extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/ThumbnailPanel.java	(revision 7219)
+++ extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/ThumbnailPanel.java	(revision 7221)
@@ -14,5 +14,4 @@
 import java.io.IOException;
 import java.util.List;
-
 import javax.swing.JButton;
 import javax.swing.JDialog;
@@ -25,5 +24,4 @@
 import javax.swing.JScrollPane;
 import javax.swing.ListSelectionModel;
-
 import fr.mael.jiwigo.om.Image;
 import fr.mael.jiwigo.om.Tag;
@@ -34,4 +32,5 @@
 import fr.mael.jiwigo.ui.browser.BrowserFrame;
 import fr.mael.jiwigo.ui.layout.VerticalLayout;
+
 
 /**
@@ -65,169 +64,178 @@
  */
 public class ThumbnailPanel extends JLabel implements MouseListener, ActionListener {
-    /**
-     * Logger
-     */
-    public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
-	    .getLog(ThumbnailPanel.class);
-    /**
-     * the image
-     */
-    private Image image;
-
-    /**
-     * Popup menu to edit images info
-     */
-    private JMenuItem menuAjouterTag;
-
-    /**
-     * Button to add tags
-     */
-    private JButton boutonOkAjouterTag;
-
-    /**
-     * List of tags
-     */
-    private JList listTags;
-
-    /**
-     * Dialog that allows to choose tags
-     */
-    private JDialog dialogChoixTags;
-
-    /**
-     * Constructeur
-     * @param image the image
-     * @param imagesPanel the panel
-     */
-    public ThumbnailPanel(Image image) {
-	this.image = image;
-	setToolTipText("<html><center>" + image.getName() + "<br/>" + image.getVue() + " "
-		+ Messages.getMessage("hits") + "</center></html>");
-	this.addMouseListener(this);
-    }
-
-    protected void paintComponent(Graphics g) {
-	super.paintComponent(g);
-	Graphics2D g2 = (Graphics2D) g;
-	g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
-	double x = (getWidth() * ImagesManagement.getMiniatureBufferedImage(image).getWidth()) / 2;
-	double y = (getHeight() * ImagesManagement.getMiniatureBufferedImage(image).getHeight()) / 2;
-	g2.drawRenderedImage(ImagesManagement.getMiniatureBufferedImage(image), null);
-    }
-
-    /* (non-Javadoc)
-     * @see javax.swing.JComponent#getPreferredSize()
-     */
-    public Dimension getPreferredSize() {
-	int w = (int) (ImagesManagement.getMiniatureBufferedImage(image).getWidth());
-	int h = (int) (ImagesManagement.getMiniatureBufferedImage(image).getHeight() + 10);
-	return new Dimension(w, h);
-    }
-
-    @Override
-    public void mouseClicked(MouseEvent paramMouseEvent) {
-	// on affiche l'image en grand
-	ImagesManagement.setCurrentImage(image);
-	try {
-	    if (paramMouseEvent.getButton() == 1) {
-		new BrowserFrame(image);
-	    } else if (paramMouseEvent.getButton() == 3) {
-		JPopupMenu popup = new JPopupMenu();
-		menuAjouterTag = new JMenuItem(Messages.getMessage("thumbviewer_addTag"));
-		menuAjouterTag.addActionListener(this);
-		popup.add(menuAjouterTag);
-		popup.show(this, paramMouseEvent.getX(), paramMouseEvent.getY());
-	    }
-	} catch (Exception e) {
-	    e.printStackTrace();
-	}
-
-    }
-
-    @Override
-    public void mouseEntered(MouseEvent paramMouseEvent) {
-	this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
-    }
-
-    @Override
-    public void mouseExited(MouseEvent paramMouseEvent) {
-    }
-
-    @Override
-    public void mousePressed(MouseEvent paramMouseEvent) {
-	// TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void mouseReleased(MouseEvent paramMouseEvent) {
-	// TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void actionPerformed(ActionEvent arg0) {
-	if (arg0.getSource().equals(menuAjouterTag)) {
-	    try {
-		//getting the list of tags
-		List<Tag> tagsDispo = TagService.getInstance().lister();
-		//list to array (cause fucking JList does not support Lists)
-		Tag[] tableauTagDispo = (Tag[]) tagsDispo.toArray(new Tag[tagsDispo.size()]);
-		//getting the image's tags to preselect them
-		List<Tag> tagsDeLimage = TagService.getInstance().tagsForImage(image);
-		listTags = new JList(tableauTagDispo);
-		//multiple selection is allowed
-		listTags.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
-		listTags.setPreferredSize(new Dimension(100, 200));
-		//construct an array of the indices to select in the jlist
-		int[] indices = new int[tagsDeLimage.size()];
-		int compteur = 0;
-		for (int i = 0; i < tableauTagDispo.length; i++) {
-		    for (Tag tag : tagsDeLimage) {
-			if (tag.getId().equals(tableauTagDispo[i].getId())) {
-			    indices[compteur++] = i;
-
-			}
-		    }
+
+	/**
+	 * Logger
+	 */
+	public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(ThumbnailPanel.class);
+	/**
+	 * the image
+	 */
+	private Image image;
+
+	/**
+	 * Popup menu to edit images info
+	 */
+	private JMenuItem menuAjouterTag;
+
+	/**
+	 * Button to add tags
+	 */
+	private JButton boutonOkAjouterTag;
+
+	/**
+	 * List of tags
+	 */
+	private JList listTags;
+
+	/**
+	 * Dialog that allows to choose tags
+	 */
+	private JDialog dialogChoixTags;
+
+
+	/**
+	 * Constructeur
+	 * @param image the image
+	 * @param imagesPanel the panel
+	 */
+	public ThumbnailPanel(Image image) {
+		this.image = image;
+		setToolTipText("<html><center>" + image.getName() + "<br/>" + image.getVue() + " " + Messages.getMessage("hits")
+				+ "</center></html>");
+		this.addMouseListener(this);
+	}
+
+
+	protected void paintComponent(Graphics g) {
+		super.paintComponent(g);
+		Graphics2D g2 = (Graphics2D) g;
+		g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+		double x = (getWidth() * ImagesManagement.getMiniatureBufferedImage(image).getWidth()) / 2;
+		double y = (getHeight() * ImagesManagement.getMiniatureBufferedImage(image).getHeight()) / 2;
+		g2.drawRenderedImage(ImagesManagement.getMiniatureBufferedImage(image), null);
+	}
+
+
+	/* (non-Javadoc)
+	 * @see javax.swing.JComponent#getPreferredSize()
+	 */
+	public Dimension getPreferredSize() {
+		int w = (int) (ImagesManagement.getMiniatureBufferedImage(image).getWidth());
+		int h = (int) (ImagesManagement.getMiniatureBufferedImage(image).getHeight() + 10);
+		return new Dimension(w, h);
+	}
+
+
+	@Override
+	public void mouseClicked(MouseEvent paramMouseEvent) {
+		// on affiche l'image en grand
+		ImagesManagement.setCurrentImage(image);
+		try {
+			if (paramMouseEvent.getButton() == 1) {
+				new BrowserFrame(image);
+			} else if (paramMouseEvent.getButton() == 3) {
+				JPopupMenu popup = new JPopupMenu();
+				menuAjouterTag = new JMenuItem(Messages.getMessage("thumbviewer_addTag"));
+				menuAjouterTag.addActionListener(this);
+				popup.add(menuAjouterTag);
+				popup.show(this, paramMouseEvent.getX(), paramMouseEvent.getY());
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
 		}
-		listTags.setSelectedIndices(indices);
-
-		JScrollPane scrollPane = new JScrollPane(listTags);
-		dialogChoixTags = new JDialog();
-		dialogChoixTags.setLayout(new BorderLayout());
-		JPanel panelNorth = new JPanel(new VerticalLayout());
-		panelNorth.add(new JLabel(Messages.getMessage("thumbviewer_selectTag")));
-		panelNorth.add(scrollPane);
-		dialogChoixTags.add(panelNorth, BorderLayout.NORTH);
-		JPanel panelBouton = new JPanel(new FlowLayout());
-		boutonOkAjouterTag = new JButton("Ok");
-		panelBouton.add(boutonOkAjouterTag);
-		boutonOkAjouterTag.addActionListener(this);
-		dialogChoixTags.add(panelBouton, BorderLayout.CENTER);
-		dialogChoixTags.setSize(new Dimension(400, 280));
-		dialogChoixTags.setLocationRelativeTo(null);
-		dialogChoixTags.setVisible(true);
-	    } catch (IOException e) {
-		e.printStackTrace();
-	    }
-	} else if (arg0.getSource().equals(boutonOkAjouterTag)) {
-	    StringBuffer tagIds = new StringBuffer("");
-	    for (Object object : listTags.getSelectedValues()) {
-		Tag tag = (Tag) object;
-		tagIds.append(tag.getId() + ",");
-	    }
-	    tagIds.deleteCharAt(tagIds.lastIndexOf(","));
-	    try {
-		if (!ImageService.getInstance().addTags(image, tagIds.toString())) {
-		    JOptionPane.showMessageDialog(this, Messages.getMessage("addingTagsError"), Messages
-			    .getMessage("error"), JOptionPane.ERROR_MESSAGE);
-		} else {
-		    dialogChoixTags.dispose();
+
+	}
+
+
+	@Override
+	public void mouseEntered(MouseEvent paramMouseEvent) {
+		this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+	}
+
+
+	@Override
+	public void mouseExited(MouseEvent paramMouseEvent) {
+	}
+
+
+	@Override
+	public void mousePressed(MouseEvent paramMouseEvent) {
+		// TODO Auto-generated method stub
+
+	}
+
+
+	@Override
+	public void mouseReleased(MouseEvent paramMouseEvent) {
+		// TODO Auto-generated method stub
+
+	}
+
+
+	@Override
+	public void actionPerformed(ActionEvent arg0) {
+		if (arg0.getSource().equals(menuAjouterTag)) {
+			try {
+				//getting the list of tags
+				List<Tag> tagsDispo = TagService.getInstance().lister();
+				//list to array (cause fucking JList does not support Lists)
+				Tag[] tableauTagDispo = (Tag[]) tagsDispo.toArray(new Tag[tagsDispo.size()]);
+				//getting the image's tags to preselect them
+				List<Tag> tagsDeLimage = TagService.getInstance().tagsForImage(image);
+				listTags = new JList(tableauTagDispo);
+				//multiple selection is allowed
+				listTags.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+				listTags.setPreferredSize(new Dimension(100, 200));
+				//construct an array of the indices to select in the jlist
+				int[] indices = new int[tagsDeLimage.size()];
+				int compteur = 0;
+				for (int i = 0; i < tableauTagDispo.length; i++) {
+					for (Tag tag : tagsDeLimage) {
+						if (tag.getId().equals(tableauTagDispo[i].getId())) {
+							indices[compteur++] = i;
+
+						}
+					}
+				}
+				listTags.setSelectedIndices(indices);
+
+				JScrollPane scrollPane = new JScrollPane(listTags);
+				dialogChoixTags = new JDialog();
+				dialogChoixTags.setLayout(new BorderLayout());
+				JPanel panelNorth = new JPanel(new VerticalLayout());
+				panelNorth.add(new JLabel(Messages.getMessage("thumbviewer_selectTag")));
+				panelNorth.add(scrollPane);
+				dialogChoixTags.add(panelNorth, BorderLayout.NORTH);
+				JPanel panelBouton = new JPanel(new FlowLayout());
+				boutonOkAjouterTag = new JButton("Ok");
+				panelBouton.add(boutonOkAjouterTag);
+				boutonOkAjouterTag.addActionListener(this);
+				dialogChoixTags.add(panelBouton, BorderLayout.CENTER);
+				dialogChoixTags.setSize(new Dimension(400, 280));
+				dialogChoixTags.setLocationRelativeTo(null);
+				dialogChoixTags.setVisible(true);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		} else if (arg0.getSource().equals(boutonOkAjouterTag)) {
+			StringBuffer tagIds = new StringBuffer("");
+			for (Object object : listTags.getSelectedValues()) {
+				Tag tag = (Tag) object;
+				tagIds.append(tag.getId() + ",");
+			}
+			tagIds.deleteCharAt(tagIds.lastIndexOf(","));
+			try {
+				if (!ImageService.getInstance().addTags(image, tagIds.toString())) {
+					JOptionPane.showMessageDialog(this, Messages.getMessage("addingTagsError"), Messages.getMessage("error"),
+							JOptionPane.ERROR_MESSAGE);
+				} else {
+					dialogChoixTags.dispose();
+				}
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+
 		}
-	    } catch (IOException e) {
-		e.printStackTrace();
-	    }
-
-	}
-    }
+	}
 }
