Changeset 6962


Ignore:
Timestamp:
Sep 19, 2010, 3:19:40 PM (14 years ago)
Author:
mlg
Message:

"Feature" :
Until now, it was not possible to create a "root" category. It is now possible.

Location:
extensions/jiwigo/trunk/src
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/dao/CategoryDao.java

    r6831 r6962  
    9797    public boolean creer(Category category) {
    9898        try {
    99             return Outil.checkOk(Main.sessionManager.executerReturnDocument(MethodsEnum.AJOUTER_CATEGORIE.getLabel(),
    100                     "name", category.getNom(), "parent", String.valueOf(category.getParentDirect())));
     99            if (category.getParentDirect() != null) {
     100                return Outil.checkOk(Main.sessionManager.executerReturnDocument(MethodsEnum.AJOUTER_CATEGORIE
     101                        .getLabel(), "name", category.getNom(), "parent", String.valueOf(category.getParentDirect())));
     102            } else {
     103                return Outil.checkOk(Main.sessionManager.executerReturnDocument(MethodsEnum.AJOUTER_CATEGORIE
     104                        .getLabel(), "name", category.getNom()));
     105            }
    101106        } catch (IOException e) {
    102107            LOG.error(Outil.getStackTrace(e));
  • extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/om/Category.java

    r6821 r6962  
    6363        idCategoriesMeres = new ArrayList<Integer>();
    6464        for (String cat : catMeres.split(",")) {
    65             idCategoriesMeres.add(Integer.valueOf(cat));
     65            if (!cat.equals("")) {
     66                idCategoriesMeres.add(Integer.valueOf(cat));
     67            }
    6668        }
    6769        categoriesFilles = new ArrayList<Category>();
  • extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/service/CategoryService.java

    r6831 r6962  
    113113        return CategoryDao.getInstance().creer(category);
    114114    }
     115
     116    /**
     117     * Création d'une catégorie
     118     * @param nom nom de la catégorie
     119     * @param parent catégorie parent
     120     * @return true si la catégorie a bien été créée
     121     */
     122    public boolean creer(String nom) {
     123        Category category = new Category();
     124        category.setNom(nom);
     125        return CategoryDao.getInstance().creer(category);
     126    }
    115127}
  • extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/CategoriesTree.java

    r6958 r6962  
    189189        tree.setSelectionRow(selRow);
    190190        //end
    191         if (selRow != -1) {
    192             if (e.getButton() == 3) {
    193                 JPopupMenu popup = new JPopupMenu();
    194                 menuAjouter = new JMenuItem(Messages.getMessage("categories_add"));
    195                 menuAjouter.addActionListener(this);
    196                 popup.add(menuAjouter);
    197                 menuActualiser = new JMenuItem(Messages.getMessage("categories_update"));
    198                 menuActualiser.addActionListener(this);
    199                 popup.add(menuActualiser);
    200                 popup.show(tree, e.getX(), e.getY());
     191
     192        if (e.getButton() == 3) {
     193            JPopupMenu popup = new JPopupMenu();
     194            menuAjouter = new JMenuItem(Messages.getMessage("categories_add"));
     195            menuAjouter.addActionListener(this);
     196            popup.add(menuAjouter);
     197            menuActualiser = new JMenuItem(Messages.getMessage("categories_update"));
     198            menuActualiser.addActionListener(this);
     199            popup.add(menuActualiser);
     200            popup.show(tree, e.getX(), e.getY());
     201            if (selRow != -1) {
    201202                DefaultMutableTreeNode node = (DefaultMutableTreeNode) (selPath.getLastPathComponent());
    202203                this.selectedCategory = (Category) node.getUserObject();
     204            } else {
     205                this.selectedCategory = null;
    203206            }
    204207        }
     
    217220            String nomcategorie = JOptionPane.showInputDialog(null, Messages.getMessage("categories_enterName"),
    218221                    Messages.getMessage("categories_add"), JOptionPane.INFORMATION_MESSAGE);
     222            //if the name of the category is not empty
    219223            if (!(nomcategorie == null) && !nomcategorie.equals("")) {
    220                 if (CategoryService.getInstance().creer(nomcategorie, selectedCategory.getIdentifiant())) {
    221                     setUpUi();
     224                //if there is a parent category
     225                if (selectedCategory != null) {
     226                    //try to create a category
     227                    if (CategoryService.getInstance().creer(nomcategorie, selectedCategory.getIdentifiant())) {
     228                        setUpUi();
     229                    } else {
     230                        JOptionPane.showMessageDialog(null, Messages.getMessage("categoryCreationError"), Messages
     231                                .getMessage("error"), JOptionPane.ERROR_MESSAGE);
     232
     233                    }
    222234                } else {
    223                     JOptionPane.showMessageDialog(null, Messages.getMessage("categoryCreationError"), Messages
    224                             .getMessage("error"), JOptionPane.ERROR_MESSAGE);
    225 
     235                    if (CategoryService.getInstance().creer(nomcategorie)) {
     236                        setUpUi();
     237                    } else {
     238                        JOptionPane.showMessageDialog(null, Messages.getMessage("categoryCreationError"), Messages
     239                                .getMessage("error"), JOptionPane.ERROR_MESSAGE);
     240
     241                    }
    226242                }
    227243            }
  • extensions/jiwigo/trunk/src/main/resources/log4j.xml

    r6959 r6962  
    2323        <!-- Déclaration loggers -->
    2424        <logger name="fr.mael.jiwigo" additivity="false">
    25                 <level value="DEBUG" />
     25                <level value="INFO" />
    2626                <appender-ref ref="console" />
    2727                <appender-ref ref="fichier" />
Note: See TracChangeset for help on using the changeset viewer.