r1081 - in trunk: coser-business/src/main/java/fr/ifremer/coser coser-business/src/main/java/fr/ifremer/coser/bean coser-business/src/main/java/fr/ifremer/coser/services coser-ui/src/main/java/fr/ifremer/coser/ui coser-ui/src/main/java/fr/ifremer/coser/ui/result coser-ui/src/main/java/fr/ifremer/coser/ui/selection coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model coser-ui/src/main/resources/i18n
Author: echatellier Date: 2012-10-30 10:50:42 +0100 (Tue, 30 Oct 2012) New Revision: 1081 Url: http://forge.codelutin.com/repositories/revision/coser/1081 Log: fixes #1613: Inclure le fichier reftax dans l'export rsufi fixes #1615: Archivage des autres fichiers d'entr?\195?\169e de RSUFI Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionFilesView.jaxx trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/FileListModel.java Removed: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/OtherDataFileListModel.java Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/CoserConstants.java trunk/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResultPath.java trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionAddResultDialog.jaxx trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionEditResultDialog.jaxx trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionRsufiView.jaxx trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/CoserConstants.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/CoserConstants.java 2012-10-29 15:16:15 UTC (rev 1080) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/CoserConstants.java 2012-10-30 09:50:42 UTC (rev 1081) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric + * Copyright (C) 2010 - 2012 Ifremer, Codelutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -59,6 +59,9 @@ /** Nom du dossier de sauvegarde des selections. */ public static final String STORAGE_SELECTION_DIRECTORY = "selections"; + /** Nom du dossier de stockage des autres fichier de la selection a inclure dans l'export rsufi. */ + public static final String STORAGE_SELECTION_FILES = "others"; + /** Nom du dossier des resultats RSufi. */ public static final String STORAGE_RESULTS_DIRECTORY = "results"; @@ -66,7 +69,7 @@ public static final String STORAGE_MAPS_DIRECTORY = "maps"; /** Nom du dossier de stockage des autres fichier de resultats rsufi. */ - public static final String STORAGE_OTHERS_DIRECTORY = "others"; + public static final String STORAGE_RESULT_FILES = "others"; /** Suffix des nom de fichiers data apres control. */ public static final String STORAGE_CONTROL_SUFFIX = "_co"; Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResultPath.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResultPath.java 2012-10-29 15:16:15 UTC (rev 1080) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResultPath.java 2012-10-30 09:50:42 UTC (rev 1081) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2011 Ifremer, Codelutin, Chatellier Eric + * Copyright (C) 2011 - 2012 Ifremer, Codelutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -106,8 +106,7 @@ if (!(obj instanceof RSufiResultPath)) { result = false; - } - else { + } else { RSufiResultPath other = (RSufiResultPath)obj; result &= project.getName().equals(other.project.getName()); result &= selection.getName().equals(other.selection.getName()); Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java 2012-10-29 15:16:15 UTC (rev 1080) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java 2012-10-30 09:50:42 UTC (rev 1081) @@ -25,6 +25,7 @@ package fr.ifremer.coser.bean; +import java.io.File; import java.util.Collections; import java.util.List; import java.util.Properties; @@ -93,6 +94,9 @@ protected boolean validated; + /** Liste des nom de fichiers/dossier present dans other files */ + protected List<File> otherFiles; + protected List<RSufiResult> rsufiResults; public Selection() { @@ -261,6 +265,14 @@ getPropertyChangeSupport().firePropertyChange("selectedSpeciesMaturityComment", oldValue, selectedSpeciesMaturityComment); } + public List<File> getOtherFiles() { + return otherFiles; + } + + public void setOtherFiles(List<File> otherFiles) { + this.otherFiles = otherFiles; + } + public boolean isValidated() { return validated; } Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2012-10-29 15:16:15 UTC (rev 1080) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2012-10-30 09:50:42 UTC (rev 1081) @@ -476,7 +476,17 @@ } finally { IOUtils.closeQuietly(inputStream); } - + + // other files dir + File othersDir = new File(selectionDirectory, CoserConstants.STORAGE_SELECTION_FILES); + List<File> otherFiles = new ArrayList<File>(); + if (othersDir.isDirectory()) { + for (File file : othersDir.listFiles()) { + otherFiles.add(file); + } + } + selection.setOtherFiles(otherFiles); + List<RSufiResult> rsufiResults = loadRSufiResults(selectionDirectory); selection.setRsufiResults(rsufiResults); @@ -539,7 +549,7 @@ rsufiResult.setMapsAvailable(mapsDir.isDirectory()); // other files dir - File othersDir = new File(resultDirectory, CoserConstants.STORAGE_OTHERS_DIRECTORY); + File othersDir = new File(resultDirectory, CoserConstants.STORAGE_RESULT_FILES); List<File> otherFiles = new ArrayList<File>(); if (othersDir.isDirectory()) { for (File file : othersDir.listFiles()) { @@ -1135,7 +1145,7 @@ } // sauvegarde des fichiers autre - File otherFilesDirectory = new File(rsufiResultDirectory, CoserConstants.STORAGE_OTHERS_DIRECTORY); + File otherFilesDirectory = new File(rsufiResultDirectory, CoserConstants.STORAGE_RESULT_FILES); for (File othersFile : othersFiles) { if (othersFile.isDirectory()) { FileUtils.copyDirectoryToDirectory(othersFile, otherFilesDirectory); @@ -1156,7 +1166,7 @@ rsufiResult.setMapsAvailable(mapsDir.isDirectory()); // update other files list - File othersDir = new File(rsufiResultDirectory, CoserConstants.STORAGE_OTHERS_DIRECTORY); + File othersDir = new File(rsufiResultDirectory, CoserConstants.STORAGE_RESULT_FILES); List<File> otherFiles = new ArrayList<File>(); if (othersDir.isDirectory()) { for (File file : othersDir.listFiles()) { @@ -1188,7 +1198,7 @@ File selectionDirectory = new File(selectionsDirectory, selection.getName()); File resultsDirectory = new File(selectionDirectory, CoserConstants.STORAGE_RESULTS_DIRECTORY); File rsufiResultDirectory = new File(resultsDirectory, rsufiResult.getName()); - File otherFilesDirectory = new File(rsufiResultDirectory, CoserConstants.STORAGE_OTHERS_DIRECTORY); + File otherFilesDirectory = new File(rsufiResultDirectory, CoserConstants.STORAGE_RESULT_FILES); // property file try { @@ -1211,10 +1221,9 @@ } } // update other files list - File othersDir = new File(rsufiResultDirectory, CoserConstants.STORAGE_OTHERS_DIRECTORY); List<File> otherFiles = new ArrayList<File>(); - if (othersDir.isDirectory()) { - for (File file : othersDir.listFiles()) { + if (otherFilesDirectory.isDirectory()) { + for (File file : otherFilesDirectory.listFiles()) { otherFiles.add(file); } } @@ -2849,15 +2858,15 @@ public File extractRSUfiData(Project project, Selection selection, File directory, boolean onlyDataTable) throws CoserBusinessException { // Nommer le dossier RSUFI_DATA_nomduprojet.... - File projectDirectory = new File(directory, "RSUFI_DATA_" + project.getName()); - projectDirectory.mkdirs(); + File exportDirectory = new File(directory, "RSUFI_DATA_" + project.getName()); + exportDirectory.mkdirs(); // extract 4 data files for (Category category : Category.values()) { if (category.isDataCategory()) { // originals names without suffix String storageFileName = commonService.getDataStorageFileName(project, category, null); - File dataFile = new File(projectDirectory, storageFileName); + File dataFile = new File(exportDirectory, storageFileName); if (log.isDebugEnabled()) { log.debug("Saving selection file : " + dataFile); } @@ -2870,11 +2879,11 @@ if (!onlyDataTable) { // extract additionnal data file (selected species) - File listSpeciesFile = new File(projectDirectory, "ListEspeces" + project.getName() + ".txt"); + File listSpeciesFile = new File(exportDirectory, "ListEspeces" + project.getName() + ".txt"); fillListSpeciesFile(selection, listSpeciesFile); // extract additionnal project information - File informationFile = new File(projectDirectory, "project.txt"); + File informationFile = new File(exportDirectory, "project.txt"); PrintStream out = null; try { out = new PrintStream(new BufferedOutputStream(new FileOutputStream(informationFile))); @@ -2888,6 +2897,20 @@ DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT, config.getLocale()); out.println(_("coser.business.extract.creationdate") + dateFormat.format(project.getCreationDate())); + // add selection additional files + File projectsDirectory = config.getProjectsDirectory(); + File projectDirectory = new File(projectsDirectory, project.getName()); + File selectionsDirectory = new File(projectDirectory, CoserConstants.STORAGE_SELECTION_DIRECTORY); + File selectionDirectory = new File(selectionsDirectory, selection.getName()); + File otherFilesDirectory = new File(selectionDirectory, CoserConstants.STORAGE_SELECTION_FILES); + if (otherFilesDirectory.isDirectory()) { + FileUtils.copyDirectoryToDirectory(otherFilesDirectory, exportDirectory); + } + + // add reftax + File reftaxFile = new File(projectDirectory, CoserConstants.Category.REFTAX_SPECIES.getStorageFileName()); + FileUtils.copyFileToDirectory(reftaxFile, exportDirectory); + } catch (IOException ex) { throw new CoserBusinessException("Can't save project information file", ex); } @@ -2896,7 +2919,7 @@ } } - return projectDirectory; + return exportDirectory; } /** @@ -3189,47 +3212,54 @@ return CoserUtils.sortByValue(speciesMap); } - /* - * Retourne le nom d'affichage d'une espèce pour l'utilisateur suivant - * les préférences qu'il a choisit. + /** + * Save existing rsufi result. * - * @param project le projet pour avoir accès au reftax - * @param speciesId le code a retranscrire - * @return display name - * @since 1.3 - * - public String getSpeciesDisplayField(Project project, String speciesId) { + * @param project project + * @param selection selection + * @param rsufiResult new result to save + * @throws CoserBusinessException + * @since 1.4 + */ + public void editSelectionOptions(Project project, Selection selection, List<File> othersFile) throws CoserBusinessException { - // "C_Perm";"NumSys";"NivSys";"C_VALIDE";"L_VALIDE";"AA_VALIDE";"C_TxPère";"Taxa" - int index = -1; - switch (project.getStorageSpeciesType()) { - case C_Valide: - index = ((ReftaxMemoryDataStorage)project.getRefTaxSpecies()).indexOfCValide(speciesId); - break; - case C_PERM: - index = ((ReftaxMemoryDataStorage)project.getRefTaxSpecies()).indexOfCode(speciesId); - break; - case L_Valide: - index = ((ReftaxMemoryDataStorage)project.getRefTaxSpecies()).indexOfLValide(speciesId); - break; - } + File projectsDirectory = config.getProjectsDirectory(); + File projectDirectory = new File(projectsDirectory, project.getName()); + File selectionsDirectory = new File(projectDirectory, CoserConstants.STORAGE_SELECTION_DIRECTORY); + File selectionDirectory = new File(selectionsDirectory, selection.getName()); + File otherFilesDirectory = new File(selectionDirectory, CoserConstants.STORAGE_SELECTION_FILES); - String speciesText = speciesId; - if (index >= 0) { - String[] data = project.getRefTaxSpecies().get(index); - switch (project.getDisplaySpeciesType()) { - case C_Valide: - speciesText = data[3]; - break; - case C_PERM: - speciesText = data[0]; - break; - case L_Valide: - speciesText = data[4]; - break; + // property file + try { + saveProjectSelection(project, selection); + + // remove some files + Collection<File> toDeletes = CollectionUtils.subtract(selection.getOtherFiles(), othersFile); + for (File toDelete : toDeletes) { + FileUtils.deleteQuietly(toDelete); } + // copy new file + for (File otherFile : othersFile) { + // non modified result, skipping it + if (!otherFile.getAbsolutePath().startsWith(otherFilesDirectory.getAbsolutePath())) { + if (otherFile.isDirectory()) { + FileUtils.copyDirectoryToDirectory(otherFile, otherFilesDirectory); + } else { + FileUtils.copyFileToDirectory(otherFile, otherFilesDirectory); + } + } + } + // update other files list + List<File> otherFiles = new ArrayList<File>(); + if (otherFilesDirectory.isDirectory()) { + for (File file : otherFilesDirectory.listFiles()) { + otherFiles.add(file); + } + } + selection.setOtherFiles(otherFiles); + + } catch (IOException ex) { + throw new CoserBusinessException("Can't edit result", ex); } - - return speciesText; - }*/ + } } Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2012-10-29 15:16:15 UTC (rev 1080) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2012-10-30 09:50:42 UTC (rev 1081) @@ -42,7 +42,6 @@ import javax.swing.filechooser.FileFilter; import jaxx.runtime.JAXXContext; -import jaxx.runtime.JAXXUtil; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/OtherDataFileListModel.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/OtherDataFileListModel.java 2012-10-29 15:16:15 UTC (rev 1080) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/OtherDataFileListModel.java 2012-10-30 09:50:42 UTC (rev 1081) @@ -1,85 +0,0 @@ -/* - * #%L - * - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2010 - 2012 Ifremer, Codelutin, Chatellier Eric - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -package fr.ifremer.coser.ui.result; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.AbstractListModel; - -/** - * Modele de list pour la list des fichiers et répertoire des fichiers - * additionnels. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class OtherDataFileListModel extends AbstractListModel { - - /** serialVersionUID. */ - private static final long serialVersionUID = -8652851018076968539L; - - protected List<File> otherFiles; - - public OtherDataFileListModel() { - otherFiles = new ArrayList<File>(); - } - - public List<File> getOtherFiles() { - return otherFiles; - } - - public void setOtherFiles(List<File> otherFiles) { - this.otherFiles = otherFiles; - fireContentsChanged(this, 0, otherFiles.size() - 1); - } - - public void add(File file) { - otherFiles.add(file); - fireIntervalAdded(this, otherFiles.size() - 1, otherFiles.size() - 1); - } - - public void remove(File file) { - int index = otherFiles.indexOf(file); - if (otherFiles.remove(file)) { - fireIntervalRemoved(this, index, index); - } - } - - @Override - public int getSize() { - return otherFiles.size(); - } - - @Override - public Object getElementAt(int index) { - return otherFiles.get(index); - } -} Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionAddResultDialog.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionAddResultDialog.jaxx 2012-10-29 15:16:15 UTC (rev 1080) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionAddResultDialog.jaxx 2012-10-30 09:50:42 UTC (rev 1081) @@ -143,7 +143,7 @@ <row> <cell columns="3" weighty="1" fill="both"> <JScrollPane> - <OtherDataFileListModel id="otherDataFileListModel" /> + <fr.ifremer.coser.ui.selection.model.FileListModel id="otherDataFileListModel" /> <JList id="otherDataFileList" model="{otherDataFileListModel}"/> </JScrollPane> </cell> Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionEditResultDialog.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionEditResultDialog.jaxx 2012-10-29 15:16:15 UTC (rev 1080) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionEditResultDialog.jaxx 2012-10-30 09:50:42 UTC (rev 1081) @@ -85,7 +85,7 @@ <row> <cell columns="2" weighty="1" fill="both"> <JScrollPane> - <OtherDataFileListModel id="otherDataFileListModel" /> + <fr.ifremer.coser.ui.selection.model.FileListModel id="otherDataFileListModel" /> <JList id="otherDataFileList" model="{otherDataFileListModel}"/> <ListSelectionModel javaBean="otherDataFileList.getSelectionModel()" onValueChanged="removeOtherFile.setEnabled(getOtherDataFileList().getSelectedIndex() != -1)" /> @@ -102,7 +102,8 @@ </cell> <cell> <JButton id="removeOtherFile" text="coser.ui.result.removeOtherDataFile" - onActionPerformed="getHandler().removeSelectedFile(this)"/> + onActionPerformed="getHandler().removeSelectedFile(this)" + enabled="false"/> </cell> <cell weightx="1" anchor="east"> <JButton text="coser.ui.result.cancel" Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionFilesView.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionFilesView.jaxx (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionFilesView.jaxx 2012-10-30 09:50:42 UTC (rev 1081) @@ -0,0 +1,68 @@ +<!-- + #%L + Coser :: UI + + $Id$ + $HeadURL$ + %% + Copyright (C) 2012 Ifremer, Codelutin, Chatellier Eric + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JDialog title="coser.ui.selection.option.editFilesTitle" modal="true"> + <SelectionHandler id="handler" javaBean="null" /> + <Table> + <row> + <cell fill="horizontal"> + <JLabel text="coser.ui.selection.option.filesDetails" /> + </cell> + </row> + <row> + <cell weighty="1" fill="both"> + <JScrollPane> + <fr.ifremer.coser.ui.selection.model.FileListModel id="selectionFilesListModel" /> + <JList id="selectionFilesList" model="{selectionFilesListModel}" + onValueChanged="removeOtherFile.setEnabled(getSelectionFilesList().getSelectedIndex() != -1)" /> + </JScrollPane> + </cell> + </row> + <row> + <cell fill="horizontal" insets="0"> + <Table> + <row> + <cell> + <JButton text="coser.ui.selection.option.addSelectionFile" + onActionPerformed="getHandler().selectResultFileOrDirectory(this, selectionFilesList)"/> + </cell> + <cell> + <JButton id="removeOtherFile" text="coser.ui.selection.option.removeSelectionFile" + onActionPerformed="getHandler().removeSelectedFile(this)" + enabled="false"/> + </cell> + <cell weightx="1" anchor="east"> + <JButton text="coser.ui.result.cancel" + onActionPerformed="dispose()"/> + </cell> + <cell> + <JButton id="saveResultButton" text="coser.ui.selection.option.validSelectionFiles" + onActionPerformed="getHandler().performSaveSelectionFiles(this)"/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> +</JDialog> Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2012-10-29 15:16:15 UTC (rev 1080) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2012-10-30 09:50:42 UTC (rev 1081) @@ -72,6 +72,7 @@ import fr.ifremer.coser.bean.Selection; import fr.ifremer.coser.services.ProjectService; import fr.ifremer.coser.services.PublicationService; +import fr.ifremer.coser.ui.CoserFrameHandler.SelectionFileFilter; import fr.ifremer.coser.ui.common.DataHandler; import fr.ifremer.coser.ui.common.SpeciesListRenderer; import fr.ifremer.coser.ui.control.ControlGraphFrame; @@ -1341,7 +1342,7 @@ Project project = view.getContextValue(Project.class); Selection selection = view.getContextValue(Selection.class); ProjectService projectService = view.getContextValue(ProjectService.class); - List<File> otherFiles = view.getOtherDataFileListModel().getOtherFiles(); + List<File> otherFiles = view.getOtherDataFileListModel().getFiles(); RSufiResult newResult = view.getRsufiResult(); @@ -1372,7 +1373,7 @@ // TODO chatellier 20101121 il ne faudrait pas que ca soit le // meme, sinon meme en annulant il est modifié editResultView.setRsufiResult(result); - editResultView.getOtherDataFileListModel().setOtherFiles(new ArrayList<File>(result.getOtherFiles())); + editResultView.getOtherDataFileListModel().setFiles(new ArrayList<File>(result.getOtherFiles())); editResultView.setHandler(this); editResultView.pack(); editResultView.setLocationRelativeTo(view); @@ -1391,7 +1392,7 @@ RSufiResult editedResult = view.getRsufiResult(); try { - List<File> newOthersFile = view.getOtherDataFileListModel().getOtherFiles(); + List<File> newOthersFile = view.getOtherDataFileListModel().getFiles(); projectService.editRsufiResults(project, selection, editedResult, newOthersFile); } catch (CoserBusinessException ex) { @@ -1545,7 +1546,25 @@ view.getOtherDataFileListModel().add(selectedFile); } } + + /** + * Select other files (file or directory). + * + * @param view view + * @param listComponent list component to set selected file + */ + public void selectResultFileOrDirectory(SelectionFilesView view, JList listComponent) { + CoserConfig config = view.getContextValue(CoserConfig.class); + JFileChooser selectFileChooser = getFileChooserInstance(config.getProjectsDirectory()); + selectFileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); + int result = selectFileChooser.showOpenDialog(view); + if (result == JFileChooser.APPROVE_OPTION) { + File selectedFile = selectFileChooser.getSelectedFile(); + view.getSelectionFilesListModel().add(selectedFile); + } + } + /** * Remove selected file in other file list. * @@ -1558,6 +1577,17 @@ } /** + * Remove selected file in other file list. + * + * @param view + * @since 1.4 + */ + public void removeSelectedFile(SelectionFilesView view) { + File selectedFile = (File)view.getSelectionFilesList().getSelectedValue(); + view.getSelectionFilesListModel().remove(selectedFile); + } + + /** * Genere le log des modifications faites lors du control en HTML * et l'ouvre dans le navigateur systeme. * @@ -1576,4 +1606,42 @@ throw new CoserException("Can't generate html report", ex); } } + + /** + * Affiche la dialog de modification des fichiers d'une selection. + * (appelée depuis l'onglet rsufi) + * + * @param view parent view + * @since 1.4 + */ + public void showSelectionFilesEdit(SelectionRsufiView view) { + Selection selection = view.getContextValue(Selection.class); + + SelectionFilesView selectionFilesView = new SelectionFilesView(view); + selectionFilesView.getSelectionFilesListModel().setFiles(new ArrayList<File>(selection.getOtherFiles())); + selectionFilesView.setHandler(this); + selectionFilesView.pack(); + selectionFilesView.setLocationRelativeTo(view); + selectionFilesView.setVisible(true); + } + + /** + * Sauvegarde des options de la selection. + * + * @param view view containing option + */ + public void performSaveSelectionFiles(SelectionFilesView view) { + Project project = view.getContextValue(Project.class); + Selection selection = view.getContextValue(Selection.class); + ProjectService projectService = view.getContextValue(ProjectService.class); + + try { + List<File> newOthersFile = view.getSelectionFilesListModel().getFiles(); + projectService.editSelectionOptions(project, selection, newOthersFile); + } + catch (CoserBusinessException ex) { + JOptionPane.showMessageDialog(view, ex.getMessage(), _("coser.ui.result.saveError"), JOptionPane.ERROR_MESSAGE); + } + view.dispose(); + } } Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionRsufiView.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionRsufiView.jaxx 2012-10-29 15:16:15 UTC (rev 1080) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionRsufiView.jaxx 2012-10-30 09:50:42 UTC (rev 1081) @@ -32,6 +32,18 @@ <SelectionHandler id="handler" javaBean="null" /> <row> <cell weightx="1" fill="horizontal"> + <Table border='{BorderFactory.createTitledBorder(_("coser.ui.selection.option.optionTitle"))}'> + <row> + <cell weightx="1" anchor="west"> + <JButton text="coser.ui.selection.option.editFiles" + onActionPerformed="getHandler().showSelectionFilesEdit(this)"/> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell weightx="1" fill="horizontal"> <Table border='{BorderFactory.createTitledBorder(_("coser.ui.result.extractDataTitle"))}'> <row> <cell> Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/FileListModel.java (from rev 1064, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/OtherDataFileListModel.java) =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/FileListModel.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/model/FileListModel.java 2012-10-30 09:50:42 UTC (rev 1081) @@ -0,0 +1,85 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 - 2012 Ifremer, Codelutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package fr.ifremer.coser.ui.selection.model; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.AbstractListModel; + +/** + * Modele de list pour la list des fichiers et répertoire des fichiers + * additionnels. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class FileListModel extends AbstractListModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = -8652851018076968539L; + + protected List<File> files; + + public FileListModel() { + files = new ArrayList<File>(); + } + + public List<File> getFiles() { + return files; + } + + public void setFiles(List<File> files) { + this.files = files; + fireContentsChanged(this, 0, files.size() - 1); + } + + public void add(File file) { + files.add(file); + fireIntervalAdded(this, files.size() - 1, files.size() - 1); + } + + public void remove(File file) { + int index = files.indexOf(file); + if (files.remove(file)) { + fireIntervalRemoved(this, index, index); + } + } + + @Override + public int getSize() { + return files.size(); + } + + @Override + public Object getElementAt(int index) { + return files.get(index); + } +} Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties =================================================================== --- trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2012-10-29 15:16:15 UTC (rev 1080) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2012-10-30 09:50:42 UTC (rev 1081) @@ -243,6 +243,13 @@ coser.ui.selection.nonJustifiedTitle=Unjustified selection coser.ui.selection.occurrenceDensitySpecies=L2 \: Filtered species (%d/%d) coser.ui.selection.occurrencedensityrenderer=<html>%s<span style\='font-size\:85%%;color\:gray;'>(Occ\=%.2f, Dens\=%.2f)</span></html> +coser.ui.selection.option.addSelectionFile=Add +coser.ui.selection.option.editFiles=Selection files +coser.ui.selection.option.editFilesTitle=Edit files +coser.ui.selection.option.filesDetails=This files will be saved into current selection and copied into RSufi export. +coser.ui.selection.option.optionTitle=Options +coser.ui.selection.option.removeSelectionFile=Remove +coser.ui.selection.option.validSelectionFiles=Save coser.ui.selection.reloadcontroldata=Reload controled data coser.ui.selection.replay.chooseselection=Choose selection to replay \: coser.ui.selection.replay.choosespecies=Choose species to keep \: Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties =================================================================== --- trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2012-10-29 15:16:15 UTC (rev 1080) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2012-10-30 09:50:42 UTC (rev 1081) @@ -243,6 +243,13 @@ coser.ui.selection.nonJustifiedTitle=Sélection non justifiée coser.ui.selection.occurrenceDensitySpecies=L2 \: Espèces filtrées (%d/%d) coser.ui.selection.occurrencedensityrenderer=<html>%s<span style\='font-size\:85%%;color\:gray;'>(Occ\=%.2f, Dens\=%.2f)</span></html> +coser.ui.selection.option.addSelectionFile=Ajouter +coser.ui.selection.option.editFiles=Fichiers de la sélection +coser.ui.selection.option.editFilesTitle=Modifier les fichiers +coser.ui.selection.option.filesDetails=Les fichiers suivants seront sauvegardés dans la sélection courante et copier dans l'export RSufi. +coser.ui.selection.option.optionTitle=Options +coser.ui.selection.option.removeSelectionFile=Supprimer +coser.ui.selection.option.validSelectionFiles=Sauver coser.ui.selection.reloadcontroldata=Recharger les données contrôlées coser.ui.selection.replay.chooseselection=Choisissez la sélection à rejouer \: coser.ui.selection.replay.choosespecies=Choisissez les espèces à conserver \:
participants (1)
-
echatellier@users.forge.codelutin.com