Changeset 8838


Ignore:
Timestamp:
01/22/11 14:46:45 (9 years ago)
Author:
mlg
Message:

Images can be sent from the file new file browser.

Location:
extensions/jiwigo/trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • extensions/jiwigo/trunk/install/install.txt

    r6963 r8838  
    55##################################################################################### 
    66 
    7 1 - You must first checkout the project from svn. Create a new Java project from the svn version. 
     71 - You must first checkout the project from svn (url is http://piwigo.org/svn/extensions/jiwigo/). Create a new Java project from the svn version. 
    882 - Then install maven plugin for eclipse. It is available from that update site : http://m2eclipse.sonatype.org/sites/m2e 
    993 - Then enable maven dependency management : right click on the project > maven > enable dependency management. 
  • extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/Main.java

    r7221 r8838  
    33import java.io.File; 
    44import java.io.IOException; 
     5 
    56import javax.swing.UIManager; 
     7 
    68import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel; 
     9 
    710import fr.mael.jiwigo.transverse.session.SessionManager; 
    811import fr.mael.jiwigo.transverse.util.Outil; 
     
    1013import fr.mael.jiwigo.ui.ConnexionDialog; 
    1114import fr.mael.jiwigo.ui.mainframe.MainFrame; 
    12  
    1315 
    1416/** 
     
    3840   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3941    
    40  * Classe principale de lancement de l'interface. 
     42 * Main class 
    4143 * @author mael 
    4244 * 
     
    4446public class Main { 
    4547 
    46         /** 
    47         * Logger 
    48         */ 
    49         public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(Main.class); 
    50         /** 
    51         * The login and session manager that allows to connect to 
    52         * the webservice and to query it 
    53         */ 
    54         public static SessionManager sessionManager; 
     48    /** 
     49    * Logger 
     50    */ 
     51    public static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory.getLog(Main.class); 
     52    /** 
     53    * The login and session manager that allows to connect to 
     54    * the webservice and to query it 
     55    */ 
     56    public static SessionManager sessionManager; 
    5557 
    56         /** 
    57         *  the main window 
    58         */ 
    59         private static MainFrame mainFrame; 
     58    /** 
     59    *  the main window 
     60    */ 
     61    private static MainFrame mainFrame; 
    6062 
    61  
    62         public static void main(String[] args) { 
    63                 try { 
    64                         UIManager.setLookAndFeel(new NimbusLookAndFeel()); 
    65                 } catch (Exception e) { 
    66                 } 
    67                 File dossierConfig = new File(System.getProperty("user.home") + "/.jiwigo"); 
    68                 if (!dossierConfig.exists()) { 
    69                         dossierConfig.mkdir(); 
    70                 } 
    71                 try { 
    72                         PreferencesManagement.creerFichierParDefaut(); 
    73                         //dialog de connexion 
    74                         ConnexionDialog dialog = new ConnexionDialog(); 
    75                         dialog.showDialog(); 
    76                 } catch (IOException e) { 
    77                         LOG.error(Outil.getStackTrace(e)); 
    78                 } 
    79  
     63    public static void main(String[] args) { 
     64        try { 
     65            UIManager.setLookAndFeel(new NimbusLookAndFeel()); 
     66        } catch (Exception e) { 
     67        } 
     68        File dossierConfig = new File(System.getProperty("user.home") + "/.jiwigo"); 
     69        if (!dossierConfig.exists()) { 
     70            dossierConfig.mkdir(); 
     71        } 
     72        try { 
     73            PreferencesManagement.creerFichierParDefaut(); 
     74            //dialog de connexion 
     75            ConnexionDialog dialog = new ConnexionDialog(); 
     76            dialog.showDialog(); 
     77        } catch (IOException e) { 
     78            LOG.error(Outil.getStackTrace(e)); 
    8079        } 
    8180 
     81    } 
    8282 
    83         public static void showFrame() { 
     83    public static void showFrame() { 
    8484 
    85                 if (mainFrame == null) { 
    86                         mainFrame = MainFrame.getInstance(); 
    87                 } 
    88                 if (!mainFrame.isVisible()) { 
    89                         mainFrame.showUi(); 
    90                 } 
     85        if (mainFrame == null) { 
     86            mainFrame = MainFrame.getInstance(); 
    9187        } 
     88        if (!mainFrame.isVisible()) { 
     89            mainFrame.showUi(); 
     90        } 
     91    } 
    9292} 
  • extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/dao/ImageDao.java

    r8829 r8838  
    1414import fr.mael.jiwigo.Main; 
    1515import fr.mael.jiwigo.om.Image; 
    16 import fr.mael.jiwigo.transverse.ImagesManagement; 
    1716import fr.mael.jiwigo.transverse.enumeration.MethodsEnum; 
    1817import fr.mael.jiwigo.transverse.enumeration.PreferencesEnum; 
    1918import fr.mael.jiwigo.transverse.util.Outil; 
    2019import fr.mael.jiwigo.transverse.util.preferences.PreferencesManagement; 
     20import fr.mael.jiwigo.ui.mainframe.MainFrame; 
    2121 
    2222/** 
     
    191191            reussite = false; 
    192192        } 
     193        MainFrame.getInstance().setMessage(""); 
    193194        suppressionFichierTemporaires(); 
    194195        return reussite; 
  • extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/om/Category.java

    r6980 r8838  
    4646    private Element element; 
    4747    private Integer parentDirect; 
     48    private Integer level; 
    4849 
    4950    public Category() { 
     
    197198    } 
    198199 
     200    public Integer getLevel() { 
     201        return level; 
     202    } 
     203 
     204    public void setLevel(Integer level) { 
     205        this.level = level; 
     206    } 
     207 
    199208} 
  • extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/service/CategoryService.java

    r6980 r8838  
    8282     * @throws IOException  
    8383     */ 
    84     public List<Category> construireArbre() throws IOException { 
     84    public List<Category> makeTree() throws IOException { 
    8585        List<Category> list = CategoryDao.getInstance().lister(true); 
    8686        for (Category category : list) { 
  • extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/service/ImageService.java

    r8829 r8838  
    77import fr.mael.jiwigo.dao.ImageDao; 
    88import fr.mael.jiwigo.om.Image; 
     9import fr.mael.jiwigo.transverse.ImagesManagement; 
    910import fr.mael.jiwigo.transverse.enumeration.PreferencesEnum; 
    1011import fr.mael.jiwigo.transverse.util.ImagesUtil; 
     
    133134        image.setOriginale(originale); 
    134135        image.setIdCategory(idCategory); 
     136        image.setPrivacyLevel(String.valueOf(ImagesManagement.getInstance().getPrivacyLevel())); 
    135137        MainFrame.getInstance() 
    136138                .setMessage(Messages.getMessage("mainFrame_sendingFiles") + " " + originalFile.getName()); 
  • extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/transverse/session/SessionManager.java

    r8830 r8838  
    168168        method.addParameter("method", methode); 
    169169        for (int i = 0; i < parametres.length; i += 2) { 
     170            System.out.println(parametres[i] + " -> " + parametres[i + 1]); 
    170171            method.addParameter(parametres[i], parametres[i + 1]); 
    171172 
  • extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/CategoriesTree.java

    r8829 r8838  
    138138        DefaultMutableTreeNode category = null; 
    139139        try { 
    140             List<Category> list = CategoryService.getInstance().construireArbre(); 
     140            List<Category> list = CategoryService.getInstance().makeTree(); 
    141141            for (Category cat : list) { 
    142142                if (cat.getCategoriesMeres().size() == 0) { 
  • extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/search/tree/FileTree.java

    r8834 r8838  
    33import java.awt.BorderLayout; 
    44import java.awt.Dimension; 
     5import java.awt.event.ActionEvent; 
     6import java.awt.event.ActionListener; 
    57import java.awt.event.MouseEvent; 
    68import java.awt.event.MouseListener; 
     
    911import javax.swing.JFileChooser; 
    1012import javax.swing.JFrame; 
     13import javax.swing.JMenuItem; 
    1114import javax.swing.JPanel; 
     15import javax.swing.JPopupMenu; 
    1216import javax.swing.JScrollPane; 
    1317import javax.swing.JTextField; 
     
    1721import javax.swing.tree.DefaultMutableTreeNode; 
    1822import javax.swing.tree.DefaultTreeModel; 
     23import javax.swing.tree.TreePath; 
    1924import javax.swing.tree.TreeSelectionModel; 
    2025 
     26import fr.mael.jiwigo.transverse.ImagesManagement; 
     27import fr.mael.jiwigo.ui.mainframe.DialogPrivacyLevel; 
     28import fr.mael.jiwigo.ui.search.DialogChooseCategory; 
    2129import fr.mael.jiwigo.ui.search.File; 
    2230 
     
    5058    * File tree 
    5159*/ 
    52 public class FileTree extends JPanel implements TreeSelectionListener, MouseListener { 
     60public class FileTree extends JPanel implements TreeSelectionListener, MouseListener, ActionListener { 
    5361    private String path; 
    5462 
     
    5866 
    5967    private JTree tree; 
     68 
     69    private ArrayList<File> filesToSend; 
     70 
     71    /** 
     72     * the menu to add a category 
     73     */ 
     74    private JMenuItem menuSend; 
    6075 
    6176    public static void main(String[] args) { 
     
    7893        fieldPath.addMouseListener(this); 
    7994        tree = new JTree(root); 
    80         tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); 
     95        tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); 
    8196        tree.addTreeSelectionListener(this); 
    8297        tree.setCellRenderer(new MyTreeCellRenderer()); 
    8398        tree.setRootVisible(false); 
     99        tree.addMouseListener(this); 
    84100        JScrollPane treeView = new JScrollPane(tree); 
    85101        Dimension minimumSize = new Dimension(100, 50); 
     
    90106    } 
    91107 
     108    /** 
     109     * Method that reload the tree 
     110     */ 
    92111    public void reload() { 
    93112        root.removeAllChildren(); 
     
    96115    } 
    97116 
     117    /** 
     118     * This method creates filters the files to display depending on their 
     119     * extension (only image files) 
     120     * @param root 
     121     */ 
    98122    private void createNodes(DefaultMutableTreeNode root) { 
    99123        DefaultMutableTreeNode fileNode = null; 
     
    103127            ArrayList<File> filter = new ArrayList<File>(); 
    104128            for (File file : fls) { 
     129                //only png and jpg are displayed 
    105130                if ((file.isDirectory() && !(file.getName().charAt(0) == '.')) 
    106131                        || (file.isFile() && ((file.getName().toLowerCase().endsWith(".jpg") 
     
    110135                } 
    111136            } 
     137            //call to the method that creates the files hierarchy 
    112138            for (File file : filter) { 
    113139                fileNode = new DefaultMutableTreeNode(file); 
     
    154180 
    155181    @Override 
    156     public void mouseClicked(MouseEvent arg0) { 
    157         if (arg0.getSource().equals(fieldPath)) { 
     182    public void mouseClicked(MouseEvent mouseEvent) { 
     183        if (mouseEvent.getSource().equals(fieldPath)) { 
    158184            JFileChooser chooser = new JFileChooser(); 
    159185            chooser.setCurrentDirectory(new java.io.File(path)); 
     
    166192            } 
    167193        } 
     194 
     195        if (mouseEvent.getButton() == 3) { 
     196            filesToSend = new ArrayList<File>(); 
     197            TreePath treePath[] = tree.getSelectionPaths(); 
     198            for (TreePath treeP : treePath) { 
     199                DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeP.getLastPathComponent(); 
     200                File file = (File) node.getUserObject(); 
     201                filesToSend.add(file); 
     202            } 
     203            JPopupMenu popup = new JPopupMenu(); 
     204            menuSend = new JMenuItem("Envoyer"); 
     205            menuSend.addActionListener(this); 
     206            popup.add(menuSend); 
     207            popup.show(tree, mouseEvent.getX(), mouseEvent.getY()); 
     208        } 
    168209    } 
    169210 
     
    196237    } 
    197238 
     239    @Override 
     240    public void actionPerformed(ActionEvent paramActionEvent) { 
     241        if (paramActionEvent.getSource().equals(menuSend)) { 
     242            //first, the dialog that allows to choose the privacy level of the photo(s) is called 
     243            if (!ImagesManagement.getInstance().isRememberPrivacyLevel()) { 
     244                new DialogPrivacyLevel(); 
     245            } 
     246            //then the dialog that allow to choose the category is called 
     247            new DialogChooseCategory(filesToSend); 
     248        } 
     249    } 
     250 
    198251} 
Note: See TracChangeset for help on using the changeset viewer.