Author: echatellier Date: 2012-08-14 11:26:57 +0200 (Tue, 14 Aug 2012) New Revision: 1042 Url: http://forge.codelutin.com/repositories/revision/coser/1042 Log: fixes #1327: Am?\195?\169liorer la gestion des ?\194?\171 autres fichiers ?\194?\187 lors de la modification Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/CoserExceptionHandler.java Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResult.java trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectHandler.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/OtherDataFileListModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ResultTableModel.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/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/bean/RSufiResult.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResult.java 2012-08-13 15:28:17 UTC (rev 1041) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResult.java 2012-08-14 09:26:57 UTC (rev 1042) @@ -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 @@ -25,7 +25,9 @@ package fr.ifremer.coser.bean; +import java.io.File; import java.util.Date; +import java.util.List; import java.util.Properties; /** @@ -66,8 +68,8 @@ /** Utilisé seulement dans l'ui de visu des resultats (presence de carte ou non). */ protected boolean mapsAvailable; - /** Utilisé seulement dans l'ui de visu des resultats (presence d'autres fichiers ou non). */ - protected boolean otherFilesAvailable; + /** Liste des nom de fichiers/dossier present dans other files */ + protected List<File> otherFiles; /** Result publiable. */ protected boolean publiableResult; @@ -186,12 +188,12 @@ this.mapsAvailable = mapsAvailable; } - public boolean isOtherFilesAvailable() { - return otherFilesAvailable; + public List<File> getOtherFiles() { + return otherFiles; } - public void setOtherFilesAvailable(boolean otherFilesAvailable) { - this.otherFilesAvailable = otherFilesAvailable; + public void setOtherFiles(List<File> otherFiles) { + this.otherFiles = otherFiles; } public void setPubliableResult(boolean publiableResult) { 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-08-13 15:28:17 UTC (rev 1041) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2012-08-14 09:26:57 UTC (rev 1042) @@ -538,7 +538,13 @@ // other files dir File othersDir = new File(resultDirectory, CoserConstants.STORAGE_OTHERS_DIRECTORY); - rsufiResult.setOtherFilesAvailable(othersDir.isDirectory()); + List<File> otherFiles = new ArrayList<File>(); + if (othersDir.isDirectory()) { + for (File file : othersDir.listFiles()) { + otherFiles.add(file); + } + } + rsufiResult.setOtherFiles(otherFiles); } } } @@ -1101,8 +1107,7 @@ // save it if (rsufiResultDirectory.exists()) { throw new CoserBusinessException(_("coser.business.result.rsufiResultAlreadyExists", rsufiResult.getName())); - } - else { + } else { rsufiResultDirectory.mkdirs(); // ensure creation date (modifiable par l'ui) @@ -1131,8 +1136,7 @@ for (File othersFile : othersFiles) { if (othersFile.isDirectory()) { FileUtils.copyDirectoryToDirectory(othersFile, otherFilesDirectory); - } - else { + } else { FileUtils.copyFileToDirectory(othersFile, otherFilesDirectory); } } @@ -1148,9 +1152,15 @@ File mapsDir = new File(rsufiResultDirectory, CoserConstants.STORAGE_MAPS_DIRECTORY); rsufiResult.setMapsAvailable(mapsDir.isDirectory()); - // other files dir + // update other files list File othersDir = new File(rsufiResultDirectory, CoserConstants.STORAGE_OTHERS_DIRECTORY); - rsufiResult.setOtherFilesAvailable(othersDir.isDirectory()); + List<File> otherFiles = new ArrayList<File>(); + if (othersDir.isDirectory()) { + for (File file : othersDir.listFiles()) { + otherFiles.add(file); + } + } + rsufiResult.setOtherFiles(otherFiles); List<RSufiResult> results = selection.getRsufiResults(); results.add(rsufiResult); @@ -1160,14 +1170,14 @@ } /** - * Save existing rsufi result (just save property file) + * Save existing rsufi result. * * @param project project * @param selection selection * @param rsufiResult new result to save * @throws CoserBusinessException */ - public void saveRsufiResults(Project project, Selection selection, RSufiResult rsufiResult) throws CoserBusinessException { + public void editRsufiResults(Project project, Selection selection, RSufiResult rsufiResult, List<File> othersFile) throws CoserBusinessException { File projectsDirectory = config.getProjectsDirectory(); File projectDirectory = new File(projectsDirectory, project.getName()); @@ -1175,13 +1185,45 @@ 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); // property file - saveRSufiResult(rsufiResultDirectory, rsufiResult); + try { + saveRSufiResult(rsufiResultDirectory, rsufiResult); + + // remove some files + Collection<File> toDeletes = CollectionUtils.subtract(rsufiResult.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 + File othersDir = new File(rsufiResultDirectory, CoserConstants.STORAGE_OTHERS_DIRECTORY); + List<File> otherFiles = new ArrayList<File>(); + if (othersDir.isDirectory()) { + for (File file : othersDir.listFiles()) { + otherFiles.add(file); + } + } + rsufiResult.setOtherFiles(otherFiles); - List<RSufiResult> results = selection.getRsufiResults(); - // this way to fire change event (do not remove) - selection.setRsufiResults(results); + List<RSufiResult> results = selection.getRsufiResults(); + // this way to fire change event (do not remove) + selection.setRsufiResults(results); + + } catch (IOException ex) { + throw new CoserBusinessException("Can't edit result", ex); + } } /** @@ -1205,7 +1247,7 @@ log.debug("Saving result properties file : " + propertiesFile); } } catch (IOException ex) { - throw new CoserBusinessException("Can't save result properties file", ex); + throw new CoserBusinessException("Can't save result", ex); } finally { IOUtils.closeQuietly(outputStream); } Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java 2012-08-13 15:28:17 UTC (rev 1041) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java 2012-08-14 09:26:57 UTC (rev 1042) @@ -25,7 +25,6 @@ package fr.ifremer.coser; import java.io.File; -import java.util.Map; import javax.swing.SwingUtilities; import javax.swing.UIManager; @@ -42,14 +41,12 @@ import com.bbn.openmap.MapBean; -import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.services.CommandService; import fr.ifremer.coser.services.ControlService; import fr.ifremer.coser.services.ProjectService; import fr.ifremer.coser.services.PublicationService; import fr.ifremer.coser.services.WebService; import fr.ifremer.coser.ui.CoserFrame; -import fr.ifremer.coser.ui.util.ErrorHelper; /** * Coser main class. @@ -64,6 +61,8 @@ private static final Log log = LogFactory.getLog(Coser.class); + protected static CoserConfig coserConfig; + /** * Coser main method. * @@ -72,7 +71,7 @@ public static void main(String... args) { // init config - final CoserConfig coserConfig = new CoserConfig(); + coserConfig = new CoserConfig(); try { coserConfig.parse(args); } catch (ArgumentsParserException ex) { @@ -87,15 +86,9 @@ // catch wall application exception launch(coserConfig); - Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { - public void uncaughtException(Thread t, Throwable ex) { - if (log.isErrorEnabled()) { - log.error("Global application exception", ex); - } - ErrorHelper errorHelper = new ErrorHelper(coserConfig); - errorHelper.showErrorDialog(null, ex.getMessage(), ex); - } - }); + // catch uncaught exceptions + Thread.setDefaultUncaughtExceptionHandler(new CoserExceptionHandler()); + System.setProperty("sun.awt.exception.handler", CoserExceptionHandler.class.getName()); } /** Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/CoserExceptionHandler.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/CoserExceptionHandler.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/CoserExceptionHandler.java 2012-08-14 09:26:57 UTC (rev 1042) @@ -0,0 +1,65 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 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; + +import java.lang.Thread.UncaughtExceptionHandler; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import fr.ifremer.coser.ui.util.ErrorHelper; + +/** + * Coser global exception handler. + * + * Catch all application uncaught and display it in a custom JoptionPane + * or JXErrorPane. + * + * See http://stackoverflow.com/a/4448569/1165234 for details. + * + * @author echatellier + * @since 1.3 + */ +public class CoserExceptionHandler implements UncaughtExceptionHandler { + + private static final Log log = LogFactory.getLog(CoserExceptionHandler.class); + + @Override + public void uncaughtException(Thread t, Throwable ex) { + handleException(t.getName(), ex); + } + + public void handle(Throwable thrown) { + // for EDT exceptions + handleException(Thread.currentThread().getName(), thrown); + } + + protected void handleException(String tname, Throwable ex) { + if (log.isErrorEnabled()) { + log.error("Global application exception", ex); + } + ErrorHelper errorHelper = new ErrorHelper(Coser.coserConfig); + errorHelper.showErrorDialog(null, ex.getMessage(), ex); + } +} Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/CoserExceptionHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL 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-08-13 15:28:17 UTC (rev 1041) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2012-08-14 09:26:57 UTC (rev 1042) @@ -427,8 +427,6 @@ setMainComponent(selectionView); } catch (CoserBusinessException ex) { - JOptionPane.showMessageDialog(view, ex.getMessage(), _("coser.ui.selection.createError"), - JOptionPane.ERROR_MESSAGE); throw new CoserException("Can't create new selection", ex); } finally { Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectHandler.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectHandler.java 2012-08-13 15:28:17 UTC (rev 1041) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectHandler.java 2012-08-14 09:26:57 UTC (rev 1042) @@ -25,6 +25,7 @@ import static org.nuiton.i18n.I18n._; +import java.awt.event.MouseEvent; import java.io.File; import java.util.HashMap; import java.util.List; @@ -307,7 +308,7 @@ * * @param projectView view */ - public void loadProject(final ProjectOpenView projectView) { + public void loadProject(ProjectOpenView projectView) { int selectedIndex = projectView.getProjectsList().getSelectedIndex(); String projectName = (String)projectView.getProjectsList().getModel().getElementAt(selectedIndex); @@ -329,4 +330,20 @@ setDefaultCursor(projectView); } } + + /** + * Reload project (name selected in ui). + * + * @param projectView view + * @param event mouse event + */ + public void loadProjectOnDoubleClick(ProjectOpenView projectView, MouseEvent event) { + + if (event.getButton() == MouseEvent.BUTTON1 && event.getClickCount() == 2) { + int selectedIndex = projectView.getProjectsList().getSelectedIndex(); + if (selectedIndex >= 0) { + loadProject(projectView); + } + } + } } Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx 2012-08-13 15:28:17 UTC (rev 1041) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectOpenView.jaxx 2012-08-14 09:26:57 UTC (rev 1042) @@ -38,7 +38,8 @@ <cell fill="both" weightx="1"> <JScrollPane> <JList id="projectsList" selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}" - model="{new fr.ifremer.coser.ui.project.ProjectNamesListModel(this)}" /> + model="{new fr.ifremer.coser.ui.project.ProjectNamesListModel(this)}" + onMouseClicked="getHandler().loadProjectOnDoubleClick(this, event)" /> </JScrollPane> </cell> </row> Modified: 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-08-13 15:28:17 UTC (rev 1041) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/OtherDataFileListModel.java 2012-08-14 09:26:57 UTC (rev 1042) @@ -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 General Public License as @@ -55,23 +55,29 @@ 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); } - /* - * @see javax.swing.ListModel#getSize() - */ + 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(); } - /* - * @see javax.swing.ListModel#getElementAt(int) - */ @Override public Object getElementAt(int index) { return otherFiles.get(index); Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ResultTableModel.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ResultTableModel.java 2012-08-13 15:28:17 UTC (rev 1041) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ResultTableModel.java 2012-08-14 09:26:57 UTC (rev 1042) @@ -131,7 +131,7 @@ result = rsufiResult.isMapsAvailable(); break; case 6: - result = rsufiResult.isOtherFilesAvailable(); + result = !rsufiResult.getOtherFiles().isEmpty(); break; } 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-08-13 15:28:17 UTC (rev 1041) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionAddResultDialog.jaxx 2012-08-14 09:26:57 UTC (rev 1042) @@ -149,7 +149,7 @@ </cell> </row> <row> - <cell columns="3" fill="horizontal"> + <cell columns="3" fill="horizontal" insets="0"> <Table> <row> <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-08-13 15:28:17 UTC (rev 1041) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionEditResultDialog.jaxx 2012-08-14 09:26:57 UTC (rev 1042) @@ -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 General Public License as @@ -22,7 +22,7 @@ <http://www.gnu.org/licenses/gpl-3.0.html>. #L% --> -<JDialog title="coser.ui.result.newResult" modal="true"> +<JDialog title="coser.ui.result.editResult" modal="true"> <Table> <fr.ifremer.coser.ui.selection.SelectionHandler id="handler" javaBean="null" /> @@ -78,10 +78,43 @@ </cell> </row> <row> - <cell columns="2" anchor="east"> - <JButton id="saveResultButton" text="coser.ui.result.validEditResult" - onActionPerformed="getHandler().performEditResult(this)"/> + <cell anchor="west" columns="2"> + <JLabel text="coser.ui.result.otherDataFile" /> </cell> </row> + <row> + <cell columns="2" weighty="1" fill="both"> + <JScrollPane> + <OtherDataFileListModel id="otherDataFileListModel" /> + <JList id="otherDataFileList" model="{otherDataFileListModel}"/> + <ListSelectionModel javaBean="otherDataFileList.getSelectionModel()" + onValueChanged="removeOtherFile.setEnabled(getOtherDataFileList().getSelectedIndex() != -1)" /> + </JScrollPane> + </cell> + </row> + <row> + <cell columns="2" fill="horizontal" weightx="1"> + <Table> + <row> + <cell> + <JButton text="coser.ui.result.addOtherDataFile" + onActionPerformed="getHandler().selectResultFileOrDirectory(this, otherDataFileList)"/> + </cell> + <cell> + <JButton id="removeOtherFile" text="coser.ui.result.removeOtherDataFile" + onActionPerformed="getHandler().removeSelectedFile(this)"/> + </cell> + <cell weightx="1" anchor="east"> + <JButton text="coser.ui.result.cancel" + onActionPerformed="dispose()"/> + </cell> + <cell> + <JButton id="saveResultButton" text="coser.ui.result.validEditResult" + onActionPerformed="getHandler().performEditResult(this)"/> + </cell> + </row> + </Table> + </cell> + </row> </Table> </JDialog> \ No newline at end of file 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-08-13 15:28:17 UTC (rev 1041) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2012-08-14 09:26:57 UTC (rev 1042) @@ -33,7 +33,6 @@ import java.awt.event.MouseEvent; import java.io.File; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashSet; @@ -1320,27 +1319,6 @@ } /** - * Show rsufi result edit dialog with selected rsufiresult. - * - * @param view view - */ - public void showEditResultDialog(SelectionRsufiView view) { - - // get selected rsufi result - int selectedRow = view.getSelectionResultsTable().getSelectedRow(); - RSufiResult result = view.getSelectionResultsTableModel().getValue(selectedRow); - - SelectionEditResultDialog editResultView = new SelectionEditResultDialog(view); - // TODO chatellier 20101121 il ne faudrait pas que ca soit le - // meme, sinon meme en annulant il est modifié - editResultView.setRsufiResult(result); - editResultView.setHandler(this); - editResultView.pack(); - editResultView.setLocationRelativeTo(view); - editResultView.setVisible(true); - } - - /** * Save new result after clicking "ok" button on SelectionAddResultDialog * opened by {@link #showAddResultDialog(SelectionRsufiView)}. * @@ -1362,7 +1340,6 @@ } catch (CoserBusinessException ex) { JOptionPane.showMessageDialog(view, ex.getMessage(), _("coser.ui.result.saveError"), JOptionPane.ERROR_MESSAGE); - throw new CoserException("Can't save result", ex); } finally { setDefaultCursor(view); @@ -1371,6 +1348,28 @@ } /** + * Show rsufi result edit dialog with selected rsufiresult. + * + * @param view view + */ + public void showEditResultDialog(SelectionRsufiView view) { + + // get selected rsufi result + int selectedRow = view.getSelectionResultsTable().getSelectedRow(); + RSufiResult result = view.getSelectionResultsTableModel().getValue(selectedRow); + + SelectionEditResultDialog editResultView = new SelectionEditResultDialog(view); + // 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.setHandler(this); + editResultView.pack(); + editResultView.setLocationRelativeTo(view); + editResultView.setVisible(true); + } + + /** * Save edited result (only save properties file). * * @param view view @@ -1382,11 +1381,11 @@ RSufiResult editedResult = view.getRsufiResult(); try { - projectService.saveRsufiResults(project, selection, editedResult); + List<File> newOthersFile = view.getOtherDataFileListModel().getOtherFiles(); + projectService.editRsufiResults(project, selection, editedResult, newOthersFile); } catch (CoserBusinessException ex) { JOptionPane.showMessageDialog(view, ex.getMessage(), _("coser.ui.result.saveError"), JOptionPane.ERROR_MESSAGE); - throw new CoserException("Can't save result", ex); } view.dispose(); } @@ -1500,7 +1499,7 @@ textComponent.setText(selectedFile.getAbsolutePath()); } } - + /** * Select other files (file or directory). * @@ -1520,6 +1519,35 @@ } /** + * Select other files (file or directory). + * + * @param view view + * @param listComponent list component to set selected file + */ + public void selectResultFileOrDirectory(SelectionEditResultDialog 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.getOtherDataFileListModel().add(selectedFile); + } + } + + /** + * Remove selected file in other file list. + * + * @param view + * @since 1.3 + */ + public void removeSelectedFile(SelectionEditResultDialog view) { + File selectedFile = (File)view.getOtherDataFileList().getSelectedValue(); + view.getOtherDataFileListModel().remove(selectedFile); + } + + /** * Genere le log des modifications faites lors du control en HTML * et l'ouvre dans le navigateur systeme. * 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-08-13 15:28:17 UTC (rev 1041) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2012-08-14 09:26:57 UTC (rev 1042) @@ -164,6 +164,7 @@ coser.ui.result.newResult=New Result coser.ui.result.otherDataFile=Other files \: coser.ui.result.publiableResult=Publiable \: +coser.ui.result.removeOtherDataFile=Remove file coser.ui.result.requiredestComIndPath= coser.ui.result.requiredestPopIndPath= coser.ui.result.requiredname= @@ -184,7 +185,6 @@ coser.ui.result.zone=Zone \: coser.ui.selection.allSpecies=L1 \: All species (%d/%d) coser.ui.selection.comment=Comment \: -coser.ui.selection.createError=Creation error coser.ui.selection.detail.confirmcontrolreload=Are you sure you want to reload controled data ?\nAll modifications done on current selection will be lost. coser.ui.selection.detail.controldatareloaded=Controled data reloaded. coser.ui.selection.detail.mainAccordion=Details 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-08-13 15:28:17 UTC (rev 1041) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2012-08-14 09:26:57 UTC (rev 1042) @@ -164,6 +164,7 @@ coser.ui.result.newResult=Nouveau résultat coser.ui.result.otherDataFile=Autre fichiers \: coser.ui.result.publiableResult=Publiable \: +coser.ui.result.removeOtherDataFile=Supprimer le fichier coser.ui.result.requiredestComIndPath= coser.ui.result.requiredestPopIndPath= coser.ui.result.requiredname= @@ -184,7 +185,6 @@ coser.ui.result.zone=Zone \: coser.ui.selection.allSpecies=L1 \: Toutes les espèces (%d/%d) coser.ui.selection.comment=Commentaire \: -coser.ui.selection.createError=Erreur de créaction coser.ui.selection.detail.confirmcontrolreload=Êtes vous sûr de vouloir recharger les données contrôlées ?\nToutes les modifications de la sélection en cours seront perdues. coser.ui.selection.detail.controldatareloaded=Données contrôlées rechargées. coser.ui.selection.detail.mainAccordion=Détails