source: extensions/jiwigo/trunk/src/main/java/fr/mael/jiwigo/ui/mainframe/thread/ThreadPhotoSending.java @ 8834

Last change on this file since 8834 was 8834, checked in by mlg, 13 years ago

New feature
Not totally implemented. This feature will allow the user to browse his system, searching for image files, to send them.
This is a new Panel where the user can choose the folder he wants to browse. Then a (recursive) tree of this folder is display so that the user can browse it. Only images (currently jpg and png) are displayed. When the user clicks on a file, the image is displayed in a panel. He can right click on the file to send the image to piwigo.

At the moment, the first part of the feature is implemented (but not fully tested) : the display of the file tree and the display of the image on click. (the images cannot be sent).

File size: 3.1 KB
Line 
1package fr.mael.jiwigo.ui.mainframe.thread;
2
3import java.io.File;
4
5import javax.swing.JOptionPane;
6
7import fr.mael.jiwigo.service.ImageService;
8import fr.mael.jiwigo.transverse.util.Messages;
9import fr.mael.jiwigo.ui.mainframe.MainFrame;
10import fr.mael.jiwigo.ui.mainframe.ThumbnailCategoryPanel;
11
12/**
13   Copyright (c) 2010, Mael
14   All rights reserved.
15
16   Redistribution and use in source and binary forms, with or without
17   modification, are permitted provided that the following conditions are met:
18    * Redistributions of source code must retain the above copyright
19      notice, this list of conditions and the following disclaimer.
20    * Redistributions in binary form must reproduce the above copyright
21      notice, this list of conditions and the following disclaimer in the
22      documentation and/or other materials provided with the distribution.
23    * Neither the name of jiwigo nor the
24      names of its contributors may be used to endorse or promote products
25      derived from this software without specific prior written permission.
26
27   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
28   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
29   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30   DISCLAIMED. IN NO EVENT SHALL Mael BE LIABLE FOR ANY
31   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
32   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
34   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 * @author mael
38 * Thread that send the photos
39 */
40public class ThreadPhotoSending implements Runnable {
41    private File[] files;
42    private ThumbnailCategoryPanel thumbPanel;
43
44    public ThreadPhotoSending(File[] files, ThumbnailCategoryPanel thumbPanel) {
45        this.files = files;
46        this.thumbPanel = thumbPanel;
47    }
48
49    @Override
50    public void run() {
51
52        for (int i = 0; i < files.length; i++) {
53            int nbProgressBar = ((i + 1) * 100) / files.length;
54            try {
55                MainFrame.getInstance().setAdditionalMessage(
56                        Messages.getMessage("file") + " " + (i + 1) + "/" + files.length + " : ");
57                ImageService.getInstance().creer(files[i].getCanonicalPath(), thumbPanel.getCategoryId());
58                MainFrame.getInstance().setMessage(files[i].getName() + " " + Messages.getMessage("sendingSuccess"));
59            } catch (Exception e) {
60                //displays a dialog if there is an error
61                JOptionPane.showMessageDialog(null, Messages.getMessage("sendingError") + files[i].getName(), Messages
62                        .getMessage("error"), JOptionPane.ERROR_MESSAGE);
63                MainFrame.getInstance().setMessage(Messages.getMessage("sendingError") + " " + files[i].getName());
64            } finally {
65                MainFrame.getInstance().getProgressBar().setValue(nbProgressBar);
66            }
67        }
68        MainFrame.getInstance().setAdditionalMessage("");
69        //refresh
70        thumbPanel.rafraichir(thumbPanel.getCategoryId(), true);
71        MainFrame.getInstance().getProgressBar().setValue(0);
72    }
73}
Note: See TracBrowser for help on using the repository browser.