Author: chatellier Date: 2010-12-01 10:05:08 +0000 (Wed, 01 Dec 2010) New Revision: 316 Log: Add edit and close project actions Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectEditView.jaxx Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectCreationView.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/services/ProjectService.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-12-01 09:59:03 UTC (rev 315) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-12-01 10:05:08 UTC (rev 316) @@ -216,6 +216,27 @@ } } + saveProject(project); + + // init additional structures (load empty control) + project.setSelections(new HashMap<String, Selection>()); + control.setHistoryCommand(new ArrayList<Command>()); + project.setControl(control); + + return project; + } + + /** + * Sauve seulement les informations concernant le projet. + * + * @param project + * @throws CoserBusinessException + */ + public void saveProject(Project project) throws CoserBusinessException { + File projectsDirectory = config.getProjectsDirectory(); + String projectName = project.getName(); + File projectDirectory = new File(projectsDirectory, projectName); + // save project properties file File propertiesFile = new File(projectDirectory, "project.properties"); Properties props = project.toProperties(); @@ -233,13 +254,6 @@ finally { IOUtils.closeQuietly(outputStream); } - - // init additional structures (load empty control) - project.setSelections(new HashMap<String, Selection>()); - control.setHistoryCommand(new ArrayList<Command>()); - project.setControl(control); - - return project; } /** Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx 2010-12-01 09:59:03 UTC (rev 315) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx 2010-12-01 10:05:08 UTC (rev 316) @@ -26,16 +26,16 @@ name="mainFrame" onWindowClosing="getHandler().quit()"> <CoserFrameHandler id="handler" constructorParams="this" /> + <fr.ifremer.coser.bean.Project id="project" javaBean="null" /> <JMenuBar id='coserMenuBar'> <JMenu id='menuFile' text="coser.ui.mainframe.menu.file"> <JMenuItem text="coser.ui.mainframe.menu.newProject" onActionPerformed="getHandler().showProjectCreationView()"/> <JMenuItem text="coser.ui.mainframe.menu.openProject" onActionPerformed="getHandler().showProjectOpenView()"/> + <JMenuItem text="coser.ui.mainframe.menu.editProject" onActionPerformed="getHandler().showProjectEditView()" enabled="{getProject() != null}" /> + <JMenuItem text="coser.ui.mainframe.menu.closeProject" onActionPerformed="getHandler().closeProject()" enabled="{getProject() != null}" /> <JSeparator/> - <JMenuItem actionIcon="i18n-fr" text="coser.ui.mainframe.menu.locale.fr" onActionPerformed="getHandler().switchLanguage(this, Locale.FRANCE)"/> - <JMenuItem actionIcon="i18n-gb" text="coser.ui.mainframe.menu.locale.uk" onActionPerformed="getHandler().switchLanguage(this, Locale.UK)"/> - <JSeparator/> <JMenuItem text="coser.ui.mainframe.menu.quit" onActionPerformed="getHandler().quit()"/> </JMenu> @@ -49,6 +49,9 @@ <JMenu id='menuOptions' text="coser.ui.mainframe.menu.options"> <JMenuItem text="coser.ui.mainframe.menu.configuration" onActionPerformed="getHandler().showCoserConfiguration()"/> <JMenuItem text="coser.ui.mainframe.menu.validators" onActionPerformed="getHandler().showValidatorsConfiguration()"/> + <JSeparator/> + <JMenuItem actionIcon="i18n-fr" text="coser.ui.mainframe.menu.locale.fr" onActionPerformed="getHandler().switchLanguage(this, Locale.FRANCE)"/> + <JMenuItem actionIcon="i18n-gb" text="coser.ui.mainframe.menu.locale.uk" onActionPerformed="getHandler().switchLanguage(this, Locale.UK)"/> </JMenu> <JMenu id='menuView' text="coser.ui.mainframe.menu.view"> 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 2010-12-01 09:59:03 UTC (rev 315) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2010-12-01 10:05:08 UTC (rev 316) @@ -60,6 +60,7 @@ import fr.ifremer.coser.ui.control.ControlHandler; import fr.ifremer.coser.ui.control.ControlView; import fr.ifremer.coser.ui.project.ProjectCreationView; +import fr.ifremer.coser.ui.project.ProjectEditView; import fr.ifremer.coser.ui.project.ProjectOpenView; import fr.ifremer.coser.ui.project.ProjectSummaryView; import fr.ifremer.coser.ui.selection.SelectionHandler; @@ -120,6 +121,17 @@ } /** + * Display new open view in main view. + */ + public void showProjectEditView() { + Project project = view.getProject(); + ProjectEditView projectEditView = new ProjectEditView(view); + projectEditView.setHandler(this); + projectEditView.setProject(project); + setMainComponent(projectEditView); + } + + /** * Replace window main component. * * @param component new component @@ -312,6 +324,23 @@ } /** + * Sauve le projet apres edition. + * + * @param view view + */ + public void saveProject(ProjectEditView view) { + Project project = view.getProject(); + ProjectService projectService = view.getContextValue(ProjectService.class); + try { + projectService.saveProject(project); + showSummaryView(); + } + catch (CoserBusinessException ex) { + throw new CoserException("Can't save project", ex); + } + } + + /** * Reload project (name selected in ui). * * @param projectView view @@ -334,9 +363,18 @@ } /** + * Ferme le projet. + */ + public void closeProject() { + setMainComponent(null); + view.setProject(null); + } + + /** * Do some operation when a new project is loaded into application. */ protected void projectLoaded(Project project) { + view.setProject(project); view.setContextValue(project); view.getMenuWindow().setEnabled(true); view.getMenuWindowSelectionMenuItem().setProject(project); Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectCreationView.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectCreationView.jaxx 2010-12-01 09:59:03 UTC (rev 315) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectCreationView.jaxx 2010-12-01 10:05:08 UTC (rev 316) @@ -63,7 +63,7 @@ <JLabel text='{getContextValue(fr.ifremer.coser.CoserConfig.class).getProjectsDirectory().getAbsolutePath() + File.separator}' /> </cell> <cell anchor="west" weightx="1" fill="horizontal"> - <JTextField id="projectProjectName" text="{project.getName()}" /> + <JTextField id="projectProjectName" text="{getProject().getName()}" /> <javax.swing.text.Document javaBean="projectProjectName.getDocument()" onInsertUpdate='getProject().setName(projectProjectName.getText())' onRemoveUpdate='getProject().setName(projectProjectName.getText())' /> @@ -75,7 +75,7 @@ <JLabel text="coser.ui.project.projectauthor" /> </cell> <cell weightx="1" fill="horizontal" columns="2"> - <JTextField id="projectAuthor" text="{project.getAuthor()}" /> + <JTextField id="projectAuthor" text="{getProject().getAuthor()}" /> <javax.swing.text.Document javaBean="projectAuthor.getDocument()" onInsertUpdate='getProject().setAuthor(projectAuthor.getText())' onRemoveUpdate='getProject().setAuthor(projectAuthor.getText())' /> @@ -87,7 +87,7 @@ <JLabel text="coser.ui.project.catchFile" /> </cell> <cell weightx="1" fill="horizontal" columns="2"> - <JTextField id="projectCatchFile" text="{project.getCatchFile()}" /> + <JTextField id="projectCatchFile" text="{getProject().getCatchFile()}" /> <javax.swing.text.Document javaBean="projectCatchFile.getDocument()" onInsertUpdate='getProject().setCatchFile(projectCatchFile.getText())' onRemoveUpdate='getProject().setCatchFile(projectCatchFile.getText())' /> @@ -102,7 +102,7 @@ <JLabel text="coser.ui.project.strataFile" /> </cell> <cell fill="horizontal" columns="2"> - <JTextField id="projectStrataFile" text="{project.getStrataFile()}" /> + <JTextField id="projectStrataFile" text="{getProject().getStrataFile()}" /> <javax.swing.text.Document javaBean="projectStrataFile.getDocument()" onInsertUpdate='getProject().setStrataFile(projectStrataFile.getText())' onRemoveUpdate='getProject().setStrataFile(projectStrataFile.getText())' /> @@ -117,7 +117,7 @@ <JLabel text="coser.ui.project.lengthFile" /> </cell> <cell fill="horizontal" columns="2"> - <JTextField id="projectLengthFile" text="{project.getLengthFile()}" /> + <JTextField id="projectLengthFile" text="{getProject().getLengthFile()}" /> <javax.swing.text.Document javaBean="projectLengthFile.getDocument()" onInsertUpdate='getProject().setLengthFile(projectLengthFile.getText())' onRemoveUpdate='getProject().setLengthFile(projectLengthFile.getText())' /> @@ -132,7 +132,7 @@ <JLabel text="coser.ui.project.haulFile" /> </cell> <cell fill="horizontal" columns="2"> - <JTextField id="projectHaulFile" text="{project.getHaulFile()}" /> + <JTextField id="projectHaulFile" text="{getProject().getHaulFile()}" /> <javax.swing.text.Document javaBean="projectHaulFile.getDocument()" onInsertUpdate='getProject().setHaulFile(projectHaulFile.getText())' onRemoveUpdate='getProject().setHaulFile(projectHaulFile.getText())' /> Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectEditView.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectEditView.jaxx (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/project/ProjectEditView.jaxx 2010-12-01 10:05:08 UTC (rev 316) @@ -0,0 +1,88 @@ +<!-- + #%L + Coser :: UI + + $Id$ + $HeadURL$ + %% + Copyright (C) 2010 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% + --> +<Table> + <fr.ifremer.coser.ui.CoserFrameHandler id="handler" javaBean="null" /> + + <!-- Validation --> + <fr.ifremer.coser.bean.Project id="project" javaBean="null" /> + <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errorsTableModel' + onTableChanged='saveProjectButton.setEnabled(errorsTableModel.getRowCount()==0)'/> + <BeanValidator id='validatorProject' bean='project' + uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI" + errorTableModel="errorsTableModel"> + <field name="name" component="projectProjectName" /> + <field name="author" component="projectAuthor" /> + </BeanValidator> + + <row> + <cell weightx="1" fill="horizontal"> + <Table border='{BorderFactory.createTitledBorder(_("coser.ui.project.editProject"))}'> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.projectname" /> + </cell> + <cell> + <JLabel text='{getContextValue(fr.ifremer.coser.CoserConfig.class).getProjectsDirectory().getAbsolutePath() + File.separator}' /> + </cell> + <cell anchor="west" weightx="1" fill="horizontal"> + <JTextField id="projectProjectName" enabled="false" text="{getProject().getName()}" /> + </cell> + </row> + <row> + <cell anchor="west"> + <JLabel text="coser.ui.project.projectauthor" /> + </cell> + <cell weightx="1" fill="horizontal" columns="2"> + <JTextField id="projectAuthor" text="{getProject().getAuthor()}" /> + <javax.swing.text.Document javaBean="projectAuthor.getDocument()" + onInsertUpdate='getProject().setAuthor(projectAuthor.getText())' + onRemoveUpdate='getProject().setAuthor(projectAuthor.getText())' /> + + </cell> + </row> + <row> + <cell anchor="northwest"> + <JLabel text="coser.ui.project.projectcomment" /> + </cell> + <cell fill="horizontal" columns="2"> + <JScrollPane> + <JTextArea id="projectComment" rows="3" text="{getProject().getComment()}"/> + </JScrollPane> + <javax.swing.text.Document javaBean="projectComment.getDocument()" + onInsertUpdate='getProject().setComment(projectComment.getText())' + onRemoveUpdate='getProject().setComment(projectComment.getText())' /> + + </cell> + </row> + <row> + <cell columns="4" anchor="east"> + <JButton id="saveProjectButton" text="coser.ui.project.saveProject" + onActionPerformed="getHandler().saveProject(this)" /> + </cell> + </row> + </Table> + </cell> + </row> +</Table> 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 2010-12-01 09:59:03 UTC (rev 315) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2010-12-01 10:05:08 UTC (rev 316) @@ -59,6 +59,7 @@ coser.ui.graph.lengthStructure=Length structure coser.ui.locale.mustRestart=You must restart application to take effect coser.ui.locale.title=Locale modification +coser.ui.mainframe.menu.closeProject=Close project coser.ui.mainframe.menu.configuration=Configuration coser.ui.mainframe.menu.data=Data coser.ui.mainframe.menu.data.control=Control @@ -68,6 +69,7 @@ coser.ui.mainframe.menu.data.replaySelection=Replay selection coser.ui.mainframe.menu.data.selections=S\u00E9lections coser.ui.mainframe.menu.data.summary=Summary +coser.ui.mainframe.menu.editProject=Edit project coser.ui.mainframe.menu.file=File coser.ui.mainframe.menu.locale.fr=Fran\u00E7ais coser.ui.mainframe.menu.locale.uk=English @@ -85,6 +87,7 @@ coser.ui.project.createProjectMissingReftax=File 'Reftax' is not valid \!\n(check configuration \: coser.reference.species) coser.ui.project.creationError=Creation error coser.ui.project.customReferenceSpeciesFile=New reference file \: +coser.ui.project.editProject=Edit project coser.ui.project.haulFile=Haul file \: coser.ui.project.lengthFile=Length file \: coser.ui.project.missingFile=Missing file @@ -96,6 +99,7 @@ coser.ui.project.projectauthor=Author \: coser.ui.project.projectcomment=Comment \: coser.ui.project.projectname=Project name \: +coser.ui.project.saveProject=Save project coser.ui.project.strataFile=Strata file \: coser.ui.project.summary.path=Project path \: coser.ui.project.summary.title=Project summary 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 2010-12-01 09:59:03 UTC (rev 315) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2010-12-01 10:05:08 UTC (rev 316) @@ -59,6 +59,7 @@ coser.ui.graph.lengthStructure=Structures en taille coser.ui.locale.mustRestart=Vous devez red\u00E9marrer l'application pour prendre en compte la modification. coser.ui.locale.title=Modification de la langue +coser.ui.mainframe.menu.closeProject=Fermer le projet coser.ui.mainframe.menu.configuration=Configuration coser.ui.mainframe.menu.data=Donn\u00E9es coser.ui.mainframe.menu.data.control=Contr\u00F4le @@ -68,6 +69,7 @@ coser.ui.mainframe.menu.data.replaySelection=Rejouer une s\u00E9lection coser.ui.mainframe.menu.data.selections=S\u00E9lections coser.ui.mainframe.menu.data.summary=R\u00E9sum\u00E9 +coser.ui.mainframe.menu.editProject=Modifier le projet coser.ui.mainframe.menu.file=Fichier coser.ui.mainframe.menu.locale.fr=Fran\u00E7ais coser.ui.mainframe.menu.locale.uk=English @@ -85,6 +87,7 @@ coser.ui.project.createProjectMissingReftax=Le fichier 'Reftax' n'est pas valide \!\n(v\u00E9rifiez la configuration \: coser.reference.species) coser.ui.project.creationError=Erreur de cr\u00E9ation coser.ui.project.customReferenceSpeciesFile=Nouveau fichier de r\u00E9f\u00E9rence \: +coser.ui.project.editProject=Modifier le projet coser.ui.project.haulFile=Fichier des traits \: coser.ui.project.lengthFile=Fichier des tailles \: coser.ui.project.missingFile=Fichier manquant @@ -96,6 +99,7 @@ coser.ui.project.projectauthor=Auteur \: coser.ui.project.projectcomment=Commentaire \: coser.ui.project.projectname=Nom du projet \: +coser.ui.project.saveProject=Sauver le projet coser.ui.project.strataFile=Fichier des strates \: coser.ui.project.summary.path=Chemin du projet \: coser.ui.project.summary.title=R\u00E9sum\u00E9 du projet