OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 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 30... Line 30...
30
import java.io.IOException;
30
import java.io.IOException;
31
import java.text.ChoiceFormat;
31
import java.text.ChoiceFormat;
32
import java.text.MessageFormat;
32
import java.text.MessageFormat;
33
import java.util.Collection;
33
import java.util.Collection;
34
import java.util.HashSet;
34
import java.util.HashSet;
-
 
35
import java.util.List;
35
import java.util.Set;
36
import java.util.Set;
36
 
37
 
37
import javax.swing.AbstractAction;
38
import javax.swing.AbstractAction;
38
import javax.swing.Action;
39
import javax.swing.Action;
39
import javax.swing.JComponent;
40
import javax.swing.JComponent;
Line 225... Line 226...
225
            public void handleFile(File f) {
226
            public void handleFile(File f) {
226
                if (!f.getName().endsWith(".jar")) {
227
                if (!f.getName().endsWith(".jar")) {
227
                    JOptionPane.showMessageDialog(panel, "Impossible d'installer le module. Le fichier n'est pas un module.");
228
                    JOptionPane.showMessageDialog(panel, "Impossible d'installer le module. Le fichier n'est pas un module.");
228
                    return;
229
                    return;
229
                }
230
                }
230
                final File dir = Gestion.MODULES_DIR;
231
                final List<File> dirs = panel.getModuleManager().getFolders();
231
                // TODO test symlink in Java 7
232
                final File dir = ModuleManager.getFolderToWrite(dirs);
232
                if (!dir.isDirectory()) {
233
                if (dir == null) {
233
                    if (dir.exists()) {
234
                    if (dirs.isEmpty()) {
234
                        JOptionPane.showMessageDialog(panel, "Le fichier existe mais n'est pas un dossier : " + dir.getAbsolutePath());
235
                        JOptionPane.showMessageDialog(panel, "Aucun dossier configuré");
235
                        return;
-
 
236
                    } else {
236
                    } else {
237
                        try {
-
 
238
                            FileUtils.mkdir_p(dir);
-
 
239
                        } catch (IOException e) {
-
 
240
                            JOptionPane.showMessageDialog(panel, "Impossible de créer le dossier des modules : " + dir.getAbsolutePath());
237
                        JOptionPane.showMessageDialog(panel, "Impossible de créer le dossier des modules : " + dirs);
241
                            return;
-
 
242
                        }
-
 
243
                    }
238
                    }
-
 
239
                    return;
244
                }
240
                }
245
                File out = null;
241
                File out = null;
246
                if (dir.canWrite()) {
242
                if (dir.canWrite()) {
247
                    try {
243
                    try {
248
                        out = new File(dir, f.getName());
244
                        out = new File(dir, f.getName());