OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 180 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 180 Rev 182
Line 1... Line 1...
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
9
 * language governing permissions and limitations under the License.
Line 24... Line 24...
24
import org.openconcerto.utils.ExceptionHandler;
24
import org.openconcerto.utils.ExceptionHandler;
25
import org.openconcerto.utils.FileUtils;
25
import org.openconcerto.utils.FileUtils;
26
 
26
 
27
import java.awt.Color;
27
import java.awt.Color;
28
import java.awt.Component;
28
import java.awt.Component;
-
 
29
import java.awt.Desktop;
29
import java.awt.Dimension;
30
import java.awt.Dimension;
30
import java.awt.FileDialog;
31
import java.awt.FileDialog;
31
import java.awt.FlowLayout;
32
import java.awt.FlowLayout;
32
import java.awt.Frame;
33
import java.awt.Frame;
33
import java.awt.GridBagConstraints;
34
import java.awt.GridBagConstraints;
Line 41... Line 42...
41
import java.awt.event.ActionListener;
42
import java.awt.event.ActionListener;
42
import java.awt.event.MouseAdapter;
43
import java.awt.event.MouseAdapter;
43
import java.awt.event.MouseEvent;
44
import java.awt.event.MouseEvent;
44
import java.io.File;
45
import java.io.File;
45
import java.io.IOException;
46
import java.io.IOException;
-
 
47
import java.net.URI;
-
 
48
import java.net.URISyntaxException;
46
import java.sql.SQLException;
49
import java.sql.SQLException;
47
import java.util.ArrayList;
50
import java.util.ArrayList;
48
import java.util.Collection;
51
import java.util.Collection;
49
import java.util.Collections;
52
import java.util.Collections;
50
import java.util.Comparator;
53
import java.util.Comparator;
Line 210... Line 213...
210
        toolbar.setLayout(new FlowLayout(FlowLayout.LEFT));
213
        toolbar.setLayout(new FlowLayout(FlowLayout.LEFT));
211
        final JButton addFolderButton = new JButton("Nouveau dossier");
214
        final JButton addFolderButton = new JButton("Nouveau dossier");
212
        toolbar.add(addFolderButton);
215
        toolbar.add(addFolderButton);
213
        final JButton addFileButton = new JButton("Ajouter un fichier");
216
        final JButton addFileButton = new JButton("Ajouter un fichier");
214
        toolbar.add(addFileButton);
217
        toolbar.add(addFileButton);
-
 
218
        final JButton addURLButton = new JButton("Ajouter une URL");
-
 
219
        toolbar.add(addURLButton);
215
 
220
 
216
        final JProgressBar progressBar = new JProgressBar(0, 100);
221
        final JProgressBar progressBar = new JProgressBar(0, 100);
217
        progressBar.setValue(100);
222
        progressBar.setValue(100);
218
        progressBar.setStringPainted(true);
223
        progressBar.setStringPainted(true);
219
        progressBar.setVisible(false);
224
        progressBar.setVisible(false);
Line 258... Line 263...
258
                    }
263
                    }
259
                }
264
                }
260
            }
265
            }
261
        });
266
        });
262
 
267
 
-
 
268
        addURLButton.addActionListener(new ActionListener() {
-
 
269
	        @Override
-
 
270
	        public void actionPerformed(ActionEvent e) {
-
 
271
	            final Frame frame = SwingThreadUtils.getAncestorOrSelf(Frame.class, (Component) e.getSource());
-
 
272
	            final String fileName = JOptionPane.showInputDialog(frame, "Veuillez entrer votre URL");
-
 
273
	
-
 
274
	            if (fileName != null) {
-
 
275
	                AttachmentUtils utils = new AttachmentUtils();
-
 
276
	                try {
-
 
277
	                    utils.createURL(fileName, rowSource, idParent);
-
 
278
	                } catch (SQLException e1) {
-
 
279
	                    JOptionPane.showMessageDialog(null, "Impossible de créer l'URL.", "Erreur", JOptionPane.ERROR_MESSAGE);
-
 
280
	                }
-
 
281
	                initUI();
-
 
282
	            }
-
 
283
	        }
-
 
284
	    });
-
 
285
 
263
        ScrollablePanel files = new ScrollablePanel() {
286
        ScrollablePanel files = new ScrollablePanel() {
264
            @Override
287
            @Override
265
            public Dimension getPreferredSize() {
288
            public Dimension getPreferredSize() {
266
                int w = getSize().width;
289
                int w = getSize().width;
267
                int nbPerRow = (w - 5) / (FilePanel.PREFERRED_WIDTH + 5);
290
                int nbPerRow = (w - 5) / (FilePanel.PREFERRED_WIDTH + 5);
Line 308... Line 331...
308
                @Override
331
                @Override
309
                public void mousePressed(MouseEvent e) {
332
                public void mousePressed(MouseEvent e) {
310
                    if (e.getClickCount() == 2) {
333
                    if (e.getClickCount() == 2) {
311
                        if (a.isFolder()) {
334
                        if (a.isFolder()) {
312
                            openFolder(a);
335
                            openFolder(a);
-
 
336
                        } else if( a.getMimeType().equals(Attachment.MIMETYPE_URL) ) {
-
 
337
                            try {
-
 
338
                                Desktop.getDesktop().browse(new URI(a.getFileName()));
-
 
339
                            } catch (IOException | URISyntaxException e1) {
-
 
340
                                ExceptionHandler.handle("Malformation URL", e1);
-
 
341
                            }
313
                        } else {
342
                        } else {
314
                            final Thread t = new Thread() {
343
                            final Thread t = new Thread() {
315
                                @Override
344
                                @Override
316
                                public void run() {
345
                                public void run() {
317
                                    AttachmentUtils utils = new AttachmentUtils();
346
                                    AttachmentUtils utils = new AttachmentUtils();